use of com.emc.storageos.db.client.model.uimodels.CatalogCategory in project coprhd-controller by CoprHD.
the class CatalogServiceTest method testFindByCatalogCategory.
@Test
public void testFindByCatalogCategory() {
_logger.info("Starting FindByCatalogCategory test");
ModelClient modelClient = getModelClient();
CatalogCategory root = createCategoryWithLabel("rooty");
modelClient.save(root);
CatalogService s1 = createWithLabel("s1");
s1.setCatalogCategoryId(new NamedURI(root.getId(), root.getLabel()));
modelClient.save(s1);
CatalogCategory c1 = createCategoryWithLabel("asdf");
c1.setCatalogCategoryId(new NamedURI(root.getId(), root.getLabel()));
modelClient.save(c1);
CatalogService s2 = createWithLabel("s2");
s2.setCatalogCategoryId(new NamedURI(c1.getId(), c1.getLabel()));
modelClient.save(s2);
CatalogService s3 = createWithLabel("s3");
s3.setCatalogCategoryId(new NamedURI(c1.getId(), c1.getLabel()));
modelClient.save(s3);
CatalogCategory c2 = createCategoryWithLabel("asdf2");
c2.setCatalogCategoryId(new NamedURI(root.getId(), root.getLabel()));
modelClient.save(c2);
CatalogService s4 = createWithLabel("s4");
s4.setCatalogCategoryId(new NamedURI(c2.getId(), c2.getLabel()));
modelClient.save(s4);
CatalogService s5 = createWithLabel("s5");
s5.setCatalogCategoryId(new NamedURI(c2.getId(), c2.getLabel()));
modelClient.save(s5);
CatalogService s6 = createWithLabel("s6");
s6.setCatalogCategoryId(new NamedURI(c2.getId(), c2.getLabel()));
modelClient.save(s6);
List<CatalogService> results = modelClient.catalogServices().findByCatalogCategory(root.getId());
Assert.assertNotNull(results);
Assert.assertEquals(1, results.size());
results = modelClient.catalogServices().findByCatalogCategory(c1.getId());
Assert.assertNotNull(results);
Assert.assertEquals(2, results.size());
results = modelClient.catalogServices().findByCatalogCategory(c2.getId());
Assert.assertNotNull(results);
Assert.assertEquals(3, results.size());
}
use of com.emc.storageos.db.client.model.uimodels.CatalogCategory in project coprhd-controller by CoprHD.
the class BasePermissionsHelper method checkForActiveCatalogCategoryAclsUsingUserGroup.
/**
* Checks whether the given the user group is present the any of the
* catalog category acls or not
*
* @param label to check if any tenants role-assignments uses user group or not.
* @return set of URI's catalog category that uses the user group.
*/
public Set<URI> checkForActiveCatalogCategoryAclsUsingUserGroup(String label) {
Set<URI> catalogCategoryUsingUserGroup = null;
// Find all the configured Catalog category IDs based on the type.
List<URI> catalogCategoryURIList = _dbClient.queryByType(CatalogCategory.class, true);
if (catalogCategoryURIList == null || !catalogCategoryURIList.iterator().hasNext()) {
_log.warn("There are no catalog category configured.");
return catalogCategoryUsingUserGroup;
}
// Find all the configured Catalog category objects based on the given list of IDs.
List<CatalogCategory> catalogCategories = _dbClient.queryObject(CatalogCategory.class, catalogCategoryURIList);
if (CollectionUtils.isEmpty(catalogCategories)) {
_log.error("Could not find the Catalog category objects for the Ids {}", catalogCategoryURIList.toString());
return catalogCategoryUsingUserGroup;
}
catalogCategoryUsingUserGroup = new HashSet<URI>();
for (CatalogCategory catalogCategory : catalogCategories) {
if (catalogCategory == null) {
_log.info("Invalid catalog category");
continue;
}
if (CollectionUtils.isEmpty(catalogCategory.getAcls())) {
_log.debug("ACLs not configured for Catalog category {}", catalogCategory.getLabel());
continue;
}
Set<String> aclKeys = catalogCategory.getAcls().keySet();
if (checkUserGroupWithPermissionKeys(label, aclKeys)) {
catalogCategoryUsingUserGroup.add(catalogCategory.getId());
}
}
return catalogCategoryUsingUserGroup;
}
use of com.emc.storageos.db.client.model.uimodels.CatalogCategory in project coprhd-controller by CoprHD.
the class CatalogCategoryService 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) {
CatalogCategory catalogCategory = catalogCategoryManager.getCatalogCategoryById(id);
URI tenantId = uri(catalogCategory.getTenant());
_permissionsHelper.updateACLs(catalogCategory, changes, new CatalogACLInputFilter(tenantId));
catalogCategoryManager.updateCatalogCategory(catalogCategory);
;
auditOpSuccess(OperationTypeEnum.MODIFY_CATALOG_CATEGORY_ACL, catalogCategory.getId().toString(), catalogCategory.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 CatalogCategoryService method getRootCatalogCategory.
/**
* Get the root catalog category for a tenant
*
* @prereq none
* @brief Get Root Catalog Category
* @return Root Catalog Category
*/
@GET
@Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Path("")
public CatalogCategoryRestRep getRootCatalogCategory(@DefaultValue("") @QueryParam(SearchConstants.TENANT_ID_PARAM) String tenantId) {
StorageOSUser user = getUserFromContext();
if (StringUtils.isBlank(tenantId)) {
tenantId = user.getTenantId();
}
verifyAuthorizedInTenantOrg(uri(tenantId), user);
CatalogCategory catalogCategory = catalogCategoryManager.getOrCreateRootCategory(uri(tenantId));
return map(catalogCategory);
}
use of com.emc.storageos.db.client.model.uimodels.CatalogCategory in project coprhd-controller by CoprHD.
the class CatalogCategoryService method deactivateCatalogCategory.
/**
* Deactivates the catalog category
*
* @param id the URN of a catalog category to be deactivated
* @brief Deactivate Catalog Category
* @return OK if deactivation completed successfully
* @throws DatabaseException when a DB error occurs
*/
@POST
@Path("/{id}/deactivate")
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@CheckPermission(roles = { Role.TENANT_ADMIN })
public Response deactivateCatalogCategory(@PathParam("id") URI id) throws DatabaseException {
CatalogCategory catalogCategory = queryResource(id);
ArgValidator.checkEntity(catalogCategory, id, true);
catalogCategoryManager.deleteCatalogCategory(catalogCategory);
auditOpSuccess(OperationTypeEnum.DELETE_CATALOG_CATEGORY, catalogCategory.auditParameters());
return Response.ok().build();
}
Aggregations