01: /*
02: * Copyright 2002 Sun Microsystems, Inc. All
03: * rights reserved. Use of this product is subject
04: * to license terms. Federal Acquisitions:
05: * Commercial Software -- Government Users
06: * Subject to Standard License Terms and
07: * Conditions.
08: *
09: * Sun, Sun Microsystems, the Sun logo, and Sun ONE
10: * are trademarks or registered trademarks of Sun Microsystems,
11: * Inc. in the United States and other countries.
12: */
13:
14: package com.sun.portal.wsrp.consumer.markup;
15:
16: import java.lang.Exception;
17:
18: import com.sun.portal.container.ContentException;
19: import com.sun.portal.wsrp.consumer.common.WSRPConsumerErrorCode;
20: import com.sun.portal.wsrp.common.stubs.AccessDeniedFault;
21: import com.sun.portal.wsrp.common.stubs.InvalidSessionFault;
22: import com.sun.portal.wsrp.common.stubs.InvalidCookieFault;
23: import com.sun.portal.wsrp.common.stubs.MissingParametersFault;
24: import com.sun.portal.wsrp.common.stubs.OperationFailedFault;
25: import com.sun.portal.wsrp.common.stubs.PortletStateChangeRequiredFault;
26: import com.sun.portal.wsrp.common.stubs.UnsupportedLocaleFault;
27: import com.sun.portal.wsrp.common.stubs.UnsupportedMimeTypeFault;
28: import com.sun.portal.wsrp.common.stubs.UnsupportedModeFault;
29: import com.sun.portal.wsrp.common.stubs.UnsupportedWindowStateFault;
30: import com.sun.portal.wsrp.common.stubs.Fault;
31:
32: /**
33: * A ErrorCodeException is thrown when nothing error
34: * message needs to be displayed on the Provider.
35: **/
36: public class MarkupContentException extends ContentException {
37:
38: /**
39: * Constructs a new exception with the specified message, indicating an
40: * error in the provider as happened.<br><br>
41: *
42: * @param msg The descriptive message.
43: */
44: public MarkupContentException(WSRPConsumerErrorCode code, String msg) {
45: super (msg, code);
46: }
47:
48: /**
49: * Constructs a new exception with the specified message, and the original
50: * <code>exception</code> or <code>error</code>, indicating an error in the
51: * container as happened.<br><br>
52: *
53: * @param msg The descriptive message.
54: * @param e The original <code>exception</code> or <code>error</code>.
55: */
56: public MarkupContentException(WSRPConsumerErrorCode code,
57: String msg, Throwable e) {
58: super (msg, code, e);
59: }
60:
61: static public WSRPConsumerErrorCode getFaultErrorCode(Fault ex) {
62:
63: if (ex == null) {
64: throw new IllegalArgumentException("Null param");
65: }
66:
67: if (ex instanceof AccessDeniedFault) {
68: return WSRPConsumerErrorCode.ACCESS_DENIED_FAULT;
69: } else if (ex instanceof InvalidSessionFault) {
70: return WSRPConsumerErrorCode.INVALID_SESSION_FAULT;
71: } else if (ex instanceof InvalidCookieFault) {
72: return WSRPConsumerErrorCode.INVALID_COOKIE_FAULT;
73: } else if (ex instanceof MissingParametersFault) {
74: return WSRPConsumerErrorCode.MISSING_PARAMETERS_FAULT;
75: } else if (ex instanceof OperationFailedFault) {
76: return WSRPConsumerErrorCode.OPERATION_FAILED_FAULT;
77: } else if (ex instanceof PortletStateChangeRequiredFault) {
78: return WSRPConsumerErrorCode.PORTLET_STATE_CHANGE_REQUIRED_FAULT;
79: } else if (ex instanceof UnsupportedLocaleFault) {
80: return WSRPConsumerErrorCode.UNSUPPORTED_LOCALE_FAULT;
81: } else if (ex instanceof UnsupportedMimeTypeFault) {
82: return WSRPConsumerErrorCode.UNSUPPORTED_MIME_TYPE_FAULT;
83: } else if (ex instanceof UnsupportedModeFault) {
84: return WSRPConsumerErrorCode.UNSUPPORTED_MODE_FAULT;
85: } else if (ex instanceof UnsupportedWindowStateFault) {
86: return WSRPConsumerErrorCode.UNSUPPORTED_WINDOW_STATE_FAULT;
87: } else {
88: return WSRPConsumerErrorCode.GENERIC_CONTENT_EXCEPTION;
89: }
90:
91: }
92: }
|