use of com.agiletec.aps.system.services.lang.Lang in project entando-core by entando.
the class TestLangAction method testFailureRemoveDefaultLang.
public void testFailureRemoveDefaultLang() throws Throwable {
int initLangs = this._langManager.getLangs().size();
Lang defaultLang = this._langManager.getDefaultLang();
String result = this.executeRemoveLang("admin", defaultLang.getCode());
assertEquals(Action.INPUT, result);
assertEquals(initLangs, this._langManager.getLangs().size());
ActionSupport action = this.getAction();
Collection<String> errors = action.getActionErrors();
assertEquals(1, errors.size());
}
use of com.agiletec.aps.system.services.lang.Lang in project entando-core by entando.
the class TestWidgetsViewerAction method testGetWidgetFlavours.
public void testGetWidgetFlavours() throws Throwable {
String result = this.executeViewWidgets("admin");
assertEquals(Action.SUCCESS, result);
AbstractPortalAction action = (AbstractPortalAction) this.getAction();
List<List<SelectItem>> widgetFlavours = action.getWidgetFlavours();
assertNotNull(widgetFlavours);
assertTrue(widgetFlavours.size() >= 3);
Lang currentLang = action.getCurrentLang();
List<SelectItem> userWidgets = widgetFlavours.get(0);
assertEquals(2, userWidgets.size());
SelectItem userType = userWidgets.get(1);
assertEquals(AbstractPortalAction.USER_WIDGETS_CODE, userType.getOptgroup());
if (currentLang.getCode().equals("it")) {
assertEquals("logic_type", userType.getKey());
assertEquals("Tipo logico per test", userType.getValue());
} else {
assertEquals("logic_type", userType.getKey());
assertEquals("Logic type for test", userType.getValue());
}
List<SelectItem> customWidgets = widgetFlavours.get(1);
assertEquals(1, customWidgets.size());
SelectItem customType = customWidgets.get(0);
assertEquals(AbstractPortalAction.CUSTOM_WIDGETS_CODE, customType.getOptgroup());
if (currentLang.getCode().equals("it")) {
assertEquals("leftmenu", customType.getKey());
assertEquals("Menu di navigazione verticale", customType.getValue());
} else {
assertEquals("leftmenu", customType.getKey());
assertEquals("Vertical Navigation Menu", customType.getValue());
}
List<SelectItem> jacmsWidgets = widgetFlavours.get(2);
assertEquals(3, jacmsWidgets.size());
SelectItem jacmsWidgetTypes = jacmsWidgets.get(1);
assertEquals("jacms", jacmsWidgetTypes.getOptgroup());
if (currentLang.getCode().equals("it")) {
assertEquals("content_viewer_list", jacmsWidgetTypes.getKey());
assertEquals("Contenuti - Pubblica una Lista di Contenuti", jacmsWidgetTypes.getValue());
}
List<SelectItem> stockWidgets = widgetFlavours.get(widgetFlavours.size() - 1);
assertEquals(4, stockWidgets.size());
SelectItem stockType = stockWidgets.get(3);
assertEquals(AbstractPortalAction.STOCK_WIDGETS_CODE, stockType.getOptgroup());
if (currentLang.getCode().equals("it")) {
assertEquals("login_form", stockType.getKey());
assertEquals("Widget di Login", stockType.getValue());
} else {
assertEquals("messages_system", stockType.getKey());
assertEquals("System Messages", stockType.getValue());
}
}
use of com.agiletec.aps.system.services.lang.Lang in project entando-core by entando.
the class ContentActionHelper method createActivityStreamInfo.
@Override
public ActivityStreamInfo createActivityStreamInfo(Content content, int strutsAction, boolean addLink) {
ActivityStreamInfo asi = new ActivityStreamInfo();
asi.setActionType(strutsAction);
Lang defaultLang = this.getLangManager().getDefaultLang();
Properties titles = new Properties();
titles.setProperty(defaultLang.getCode(), (null != content.getDescription()) ? content.getDescription() : "-");
asi.setObjectTitles(titles);
if (addLink) {
asi.setLinkNamespace("/do/jacms/Content");
asi.setLinkActionName("edit");
asi.addLinkParameter("contentId", content.getId());
asi.setLinkAuthGroup(content.getMainGroup());
asi.setLinkAuthPermission(Permission.CONTENT_EDITOR);
}
List<String> groupCodes = new ArrayList<String>();
if (null != content.getMainGroup()) {
groupCodes.addAll(content.getGroups());
}
groupCodes.add(content.getMainGroup());
asi.setGroups(groupCodes);
return asi;
}
use of com.agiletec.aps.system.services.lang.Lang in project entando-core by entando.
the class ContentActionHelper method scanReferences.
/**
* Controlla le referenziazioni di un contenuto. Verifica la referenziazione
* di un contenuto con altri contenuti o pagine nel caso di operazioni di
* ripubblicazione di contenuti non del gruppo ad accesso libero.
* L'operazione si rende necessaria per ovviare a casi nel cui il contenuto,
* di un particolare gruppo, sia stato pubblicato precedentemente in una
* pagina o referenziato in un'altro contenuto grazie alla associazione di
* questo con altri gruppi abilitati alla visualizzazione. Il controllo
* evidenzia quali devono essere i gruppi al quale il contenuto deve essere
* necessariamente associato (ed il perchè) per salvaguardare le precedenti
* relazioni.
*
* @param content
* Il contenuto da analizzare.
* @param action
* L'action da valorizzare con i messaggi di errore.
* @throws ApsSystemException
* In caso di errore.
*/
@Override
public void scanReferences(Content content, ActionSupport action) throws ApsSystemException {
if (!Group.FREE_GROUP_NAME.equals(content.getMainGroup()) && !content.getGroups().contains(Group.FREE_GROUP_NAME)) {
HttpServletRequest request = ServletActionContext.getRequest();
try {
String[] defNames = ApsWebApplicationUtils.getWebApplicationContext(request).getBeanNamesForType(ContentUtilizer.class);
for (int i = 0; i < defNames.length; i++) {
Object service = null;
try {
service = ApsWebApplicationUtils.getWebApplicationContext(request).getBean(defNames[i]);
} catch (Throwable t) {
_logger.error("error loading ReferencingObject ", t);
service = null;
}
if (service != null) {
ContentUtilizer contentUtilizer = (ContentUtilizer) service;
List<Object> utilizers = contentUtilizer.getContentUtilizers(content.getId());
if (null == utilizers) {
continue;
}
Lang lang = this.getLangManager().getDefaultLang();
for (int j = 0; j < utilizers.size(); j++) {
Object object = utilizers.get(j);
if (service instanceof IContentManager && object instanceof String) {
// Content
// ID
Content refContent = this.getContentManager().loadContent(object.toString(), true);
if (!content.getMainGroup().equals(refContent.getMainGroup()) && !content.getGroups().contains(refContent.getMainGroup())) {
String[] args = { this.getGroupManager().getGroup(refContent.getMainGroup()).getDescription(), object.toString() + " '" + refContent.getDescription() + "'" };
action.addFieldError("mainGroup", action.getText("error.content.referencedContent.wrongGroups", args));
}
} else if (object instanceof IPage) {
// Content ID
IPage page = (IPage) object;
// page online, must be done the same check
if (!CmsPageUtil.isContentPublishableOnPageOnline(content, page)) {
PageMetadata metadata = page.getMetadata();
List<String> pageGroups = new ArrayList<String>();
pageGroups.add(page.getGroup());
if (metadata != null && null != metadata.getExtraGroups()) {
pageGroups.addAll(metadata.getExtraGroups());
}
String[] args = { pageGroups.toString(), page.getTitle(lang.getCode()) };
action.addFieldError("mainGroup", action.getText("error.content.referencedPage.wrongGroups", args));
}
}
}
}
}
} catch (Throwable t) {
throw new ApsSystemException("Error in hasReferencingObject method", t);
}
}
}
use of com.agiletec.aps.system.services.lang.Lang in project entando-core by entando.
the class ContentListViewerWidgetAction method isMultilanguageParamValued.
private boolean isMultilanguageParamValued(String prefix) {
ApsProperties config = this.getWidget().getConfig();
if (null == config) {
return false;
}
for (int i = 0; i < this.getLangs().size(); i++) {
Lang lang = this.getLangs().get(i);
String paramValue = config.getProperty(prefix + lang.getCode());
if (null != paramValue && paramValue.trim().length() > 0) {
return true;
}
}
return false;
}
Aggregations