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:
06: package org.jasig.portal.layout.dlm;
07:
08: import org.jasig.portal.PortalException;
09: import org.jasig.portal.security.IPerson;
10: import org.w3c.dom.Element;
11:
12: /**
13: * Layout processing action to reset an attribute to the value specified by the
14: * owning fragment.
15: *
16: * @author Mark Boyd
17: */
18: public class LPAResetAttribute implements ILayoutProcessingAction {
19: private String nodeId = null;
20: private String name = null;
21: private IPerson person = null;
22: private Element ilfNode = null;
23: private String fragmentValue = null;
24:
25: LPAResetAttribute(String nodeId, String name, String fragmentValue,
26: IPerson p, Element ilfNode) {
27: this .nodeId = nodeId;
28: this .name = name;
29: this .person = p;
30: this .ilfNode = ilfNode;
31: this .fragmentValue = fragmentValue;
32: }
33:
34: /**
35: * Reset a parameter to not override the value specified by a fragment.
36: * This is done by removing the parm edit in the PLF and setting the value
37: * in the ILF to the passed-in fragment value.
38: */
39: public void perform() throws PortalException {
40: /*
41: * push the change into the PLF
42: */
43: if (nodeId.startsWith(Constants.FRAGMENT_ID_USER_PREFIX)) {
44: // remove the parm edit
45: EditManager.removeEditDirective(nodeId, name, person);
46:
47: // handle label localization updates
48: if (name.equals(Constants.ATT_NAME)
49: && DistributedLayoutManager.ContextHolder.labelPolicy != null) {
50: Element plfNode = HandlerUtils.getPLFNode(ilfNode,
51: person, false, // create node if not found
52: false); // don't create children
53: if (plfNode != null) // will always be non-null if we get here
54: {
55: String plfId = plfNode
56: .getAttribute(Constants.ATT_PLF_ID);
57: DistributedLayoutManager.ContextHolder.labelPolicy
58: .deleteNodeLabel(nodeId, plfId, false, // only remove for current locale
59: person.getID(), false); // not a fragment owner
60: }
61: }
62: }
63: /*
64: * push the fragment value into the ILF if not the name element. For the
65: * name element the locale specific value will be injected during
66: * layout rendering.
67: */
68: if (!name.equals(Constants.ATT_NAME)) {
69: ilfNode.setAttribute(name, fragmentValue);
70: }
71: }
72: }
|