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);
}
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;
}
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);
}
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();
}
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;
}
Aggregations