KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > infoglue > deliver > taglib > management > RemoteUserPropertiesServiceTag


1 package org.infoglue.deliver.taglib.management;
2
3 import java.util.ArrayList JavaDoc;
4 import java.util.HashMap JavaDoc;
5 import java.util.List JavaDoc;
6 import java.util.Map JavaDoc;
7
8 import javax.servlet.jsp.JspException JavaDoc;
9 import javax.servlet.jsp.JspTagException JavaDoc;
10
11 import org.infoglue.cms.entities.management.UserPropertiesVO;
12 import org.infoglue.cms.security.InfoGluePrincipal;
13 import org.infoglue.deliver.taglib.TemplateControllerTag;
14 import org.infoglue.deliver.util.webservices.DynamicWebservice;
15
16
17 /**
18  * This tag helps create a content in the cms from the delivery application.
19  */

20
21 public class RemoteUserPropertiesServiceTag extends TemplateControllerTag
22 {
23     /**
24      * The universal version identifier.
25      */

26     private static final long serialVersionUID = -1904980538720103871L;
27
28     /**
29      *
30      */

31     private String JavaDoc targetEndpointAddress;
32     
33     /**
34      *
35      */

36     private String JavaDoc operationName;
37     
38     /**
39      *
40      */

41     private InfoGluePrincipal principal;
42     
43     /**
44      *
45      */

46     private Integer JavaDoc languageId;
47     private Integer JavaDoc contentTypeDefinitionId;
48     private Map JavaDoc userPropertiesAttributesMap = new HashMap JavaDoc();
49     
50     /**
51      *
52      */

53     public RemoteUserPropertiesServiceTag()
54     {
55         super();
56     }
57
58     /**
59      * Initializes the parameters to make it accessible for the children tags (if any).
60      *
61      * @return indication of whether to evaluate the body or not.
62      * @throws JspException if an error occurred while processing this tag.
63      */

64     public int doStartTag() throws JspException JavaDoc
65     {
66         return EVAL_BODY_INCLUDE;
67     }
68
69     /**
70      *
71      */

72    public int doEndTag() throws JspException JavaDoc
73    {
74        try
75        {
76            if(this.principal == null)
77                this.principal = this.getController().getPrincipal();
78            
79            final DynamicWebservice ws = new DynamicWebservice(principal);
80           
81            ws.setTargetEndpointAddress(targetEndpointAddress);
82            ws.setOperationName(operationName);
83            ws.setReturnType(Boolean JavaDoc.class);
84                    
85            if(this.languageId == null)
86                ws.addArgument("languageId", this.getController().getLanguageId());
87            else
88                ws.addArgument("languageId", this.languageId);
89                    
90            ws.addArgument("contentTypeDefinitionId", this.contentTypeDefinitionId);
91            ws.addArgument("userPropertiesAttributesMap", userPropertiesAttributesMap);
92            
93            ws.callService();
94            setResultAttribute(ws.getResult());
95        }
96        catch(Exception JavaDoc e)
97        {
98            e.printStackTrace();
99            throw new JspTagException JavaDoc(e.getMessage());
100        }
101        
102        return EVAL_PAGE;
103    }
104    
105    /**
106     *
107     */

108    public void setTargetEndpointAddress(final String JavaDoc targetEndpointAddress) throws JspException JavaDoc
109    {
110        this.targetEndpointAddress = evaluateString("remoteContentService", "targetEndpointAddress", targetEndpointAddress);
111    }
112
113    /**
114     *
115     */

116    public void setOperationName(final String JavaDoc operationName)
117    {
118        this.operationName = operationName;
119    }
120
121    /**
122     *
123     */

124    public void setPrincipal(final String JavaDoc principalString) throws JspException JavaDoc
125    {
126        this.principal = (InfoGluePrincipal) this.evaluate("remoteContentService", "principal", principalString, InfoGluePrincipal.class);
127    }
128
129    /**
130     *
131     */

132    public void setLanguageId(final String JavaDoc languageIdString) throws JspException JavaDoc
133    {
134        this.languageId = this.evaluateInteger("remoteUserPropertiesService", "languageId", languageIdString);
135    }
136
137    /**
138     *
139     */

140    public void setContentTypeDefinitionId(final String JavaDoc contentTypeDefinitionIdString) throws JspException JavaDoc
141    {
142        this.contentTypeDefinitionId = this.evaluateInteger("remoteUserPropertiesService", "contentTypeDefinitionId", contentTypeDefinitionIdString);
143    }
144
145     /**
146      * Adds the content version attribute to the contentVersion Value.
147      *
148      * @throws JspException if the ancestor tag isn't a url tag.
149      */

150     public void addUserPropertiesAttribute(String JavaDoc name, String JavaDoc value) throws JspException JavaDoc
151     {
152         this.userPropertiesAttributesMap.put(name, value);
153     }
154
155 }
Popular Tags