KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > infoglue > cms > applications > managementtool > actions > ViewRepositoryPropertiesAction


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

45
46 public class ViewRepositoryPropertiesAction extends InfoGluePropertiesAbstractAction
47 {
48     private static final long serialVersionUID = 1L;
49
50     private RepositoryVO repositoryVO = new RepositoryVO();
51     private PropertySet propertySet = null;
52     private List JavaDoc contentTypeDefinitionVOList = null;
53     private List JavaDoc repositoryVOList = null;
54     
55     private String JavaDoc WYSIWYGConfig = null;
56     private String JavaDoc stylesXML = null;
57     private String JavaDoc defaultFolderContentTypeName = null;
58     private String JavaDoc defaultTemplateRepository = null;
59     private String JavaDoc parentRepository = null;
60
61     
62     public ViewRepositoryPropertiesAction()
63     {
64     }
65         
66     protected void initialize(Integer JavaDoc repositoryId) throws Exception JavaDoc
67     {
68         this.repositoryVO = RepositoryController.getController().getRepositoryVOWithId(repositoryId);
69         this.contentTypeDefinitionVOList = ContentTypeDefinitionController.getController().getContentTypeDefinitionVOList(ContentTypeDefinitionVO.CONTENT);
70         this.repositoryVOList = RepositoryController.getController().getRepositoryVOList();
71             
72         Map JavaDoc args = new HashMap JavaDoc();
73         args.put("globalKey", "infoglue");
74         PropertySet ps = PropertySetManager.getInstance("jdbc", args);
75         
76         byte[] WYSIWYGConfigBytes = ps.getData("repository_" + this.getRepositoryId() + "_WYSIWYGConfig");
77         if(WYSIWYGConfigBytes != null)
78             this.WYSIWYGConfig = new String JavaDoc(WYSIWYGConfigBytes, "utf-8");
79
80         byte[] StylesXMLBytes = ps.getData("repository_" + this.getRepositoryId() + "_StylesXML");
81         if(StylesXMLBytes != null)
82             this.stylesXML = new String JavaDoc(StylesXMLBytes, "utf-8");
83
84         this.defaultFolderContentTypeName = ps.getString("repository_" + this.getRepositoryId() + "_defaultFolderContentTypeName");
85         this.defaultTemplateRepository = ps.getString("repository_" + this.getRepositoryId() + "_defaultTemplateRepository");
86         this.parentRepository = ps.getString("repository_" + this.getRepositoryId() + "_parentRepository");
87     }
88
89     /**
90      * The main method that fetches the Value-objects for this use-case
91      */

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

103     
104     public String JavaDoc doSave() throws Exception JavaDoc
105     {
106         Map JavaDoc args = new HashMap JavaDoc();
107         args.put("globalKey", "infoglue");
108         PropertySet ps = PropertySetManager.getInstance("jdbc", args);
109         
110         ps.setData("repository_" + this.getRepositoryId() + "_WYSIWYGConfig", WYSIWYGConfig.getBytes("utf-8"));
111         ps.setData("repository_" + this.getRepositoryId() + "_StylesXML", stylesXML.getBytes("utf-8"));
112         ps.setString("repository_" + this.getRepositoryId() + "_defaultFolderContentTypeName", defaultFolderContentTypeName);
113         ps.setString("repository_" + this.getRepositoryId() + "_defaultTemplateRepository", defaultTemplateRepository);
114         ps.setString("repository_" + this.getRepositoryId() + "_parentRepository", parentRepository);
115         
116         //TODO - hack to get the caches to be updated when properties are affected..
117
RepositoryVO repositoryVO = RepositoryController.getController().getFirstRepositoryVO();
118         repositoryVO.setDescription(repositoryVO.getDescription() + ".");
119         RepositoryController.getController().update(repositoryVO);
120         
121         return "save";
122     }
123
124     /**
125      * The main method that fetches the Value-objects for this use-case
126      */

127     
128     public String JavaDoc doSaveAndExit() throws Exception JavaDoc
129     {
130         return "saveAndExit";
131     }
132
133     public java.lang.Integer JavaDoc getRepositoryId()
134     {
135         return this.repositoryVO.getRepositoryId();
136     }
137         
138     public void setRepositoryId(java.lang.Integer JavaDoc repositoryId) throws Exception JavaDoc
139     {
140         this.repositoryVO.setRepositoryId(repositoryId);
141     }
142
143     public RepositoryVO getRepositoryVO()
144     {
145         return repositoryVO;
146     }
147     
148     public String JavaDoc getWYSIWYGConfig()
149     {
150         return WYSIWYGConfig;
151     }
152     
153     public void setWYSIWYGConfig(String JavaDoc config)
154     {
155         WYSIWYGConfig = config;
156     }
157
158     public String JavaDoc getWYSIWYGStyles()
159     {
160         return stylesXML;
161     }
162     
163     public void setWYSIWYGStyles(String JavaDoc stylesXML)
164     {
165         this.stylesXML = stylesXML;
166     }
167
168     public PropertySet getPropertySet()
169     {
170         return propertySet;
171     }
172     
173     public String JavaDoc getDefaultFolderContentTypeName()
174     {
175         return defaultFolderContentTypeName;
176     }
177     
178     public void setDefaultFolderContentTypeName(String JavaDoc defaultFolderContentTypeName)
179     {
180         this.defaultFolderContentTypeName = defaultFolderContentTypeName;
181     }
182     
183     public String JavaDoc getDefaultTemplateRepository()
184     {
185         return defaultTemplateRepository;
186     }
187     
188     public void setDefaultTemplateRepository(String JavaDoc defaultTemplateRepository)
189     {
190         this.defaultTemplateRepository = defaultTemplateRepository;
191     }
192
193     public String JavaDoc getParentRepository()
194     {
195         return parentRepository;
196     }
197     
198     public void setParentRepository(String JavaDoc parentRepository)
199     {
200         this.parentRepository = parentRepository;
201     }
202
203     public List JavaDoc getContentTypeDefinitionVOList()
204     {
205         return contentTypeDefinitionVOList;
206     }
207
208     public List JavaDoc getRepositoryVOList()
209     {
210         return repositoryVOList;
211     }
212 }
213
Popular Tags