Search in sources :

Example 66 with Lang

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

the class LangAction method add.

public String add() {
    try {
        Lang langToAdd = this.getLangManager().getLang(this.getLangCode());
        if (null != langToAdd) {
            String[] args = { this.getLangCode() };
            this.addActionError(this.getText("error.lang.alreadyPresent", args));
            return INPUT;
        }
        this.getLangManager().addLang(this.getLangCode());
    } catch (Throwable t) {
        _logger.error("error in add", t);
        return FAILURE;
    }
    return SUCCESS;
}
Also used : Lang(com.agiletec.aps.system.services.lang.Lang)

Example 67 with Lang

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

the class LocaleStringAction method checkLabels.

private void checkLabels() {
    Iterator<Lang> langsIter = this.getLangManager().getLangs().iterator();
    while (langsIter.hasNext()) {
        Lang lang = langsIter.next();
        String code = lang.getCode();
        String label = this.getRequest().getParameter(code);
        if (null != label && label.trim().length() > 0) {
            this.addLabel(code, label);
        } else {
            this.getLabels().remove(code);
            if (lang.isDefault()) {
                String[] args = { lang.getDescr() };
                this.addFieldError(code, this.getText("error.label.valueMandatory", args));
            }
        }
    }
}
Also used : Lang(com.agiletec.aps.system.services.lang.Lang)

Example 68 with Lang

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

the class RequestValidator method isRightPath.

private boolean isRightPath(RequestContext reqCtx) {
    boolean ok = false;
    String resourcePath;
    Matcher matcher;
    Lang lang = null;
    IPage page = null;
    if (this.getResourcePath(reqCtx).equals("/pages")) {
        resourcePath = getFullResourcePath(reqCtx);
        matcher = this._patternFullPath.matcher(resourcePath);
        if (matcher.lookingAt()) {
            ok = true;
            String sect1 = matcher.group(1);
            lang = getLangManager().getLang(sect1);
            page = this.getPage(matcher);
        }
    } else {
        resourcePath = getResourcePath(reqCtx);
        matcher = this._pattern.matcher(resourcePath);
        if (matcher.lookingAt()) {
            ok = true;
            String sect1 = matcher.group(1);
            String sect2 = matcher.group(2);
            lang = getLangManager().getLang(sect1);
            page = this.getPageManager().getOnlinePage(sect2);
        } else {
            // to preserve url with ".wp" suffix
            matcher = this._oldPattern.matcher(resourcePath);
            if (matcher.lookingAt()) {
                ok = true;
                String sect1 = matcher.group(1);
                String sect2 = matcher.group(2);
                lang = getLangManager().getLang(sect1);
                page = this.getPageManager().getOnlinePage(sect2);
            }
        }
    }
    if (!ok)
        return false;
    reqCtx.addExtraParam(SystemConstants.EXTRAPAR_CURRENT_LANG, lang);
    reqCtx.addExtraParam(SystemConstants.EXTRAPAR_CURRENT_PAGE, page);
    return true;
}
Also used : IPage(com.agiletec.aps.system.services.page.IPage) Matcher(java.util.regex.Matcher) Lang(com.agiletec.aps.system.services.lang.Lang)

Example 69 with Lang

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

the class PreviewRequestValidator method isRightPath.

private boolean isRightPath(RequestContext reqCtx) {
    boolean ok = false;
    String resourcePath;
    Matcher matcher;
    Lang lang = null;
    IPage page = null;
    if (this.getResourcePath(reqCtx).equals("/preview")) {
        resourcePath = getFullResourcePath(reqCtx);
        matcher = this._pattern.matcher(resourcePath);
        if (matcher.lookingAt()) {
            ok = true;
            String sect1 = matcher.group(1);
            String sect2 = matcher.group(2);
            lang = getLangManager().getLang(sect1);
            page = this.getDesiredPage(sect2);
        }
    }
    if (!ok) {
        return false;
    }
    reqCtx.addExtraParam(SystemConstants.EXTRAPAR_CURRENT_LANG, lang);
    reqCtx.addExtraParam(SystemConstants.EXTRAPAR_CURRENT_PAGE, page);
    return true;
}
Also used : IPage(com.agiletec.aps.system.services.page.IPage) Matcher(java.util.regex.Matcher) Lang(com.agiletec.aps.system.services.lang.Lang)

Example 70 with Lang

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

the class ContentPreviewViewerHelper method getRenderedContent.

@Override
public String getRenderedContent(String contentId, String modelId, RequestContext reqCtx) throws ApsSystemException {
    String renderedContent = "";
    HttpServletRequest request = reqCtx.getRequest();
    try {
        String contentOnSessionMarker = (String) request.getAttribute("contentOnSessionMarker");
        if (null == contentOnSessionMarker || contentOnSessionMarker.trim().length() == 0) {
            contentOnSessionMarker = request.getParameter("contentOnSessionMarker");
        }
        Lang currentLang = (Lang) reqCtx.getExtraParam(SystemConstants.EXTRAPAR_CURRENT_LANG);
        String langCode = currentLang.getCode();
        Widget widget = (Widget) reqCtx.getExtraParam(SystemConstants.EXTRAPAR_CURRENT_WIDGET);
        Content contentOnSession = (Content) request.getSession().getAttribute(ContentActionConstants.SESSION_PARAM_NAME_CURRENT_CONTENT_PREXIX + contentOnSessionMarker);
        contentId = (contentOnSession.getId() == null ? contentOnSession.getTypeCode() + "123" : contentOnSession.getId());
        ApsProperties widgetConfig = widget.getConfig();
        modelId = this.extractModelId(contentId, modelId, widgetConfig);
        if (null != contentId && null != modelId) {
            long longModelId = new Long(modelId).longValue();
            this.setStylesheet(longModelId, reqCtx);
            ContentRenderizationInfo renderizationInfo = this.getContentDispenser().getRenderizationInfo(contentId, longModelId, langCode, reqCtx);
            if (null == renderizationInfo) {
                _logger.warn("Null Renderization informations: content={}", contentId);
            } else {
                this.getContentDispenser().resolveLinks(renderizationInfo, reqCtx);
                renderedContent = renderizationInfo.getRenderedContent();
            }
        } else {
            _logger.warn("Parametri visualizzazione contenuto incompleti: contenuto={} modello={}", contentId, modelId);
        }
    } catch (Throwable t) {
        _logger.error("error loading rendered content for preview", t);
        // ApsSystemUtils.logThrowable(t, this, "getRenderedContent");
        throw new ApsSystemException("error loading rendered content for preview", t);
    }
    return renderedContent;
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) ContentRenderizationInfo(com.agiletec.plugins.jacms.aps.system.services.dispenser.ContentRenderizationInfo) Content(com.agiletec.plugins.jacms.aps.system.services.content.model.Content) Widget(com.agiletec.aps.system.services.page.Widget) Lang(com.agiletec.aps.system.services.lang.Lang) ApsSystemException(com.agiletec.aps.system.exception.ApsSystemException) 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