KickJava   Java API By Example, From Geeks To Geeks.

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


1 /*
2  * File : $Source: /usr/local/cvs/opencms/src/org/opencms/setup/xml/CmsXmlAddAutoSetFeatures.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.CmsResourceTypePointer;
43 import org.opencms.file.types.CmsResourceTypeXmlPage;
44 import org.opencms.util.CmsStringUtil;
45
46 import java.util.ArrayList JavaDoc;
47 import java.util.List JavaDoc;
48
49 import org.dom4j.Document;
50 import org.dom4j.Node;
51
52 /**
53  * Adds the auto set features in new dialog.<p>
54  *
55  * @author Michael Moossen
56  *
57  * @version $Revision: 1.2 $
58  *
59  * @since 6.1.8
60  */

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

69     public String JavaDoc getName() {
70
71         return "Add auto set features in new dialog";
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             CmsSetupXmlHelper.setValue(document, xpath, Boolean.FALSE.toString());
82             return true;
83         }
84         return false;
85     }
86
87     /**
88      * @see org.opencms.setup.xml.A_CmsSetupXmlUpdate#getCommonPath()
89      */

90     protected String JavaDoc getCommonPath() {
91
92         // /opencms/workplace/explorertypes
93
return new StringBuffer JavaDoc("/").append(CmsConfigurationManager.N_ROOT).append("/").append(
94             CmsWorkplaceConfiguration.N_WORKPLACE).append("/").append(CmsWorkplaceConfiguration.N_EXPLORERTYPES).toString();
95     }
96
97     /**
98      * @see org.opencms.setup.xml.A_CmsSetupXmlUpdate#getXPathsToUpdate()
99      */

