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;
}
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;
}
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;
}
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;
}
Aggregations