KickJava   Java API By Example, From Geeks To Geeks.

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


1 /*
2  * File : $Source: /usr/local/cvs/opencms/src/org/opencms/setup/xml/CmsXmlAddMultiContextMenu.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.CmsWorkplaceConfiguration;
36 import org.opencms.configuration.I_CmsXmlConfiguration;
37
38 import java.util.Collections JavaDoc;
39 import java.util.List JavaDoc;
40
41 import org.dom4j.Document;
42 import org.dom4j.Node;
43
44 /**
45  * Adds the new content notification node.<p>
46  *
47  * @author Michael Moossen
48  *
49  * @version $Revision: 1.2 $
50  *
51  * @since 6.1.8
52  */

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

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

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

77     protected boolean executeUpdate(Document document, String JavaDoc xpath) {
78
79         Node node = document.selectSingleNode(xpath);
80         if (node == null) {
81             if (xpath.equals(getXPathsToUpdate().get(0))) {
82                 setEntry(document, xpath, "explorer.context.lock", "commons/lock.jsp", "", "10");
83                 setEntry(document, xpath, "explorer.context.unlock", "commons/unlock.jsp", "", "20");
84                 CmsSetupXmlHelper.setValue(document, xpath
85                     + "/"
86                     + CmsWorkplaceConfiguration.N_SEPARATOR
87                     + "[@"
88                     + I_CmsXmlConfiguration.A_ORDER
89                     + "='30']"
90                     + "/@"
91                     + I_CmsXmlConfiguration.A_ORDER, "30");
92                 setEntry(document, xpath, "explorer.context.publish", "commons/publishresource.jsp", "", "40");
93                 CmsSetupXmlHelper.setValue(document, xpath
94                     + "/"
95                     + CmsWorkplaceConfiguration.N_SEPARATOR
96                     + "[@"
97                     + I_CmsXmlConfiguration.A_ORDER
98                     + "='50']"
99                     + "/@"
100                     + I_CmsXmlConfiguration.A_ORDER, "50");
101                 setEntry(document, xpath, "explorer.context.copy", "commons/copy.jsp", "", "60");
102                 setEntry(document, xpath, "explorer.context.move.multi", "commons/move.jsp", "", "70");
103                 setEntry(document, xpath, "explorer.context.delete", "commons/delete.jsp", "", "80");
104                 setEntry(document, xpath, "explorer.context.touch", "commons/touch.jsp", "", "90");
105                 setEntry(document, xpath, "explorer.context.availability", "commons/availability.jsp", "", "100");
106                 setEntry(document, xpath, "explorer.context.undochanges", "commons/undochanges.jsp", "", "110");
107                 setEntry(document, xpath, "explorer.context.undelete", "commons/undelete.jsp", "", "120");
108             }
109             return true;
110         }
111         return false;
112     }
113
114     /**
115      * @see org.opencms.setup.xml.A_CmsSetupXmlUpdate#getCommonPath()
116      */

117     protected String JavaDoc getCommonPath() {
118
119         // /opencms/workplace/explorertypes
120
StringBuffer JavaDoc xp = new StringBuffer JavaDoc(256);
121         xp.append("/").append(CmsConfigurationManager.N_ROOT);
122         xp.append("/").append(CmsWorkplaceConfiguration.N_WORKPLACE);
123         xp.append("/").append(CmsWorkplaceConfiguration.N_EXPLORERTYPES);
124         return xp.toString();
125     }
126
127     /**
128      * @see org.opencms.setup.xml.A_CmsSetupXmlUpdate#getXPathsToUpdate()
129      */

130     protected List JavaDoc getXPathsToUpdate() {
131
132         if (m_xpaths == null) {
133             // /opencms/workplace/explorertypes/multicontextmenu
134
StringBuffer JavaDoc xp = new StringBuffer JavaDoc(256);
135             xp.append("/").append(CmsConfigurationManager.N_ROOT);
136             xp.append("/").append(CmsWorkplaceConfiguration.N_WORKPLACE);
137             xp.append("/").append(CmsWorkplaceConfiguration.N_EXPLORERTYPES);
138             xp.append("/").append(CmsWorkplaceConfiguration.N_MULTICONTEXTMENU);
139             m_xpaths = Collections.singletonList(xp.toString());
140         }
141         return m_xpaths;
142     }
143
144     /**
145      * Creates a new entry node.<p>
146      *
147      * @param document the xml document to change
148      * @param xpath the base xpath
149      * @param key the localization key name
150      * @param uri the entry uri
151      * @param rules the permissions rules
152      * @param order the relative order
153      */

154     private void setEntry(Document document, String JavaDoc xpath, String JavaDoc key, String JavaDoc uri, String JavaDoc rules, String JavaDoc order) {
155
156         String JavaDoc xp = xpath
157             + "/"
158             + CmsWorkplaceConfiguration.N_ENTRY
159             + "[@"
160             + I_CmsXmlConfiguration.A_URI
161             + "='"
162             + uri
163             + "']";
164         CmsSetupXmlHelper.setValue(document, xp + "/@" + I_CmsXmlConfiguration.A_URI, uri);
165         CmsSetupXmlHelper.setValue(document, xp + "/@" + I_CmsXmlConfiguration.A_KEY, key);
166         CmsSetupXmlHelper.setValue(document, xp + "/@" + CmsWorkplaceConfiguration.A_RULES, rules);
167         CmsSetupXmlHelper.setValue(document, xp + "/@" + I_CmsXmlConfiguration.A_ORDER, order);
168     }
169
170 }
Popular Tags