KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > infoglue > deliver > taglib > content > RemoteContentServiceTag


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

18
19 public class RemoteContentServiceTag extends TemplateControllerTag
20 {
21     /**
22      * The universal version identifier.
23      */

24     private static final long serialVersionUID = -1904980538720103871L;
25
26     /**
27      * The list of contents that should be stored.
28      */

29     private List JavaDoc contents = new ArrayList JavaDoc();
30     
31     /**
32      *
33      */

34     private String JavaDoc name;
35     
36     /**
37      *
38      */

39     private String JavaDoc targetEndpointAddress;
40     
41     /**
42      *
43      */

44     private String JavaDoc operationName;
45     
46     /**
47      *
48      */

49     private InfoGluePrincipal principal;
50     
51     /**
52      *
53      */

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

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

73    public int doEndTag() throws JspException JavaDoc
74    {
75        try
76        {
77            if(this.principal == null)
78                this.principal = this.getController().getPrincipal();
79            
80            final DynamicWebservice ws = new DynamicWebservice(principal);
81           
82            ws.setTargetEndpointAddress(targetEndpointAddress);
83            ws.setOperationName(operationName);
84            ws.setReturnType(Boolean JavaDoc.class);
85            
86            //List contents = new ArrayList();
87
//Map content = new HashMap();
88
//content.put("name", "Mattias Testar");
89
//contents.add(content);
90

91            ws.addArgument("contents", contents);
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        contents.clear();
103
104        return EVAL_PAGE;
105    }
106    
107    /**
108     *
109     */

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

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

126    public void setPrincipal(final String JavaDoc principalString) throws JspException JavaDoc
127    {
128        this.principal = (InfoGluePrincipal) this.evaluate("remoteContentService", "principal", principalString, InfoGluePrincipal.class);
129    }
130
131    /**
132     * Add the content the child tag generated to the list of contents that are to be persisted.
133     */

134    /*
135    public void addContent(final ContentVO contentVO)
136    {
137        //Map contentMap = new HashMap();
138        //contentMap.put("name", "Kalle" + contentVO.getName());
139        //this.contents.add(contentMap);
140        this.contents.add(contentVO);
141    }
142    */

143    
144    /**
145     * Add the content the child tag generated to the list of contents that are to be persisted.
146     */

147    public void addContentMap(final Map JavaDoc contentMap)
148    {
149        this.contents.add(contentMap);
150    }
151
152 }
Popular Tags