Search in sources :

Example 6 with IURLManager

use of com.agiletec.aps.system.services.url.IURLManager 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);
        // ApsSystemUtils.logThrowable(t, this, "getPageURLWithWidget", "Error getting pageUrl with widget: " + widgetCode);
        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)

Example 7 with IURLManager

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

the class FrontServletActionRedirectResult method execute.

@Override
public void execute(ActionInvocation invocation) throws Exception {
    try {
        this.actionName = this.conditionalParse(this.actionName, invocation);
        if (this.namespace == null) {
            this.namespace = invocation.getProxy().getNamespace();
        } else {
            this.namespace = this.conditionalParse(this.namespace, invocation);
        }
        if (this.method == null) {
            this.method = "";
        } else {
            this.method = this.conditionalParse(this.method, invocation);
        }
        String anchorDest = null;
        Map<String, String> redirectParams = new HashMap<String, String>();
        ResultConfig resultConfig = invocation.getProxy().getConfig().getResults().get(invocation.getResultCode());
        if (resultConfig != null) {
            this.extractResultParams(redirectParams, resultConfig, invocation);
            anchorDest = this.extractAnchorDest(resultConfig, invocation);
        }
        HttpServletRequest request = ServletActionContext.getRequest();
        RequestContext reqCtx = (RequestContext) request.getAttribute(RequestContext.REQCTX);
        this.extractInternalServletParams(redirectParams, reqCtx);
        IURLManager urlManager = (IURLManager) ApsWebApplicationUtils.getBean(SystemConstants.URL_MANAGER, request);
        Page currentPage = (Page) reqCtx.getExtraParam(SystemConstants.EXTRAPAR_CURRENT_PAGE);
        Lang currentLang = (Lang) reqCtx.getExtraParam(SystemConstants.EXTRAPAR_CURRENT_LANG);
        ConfigInterface configManager = (ConfigInterface) ApsWebApplicationUtils.getBean(SystemConstants.BASE_CONFIG_MANAGER, request);
        String urlType = configManager.getParam(SystemConstants.CONFIG_PARAM_BASE_URL);
        boolean needRequest = (null != urlType && !urlType.equals(SystemConstants.CONFIG_PARAM_BASE_URL_RELATIVE));
        String url = urlManager.createURL(currentPage, currentLang, redirectParams, false, (needRequest) ? request : null);
        if (null != anchorDest) {
            url += "#" + anchorDest;
        }
        this.setLocation(url);
    } catch (Throwable t) {
        _logger.error("error in execute", t);
    }
    super.execute(invocation);
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) ResultConfig(com.opensymphony.xwork2.config.entities.ResultConfig) HashMap(java.util.HashMap) IURLManager(com.agiletec.aps.system.services.url.IURLManager) Page(com.agiletec.aps.system.services.page.Page) Lang(com.agiletec.aps.system.services.lang.Lang) ConfigInterface(com.agiletec.aps.system.services.baseconfig.ConfigInterface) RequestContext(com.agiletec.aps.system.RequestContext)

Example 8 with IURLManager

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

the class ActionURLTag method doEndTag.

@Override
public int doEndTag() throws JspException {
    ServletRequest request = this.pageContext.getRequest();
    RequestContext reqCtx = (RequestContext) request.getAttribute(RequestContext.REQCTX);
    IURLManager urlManager = (IURLManager) ApsWebApplicationUtils.getBean(SystemConstants.URL_MANAGER, this.pageContext);
    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, this.getPath());
        pageUrl.addParam(InternalServletTag.REQUEST_PARAM_FRAMEDEST, currentFrame.toString());
        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));
            }
        }
        String path = pageUrl.getURL();
        if (null != this.getVar()) {
            this.pageContext.setAttribute(this.getVar(), path);
        } else {
            this.pageContext.getOut().print(path);
        }
    } catch (IOException e) {
        _logger.error("Error closing tag", e);
        // ApsSystemUtils.logThrowable(e, this, "doEndTag");
        throw new JspException("Error closing tag ", e);
    }
    this.release();
    return EVAL_PAGE;
}
Also used : ServletRequest(javax.servlet.ServletRequest) JspException(javax.servlet.jsp.JspException) 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) IOException(java.io.IOException)

Example 9 with IURLManager

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

the class NavigatorTarget method getUrl.

/**
 * Restituisce il link alla pagina corrente.
 *
 * @return Il link alla pagina.
 */
public String getUrl() {
    IURLManager urlManager = (IURLManager) ApsWebApplicationUtils.getBean(SystemConstants.URL_MANAGER, this._reqCtx.getRequest());
    PageURL pageUrl = urlManager.createURL(this._reqCtx);
    pageUrl.setPage(this.getPage());
    String urlString = pageUrl.getURL();
    return urlString;
}
Also used : PageURL(com.agiletec.aps.system.services.url.PageURL) IURLManager(com.agiletec.aps.system.services.url.IURLManager)

Example 10 with IURLManager

use of com.agiletec.aps.system.services.url.IURLManager 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

IURLManager (com.agiletec.aps.system.services.url.IURLManager)11 PageURL (com.agiletec.aps.system.services.url.PageURL)6 RequestContext (com.agiletec.aps.system.RequestContext)5 IPage (com.agiletec.aps.system.services.page.IPage)4 ConfigInterface (com.agiletec.aps.system.services.baseconfig.ConfigInterface)3 ServletRequest (javax.servlet.ServletRequest)3 JspException (javax.servlet.jsp.JspException)3 ILangManager (com.agiletec.aps.system.services.lang.ILangManager)2 Lang (com.agiletec.aps.system.services.lang.Lang)2 HttpServletRequest (javax.servlet.http.HttpServletRequest)2 ApsSystemException (com.agiletec.aps.system.exception.ApsSystemException)1 ICategoryManager (com.agiletec.aps.system.services.category.ICategoryManager)1 II18nManager (com.agiletec.aps.system.services.i18n.II18nManager)1 IKeyGeneratorManager (com.agiletec.aps.system.services.keygenerator.IKeyGeneratorManager)1 IPageManager (com.agiletec.aps.system.services.page.IPageManager)1 Page (com.agiletec.aps.system.services.page.Page)1 IPageModelManager (com.agiletec.aps.system.services.pagemodel.IPageModelManager)1 IRoleManager (com.agiletec.aps.system.services.role.IRoleManager)1 IUserManager (com.agiletec.aps.system.services.user.IUserManager)1 ResultConfig (com.opensymphony.xwork2.config.entities.ResultConfig)1