Search in sources :

Example 1 with CatalogImageList

use of com.emc.vipr.model.catalog.CatalogImageList in project coprhd-controller by CoprHD.

the class CatalogImages method listByTenant.

@Override
public List<NamedRelatedResourceRep> listByTenant(URI tenantId) {
    UriBuilder uriBuilder = client.uriBuilder(PathConstants.CATALOG_IMAGE_URL);
    if (tenantId != null) {
        uriBuilder = uriBuilder.queryParam(SearchConstants.TENANT_ID_PARAM, tenantId);
    }
    CatalogImageList response = client.getURI(CatalogImageList.class, uriBuilder.build());
    return ResourceUtils.defaultList(response.getCatalogImages());
}
Also used : CatalogImageList(com.emc.vipr.model.catalog.CatalogImageList) UriBuilder(javax.ws.rs.core.UriBuilder)

Example 2 with CatalogImageList

use of com.emc.vipr.model.catalog.CatalogImageList 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)

Aggregations

CatalogImageList (com.emc.vipr.model.catalog.CatalogImageList)2 CatalogImage (com.emc.storageos.db.client.model.uimodels.CatalogImage)1 NamedRelatedResourceRep (com.emc.storageos.model.NamedRelatedResourceRep)1 StorageOSUser (com.emc.storageos.security.authentication.StorageOSUser)1 GET (javax.ws.rs.GET)1 Path (javax.ws.rs.Path)1 Produces (javax.ws.rs.Produces)1 UriBuilder (javax.ws.rs.core.UriBuilder)1