Search in sources :

Example 86 with TaskResourceRep

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;
}
Also used : TaskList(com.emc.storageos.model.TaskList) ArrayList(java.util.ArrayList) TaskResourceRep(com.emc.storageos.model.TaskResourceRep) URI(java.net.URI) ObjectMapper(org.codehaus.jackson.map.ObjectMapper) JaxbAnnotationIntrospector(org.codehaus.jackson.xc.JaxbAnnotationIntrospector)

Example 87 with TaskResourceRep

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;
}
Also used : NamedURI(com.emc.storageos.db.client.model.NamedURI) RestLinkRep(com.emc.storageos.model.RestLinkRep) TaskResourceRep(com.emc.storageos.model.TaskResourceRep) NamedRelatedResourceRep(com.emc.storageos.model.NamedRelatedResourceRep)

Example 88 with 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;
}
Also used : TaskResourceRep(com.emc.storageos.model.TaskResourceRep)

Example 89 with TaskResourceRep

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);
}
Also used : Task(com.emc.vipr.client.Task) TaskResourceRep(com.emc.storageos.model.TaskResourceRep) URI(java.net.URI)

Example 90 with TaskResourceRep

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);
}
Also used : Task(com.emc.vipr.client.Task) TaskResourceRep(com.emc.storageos.model.TaskResourceRep) UriBuilder(javax.ws.rs.core.UriBuilder)

Aggregations

TaskResourceRep (com.emc.storageos.model.TaskResourceRep)160 URI (java.net.URI)85 TaskList (com.emc.storageos.model.TaskList)82 Operation (com.emc.storageos.db.client.model.Operation)68 Produces (javax.ws.rs.Produces)59 ArrayList (java.util.ArrayList)56 Volume (com.emc.storageos.db.client.model.Volume)55 Path (javax.ws.rs.Path)54 CheckPermission (com.emc.storageos.security.authorization.CheckPermission)53 POST (javax.ws.rs.POST)50 InternalException (com.emc.storageos.svcs.errorhandling.resources.InternalException)49 Consumes (javax.ws.rs.Consumes)36 APIException (com.emc.storageos.svcs.errorhandling.resources.APIException)35 StorageSystem (com.emc.storageos.db.client.model.StorageSystem)32 NamedURI (com.emc.storageos.db.client.model.NamedURI)30 NullColumnValueGetter.isNullURI (com.emc.storageos.db.client.util.NullColumnValueGetter.isNullURI)23 Project (com.emc.storageos.db.client.model.Project)20 URIQueryResultList (com.emc.storageos.db.client.constraint.URIQueryResultList)18 VirtualPool (com.emc.storageos.db.client.model.VirtualPool)17 Copy (com.emc.storageos.model.block.Copy)17