use of com.agiletec.aps.system.services.category.Category in project entando-core by entando.
the class TestCategoryAction method testTrashCategory.
public void testTrashCategory() throws Throwable {
String categoryCode = "cat_temp";
assertNull(this._categoryManager.getCategory(categoryCode));
try {
String result = this.saveNewCategory("admin", categoryCode);
assertEquals(Action.SUCCESS, result);
Category category = this._categoryManager.getCategory(categoryCode);
assertNotNull(category);
this.initAction("/do/Category", "trash");
this.addParameter("selectedNode", categoryCode);
result = this.executeAction();
assertEquals(Action.SUCCESS, result);
category = this._categoryManager.getCategory(categoryCode);
assertNotNull(category);
} catch (Throwable t) {
throw t;
} finally {
this._categoryManager.deleteCategory(categoryCode);
assertNull(this._categoryManager.getCategory(categoryCode));
}
}
use of com.agiletec.aps.system.services.category.Category in project entando-core by entando.
the class TestCategoryAction method testDeleteCategory_2.
public void testDeleteCategory_2() throws Throwable {
this.setUserOnSession("admin");
String categoryCode = "general_cat1";
assertNotNull(this._categoryManager.getCategory(categoryCode));
try {
this.initAction("/do/Category", "trash");
this.addParameter("selectedNode", categoryCode);
String result = this.executeAction();
assertEquals("references", result);
Category category = this._categoryManager.getCategory(categoryCode);
assertNotNull(category);
Map<String, Object> references = ((CategoryAction) this.getAction()).getReferences();
assertNotNull(references);
assertEquals(2, references.size());
this.initAction("/do/Category", "delete");
this.addParameter("selectedNode", categoryCode);
result = this.executeAction();
assertEquals("references", result);
category = this._categoryManager.getCategory(categoryCode);
assertNotNull(category);
references = ((CategoryAction) this.getAction()).getReferences();
assertNotNull(references);
assertEquals(2, references.size());
} catch (Throwable t) {
throw t;
}
}
use of com.agiletec.aps.system.services.category.Category in project entando-core by entando.
the class ContentCategoryAction method joinCategory.
/**
* Performs the action of adding of a category to the content.
* @return The result code.
*/
public String joinCategory() {
this.updateContentOnSession();
try {
String categoryCode = this.getCategoryCode();
Category category = this.getCategoryManager().getCategory(categoryCode);
if (null != category && !category.getCode().equals(category.getParentCode()) && !this.getContent().getCategories().contains(category)) {
this.getContent().addCategory(category);
}
} catch (Throwable t) {
_logger.error("error in joinCategory", t);
return FAILURE;
}
return SUCCESS;
}
use of com.agiletec.aps.system.services.category.Category in project entando-core by entando.
the class ContentFinderAction method getContents.
/**
* Restituisce la lista identificativi di contenuti che deve essere erogata
* dall'interfaccia di visualizzazione dei contenuti. La lista deve essere
* filtrata secondo i parametri di ricerca impostati.
*
* @return La lista di contenuti che deve essere erogata dall'interfaccia di
* visualizzazione dei contenuti.
*/
public List<String> getContents() {
List<String> result = null;
try {
ContentFinderSearchInfo searchInfo = getContentSearchInfo();
List<String> allowedGroups = this.getContentGroupCodes();
String[] categories = null;
Category category = this.getCategoryManager().getCategory(this.getCategoryCode());
if (null != category && !category.isRoot()) {
String catCode = this.getCategoryCode().trim();
categories = new String[] { catCode };
searchInfo.setCategoryCode(catCode);
} else {
searchInfo.setCategoryCode(null);
}
result = this.getContentManager().loadWorkContentsId(categories, this.getFilters(), allowedGroups);
} catch (Throwable t) {
_logger.error("error in getContents", t);
throw new RuntimeException("error in getContents", t);
}
return result;
}
use of com.agiletec.aps.system.services.category.Category in project entando-core by entando.
the class CategoryAction method checkDelete.
/**
* Perform all the needed checks before deleting a category. When errors are
* detected a new actionMessaged, containing the appropriate error code and
* messaged, is created.
*
* @return null if the deletion operation is successful, otherwise the error
* code
*/
protected String checkDelete() {
Category currentCategory = this.getCategory(this.getSelectedNode());
if (null == currentCategory) {
_logger.info("Required a selected node");
this.addActionError(this.getText("error.category.selectCategory"));
return "categoryTree";
}
if (currentCategory.getCode().equals(currentCategory.getParentCode())) {
_logger.info("Home category not deletable");
this.addActionError(this.getText("error.category.homeDelete.notAllowed"));
return "categoryTree";
}
if (currentCategory.getChildrenCodes().length != 0) {
_logger.info("Category with children not deletable");
this.addActionError(this.getText("error.category.deleteWithChildren.notAllowed"));
return "categoryTree";
}
this.extractReferencingObjects(this.getSelectedNode());
if (null != this.getReferences() && this.getReferences().size() > 0) {
return "references";
}
return null;
}
Aggregations