Search in sources :

Example 56 with Lang

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());
}
Also used : ActionSupport(com.opensymphony.xwork2.ActionSupport) Lang(com.agiletec.aps.system.services.lang.Lang)

Example 57 with Lang

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());
    }
}
Also used : SelectItem(com.agiletec.aps.util.SelectItem) List(java.util.List) Lang(com.agiletec.aps.system.services.lang.Lang)

Example 58 with Lang

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;
}
Also used : ActivityStreamInfo(org.entando.entando.aps.system.services.actionlog.model.ActivityStreamInfo) ArrayList(java.util.ArrayList) Lang(com.agiletec.aps.system.services.lang.Lang) Properties(java.util.Properties)

Example 59 with Lang

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);
        }
    }
}
Also used : PageMetadata(com.agiletec.aps.system.services.page.PageMetadata) Lang(com.agiletec.aps.system.services.lang.Lang) ApsSystemException(com.agiletec.aps.system.exception.ApsSystemException) ContentUtilizer(com.agiletec.plugins.jacms.aps.system.services.content.ContentUtilizer) HttpServletRequest(javax.servlet.http.HttpServletRequest) IPage(com.agiletec.aps.system.services.page.IPage) IContentManager(com.agiletec.plugins.jacms.aps.system.services.content.IContentManager) Content(com.agiletec.plugins.jacms.aps.system.services.content.model.Content) ArrayList(java.util.ArrayList) List(java.util.List)

Example 60 with Lang

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;
}
Also used : Lang(com.agiletec.aps.system.services.lang.Lang) ApsProperties(com.agiletec.aps.util.ApsProperties)

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