66 return true;
67 }
68 }
69 return false;
70 }
71
72 /** *//**
73 * Determine the next view based on the current view
74 * (<code>from-view-id</code>
75 * stored in <code>FacesContext</code>), <code>fromAction</code> and
76 * <code>outcome</code>.
77 *
78 * @param context
79 * The <code>FacesContext</code>
80 * @param fromAction
81 * the action reference string
82 * @param outcome
83 * the outcome string
84 */
85 public void handleNavigation(FacesContext context, String fromAction,
86 String outcome) {
87 if (context == null) {
88 String message = Util
89 .getExceptionMessageString(Util.
90 NULL_PARAMETERS_ERROR_MESSAGE_ID);
91 message = message + " context " + context;
92 throw new NullPointerException(message);
93 }
94 if (outcome == null) {
95 if (DEBUGLOG.isDebugEnabled()) {
96 DEBUGLOG.debug("No navigation rule found for outcome "
97 + outcome + "and viewId "
98 + context.getViewRoot().getViewId()
99 + " Explicitly remain on the current view ");
100 }
101 return; // Explicitly remain on the current view
102 }
103 CaseStruct caseStruct = getViewId(context, fromAction, outcome);
104 ExternalContext extContext = context.getExternalContext();
105 if (caseStruct != null) {
106 Object obj = context.getExternalContext().getSessionMap().get(
107 Constant.LOGIN_INFO_KEY);
108 List authList = null;
109 if (obj != null) {
110 authList = ((LoginInfo) obj).getAuthorityFunctionVoList();
111 }
112 String uri = caseStruct.navCase.getToViewId().replace(".jsp",
113 ".faces");
114 boolean flag=true;
115 if (this.IGNORED_URI.indexOf(uri) < 0) {
116 if (authList != null && !this.checkURL(authList, uri)) {
117 // URI is invalid
118 flag=false;
119 }
120 }
121
122 ViewHandler viewHandler = Util.getViewHandler(context);
123 Util.doAssert(null != viewHandler);
124
125 if (caseStruct.navCase.hasRedirect()) {
126 // perform a 302 redirect.
127 String newPath = viewHandler.getActionURL(context,
128 caseStruct.viewId);
129
130 try {
131 if (DEBUGLOG.isDebugEnabled()) {
132 DEBUGLOG.debug("Redirecting to path " + newPath
133 + " for outcome " + outcome + "and viewId "
134 + caseStruct.viewId);
135 }
136 extContext.redirect(newPath);
137 } catch (java.io.IOException ioe) {
138 String message = "Redirect to " + newPath + " failed.";
139 ERRORLOG.error(message);
140 throw new FacesException(message, ioe);
141 }
142 context.responseComplete();
143 if (DEBUGLOG.isDebugEnabled()) {
144 DEBUGLOG
145 .debug("Response complete for "
146 + caseStruct.viewId);
147 }
148 } else {
149 UIViewRoot newRoot = null;
150 if (flag) {
151 newRoot = viewHandler
152 .createView(context, caseStruct.viewId);
153 } else {
154 newRoot = viewHandler.createView(context,
155 "/backForward.jsp");
156 }
157 context.setViewRoot(newRoot);
158 if (DEBUGLOG.isDebugEnabled()) {
159 DEBUGLOG.debug("Set new view in FacesContext for "
160 + caseStruct.viewId);
161 }
162 }
163 }
164 }
165
166 /** *//**
167 * This method uses helper methods to determine the new <code>view</code>
168 * identifier. Refer to section 7.4.2 of the specification for more details.
169 *
170 * @param context
171 * The Faces Context
172 * @param fromAction
173 * The action reference string
174 * @param outcome
175 * The outcome string
176 * @return The <code>view</code> identifier.
177 */
178 private CaseStruct getViewId(FacesContext context, String fromAction,