100     protected List JavaDoc getXPathsToUpdate() {
101
102         if (m_xpaths == null) {
103             // /opencms/workplace/explorertypes/explorertype[@name='${etype}']/newresource/@${attr}
104
StringBuffer JavaDoc xp = new StringBuffer JavaDoc(256);
105             xp.append("/").append(CmsConfigurationManager.N_ROOT);
106             xp.append("/").append(CmsWorkplaceConfiguration.N_WORKPLACE);
107             xp.append("/").append(CmsWorkplaceConfiguration.N_EXPLORERTYPES);
108             xp.append("/").append(CmsWorkplaceConfiguration.N_EXPLORERTYPE);
109             xp.append("[@").append(I_CmsXmlConfiguration.N_NAME);
110             xp.append("='${etype}']/").append(CmsWorkplaceConfiguration.N_NEWRESOURCE);
111             xp.append("/@");
112             m_xpaths = new ArrayList JavaDoc();
113             // ${etype}: folder, imagegallery, downloadgallery, xmlcontent, xmlpage, plain, image, jsp, binary, pointer, XMLTemplate, link, upload, extendedfolder, structurecontent
114
// ${attr}: autosetnavigation, autosettitle
115
m_xpaths.add(CmsStringUtil.substitute(xp.toString(), "${etype}", CmsResourceTypeFolder.getStaticTypeName())
116                 + CmsWorkplaceConfiguration.A_AUTOSETNAVIGATION);
117             m_xpaths.add(CmsStringUtil.substitute(xp.toString(), "${etype}", "imagegallery")
118                 + CmsWorkplaceConfiguration.A_AUTOSETNAVIGATION);
119             m_xpaths.add(CmsStringUtil.substitute(xp.toString(), "${etype}", "downloadgallery")
120                 + CmsWorkplaceConfiguration.A_AUTOSETNAVIGATION);
121             m_xpaths.add(CmsStringUtil.substitute(xp.toString(), "${etype}", "xmlcontent")
122                 + CmsWorkplaceConfiguration.A_AUTOSETNAVIGATION);
123             m_xpaths.add(CmsStringUtil.substitute(xp.toString(), "${etype}", CmsResourceTypeXmlPage.getStaticTypeName())
124                 + CmsWorkplaceConfiguration.A_AUTOSETNAVIGATION);
125             m_xpaths.add(CmsStringUtil.substitute(xp.toString(), "${etype}", CmsResourceTypePlain.getStaticTypeName())
126                 + CmsWorkplaceConfiguration.A_AUTOSETNAVIGATION);
127             m_xpaths.add(CmsStringUtil.substitute(xp.toString(), "${etype}", CmsResourceTypeImage.getStaticTypeName())
128                 + CmsWorkplaceConfiguration.A_AUTOSETNAVIGATION);
129             m_xpaths.add(CmsStringUtil.substitute(xp.toString(), "${etype}", CmsResourceTypeJsp.getStaticTypeName())
130                 + CmsWorkplaceConfiguration.A_AUTOSETNAVIGATION);
131             m_xpaths.add(CmsStringUtil.substitute(xp.toString(), "${etype}", CmsResourceTypeBinary.getStaticTypeName())
132                 + CmsWorkplaceConfiguration.A_AUTOSETNAVIGATION);
133             m_xpaths.add(CmsStringUtil.substitute(xp.toString(), "${etype}", "XMLTemplate")
134                 + CmsWorkplaceConfiguration.A_AUTOSETNAVIGATION);
135             m_xpaths.add(CmsStringUtil.substitute(xp.toString(), "${etype}", CmsResourceTypePointer.getStaticTypeName())
136                 + CmsWorkplaceConfiguration.A_AUTOSETNAVIGATION);
137             m_xpaths.add(CmsStringUtil.substitute(xp.toString(), "${etype}", "link")
138                 + CmsWorkplaceConfiguration.A_AUTOSETNAVIGATION);
139             m_xpaths.add(CmsStringUtil.substitute(xp.toString(), "${etype}", "upload")
140                 + CmsWorkplaceConfiguration.A_AUTOSETNAVIGATION);
141             m_xpaths.add(CmsStringUtil.substitute(xp.toString(), "${etype}", "extendedfolder")
142                 + CmsWorkplaceConfiguration.A_AUTOSETNAVIGATION);
143             m_xpaths.add(CmsStringUtil.substitute(xp.toString(), "${etype}", "structurecontent")
144                 + CmsWorkplaceConfiguration.A_AUTOSETNAVIGATION);
145
146             m_xpaths.add(CmsStringUtil.substitute(xp.toString(), "${etype}", CmsResourceTypeFolder.getStaticTypeName())
147                 + CmsWorkplaceConfiguration.A_AUTOSETTITLE);
148             m_xpaths.add(CmsStringUtil.substitute(xp.toString(), "${etype}", "imagegallery")
149                 + CmsWorkplaceConfiguration.A_AUTOSETTITLE);
150             m_xpaths.add(CmsStringUtil.substitute(xp.toString(), "${etype}", "downloadgallery")
151                 + CmsWorkplaceConfiguration.A_AUTOSETTITLE);
152             m_xpaths.add(CmsStringUtil.substitute(xp.toString(), "${etype}", "xmlcontent")
153                 + CmsWorkplaceConfiguration.A_AUTOSETTITLE);
154             m_xpaths.add(CmsStringUtil.substitute(xp.toString(), "${etype}", CmsResourceTypeXmlPage.getStaticTypeName())
155                 + CmsWorkplaceConfiguration.A_AUTOSETTITLE);
156             m_xpaths.add(CmsStringUtil.substitute(xp.toString(), "${etype}", CmsResourceTypePlain.getStaticTypeName())
157                 + CmsWorkplaceConfiguration.A_AUTOSETTITLE);
158             m_xpaths.add(CmsStringUtil.substitute(xp.toString(), "${etype}", CmsResourceTypeImage.getStaticTypeName())
159                 + CmsWorkplaceConfiguration.A_AUTOSETTITLE);
160             m_xpaths.add(CmsStringUtil.substitute(xp.toString(), "${etype}", CmsResourceTypeJsp.getStaticTypeName())
161                 + CmsWorkplaceConfiguration.A_AUTOSETTITLE);
162             m_xpaths.add(CmsStringUtil.substitute(xp.toString(), "${etype}", CmsResourceTypeBinary.getStaticTypeName())
163                 + CmsWorkplaceConfiguration.A_AUTOSETTITLE);
164             m_xpaths.add(CmsStringUtil.substitute(xp.toString(), "${etype}", "XMLTemplate")
165                 + CmsWorkplaceConfiguration.A_AUTOSETTITLE);
166             m_xpaths.add(CmsStringUtil.substitute(xp.toString(), "${etype}", CmsResourceTypePointer.getStaticTypeName())
167                 + CmsWorkplaceConfiguration.A_AUTOSETTITLE);
168             m_xpaths.add(CmsStringUtil.substitute(xp.toString(), "${etype}", "link")
169                 + CmsWorkplaceConfiguration.A_AUTOSETTITLE);
170             m_xpaths.add(CmsStringUtil.substitute(xp.toString(), "${etype}", "upload")
171                 + CmsWorkplaceConfiguration.A_AUTOSETTITLE);
172             m_xpaths.add(CmsStringUtil.substitute(xp.toString(), "${etype}", "extendedfolder")
173                 + CmsWorkplaceConfiguration.A_AUTOSETTITLE);
174             m_xpaths.add(CmsStringUtil.substitute(xp.toString(), "${etype}", "structurecontent")
175                 + CmsWorkplaceConfiguration.A_AUTOSETTITLE);
176         }
177         return m_xpaths;
178     }
179
180 }
Popular Tags