KickJava   Java API By Example, From Geeks To Geeks.

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


1 package org.infoglue.deliver.taglib.content;
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.security.InfoGluePrincipal;
12 import org.infoglue.cms.webservices.elements.RemoteAttachment;
13
14 /**
15  * This tag helps update a content in the cms from the delivery application.
16  */

17
18 public class UpdateContentVersionTag extends InfoGlueWebServiceTag implements ContentVersionParameterInterface
19 {
20     /**
21      * The universal version identifier.
22      */

23     private static final long serialVersionUID = -1904980538720103871L;
24
25     /**
26      *
27      */

28     private String JavaDoc operationName = "updateContentVersion";
29
30     /**
31      * The map containing the content that should be updated.
32      */

33
34     private Map JavaDoc contentVersion = new HashMap JavaDoc();
35
36     private Integer JavaDoc contentVersionId;
37     private Integer JavaDoc stateId;
38     private String JavaDoc versionComment;
39     private Integer JavaDoc languageId;
40     private Integer JavaDoc contentId;
41     private String JavaDoc versionValue;
42
43     /**
44      *
45      */

46     private InfoGluePrincipal principal;
47
48     /**
49      *
50      */

51     public UpdateContentVersionTag()
52     {
53         super();
54     }
55
56     /**
57      * Initializes the parameters to make it accessible for the children tags
58      * (if any).
59      *
60      * @return indication of whether to evaluate the body or not.
61      * @throws JspException
62      * 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.contentVersionId != null)
77                 contentVersion.put("contentVersionId", this.contentVersionId);
78             if(this.contentId != null)
79                 contentVersion.put("contentId", this.contentId);
80             if(this.languageId != null)
81                 contentVersion.put("languageId", this.languageId);
82             if(this.stateId != null)
83                 contentVersion.put("stateId", this.stateId);
84             if(this.versionComment != null)
85                 contentVersion.put("versionComment", this.versionComment);
86             if(this.versionValue != null)
87                 contentVersion.put("versionValue", this.versionValue);
88                 
89             this.invokeOperation("contentVersion", contentVersion);
90         }
91         catch (Exception JavaDoc e)
92         {
93             e.printStackTrace();
94             throw new JspTagException JavaDoc(e.getMessage());
95         }
96
97         contentVersion.clear();
98         this.contentId = null;
99         this.contentVersionId = null;
100         this.languageId = null;
101         this.versionComment = null;
102         this.versionValue = null;
103         this.stateId = null;
104         
105         return EVAL_PAGE;
106     }
107
108     /**
109      * Adds the content version attribute to the contentVersion Value.
110      *
111      * @throws JspException if the ancestor tag isn't a url tag.
112      */

113     public void addContentVersionAttribute(String JavaDoc name, String JavaDoc value) throws JspException JavaDoc
114     {
115         Map JavaDoc contentVersionAttributes = (Map JavaDoc)this.contentVersion.get("contentVersionAttributes");
116         if(contentVersionAttributes == null)
117         {
118             contentVersionAttributes = new HashMap JavaDoc();
119             this.contentVersion.put("contentVersionAttributes", contentVersionAttributes);
120         }
121
122         contentVersionAttributes.put(name, value);
123     }
124
125     /**
126      * Adds the content version attribute to the contentVersion Value.
127      *
128      * @throws JspException if the ancestor tag isn't a url tag.
129      */

130     public void addDigitalAsset(RemoteAttachment remoteAttachment) throws JspException JavaDoc
131     {
132         List JavaDoc digitalAssets = (List JavaDoc)this.contentVersion.get("digitalAssets");
133         if(digitalAssets == null)
134         {
135             digitalAssets = new ArrayList JavaDoc();
136             this.contentVersion.put("digitalAssets", digitalAssets);
137         }
138
139         digitalAssets.add(remoteAttachment);
140     }
141
142     /**
143      *
144      */

145     public void setOperationName(final String JavaDoc operationName)
146     {
147         this.operationName = operationName;
148     }
149
150     /**
151      *
152      */

153     public void setPrincipal(final String JavaDoc principalString) throws JspException JavaDoc
154     {
155         this.principal = (InfoGluePrincipal) this.evaluate("remoteContentService", "principal", principalString, InfoGluePrincipal.class);
156     }
157
158     public void setContentVersionId(String JavaDoc contentVersionId) throws JspException JavaDoc
159     {
160         this.contentVersionId = evaluateInteger("updateContentVersion", "contentVersionId", contentVersionId);
161     }
162
163     public void setContentId(String JavaDoc contentId) throws JspException JavaDoc
164     {
165         this.contentId = evaluateInteger("updateContentVersion", "contentId", contentId);
166     }
167
168     public void setLanguageId(String JavaDoc languageId) throws JspException JavaDoc
169     {
170         this.languageId = evaluateInteger("updateContentVersion", "languageId", languageId);
171     }
172
173     public void setStateId(String JavaDoc stateId) throws JspException JavaDoc
174     {
175         this.stateId = evaluateInteger("updateContentVersion", "stateId", stateId);
176     }
177
178     public void setVersionComment(String JavaDoc versionComment) throws JspException JavaDoc
179     {
180         this.versionComment = evaluateString("updateContentVersion", "versionComment", versionComment);
181     }
182
183     public void setVersionValue(String JavaDoc versionValue) throws JspException JavaDoc
184     {
185         this.versionValue = evaluateString("updateContentVersion", "versionValue", versionValue);
186     }
187
188     public String JavaDoc getOperationName()
189     {
190         return this.operationName;
191     }
192 }
Popular Tags