Search in sources :

Example 31 with CheckPermission

use of com.emc.storageos.security.authorization.CheckPermission in project coprhd-controller by CoprHD.

the class StorageSystemService method getStorageSystems.

/**
 * Gets the id, name, and self link for all registered storage systems.
 *
 * @brief List storage systems
 * @return A reference to a StorageSystemList.
 */
@GET
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@CheckPermission(roles = { Role.SYSTEM_ADMIN, Role.SYSTEM_MONITOR })
public StorageSystemList getStorageSystems() {
    StorageSystemList systemsList = new StorageSystemList();
    List<URI> ids = _dbClient.queryByType(StorageSystem.class, true);
    Iterator<StorageSystem> iter = _dbClient.queryIterativeObjects(StorageSystem.class, ids);
    while (iter.hasNext()) {
        systemsList.getStorageSystems().add(toNamedRelatedResource(iter.next()));
    }
    return systemsList;
}
Also used : StorageSystemList(com.emc.storageos.model.systems.StorageSystemList) URI(java.net.URI) StorageSystem(com.emc.storageos.db.client.model.StorageSystem) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET) CheckPermission(com.emc.storageos.security.authorization.CheckPermission)

Example 32 with CheckPermission

use of com.emc.storageos.security.authorization.CheckPermission in project coprhd-controller by CoprHD.

the class StorageSystemService method getStorageSystem.

/**
 * Get information about the registered storage system with the passed id.
 *
 * @param id the URN of a ViPR storage system.
 *
 * @brief Show storage system
 * @return A reference to a StorageSystemRestRep
 */
@GET
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Path("/{id}")
@CheckPermission(roles = { Role.SYSTEM_ADMIN, Role.SYSTEM_MONITOR })
public StorageSystemRestRep getStorageSystem(@PathParam("id") URI id) {
    ArgValidator.checkFieldUriType(id, StorageSystem.class, "id");
    StorageSystem system = queryResource(id);
    StorageSystemRestRep restRep = map(system);
    restRep.setNumResources(getNumResources(system, _dbClient));
    return restRep;
}
Also used : StorageSystemRestRep(com.emc.storageos.model.systems.StorageSystemRestRep) StorageSystem(com.emc.storageos.db.client.model.StorageSystem) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET) CheckPermission(com.emc.storageos.security.authorization.CheckPermission)

Example 33 with CheckPermission

use of com.emc.storageos.security.authorization.CheckPermission in project coprhd-controller by CoprHD.

the class TaskService method resumeTask.

/**
 * Resumes a task. This can only be performed on a Task that has status of: suspended_no_error
 * Retries a task. This can only be performed on a Task that has status of: suspended_error
 *
 * In the case of retry, we will retry the controller workflow starting at the failed step.
 *
 * @brief Resumes a task
 * @param taskId
 *            ID of the task to be resumed
 */
@POST
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Path("/{taskId}/resume")
@CheckPermission(roles = { Role.TENANT_ADMIN, Role.SYSTEM_ADMIN, Role.RESTRICTED_SYSTEM_ADMIN }, acls = { ACL.OWN, ACL.ALL })
public Response resumeTask(@PathParam("taskId") URI taskId) {
    Task task = queryResource(taskId);
    // Permission Check
    if (task.getTenant().equals(TenantOrg.SYSTEM_TENANT)) {
        verifySystemAdmin();
    } else {
        verifyUserHasAccessToTenants(Lists.newArrayList(task.getTenant()));
    }
    Workflow workflow = validateWorkflow(task);
    String opId = UUID.randomUUID().toString();
    // Resume the workflow
    WorkflowService.initTaskStatus(_dbClient, workflow, opId, Operation.Status.pending, ResourceOperationTypeEnum.WORKFLOW_RESUME);
    getWorkflowController().resumeWorkflow(workflow.getId(), opId);
    return Response.ok().build();
}
Also used : Task(com.emc.storageos.db.client.model.Task) MapTask(com.emc.storageos.api.mapper.functions.MapTask) Workflow(com.emc.storageos.db.client.model.Workflow) Path(javax.ws.rs.Path) POST(javax.ws.rs.POST) Produces(javax.ws.rs.Produces) CheckPermission(com.emc.storageos.security.authorization.CheckPermission)

