01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * http://www.apache.org/licenses/LICENSE-2.0
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
16: *
17: * $Header:$
18: */
19: package org.apache.beehive.netui.pageflow;
20:
21: import org.apache.beehive.netui.util.Bundle;
22: import org.apache.beehive.netui.pageflow.internal.InternalUtils;
23: import org.apache.struts.action.ActionMapping;
24:
25: import javax.servlet.http.HttpServletRequest;
26: import javax.servlet.http.HttpServletResponse;
27: import java.io.IOException;
28: import java.io.PrintWriter;
29:
30: /**
31: * Base class for PageFlow-related Exceptions.
32: */
33: public abstract class PageFlowException extends
34: PageFlowManagedObjectException {
35: private String _actionName;
36:
37: protected PageFlowException(String actionName, FlowController fc) {
38: super (fc);
39: init(actionName);
40: }
41:
42: protected PageFlowException(String actionName, FlowController fc,
43: Throwable cause) {
44: super (fc, cause);
45: init(actionName);
46: }
47:
48: protected void init(String actionName) {
49: _actionName = actionName != null && actionName.length() > 0
50: && actionName.charAt(0) == '/' ? actionName
51: .substring(1) : actionName;
52: }
53:
54: /**
55: * Get the related FlowController.
56: *
57: * @return the {@link FlowController} associated with this exception.
58: */
59: public FlowController getFlowController() {
60: return (FlowController) getManagedObject();
61: }
62:
63: /**
64: * Get the name of the related FlowController.
65: *
66: * @return the class name of the {@link FlowController} associated with this exception.
67: */
68: public String getFlowControllerURI() {
69: FlowController flowController = getFlowController();
70: return flowController != null ? flowController.getDisplayName()
71: : null;
72: }
73:
74: /**
75: * Get the name of the action associated with this exception.
76: *
77: * @return a String that is the name of the action associated with this exception.
78: */
79: public String getActionName() {
80: return _actionName;
81: }
82:
83: /**
84: * Tell whether the root cause may be session expiration in cases where the requested session ID is different than
85: * the actual session ID; if <code>true</code>, then a {@link SessionExpiredException} will be thrown instead of
86: * this one in these situations.
87: */
88: public abstract boolean causeMayBeSessionExpiration();
89: }
|