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