use of org.apache.openejb.jee.oejb2.QueryType in project midpoint by Evolveum.
the class TestOpenDj method test201SearchObjects.
@Test
public void test201SearchObjects() throws Exception {
final String TEST_NAME = "test201SearchObjects";
TestUtil.displayTestTile(TEST_NAME);
Task task = createTask(TEST_NAME);
OperationResult result = task.getResult();
ShadowType object = parseObjectType(ACCOUNT_SEARCH_FILE, ShadowType.class);
display("New object", object);
String addedObjectOid = provisioningService.addObject(object.asPrismObject(), null, null, taskManager.createTaskInstance(), result);
assertEquals(ACCOUNT_SEARCH_OID, addedObjectOid);
QueryType queryType = PrismTestUtil.parseAtomicValue(QUERY_ALL_ACCOUNTS_FILE, QueryType.COMPLEX_TYPE);
ObjectQuery query = QueryJaxbConvertor.createObjectQuery(ShadowType.class, queryType, prismContext);
rememberConnectorOperationCount();
rememberConnectorSimulatedPagingSearchCount();
// WHEN
SearchResultList<PrismObject<ShadowType>> searchResults = provisioningService.searchObjects(ShadowType.class, query, null, task, result);
// THEN
result.computeStatus();
assertSuccess(result);
display("Search resutls", searchResults);
assertEquals("Unexpected number of search results", 14, searchResults.size());
assertConnectorOperationIncrement(1, 29);
assertConnectorSimulatedPagingSearchIncrement(0);
}
use of org.apache.openejb.jee.oejb2.QueryType in project midpoint by Evolveum.
the class AbstractTestForExchangeConnector method searchRoleByName.
protected RoleType searchRoleByName(String roleName) throws SAXException, IOException, FaultMessage, JAXBException {
// WARNING: in a real case make sure that the role name is properly escaped before putting it in XML
SearchFilterType filter = ModelClientUtil.parseSearchFilterType("<equal xmlns='http://prism.evolveum.com/xml/ns/public/query-3' xmlns:c='http://midpoint.evolveum.com/xml/ns/public/common/common-3' >" + "<path>c:name</path>" + "<value>" + roleName + "</value>" + "</equal>");
QueryType query = new QueryType();
query.setFilter(filter);
SelectorQualifiedGetOptionsType options = new SelectorQualifiedGetOptionsType();
Holder<ObjectListType> objectListHolder = new Holder<ObjectListType>();
Holder<OperationResultType> resultHolder = new Holder<OperationResultType>();
modelPort.searchObjects(ModelClientUtil.getTypeQName(RoleType.class), query, options, objectListHolder, resultHolder);
ObjectListType objectList = objectListHolder.value;
List<ObjectType> objects = objectList.getObject();
if (objects.isEmpty()) {
return null;
}
if (objects.size() == 1) {
return (RoleType) objects.get(0);
}
throw new IllegalStateException("Expected to find a single role with name '" + roleName + "' but found " + objects.size() + " users instead");
}
use of org.apache.openejb.jee.oejb2.QueryType in project midpoint by Evolveum.
the class AbstractTestForExchangeConnector method searchUserByName.
protected UserType searchUserByName(String username) throws SAXException, IOException, FaultMessage, JAXBException {
// WARNING: in a real case make sure that the username is properly escaped before putting it in XML
SearchFilterType filter = ModelClientUtil.parseSearchFilterType("<equal xmlns='http://prism.evolveum.com/xml/ns/public/query-3' xmlns:c='http://midpoint.evolveum.com/xml/ns/public/common/common-3' >" + "<path>c:name</path>" + "<value>" + username + "</value>" + "</equal>");
QueryType query = new QueryType();
query.setFilter(filter);
SelectorQualifiedGetOptionsType options = new SelectorQualifiedGetOptionsType();
Holder<ObjectListType> objectListHolder = new Holder<ObjectListType>();
Holder<OperationResultType> resultHolder = new Holder<OperationResultType>();
modelPort.searchObjects(ModelClientUtil.getTypeQName(UserType.class), query, options, objectListHolder, resultHolder);
ObjectListType objectList = objectListHolder.value;
List<ObjectType> objects = objectList.getObject();
if (objects.isEmpty()) {
return null;
}
if (objects.size() == 1) {
return (UserType) objects.get(0);
}
throw new IllegalStateException("Expected to find a single user with username '" + username + "' but found " + objects.size() + " users instead");
}
use of org.apache.openejb.jee.oejb2.QueryType in project midpoint by Evolveum.
the class Main method listRequestableRoles.
private static Collection<RoleType> listRequestableRoles(ModelPortType modelPort) throws SAXException, IOException, FaultMessage, JAXBException {
SearchFilterType filter = ModelClientUtil.parseSearchFilterType("<equal xmlns='http://prism.evolveum.com/xml/ns/public/query-3' xmlns:c='http://midpoint.evolveum.com/xml/ns/public/common/common-3' >" + "<path>c:requestable</path>" + "<value>true</value>" + "</equal>");
QueryType query = new QueryType();
query.setFilter(filter);
SelectorQualifiedGetOptionsType options = new SelectorQualifiedGetOptionsType();
Holder<ObjectListType> objectListHolder = new Holder<ObjectListType>();
Holder<OperationResultType> resultHolder = new Holder<OperationResultType>();
modelPort.searchObjects(ModelClientUtil.getTypeQName(RoleType.class), query, options, objectListHolder, resultHolder);
ObjectListType objectList = objectListHolder.value;
return (Collection) objectList.getObject();
}
use of org.apache.openejb.jee.oejb2.QueryType in project midpoint by Evolveum.
the class Main method createUserQuery1.
private static QueryType createUserQuery1(String username) throws JAXBException, SAXException, IOException {
// WARNING: in a real case make sure that the username is properly escaped before putting it in XML
SearchFilterType filter = ModelClientUtil.parseSearchFilterType("<equal xmlns='http://prism.evolveum.com/xml/ns/public/query-3' xmlns:c='http://midpoint.evolveum.com/xml/ns/public/common/common-3' >" + "<path>c:name</path>" + "<value>" + username + "</value>" + "</equal>");
QueryType query = new QueryType();
query.setFilter(filter);
return query;
}
Aggregations