1 24 package org.ofbiz.minilang.method.entityops; 25 26 import org.ofbiz.base.util.Debug; 27 import org.ofbiz.entity.GenericValue; 28 import org.ofbiz.minilang.SimpleMethod; 29 import org.ofbiz.minilang.method.ContextAccessor; 30 import org.ofbiz.minilang.method.MethodContext; 31 import org.ofbiz.minilang.method.MethodOperation; 32 import org.w3c.dom.Element ; 33 34 41 public class SetCurrentUserLogin extends MethodOperation { 42 43 public static final String module = SetCurrentUserLogin.class.getName(); 44 45 ContextAccessor valueAcsr; 46 47 public SetCurrentUserLogin(Element element, SimpleMethod simpleMethod) { 48 super(element, simpleMethod); 49 valueAcsr = new ContextAccessor(element.getAttribute("value-name")); 50 } 51 52 public boolean exec(MethodContext methodContext) { 53 GenericValue userLogin = (GenericValue) valueAcsr.get(methodContext); 54 if (userLogin == null) { 55 Debug.logWarning("In SetCurrentUserLogin a value was not found with the specified valueName: " + valueAcsr + ", not setting", module); 56 return true; 57 } 58 59 methodContext.setUserLogin(userLogin, this.simpleMethod.getUserLoginEnvName()); 60 return true; 61 } 62 63 public String rawString() { 64 return "<set-current-user-login/>"; 66 } 67 public String expandedString(MethodContext methodContext) { 68 return this.rawString(); 70 } 71 } 72 | Popular Tags |