1 24 package org.ofbiz.minilang.method.entityops; 25 26 import org.ofbiz.base.util.Debug; 27 import org.ofbiz.entity.transaction.GenericTransactionException; 28 import org.ofbiz.entity.transaction.TransactionUtil; 29 import org.ofbiz.minilang.SimpleMethod; 30 import org.ofbiz.minilang.method.ContextAccessor; 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 TransactionBegin extends MethodOperation { 43 44 public static final String module = TransactionBegin.class.getName(); 45 46 ContextAccessor beganTransactionAcsr; 47 48 public TransactionBegin(Element element, SimpleMethod simpleMethod) { 49 super(element, simpleMethod); 50 beganTransactionAcsr = new ContextAccessor(element.getAttribute("began-transaction-name"), "beganTransaction"); 51 } 52 53 public boolean exec(MethodContext methodContext) { 54 boolean beganTransaction = false; 55 try { 56 beganTransaction = TransactionUtil.begin(); 57 } catch (GenericTransactionException e) { 58 Debug.logError(e, "Could not begin transaction in simple-method, returning error.", module); 59 60 String errMsg = "ERROR: Could not complete the " + simpleMethod.getShortDescription() + " process [error beginning a transaction: " + e.getMessage() + "]"; 61 methodContext.setErrorReturn(errMsg, simpleMethod); 62 return false; 63 } 64 65 beganTransactionAcsr.put(methodContext, new Boolean (beganTransaction)); 66 return true; 67 } 68 69 public String rawString() { 70 return "<transaction-begin/>"; 72 } 73 public String expandedString(MethodContext methodContext) { 74 return this.rawString(); 76 } 77 } 78 | Popular Tags |