use of org.ovirt.engine.api.model.Fault in project ovirt-engine by oVirt.
the class EnumValidatorTest method verifyInvalidValueException.
private void verifyInvalidValueException(WebApplicationException wae, String value, String typeName) {
assertEquals(400, wae.getResponse().getStatus());
Fault fault = (Fault) wae.getResponse().getEntity();
assertNotNull(fault);
assertEquals("Invalid value", fault.getReason());
assertEquals(value + " is not a member of " + typeName + ". Possible values for State are: new, runnable, blocked, waiting, timed_waiting, terminated", fault.getDetail());
}
use of org.ovirt.engine.api.model.Fault in project ovirt-engine by oVirt.
the class BaseBackendResource method fault.
protected Fault fault(String reason, String detail) {
Fault fault = new Fault();
fault.setReason(reason);
fault.setDetail(detail);
return fault;
}
use of org.ovirt.engine.api.model.Fault in project ovirt-engine by oVirt.
the class BackendGlusterBricksResource method validateBrickNames.
private void validateBrickNames(Action action) {
List<GlusterBrick> bricks = action.getBricks().getGlusterBricks();
for (GlusterBrick brick : bricks) {
if (brick.getName() == null || brick.getName().equals("")) {
Fault fault = new Fault();
fault.setReason(localize(Messages.INCOMPLETE_PARAMS_REASON));
throw new WebApplicationException(Response.status(Response.Status.BAD_REQUEST).entity(fault).build());
}
}
}
use of org.ovirt.engine.api.model.Fault in project ovirt-engine by oVirt.
the class BackendVmResource method start.
@Override
public Response start(Action action) {
RunVmParams params;
ActionType actionType;
if (action.isSetVm()) {
Vm vm = action.getVm();
actionType = ActionType.RunVmOnce;
params = createRunVmOnceParams(vm, action.isSetVolatile() && action.isVolatile());
} else {
actionType = ActionType.RunVm;
params = new RunVmParams(guid);
}
if (action.isSetPause() && action.isPause()) {
params.setRunAndPause(true);
}
boolean useSysprep = action.isSetUseSysprep() && action.isUseSysprep();
boolean useCloudInit = action.isSetUseCloudInit() && action.isUseCloudInit();
if (useSysprep && useCloudInit) {
Fault fault = new Fault();
fault.setReason(localize(Messages.CANT_USE_SYSPREP_AND_CLOUD_INIT_SIMULTANEOUSLY));
return Response.status(Response.Status.CONFLICT).entity(fault).build();
}
if (useSysprep) {
params.setInitializationType(InitializationType.Sysprep);
} else if (useCloudInit) {
params.setInitializationType(InitializationType.CloudInit);
} else {
params.setInitializationType(InitializationType.None);
}
return doAction(actionType, params, action);
}
use of org.ovirt.engine.api.model.Fault in project ovirt-engine by oVirt.
the class BackendFilesResourceTest method testListFailure.
@Test
@Override
public void testListFailure() throws Exception {
UriInfo uriInfo = setUpUriExpectations(null);
setUpEntityQueryExpectations(QueryType.GetImagesList, GetImagesListParameters.class, new String[] { "StorageDomainId", "ImageType" }, new Object[] { GUIDS[0], ImageFileType.All }, setUpFiles(), AbstractBackendCollectionResourceTest.FAILURE);
setupGetStorageDomainExpectations(StorageDomainType.ISO);
collection.setUriInfo(uriInfo);
try {
getCollection();
fail("expected WebApplicationException");
} catch (WebApplicationException wae) {
assertTrue(wae.getResponse().getEntity() instanceof Fault);
assertEquals(mockl10n(FAILURE), ((Fault) wae.getResponse().getEntity()).getDetail());
}
}
Aggregations