Search in sources :

Example 1 with ApprovalList

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

the class ApprovalService method getApprovals.

/**
 * Gets the list of approvals
 *
 * @param tenantId the URN of a tenant
 * @brief List Approvals
 * @return a list of approvals
 * @throws DatabaseException when a DB error occurs
 */
@GET
@Path("")
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
public ApprovalList getApprovals(@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<ApprovalRequest> approvals = approvalManager.getApprovals(uri(tenantId));
    ApprovalList approvalList = new ApprovalList();
    for (ApprovalRequest approval : approvals) {
        NamedRelatedResourceRep approvalRestRep = toNamedRelatedResource(ResourceTypeEnum.APPROVAL, approval.getId(), approval.getLabel());
        approvalList.getApprovals().add(approvalRestRep);
    }
    return approvalList;
}
Also used : ApprovalList(com.emc.vipr.model.catalog.ApprovalList) StorageOSUser(com.emc.storageos.security.authentication.StorageOSUser) ApprovalRequest(com.emc.storageos.db.client.model.uimodels.ApprovalRequest) NamedRelatedResourceRep(com.emc.storageos.model.NamedRelatedResourceRep) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET)

Example 2 with ApprovalList

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

the class Approvals2 method listByTenant.

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

Aggregations

ApprovalList (com.emc.vipr.model.catalog.ApprovalList)2 ApprovalRequest (com.emc.storageos.db.client.model.uimodels.ApprovalRequest)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