use of com.agiletec.aps.system.services.category.ICategoryManager in project entando-core by entando.
the class TestCmsApplicationContext method testGetCmsServices.
public void testGetCmsServices() throws Throwable {
try {
IResourceManager resourceManager = (IResourceManager) this.getService(JacmsSystemConstants.RESOURCE_MANAGER);
assertNotNull(resourceManager);
IContentManager contentManager = (IContentManager) this.getService(JacmsSystemConstants.CONTENT_MANAGER);
assertNotNull(contentManager);
ICategoryManager categoryManager = (ICategoryManager) this.getService(SystemConstants.CATEGORY_MANAGER);
assertNotNull(categoryManager);
IContentModelManager contentModelManager = (IContentModelManager) this.getService(JacmsSystemConstants.CONTENT_MODEL_MANAGER);
assertNotNull(contentModelManager);
IContentRenderer contentRenderer = (IContentRenderer) this.getService(JacmsSystemConstants.CONTENT_RENDERER_MANAGER);
assertNotNull(contentRenderer);
IContentDispenser contentDispenser = (IContentDispenser) this.getService(JacmsSystemConstants.CONTENT_DISPENSER_MANAGER);
assertNotNull(contentDispenser);
ICmsSearchEngineManager searchEngineManager = (ICmsSearchEngineManager) this.getService(JacmsSystemConstants.SEARCH_ENGINE_MANAGER);
assertNotNull(searchEngineManager);
ILinkResolverManager linkResolver = (ILinkResolverManager) this.getService(JacmsSystemConstants.LINK_RESOLVER_MANAGER);
assertNotNull(linkResolver);
IContentPageMapperManager contentPageMapper = (IContentPageMapperManager) this.getService(JacmsSystemConstants.CONTENT_PAGE_MAPPER_MANAGER);
assertNotNull(contentPageMapper);
} catch (Throwable t) {
throw t;
}
}
use of com.agiletec.aps.system.services.category.ICategoryManager in project entando-core by entando.
the class TestContentManager method testSearchWorkContents_3.
public void testSearchWorkContents_3() throws Throwable {
List<String> groupCodes = new ArrayList<String>();
groupCodes.add(Group.ADMINS_GROUP_NAME);
EntitySearchFilter creationOrder = new EntitySearchFilter(IContentManager.CONTENT_CREATION_DATE_FILTER_KEY, false);
creationOrder.setOrder(EntitySearchFilter.DESC_ORDER);
EntitySearchFilter[] filters = { creationOrder };
String[] categories_1 = { "general_cat2" };
List<String> contents = this._contentManager.loadWorkContentsId(categories_1, filters, groupCodes);
String[] order_a = { "ART120", "ART112", "ART111", "EVN193", "ART179" };
assertEquals(order_a.length, contents.size());
this.verifyOrder(contents, order_a);
String[] categories_2 = { "general_cat1", "general_cat2" };
contents = this._contentManager.loadWorkContentsId(categories_2, filters, groupCodes);
String[] order_b = { "ART111", "ART179" };
assertEquals(order_b.length, contents.size());
assertEquals(order_b[0], contents.get(0));
Content newContent = this._contentManager.loadContent("EVN193", false);
newContent.setId(null);
try {
this._contentManager.saveContent(newContent);
contents = this._contentManager.loadWorkContentsId(categories_1, filters, groupCodes);
String[] order_c = { newContent.getId(), "ART120", "ART112", "ART111", "EVN193", "ART179" };
assertEquals(order_c.length, contents.size());
this.verifyOrder(contents, order_c);
ICategoryManager categoryManager = (ICategoryManager) this.getService(SystemConstants.CATEGORY_MANAGER);
newContent.addCategory(categoryManager.getCategory("general_cat1"));
this._contentManager.saveContent(newContent);
contents = this._contentManager.loadWorkContentsId(categories_2, filters, groupCodes);
String[] order_d = { newContent.getId(), "ART111", "ART179" };
assertEquals(order_d.length, contents.size());
this.verifyOrder(contents, order_d);
} catch (Throwable t) {
throw t;
} finally {
this._contentManager.deleteContent(newContent);
assertNull(this._contentManager.loadContent(newContent.getId(), false));
}
}
use of com.agiletec.aps.system.services.category.ICategoryManager in project entando-core by entando.
the class ResourceManagerIntegrationTest method getMockResource.
private ResourceDataBean getMockResource(String resourceType, String mainGroup, String resDescrToAdd, String categoryCodeToAdd) {
File file = new File("target/test/entando_logo.jpg");
MockResourceDataBean bean = new MockResourceDataBean();
bean.setFile(file);
bean.setDescr(resDescrToAdd);
bean.setMainGroup(mainGroup);
bean.setResourceType(resourceType);
bean.setMimeType("image/jpeg");
List<Category> categories = new ArrayList<Category>();
ICategoryManager catManager = (ICategoryManager) this.getService(SystemConstants.CATEGORY_MANAGER);
Category cat = catManager.getCategory(categoryCodeToAdd);
categories.add(cat);
bean.setCategories(categories);
return bean;
}
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