Search in sources :

Example 51 with Lang

use of com.agiletec.aps.system.services.lang.Lang in project entando-core by entando.

the class TestLinkResolverManager method setUp.

@Override
public void setUp() throws Exception {
    try {
        super.setUp();
        _reqCtx = this.getRequestContext();
        Lang lang = new Lang();
        lang.setCode("it");
        lang.setDescr("italiano");
        _reqCtx.addExtraParam(SystemConstants.EXTRAPAR_CURRENT_LANG, lang);
        this.init();
    } catch (Throwable t) {
        throw new Exception(t);
    }
}
Also used : Lang(com.agiletec.aps.system.services.lang.Lang)

Example 52 with Lang

use of com.agiletec.aps.system.services.lang.Lang in project entando-core by entando.

the class I18nFrontEndInterceptor method intercept.

@Override
public String intercept(ActionInvocation invocation) throws Exception {
    HttpServletRequest request = ServletActionContext.getRequest();
    RequestContext reqCtx = (RequestContext) request.getAttribute(RequestContext.REQCTX);
    if (null != reqCtx) {
        Lang currentLang = (Lang) reqCtx.getExtraParam(SystemConstants.EXTRAPAR_CURRENT_LANG);
        Locale locale = new Locale(currentLang.getCode(), "");
        invocation.getInvocationContext().setLocale(locale);
    }
    return invocation.invoke();
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) Locale(java.util.Locale) Lang(com.agiletec.aps.system.services.lang.Lang) RequestContext(com.agiletec.aps.system.RequestContext)

Example 53 with Lang

use of com.agiletec.aps.system.services.lang.Lang 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);
        String url = urlManager.createURL(currentPage, currentLang, redirectParams, false, request);
        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) RequestContext(com.agiletec.aps.system.RequestContext)

Example 54 with Lang

use of com.agiletec.aps.system.services.lang.Lang in project entando-core by entando.

the class ApiServiceAction method checkDescriptions.

private void checkDescriptions() {
    this.setDescriptions(new ApsProperties());
    Iterator<Lang> langsIter = this.getLangManager().getLangs().iterator();
    while (langsIter.hasNext()) {
        Lang lang = (Lang) langsIter.next();
        String titleKey = "lang_" + lang.getCode();
        String title = this.getRequest().getParameter(titleKey);
        if (null == title || title.trim().length() == 0) {
            String[] args = { lang.getDescr() };
            this.addFieldError(titleKey, this.getText("error.service.new.insertDescription", args));
        } else {
            this.getDescriptions().put(lang.getCode(), title.trim());
        }
    }
}
Also used : Lang(com.agiletec.aps.system.services.lang.Lang) ApsProperties(com.agiletec.aps.util.ApsProperties)

Example 55 with Lang

use of com.agiletec.aps.system.services.lang.Lang in project entando-core by entando.

the class RowContentListViewerWidgetAction method isMultilanguageParamValued.

private boolean isMultilanguageParamValued(String prefix) {
    ApsProperties config = this.getWidget().getConfig();
    if (null == config) {
        return false;
    }
    for (int i = 0; i < this.getLangs().size(); i++) {
        Lang lang = this.getLangs().get(i);
        String paramValue = config.getProperty(prefix + lang.getCode());
        if (null != paramValue && paramValue.trim().length() > 0) {
            return true;
        }
    }
    return false;
}
Also used : Lang(com.agiletec.aps.system.services.lang.Lang) ApsProperties(com.agiletec.aps.util.ApsProperties)

Aggregations

Lang (com.agiletec.aps.system.services.lang.Lang)90 ArrayList (java.util.ArrayList)15 ApsProperties (com.agiletec.aps.util.ApsProperties)14 IPage (com.agiletec.aps.system.services.page.IPage)12 ApsSystemException (com.agiletec.aps.system.exception.ApsSystemException)11 RequestContext (com.agiletec.aps.system.RequestContext)10 Widget (com.agiletec.aps.system.services.page.Widget)10 ILangManager (com.agiletec.aps.system.services.lang.ILangManager)8 AttributeTracer (com.agiletec.aps.system.common.entity.model.AttributeTracer)7 AttributeInterface (com.agiletec.aps.system.common.entity.model.attribute.AttributeInterface)7 HttpServletRequest (javax.servlet.http.HttpServletRequest)7 HashMap (java.util.HashMap)6 ServletRequest (javax.servlet.ServletRequest)6 AttributeFieldError (com.agiletec.aps.system.common.entity.model.AttributeFieldError)4 IApsEntity (com.agiletec.aps.system.common.entity.model.IApsEntity)4 IndexableAttributeInterface (com.agiletec.aps.system.common.searchengine.IndexableAttributeInterface)4 Category (com.agiletec.aps.system.services.category.Category)4 Properties (java.util.Properties)4 JspException (javax.servlet.jsp.JspException)4 StringField (org.apache.lucene.document.StringField)4