Search in sources :

Example 1 with CatalogImage

use of com.emc.storageos.db.client.model.uimodels.CatalogImage in project coprhd-controller by CoprHD.

the class CatalogImageService method updateCatalogImage.

/**
 * Update catalog image
 *
 * @param param Catalog Image update parameters
 * @param id the URN the catalog image
 * @prereq none
 * @brief Update Catalog Image
 * @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 CatalogImageRestRep updateCatalogImage(@PathParam("id") URI id, CatalogImageUpdateParam param) {
    CatalogImage catalogImage = getCatalogImageById(id, true);
    StorageOSUser user = getUserFromContext();
    verifyAuthorizedInTenantOrg(uri(catalogImage.getTenant()), user);
    validateParam(uri(catalogImage.getTenant()), param, catalogImage);
    updateObject(catalogImage, param);
    catalogImageManager.updateCatalogImage(catalogImage);
    auditOpSuccess(OperationTypeEnum.UPDATE_CATALOG_IMAGE, catalogImage.auditParameters());
    catalogImage = catalogImageManager.getCatalogImageById(catalogImage.getId());
    return map(catalogImage);
}
Also used : StorageOSUser(com.emc.storageos.security.authentication.StorageOSUser) CatalogImage(com.emc.storageos.db.client.model.uimodels.CatalogImage) 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)

Example 2 with CatalogImage

use of com.emc.storageos.db.client.model.uimodels.CatalogImage in project coprhd-controller by CoprHD.

the class CatalogImageService method getCatalogImages.

/**
 * Gets the list of catalog images
 *
 * @param tenantId the URN of a tenant
 * @brief List Catalog Images
 * @return a list of catalog images
 * @throws DatabaseException when a DB error occurs
 */
@GET
@Path("")
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
public CatalogImageList getCatalogImages(@DefaultValue("") @QueryParam(SearchConstants.TENANT_ID_PARAM) String tenantId) throws DatabaseException {
    StorageOSUser user = getUserFromContext();
    if (StringUtils.isBlank(tenantId)) {
        tenantId = user.getTenantId();
    }
    verifyAuthorizedInTenantOrg(uri(tenantId), getUserFromContext());
    List<CatalogImage> catalogImages = catalogImageManager.getCatalogImages(uri(tenantId));
    CatalogImageList list = new CatalogImageList();
    for (CatalogImage catalogImage : catalogImages) {
        NamedRelatedResourceRep resourceRep = toNamedRelatedResource(ResourceTypeEnum.CATALOG_IMAGE, catalogImage.getId(), catalogImage.getLabel());
        list.getCatalogImages().add(resourceRep);
    }
    return list;
}
Also used : CatalogImageList(com.emc.vipr.model.catalog.CatalogImageList) StorageOSUser(com.emc.storageos.security.authentication.StorageOSUser) CatalogImage(com.emc.storageos.db.client.model.uimodels.CatalogImage) NamedRelatedResourceRep(com.emc.storageos.model.NamedRelatedResourceRep) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET)

Example 3 with CatalogImage

use of com.emc.storageos.db.client.model.uimodels.CatalogImage in project coprhd-controller by CoprHD.

the class CatalogImageService method createCatalogImage.

/**
 * Creates a new catalog image
 *
 * @param createParam
 *            the parameter to create a new catalog image
 * @prereq none
 * @brief Create Catalog Image
 * @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 CatalogImageRestRep createCatalogImage(CatalogImageCreateParam createParam) {
    StorageOSUser user = getUserFromContext();
    verifyAuthorizedInTenantOrg(createParam.getTenant(), user);
    validateParam(createParam.getTenant(), createParam, null);
    CatalogImage catalogImage = createNewObject(createParam.getTenant(), createParam);
    catalogImageManager.createCatalogImage(catalogImage);
    auditOpSuccess(OperationTypeEnum.CREATE_CATALOG_IMAGE, catalogImage.auditParameters());
    return map(catalogImage);
}
Also used : StorageOSUser(com.emc.storageos.security.authentication.StorageOSUser) CatalogImage(com.emc.storageos.db.client.model.uimodels.CatalogImage) 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 4 with CatalogImage

use of com.emc.storageos.db.client.model.uimodels.CatalogImage in project coprhd-controller by CoprHD.

the class CatalogImageService method deactivateCatalogImage.

/**
 * Deactivates the catalog image
 *
 * @param id the URN of an catalog image to be deactivated
 * @brief Deactivate Catalog Image
 * @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 deactivateCatalogImage(@PathParam("id") URI id) throws DatabaseException {
    CatalogImage catalogImage = queryResource(id);
    ArgValidator.checkEntity(catalogImage, id, true);
    catalogImageManager.deleteCatalogImage(catalogImage);
    auditOpSuccess(OperationTypeEnum.DELETE_CATALOG_IMAGE, catalogImage.auditParameters());
    return Response.ok().build();
}
Also used : CatalogImage(com.emc.storageos.db.client.model.uimodels.CatalogImage) Path(javax.ws.rs.Path) POST(javax.ws.rs.POST) Produces(javax.ws.rs.Produces) CheckPermission(com.emc.storageos.security.authorization.CheckPermission)

Example 5 with CatalogImage

use of com.emc.storageos.db.client.model.uimodels.CatalogImage in project coprhd-controller by CoprHD.

the class CatalogImageMapper method createNewObject.

public static CatalogImage createNewObject(URI tenantId, CatalogImageCreateParam param) {
    CatalogImage newObject = new CatalogImage();
    newObject.setId(URIUtil.createId(CatalogImage.class));
    newObject.setTenant(tenantId.toString());
    updateObject(newObject, param);
    return newObject;
}
Also used : CatalogImage(com.emc.storageos.db.client.model.uimodels.CatalogImage)

Aggregations

CatalogImage (com.emc.storageos.db.client.model.uimodels.CatalogImage)6 Path (javax.ws.rs.Path)4 Produces (javax.ws.rs.Produces)4 StorageOSUser (com.emc.storageos.security.authentication.StorageOSUser)3 CheckPermission (com.emc.storageos.security.authorization.CheckPermission)3 Consumes (javax.ws.rs.Consumes)2 POST (javax.ws.rs.POST)2 NamedRelatedResourceRep (com.emc.storageos.model.NamedRelatedResourceRep)1 CatalogImageList (com.emc.vipr.model.catalog.CatalogImageList)1 GET (javax.ws.rs.GET)1 PUT (javax.ws.rs.PUT)1