Search in sources :

Example 1 with CreationStatus

use of org.ovirt.engine.api.model.CreationStatus in project ovirt-engine by oVirt.

the class AbstractBackendActionableResource method actionAsync.

protected Response actionAsync(ActionReturnValue actionResult, Action action) {
    action.setAsync(true);
    String ids = asString(actionResult.getVdsmTaskIdList());
    action.setId(ids);
    Current current = CurrentManager.get();
    String path = current.getRelativePath();
    action.setHref(path + "/" + ids);
    addOrUpdateLink(action, "parent", path.substring(0, path.lastIndexOf("/")));
    addOrUpdateLink(action, "replay", path);
    CreationStatus status = getAsynchronousStatus(actionResult);
    if (status != null) {
        action.setStatus(status.value());
    }
    return Response.status(ACCEPTED_STATUS).entity(action).build();
}
Also used : Current(org.ovirt.engine.api.restapi.invocation.Current) CreationStatus(org.ovirt.engine.api.model.CreationStatus)

Example 2 with CreationStatus

use of org.ovirt.engine.api.model.CreationStatus in project ovirt-engine by oVirt.

the class AbstractBackendResource method getVdsmTasksStatus.

private CreationStatus getVdsmTasksStatus(ActionReturnValue result) {
    CreationStatus asyncStatus = null;
    QueryReturnValue monitorResult = runQuery(QueryType.GetTasksStatusesByTasksIDs, new GetTasksStatusesByTasksIDsParameters(result.getVdsmTaskIdList()));
    if (monitorResult != null && monitorResult.getSucceeded() && monitorResult.getReturnValue() != null) {
        Mapper<AsyncTaskStatus, CreationStatus> mapper = getMapper(AsyncTaskStatus.class, CreationStatus.class);
        for (AsyncTaskStatus task : asCollection(AsyncTaskStatus.class, monitorResult.getReturnValue())) {
            asyncStatus = mapper.map(task, asyncStatus);
        }
    }
    return asyncStatus;
}
Also used : QueryReturnValue(org.ovirt.engine.core.common.queries.QueryReturnValue) AsyncTaskStatus(org.ovirt.engine.core.common.businessentities.AsyncTaskStatus) GetTasksStatusesByTasksIDsParameters(org.ovirt.engine.core.common.queries.GetTasksStatusesByTasksIDsParameters) CreationStatus(org.ovirt.engine.api.model.CreationStatus)

Example 3 with CreationStatus

use of org.ovirt.engine.api.model.CreationStatus in project ovirt-engine by oVirt.

the class AbstractBackendCollectionResource method handleAsynchrony.

protected void handleAsynchrony(ActionReturnValue result, R model) {
    CreationStatus status = getAsynchronousStatus(result);
    if (status != null) {
        model.setCreationStatus(status.value());
    }
    linkSubResource(model, CREATION_STATUS_REL, asString(result.getVdsmTaskIdList()));
}
Also used : CreationStatus(org.ovirt.engine.api.model.CreationStatus)

Example 4 with CreationStatus

use of org.ovirt.engine.api.model.CreationStatus in project ovirt-engine by oVirt.

the class CreationMapper method map.

@Mapping(from = List.class, to = Creation.class)
public static Creation map(List<AsyncTaskStatus> entity, Creation template) {
    Creation model = template != null ? template : new Creation();
    CreationStatus asyncStatus = null;
    for (AsyncTaskStatus task : entity) {
        asyncStatus = AsyncTaskMapper.map(task, asyncStatus);
    }
    model.setStatus(asyncStatus.value());
    if (asyncStatus == CreationStatus.FAILED) {
        model.setFault(new Fault());
        for (AsyncTaskStatus task : entity) {
            if (task.getException() != null) {
                model.getFault().setDetail(task.getException().toString());
                break;
            }
        }
    }
    return model;
}
Also used : Creation(org.ovirt.engine.api.model.Creation) AsyncTaskStatus(org.ovirt.engine.core.common.businessentities.AsyncTaskStatus) Fault(org.ovirt.engine.api.model.Fault) CreationStatus(org.ovirt.engine.api.model.CreationStatus)

Example 5 with CreationStatus

use of org.ovirt.engine.api.model.CreationStatus in project ovirt-engine by oVirt.

the class ActionMapper method map.

@Mapping(from = List.class, to = Action.class)
public static Action map(List<AsyncTaskStatus> entity, Action template) {
    Action model = template != null ? template : new Action();
    CreationStatus asyncStatus = null;
    for (AsyncTaskStatus task : entity) {
        asyncStatus = AsyncTaskMapper.map(task, asyncStatus);
    }
    model.setStatus(asyncStatus.value());
    if (asyncStatus == CreationStatus.FAILED) {
        model.setFault(new Fault());
        for (AsyncTaskStatus task : entity) {
            if (task.getException() != null) {
                model.getFault().setDetail(task.getException().toString());
                break;
            }
        }
    }
    return model;
}
Also used : Action(org.ovirt.engine.api.model.Action) AsyncTaskStatus(org.ovirt.engine.core.common.businessentities.AsyncTaskStatus) Fault(org.ovirt.engine.api.model.Fault) CreationStatus(org.ovirt.engine.api.model.CreationStatus)

Aggregations

CreationStatus (org.ovirt.engine.api.model.CreationStatus)5 AsyncTaskStatus (org.ovirt.engine.core.common.businessentities.AsyncTaskStatus)3 Fault (org.ovirt.engine.api.model.Fault)2 Action (org.ovirt.engine.api.model.Action)1 Creation (org.ovirt.engine.api.model.Creation)1 Current (org.ovirt.engine.api.restapi.invocation.Current)1 GetTasksStatusesByTasksIDsParameters (org.ovirt.engine.core.common.queries.GetTasksStatusesByTasksIDsParameters)1 QueryReturnValue (org.ovirt.engine.core.common.queries.QueryReturnValue)1