001: /* Copyright 2001, 2004 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.channels;
007:
008: import java.io.PrintWriter;
009:
010: import org.jasig.portal.ChannelCacheKey;
011: import org.jasig.portal.ChannelRuntimeData;
012: import org.jasig.portal.ChannelRuntimeProperties;
013: import org.jasig.portal.ChannelStaticData;
014: import org.jasig.portal.ICacheable;
015: import org.jasig.portal.IChannel;
016: import org.jasig.portal.ICharacterChannel;
017: import org.jasig.portal.IPrivilegedChannel;
018: import org.jasig.portal.PortalControlStructures;
019: import org.jasig.portal.PortalEvent;
020: import org.jasig.portal.PortalException;
021: import org.jasig.portal.channels.error.ErrorCode;
022: import org.xml.sax.ContentHandler;
023:
024: /**
025: * Deprecated legacy stub channel.
026: * CError has been moved to the org.jasig.portal.error package.
027: * This class exists to provide backwards compatibility -- it delegates to
028: * the org.jasig.portal.error.CError channel.
029: * @author andrew.petro@yale.edu
030: * @version $Revision: 35594 $ $Date: 2005-04-17 13:55:47 -0700 (Sun, 17 Apr 2005) $
031: * @deprecated moved to org.jasig.portal.channels.error package.
032: */
033: public class CError implements IPrivilegedChannel, ICacheable,
034: ICharacterChannel {
035:
036: /** Generic error code */
037: public static final int GENERAL_ERROR = 0;
038:
039: /** Error code for failure during rendering. */
040: public static final int RENDER_TIME_EXCEPTION = 1;
041:
042: /** Error code for errors at time static data is set */
043: public static final int SET_STATIC_DATA_EXCEPTION = 2;
044:
045: /** Error code for errors at time runtime data is set. */
046: public static final int SET_RUNTIME_DATA_EXCEPTION = 3;
047:
048: /** Error code for channels that fail to complete rendering during
049: * allotted time.
050: */
051: public static final int TIMEOUT_EXCEPTION = 4;
052:
053: /** Error code representing failure when framework attempts to set
054: * channel portal control structures.
055: */
056: public static final int SET_PCS_EXCEPTION = 5;
057:
058: /**
059: * Error code representing failure to render due to lack of authorization.
060: */
061: public static final int CHANNEL_AUTHORIZATION_EXCEPTION = 6;
062:
063: /**
064: * Error code representing the channel being just plain missing.
065: */
066: public static final int CHANNEL_MISSING_EXCEPTION = 7;
067:
068: // codes defining exception types
069: public static final int GENERAL_RENDERING_EXCEPTION = 1;
070: public static final int INTERNAL_TIMEOUT_EXCEPTION = 2;
071: public static final int AUTHORIZATION_EXCEPTION = 3;
072: public static final int RESOURCE_MISSING_EXCEPTION = 4;
073:
074: /**
075: * The modern CError instance to which we delegate.
076: */
077: private org.jasig.portal.channels.error.CError delegate;
078:
079: /**
080: * Construct an uninitialized instance of the CError channel.
081: */
082: public CError() {
083: this .delegate = new org.jasig.portal.channels.error.CError();
084: }
085:
086: /**
087: * Construct an instance of the Error channel representing a failure to render of
088: * a particular subscribed channel for reason of having thrown a Throwable.
089: * @param errorCode - one of the static error codes of this class
090: * @param throwable - cause of failed channel's failure
091: * @param channelSubscribeId - identifies the failed channel
092: * @param channelInstance - the failed channel
093: */
094: public CError(int errorCode, Throwable throwable,
095: String channelSubscribeId, IChannel channelInstance) {
096: ErrorCode codeObject = ErrorCode.codeForInt(errorCode);
097: this .delegate = new org.jasig.portal.channels.error.CError(
098: codeObject, throwable, channelSubscribeId,
099: channelInstance);
100: }
101:
102: /**
103: * Instantiate a CError representing a particular channel's failure,
104: * including a message and errorCode, but not a Throwable.
105: * @param errorCode - one of the static error codes of this class
106: * @param message - describes error
107: * @param channelSubscribeId - identifies failed channel
108: * @param channelInstance - failed channel
109: */
110: public CError(int errorCode, String message,
111: String channelSubscribeId, IChannel channelInstance) {
112: ErrorCode codeObject = ErrorCode.codeForInt(errorCode);
113: this .delegate = new org.jasig.portal.channels.error.CError(
114: codeObject, message, channelSubscribeId,
115: channelInstance);
116: }
117:
118: /**
119: * Instantiate a CError instance representing the failure of some particular channel,
120: * including an error code, message, and the Throwable.
121: * @param errorCode - one of the static error codes of this class
122: * @param exception - thrown by the failed channel
123: * @param channelSubscribeId - identifies failed channel
124: * @param channelInstance - the failed channel instance
125: * @param message - message describing failure
126: */
127: public CError(int errorCode, Throwable exception,
128: String channelSubscribeId, IChannel channelInstance,
129: String message) {
130: ErrorCode codeObject = ErrorCode.codeForInt(errorCode);
131: this .delegate = new org.jasig.portal.channels.error.CError(
132: codeObject, exception, channelSubscribeId,
133: channelInstance, message);
134: }
135:
136: /**
137: * Set the failure message.
138: * @param m - a mesage describing the error.
139: */
140: public void setMessage(String m) {
141: this .delegate.getErrorDocument().setMessage(m);
142: }
143:
144: public void setPortalControlStructures(PortalControlStructures pcs) {
145: this .delegate.setPortalControlStructures(pcs);
146: }
147:
148: /*
149: * This is so CError can be used by getUserLayout() as a placeholder for
150: * channels that have either been deleted from the portal database or
151: * the users permission to use the channel has been removed (permanently or
152: * temporarily).
153: */
154: public void setStaticData(ChannelStaticData sd) {
155: this .delegate.setStaticData(sd);
156: }
157:
158: public void renderXML(ContentHandler out) {
159: this .delegate.renderXML(out);
160: }
161:
162: public ChannelCacheKey generateKey() {
163: return this .delegate.generateKey();
164: }
165:
166: public boolean isCacheValid(Object validity) {
167: return this .delegate.isCacheValid(validity);
168: }
169:
170: public void renderCharacters(PrintWriter out)
171: throws PortalException {
172: this .delegate.renderCharacters(out);
173: }
174:
175: public void setRuntimeData(ChannelRuntimeData rd)
176: throws PortalException {
177: this .delegate.setRuntimeData(rd);
178: }
179:
180: public void receiveEvent(PortalEvent ev) {
181: this .delegate.receiveEvent(ev);
182: }
183:
184: public ChannelRuntimeProperties getRuntimeProperties() {
185: return this.delegate.getRuntimeProperties();
186: }
187:
188: }
|