Search in sources :

Example 1 with StepList

use of com.emc.storageos.model.workflow.StepList in project coprhd-controller by CoprHD.

the class WorkflowService method getStepList.

/**
 * Gets a list of all the steps in a particular workflow.
 *
 * @param id the URN of a ViPR workflow
 * @brief List workflow steps
 * @return List of steps of a workflow
 */
@GET
@Path("/{id}/steps")
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@CheckPermission(roles = { Role.SYSTEM_ADMIN, Role.RESTRICTED_SYSTEM_ADMIN, Role.SYSTEM_MONITOR, Role.TENANT_ADMIN })
public StepList getStepList(@PathParam("id") URI id) {
    ArgValidator.checkFieldUriType(id, Workflow.class, "id");
    Workflow workflow = queryResource(id);
    if (userIsOnlyTenantAdmin()) {
        // User is only tenant admin so only return steps for workflows for that tenant.
        if (!isTopLevelWorkflowForUserTenant(getTopLevelWorkflow(workflow))) {
            throw APIException.badRequests.userNotAuthorizedForWorkflow();
        }
    }
    StepList list = new StepList();
    URIQueryResultList stepURIs = new URIQueryResultList();
    _dbClient.queryByConstraint(ContainmentConstraint.Factory.getWorkflowWorkflowStepConstraint(id), stepURIs);
    Iterator<URI> iter = stepURIs.iterator();
    while (iter.hasNext()) {
        URI workflowStepURI = iter.next();
        WorkflowStep step = _dbClient.queryObject(WorkflowStep.class, workflowStepURI);
        list.getSteps().add(map(step, getChildWorkflows(step)));
    }
    return list;
}
Also used : WorkflowStep(com.emc.storageos.db.client.model.WorkflowStep) StepList(com.emc.storageos.model.workflow.StepList) Workflow(com.emc.storageos.db.client.model.Workflow) URI(java.net.URI) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET) CheckPermission(com.emc.storageos.security.authorization.CheckPermission)

Aggregations

URIQueryResultList (com.emc.storageos.db.client.constraint.URIQueryResultList)1 Workflow (com.emc.storageos.db.client.model.Workflow)1 WorkflowStep (com.emc.storageos.db.client.model.WorkflowStep)1 StepList (com.emc.storageos.model.workflow.StepList)1 CheckPermission (com.emc.storageos.security.authorization.CheckPermission)1 URI (java.net.URI)1 GET (javax.ws.rs.GET)1 Path (javax.ws.rs.Path)1 Produces (javax.ws.rs.Produces)1