KickJava   Java API By Example, From Geeks To Geeks.

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


1 /*
2  * File : $Source: /usr/local/cvs/opencms/src/org/opencms/setup/xml/CmsXmlAddAvailabilityContextMenu.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 import org.opencms.file.types.CmsResourceTypeBinary;
38 import org.opencms.file.types.CmsResourceTypeFolder;
39 import org.opencms.file.types.CmsResourceTypeImage;
40 import org.opencms.file.types.CmsResourceTypeJsp;
41 import org.opencms.file.types.CmsResourceTypePlain;
42 import org.opencms.file.types.CmsResourceTypeXmlPage;
43 import org.opencms.util.CmsStringUtil;
44
45 import java.util.ArrayList JavaDoc;
46 import java.util.HashMap JavaDoc;
47 import java.util.List JavaDoc;
48 import java.util.Map JavaDoc;
49
50 import org.dom4j.Document;
51 import org.dom4j.Node;
52
53 /**
54  * Adds the availability context menu node.<p>
55  *
56  * @author Michael Moossen
57  *
58  * @version $Revision: 1.2 $
59  *
60  * @since 6.1.8
61  */

62 public class CmsXmlAddAvailabilityContextMenu extends A_CmsXmlWorkplace {
63
64     /** List of xpaths to update. */
65     private List JavaDoc m_xpaths;
66
67     /**
68      * @see org.opencms.setup.xml.I_CmsSetupXmlUpdate#getName()
69      */

70     public String JavaDoc getName() {
71
72         return "Add context menu for Availability";
73     }
74
75     /**
76      * @see org.opencms.setup.xml.A_CmsSetupXmlUpdate#executeUpdate(org.dom4j.Document, java.lang.String)
77      */

78     protected boolean executeUpdate(Document document, String JavaDoc xpath) {
79
80         Node node = document.selectSingleNode(xpath);
81         if (node == null) {
82             if (xpath.indexOf("availability") > 0) {
83                 CmsSetupXmlHelper.setValue(
84                     document,
85                     xpath + "/@" + I_CmsXmlConfiguration.A_URI,
86                     "commons/availability.jsp");
87                 CmsSetupXmlHelper.setValue(
88                     document,
89                     xpath + "/@" + I_CmsXmlConfiguration.A_KEY,
90                     "explorer.context.availability");
91                 CmsSetupXmlHelper.setValue(
92                     document,
93                     xpath + "/@" + CmsWorkplaceConfiguration.A_RULES,
94                     "d d iiii aaai dddd");
95                 CmsSetupXmlHelper.setValue(document, xpath + "/@" + I_CmsXmlConfiguration.A_ORDER, "200");
96             } else if (xpath.indexOf("undochanges") > 0) {
97                 CmsSetupXmlHelper.setValue(document, xpath + "/@" + I_CmsXmlConfiguration.A_ORDER, "210");
98             } else if (xpath.indexOf("undelete") > 0) {
99                 CmsSetupXmlHelper.setValue(document, xpath + "/@" + I_CmsXmlConfiguration.A_ORDER, "220");
100             }
101             return true;
102         }
103         return false;
104     }
105
106     /**
107      * @see org.opencms.setup.xml.A_CmsSetupXmlUpdate#getCommonPath()
108      */

109     protected String JavaDoc getCommonPath() {
110
111         // /opencms/workplace/explorertypes
112
return new StringBuffer JavaDoc("/").append(CmsConfigurationManager.N_ROOT).append("/").append(
113             CmsWorkplaceConfiguration.N_WORKPLACE).append("/").append(CmsWorkplaceConfiguration.N_EXPLORERTYPES).toString();
114     }
115
116     /**
117      * @see org.opencms.setup.xml.A_CmsSetupXmlUpdate#getXPathsToUpdate()
118      */

119     protected List JavaDoc getXPathsToUpdate() {
120
121         if (m_xpaths == null) {
122             // /opencms/workplace/explorertypes/explorertype[@name='${etype}']/editoptions/contextmenu/entry[@uri='commons/${res}.jsp']
123
StringBuffer JavaDoc xp = new StringBuffer JavaDoc(256);
124             xp.append("/");
125             xp.append(CmsConfigurationManager.N_ROOT);
126             xp.append("/");
127             xp.append(CmsWorkplaceConfiguration.N_WORKPLACE);
128             xp.append("/");
129             xp.append(CmsWorkplaceConfiguration.N_EXPLORERTYPES);
130             xp.append("/");
131             xp.append(CmsWorkplaceConfiguration.N_EXPLORERTYPE);
132             xp.append("[@");
133             xp.append(I_CmsXmlConfiguration.N_NAME);
134             xp.append("='${etype}']/");
135             xp.append(CmsWorkplaceConfiguration.N_EDITOPTIONS);
136             xp.append("/");
137             xp.append(CmsWorkplaceConfiguration.N_CONTEXTMENU);
138             xp.append("/");
139             xp.append(CmsWorkplaceConfiguration.N_ENTRY);
140             xp.append("[@");
141             xp.append(I_CmsXmlConfiguration.A_URI);
142             xp.append("='commons/${res}.jsp']");
143             m_xpaths = new ArrayList JavaDoc();
144             // ${etype}: folder, imagegallery, xmlcontent, xmlpage, plain, image, jsp, binary, XMLTemplate
145
// ${res}: availability, undochanges, undelete
146
Map JavaDoc subs = new HashMap JavaDoc();
147             subs.put("${res}", "availability");
148             subs.put("${etype}", CmsResourceTypeFolder.getStaticTypeName());
149             m_xpaths.add(CmsStringUtil.substitute(xp.toString(), subs));
150             subs.put("${etype}", "imagegallery");
151             m_xpaths.add(CmsStringUtil.substitute(xp.toString(), subs));
152             subs.put("${etype}", "xmlcontent");
153             m_xpaths.add(CmsStringUtil.substitute(xp.toString(), subs));
154             subs.put("${etype}", CmsResourceTypeXmlPage.getStaticTypeName());
155             m_xpaths.add(CmsStringUtil.substitute(xp.toString(), subs));
156             subs.put("${etype}", CmsResourceTypePlain.getStaticTypeName());
157             m_xpaths.add(CmsStringUtil.substitute(xp.toString(), subs));
158             subs.put("${etype}", CmsResourceTypeImage.getStaticTypeName());
159             m_xpaths.add(CmsStringUtil.substitute(xp.toString(), subs));
160             subs.put("${etype}", CmsResourceTypeJsp.getStaticTypeName());
161             m_xpaths.add(CmsStringUtil.substitute(xp.toString(), subs));
162             subs.put("${etype}", CmsResourceTypeBinary.getStaticTypeName());
163             m_xpaths.add(CmsStringUtil.substitute(xp.toString(), subs));
164             subs.put("${etype}", "XMLTemplate");
165             m_xpaths.add(CmsStringUtil.substitute(xp.toString(), subs));
166
167             subs.put("${res}", "undochanges");
168             subs.put("${etype}", CmsResourceTypeFolder.getStaticTypeName());
169             m_xpaths.add(CmsStringUtil.substitute(xp.toString(), subs));
170             subs.put("${etype}", "imagegallery");
171             m_xpaths.add(CmsStringUtil.substitute(xp.toString(), subs));
172             subs.put("${etype}", "xmlcontent");
173             m_xpaths.add(CmsStringUtil.substitute(xp.toString(), subs));
174             subs.put("${etype}", CmsResourceTypeXmlPage.getStaticTypeName());
175             m_xpaths.add(CmsStringUtil.substitute(xp.toString(), subs));
176             subs.put("${etype}", CmsResourceTypePlain.getStaticTypeName());
177             m_xpaths.add(CmsStringUtil.substitute(xp.toString(), subs));
178             subs.put("${etype}", CmsResourceTypeImage.getStaticTypeName());
179             m_xpaths.add(CmsStringUtil.substitute(xp.toString(), subs));
180             subs.put("${etype}", CmsResourceTypeJsp.getStaticTypeName());
181             m_xpaths.add(CmsStringUtil.substitute(xp.toString(), subs));
182             subs.put("${etype}", CmsResourceTypeBinary.getStaticTypeName());
183             m_xpaths.add(CmsStringUtil.substitute(xp.toString(), subs));
184             subs.put("${etype}", "XMLTemplate");
185             m_xpaths.add(CmsStringUtil.substitute(xp.toString(), subs));
186
187             subs.put("${res}", "undelete");
188             subs.put("${etype}", CmsResourceTypeFolder.getStaticTypeName());
189             m_xpaths.add(CmsStringUtil.substitute(xp.toString(), subs));
190             subs.put("${etype}", "imagegallery");
191             m_xpaths.add(CmsStringUtil.substitute(xp.toString(), subs));
192             subs.put("${etype}", "xmlcontent");
193             m_xpaths.add(CmsStringUtil.substitute(xp.toString(), subs));
194             subs.put("${etype}", CmsResourceTypeXmlPage.getStaticTypeName());
195             m_xpaths.add(CmsStringUtil.substitute(xp.toString(), subs));
196             subs.put("${etype}", CmsResourceTypePlain.getStaticTypeName());
197             m_xpaths.add(CmsStringUtil.substitute(xp.toString(), subs));
198             subs.put("${etype}", CmsResourceTypeImage.getStaticTypeName());
199             m_xpaths.add(CmsStringUtil.substitute(xp.toString(), subs));
200             subs.put("${etype}", CmsResourceTypeJsp.getStaticTypeName());
201             m_xpaths.add(CmsStringUtil.substitute(xp.toString(), subs));
202             subs.put("${etype}", CmsResourceTypeBinary.getStaticTypeName());
203             m_xpaths.add(CmsStringUtil.substitute(xp.toString(), subs));
204             subs.put("${etype}", "XMLTemplate");
205             m_xpaths.add(CmsStringUtil.substitute(xp.toString(), subs));
206         }
207         return m_xpaths;
208     }
209
210 }
Popular Tags