Search in sources :

Example 21 with CatalogCategory

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;
}
Also used : CatalogCategoryMapper.createNewCatalogCategory(com.emc.sa.api.mapper.CatalogCategoryMapper.createNewCatalogCategory) CatalogCategory(com.emc.storageos.db.client.model.uimodels.CatalogCategory) CatalogCategoryList(com.emc.vipr.model.catalog.CatalogCategoryList) NamedRelatedResourceRep(com.emc.storageos.model.NamedRelatedResourceRep) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET)

Example 22 with CatalogCategory

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);
}
Also used : StorageOSUser(com.emc.storageos.security.authentication.StorageOSUser) CatalogCategoryMapper.createNewCatalogCategory(com.emc.sa.api.mapper.CatalogCategoryMapper.createNewCatalogCategory) CatalogCategory(com.emc.storageos.db.client.model.uimodels.CatalogCategory) Path(javax.ws.rs.Path) POST(javax.ws.rs.POST) Consumes(javax.ws.rs.Consumes) Produces(javax.ws.rs.Produces) CheckPermission(com.emc.storageos.security.authorization.CheckPermission)

Example 23 with 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;
}
Also used : CatalogCategoryMapper.createNewCatalogCategory(com.emc.sa.api.mapper.CatalogCategoryMapper.createNewCatalogCategory) CatalogCategory(com.emc.storageos.db.client.model.uimodels.CatalogCategory) ACLAssignments(com.emc.storageos.model.auth.ACLAssignments)

Example 24 with CatalogCategory

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);
}
Also used : CatalogService(com.emc.storageos.db.client.model.uimodels.CatalogService) CatalogCategory(com.emc.storageos.db.client.model.uimodels.CatalogCategory) URI(java.net.URI) CatalogACLInputFilter(com.emc.sa.api.utils.CatalogACLInputFilter) Path(javax.ws.rs.Path) Consumes(javax.ws.rs.Consumes) PUT(javax.ws.rs.PUT) CheckPermission(com.emc.storageos.security.authorization.CheckPermission)

Example 25 with CatalogCategory

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);
}
Also used : CatalogServiceField(com.emc.storageos.db.client.model.uimodels.CatalogServiceField) WorkflowServiceDescriptor(com.emc.sa.catalog.WorkflowServiceDescriptor) ServiceDescriptor(com.emc.sa.descriptor.ServiceDescriptor) StorageOSUser(com.emc.storageos.security.authentication.StorageOSUser) CatalogService(com.emc.storageos.db.client.model.uimodels.CatalogService) CatalogCategory(com.emc.storageos.db.client.model.uimodels.CatalogCategory) Path(javax.ws.rs.Path) Consumes(javax.ws.rs.Consumes) Produces(javax.ws.rs.Produces) PUT(javax.ws.rs.PUT) CheckPermission(com.emc.storageos.security.authorization.CheckPermission)

Aggregations

CatalogCategory (com.emc.storageos.db.client.model.uimodels.CatalogCategory)36 NamedURI (com.emc.storageos.db.client.model.NamedURI)12 CatalogCategoryMapper.createNewCatalogCategory (com.emc.sa.api.mapper.CatalogCategoryMapper.createNewCatalogCategory)9 Path (javax.ws.rs.Path)9 BaseModelTest (com.emc.sa.model.BaseModelTest)7 ModelClient (com.emc.sa.model.dao.ModelClient)7 CatalogService (com.emc.storageos.db.client.model.uimodels.CatalogService)7 CheckPermission (com.emc.storageos.security.authorization.CheckPermission)7 URI (java.net.URI)7 Consumes (javax.ws.rs.Consumes)7 Produces (javax.ws.rs.Produces)7 Test (org.junit.Test)7 StorageOSUser (com.emc.storageos.security.authentication.StorageOSUser)6 PUT (javax.ws.rs.PUT)4 CatalogServiceField (com.emc.storageos.db.client.model.uimodels.CatalogServiceField)3 POST (javax.ws.rs.POST)3 CatalogACLInputFilter (com.emc.sa.api.utils.CatalogACLInputFilter)2 WorkflowServiceDescriptor (com.emc.sa.catalog.WorkflowServiceDescriptor)2 ServiceDescriptor (com.emc.sa.descriptor.ServiceDescriptor)2 GET (javax.ws.rs.GET)2