protected Response actionSuccess(Action action) { action.setStatus(CreationStatus.COMPLETE.value()); return Response.ok().entity(action).build(); }
private Response actionSuccess(Action action, Object result) { setActionItem(action, result); action.setStatus(CreationStatus.COMPLETE.value()); return Response.ok().entity(action).build(); }
protected Response actionStatus(CreationStatus status, Action action, Object result) { setActionItem(action, result); action.setStatus(status.value()); return Response.ok().entity(action).build(); }
protected Response actionFailure(Action action, WebApplicationException wae) { action.setStatus(CreationStatus.FAILED.value()); return Response.fromResponse(wae.getResponse()).entity(action).build(); }
protected Response performNonBlockingAction(ActionType task, ActionParametersBase params, Action action) { try { doNonBlockingAction(task, params); if (action!=null) { action.setStatus(CreationStatus.IN_PROGRESS.value()); return Response.status(Response.Status.ACCEPTED).entity(action).build(); } else { return Response.status(Response.Status.ACCEPTED).build(); } } catch (Exception e) { return handleError(Response.class, e, false); } }
private Response handleFailure(Action action, String message) { action.setStatus(CreationStatus.FAILED.value()); action.setFault(new Fault()); action.getFault().setReason(message); return Response.ok().entity(action).build(); }
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(); }
protected Response performAction(ActionType task, ActionParametersBase params, Action action, boolean getEntityWhenDone) { try { if (isAsync() || expectNonBlocking()) { return performNonBlockingAction(task, params, action); } else { ActionReturnValue actionResult = doAction(task, params); if (action == null) { action = new Action(); } if (actionResult.getJobId() != null) { setJobLink(action, actionResult); } action.setStatus(CreationStatus.COMPLETE.value()); if (getEntityWhenDone) { setActionItem(action, getEntity()); } return Response.ok().entity(action).build(); } } catch (Exception e) { return handleError(Response.class, e, false); } }
@Override public Response isAttached(Action action) { validateParameters(action, "host.id|name"); Guid hostId = getHostId(action); org.ovirt.engine.core.common.businessentities.StorageDomain storageDomainToAttach = getEntity( org.ovirt.engine.core.common.businessentities.StorageDomain.class, QueryType.GetStorageDomainById, new IdQueryParameters(guid), guid.toString() ); StorageDomainsAndStoragePoolIdQueryParameters parameters = new StorageDomainsAndStoragePoolIdQueryParameters(storageDomainToAttach, null, hostId); parameters.setCheckStoragePoolStatus(false); List<StorageDomainStatic> attachedStorageDomains = getEntity( List.class, QueryType.GetStorageDomainsWithAttachedStoragePoolGuid, parameters, guid.toString(), true ); // This is an atypical action, as it doesn't invoke a backend action, but a query. As a result we need to // create and populate the returned action object so that it looks like a real action result. Action result = new Action(); result.setIsAttached(!attachedStorageDomains.isEmpty()); result.setStatus(CreationStatus.COMPLETE.value()); return Response.ok().entity(result).build(); }
@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; } }
to.setStatus(from.getStatus().getState());