KickJava   Java API By Example, From Geeks To Geeks.

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


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

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

62     public String JavaDoc getName() {
63
64         return "Add new Image Gallery parameter";
65     }
66
67     /**
68      * @see org.opencms.setup.xml.I_CmsSetupXmlUpdate#getXmlFilename()
69      */

70     public String JavaDoc getXmlFilename() {
71
72         return CmsVfsConfiguration.DEFAULT_XML_FILE_NAME;
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.equals(getXPathsToUpdate().get(0))) {
83                 CmsSetupXmlHelper.setValue(
84                     document,
85                     xpath + "/@" + I_CmsXmlConfiguration.A_NAME,
86                     CmsResourceTypeFolderExtended.CONFIGURATION_FOLDER_CLASS_PARAMS);
87                 CmsSetupXmlHelper.setValue(document, xpath, "w:120,h:90,c:dddddd,t:1,r:2");
88             }
89             return true;
90         }
91         return false;
92     }
93
94     /**
95      * @see org.opencms.setup.xml.A_CmsSetupXmlUpdate#getCommonPath()
96      */

97     protected String JavaDoc getCommonPath() {
98
99         // /opencms/vfs/resources/resourcetypes/type[@class='org.opencms.file.types.CmsResourceTypeFolderExtended']
100
StringBuffer JavaDoc xp = new StringBuffer JavaDoc(256);
101         xp.append("/").append(CmsConfigurationManager.N_ROOT);
102         xp.append("/").append(CmsVfsConfiguration.N_VFS);
103         xp.append("/").append(CmsVfsConfiguration.N_RESOURCES);
104         xp.append("/").append(CmsVfsConfiguration.N_RESOURCETYPES);
105         xp.append("/").append(CmsVfsConfiguration.N_TYPE);
106         xp.append("[@").append(I_CmsXmlConfiguration.A_CLASS);
107         xp.append("='").append(CmsResourceTypeFolderExtended.class.getName());
108         return xp.append("']").toString();
109     }
110
111     /**
112      * @see org.opencms.setup.xml.A_CmsSetupXmlUpdate#getXPathsToUpdate()
113      */

114     protected List JavaDoc getXPathsToUpdate() {
115
116         if (m_xpaths == null) {
117             // "/opencms/vfs/resources/resourcetypes/type[@class='org.opencms.file.types.CmsResourceTypeFolderExtended']/param[@name='folder.class.params']";
118
StringBuffer JavaDoc xp = new StringBuffer JavaDoc(256);
119             xp.append("/").append(CmsConfigurationManager.N_ROOT);
120             xp.append("/").append(CmsVfsConfiguration.N_VFS);
121             xp.append("/").append(CmsVfsConfiguration.N_RESOURCES);
122             xp.append("/").append(CmsVfsConfiguration.N_RESOURCETYPES);
123             xp.append("/").append(CmsVfsConfiguration.N_TYPE);
124             xp.append("[@").append(I_CmsXmlConfiguration.A_CLASS);
125             xp.append("='").append(CmsResourceTypeFolderExtended.class.getName());
126             xp.append("']/").append(I_CmsXmlConfiguration.N_PARAM);
127             xp.append("[@").append(I_CmsXmlConfiguration.A_NAME);
128             xp.append("='").append(CmsResourceTypeFolderExtended.CONFIGURATION_FOLDER_CLASS_PARAMS);
129             xp.append("']");
130             m_xpaths = Collections.singletonList(xp.toString());
131         }
132         return m_xpaths;
133     }
134
135 }
Popular Tags