KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > opencms > setup > xml > CmsXmlAddContentNotification


1 /*
2  * File : $Source: /usr/local/cvs/opencms/src/org/opencms/setup/xml/CmsXmlAddContentNotification.java,v $
3  * Date : $Date: 2006/03/27 14:52:44 $
4  * Version: $Revision: 1.2 $
5  *
6  * This library is part of OpenCms -
7  * the Open Source Content Mananagement System
8  *
9  * Copyright (c) 2005 Alkacon Software GmbH (http://www.alkacon.com)
10  *
11  * This library is free software; you can redistribute it and/or
12  * modify it under the terms of the GNU Lesser General Public
13  * License as published by the Free Software Foundation; either
14  * version 2.1 of the License, or (at your option) any later version.
15  *
16  * This library is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19  * Lesser General Public License for more details.
20  *
21  * For further information about Alkacon Software GmbH, please see the
22  * company website: http://www.alkacon.com
23  *
24  * For further information about OpenCms, please see the
25  * project website: http://www.opencms.org
26  *
27  * You should have received a copy of the GNU Lesser General Public
28  * License along with this library; if not, write to the Free Software
29  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
30  */

31
32 package org.opencms.setup.xml;
33
34 import org.opencms.configuration.CmsConfigurationManager;
35 import org.opencms.configuration.CmsSystemConfiguration;
36
37 import java.util.Collections JavaDoc;
38 import java.util.List JavaDoc;
39
40 import org.dom4j.Document;
41 import org.dom4j.Node;
42
43 /**
44  * Adds the new content notification node.<p>
45  *
46  * @author Michael Moossen
47  *
48  * @version $Revision: 1.2 $
49  *
50  * @since 6.1.8
51  */

52 public class CmsXmlAddContentNotification extends A_CmsSetupXmlUpdate {
53
54     /** List of xpaths to update. */
55     private List JavaDoc m_xpaths;
56
57     /**
58      * @see org.opencms.setup.xml.I_CmsSetupXmlUpdate#getName()
59      */

60     public String JavaDoc getName() {
61
62         return "Add new Content Notification feature";
63     }
64
65     /**
66      * @see org.opencms.setup.xml.I_CmsSetupXmlUpdate#getXmlFilename()
67      */

68     public String JavaDoc getXmlFilename() {
69
70         return CmsSystemConfiguration.DEFAULT_XML_FILE_NAME;
71     }
72
73     /**
74      * @see org.opencms.setup.xml.A_CmsSetupXmlUpdate#executeUpdate(org.dom4j.Document, java.lang.String)
75      */

76     protected boolean executeUpdate(Document document, String JavaDoc xpath) {
77
78         Node node = document.selectSingleNode(xpath);
79         if (node == null) {
80             if (xpath.equals(getXPathsToUpdate().get(0))) {
81                 CmsSetupXmlHelper.setValue(document, xpath + "/" + CmsSystemConfiguration.N_NOTIFICATION_TIME, "365");
82                 CmsSetupXmlHelper.setValue(
83                     document,
84                     xpath + "/" + CmsSystemConfiguration.N_NOTIFICATION_PROJECT,
85                     "Offline");
86             }
87             return true;
88         }
89         return false;
90     }
91
92     /**
93      * @see org.opencms.setup.xml.A_CmsSetupXmlUpdate#getCommonPath()
94      */

95     protected String JavaDoc getCommonPath() {
96
97         // /opencms/system
98
return new StringBuffer JavaDoc("/").append(CmsConfigurationManager.N_ROOT).append("/").append(
99             CmsSystemConfiguration.N_SYSTEM).toString();
100     }
101
102     /**
103      * @see org.opencms.setup.xml.A_CmsSetupXmlUpdate#getXPathsToUpdate()
104      */

105     protected List JavaDoc getXPathsToUpdate() {
106
107         if (m_xpaths == null) {
108             // /opencms/system/content-notification
109
StringBuffer JavaDoc xp = new StringBuffer JavaDoc(256);
110             xp.append("/").append(CmsConfigurationManager.N_ROOT);
111             xp.append("/").append(CmsSystemConfiguration.N_SYSTEM);
112             xp.append("/").append(CmsSystemConfiguration.N_CONTENT_NOTIFICATION);
113             m_xpaths = Collections.singletonList(xp.toString());
114         }
115         return m_xpaths;
116     }
117
118 }
Popular Tags