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