/** * Convert to URL string to move the action. <br> * e.g. ProductListAction to /product/list/ <br> * And not contain context path. * @param actionType The class type of action that it redirects to. (NotNull) * @return The URL string to move to the action. (NotNull) */ public String toActionUrl(Class<?> actionType) { assertArgumentNotNull("actionType", actionType); return toActionUrl(actionType, EMPTY_URL_CHAIN); }
/** * Initialize this component. <br> * This is basically called by DI setting file. */ @PostConstruct public synchronized void initialize() { final FwWebDirection direction = assistOptionalActionDirection(); actionAdjustmentProvider = direction.assistActionAdjustmentProvider(); showBootLogging(); }
/** * Convert to URL string to move the action. <br> * e.g. ProductListAction with moreUrl(3) to /product/list/3 <br> * And not contain context path. * @param actionType The class type of action that it redirects to. (NotNull) * @param chain The chain of URL to build additional info on URL. (NotNull) * @return The URL string to move to the action. (NotNull) */ public String toActionUrl(Class<?> actionType, UrlChain chain) { assertArgumentNotNull("actionType", actionType); assertArgumentNotNull("chain", chain); final UrlReverseOption option = customizeActionUrlReverse(actionType, chain); // not null, empty allowed final StringBuilder sb = new StringBuilder(); buildActionPath(sb, actionType, option); buildUrlParts(sb, chain); buildGetParam(sb, chain); buildHashOnUrl(sb, chain); return sb.toString(); }
/** * Handle the action path from the specified request path. * @param requestPath The request path to be analyzed. (NotNull) * @param handler The handler of the action path when the action is found. (NotNull) * @return Is it actually handled? (false if not found) * @throws Exception When the handler throws or internal process throws. */ public boolean handleActionPath(String requestPath, ActionFoundPathHandler handler) throws Exception { assertArgumentNotNull("requestPath", requestPath); assertArgumentNotNull("handler", handler); final MappingPathResource pathResource = customizeActionMapping(requestPath); return mappingActionPath(pathResource, handler); }
/** * Convert to URL string to move the action. * <pre> * <span style="color: #3F7E5E">// /product/list/</span> * String url = toActionUrl(ProductListAction.<span style="color: #70226C">class</span>); * </pre> * @param actionType The class type of action that it redirects to. (NotNull) * @return The URL string to move to the action. (NotNull) */ protected String toActionUrl(Class<?> actionType) { assertArgumentNotNull("actionType", actionType); return actionPathResolver.toActionUrl(actionType); }
final String[] names = LdiStringUtil.split(mappingPath, URL_DELIMITER); // e.g. [sea, land] if /sea/land/ final LaContainer root = container.getRoot(); // because actions are in root final String rootAction = buildActionName(pathResource, null, "root"); if (names.length == 0) { // root action, / => rootAction if (hasActionDef(root, rootAction)) { if (executeHandlerIfFound(pathResource, handler, rootAction, null)) { return true; if (containsNotAllowedCharacterAsActionPath(currentName)) { // e.g. /Sea/land/, /sea/Land/ return false; // cannot use upper case in action path (while, allowed in param path) final String directAction = buildActionName(pathResource, null, currentName); if (hasActionDef(root, directAction)) { if (executeHandlerIfFound(pathResource, handler, directAction, buildParamPath(names, nextIndex))) { return true; final String wholePkgAction = buildActionName(pathResource, currentName + "_", currentName); if (hasActionDef(root, wholePkgAction)) { if (executeHandlerIfFound(pathResource, handler, wholePkgAction, buildParamPath(names, nextIndex))) { return true; final String classPrefix = prefixSb.toString() + initCap(currentName); // seaLand, seaLandPiari final String actionName = buildActionName(pathResource, pkgSb != null ? pkgSb.toString() : null, classPrefix); if (hasActionDef(root, actionName)) { if (executeHandlerIfFound(pathResource, handler, actionName, buildParamPath(names, nextIndex))) { return true; final String morePkgActionName = buildActionName(pathResource, pkgSb.toString(), classPrefix);
public String prepareExpectedRoutingMessage(String requestPath) { // for debug final StringBuilder sb = new StringBuilder(); sb.append("\n"); sb.append("/= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = *No routing action:\n"); sb.append("e.g. expected actions for ").append(requestPath).append("\n"); final MappingPathResource pathResource = customizeActionMapping(requestPath); final List<String> nameList = buildExpectedRoutingActionList(pathResource.getMappingPath()); boolean exists = false; for (String name : nameList) { if (name.endsWith("@index()") && containsNotAllowedCharacterAsActionPath(requestPath)) { // e.g. /product/List/ continue; } final String packageExp = Srl.substringLastFront(name, "."); if (!containsNotAllowedCharacterAsActionPath(packageExp)) { sb.append(" web.").append(name).append("\n"); exists = true; } } if (exists) { sb.append(" (and so on...)\n"); } else { sb.append(" *no suggestion... e.g. cannot use upper case in action path\n"); } sb.append("= = = = = = = = = =/"); return sb.toString(); }
protected void resolveAbsolutePath(String input, StringBuilder sb) { final int paramMarkIndex = input.indexOf('?'); final String path = paramMarkIndex >= 0 ? input.substring(0, paramMarkIndex) : input; final String queryString = paramMarkIndex >= 0 ? input.substring(paramMarkIndex) : ""; final ActionPathResolver resolver = getActionResolver(); try { final ActionFoundPathHandler handler = createActionPathHandler(sb, path, queryString); final boolean handled = resolver.handleActionPath(path, handler); if (!handled) { throwLinkActionNotFoundException(path, queryString); } } catch (Exception e) { if (e instanceof RuntimeException) { throw (RuntimeException) e; } else { final String msg = "Failed to handle action path: " + path; throw new IllegalStateException(msg, e); } } }
protected String toActionUrl(Class<?> actionType) { // #hope get it from requestManager or response saves action type return getActionPathResolver().toActionUrl(actionType); }
final String[] names = LdiStringUtil.split(mappingPath, URL_DELIMITER); // e.g. [sea, land] if /sea/land/ final LaContainer root = container.getRoot(); // because actions are in root final String rootAction = buildActionName(pathResource, null, "root"); if (names.length == 0) { // root action, / => rootAction if (hasActionDef(root, rootAction)) { if (executeHandlerIfFound(pathResource, handler, rootAction, null)) { return true; if (containsNotAllowedCharacterAsActionPath(currentName)) { // e.g. /Sea/land/, /sea/Land/ return false; // cannot use upper case in action path (while, allowed in param path) final String directAction = buildActionName(pathResource, null, currentName); if (hasActionDef(root, directAction)) { if (executeHandlerIfFound(pathResource, handler, directAction, buildParamPath(names, nextIndex))) { return true; final String wholePkgAction = buildActionName(pathResource, currentName + "_", currentName); if (hasActionDef(root, wholePkgAction)) { if (executeHandlerIfFound(pathResource, handler, wholePkgAction, buildParamPath(names, nextIndex))) { return true; final String classPrefix = prefixSb.toString() + initCap(currentName); // seaLand, seaLandPiari final String actionName = buildActionName(pathResource, pkgSb != null ? pkgSb.toString() : null, classPrefix); if (hasActionDef(root, actionName)) { if (executeHandlerIfFound(pathResource, handler, actionName, buildParamPath(names, nextIndex))) { return true; final String morePkgActionName = buildActionName(pathResource, pkgSb.toString(), classPrefix);
/** * Handle the action path from the specified request path. * @param requestPath The request path to be analyzed. (NotNull) * @param handler The handler of the action path when the action is found. (NotNull) * @return Is it actually handled? (false if not found) * @throws Exception When the handler throws or internal process throws. */ public boolean handleActionPath(String requestPath, ActionFoundPathHandler handler) throws Exception { assertArgumentNotNull("requestPath", requestPath); assertArgumentNotNull("handler", handler); final MappingPathResource pathResource = customizeActionMapping(requestPath); return mappingActionPath(pathResource, handler); }
public String prepareExpectedRoutingMessage(String requestPath) { // for debug final StringBuilder sb = new StringBuilder(); sb.append("\n"); sb.append("/= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = *No routing action:\n"); sb.append("e.g. expected actions for ").append(requestPath).append("\n"); final MappingPathResource pathResource = customizeActionMapping(requestPath); final List<String> nameList = buildExpectedRoutingActionList(pathResource.getMappingPath()); boolean exists = false; for (String name : nameList) { if (name.endsWith("@index()") && containsNotAllowedCharacterAsActionPath(requestPath)) { // e.g. /product/List/ continue; } final String packageExp = Srl.substringLastFront(name, "."); if (!containsNotAllowedCharacterAsActionPath(packageExp)) { sb.append(" web.").append(name).append("\n"); exists = true; } } if (exists) { sb.append(" (and so on...)\n"); } else { sb.append(" *no suggestion... e.g. cannot use upper case in action path\n"); } sb.append("= = = = = = = = = =/"); return sb.toString(); }
@Override protected void lookup() throws JspException { setupModuleConfig(); setupActionForNow(); final int paramMarkIndex = action.indexOf('?'); final String path = paramMarkIndex >= 0 ? action.substring(0, paramMarkIndex) : action; final String queryString = paramMarkIndex >= 0 ? action.substring(paramMarkIndex) : ""; final ActionPathResolver resolver = getActionResolver(); try { final ActionFoundPathHandler handler = createActionPathHandler(path, queryString); final boolean handled = resolver.handleActionPath(path, handler); if (!handled) { throwFormActionNotFoundException(path, queryString); } } catch (Exception e) { if (e instanceof RuntimeException) { throw (RuntimeException) e; } else if (e instanceof JspException) { throw (JspException) e; } else { String msg = "Failed to handle action path: " + path; throw new IllegalStateException(msg, e); } } checkActionMappingExistence(); setupBeanInfo(); }
/** * Convert to URL string to move the action. * <pre> * <span style="color: #3F7E5E">// /product/list/</span> * String url = toActionUrl(ProductListAction.<span style="color: #70226C">class</span>); * </pre> * @param actionType The class type of action that it redirects to. (NotNull) * @return The URL string to move to the action. (NotNull) */ protected String toActionUrl(Class<?> actionType) { assertArgumentNotNull("actionType", actionType); return actionPathResolver.toActionUrl(actionType); }
/** * Convert to URL string to move the action. <br> * e.g. ProductListAction with moreUrl(3) to /product/list/3 <br> * And not contain context path. * @param actionType The class type of action that it redirects to. (NotNull) * @param chain The chain of URL to build additional info on URL. (NotNull) * @return The URL string to move to the action. (NotNull) */ public String toActionUrl(Class<?> actionType, UrlChain chain) { assertArgumentNotNull("actionType", actionType); assertArgumentNotNull("chain", chain); final UrlReverseOption option = customizeActionUrlReverse(actionType, chain); // not null, empty allowed final StringBuilder sb = new StringBuilder(); buildActionPath(sb, actionType, option); buildUrlParts(sb, chain); buildGetParam(sb, chain); buildHashOnUrl(sb, chain); return sb.toString(); }
/** * Convert to URL string to move the action. <br> * e.g. ProductListAction to /product/list/ <br> * And not contain context path. * @param actionType The class type of action that it redirects to. (NotNull) * @return The URL string to move to the action. (NotNull) */ public String toActionUrl(Class<?> actionType) { assertArgumentNotNull("actionType", actionType); return toActionUrl(actionType, EMPTY_URL_CHAIN); }
final String contextPath = extractContextPath(httpReq); final ActionFoundPathHandler handler = createActionFoundPathHandler(httpReq, httpRes, contextPath); // (#to_action) if (resolver.handleActionPath(requestPath, handler)) { // #to_action return;
/** * Initialize this component. <br> * This is basically called by DI setting file. */ @PostConstruct public synchronized void initialize() { final FwWebDirection direction = assistOptionalActionDirection(); actionAdjustmentProvider = direction.assistActionAdjustmentProvider(); showBootLogging(); }
@Override public HtmlResponse redirectToLoginAction() { final Class<?> redirectLoginActionType = getRedirectLoginActionType(); final String actionUrl = actionPathResolver.toActionUrl(redirectLoginActionType); return HtmlResponse.fromRedirectPath(actionUrl); }
final String contextPath = extractContextPath(httpReq); final ActionFoundPathHandler handler = createActionPathHandler(httpReq, httpRes, contextPath); // (#to_action) if (resolver.handleActionPath(requestPath, handler)) { // #to_action return;