private boolean handleHelperStart() { Logger.log.info("Handling helper start in view: " + viewParameters.viewID); View view = new View(); List producersList = viewResolver.getProducers(viewParameters.viewID); if (producersList.size() != 1) { throw new IllegalArgumentException( "There is not exactly one view producer for the view: " + viewParameters.viewID); } ViewComponentProducer vp = (ViewComponentProducer) producersList.get(0); statePreservationManager.scopeRestore(); vp.fillComponents(view.viewroot, viewParameters, null); statePreservationManager.scopePreserve(); UIOutput helperId = (UIOutput) view.viewroot.getComponent(HelperViewParameters.HELPER_ID); UICommand helperBinding = (UICommand) view.viewroot.getComponent(HelperViewParameters.POST_HELPER_BINDING); tsh.putTokenState( TOKEN_STATE_PREFIX + viewParameters.viewID + HelperViewParameters.HELPER_ID, helperId.getValue()); if (helperBinding != null) { tsh.putTokenState( TOKEN_STATE_PREFIX + viewParameters.viewID + HelperViewParameters.POST_HELPER_BINDING, helperBinding.methodbinding); // Support for a ParameterList on the UICommand if (helperBinding.parameters != null) { tsh.putTokenState( TOKEN_STATE_PREFIX + viewParameters.viewID + POST_HELPER_BINDING_PARAMLIST, helperBinding.parameters); } } // We need to save these ViewParameters for ActionResultInterceptors tsh.putTokenState( TOKEN_STATE_PREFIX + viewParameters.viewID + POST_HELPER_ARI2_VIEWPARAMS, viewParameters); // Hack to know if we're in the helper tsh.putTokenState(IN_HELPER_INDICATOR, IN_HELPER_INDICATOR); String helperToolPath = bup.getBaseURL() + viewParameters.viewID + IN_HELPER_PATH; tsh.putTokenState( helperId.getValue() + Tool.HELPER_DONE_URL, bup.getBaseURL() + viewParameters.viewID + HELPER_FINISHED_PATH); try { response.sendRedirect(helperToolPath); } catch (IOException e) { throw UniversalRuntimeException.accumulate( e, "IOException when trying to redirect to helper tool"); } return true; }
private boolean handleHelperHelper(final String pathBeyondViewID) { Logger.log.info( "Handling helper in view: " + viewParameters.viewID + " pathBeyondViewID: " + pathBeyondViewID); String helperId = (String) tsh.getTokenState( TOKEN_STATE_PREFIX + viewParameters.viewID + HelperViewParameters.HELPER_ID); if (pathBeyondViewID.endsWith(".helper")) { int i = pathBeyondViewID.lastIndexOf('/'); if (i >= 0) { String helperName = pathBeyondViewID.substring(i + 1); String toolName = pathBeyondViewID.substring(0, i); i = helperName.lastIndexOf('.'); helperName = helperName.substring(0, i); Logger.log.debug("new helper name" + helperName); Logger.log.debug("tool name" + toolName); tsh.putTokenState(TOKEN_STATE_PREFIX + viewParameters.viewID + "orig-helper-id", helperId); tsh.putTokenState( TOKEN_STATE_PREFIX + viewParameters.viewID + "helper-tool-name", toolName); helperId = helperName; tsh.putTokenState( TOKEN_STATE_PREFIX + viewParameters.viewID + HelperViewParameters.HELPER_ID, helperId); } } String origToolName = (String) tsh.getTokenState(TOKEN_STATE_PREFIX + viewParameters.viewID + "helper-tool-name"); if (origToolName != null && pathBeyondViewID.endsWith(origToolName)) { helperId = (String) tsh.getTokenState(TOKEN_STATE_PREFIX + viewParameters.viewID + "orig-helper-id"); Logger.log.debug("returning to " + helperId); tsh.putTokenState( TOKEN_STATE_PREFIX + viewParameters.viewID + HelperViewParameters.HELPER_ID, helperId); tsh.clearTokenState(TOKEN_STATE_PREFIX + viewParameters.viewID + "helper-tool-name"); tsh.clearTokenState(TOKEN_STATE_PREFIX + viewParameters.viewID + "orig-helper-id"); } ActiveTool helperTool = activeToolManager.getActiveTool(helperId); String baseUrl = bup.getBaseURL(); int hostStart = baseUrl.indexOf("://") + 3; int hostEnd = baseUrl.indexOf('/', hostStart); String contextPath = baseUrl.substring(hostEnd); contextPath += viewParameters.viewID; contextPath += IN_HELPER_PATH; String helperPathInfo = pathInfo[0] + "/" + pathInfo[1]; request.removeAttribute(Tool.NATIVE_URL); // this is the forward call try { helperTool.help(request, response, contextPath, helperPathInfo); } catch (ToolException e) { throw UniversalRuntimeException.accumulate( e, "ToolException when trying to call help. HelperId: " + helperId + " contextPath: " + contextPath + " pathInfo: " + pathInfo); } return true; }