use of com.emc.storageos.model.TaskResourceRep in project coprhd-controller by CoprHD.
the class Tasks method detailsJson.
public static void detailsJson(String taskId) {
if (StringUtils.isBlank(taskId)) {
notFound("Task [" + taskId + "]");
}
TaskResourceRep task = TaskUtils.getTask(uri(taskId));
if (task == null) {
notFound("Task [" + taskId + "]");
}
renderJSON(TaskUtils.getTaskSummary(task));
}
use of com.emc.storageos.model.TaskResourceRep in project coprhd-controller by CoprHD.
the class Tasks method listAllJson.
public static void listAllJson(Long lastUpdated, Boolean systemTasks) {
if (systemTasks == null) {
systemTasks = Boolean.FALSE;
}
if (systemTasks && Security.isSystemAdminOrRestrictedSystemAdmin() == false) {
forbidden();
}
Integer maxTasks = params.get("maxTasks", Integer.class);
if (maxTasks == null) {
maxTasks = 100;
}
if (maxTasks == 0) {
maxTasks = -1;
}
ViPRCoreClient client = getViprClient();
List<TaskResourceRep> taskResourceReps = null;
if (lastUpdated == null) {
if (systemTasks) {
taskResourceReps = client.tasks().getByRefs(client.tasks().listByTenant(SYSTEM_TENANT, maxTasks));
} else {
taskResourceReps = client.tasks().getByRefs(client.tasks().listByTenant(uri(Models.currentAdminTenant()), maxTasks));
}
} else {
taskResourceReps = taskPoll(lastUpdated, systemTasks, maxTasks);
}
Collections.sort(taskResourceReps, orderedTaskComparitor);
List<TasksDataTable.Task> tasks = Lists.newArrayList();
if (taskResourceReps != null) {
for (TaskResourceRep taskResourceRep : taskResourceReps) {
TasksDataTable.Task task = new TasksDataTable.Task(taskResourceRep);
if (Objects.equals(task.state, "pending") || Objects.equals(task.state, "queued")) {
task.progress = Math.max(task.progress, MINIMUM_TASK_PROGRESS);
}
tasks.add(task);
}
}
renderJSON(DataTablesSupport.createJSON(tasks, params));
}
use of com.emc.storageos.model.TaskResourceRep in project coprhd-controller by CoprHD.
the class Tasks method details.
public static void details(String taskId) {
if (StringUtils.isBlank(taskId)) {
listAll(false);
}
TaskResourceRep task = TaskUtils.getTask(uri(taskId));
if (task == null) {
flash.error(MessagesUtils.get(UNKNOWN, taskId));
listAll(false);
}
if (task != null && task.getResource() != null && task.getResource().getId() != null) {
ResourceType resourceType = ResourceType.fromResourceId(task.getResource().getId().toString());
renderArgs.put("resourceType", resourceType);
}
String orderId = TagUtils.getOrderIdTagValue(task);
String orderNumber = TagUtils.getOrderNumberTagValue(task);
Common.angularRenderArgs().put("task", TaskUtils.getTaskSummary(task));
TaskLogsDataTable dataTable = new TaskLogsDataTable();
render(task, dataTable, orderId, orderNumber);
}
use of com.emc.storageos.model.TaskResourceRep in project coprhd-controller by CoprHD.
the class FileProtectionPolicies method saveUnAssignPolicy.
@FlashException(keep = true, referrer = { "unassign" })
public static void saveUnAssignPolicy(AssignPolicyForm assignPolicy) {
if (assignPolicy == null) {
Logger.error("No Unassign policy parameters passed");
badRequest("No Unassign policy parameters passed");
return;
}
assignPolicy.validate("UnassignPolicy");
if (Validation.hasErrors()) {
Common.handleError();
}
assignPolicy.id = params.get("id");
FilePolicyUnAssignParam unAssignPolicyParam = new FilePolicyUnAssignParam();
try {
if (updateUnAssignPolicyParam(assignPolicy, unAssignPolicyParam)) {
TaskResourceRep taskRes = getViprClient().fileProtectionPolicies().unassignPolicy(uri(assignPolicy.id), unAssignPolicyParam);
if (isTaskSuccessful(assignPolicy.id, taskRes)) {
flash.success(MessagesUtils.get("unAssignPolicy.request.saved", assignPolicy.policyName));
}
}
} catch (Exception ex) {
flash.error(ex.getMessage(), assignPolicy.policyName);
}
if (StringUtils.isNotBlank(assignPolicy.referrerUrl)) {
redirect(assignPolicy.referrerUrl);
} else {
list();
}
}
use of com.emc.storageos.model.TaskResourceRep in project coprhd-controller by CoprHD.
the class BlockVolumes method deactivate.
/**
* Begins deactivating a block volume by ID.
* <p>
* API Call: <tt>POST /block/volumes/{id}/deactivate?type={deletionType}</tt>
*
* @param id
* the ID of the block volume to deactivate.
* @param deletionType
* {@code FULL} or {@code VIPR_ONLY}
* @return a task for monitoring the progress of the operation.
*
* @see com.emc.storageos.model.block.VolumeDeleteTypeEnum
*/
public Task<VolumeRestRep> deactivate(URI id, VolumeDeleteTypeEnum deletionType) {
URI uri = client.uriBuilder(getDeactivateUrl()).queryParam("type", deletionType).build(id);
TaskResourceRep task = client.postURI(TaskResourceRep.class, uri);
return new Task<>(client, task, resourceClass);
}
Aggregations