01: /* Copyright 2001 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.immutable;
07:
08: import org.jasig.portal.utils.SAX2FilterImpl;
09: import org.xml.sax.Attributes;
10: import org.xml.sax.ContentHandler;
11: import org.xml.sax.SAXException;
12: import org.xml.sax.XMLReader;
13: import org.xml.sax.helpers.AttributesImpl;
14:
15: /**
16: * This filter will mark all folders and channels as unremovable and immutable.
17: *
18: * Prior to uPortal 2.5, this class existed in the package org.jasig.portal.layout.
19: * It was moved to its present package to associate it with the
20: * ImmutableUserLayoutManagerWrapper and to separate it from the general Layout API.
21: *
22: * @author Peter Kharchenko {@link <a href="mailto:pkharchenko@interactivebusiness.com"">pkharchenko@interactivebusiness.com"</a>}
23: * @version 1.0 $Revision: 36690 $ $Date: 2006-08-25 14:03:25 -0700 (Fri, 25 Aug 2006) $
24: */
25: public class ImmutableUserLayoutSAXFilter extends SAX2FilterImpl {
26:
27: // downward
28: public ImmutableUserLayoutSAXFilter(ContentHandler handler) {
29: super (handler);
30: }
31:
32: // upward
33: public ImmutableUserLayoutSAXFilter(XMLReader parent) {
34: super (parent);
35: }
36:
37: public void startElement(String uri, String localName,
38: String qName, Attributes atts) throws SAXException {
39: // recognizing "channel"
40: if (qName.equals("channel") || qName.equals("folder")) {
41: // todo: deal with permissions on the top-level <layout> node
42: AttributesImpl attsImpl = new AttributesImpl(atts);
43: attsImpl.setValue(attsImpl.getIndex("unremovable"), "true");
44: attsImpl.setValue(attsImpl.getIndex("immutable"), "true");
45: super.startElement(uri, localName, qName, attsImpl);
46: } else {
47: super.startElement(uri, localName, qName, atts);
48: }
49: }
50: }
|