KickJava   Java API By Example, From Geeks To Geeks.

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


1 /*
2  * File : $Source: /usr/local/cvs/opencms/src/org/opencms/setup/xml/A_CmsXmlWorkplace.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.CmsWorkplaceConfiguration;
35 import org.opencms.configuration.I_CmsXmlConfiguration;
36
37 import org.dom4j.Document;
38
39 /**
40  * Skeleton for handling opencms-workplace.xml.<p>
41  *
42  * @author Michael Moossen
43  *
44  * @version $Revision: 1.2 $
45  *
46  * @since 6.1.8
47  */

48 public abstract class A_CmsXmlWorkplace extends A_CmsSetupXmlUpdate {
49
50     /**
51      * @see org.opencms.setup.xml.I_CmsSetupXmlUpdate#getXmlFilename()
52      */

53     public String JavaDoc getXmlFilename() {
54
55         return CmsWorkplaceConfiguration.DEFAULT_XML_FILE_NAME;
56     }
57
58     /**
59      * Creates a new access control entry node.<p>
60      *
61      * @param document the xml document to change
62      * @param xpath the base xpath
63      * @param principal the principal
64      * @param permissions the permissions string
65      *
66      * @return if a modification has been needed
67      */

68     protected boolean setAccessEntry(Document document, String JavaDoc xpath, String JavaDoc principal, String JavaDoc permissions) {
69
70         boolean ret = false;
71         String JavaDoc xp = xpath
72             + "/"
73             + CmsWorkplaceConfiguration.N_ACCESSENTRY
74             + "[@"
75             + CmsWorkplaceConfiguration.A_PRINCIPAL
76             + "='"
77             + principal
78             + "']";
79         if (CmsSetupXmlHelper.getValue(document, xp + "/@" + CmsWorkplaceConfiguration.A_PRINCIPAL) == null) {
80             ret = true;
81         }
82         CmsSetupXmlHelper.setValue(document, xp + "/@" + CmsWorkplaceConfiguration.A_PRINCIPAL, principal);
83         if (!permissions.equals(CmsSetupXmlHelper.getValue(document, xp
84             + "/@"
85             + CmsWorkplaceConfiguration.A_PERMISSIONS))) {
86             CmsSetupXmlHelper.setValue(document, xp + "/@" + CmsWorkplaceConfiguration.A_PERMISSIONS, permissions);
87             ret = true;
88         }
89         return ret;
90     }
91
92     /**
93      * Creates a new context menu entry node.<p>
94      *
95      * @param document the xml document to change
96      * @param xpath the base xpath
97      * @param key the localization key name
98      * @param uri the entry uri
99      * @param rules the permissions rules
100      * @param order the relative order
101      */

102     protected void setMenuEntry(Document document, String JavaDoc xpath, String JavaDoc key, String JavaDoc uri, String JavaDoc rules, String JavaDoc order) {
103
104         String JavaDoc xp = xpath
105             + "/"
106             + CmsWorkplaceConfiguration.N_ENTRY
107             + "[@"
108             + I_CmsXmlConfiguration.A_URI
109             + "='"
110             + uri
111             + "']";
112         CmsSetupXmlHelper.setValue(document, xp + "/@" + I_CmsXmlConfiguration.A_URI, uri);
113         CmsSetupXmlHelper.setValue(document, xp + "/@" + I_CmsXmlConfiguration.A_KEY, key);
114         CmsSetupXmlHelper.setValue(document, xp + "/@" + CmsWorkplaceConfiguration.A_RULES, rules);
115         CmsSetupXmlHelper.setValue(document, xp + "/@" + I_CmsXmlConfiguration.A_ORDER, order);
116     }
117 }
Popular Tags