01: /* Copyright 2005 The JA-SIG Collaborative. All rights reserved.
02: * See license distributed with this file and
03: * available online at http://www.uportal.org/license.html
04: */
05: package org.jasig.portal.layout.dlm;
06:
07: import org.w3c.dom.Attr;
08: import org.w3c.dom.Element;
09:
10: /**
11: * This class wraps folder layout elements in cached fragment definitions to
12: * enable the layout manager to make informed descisions on attributes should be
13: * persisted. Attributes on elements in the user's layout do not indicate
14: * if they came from a user change or from a fragment's defined value. This
15: * class enables the layout manager to make such determinations.
16: *
17: * @version $Revision: 36294 $ $Date: 2005-11-10 12:36:31 -0700 (Thu, 10 Nov 2005) $
18: * @author mboyd@sungardsct.com
19: * @since uPortal 2.6
20: */
21: class FragmentNodeInfo {
22: protected Element node = null;
23:
24: FragmentNodeInfo(Element node) {
25: this .node = node;
26: }
27:
28: /**
29: * Returns the value of an attribute or null if such an attribute is not
30: * defined on the underlying element.
31: */
32: public String getAttributeValue(String name) {
33: Attr att = node.getAttributeNode(name);
34: if (att == null)
35: return null;
36: return att.getNodeValue();
37: }
38:
39: /**
40: * Returns true if an attribute can be modified for a node. This is based
41: * on a single dlm:editAllowed attribute for nodes in fragments. If not
42: * included then edits to node attributes are allowed. If included with a
43: * value other than true then edits are prevented.
44: *
45: * @param name
46: * @return
47: */
48: public boolean canOverrideAttributes() {
49: Attr att = node.getAttributeNode(Constants.ATT_EDIT_ALLOWED);
50:
51: if (att == null)
52: return true;
53: return att.getNodeValue().equals("true");
54: }
55: }
|