use of com.emc.storageos.model.TaskResourceRep in project coprhd-controller by CoprHD.
the class CustomServicesViprExecution method waitForTask.
private Map<URI, String> waitForTask(final String result) throws Exception {
final List<URI> uris = new ArrayList<URI>();
final String classname = primitive.response();
if (classname.contains(RESTHelper.TASKLIST)) {
final ObjectMapper mapper = new ObjectMapper();
mapper.setAnnotationIntrospector(new JaxbAnnotationIntrospector());
final Class<?> clazz = Class.forName(classname);
final Object taskList = mapper.readValue(result, clazz.newInstance().getClass());
List<TaskResourceRep> resources = ((TaskList) taskList).getTaskList();
for (TaskResourceRep res : resources) {
uris.add(res.getId());
}
} else if (classname.contains(RESTHelper.TASK)) {
final ObjectMapper mapper = new ObjectMapper();
mapper.setAnnotationIntrospector(new JaxbAnnotationIntrospector());
final Class<?> clazz = Class.forName(classname);
final Object task = mapper.readValue(result, clazz.newInstance().getClass());
uris.add(((TaskResourceRep) task).getId());
}
if (!uris.isEmpty()) {
return CustomServicesUtils.waitForTasks(uris, getClient());
}
return null;
}
use of com.emc.storageos.model.TaskResourceRep in project coprhd-controller by CoprHD.
the class CallHomeServiceImpl method toTask.
private TaskResourceRep toTask(Task task) {
TaskResourceRep taskResourceRep = new TaskResourceRep();
taskResourceRep.setId(task.getId());
NamedURI resource = task.getResource();
NamedRelatedResourceRep namedRelatedResourceRep = new NamedRelatedResourceRep(resource.getURI(), new RestLinkRep("self", URI.create("/" + resource.getURI())), resource.getName());
taskResourceRep.setResource(namedRelatedResourceRep);
if (!StringUtils.isBlank(task.getRequestId())) {
taskResourceRep.setOpId(task.getRequestId());
}
// Operation
taskResourceRep.setState(task.getStatus());
if (task.getServiceCode() != null) {
taskResourceRep.setServiceError(toServiceErrorRestRep(toServiceCode(task.getServiceCode()), task.getMessage()));
} else {
taskResourceRep.setMessage(task.getMessage());
}
taskResourceRep.setDescription(task.getDescription());
taskResourceRep.setStartTime(task.getStartTime());
taskResourceRep.setEndTime(task.getEndTime());
taskResourceRep.setProgress(task.getProgress() != null ? task.getProgress() : 0);
taskResourceRep.setQueuedStartTime(task.getQueuedStartTime());
taskResourceRep.setQueueName(task.getQueueName());
return taskResourceRep;
}
use of com.emc.storageos.model.TaskResourceRep in project coprhd-controller by CoprHD.
the class TaskUtils method toTaskSummaries.
public static List<TaskSummary> toTaskSummaries(List<TaskResourceRep> tasks) {
List<TaskSummary> taskSummaries = Lists.newArrayList();
for (TaskResourceRep task : tasks) {
TaskSummary taskSummary = new TaskSummary(task);
taskSummary.progress = Math.max(taskSummary.progress, MINIMUM_TASK_PROGRESS);
taskSummaries.add(taskSummary);
}
return taskSummaries;
}
use of com.emc.storageos.model.TaskResourceRep in project coprhd-controller by CoprHD.
the class ObjectBuckets method create.
/**
* Begins create the bucket.
* <p>
* API Call: <tt>POST /object/buckets</tt>
*
* @param input
* the create configuration.
* @return a task for monitoring the progress of the operation.
*/
public Task<BucketRestRep> create(BucketParam input, URI project) {
URI uri = client.uriBuilder(baseUrl).queryParam("project", project).build();
TaskResourceRep task = client.postURI(TaskResourceRep.class, input, uri);
return new Task<>(client, task, resourceClass);
}
use of com.emc.storageos.model.TaskResourceRep in project coprhd-controller by CoprHD.
the class Tenants method createHost.
public Task<HostRestRep> createHost(URI tenantId, HostCreateParam input, boolean validateConnection) {
UriBuilder uriBuilder = client.uriBuilder(HOST_BY_TENANT_URL);
if (validateConnection) {
uriBuilder.queryParam(VALIDATE_CONNECTION_PARAM, Boolean.TRUE);
}
TaskResourceRep task = client.postURI(TaskResourceRep.class, input, uriBuilder.build(tenantId));
return new Task<HostRestRep>(client, task, HostRestRep.class);
}
Aggregations