KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > infoglue > cms > applications > contenttool > actions > ViewContentPropertiesAction


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
24 package org.infoglue.cms.applications.contenttool.actions;
25
26 import java.util.HashMap JavaDoc;
27 import java.util.List JavaDoc;
28 import java.util.Map JavaDoc;
29
30 import org.apache.log4j.Logger;
31 import org.infoglue.cms.applications.common.actions.InfoGluePropertiesAbstractAction;
32 import org.infoglue.cms.controllers.kernel.impl.simple.ContentController;
33 import org.infoglue.cms.controllers.kernel.impl.simple.ContentTypeDefinitionController;
34 import org.infoglue.cms.controllers.kernel.impl.simple.LanguageController;
35 import org.infoglue.cms.entities.content.ContentVO;
36 import org.infoglue.cms.entities.management.ContentTypeDefinitionVO;
37
38 import com.opensymphony.module.propertyset.PropertySet;
39 import com.opensymphony.module.propertyset.PropertySetManager;
40
41 /**
42  * This class implements the action class for viewContentProperties.
43  * The use-case lets the user see all extra-properties for a content
44  *
45  * @author Mattias Bogeblad
46  */

47
48 public class ViewContentPropertiesAction extends InfoGluePropertiesAbstractAction
49 {
50     private final static Logger logger = Logger.getLogger(ViewContentPropertiesAction.class.getName());
51
52     private static final long serialVersionUID = 1L;
53     
54     private ContentVO contentVO = new ContentVO();
55     private PropertySet propertySet = null;
56     private List JavaDoc contentTypeDefinitionVOList = null;
57     private List JavaDoc languageVOList = null;
58     
59     private String JavaDoc allowedContentTypeNames = null;
60     private String JavaDoc defaultContentTypeName = null;
61     private String JavaDoc initialLanguageId = null;
62     
63     public ViewContentPropertiesAction()
64     {
65     }
66         
67     protected void initialize(Integer JavaDoc contentId) throws Exception JavaDoc
68     {
69         this.contentVO = ContentController.getContentController().getContentVOWithId(contentId);
70         this.contentTypeDefinitionVOList = ContentTypeDefinitionController.getController().getContentTypeDefinitionVOList(ContentTypeDefinitionVO.CONTENT);
71         this.languageVOList = LanguageController.getController().getLanguageVOList(this.contentVO.getRepositoryId());
72         
73         Map JavaDoc args = new HashMap JavaDoc();
74         args.put("globalKey", "infoglue");
75         PropertySet ps = PropertySetManager.getInstance("jdbc", args);
76
77         if ( ps.exists("content_" + this.getContentId() + "_allowedContentTypeNames" ) )
78         {
79             this.allowedContentTypeNames = ps.getString("content_" + this.getContentId() + "_allowedContentTypeNames");
80         }
81         this.defaultContentTypeName = ps.getString("content_" + this.getContentId() + "_defaultContentTypeName");
82         this.initialLanguageId = ps.getString("content_" + this.getContentId() + "_initialLanguageId");
83         logger.info("allowedContentTypeNames:" + allowedContentTypeNames);
84         logger.info("defaultContentTypeName:" + defaultContentTypeName);
85         logger.info("initialLanguageId:" + initialLanguageId);
86     }
87
88     /**
89      * The main method that fetches the Value-objects for this use-case
90      */

91     
92     public String JavaDoc doExecute() throws Exception JavaDoc
93     {
94         this.initialize(getContentId());
95
96         return "success";
97     }
98     
99     /**
100      * The main method that fetches the Value-objects for this use-case
101      */

102     
103     public String JavaDoc doSave() throws Exception JavaDoc
104     {
105         String JavaDoc allowedContentTypeNames = null;
106         String JavaDoc[] allowedContentTypeNameArray = getRequest().getParameterValues("allowedContentTypeName");
107         if(allowedContentTypeNameArray != null)
108         {
109             logger.info("allowedContentTypeNameArray:" + allowedContentTypeNameArray);
110             allowedContentTypeNames = "";
111             for(int i=0; i<allowedContentTypeNameArray.length; i++)
112             {
113                 allowedContentTypeNames += allowedContentTypeNameArray[i] + ",";
114             }
115         }
116         
117         Map JavaDoc args = new HashMap JavaDoc();
118         args.put("globalKey", "infoglue");
119         PropertySet ps = PropertySetManager.getInstance("jdbc", args);
120         
121         if(allowedContentTypeNames != null )
122             ps.setString("content_" + this.getContentId() + "_allowedContentTypeNames", allowedContentTypeNames);
123         if(defaultContentTypeName != null)
124             ps.setString("content_" + this.getContentId() + "_defaultContentTypeName", defaultContentTypeName);
125         if(initialLanguageId != null)
126             ps.setString("content_" + this.getContentId() + "_initialLanguageId", initialLanguageId);
127         
128         return "save";
129     }
130
131     /**
132      * The main method that fetches the Value-objects for this use-case
133      */

134     
135     public String JavaDoc doSaveAndExit() throws Exception JavaDoc
136     {
137         return "saveAndExit";
138     }
139
140     public java.lang.Integer JavaDoc getContentId()
141     {
142         return this.contentVO.getContentId();
143     }
144         
145     public void setContentId(java.lang.Integer JavaDoc contentId) throws Exception JavaDoc
146     {
147         this.contentVO.setContentId(contentId);
148     }
149
150     public ContentVO getContentVO()
151     {
152         return contentVO;
153     }
154     
155     public List JavaDoc getContentTypeDefinitionVOList()
156     {
157         return contentTypeDefinitionVOList;
158     }
159     
160     public String JavaDoc getAllowedContentTypeNames()
161     {
162         return allowedContentTypeNames;
163     }
164
165     public String JavaDoc getDefaultContentTypeName()
166     {
167         return defaultContentTypeName;
168     }
169     
170     public void setDefaultContentTypeName(String JavaDoc defaultContentTypeName)
171     {
172         this.defaultContentTypeName = defaultContentTypeName;
173     }
174     
175     public List JavaDoc getLanguageVOList()
176     {
177         return languageVOList;
178     }
179     
180     public String JavaDoc getInitialLanguageId()
181     {
182         return initialLanguageId;
183     }
184     
185     public void setInitialLanguageId(String JavaDoc initialLanguageId)
186     {
187         this.initialLanguageId = initialLanguageId;
188     }
189 }
190
Popular Tags