use of com.evolveum.midpoint.xml.ns._public.common.api_types_3.ObjectListType in project midpoint by Evolveum.
the class TestSanityLegacy method test480ListResources.
@Test
public void test480ListResources() throws Exception {
final String TEST_NAME = "test480ListResources";
TestUtil.displayTestTile(TEST_NAME);
// GIVEN
OperationResultType result = new OperationResultType();
Holder<OperationResultType> resultHolder = new Holder<OperationResultType>(result);
Holder<ObjectListType> objectListHolder = new Holder<ObjectListType>();
SelectorQualifiedGetOptionsType options = new SelectorQualifiedGetOptionsType();
// WHEN
modelWeb.searchObjects(ObjectTypes.RESOURCE.getTypeQName(), null, options, objectListHolder, resultHolder);
// THEN
display("Resources", objectListHolder.value);
assertEquals("Unexpected number of resources", 3, objectListHolder.value.getObject().size());
for (ObjectType object : objectListHolder.value.getObject()) {
// Marshalling may fail even though the Java object is OK so test for it
String xml = prismContext.serializeObjectToString(object.asPrismObject(), PrismContext.LANG_XML);
}
}
use of com.evolveum.midpoint.xml.ns._public.common.api_types_3.ObjectListType in project midpoint by Evolveum.
the class TestWSSanity method test015SearchLdapConnector.
// TODO: fetch&parse schema http://..?WSDL
@Test
public void test015SearchLdapConnector() throws Exception {
final String TEST_NAME = "test015SearchLdapConnector";
displayTestTitle(TEST_NAME);
QueryType query = new QueryType();
query.setFilter(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:connectorType</path>" + "<value>" + CONNECTOR_LDAP_TYPE + "</value>" + "</equal>"));
Holder<ObjectListType> objectListHolder = new Holder<>();
Holder<OperationResultType> resultHolder = new Holder<>();
// WHEN
modelPort.searchObjects(ModelClientUtil.getTypeQName(ConnectorType.class), query, null, objectListHolder, resultHolder);
// THEN
assertSuccess(resultHolder);
ObjectListType objectList = objectListHolder.value;
assertEquals("Unexpected number of LDAP connectors", 1, objectList.getObject().size());
ConnectorType ldapConnector = (ConnectorType) objectList.getObject().get(0);
assertNotNull("Null LDAP connector", ldapConnector);
connectorLdapOid = ldapConnector.getOid();
assertNotNull("Null LDAP connector OID", connectorLdapOid);
}
use of com.evolveum.midpoint.xml.ns._public.common.api_types_3.ObjectListType in project midpoint by Evolveum.
the class ReportWebService method createObjectListType.
private ObjectListType createObjectListType(Collection resultList) {
if (resultList == null) {
return new ObjectListType();
}
ObjectListType results = new ObjectListType();
int skipped = 0;
for (Object object : resultList) {
if (object instanceof PrismObject) {
results.getObject().add(((PrismObject<ObjectType>) object).asObjectable());
} else if (object instanceof ObjectType) {
results.getObject().add((ObjectType) object);
} else {
skipped++;
}
}
if (skipped > 0) {
LOGGER.warn("{} non-PrismObject data objects not returned, as these are not supported by ReportWebService yet", skipped);
}
return results;
}
use of com.evolveum.midpoint.xml.ns._public.common.api_types_3.ObjectListType in project midpoint by Evolveum.
the class ReportWebServiceRaw method invokeAllowingFaults.
public DOMSource invokeAllowingFaults(DOMSource request) throws FaultMessage {
Node rootNode = request.getNode();
Element rootElement;
if (rootNode instanceof Document) {
rootElement = ((Document) rootNode).getDocumentElement();
} else if (rootNode instanceof Element) {
rootElement = (Element) rootNode;
} else {
// throw ws.createIllegalArgumentFault("Unexpected DOM node type: " + rootNode);
throw new FaultMessage("Unexpected DOM node type: " + rootNode);
}
Object requestObject;
try {
requestObject = prismContext.parserFor(rootElement).parseRealValue();
} catch (SchemaException e) {
throw new FaultMessage("Couldn't parse SOAP request body because of schema exception: " + e.getMessage());
// throw ws.createIllegalArgumentFault("Couldn't parse SOAP request body because of schema exception: " + e.getMessage());
}
Node response;
Holder<OperationResultType> operationResultTypeHolder = new Holder<>();
SerializationContext ctx = new SerializationContext(SerializationOptions.createSerializeReferenceNames());
try {
if (requestObject instanceof EvaluateScriptType) {
EvaluateScriptType s = (EvaluateScriptType) requestObject;
ObjectListType olt = reportService.evaluateScript(s.getScript(), s.getParameters());
EvaluateScriptResponseType sr = new EvaluateScriptResponseType();
sr.setObjectList(olt);
response = prismContext.domSerializer().context(ctx).serializeAnyData(sr, ReportPort.EVALUATE_SCRIPT_RESPONSE);
} else if (requestObject instanceof EvaluateAuditScriptType) {
EvaluateAuditScriptType s = (EvaluateAuditScriptType) requestObject;
AuditEventRecordListType olt = reportService.evaluateAuditScript(s.getScript(), s.getParameters());
EvaluateAuditScriptResponseType sr = new EvaluateAuditScriptResponseType();
sr.setObjectList(olt);
response = prismContext.domSerializer().context(ctx).serializeAnyData(sr, ReportPort.EVALUATE_AUDIT_SCRIPT_RESPONSE);
} else if (requestObject instanceof ProcessReportType) {
ProcessReportType p = (ProcessReportType) requestObject;
ObjectListType olt = reportService.processReport(p.getQuery(), p.getParameters(), p.getOptions());
ProcessReportResponseType pr = new ProcessReportResponseType();
pr.setObjectList(olt);
response = prismContext.domSerializer().context(ctx).serializeAnyData(pr, ReportPort.PROCESS_REPORT_RESPONSE);
} else {
throw new FaultMessage("Unsupported request type: " + requestObject);
}
} catch (SchemaException e) {
throwFault(e, operationResultTypeHolder.value);
// not reached
return null;
}
return new DOMSource(response);
}
use of com.evolveum.midpoint.xml.ns._public.common.api_types_3.ObjectListType 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");
}
Aggregations