use of com.emc.vipr.model.catalog.CatalogServiceRestRep in project coprhd-controller by CoprHD.
the class EditCatalog method copyService.
public static void copyService(String serviceId, String fromId) {
CatalogServiceRestRep catalogService = CatalogServiceUtils.getCatalogService(uri(serviceId));
ServiceForm service = new ServiceForm(catalogService);
service.id = null;
service.copiedFrom = serviceId;
service.title = Messages.get("EditCatalog.copyOf", service.title);
service.fromId = StringUtils.defaultIfBlank(fromId, service.owningCategoryId);
edit(service);
}
use of com.emc.vipr.model.catalog.CatalogServiceRestRep in project coprhd-controller by CoprHD.
the class EditCatalog method moveDownService.
public static void moveDownService(String id) {
CatalogServiceRestRep catalogService = CatalogServiceUtils.getCatalogService(uri(id));
CatalogServiceUtils.moveDownService(catalogService.getId());
services(catalogService.getCatalogCategory().getId().toString());
}
use of com.emc.vipr.model.catalog.CatalogServiceRestRep in project coprhd-controller by CoprHD.
the class EditCatalog method saveService.
public static void saveService(ServiceForm service) {
// Set name before validation
if (StringUtils.isNotBlank(service.title)) {
service.name = service.title.replaceAll(" ", "");
}
service.validate("service");
if (validation.hasErrors()) {
params.flash();
validation.keep();
if (service.isCopy()) {
copyService(service.copiedFrom, service.fromId);
} else if (service.isNew()) {
createService(service.owningCategoryId, service.fromId);
} else {
editService(service.id, service.fromId);
}
} else {
CatalogServiceRestRep catalogService = service.save();
String parentId = getParentId(catalogService.getCatalogCategory());
String fromId = StringUtils.defaultIfBlank(service.fromId, parentId);
catalogUpdated(fromId, "EditCatalog.savedService", catalogService.getTitle());
}
}
use of com.emc.vipr.model.catalog.CatalogServiceRestRep in project coprhd-controller by CoprHD.
the class CatalogApi method serviceDescriptor.
public static void serviceDescriptor(String serviceId) {
CatalogServiceRestRep service = CatalogServiceUtils.getCatalogService(uri(serviceId));
ServiceDescriptorRestRep descriptor = service.getServiceDescriptor();
// Remove any locked fields so user does not see things they cannot change
for (CatalogServiceFieldRestRep catalogServiceField : service.getCatalogServiceFields()) {
if (catalogServiceField.getOverride()) {
ServiceFieldRestRep serviceField = ServiceDescriptorUtils.getField(descriptor, catalogServiceField.getName());
descriptor.getItems().remove(serviceField);
}
}
renderPrettyJson(descriptor);
}
use of com.emc.vipr.model.catalog.CatalogServiceRestRep in project coprhd-controller by CoprHD.
the class CatalogApi method getCategoryOrService.
private static DataObjectRestRep getCategoryOrService(CatalogCategoryRestRep category, String subPath) {
if (category != null) {
List<CatalogServiceRestRep> catalogServices = CatalogServiceUtils.getCatalogServices(category);
for (CatalogServiceRestRep catalogService : catalogServices) {
if (StringUtils.equalsIgnoreCase(subPath, catalogService.getName())) {
return catalogService;
}
}
List<CatalogCategoryRestRep> subCatalogCategories = CatalogCategoryUtils.getCatalogCategories(category);
for (CatalogCategoryRestRep subCatalogCategory : subCatalogCategories) {
if (StringUtils.equalsIgnoreCase(subPath, subCatalogCategory.getName())) {
return subCatalogCategory;
}
}
}
return null;
}
Aggregations