Search in sources :

Example 1 with VirtualArrayBulkRep

use of com.emc.storageos.model.varray.VirtualArrayBulkRep in project coprhd-controller by CoprHD.

the class VirtualArrayService method queryFilteredBulkResourceReps.

@SuppressWarnings({ "unchecked", "rawtypes" })
@Override
protected VirtualArrayBulkRep queryFilteredBulkResourceReps(List<URI> ids) {
    if (isSystemOrRestrictedSystemAdmin()) {
        return queryBulkResourceReps(ids);
    }
    if (!ids.iterator().hasNext()) {
        return new VirtualArrayBulkRep();
    }
    // 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<VirtualArray> 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 arrays from vdc " + shortVdcId, ex);
            throw APIException.internalServerErrors.genericApisvcError("error retrieving remote array", ex);
        }
    }
    BulkList.ResourceFilter filter = new BulkList.VirtualArrayACLFilter(getUserFromContext(), _permissionsHelper);
    return new VirtualArrayBulkRep(BulkList.wrapping(dbIterator, MapVirtualArray.getInstance(), filter));
}
Also used : MapVirtualArray(com.emc.storageos.api.mapper.functions.MapVirtualArray) VirtualArray(com.emc.storageos.db.client.model.VirtualArray) GeoServiceClient(com.emc.storageos.security.geo.GeoServiceClient) BulkList(com.emc.storageos.api.service.impl.response.BulkList) VirtualArrayBulkRep(com.emc.storageos.model.varray.VirtualArrayBulkRep) APIException(com.emc.storageos.svcs.errorhandling.resources.APIException) DatabaseException(com.emc.storageos.db.exceptions.DatabaseException)

Example 2 with VirtualArrayBulkRep

use of com.emc.storageos.model.varray.VirtualArrayBulkRep in project coprhd-controller by CoprHD.

the class VirtualArrayService method queryBulkResourceReps.

@Override
public VirtualArrayBulkRep queryBulkResourceReps(List<URI> ids) {
    if (!ids.iterator().hasNext()) {
        return new VirtualArrayBulkRep();
    }
    // 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<VirtualArray> 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 arrays from vdc " + shortVdcId, ex);
            throw APIException.internalServerErrors.genericApisvcError("error retrieving remote array", ex);
        }
    }
    return new VirtualArrayBulkRep(BulkList.wrapping(dbIterator, MapVirtualArray.getInstance()));
}
Also used : MapVirtualArray(com.emc.storageos.api.mapper.functions.MapVirtualArray) VirtualArray(com.emc.storageos.db.client.model.VirtualArray) GeoServiceClient(com.emc.storageos.security.geo.GeoServiceClient) VirtualArrayBulkRep(com.emc.storageos.model.varray.VirtualArrayBulkRep) APIException(com.emc.storageos.svcs.errorhandling.resources.APIException) DatabaseException(com.emc.storageos.db.exceptions.DatabaseException)

Aggregations

MapVirtualArray (com.emc.storageos.api.mapper.functions.MapVirtualArray)2 VirtualArray (com.emc.storageos.db.client.model.VirtualArray)2 DatabaseException (com.emc.storageos.db.exceptions.DatabaseException)2 VirtualArrayBulkRep (com.emc.storageos.model.varray.VirtualArrayBulkRep)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