use of com.agiletec.aps.system.services.lang.Lang in project entando-core by entando.
the class RowContentListViewerWidgetAction method validateLink.
protected void validateLink() {
String pageLink = this.getWidget().getConfig().getProperty(IContentListWidgetHelper.WIDGET_PARAM_PAGE_LINK);
boolean existsPageLink = pageLink != null && this.getPage(pageLink) != null;
String linkDescrParamPrefix = IContentListWidgetHelper.WIDGET_PARAM_PAGE_LINK_DESCR + "_";
if (existsPageLink || this.isMultilanguageParamValued(linkDescrParamPrefix)) {
if (!existsPageLink) {
this.addFieldError(IContentListWidgetHelper.WIDGET_PARAM_PAGE_LINK, this.getText("error.widget.listViewer.pageLink.required"));
}
Lang defaultLang = this.getLangManager().getDefaultLang();
String defaultLinkDescrParam = linkDescrParamPrefix + defaultLang.getCode();
String defaultLinkDescr = this.getWidget().getConfig().getProperty(defaultLinkDescrParam);
if (defaultLinkDescr == null || defaultLinkDescr.length() == 0) {
String[] args = { defaultLang.getDescr() };
this.addFieldError(defaultLinkDescrParam, this.getText("error.widget.listViewer.defaultLangLink.required", args));
}
}
}
use of com.agiletec.aps.system.services.lang.Lang in project entando-core by entando.
the class RowContentListViewerWidgetAction method validateTitle.
protected void validateTitle() {
String titleParamPrefix = IContentListWidgetHelper.WIDGET_PARAM_TITLE + "_";
if (this.isMultilanguageParamValued(titleParamPrefix)) {
Lang defaultLang = this.getLangManager().getDefaultLang();
String defaultTitleParam = titleParamPrefix + defaultLang.getCode();
String defaultTitle = this.getWidget().getConfig().getProperty(defaultTitleParam);
if (defaultTitle == null || defaultTitle.length() == 0) {
String[] args = { defaultLang.getDescr() };
this.addFieldError(defaultTitleParam, this.getText("error.widget.listViewer.defaultLangTitle.required", args));
}
}
}
use of com.agiletec.aps.system.services.lang.Lang in project entando-core by entando.
the class TestLangAction method testAddNewLang.
public void testAddNewLang() throws Throwable {
String langCode = "fr";
try {
// utente non autorizzato
String result = this.executeAddLang("mainEditor", langCode);
assertEquals("userNotAllowed", result);
result = this.executeAddLang("admin", langCode);
assertEquals(Action.SUCCESS, result);
Lang language = this._langManager.getLang(langCode);
assertEquals(language.getDescr(), "French");
} catch (Throwable t) {
throw t;
} finally {
this._langManager.removeLang(langCode);
}
}
use of com.agiletec.aps.system.services.lang.Lang in project entando-core by entando.
the class TestLangAction method testFailureAddNewLang.
public void testFailureAddNewLang() throws Throwable {
String langCode = "fr";
try {
String result = this.executeAddLang("admin", langCode);
assertEquals(Action.SUCCESS, result);
Lang language = this._langManager.getLang(langCode);
assertEquals(language.getDescr(), "French");
result = this.executeAddLang("admin", langCode);
assertEquals(Action.INPUT, result);
result = this.executeAddLang("admin", "en");
assertEquals(Action.INPUT, result);
assertEquals(1, this.getAction().getActionErrors().size());
} catch (Throwable t) {
throw t;
} finally {
this._langManager.removeLang(langCode);
}
}
use of com.agiletec.aps.system.services.lang.Lang in project entando-core by entando.
the class AbstractResourceAttribute method validate.
@Override
public List<AttributeFieldError> validate(AttributeTracer tracer) {
List<AttributeFieldError> errors = super.validate(tracer);
try {
if (null == this.getResources()) {
return errors;
}
List<Lang> langs = super.getLangManager().getLangs();
for (int i = 0; i < langs.size(); i++) {
Lang lang = langs.get(i);
ResourceInterface resource = this.getResource(lang.getCode());
if (null == resource) {
continue;
}
AttributeTracer resourceTracer = (AttributeTracer) tracer.clone();
resourceTracer.setLang(lang);
String resourceMainGroup = resource.getMainGroup();
Content parentContent = (Content) this.getParentEntity();
if (!resourceMainGroup.equals(Group.FREE_GROUP_NAME) && !resourceMainGroup.equals(parentContent.getMainGroup()) && !parentContent.getGroups().contains(resourceMainGroup)) {
AttributeFieldError fieldError = new AttributeFieldError(this, ICmsAttributeErrorCodes.INVALID_RESOURCE_GROUPS, resourceTracer);
fieldError.setMessage("Invalid resource group - " + resourceMainGroup);
errors.add(fieldError);
}
}
} catch (Throwable t) {
logger.error("Error validating text attribute", t);
throw new RuntimeException("Error validating text attribute", t);
}
return errors;
}
Aggregations