Search in sources :

Example 1 with BlockVirtualPoolBulkRep

use of com.emc.storageos.model.vpool.BlockVirtualPoolBulkRep in project coprhd-controller by CoprHD.

the class BlockVirtualPoolService method queryFilteredBulkResourceReps.

@SuppressWarnings({ "unchecked", "rawtypes" })
@Override
protected BlockVirtualPoolBulkRep queryFilteredBulkResourceReps(List<URI> ids) {
    if (isSystemOrRestrictedSystemAdmin()) {
        return queryBulkResourceReps(ids);
    }
    if (!ids.iterator().hasNext()) {
        return new BlockVirtualPoolBulkRep();
    }
    // get vdc id from the first id; assume all id's are from the same vdc
    String shortVdcId = VdcUtil.getVdcId(getResourceClass(), ids.iterator().next()).toString();
    Iterator<VirtualPool> dbIterator;
    if (shortVdcId.equals(VdcUtil.getLocalShortVdcId())) {
        dbIterator = _dbClient.queryIterativeObjects(getResourceClass(), ids);
    } else {
        GeoServiceClient geoClient = _geoHelper.getClient(shortVdcId);
        try {
            dbIterator = geoClient.queryObjects(getResourceClass(), ids);
        } catch (Exception ex) {
            // TODO: revisit this exception
            _log.error("error retrieving bulk virtual pools from vdc " + shortVdcId, ex);
            throw APIException.internalServerErrors.genericApisvcError("error retrieving remote virtual pool", ex);
        }
    }
    BulkList.ResourceFilter filter = new BulkList.VirtualPoolFilter(Type.block, getUserFromContext(), _permissionsHelper);
    return new BlockVirtualPoolBulkRep(BulkList.wrapping(dbIterator, BLOCK_VPOOL_MAPPER, filter));
}
Also used : BlockVirtualPoolBulkRep(com.emc.storageos.model.vpool.BlockVirtualPoolBulkRep) GeoServiceClient(com.emc.storageos.security.geo.GeoServiceClient) BulkList(com.emc.storageos.api.service.impl.response.BulkList) VirtualPoolMapper.toBlockVirtualPool(com.emc.storageos.api.mapper.VirtualPoolMapper.toBlockVirtualPool) VirtualPool(com.emc.storageos.db.client.model.VirtualPool) APIException(com.emc.storageos.svcs.errorhandling.resources.APIException) DatabaseException(com.emc.storageos.db.exceptions.DatabaseException)

Example 2 with BlockVirtualPoolBulkRep

use of com.emc.storageos.model.vpool.BlockVirtualPoolBulkRep in project coprhd-controller by CoprHD.

the class BlockVirtualPoolService method queryBulkResourceReps.

@Override
public BlockVirtualPoolBulkRep queryBulkResourceReps(List<URI> ids) {
    if (!ids.iterator().hasNext()) {
        return new BlockVirtualPoolBulkRep();
    }
    // get vdc id from the first id; assume all id's are from the same vdc
    String shortVdcId = VdcUtil.getVdcId(getResourceClass(), ids.iterator().next()).toString();
    Iterator<VirtualPool> dbIterator;
    if (shortVdcId.equals(VdcUtil.getLocalShortVdcId())) {
        dbIterator = _dbClient.queryIterativeObjects(getResourceClass(), ids);
    } else {
        GeoServiceClient geoClient = _geoHelper.getClient(shortVdcId);
        try {
            dbIterator = geoClient.queryObjects(getResourceClass(), ids);
        } catch (Exception ex) {
            // TODO: revisit this exception
            _log.error("error retrieving bulk virtual pools from vdc " + shortVdcId, ex);
            throw APIException.internalServerErrors.genericApisvcError("error retrieving remote virtual pool", ex);
        }
    }
    return new BlockVirtualPoolBulkRep(BulkList.wrapping(dbIterator, BLOCK_VPOOL_MAPPER, new BulkList.VirtualPoolFilter(Type.block)));
}
Also used : BlockVirtualPoolBulkRep(com.emc.storageos.model.vpool.BlockVirtualPoolBulkRep) GeoServiceClient(com.emc.storageos.security.geo.GeoServiceClient) VirtualPoolMapper.toBlockVirtualPool(com.emc.storageos.api.mapper.VirtualPoolMapper.toBlockVirtualPool) VirtualPool(com.emc.storageos.db.client.model.VirtualPool) APIException(com.emc.storageos.svcs.errorhandling.resources.APIException) DatabaseException(com.emc.storageos.db.exceptions.DatabaseException)

Aggregations

VirtualPoolMapper.toBlockVirtualPool (com.emc.storageos.api.mapper.VirtualPoolMapper.toBlockVirtualPool)2 VirtualPool (com.emc.storageos.db.client.model.VirtualPool)2 DatabaseException (com.emc.storageos.db.exceptions.DatabaseException)2 BlockVirtualPoolBulkRep (com.emc.storageos.model.vpool.BlockVirtualPoolBulkRep)2 GeoServiceClient (com.emc.storageos.security.geo.GeoServiceClient)2 APIException (com.emc.storageos.svcs.errorhandling.resources.APIException)2 BulkList (com.emc.storageos.api.service.impl.response.BulkList)1