use of com.evolveum.midpoint.xml.ns._public.common.api_types_3.ObjectListType in project midpoint by Evolveum.
the class ModelWebServiceTest method badPagingSearch.
@Test(expectedExceptions = FaultMessage.class)
public void badPagingSearch() throws FaultMessage, SchemaException, IOException, JAXBException {
PagingType paging = new PagingType();
paging.setMaxSize(-1);
paging.setOffset(-1);
final UserType expectedUser = (UserType) PrismTestUtil.parseObject(new File(TEST_FOLDER_CONTROLLER, "./addObject/add-user-without-name.xml")).asObjectable();
setSecurityContext(expectedUser);
try {
QueryType queryType = new QueryType();
queryType.setPaging(paging);
modelService.searchObjects(UserType.COMPLEX_TYPE, queryType, null, new Holder<ObjectListType>(), new Holder<OperationResultType>());
} catch (FaultMessage ex) {
ModelTUtil.assertIllegalArgumentFault(ex);
} finally {
SecurityContextHolder.getContext().setAuthentication(null);
}
Assert.fail("Illegal argument exception was not thrown.");
}
use of com.evolveum.midpoint.xml.ns._public.common.api_types_3.ObjectListType in project midpoint by Evolveum.
the class ModelWebServiceTest method nullQueryTypeAndPaging.
// @Test(expectedExceptions = FaultMessage.class)
public void nullQueryTypeAndPaging() throws FaultMessage, SchemaException, IOException, JAXBException {
try {
final UserType expectedUser = (UserType) PrismTestUtil.parseObject(new File(TEST_FOLDER_CONTROLLER, "./addObject/add-user-without-name.xml")).asObjectable();
setSecurityContext(expectedUser);
modelService.searchObjects(UserType.COMPLEX_TYPE, null, null, new Holder<ObjectListType>(), new Holder<OperationResultType>());
Assert.fail("Illegal argument exception was not thrown.");
} catch (FaultMessage ex) {
ModelTUtil.assertIllegalArgumentFault(ex);
} finally {
SecurityContextHolder.getContext().setAuthentication(null);
}
}
use of com.evolveum.midpoint.xml.ns._public.common.api_types_3.ObjectListType in project midpoint by Evolveum.
the class ModelWebServiceTest method nullQueryType.
// @Test(expectedExceptions = FaultMessage.class)
// public void testDeleteNullOid() throws FaultMessage {
// try {
// modelService.deleteObject(UserType.COMPLEX_TYPE, null);
// } catch (FaultMessage ex) {
// ModelTUtil.assertIllegalArgumentFault(ex);
// }
// Assert.fail("delete must fail");
// }
// @Test(expectedExceptions = FaultMessage.class)
// public void testDeleteEmptyOid() throws FaultMessage {
// try {
// modelService.deleteObject(UserType.COMPLEX_TYPE, "");
// } catch (FaultMessage ex) {
// ModelTUtil.assertIllegalArgumentFault(ex);
// }
// Assert.fail("delete must fail");
// }
// @Test(expectedExceptions = FaultMessage.class)
// public void testDeleteNonExisting() throws FaultMessage, ObjectNotFoundException, SchemaException, JAXBException, FileNotFoundException {
// try {
// final String oid = "abababab-abab-abab-abab-000000000001";
// when(
// repositoryService.getObject(any(Class.class), eq(oid),
// any(Collection.class), any(OperationResult.class))).thenThrow(
// new ObjectNotFoundException("Object with oid '' not found."));
//
// final UserType user = PrismTestUtil.unmarshalObject(new File(
// TEST_FOLDER_CONTROLLER, "./addObject/add-user-without-name.xml"), UserType.class);
// setSecurityContext(user);
//
// modelService.deleteObject(UserType.COMPLEX_TYPE, oid);
// } catch (FaultMessage ex) {
// ModelTUtil.assertObjectNotFoundFault(ex);
// } finally {
// SecurityContextHolder.getContext().setAuthentication(null);
// }
// Assert.fail("delete must fail");
// }
// @Test(expectedExceptions = FaultMessage.class)
public void nullQueryType() throws FaultMessage, SchemaException, IOException, JAXBException {
try {
final UserType expectedUser = (UserType) PrismTestUtil.parseObject(new File(TEST_FOLDER_CONTROLLER, "./addObject/add-user-without-name.xml")).asObjectable();
setSecurityContext(expectedUser);
modelService.searchObjects(UserType.COMPLEX_TYPE, null, null, new Holder<ObjectListType>(), new Holder<OperationResultType>());
Assert.fail("Illegal argument exception was not thrown.");
} catch (FaultMessage ex) {
ModelTUtil.assertIllegalArgumentFault(ex);
} finally {
SecurityContextHolder.getContext().setAuthentication(null);
}
}
use of com.evolveum.midpoint.xml.ns._public.common.api_types_3.ObjectListType in project midpoint by Evolveum.
the class ModelRestService method searchObjectsByType.
@GET
@Path("/{type}")
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON, "application/yaml" })
public <T extends ObjectType> Response searchObjectsByType(@PathParam("type") String type, @QueryParam("options") List<String> options, @Context UriInfo uriInfo, @Context MessageContext mc) {
Task task = RestServiceUtil.initRequest(mc);
OperationResult parentResult = task.getResult().createSubresult(OPERATION_SEARCH_OBJECTS);
Class<T> clazz = ObjectTypes.getClassFromRestType(type);
Response response;
try {
Collection<SelectorOptions<GetOperationOptions>> searchOptions = GetOperationOptions.fromRestOptions(options, null, null);
List<PrismObject<T>> objects = model.searchObjects(clazz, null, searchOptions, task, parentResult);
ObjectListType listType = new ObjectListType();
if (objects != null) {
List<ObjectType> list = objects.stream().map(o -> convert(clazz, o, parentResult.createOperationResultType())).collect(Collectors.toList());
listType.getObject().addAll(list);
}
response = RestServiceUtil.createResponse(Response.Status.OK, listType, parentResult, true);
// response = Response.ok().entity(listType).build();
} catch (Exception ex) {
response = RestServiceUtil.handleException(parentResult, ex);
}
parentResult.computeStatus();
finishRequest(task);
return response;
}
use of com.evolveum.midpoint.xml.ns._public.common.api_types_3.ObjectListType in project midpoint by Evolveum.
the class ReportWebService method processReport.
@Override
public ObjectListType processReport(String query, RemoteReportParametersType parameters, SelectorQualifiedGetOptionsType options) {
try {
Map<QName, Object> parametersMap = getParamsMap(parameters);
ObjectQuery q = reportService.parseQuery(query, parametersMap);
Collection<PrismObject<? extends ObjectType>> resultList = reportService.searchObjects(q, MiscSchemaUtil.optionsTypeToOptions(options));
return createObjectListType(resultList);
} catch (SchemaException | ObjectNotFoundException | SecurityViolationException | CommunicationException | ConfigurationException | ExpressionEvaluationException e) {
// TODO Auto-generated catch block
throw new Fault(e);
}
}
Aggregations