Search in sources :

Example 1 with IURLManager

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

the class InfoTag method doStartTag.

@Override
public int doStartTag() throws JspException {
    ServletRequest request = this.pageContext.getRequest();
    try {
        if ("startLang".equals(this._key)) {
            Lang startLang = this.extractStartLang();
            this._info = startLang.getCode();
        } else if ("defaultLang".equals(this._key)) {
            ILangManager langManager = (ILangManager) ApsWebApplicationUtils.getBean(SystemConstants.LANGUAGE_MANAGER, this.pageContext);
            this._info = langManager.getDefaultLang().getCode();
        } else if ("currentLang".equals(this._key)) {
            RequestContext reqCtx = (RequestContext) request.getAttribute(RequestContext.REQCTX);
            Lang currentLang = (Lang) reqCtx.getExtraParam(SystemConstants.EXTRAPAR_CURRENT_LANG);
            this._info = currentLang.getCode();
        } else if ("langs".equals(this._key)) {
            ILangManager langManager = (ILangManager) ApsWebApplicationUtils.getBean(SystemConstants.LANGUAGE_MANAGER, this.pageContext);
            this._info = langManager.getLangs();
        } else if ("systemParam".equals(this._key)) {
            if (SystemConstants.PAR_APPL_BASE_URL.equals(this.getParamName())) {
                IURLManager urlManager = (IURLManager) ApsWebApplicationUtils.getBean(SystemConstants.URL_MANAGER, this.pageContext);
                this._info = urlManager.getApplicationBaseURL((HttpServletRequest) request);
            } else {
                ConfigInterface confManager = (ConfigInterface) ApsWebApplicationUtils.getBean(SystemConstants.BASE_CONFIG_MANAGER, this.pageContext);
                this._info = confManager.getParam(this.getParamName());
            }
        }
    } catch (Throwable t) {
        _logger.error("Error during tag initialization", t);
        throw new JspException("Error during tag initialization", t);
    }
    return EVAL_BODY_INCLUDE;
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) ServletRequest(javax.servlet.ServletRequest) HttpServletRequest(javax.servlet.http.HttpServletRequest) JspException(javax.servlet.jsp.JspException) ILangManager(com.agiletec.aps.system.services.lang.ILangManager) IURLManager(com.agiletec.aps.system.services.url.IURLManager) Lang(com.agiletec.aps.system.services.lang.Lang) ConfigInterface(com.agiletec.aps.system.services.baseconfig.ConfigInterface) RequestContext(com.agiletec.aps.system.RequestContext)

Example 2 with IURLManager

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

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

the class URLTag method doStartTag.

/**
 * Prepares a PageURL object; this object may comprehend several sub-tags
 */
@Override
public int doStartTag() throws JspException {
    ServletRequest request = this.pageContext.getRequest();
    RequestContext reqCtx = (RequestContext) request.getAttribute(RequestContext.REQCTX);
    try {
        IURLManager urlManager = (IURLManager) ApsWebApplicationUtils.getBean(SystemConstants.URL_MANAGER, this.pageContext);
        this._pageUrl = urlManager.createURL(reqCtx);
        if (_pageCode != null) {
            _pageUrl.setPageCode(_pageCode);
        }
        if (_langCode != null) {
            _pageUrl.setLangCode(_langCode);
        }
        if (this.isParamRepeat()) {
            List<String> exclusion = this.getParametersToExclude();
            _pageUrl.setParamRepeat(exclusion);
        }
    } catch (Throwable t) {
        _logger.error("Error during tag initialization", t);
        throw new JspException("Error during tag initialization", t);
    }
    return EVAL_BODY_INCLUDE;
}
Also used : ServletRequest(javax.servlet.ServletRequest) JspException(javax.servlet.jsp.JspException) IURLManager(com.agiletec.aps.system.services.url.IURLManager) RequestContext(com.agiletec.aps.system.RequestContext)

Example 4 with IURLManager

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

the class ApiRestServer method extractApplicationBaseUrl.

protected String extractApplicationBaseUrl(HttpServletRequest request) throws Exception {
    String applicationBaseUrl = null;
    try {
        IURLManager urlManager = (IURLManager) ApsWebApplicationUtils.getBean(SystemConstants.URL_MANAGER, request);
        applicationBaseUrl = urlManager.getApplicationBaseURL(request);
    } catch (Exception t) {
        _logger.error("Error extracting application base url", t);
    }
    return applicationBaseUrl;
}
Also used : IURLManager(com.agiletec.aps.system.services.url.IURLManager) ApsSystemException(com.agiletec.aps.system.exception.ApsSystemException)

Example 5 with IURLManager

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

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