KickJava   Java API By Example, From Geeks To Geeks.

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


1 /* ===============================================================================
2 *
3 * Part of the InfoGlue Content Management Platform (www.infoglue.org)
4 *
5 * ===============================================================================
6 *
7 * Copyright (C)
8 *
9 * This program is free software; you can redistribute it and/or modify it under
10 * the terms of the GNU General Public License version 2, as published by the
11 * Free Software Foundation. See the file LICENSE.html for more information.
12 *
13 * This program is distributed in the hope that it will be useful, but WITHOUT
14 * ANY WARRANTY, including the implied warranty of MERCHANTABILITY or FITNESS
15 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License along with
18 * this program; if not, write to the Free Software Foundation, Inc. / 59 Temple
19 * Place, Suite 330 / Boston, MA 02111-1307 / USA.
20 *
21 * ===============================================================================
22 */

23 package org.infoglue.deliver.taglib.content;
24
25 import java.util.ArrayList JavaDoc;
26 import java.util.HashMap JavaDoc;
27 import java.util.List JavaDoc;
28 import java.util.Map JavaDoc;
29
30 import javax.servlet.jsp.JspException JavaDoc;
31 import javax.servlet.jsp.JspTagException JavaDoc;
32
33 import org.infoglue.cms.webservices.elements.RemoteAttachment;
34 import org.infoglue.deliver.taglib.AbstractTag;
35
36 /**
37  * This class implements the <common:parameter> tag, which adds a parameter
38  * to the parameters of the parent tag.
39  *
40  * Note! This tag must have a <common:urlBuilder> ancestor.
41  */

42 public class ContentVersionParameterTag extends AbstractTag implements ContentVersionParameterInterface
43 {
44     /**
45      * The universal version identifier.
46      */

47     private static final long serialVersionUID = 4482006814634520239L;
48
49     /**
50      * The content version object.
51      */

52     private Map JavaDoc contentVersion = new HashMap JavaDoc();
53     
54     
55     /**
56      * Default constructor.
57      */

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

69     public int doStartTag() throws JspException JavaDoc
70     {
71         return EVAL_BODY_INCLUDE;
72     }
73
74     /**
75      * Adds a parameter with the specified name and value to the parameters
76      * of the parent tag.
77      *
78      * @return indication of whether to continue evaluating the JSP page.
79      * @throws JspException if an error occurred while processing this tag.
80      */

81     public int doEndTag() throws JspException JavaDoc
82     {
83         addContentVersion();
84         
85         contentVersion = new HashMap JavaDoc();
86         
87         return EVAL_PAGE;
88     }
89     
90     /**
91      * Adds the content version to the ancestor tag.
92      *
93      * @throws JspException if the ancestor tag isn't a url tag.
94      */

95     protected void addContentVersion() throws JspException JavaDoc
96     {
97         final ContentParameterTag parent = (ContentParameterTag) findAncestorWithClass(this, ContentParameterTag.class);
98         if(parent == null)
99         {
100             throw new JspTagException JavaDoc("ContentVersionParameterTag must have a ContentParameterTag ancestor.");
101         }
102         ((ContentParameterTag) parent).addContentVersion(contentVersion);
103     }
104
105     /**
106      * Adds the content version attribute to the contentVersion Value.
107      *
108      * @throws JspException if the ancestor tag isn't a url tag.
109      */

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

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

142     public void setLanguageId(final String JavaDoc languageId) throws JspException JavaDoc
143     {
144         this.contentVersion.put("languageId", evaluateInteger("remoteContentService", "languageId", languageId));
145     }
146
147     /**
148      *
149      */

150     public void setStateId(final String JavaDoc stateId) throws JspException JavaDoc
151     {
152         this.contentVersion.put("stateId", evaluateInteger("remoteContentService", "stateId", stateId));
153     }
154
155 }
156
Popular Tags