001: /* Copyright 2002 The JA-SIG Collaborative. All rights reserved.
002: * See license distributed with this file and
003: * available online at http://www.uportal.org/license.html
004: */
005:
006: package org.jasig.portal.layout.immutable;
007:
008: import java.util.Enumeration;
009:
010: import javax.servlet.http.HttpServletRequest;
011:
012: import org.jasig.portal.PortalException;
013: import org.jasig.portal.UserPreferences;
014: import org.jasig.portal.layout.IUserLayout;
015: import org.jasig.portal.layout.IUserLayoutManager;
016: import org.jasig.portal.layout.IUserLayoutStore;
017: import org.jasig.portal.layout.LayoutEventListener;
018: import org.jasig.portal.layout.node.IUserLayoutNodeDescription;
019: import org.jasig.portal.security.IPerson;
020: import org.w3c.dom.Document;
021: import org.xml.sax.ContentHandler;
022:
023: /**
024: * Wraps {@link IUserLayoutManager} interface to prevent access to mutator methods.
025: *
026: * Prior to uPortal 2.5, this class existed in the package org.jasig.portal.layout.
027: * It was moved to its present package to associate it with the
028: * ImmutableUserLayoutSAXFilter and to separate it from the general Layout API.
029: *
030: * @author Peter Kharchenko {@link <a href="mailto:pkharchenko@interactivebusiness.com"">pkharchenko@interactivebusiness.com"</a>}
031: * @version 1.0 $Revision: 36690 $ $Date: 2006-08-25 14:03:25 -0700 (Fri, 25 Aug 2006) $
032: */
033: public class ImmutableUserLayoutManagerWrapper implements
034: IUserLayoutManager {
035: IUserLayoutManager man = null;
036: private String cacheKey = null;
037:
038: public ImmutableUserLayoutManagerWrapper(IUserLayoutManager manager)
039: throws PortalException {
040: this .man = manager;
041: if (man == null) {
042: throw new PortalException(
043: "Can not wrap a null IUserLayoutManager !");
044: }
045: }
046:
047: public IUserLayout getUserLayout() throws PortalException {
048: return man.getUserLayout();
049: }
050:
051: public void setUserLayout(IUserLayout userLayout)
052: throws PortalException {
053: }
054:
055: public void getUserLayout(ContentHandler ch) throws PortalException {
056: //todo: we should probably cache the output here and save a DOM transform - the user layout never changes here
057: man.getUserLayout(new ImmutableUserLayoutSAXFilter(ch));
058: // man.getUserLayout(ch);
059: }
060:
061: public void getUserLayout(String nodeId, ContentHandler ch)
062: throws PortalException {
063: man.getUserLayout(nodeId, new ImmutableUserLayoutSAXFilter(ch));
064: }
065:
066: public void setLayoutStore(IUserLayoutStore ls) {
067: }
068:
069: public void loadUserLayout() throws PortalException {
070: man.loadUserLayout();
071: }
072:
073: public void saveUserLayout() throws PortalException {
074: }
075:
076: public IUserLayoutNodeDescription getNode(String nodeId)
077: throws PortalException {
078: return man.getNode(nodeId);
079: }
080:
081: public IUserLayoutNodeDescription addNode(
082: IUserLayoutNodeDescription node, String parentId,
083: String nextSiblingId) throws PortalException {
084: return null;
085: }
086:
087: public boolean moveNode(String nodeId, String parentId,
088: String nextSiblingId) throws PortalException {
089: return false;
090: }
091:
092: public boolean deleteNode(String nodeId) throws PortalException {
093: return false;
094: }
095:
096: public boolean updateNode(IUserLayoutNodeDescription node)
097: throws PortalException {
098: return false;
099: }
100:
101: public boolean canAddNode(IUserLayoutNodeDescription node,
102: String parentId, String nextSiblingId)
103: throws PortalException {
104: return false;
105: }
106:
107: public boolean canMoveNode(String nodeId, String parentId,
108: String nextSiblingId) throws PortalException {
109: return false;
110: }
111:
112: public boolean canDeleteNode(String nodeId) throws PortalException {
113: return false;
114: }
115:
116: public boolean canUpdateNode(IUserLayoutNodeDescription nodeId)
117: throws PortalException {
118: return false;
119: }
120:
121: public void markAddTargets(IUserLayoutNodeDescription node) {
122: }
123:
124: public void markMoveTargets(String nodeId) throws PortalException {
125: }
126:
127: public String getParentId(String nodeId) throws PortalException {
128: return man.getParentId(nodeId);
129: }
130:
131: public Enumeration getChildIds(String nodeId)
132: throws PortalException {
133: return man.getChildIds(nodeId);
134: }
135:
136: public String getNextSiblingId(String nodeId)
137: throws PortalException {
138: return man.getNextSiblingId(nodeId);
139: }
140:
141: public String getPreviousSiblingId(String nodeId)
142: throws PortalException {
143: return man.getPreviousSiblingId(nodeId);
144: }
145:
146: public String getCacheKey() throws PortalException {
147: // remember the cache key, since it never changes
148: if (this .cacheKey == null) {
149: cacheKey = man.getCacheKey();
150: }
151: return this .cacheKey;
152: }
153:
154: // temp methods, to be removed (getDOM() might actually stay)
155: // This method should be removed whenever it becomes possible
156: public void setUserLayoutDOM(Document doc) {
157: }
158:
159: // This method should be removed whenever it becomes possible
160: public Document getUserLayoutDOM() throws PortalException {
161: return man.getUserLayoutDOM();
162: }
163:
164: public int getLayoutId() {
165: return man.getLayoutId();
166: }
167:
168: public String getRootFolderId() {
169: return man.getRootFolderId();
170: }
171:
172: /**
173: * Returns the depth of a node in the layout tree.
174: *
175: * @param nodeId a <code>String</code> value
176: * @return a depth value
177: * @exception PortalException if an error occurs
178: */
179: public int getDepth(String nodeId) throws PortalException {
180: return man.getDepth(nodeId);
181: }
182:
183: /**
184: * Returns a subscription id given a functional name.
185: *
186: * @param fname the functional name to lookup.
187: * @return a <code>String</code> subscription id.
188: */
189: public String getSubscribeId(String fname) throws PortalException {
190: return man.getSubscribeId(fname);
191: }
192:
193: /**
194: * A factory method to create an empty <code>IUserLayoutNodeDescription</code> instance
195: *
196: * @param nodeType a node type value
197: * @return an <code>IUserLayoutNodeDescription</code> instance
198: * @exception PortalException if the error occurs.
199: */
200: public IUserLayoutNodeDescription createNodeDescription(int nodeType)
201: throws PortalException {
202: return man.createNodeDescription(nodeType);
203: }
204:
205: public boolean addLayoutEventListener(LayoutEventListener l) {
206: return false;
207: }
208:
209: public boolean removeLayoutEventListener(LayoutEventListener l) {
210: return false;
211: }
212:
213: /**
214: * Ignores this call to prevent changes to the layout.
215: */
216: public void processLayoutParameters(IPerson person,
217: UserPreferences userPrefs, HttpServletRequest req)
218: throws PortalException {
219: }
220: }
|