1 24 package org.ofbiz.minilang.method.entityops; 25 26 import org.ofbiz.base.util.Debug; 27 import org.ofbiz.base.util.GeneralException; 28 import org.ofbiz.entity.GenericDelegator; 29 import org.ofbiz.entity.finder.PrimaryKeyFinder; 30 import org.ofbiz.minilang.SimpleMethod; 31 import org.ofbiz.minilang.method.MethodContext; 32 import org.ofbiz.minilang.method.MethodOperation; 33 import org.w3c.dom.Element ; 34 35 42 public class EntityOne extends MethodOperation { 43 44 public static final String module = EntityOne.class.getName(); 45 46 protected PrimaryKeyFinder finder; 47 48 public EntityOne(Element element, SimpleMethod simpleMethod) { 49 super(element, simpleMethod); 50 this.finder = new PrimaryKeyFinder(element); 51 } 52 53 public boolean exec(MethodContext methodContext) { 54 try { 55 GenericDelegator delegator = methodContext.getDelegator(); 56 this.finder.runFind(methodContext.getEnvMap(), delegator); 57 } catch (GeneralException e) { 58 Debug.logError(e, module); 59 String errMsg = "ERROR: Could not complete the " + simpleMethod.getShortDescription() + " process: " + e.getMessage(); 60 61 if (methodContext.getMethodType() == MethodContext.EVENT) { 62 methodContext.putEnv(simpleMethod.getEventErrorMessageName(), errMsg); 63 methodContext.putEnv(simpleMethod.getEventResponseCodeName(), simpleMethod.getDefaultErrorCode()); 64 } else if (methodContext.getMethodType() == MethodContext.SERVICE) { 65 methodContext.putEnv(simpleMethod.getServiceErrorMessageName(), errMsg); 66 methodContext.putEnv(simpleMethod.getServiceResponseMessageName(), simpleMethod.getDefaultErrorCode()); 67 } 68 return false; 69 } 70 return true; 71 } 72 73 public String rawString() { 74 return "<entity-one/>"; 76 } 77 public String expandedString(MethodContext methodContext) { 78 return this.rawString(); 80 } 81 } 82 83 | Popular Tags |