KickJava   Java API By Example, From Geeks To Geeks.

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


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.ServerNodeController;
32 import org.infoglue.cms.entities.management.ServerNodeVO;
33 import org.infoglue.cms.exception.SystemException;
34 import org.infoglue.cms.security.InfoGlueAuthenticationFilter;
35 import org.infoglue.cms.util.CmsPropertyHandler;
36 import org.infoglue.cms.util.NotificationMessage;
37 import org.infoglue.cms.util.RemoteCacheUpdater;
38 import org.infoglue.deliver.util.CacheController;
39
40 import com.opensymphony.module.propertyset.PropertySet;
41 import com.opensymphony.module.propertyset.PropertySetManager;
42
43 /**
44  * This class implements the action class for viewServerNodeProperties.
45  * The use-case lets the user see all extra-properties for a serverNode
46  *
47  * @author Mattias Bogeblad
48  */

49
50 public class ViewServerNodePropertiesAction extends InfoGluePropertiesAbstractAction
51 {
52     private static final long serialVersionUID = 1L;
53
54     private ServerNodeVO serverNodeVO = new ServerNodeVO();
55     private PropertySet propertySet = null;
56     private List JavaDoc serverNodeVOList = null;
57     private String JavaDoc key = null;
58     
59     public ViewServerNodePropertiesAction()
60     {
61     }
62         
63     protected void initialize(Integer JavaDoc serverNodeId) throws Exception JavaDoc
64     {
65         if(serverNodeId != null && serverNodeId.intValue() > -1)
66             this.serverNodeVO = ServerNodeController.getController().getServerNodeVOWithId(serverNodeId);
67      
68         Map JavaDoc args = new HashMap JavaDoc();
69         args.put("globalKey", "infoglue");
70         this.propertySet = PropertySetManager.getInstance("jdbc", args);
71     }
72
73     /**
74      * The main method that fetches the Value-objects for this use-case
75      */

76     
77     public String JavaDoc doExecute() throws Exception JavaDoc
78     {
79         this.initialize(getServerNodeId());
80
81         return "success";
82     }
83     
84     private void populate(PropertySet ps, String JavaDoc key)
85     {
86         String JavaDoc value = this.getRequest().getParameter(key);
87         if(value != null && !value.equals(""))
88             ps.setString("serverNode_" + this.getServerNodeId() + "_" + key, value);
89     }
90
91     private void populateData(PropertySet ps, String JavaDoc key)
92     {
93         try
94         {
95             String JavaDoc value = this.getRequest().getParameter(key);
96             if(value != null && !value.equals(""))
97                 ps.setData("serverNode_" + this.getServerNodeId() + "_" + key, value.getBytes("utf-8"));
98         }
99         catch(Exception JavaDoc e)
100         {
101             e.printStackTrace();
102         }
103     }
104
105     /**
106      * The main method that fetches the Value-objects for this use-case
107      */

108     
109     public String JavaDoc doSave() throws Exception JavaDoc
110     {
111         Map JavaDoc args = new HashMap JavaDoc();
112         args.put("globalKey", "infoglue");
113         PropertySet ps = PropertySetManager.getInstance("jdbc", args);
114         
115         populate(ps, "isPageCacheOn");
116         populate(ps, "useSelectivePageCacheUpdate");
117         populate(ps, "expireCacheAutomatically");
118         populate(ps, "cacheExpireInterval");
119         populate(ps, "deliverRequestTimeout");
120         populate(ps, "session.timeout");
121         populate(ps, "compressPageCache");
122         populate(ps, "compressPageResponse");
123         populate(ps, "siteNodesToRecacheOnPublishing");
124         populate(ps, "recachePublishingMethod");
125         populate(ps, "recacheUrl");
126         populate(ps, "useUpdateSecurity");
127         populate(ps, "allowedAdminIP");
128         populate(ps, "pageKey");
129         populate(ps, "cmsBaseUrl");
130         populate(ps, "cmsFullBaseUrl");
131         populate(ps, "componentEditorUrl");
132         populate(ps, "componentRendererUrl");
133         populate(ps, "componentRendererAction");
134         populate(ps, "editOnSiteUrl");
135         populate(ps, "useFreeMarker");
136         populate(ps, "webServerAddress");
137         populate(ps, "applicationBaseAction");
138         populate(ps, "digitalAssetBaseUrl");
139         populate(ps, "imagesBaseUrl");
140         populate(ps, "digitalAssetPath");
141         populate(ps, "urlFormatting");
142         populate(ps, "enableNiceURI");
143         populate(ps, "niceURIEncoding");
144         populate(ps, "niceURIAttributeName");
145         populate(ps, "requestArgumentDelimiter");
146         populate(ps, "errorHandling");
147         populate(ps, "errorUrl");
148         populate(ps, "errorBusyUrl");
149         populate(ps, "externalThumbnailGeneration");
150         populate(ps, "URIEncoding");
151         populate(ps, "workflowEncoding");
152         populate(ps, "formsEncoding");
153         populate(ps, "useShortTableNames");
154         populate(ps, "logDatabaseMessages");
155         populate(ps, "statistics.enabled");
156         populate(ps, "statisticsLogPath");
157         populate(ps, "statisticsLogOneFilePerDay");
158         populate(ps, "statisticsLogger");
159         populate(ps, "enablePortal");
160         populate(ps, "portletBase");
161         populate(ps, "mail.smtp.host");
162         populate(ps, "mail.smtp.auth");
163         populate(ps, "mail.smtp.user");
164         populate(ps, "mail.smtp.password");
165         populate(ps, "mail.contentType");
166         populate(ps, "systemEmailSender");
167         populate(ps, "warningEmailReceiver");
168         populate(ps, "loginUrl");
169         populate(ps, "logoutUrl");
170         populate(ps, "invalidLoginUrl");
171         populate(ps, "successLoginBaseUrl");
172         populate(ps, "authenticatorClass");
173         populate(ps, "authorizerClass");
174         populate(ps, "serverName");
175         populate(ps, "authConstraint");
176         populate(ps, "extraParametersFile");
177         populateData(ps, "extraSecurityParameters");
178         populate(ps, "casValidateUrl");
179         populate(ps, "casServiceUrl");
180         populate(ps, "casLogoutUrl");
181         
182         populate(ps, "deliver_loginUrl");
183         populate(ps, "deliver_logoutUrl");
184         populate(ps, "deliver_invalidLoginUrl");
185         populate(ps, "deliver_successLoginBaseUrl");
186         populate(ps, "deliver_authenticatorClass");
187         populate(ps, "deliver_authorizerClass");
188         populate(ps, "deliver_serverName");
189         populate(ps, "deliver_authConstraint");
190         populate(ps, "deliver_extraParametersFile");
191         populateData(ps, "deliver_extraSecurityParameters");
192         populate(ps, "deliver_security.anonymous.username");
193         populate(ps, "deliver_security.anonymous.password");
194         populate(ps, "deliver_casValidateUrl");
195         populate(ps, "deliver_casServiceUrl");
196         populate(ps, "deliver_casLogoutUrl");
197         populateData(ps, "shortcuts");
198
199         populate(ps, "protectContentTypes");
200         populate(ps, "protectWorkflows");
201         populate(ps, "protectCategories");
202
203         populate(ps, "maxRows");
204         populate(ps, "showContentVersionFirst");
205         populate(ps, "tree");
206         populate(ps, "treemode");
207         populate(ps, "showComponentsFirst");
208         populate(ps, "showAllWorkflows");
209         populate(ps, "editOnSight");
210         populate(ps, "previewDeliveryUrl");
211         populate(ps, "stagingDeliveryUrl");
212         populateData(ps, "internalDeliveryUrls");
213         populateData(ps, "publicDeliveryUrls");
214         populate(ps, "edition.pageSize");
215         populate(ps, "content.tree.sort");
216         populate(ps, "structure.tree.sort");
217         populate(ps, "structure.tree.isHidden");
218         populate(ps, "disableEmptyUrls");
219         populate(ps, "cacheUpdateAction");
220         populate(ps, "logPath");
221
222         populate(ps, "logTransactions");
223         populate(ps, "enableExtranetCookies");
224         populate(ps, "useAlternativeBrowserLanguageCheck");
225         populate(ps, "caseSensitiveRedirects");
226         populate(ps, "useDNSNameInURI");
227         
228         populate(ps, "extranetCookieTimeout");
229         populate(ps, "webServicesBaseUrl");
230         populate(ps, "publicationThreadDelay");
231         populate(ps, "pathsToRecacheOnPublishing");
232         populate(ps, "disableTemplateDebug");
233         populate(ps, "dbRelease");
234         populate(ps, "dbUser");
235         populate(ps, "dbPassword");
236         populate(ps, "masterServer");
237         populate(ps, "slaveServer");
238         populate(ps, "buildName");
239         populate(ps, "adminToolsPath");
240         populate(ps, "dbScriptPath");
241         populate(ps, "digitalAssetUploadPath");
242         populate(ps, "inputCharacterEncoding");
243         populate(ps, "deliver_inputCharacterEncoding");
244         populate(ps, "protectDeliverWorking");
245         populate(ps, "protectDeliverPreview");
246         
247         try
248         {
249             CacheController.clearServerNodeProperty();
250             InfoGlueAuthenticationFilter.initializeCMSProperties();
251         }
252         catch (SystemException e)
253         {
254             e.printStackTrace();
255         }
256
257         NotificationMessage notificationMessage = new NotificationMessage("ViewServerNodePropertiesAction.doSave():", "ServerNodeProperties", this.getInfoGluePrincipal().getName(), NotificationMessage.SYSTEM, "0", "ServerNodeProperties");
258         //ChangeNotificationController.getInstance().addNotificationMessage(notificationMessage);
259
RemoteCacheUpdater.getSystemNotificationMessages().add(notificationMessage);
260                 
261         return "save";
262     }
263
264     /**
265      * The main method that fetches the Value-objects for this use-case
266      */

267     
268     public String JavaDoc doDeleteProperty() throws Exception JavaDoc
269     {
270         Map JavaDoc args = new HashMap JavaDoc();
271         args.put("globalKey", "infoglue");
272         PropertySet ps = PropertySetManager.getInstance("jdbc", args);
273
274         ps.remove("serverNode_" + this.getServerNodeId() + "_" + key);
275
276         try
277         {
278             CacheController.clearServerNodeProperty();
279             InfoGlueAuthenticationFilter.initializeCMSProperties();
280         }
281         catch (SystemException e)
282         {
283             e.printStackTrace();
284         }
285
286         NotificationMessage notificationMessage = new NotificationMessage("ViewServerNodePropertiesAction.doSave():", "ServerNodeProperties", this.getInfoGluePrincipal().getName(), NotificationMessage.SYSTEM, "0", "ServerNodeProperties");
287         //ChangeNotificationController.getInstance().addNotificationMessage(notificationMessage);
288
RemoteCacheUpdater.getSystemNotificationMessages().add(notificationMessage);
289
290         return "save";
291     }
292
293     /**
294      * The main method that fetches the Value-objects for this use-case
295      */

296     
297     public String JavaDoc doSaveAndExit() throws Exception JavaDoc
298     {
299         doSave();
300         
301         return "saveAndExit";
302     }
303
304     public java.lang.Integer JavaDoc getServerNodeId()
305     {
306         return this.serverNodeVO.getServerNodeId();
307     }
308         
309     public void setServerNodeId(java.lang.Integer JavaDoc serverNodeId) throws Exception JavaDoc
310     {
311         this.serverNodeVO.setServerNodeId(serverNodeId);
312     }
313
314     public ServerNodeVO getServerNodeVO()
315     {
316         return serverNodeVO;
317     }
318
319     public PropertySet getPropertySet()
320     {
321         return propertySet;
322     }
323
324     public String JavaDoc getPropertyValue(String JavaDoc prefix, String JavaDoc key)
325     {
326         String JavaDoc value = propertySet.getString("serverNode_" + this.getServerNodeId() + "_" + prefix + "_" + key);
327
328         return (value != null ? value : "");
329     }
330
331     public String JavaDoc getPropertyValue(String JavaDoc key)
332     {
333         String JavaDoc value = propertySet.getString("serverNode_" + this.getServerNodeId() + "_" + key);
334
335         return (value != null ? value : "");
336     }
337     
338     public String JavaDoc getDataPropertyValue(String JavaDoc key) throws Exception JavaDoc
339     {
340         byte[] valueBytes = propertySet.getData("serverNode_" + this.getServerNodeId() + "_" + key);
341         
342         return (valueBytes != null ? new String JavaDoc(valueBytes, "utf-8") : "");
343     }
344
345     public String JavaDoc getDataPropertyValue(String JavaDoc prefix, String JavaDoc key) throws Exception JavaDoc
346     {
347         byte[] valueBytes = propertySet.getData("serverNode_" + this.getServerNodeId() + "_" + prefix + "_" + key);
348         
349         return (valueBytes != null ? new String JavaDoc(valueBytes, "utf-8") : "");
350     }
351
352     public List JavaDoc getServerNodeVOList()
353     {
354         return serverNodeVOList;
355     }
356
357     public String JavaDoc getKey()
358     {
359         return key;
360     }
361
362     public void setKey(String JavaDoc key)
363     {
364         this.key = key;
365     }
366 }
367
Popular Tags