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;
}
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;
}
}
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;
}
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;
}
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;
}
}
Aggregations