use of com.emc.storageos.model.block.MigrationList in project coprhd-controller by CoprHD.
the class MigrationService method getMigrations.
/**
* Returns a list of the migrations the user is permitted to see or an empty
* list if the user is not authorized for any migrations.
*
* @prereq none
*
* @brief List migrations
* @return A MigrationList specifying the name, id, and self link for each
* migration.
*/
@GET
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@CheckPermission(roles = { Role.TENANT_ADMIN, Role.SYSTEM_ADMIN, Role.SYSTEM_MONITOR })
public MigrationList getMigrations() {
// Return the migrations the user is authorized to see.
MigrationList migrationList = new MigrationList();
List<URI> migrationURIs = _dbClient.queryByType(Migration.class, true);
Iterator<URI> uriIter = migrationURIs.iterator();
while (uriIter.hasNext()) {
Migration migration = queryResource(uriIter.next());
if (BulkList.MigrationFilter.isUserAuthorizedForMigration(migration, getUserFromContext(), _permissionsHelper)) {
migrationList.getMigrations().add(toNamedRelatedResource(migration, migration.getLabel()));
}
}
return migrationList;
}
use of com.emc.storageos.model.block.MigrationList in project coprhd-controller by CoprHD.
the class BlockService method getVolumeMigrations.
/**
* Returns a list of the migrations associated with the volume identified by
* the id specified in the request.
*
* @prereq none
*
* @param id
* the URN of a ViPR volume.
*
* @brief Show volume migrations
* @return A list specifying the id, name, and self link of the migrations
* associated with the volume
*/
@GET
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Path("/{id}/migrations")
@CheckPermission(roles = { Role.SYSTEM_ADMIN, Role.SYSTEM_MONITOR, Role.TENANT_ADMIN })
public MigrationList getVolumeMigrations(@PathParam("id") URI id) {
ArgValidator.checkFieldUriType(id, Volume.class, "id");
MigrationList volumeMigrations = new MigrationList();
URIQueryResultList migrationURIs = new URIQueryResultList();
_dbClient.queryByConstraint(ContainmentConstraint.Factory.getMigrationVolumeConstraint(id), migrationURIs);
Iterator<URI> migrationURIsIter = migrationURIs.iterator();
while (migrationURIsIter.hasNext()) {
URI migrationURI = migrationURIsIter.next();
Migration migration = _permissionsHelper.getObjectById(migrationURI, Migration.class);
if (BulkList.MigrationFilter.isUserAuthorizedForMigration(migration, getUserFromContext(), _permissionsHelper)) {
volumeMigrations.getMigrations().add(toNamedRelatedResource(migration, migration.getLabel()));
}
}
return volumeMigrations;
}
Aggregations