Search in sources :

Example 1 with PageURL

use of com.agiletec.aps.system.services.url.PageURL in project entando-core by entando.

the class SystemInfoWrapper method getActionPathUrl.

public String getActionPathUrl(String actionPath) {
    String url = null;
    RequestContext reqCtx = this.getReqCtx();
    IURLManager urlManager = (IURLManager) ApsWebApplicationUtils.getBean(SystemConstants.URL_MANAGER, reqCtx.getRequest());
    try {
        PageURL pageUrl = urlManager.createURL(reqCtx);
        IPage currPage = (IPage) reqCtx.getExtraParam(SystemConstants.EXTRAPAR_CURRENT_PAGE);
        Integer currentFrame = (Integer) reqCtx.getExtraParam(SystemConstants.EXTRAPAR_CURRENT_FRAME);
        pageUrl.setPage(currPage);
        pageUrl.addParam(InternalServletTag.REQUEST_PARAM_ACTIONPATH, actionPath);
        pageUrl.addParam(InternalServletTag.REQUEST_PARAM_FRAMEDEST, currentFrame.toString());
        url = pageUrl.getURL();
    } catch (Throwable t) {
        _logger.error("Error getting path for action path: {}", actionPath, t);
        return null;
    }
    return url;
}
Also used : IPage(com.agiletec.aps.system.services.page.IPage) PageURL(com.agiletec.aps.system.services.url.PageURL) IURLManager(com.agiletec.aps.system.services.url.IURLManager) RequestContext(com.agiletec.aps.system.RequestContext)

Example 2 with PageURL

use of com.agiletec.aps.system.services.url.PageURL in project entando-core by entando.

the class LinkResolverManager method resolveLink.

@Override
public String resolveLink(SymbolicLink symbolicLink, String contentId, RequestContext reqCtx) {
    if (null == symbolicLink) {
        _logger.error("Null Symbolic Link");
        return "";
    }
    String url = null;
    try {
        if (symbolicLink.getDestType() == SymbolicLink.URL_TYPE) {
            url = symbolicLink.getUrlDest();
        } else if (symbolicLink.getDestType() == SymbolicLink.PAGE_TYPE) {
            PageURL pageUrl = this.getUrlManager().createURL(reqCtx);
            pageUrl.setPageCode(symbolicLink.getPageDest());
            url = pageUrl.getURL();
        } else if (symbolicLink.getDestType() == SymbolicLink.CONTENT_ON_PAGE_TYPE) {
            PageURL pageUrl = this.getUrlManager().createURL(reqCtx);
            pageUrl.setPageCode(symbolicLink.getPageDest());
            pageUrl.addParam(SystemConstants.K_CONTENT_ID_PARAM, symbolicLink.getContentDest());
            url = pageUrl.getURL();
        } else if (symbolicLink.getDestType() == SymbolicLink.CONTENT_TYPE) {
            PageURL pageUrl = this.getUrlManager().createURL(reqCtx);
            String contentIdDest = symbolicLink.getContentDest();
            String pageCode = this.getContentPageMapperManager().getPageCode(contentIdDest);
            boolean forwardToDefaultPage = !this.isPageAllowed(reqCtx, pageCode);
            if (forwardToDefaultPage) {
                String viewPageCode = this.getContentManager().getViewPage(contentIdDest);
                pageUrl.setPageCode(viewPageCode);
                pageUrl.addParam(SystemConstants.K_CONTENT_ID_PARAM, contentIdDest);
            } else {
                pageUrl.setPageCode(pageCode);
            }
            url = pageUrl.getURL();
        } else if (symbolicLink.getDestType() == SymbolicLink.RESOURCE_TYPE) {
            ResourceInterface resource = this.getResourceManager().loadResource(symbolicLink.getResourceDest());
            if (null != resource) {
                url = resource.getDefaultUrlPath();
                if (!resource.getMainGroup().equals(Group.FREE_GROUP_NAME)) {
                    if (!url.endsWith("/")) {
                        url += "/";
                    }
                    url += AbstractResourceAttribute.REFERENCED_RESOURCE_INDICATOR + "/" + contentId + "/";
                }
            }
        }
    } catch (Throwable t) {
        _logger.error("Error resolve link from SymbolicLink", t);
        throw new RuntimeException("Error resolve link from SymbolicLink", t);
    }
    return url;
}
Also used : PageURL(com.agiletec.aps.system.services.url.PageURL) ResourceInterface(com.agiletec.plugins.jacms.aps.system.services.resource.model.ResourceInterface)

