use of com.emc.vipr.model.catalog.CatalogCategoryRestRep in project coprhd-controller by CoprHD.
the class EditCatalog method editCategory.
public static void editCategory(String categoryId, String fromId) {
CatalogCategoryRestRep category = CatalogCategoryUtils.getCatalogCategory(uri(categoryId));
CategoryForm form = new CategoryForm(category);
form.fromId = StringUtils.defaultIfBlank(fromId, form.parentId);
edit(form);
}
use of com.emc.vipr.model.catalog.CatalogCategoryRestRep in project coprhd-controller by CoprHD.
the class EditCatalog method saveCategory.
public static void saveCategory(CategoryForm category) {
// Set name before validation
if (StringUtils.isNotBlank(category.title)) {
category.name = category.title.replaceAll(" ", "");
}
category.validate("category");
if (Validation.hasErrors()) {
params.flash();
Validation.keep();
if (category.isNew()) {
createCategory(category.parentId, category.fromId);
} else {
editCategory(category.id, category.fromId);
}
} else {
CatalogCategoryRestRep catalogCategory = category.save();
String parentId = getParentId(catalogCategory.getCatalogCategory());
String fromId = StringUtils.defaultIfBlank(category.fromId, parentId);
catalogUpdated(fromId, "Saved category: %s", catalogCategory.getTitle());
}
}
use of com.emc.vipr.model.catalog.CatalogCategoryRestRep in project coprhd-controller by CoprHD.
the class EditCatalog method services.
public static void services(String id) {
List<CatalogServiceRestRep> catalogServices = null;
if (StringUtils.isNotBlank(id)) {
CatalogCategoryRestRep parent = CatalogCategoryUtils.getCatalogCategory(uri(id));
catalogServices = CatalogServiceUtils.getCatalogServices(parent);
}
render(catalogServices);
}
use of com.emc.vipr.model.catalog.CatalogCategoryRestRep in project coprhd-controller by CoprHD.
the class EditCatalog method createCategory.
public static void createCategory(String parentId, String fromId) {
CatalogCategoryRestRep parent = CatalogCategoryUtils.getCatalogCategory(uri(parentId));
CategoryForm category = new CategoryForm();
category.parentId = getId(parent);
category.fromId = StringUtils.defaultIfBlank(fromId, category.parentId);
edit(category);
}
use of com.emc.vipr.model.catalog.CatalogCategoryRestRep in project coprhd-controller by CoprHD.
the class ServiceCatalog method docCategory.
public static void docCategory(String categoryId) {
if (categoryId == null) {
redirect(DocUtils.getDocumentationLink());
}
CatalogCategoryRestRep category = CatalogCategoryUtils.getCatalogCategory(uri(categoryId));
if (category == null) {
redirect(DocUtils.getDocumentationLink());
}
// NOSONAR
Logger.debug("Redirecting to doc page for category: " + category.getName());
// ("Suppressing Sonar violation of Possible null pointer deference of category. In the previous if condition, category being null is handled.")
redirect(DocUtils.getCatalogDocumentationLink(category.getName()));
}
Aggregations