Search in sources :

Example 1 with Lang

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

the class ProtectedResourceProvider method executeLoginRedirect.

protected void executeLoginRedirect(HttpServletRequest request, HttpServletResponse response) throws ServletException {
    try {
        StringBuilder targetUrl = new StringBuilder(request.getRequestURL());
        Map<String, String> params = new HashMap<String, String>();
        params.put("returnUrl", targetUrl.toString());
        String loginPageCode = this.getConfigManager().getParam(SystemConstants.CONFIG_PARAM_LOGIN_PAGE_CODE);
        IPage page = this.getPageManager().getOnlinePage(loginPageCode);
        Lang defaultLang = this.getLangManager().getDefaultLang();
        String url = this.getUrlManager().createURL(page, defaultLang, params);
        response.sendRedirect(url);
    } catch (Throwable t) {
        _logger.error("Error executing redirect login page", t);
        throw new ServletException("Error executing redirect login page", t);
    }
}
Also used : ServletException(javax.servlet.ServletException) IPage(com.agiletec.aps.system.services.page.IPage) HashMap(java.util.HashMap) Lang(com.agiletec.aps.system.services.lang.Lang)

Example 2 with Lang

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

the class BaseContentGroupBulkCommand method checkContentReferences.

protected boolean checkContentReferences(Content content) {
    List<Lang> systemLangs = this.getSystemLangs();
    IPageManager pageManager = this.getPageManager();
    SymbolicLinkValidator validator = new SymbolicLinkValidator(this.getApplier(), pageManager);
    for (AttributeInterface attribute : content.getAttributeList()) {
        if (attribute instanceof IReferenceableAttribute) {
            List<CmsAttributeReference> references = ((IReferenceableAttribute) attribute).getReferences(systemLangs);
            if (references != null) {
                for (CmsAttributeReference reference : references) {
                    SymbolicLink symbolicLink = this.convertToSymbolicLink(reference);
                    if (symbolicLink != null) {
                        String result = validator.scan(symbolicLink, content);
                        if (ICmsAttributeErrorCodes.INVALID_CONTENT_GROUPS.equals(result) || ICmsAttributeErrorCodes.INVALID_RESOURCE_GROUPS.equals(result) || ICmsAttributeErrorCodes.INVALID_PAGE_GROUPS.equals(result)) {
                            return false;
                        }
                    }
                }
            }
        }
    }
    return true;
}
Also used : IReferenceableAttribute(com.agiletec.plugins.jacms.aps.system.services.content.model.extraAttribute.IReferenceableAttribute) IPageManager(com.agiletec.aps.system.services.page.IPageManager) SymbolicLinkValidator(com.agiletec.plugins.jacms.aps.system.services.content.model.extraAttribute.util.SymbolicLinkValidator) Lang(com.agiletec.aps.system.services.lang.Lang) CmsAttributeReference(com.agiletec.plugins.jacms.aps.system.services.content.model.CmsAttributeReference) SymbolicLink(com.agiletec.plugins.jacms.aps.system.services.content.model.SymbolicLink) AttributeInterface(com.agiletec.aps.system.common.entity.model.attribute.AttributeInterface)

Example 3 with Lang

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

the class WidgetValidatorCmsHelper method validateTitle.

public static void validateTitle(WidgetConfigurationRequest widget, ILangManager langManager, BeanPropertyBindingResult errors) {
    String titleParamPrefix = IContentListWidgetHelper.WIDGET_PARAM_TITLE + "_";
    if (isMultilanguageParamValued(widget, titleParamPrefix, langManager)) {
        Lang defaultLang = langManager.getDefaultLang();
        String defaultTitleParam = titleParamPrefix + defaultLang.getCode();
        String defaultTitle = extractConfigParam(widget, defaultTitleParam);
        if (StringUtils.isBlank(defaultTitle)) {
            errors.reject(ERRCODE_INVALID_CONFIGURATION, new String[] { defaultLang.getDescr() }, widget.getCode() + ".defaultLangTitle.required");
        }
    }
}
Also used : Lang(com.agiletec.aps.system.services.lang.Lang)

Example 4 with Lang

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

the class WidgetValidatorCmsHelper method isMultilanguageParamValued.

protected static boolean isMultilanguageParamValued(WidgetConfigurationRequest widget, String prefix, ILangManager langManager) {
    Map<String, Object> config = widget.getConfig();
    if (null == config) {
        return false;
    }
    List<Lang> langs = langManager.getLangs();
    for (int i = 0; i < langs.size(); i++) {
        Lang lang = langs.get(i);
        // (String) config.get(prefix + lang.getCode());
        String paramValue = extractConfigParam(widget, prefix + lang.getCode());
        if (null != paramValue && paramValue.trim().length() > 0) {
            return true;
        }
    }
    return false;
}
Also used : Lang(com.agiletec.aps.system.services.lang.Lang)

Example 5 with Lang

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

the class WidgetValidatorCmsHelper method validateLink.

public static void validateLink(WidgetConfigurationRequest widget, ILangManager langManager, IPageManager pageManager, BeanPropertyBindingResult errors) {
    String pageLink = extractConfigParam(widget, IContentListWidgetHelper.WIDGET_PARAM_PAGE_LINK);
    boolean existsPageLink = pageLink != null && pageManager.getDraftPage(pageLink) != null;
    String linkDescrParamPrefix = IContentListWidgetHelper.WIDGET_PARAM_PAGE_LINK_DESCR + "_";
    if (existsPageLink || isMultilanguageParamValued(widget, linkDescrParamPrefix, langManager)) {
        if (!existsPageLink) {
            errors.reject(ERRCODE_INVALID_CONFIGURATION, new String[] { pageLink }, widget.getCode() + ".pageLink.required");
        }
        Lang defaultLang = langManager.getDefaultLang();
        String defaultLinkDescrParam = linkDescrParamPrefix + defaultLang.getCode();
        String defaultLinkDescr = extractConfigParam(widget, defaultLinkDescrParam);
        if (defaultLinkDescr == null || defaultLinkDescr.length() == 0) {
            errors.reject(ERRCODE_INVALID_CONFIGURATION, new String[] { defaultLang.getDescr() }, widget.getCode() + ".defaultLangLink.required");
        }
    }
}
Also used : Lang(com.agiletec.aps.system.services.lang.Lang)

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