Search in sources :

Example 16 with Lang

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

the class CmsHypertextAttribute method validate.

@Override
public List<AttributeFieldError> validate(AttributeTracer tracer) {
    List<AttributeFieldError> errors = super.validate(tracer);
    try {
        List<Lang> langs = this.getLangManager().getLangs();
        for (Lang lang : langs) {
            AttributeTracer textTracer = (AttributeTracer) tracer.clone();
            textTracer.setLang(lang);
            String text = this.getTextMap().get(lang.getCode());
            if (null == text) {
                continue;
            }
            List<SymbolicLink> links = HypertextAttributeUtil.getSymbolicLinksOnText(text);
            if (null != links && !links.isEmpty()) {
                SymbolicLinkValidator sler = new SymbolicLinkValidator(this.getContentManager(), this.getPageManager());
                for (SymbolicLink symbLink : links) {
                    String linkErrorCode = sler.scan(symbLink, (Content) this.getParentEntity());
                    if (null != linkErrorCode) {
                        AttributeFieldError error = new AttributeFieldError(this, linkErrorCode, textTracer);
                        error.setMessage("Invalid link - page " + symbLink.getPageDest() + " - content " + symbLink.getContentDest() + " - Error code " + linkErrorCode);
                        errors.add(error);
                    }
                }
            }
        }
    } catch (Throwable t) {
        logger.error("Error validating Attribute '{}'", this.getName(), t);
        throw new RuntimeException("Error validating Attribute '" + this.getName() + "'", t);
    }
    return errors;
}
Also used : SymbolicLinkValidator(com.agiletec.plugins.jacms.aps.system.services.content.model.extraAttribute.util.SymbolicLinkValidator) AttributeTracer(com.agiletec.aps.system.common.entity.model.AttributeTracer) AttributeFieldError(com.agiletec.aps.system.common.entity.model.AttributeFieldError) Lang(com.agiletec.aps.system.services.lang.Lang) SymbolicLink(com.agiletec.plugins.jacms.aps.system.services.content.model.SymbolicLink)

Example 17 with Lang

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

the class ContentListHelper method executeFullTextSearch.

protected List<String> executeFullTextSearch(IContentListTagBean bean, List<String> masterContentsId, RequestContext reqCtx) throws ApsSystemException {
    UserFilterOptionBean fullTextUserFilter = null;
    List<UserFilterOptionBean> userFilterOptions = bean.getUserFilterOptions();
    if (null != userFilterOptions) {
        for (UserFilterOptionBean userFilter : userFilterOptions) {
            if (null != userFilter.getFormFieldValues() && userFilter.getFormFieldValues().size() > 0) {
                if (!userFilter.isAttributeFilter() && userFilter.getKey().equals(UserFilterOptionBean.KEY_FULLTEXT)) {
                    fullTextUserFilter = userFilter;
                }
            }
        }
    }
    if (fullTextUserFilter != null && null != fullTextUserFilter.getFormFieldValues()) {
        String word = fullTextUserFilter.getFormFieldValues().get(fullTextUserFilter.getFormFieldNames()[0]);
        Lang currentLang = (Lang) reqCtx.getExtraParam(SystemConstants.EXTRAPAR_CURRENT_LANG);
        List<String> fullTextResult = this.getSearchEngineManager().searchEntityId(currentLang.getCode(), word, this.getAllowedGroups(reqCtx));
        if (null != fullTextResult) {
            return ListUtils.intersection(fullTextResult, masterContentsId);
        } else {
            return new ArrayList<String>();
        }
    } else {
        return masterContentsId;
    }
}
Also used : ArrayList(java.util.ArrayList) Lang(com.agiletec.aps.system.services.lang.Lang)

Example 18 with Lang

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

the class ListAttribute method validate.

@Override
public List<AttributeFieldError> validate(AttributeTracer tracer) {
    List<AttributeFieldError> errors = super.validate(tracer);
    try {
        List<Lang> langs = super.getLangManager().getLangs();
        for (int i = 0; i < langs.size(); i++) {
            Lang lang = langs.get(i);
            List<AttributeInterface> attributeList = this.getAttributeList(lang.getCode());
            for (int j = 0; j < attributeList.size(); j++) {
                AttributeInterface attributeElement = attributeList.get(j);
                AttributeTracer elementTracer = (AttributeTracer) tracer.clone();
                elementTracer.setListElement(true);
                elementTracer.setListLang(lang);
                elementTracer.setListIndex(j);
                Status elementStatus = attributeElement.getStatus();
                if (elementStatus.equals(Status.EMPTY)) {
                    errors.add(new AttributeFieldError(attributeElement, FieldError.INVALID, elementTracer));
                } else {
                    List<AttributeFieldError> elementErrors = attributeElement.validate(elementTracer);
                    if (null != elementErrors) {
                        errors.addAll(elementErrors);
                    }
                }
            }
        }
    } catch (Throwable t) {
        // ApsSystemUtils.logThrowable(t, this, "validate");
        _logger.error("Error validating list attribute", t);
        throw new RuntimeException("Error validating list attribute", t);
    }
    return errors;
}
Also used : AttributeTracer(com.agiletec.aps.system.common.entity.model.AttributeTracer) AttributeFieldError(com.agiletec.aps.system.common.entity.model.AttributeFieldError) Lang(com.agiletec.aps.system.services.lang.Lang)

Example 19 with Lang

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

the class CategoryManagerCacheWrapper method createRoot.

protected Category createRoot(ILangManager langManager) {
    Category root = new Category();
    root.setCode("home");
    root.setParentCode("home");
    List<Lang> langs = langManager.getLangs();
    ApsProperties titles = new ApsProperties();
    for (Lang lang : langs) {
        titles.setProperty(lang.getCode(), "Home");
    }
    root.setTitles(titles);
    return root;
}
Also used : Category(com.agiletec.aps.system.services.category.Category) Lang(com.agiletec.aps.system.services.lang.Lang) ApsProperties(com.agiletec.aps.util.ApsProperties)

Example 20 with Lang

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

the class TestActivityStream method addPage.

private void addPage(String pageCode) throws Throwable {
    assertNull(this._pageManager.getDraftPage(pageCode));
    try {
        IPage root = this._pageManager.getOnlineRoot();
        Map<String, String> params = new HashMap<String, String>();
        params.put("strutsAction", String.valueOf(ApsAdminSystemConstants.ADD));
        params.put("parentPageCode", root.getCode());
        List<Lang> langs = this._langManager.getLangs();
        for (int i = 0; i < langs.size(); i++) {
            Lang lang = langs.get(i);
            params.put("lang" + lang.getCode(), "Page " + lang.getDescr());
        }
        params.put("model", "home");
        params.put("group", Group.FREE_GROUP_NAME);
        params.put("pageCode", pageCode);
        String result = this.executeSave(params, "admin");
        assertEquals(Action.SUCCESS, result);
        IPage addedPage = this._pageManager.getDraftPage(pageCode);
        assertNotNull(addedPage);
    } catch (Throwable t) {
        throw t;
    }
}
Also used : IPage(com.agiletec.aps.system.services.page.IPage) HashMap(java.util.HashMap) 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