Search in sources :

Example 1 with WorkflowList

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

the class WorkflowService method getRecentWorkflows.

/**
 * Returns workflows created in the last specified number of minutes.
 *
 * @brief List workflows created in specified time period
 */
@GET
@Path("/recent")
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@CheckPermission(roles = { Role.SYSTEM_ADMIN, Role.RESTRICTED_SYSTEM_ADMIN, Role.SYSTEM_MONITOR, Role.TENANT_ADMIN })
public WorkflowList getRecentWorkflows(@QueryParam("min") String minutes) {
    if (minutes == null) {
        minutes = "10";
    }
    Long timeDiff = new Long(minutes) * 1000 * 60;
    Long currentTime = System.currentTimeMillis();
    WorkflowList list = new WorkflowList();
    List<URI> workflowIds = _dbClient.queryByType(Workflow.class, true);
    Iterator<Workflow> workflowIter = _dbClient.queryIterativeObjects(Workflow.class, workflowIds);
    while (workflowIter.hasNext()) {
        // A user that has one of the system roles can see any workflow.
        // Otherwise, the workflow must have the same tenant as the user.
        Workflow workflow = workflowIter.next();
        if (userIsOnlyTenantAdmin()) {
            // User is only tenant admin so only return workflows for that tenant.
            if (!isTopLevelWorkflowForUserTenant(getTopLevelWorkflow(workflow))) {
                continue;
            }
        }
        if ((currentTime - workflow.getCreationTime().getTimeInMillis()) < timeDiff) {
            list.getWorkflows().add(map(workflow));
        }
    }
    return list;
}
Also used : WorkflowList(com.emc.storageos.model.workflow.WorkflowList) Workflow(com.emc.storageos.db.client.model.Workflow) URI(java.net.URI) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET) CheckPermission(com.emc.storageos.security.authorization.CheckPermission)

Example 2 with WorkflowList

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

the class WorkflowService method getCompletedWorkflows.

/**
 * Returns the completed workflows.
 *
 * @brief List completed workflows
 */
@GET
@Path("/completed")
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@CheckPermission(roles = { Role.SYSTEM_ADMIN, Role.RESTRICTED_SYSTEM_ADMIN, Role.SYSTEM_MONITOR, Role.TENANT_ADMIN })
public WorkflowList getCompletedWorkflows() {
    WorkflowList list = new WorkflowList();
    List<URI> workflowIds = _dbClient.queryByType(Workflow.class, true);
    Iterator<Workflow> workflowIter = _dbClient.queryIterativeObjects(Workflow.class, workflowIds);
    while (workflowIter.hasNext()) {
        // A user that has one of the system roles can see any workflow.
        // Otherwise, the workflow must have the same tenant as the user.
        Workflow workflow = workflowIter.next();
        if (userIsOnlyTenantAdmin()) {
            // User is only tenant admin so only return workflows for that tenant.
            if (!isTopLevelWorkflowForUserTenant(getTopLevelWorkflow(workflow))) {
                continue;
            }
        }
        if (workflow.getCompleted() == true) {
            list.getWorkflows().add(map(workflow));
        }
    }
    return list;
}
Also used : WorkflowList(com.emc.storageos.model.workflow.WorkflowList) Workflow(com.emc.storageos.db.client.model.Workflow) URI(java.net.URI) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET) CheckPermission(com.emc.storageos.security.authorization.CheckPermission)

Example 3 with WorkflowList

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

the class WorkflowService method getWorkflows.

/**
 * Returns a list of all Workflows.
 *
 * @brief List all workflows
 * @return WorkflowList
 */
@GET
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@CheckPermission(roles = { Role.SYSTEM_ADMIN, Role.RESTRICTED_SYSTEM_ADMIN, Role.SYSTEM_MONITOR, Role.TENANT_ADMIN })
public WorkflowList getWorkflows() {
    WorkflowList list = new WorkflowList();
    List<URI> workflowIds = _dbClient.queryByType(Workflow.class, true);
    Iterator<Workflow> workflowIter = _dbClient.queryIterativeObjects(Workflow.class, workflowIds);
    while (workflowIter.hasNext()) {
        // A user that has one of the system roles can see any workflow.
        // Otherwise, the workflow must have the same tenant as the user.
        Workflow workflow = workflowIter.next();
        if (userIsOnlyTenantAdmin()) {
            // User is only tenant admin so only return workflows for that tenant.
            if (!isTopLevelWorkflowForUserTenant(getTopLevelWorkflow(workflow))) {
                continue;
            }
        }
        list.getWorkflows().add(map(workflow));
    }
    return list;
}
Also used : WorkflowList(com.emc.storageos.model.workflow.WorkflowList) Workflow(com.emc.storageos.db.client.model.Workflow) URI(java.net.URI) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET) CheckPermission(com.emc.storageos.security.authorization.CheckPermission)

Example 4 with WorkflowList

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

the class WorkflowService method getActiveWorkflows.

/**
 * Returns the active workflows.
 *
 * @brief List active workflows
 */
@GET
@Path("/active")
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@CheckPermission(roles = { Role.SYSTEM_ADMIN, Role.RESTRICTED_SYSTEM_ADMIN, Role.SYSTEM_MONITOR, Role.TENANT_ADMIN })
public WorkflowList getActiveWorkflows() {
    WorkflowList list = new WorkflowList();
    List<URI> workflowIds = _dbClient.queryByType(Workflow.class, true);
    Iterator<Workflow> workflowIter = _dbClient.queryIterativeObjects(Workflow.class, workflowIds);
    while (workflowIter.hasNext()) {
        // A user that has one of the system roles can see any workflow.
        // Otherwise, the workflow must have the same tenant as the user.
        Workflow workflow = workflowIter.next();
        if (userIsOnlyTenantAdmin()) {
            // User is only tenant admin so only return workflows for that tenant.
            if (!isTopLevelWorkflowForUserTenant(getTopLevelWorkflow(workflow))) {
                continue;
            }
        }
        if (workflow.getCompleted() == false) {
            list.getWorkflows().add(map(workflow));
        }
    }
    return list;
}
Also used : WorkflowList(com.emc.storageos.model.workflow.WorkflowList) Workflow(com.emc.storageos.db.client.model.Workflow) URI(java.net.URI) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET) CheckPermission(com.emc.storageos.security.authorization.CheckPermission)

Aggregations

Workflow (com.emc.storageos.db.client.model.Workflow)4 WorkflowList (com.emc.storageos.model.workflow.WorkflowList)4 CheckPermission (com.emc.storageos.security.authorization.CheckPermission)4 URI (java.net.URI)4 GET (javax.ws.rs.GET)4 Produces (javax.ws.rs.Produces)4 Path (javax.ws.rs.Path)3