Example 34 with CheckPermission

use of com.emc.storageos.security.authorization.CheckPermission in project coprhd-controller by CoprHD.

the class TaskService method deleteTask.

/**
 * Deletes the specified task. After this operation has been called, the task will no longer be accessible.
 *
 * @brief Deletes a task
 * @param taskId
 *            ID of the task to be deleted
 */
@POST
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Path("/{taskId}/delete")
@CheckPermission(roles = { Role.SYSTEM_ADMIN, Role.RESTRICTED_SYSTEM_ADMIN }, acls = { ACL.OWN })
public Response deleteTask(@PathParam("taskId") URI taskId) {
    Task task = queryResource(taskId);
    // Permission Check
    if (task.getTenant().equals(TenantOrg.SYSTEM_TENANT)) {
        verifySystemAdmin();
    } else {
        verifyUserHasAccessToTenants(Lists.newArrayList(task.getTenant()));
    }
    _dbClient.removeObject(task);
    auditOp(OperationTypeEnum.DELETE_TASK, true, null, task.getId().toString(), task.getLabel());
    return Response.ok().build();
}
Also used : Task(com.emc.storageos.db.client.model.Task) MapTask(com.emc.storageos.api.mapper.functions.MapTask) Path(javax.ws.rs.Path) POST(javax.ws.rs.POST) Produces(javax.ws.rs.Produces) CheckPermission(com.emc.storageos.security.authorization.CheckPermission)

Example 35 with CheckPermission

use of com.emc.storageos.security.authorization.CheckPermission in project coprhd-controller by CoprHD.

the class TenantsService method createHost.

/**
 * Creates a new host for the tenant organization. Discovery is initiated
 * after the host is created.
 * <p>
 * This method is deprecated. Use /compute/hosts instead
 *
 * @param tid
 *            the tenant organization id
 * @param createParam
 *            the parameter that has the type and attribute of the host to be created.
 * @prereq none
 * @deprecated use {@link HostService#createHost(HostCreateParam,Boolean)}
 * @brief Create tenant host
 * @return the host discovery async task representation.
 */
@POST
@Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@CheckPermission(roles = { Role.TENANT_ADMIN })
@Path("/{id}/hosts")
@Deprecated
public TaskResourceRep createHost(@PathParam("id") URI tid, HostCreateParam createParam, @QueryParam("validate_connection") @DefaultValue("false") final Boolean validateConnection) {
    // This is mostly to validate the tenant
    TenantOrg tenant = getTenantById(tid, true);
    HostService hostService = _hostService;
    hostService.validateHostData(createParam, tid, null, validateConnection);
    // Create the host
    return hostService.createNewHost(tenant, createParam);
}
Also used : TenantOrg(com.emc.storageos.db.client.model.TenantOrg) Path(javax.ws.rs.Path) POST(javax.ws.rs.POST) Consumes(javax.ws.rs.Consumes) Produces(javax.ws.rs.Produces) CheckPermission(com.emc.storageos.security.authorization.CheckPermission)

Aggregations

CheckPermission (com.emc.storageos.security.authorization.CheckPermission)566 Produces (javax.ws.rs.Produces)512 Path (javax.ws.rs.Path)487 POST (javax.ws.rs.POST)240 Consumes (javax.ws.rs.Consumes)215 GET (javax.ws.rs.GET)194 URI (java.net.URI)185 Operation (com.emc.storageos.db.client.model.Operation)105 ArrayList (java.util.ArrayList)97 StorageSystem (com.emc.storageos.db.client.model.StorageSystem)93 PUT (javax.ws.rs.PUT)85 APIException (com.emc.storageos.svcs.errorhandling.resources.APIException)69 Volume (com.emc.storageos.db.client.model.Volume)68 URIQueryResultList (com.emc.storageos.db.client.constraint.URIQueryResultList)65 TaskList (com.emc.storageos.model.TaskList)61 FileShare (com.emc.storageos.db.client.model.FileShare)56 SMBFileShare (com.emc.storageos.db.client.model.SMBFileShare)54 TaskResourceRep (com.emc.storageos.model.TaskResourceRep)53 NamedURI (com.emc.storageos.db.client.model.NamedURI)47 InternalException (com.emc.storageos.svcs.errorhandling.resources.InternalException)46