1 package org.jpublish.action; 2 3 import java.util.HashMap ; 4 import java.util.Map ; 5 6 import com.anthonyeden.lib.config.Configuration; 7 import com.anthonyeden.lib.util.MessageUtilities; 8 import com.opensymphony.xwork.ActionProxy; 9 import com.opensymphony.xwork.ActionProxyFactory; 10 import org.jpublish.JPublishEngine; 11 import org.jpublish.JPublishRuntimeException; 12 import org.jpublish.RequestContext; 13 14 19 20 public class XWorkAction implements Action { 21 22 private String name = null; 23 private String namespace = null; 24 private boolean executeResult; 25 26 31 32 public String getName() { 33 return name; 34 } 35 36 41 42 public void setName(String name) { 43 this.name = name; 44 } 45 46 51 52 public String getNamespace() { 53 return namespace; 54 } 55 56 61 62 public void setNamespace(String namespace) { 63 this.namespace = namespace; 64 } 65 66 71 72 public boolean isExecuteResult() { 73 return executeResult; 74 } 75 76 81 82 public void setExecuteResult(boolean executeResult) { 83 this.executeResult = executeResult; 84 } 85 86 91 92 public void setExecuteResult(String executeResult) { 93 setExecuteResult("true".equals(executeResult)); 94 } 95 96 102 103 public void execute(RequestContext context, Configuration configuration) { 104 try { 105 Map extraContext = new HashMap (); 106 extraContext.put("requestContext", context); 107 extraContext.put("configuration", configuration); 108 109 ActionProxyFactory factory = ActionProxyFactory.getFactory(); 110 ActionProxy proxy = factory.createActionProxy(namespace, name, 111 extraContext, executeResult); 112 proxy.execute(); 113 } catch (Exception e) { 115 Object [] args = {name, namespace, e.getMessage()}; 116 String msg = MessageUtilities.getMessage(getClass(), 117 JPublishEngine.MESSAGE_PACKAGE, "actionInvocationError", args); 118 throw new JPublishRuntimeException(msg); 119 } 120 } 121 122 } 123 | Popular Tags |