Search in sources :

Example 1 with ICategoryManager

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;
    }
}
Also used : IContentDispenser(com.agiletec.plugins.jacms.aps.system.services.dispenser.IContentDispenser) ICmsSearchEngineManager(com.agiletec.plugins.jacms.aps.system.services.searchengine.ICmsSearchEngineManager) IContentRenderer(com.agiletec.plugins.jacms.aps.system.services.renderer.IContentRenderer) IContentManager(com.agiletec.plugins.jacms.aps.system.services.content.IContentManager) IResourceManager(com.agiletec.plugins.jacms.aps.system.services.resource.IResourceManager) ILinkResolverManager(com.agiletec.plugins.jacms.aps.system.services.linkresolver.ILinkResolverManager) IContentPageMapperManager(com.agiletec.plugins.jacms.aps.system.services.contentpagemapper.IContentPageMapperManager) ICategoryManager(com.agiletec.aps.system.services.category.ICategoryManager) IContentModelManager(com.agiletec.plugins.jacms.aps.system.services.contentmodel.IContentModelManager)

Example 2 with ICategoryManager

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));
    }
}
Also used : Content(com.agiletec.plugins.jacms.aps.system.services.content.model.Content) ArrayList(java.util.ArrayList) EntitySearchFilter(com.agiletec.aps.system.common.entity.model.EntitySearchFilter) ICategoryManager(com.agiletec.aps.system.services.category.ICategoryManager)

Example 3 with ICategoryManager

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;
}
Also used : Category(com.agiletec.aps.system.services.category.Category) MockResourceDataBean(com.agiletec.plugins.jacms.aps.system.services.resource.mock.MockResourceDataBean) ArrayList(java.util.ArrayList) File(java.io.File) ICategoryManager(com.agiletec.aps.system.services.category.ICategoryManager)

Example 4 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 5 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