1 package org.infoglue.deliver.taglib.content; 2 3 import java.util.ArrayList ; 4 import java.util.HashMap ; 5 import java.util.List ; 6 import java.util.Map ; 7 8 import javax.servlet.jsp.JspException ; 9 import javax.servlet.jsp.JspTagException ; 10 11 import org.infoglue.cms.security.InfoGluePrincipal; 12 import org.infoglue.cms.util.CmsPropertyHandler; 13 import org.infoglue.deliver.taglib.TemplateControllerTag; 14 import org.infoglue.deliver.util.webservices.DynamicWebservice; 15 16 19 20 public abstract class InfoGlueWebServiceTag extends TemplateControllerTag 21 { 22 25 private static final long serialVersionUID = -1904980538720103871L; 26 27 30 private String targetEndpointAddress = CmsPropertyHandler.getWebServicesBaseUrl() + "RemoteContentService"; 31 32 35 private InfoGluePrincipal principal; 36 37 40 public InfoGlueWebServiceTag() 41 { 42 super(); 43 } 44 45 46 49 public void setTargetEndpointAddress(final String targetEndpointAddress) throws JspException 50 { 51 this.targetEndpointAddress = evaluateString("infoGlueWebService", "targetEndpointAddress", targetEndpointAddress); 52 } 53 54 57 public void setPrincipal(final String principalString) throws JspException 58 { 59 this.principal = (InfoGluePrincipal) this.evaluate("infoGlueWebService", "principal", principalString, InfoGluePrincipal.class); 60 } 61 62 protected void invokeOperation(String name, Object argument) throws JspException 63 { 64 try 65 { 66 if (this.principal == null) 67 this.principal = this.getController().getPrincipal(); 68 69 final DynamicWebservice ws = new DynamicWebservice(principal); 70 71 ws.setTargetEndpointAddress(targetEndpointAddress); 72 ws.setOperationName(getOperationName()); 73 ws.setReturnType(Boolean .class); 74 75 if(argument instanceof Map || argument instanceof HashMap ) 76 ws.addArgument(name, (Map )argument); 77 else if(argument instanceof List || argument instanceof ArrayList ) 78 ws.addArgument(name, (List )argument); 79 else 80 ws.addArgument(name, argument); 81 82 ws.callService(); 83 setResultAttribute(ws.getResult()); 84 } 85 catch (Exception e) 86 { 87 e.printStackTrace(); 88 throw new JspTagException (e.getMessage()); 89 } 90 } 91 92 93 public String getTargetEndpointAddress() 94 { 95 return targetEndpointAddress; 96 } 97 98 public abstract void setOperationName(final String operationName); 99 100 public abstract String getOperationName(); 101 102 } | Popular Tags |