コード例 #1
0
  /**
   * 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);
  }
コード例 #2
0
  @PUT
  @Path("/{id}/acl")
  @Consumes({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON})
  @CheckPermission(
      roles = {Role.SECURITY_ADMIN, Role.TENANT_ADMIN},
      acls = {ACL.OWN},
      block_proxies = 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);
  }
コード例 #3
0
  /**
   * Creates a new catalog service
   *
   * @param createParam the parameter to create a new catalog service
   * @prereq none
   * @brief Create Catalog Service
   * @return none
   */
  @POST
  @Consumes({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON})
  @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON})
  @CheckPermission(
      roles = {Role.TENANT_ADMIN},
      acls = {ACL.OWN})
  @Path("")
  public CatalogServiceRestRep createCatalogService(CatalogServiceCreateParam createParam) {

    StorageOSUser user = getUserFromContext();
    CatalogCategory parentCatalogCategory =
        catalogCategoryManager.getCatalogCategoryById(createParam.getCatalogCategory());
    verifyAuthorizedInTenantOrg(uri(parentCatalogCategory.getTenant()), user);

    validateParam(createParam, null);

    CatalogService catalogService = createNewObject(createParam, parentCatalogCategory);
    List<CatalogServiceField> catalogServiceFields =
        createNewObjectList(catalogService, createParam.getCatalogServiceFields());
    catalogServiceManager.createCatalogService(catalogService, catalogServiceFields);

    auditOpSuccess(OperationTypeEnum.CREATE_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);
  }
コード例 #4
0
 @Override
 protected URI getTenantOwner(URI id) {
   CatalogService catalogService = queryResource(id);
   CatalogCategory parentCatalogCategory =
       catalogCategoryManager.getCatalogCategoryById(
           catalogService.getCatalogCategoryId().getURI());
   return uri(parentCatalogCategory.getTenant());
 }