use of com.emc.storageos.db.client.model.uimodels.CatalogCategory in project coprhd-controller by CoprHD.
the class CatalogCategoryService method getCatalogCategories.
/**
* Gets the list of sub categories within the category
*
* @param id the URN of a Catalog Category
* @brief List Catalog Categories
* @return a list of sub categories that belong to the category
* @throws DatabaseException when a DB error occurs
*/
@GET
@Path("/{id}/categories")
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
public CatalogCategoryList getCatalogCategories(@PathParam("id") URI id) throws DatabaseException {
CatalogCategory parentCatalogCategory = queryResource(id);
// check the user permissions
verifyAuthorizedInTenantOrg(uri(parentCatalogCategory.getTenant()), getUserFromContext());
List<CatalogCategory> subCatalogCategories = catalogCategoryManager.getSubCategories(id);
subCatalogCategories = filterCategoriesByACLs(subCatalogCategories);
CatalogCategoryList subCatalogCategoryList = new CatalogCategoryList();
for (CatalogCategory subCatalogCategory : subCatalogCategories) {
NamedRelatedResourceRep subCatalogCategoryRestRep = toNamedRelatedResource(ResourceTypeEnum.CATALOG_CATEGORY, subCatalogCategory.getId(), subCatalogCategory.getLabel());
subCatalogCategoryList.getCatalogCategories().add(subCatalogCategoryRestRep);
}
return subCatalogCategoryList;
}
use of com.emc.storageos.db.client.model.uimodels.CatalogCategory in project coprhd-controller by CoprHD.
the class CatalogCategoryService method createCatalogCategory.
/**
* Creates a new catalog category in the supplied parent catalog category
*
* @param createParam
* the parameter to create a new catalog category
* @prereq none
* @brief Create Catalog Category
* @return none
*/
@POST
@Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@CheckPermission(roles = { Role.TENANT_ADMIN })
@Path("")
public CatalogCategoryRestRep createCatalogCategory(CatalogCategoryCreateParam createParam) {
StorageOSUser user = getUserFromContext();
String tenantId = createParam.getTenantId();
if (StringUtils.isBlank(tenantId)) {
tenantId = user.getTenantId();
}
verifyAuthorizedInTenantOrg(uri(tenantId), user);
CatalogCategory parentCatalogCategory = queryResource(createParam.getCatalogCategoryId());
validateCatalogCategoryParam(createParam.getCatalogCategoryId(), createParam, null);
CatalogCategory catalogCategory = createNewCatalogCategory(parentCatalogCategory, createParam);
catalogCategoryManager.createCatalogCategory(catalogCategory);
auditOpSuccess(OperationTypeEnum.CREATE_CATALOG_CATEGORY, catalogCategory.auditParameters());
return map(catalogCategory);
}
use of com.emc.storageos.db.client.model.uimodels.CatalogCategory in project coprhd-controller by CoprHD.
the class CatalogCategoryService method getRoleAssignmentsResponse.
private ACLAssignments getRoleAssignmentsResponse(URI id) {
CatalogCategory catalogCategory = catalogCategoryManager.getCatalogCategoryById(id);
ACLAssignments response = new ACLAssignments();
response.setAssignments(_permissionsHelper.convertToACLEntries(catalogCategory.getAcls()));
return response;
}
use of com.emc.storageos.db.client.model.uimodels.CatalogCategory in project coprhd-controller by CoprHD.
the class CatalogServiceService method updateRoleAssignments.
@PUT
@Path("/{id}/acl")
@Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@CheckPermission(roles = { Role.SECURITY_ADMIN, Role.TENANT_ADMIN }, acls = { ACL.OWN }, blockProxies = true)
public ACLAssignments updateRoleAssignments(@PathParam("id") URI id, ACLAssignmentChanges changes) {
CatalogService catalogService = catalogServiceManager.getCatalogServiceById(id);
CatalogCategory parentCatalogCategory = catalogCategoryManager.getCatalogCategoryById(catalogService.getCatalogCategoryId().getURI());
URI tenantId = uri(parentCatalogCategory.getTenant());
_permissionsHelper.updateACLs(catalogService, changes, new CatalogACLInputFilter(tenantId));
catalogServiceManager.updateCatalogService(catalogService, null);
;
auditOpSuccess(OperationTypeEnum.MODIFY_CATALOG_SERVICE_ACL, catalogService.getId().toString(), catalogService.getLabel(), changes);
catalogConfigUtils.notifyCatalogAclChange();
return getRoleAssignmentsResponse(id);
}
use of com.emc.storageos.db.client.model.uimodels.CatalogCategory in project coprhd-controller by CoprHD.
the class CatalogServiceService method updateCatalogService.
/**
* Update catalog service
*
* @param param Catalog Service update parameters
* @param id the URN the catalog service
* @prereq none
* @brief Update Catalog Service
* @return No data returned in response body
*/
@PUT
@Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Path("/{id}")
@CheckPermission(roles = { Role.TENANT_ADMIN }, acls = { ACL.OWN })
public CatalogServiceRestRep updateCatalogService(@PathParam("id") URI id, CatalogServiceUpdateParam param) {
CatalogService catalogService = getCatalogServiceById(id, true);
List<CatalogServiceField> catalogServiceFields = catalogServiceManager.getCatalogServiceFields(id);
StorageOSUser user = getUserFromContext();
CatalogCategory parentCatalogCategory = catalogCategoryManager.getCatalogCategoryById(param.getCatalogCategory());
verifyAuthorizedInTenantOrg(uri(parentCatalogCategory.getTenant()), user);
validateParam(param, catalogService);
updateObject(catalogService, param, parentCatalogCategory);
List<CatalogServiceField> updatedCatalogServiceFields = updateObjectList(catalogService, catalogServiceFields, param.getCatalogServiceFields());
catalogServiceManager.updateCatalogService(catalogService, updatedCatalogServiceFields);
auditOpSuccess(OperationTypeEnum.UPDATE_CATALOG_SERVICE, catalogService.auditParameters());
// Refresh Objects
catalogService = catalogServiceManager.getCatalogServiceById(catalogService.getId());
catalogServiceFields = catalogServiceManager.getCatalogServiceFields(catalogService.getId());
ServiceDescriptor serviceDescriptor = getServiceDescriptor(catalogService);
return map(catalogService, serviceDescriptor, catalogServiceFields);
}
Aggregations