Example 3 with PageURL

use of com.agiletec.aps.system.services.url.PageURL in project entando-core by entando.

the class PageInfoTag method extractPageUrl.

protected void extractPageUrl(IPage page, Lang currentLang, RequestContext reqCtx) {
    IURLManager urlManager = (IURLManager) ApsWebApplicationUtils.getBean(SystemConstants.URL_MANAGER, this.pageContext);
    PageURL pageUrl = urlManager.createURL(reqCtx);
    pageUrl.setPageCode(page.getCode());
    if (this.getLangCode() != null) {
        pageUrl.setLangCode(this.getLangCode());
    } else {
        pageUrl.setLangCode(currentLang.getCode());
    }
    if (null != this.getParameters()) {
        Iterator<String> iter = this.getParameters().keySet().iterator();
        while (iter.hasNext()) {
            String name = (String) iter.next();
            pageUrl.addParam(name, this.getParameters().get(name));
        }
    }
    this.setValue(pageUrl.getURL());
}
Also used : PageURL(com.agiletec.aps.system.services.url.PageURL) IURLManager(com.agiletec.aps.system.services.url.IURLManager)

Example 4 with PageURL

use of com.agiletec.aps.system.services.url.PageURL in project entando-core by entando.

the class AbstractControlService method redirect.

protected int redirect(String redirDestPage, Map<String, String> params, RequestContext reqCtx) {
    int retStatus;
    try {
        String redirPar = this.getParameter(RequestContext.PAR_REDIRECT_FLAG, reqCtx);
        if (redirPar == null || "".equals(redirPar)) {
            PageURL url = this.getUrlManager().createURL(reqCtx);
            url.setPageCode(redirDestPage);
            if (null != params && !params.isEmpty()) {
                Iterator<String> iter = params.keySet().iterator();
                while (iter.hasNext()) {
                    String key = iter.next();
                    url.addParam(key, params.get(key));
                }
            }
            url.addParam(RequestContext.PAR_REDIRECT_FLAG, "1");
            url.setEscapeAmp(false);
            String redirUrl = url.getURL();
            _logger.debug("Redirecting to {}", redirUrl);
            return this.redirectUrl(redirUrl, reqCtx);
        } else {
            reqCtx.setHTTPError(HttpServletResponse.SC_BAD_REQUEST);
            retStatus = ControllerManager.ERROR;
        }
    } catch (Throwable t) {
        retStatus = ControllerManager.SYS_ERROR;
        reqCtx.setHTTPError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
        _logger.error("Error on creation redirect to page {}", redirDestPage, t);
    }
    return retStatus;
}
Also used : PageURL(com.agiletec.aps.system.services.url.PageURL)

Example 5 with PageURL

use of com.agiletec.aps.system.services.url.PageURL in project entando-core by entando.

the class SystemInfoWrapper method getPageURLWithWidget.

public String getPageURLWithWidget(String widgetCode) {
    String url = null;
    try {
        IPage page = this.getPageWithWidget(widgetCode);
        if (null == page) {
            return url;
        }
        IURLManager urlManager = (IURLManager) ApsWebApplicationUtils.getBean(SystemConstants.URL_MANAGER, this.getReqCtx().getRequest());
        PageURL pageUrl = urlManager.createURL(this.getReqCtx());
        pageUrl.setPage(page);
        url = pageUrl.getURL();
    } catch (Throwable t) {
        _logger.error("Error getting pageUrl with widget: {}", widgetCode, t);
        return null;
    }
    return url;
}
Also used : IPage(com.agiletec.aps.system.services.page.IPage) PageURL(com.agiletec.aps.system.services.url.PageURL) IURLManager(com.agiletec.aps.system.services.url.IURLManager)

Aggregations

PageURL (com.agiletec.aps.system.services.url.PageURL)9 IURLManager (com.agiletec.aps.system.services.url.IURLManager)6 IPage (com.agiletec.aps.system.services.page.IPage)4 RequestContext (com.agiletec.aps.system.RequestContext)2 ResourceInterface (com.agiletec.plugins.jacms.aps.system.services.resource.model.ResourceInterface)1 IOException (java.io.IOException)1 ServletRequest (javax.servlet.ServletRequest)1 JspException (javax.servlet.jsp.JspException)1