Search in sources :

Example 1 with MigrationList

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;
}
Also used : MigrationList(com.emc.storageos.model.block.MigrationList) Migration(com.emc.storageos.db.client.model.Migration) URI(java.net.URI) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET) CheckPermission(com.emc.storageos.security.authorization.CheckPermission)

Example 2 with 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;
}
Also used : MigrationList(com.emc.storageos.model.block.MigrationList) Migration(com.emc.storageos.db.client.model.Migration) URI(java.net.URI) NullColumnValueGetter.isNullURI(com.emc.storageos.db.client.util.NullColumnValueGetter.isNullURI) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET) SOURCE_TO_TARGET(com.emc.storageos.model.block.Copy.SyncDirection.SOURCE_TO_TARGET) CheckPermission(com.emc.storageos.security.authorization.CheckPermission)

Aggregations

Migration (com.emc.storageos.db.client.model.Migration)2 MigrationList (com.emc.storageos.model.block.MigrationList)2 CheckPermission (com.emc.storageos.security.authorization.CheckPermission)2 URI (java.net.URI)2 GET (javax.ws.rs.GET)2 Produces (javax.ws.rs.Produces)2 URIQueryResultList (com.emc.storageos.db.client.constraint.URIQueryResultList)1 NullColumnValueGetter.isNullURI (com.emc.storageos.db.client.util.NullColumnValueGetter.isNullURI)1 SOURCE_TO_TARGET (com.emc.storageos.model.block.Copy.SyncDirection.SOURCE_TO_TARGET)1 Path (javax.ws.rs.Path)1