Search in sources :

Example 6 with ICategoryManager

use of com.agiletec.aps.system.services.category.ICategoryManager in project entando-core by entando.

the class ContentBulkActionHelper method getCategoriesToManage.

@Override
public List<Category> getCategoriesToManage(Collection<String> categoryCodes, ValidationAware validation, TextProvider textProvider) {
    boolean allowed = true;
    List<Category> categories = new ArrayList<Category>();
    if (categoryCodes == null || categoryCodes.isEmpty()) {
        validation.addActionError(textProvider.getText("error.bulk.categories.empty"));
        allowed = false;
    } else {
        ICategoryManager categoryManager = this.getCategoryManager();
        for (String categoryCode : categoryCodes) {
            Category category = categoryManager.getCategory(categoryCode);
            if (category == null || category.isRoot()) {
                validation.addActionError(textProvider.getText("error.bulk.categories.notAllowed", new String[] { categoryCode }));
                allowed = false;
            } else {
                categories.add(category);
            }
        }
    }
    return allowed ? categories : null;
}
Also used : Category(com.agiletec.aps.system.services.category.Category) ArrayList(java.util.ArrayList) ICategoryManager(com.agiletec.aps.system.services.category.ICategoryManager)

Example 7 with ICategoryManager

use of com.agiletec.aps.system.services.category.ICategoryManager in project entando-core by entando.

the class CategoriesTag method doStartTag.

@Override
public int doStartTag() throws JspException {
    ServletRequest request = this.pageContext.getRequest();
    RequestContext reqCtx = (RequestContext) request.getAttribute(RequestContext.REQCTX);
    ICategoryManager catManager = (ICategoryManager) ApsWebApplicationUtils.getBean(SystemConstants.CATEGORY_MANAGER, this.pageContext);
    try {
        List<SelectItem> categories = new ArrayList<SelectItem>();
        Category root = (null != this.getRoot()) ? catManager.getCategory(this.getRoot()) : null;
        if (null == root) {
            root = catManager.getRoot();
        }
        Lang currentLang = (Lang) reqCtx.getExtraParam(SystemConstants.EXTRAPAR_CURRENT_LANG);
        String langCode = currentLang.getCode();
        String reqTitStyle = this.getTitleStyle();
        List<String> allowedStyles = Arrays.asList(ALLOWED_TITLE_TYPES);
        String titleStyle = (null != reqTitStyle && (allowedStyles.contains(reqTitStyle))) ? reqTitStyle : null;
        this.addSmallCategory(categories, root, langCode, titleStyle, catManager);
        this.pageContext.setAttribute(this.getVar(), categories);
    } catch (Throwable t) {
        _logger.error("Error starting tag", t);
        throw new JspException("Error starting tag", t);
    }
    return super.doStartTag();
}
Also used : ServletRequest(javax.servlet.ServletRequest) JspException(javax.servlet.jsp.JspException) Category(com.agiletec.aps.system.services.category.Category) SelectItem(com.agiletec.aps.util.SelectItem) ArrayList(java.util.ArrayList) Lang(com.agiletec.aps.system.services.lang.Lang) RequestContext(com.agiletec.aps.system.RequestContext) ICategoryManager(com.agiletec.aps.system.services.category.ICategoryManager)

Aggregations

ICategoryManager (com.agiletec.aps.system.services.category.ICategoryManager)7 ArrayList (java.util.ArrayList)5 Category (com.agiletec.aps.system.services.category.Category)3 EntitySearchFilter (com.agiletec.aps.system.common.entity.model.EntitySearchFilter)2 RequestContext (com.agiletec.aps.system.RequestContext)1 ConfigInterface (com.agiletec.aps.system.services.baseconfig.ConfigInterface)1 II18nManager (com.agiletec.aps.system.services.i18n.II18nManager)1 IKeyGeneratorManager (com.agiletec.aps.system.services.keygenerator.IKeyGeneratorManager)1 ILangManager (com.agiletec.aps.system.services.lang.ILangManager)1 Lang (com.agiletec.aps.system.services.lang.Lang)1 IPageManager (com.agiletec.aps.system.services.page.IPageManager)1 IPageModelManager (com.agiletec.aps.system.services.pagemodel.IPageModelManager)1 IRoleManager (com.agiletec.aps.system.services.role.IRoleManager)1 IURLManager (com.agiletec.aps.system.services.url.IURLManager)1 IUserManager (com.agiletec.aps.system.services.user.IUserManager)1 SelectItem (com.agiletec.aps.util.SelectItem)1 IContentManager (com.agiletec.plugins.jacms.aps.system.services.content.IContentManager)1 Content (com.agiletec.plugins.jacms.aps.system.services.content.model.Content)1 IContentModelManager (com.agiletec.plugins.jacms.aps.system.services.contentmodel.IContentModelManager)1 IContentPageMapperManager (com.agiletec.plugins.jacms.aps.system.services.contentpagemapper.IContentPageMapperManager)1