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; }
public static org.sakaiproject.tool.api.ActiveTool getActiveTool(java.lang.String param0) { org.sakaiproject.tool.api.ActiveToolManager manager = getInstance(); if (manager == null) return null; return manager.getActiveTool(param0); }