use of com.evolveum.midpoint.xml.ns._public.common.common_3.OperationResultType in project midpoint by Evolveum.
the class OperationResult method createOperationResultType.
private OperationResultType createOperationResultType(OperationResult opResult) {
OperationResultType result = new OperationResultType();
result.setToken(opResult.getToken());
result.setStatus(OperationResultStatus.createStatusType(opResult.getStatus()));
if (opResult.getCount() != 1) {
result.setCount(opResult.getCount());
}
if (opResult.getHiddenRecordsCount() != 0) {
result.setHiddenRecordsCount(opResult.getHiddenRecordsCount());
}
result.setOperation(opResult.getOperation());
result.setMessage(opResult.getMessage());
result.setMessageCode(opResult.getMessageCode());
if (opResult.getCause() != null || !opResult.details.isEmpty()) {
StringBuilder detailsb = new StringBuilder();
// Record text messages in details (if present)
if (!opResult.details.isEmpty()) {
for (String line : opResult.details) {
detailsb.append(line);
detailsb.append("\n");
}
}
// Record stack trace in details if a cause is present
if (opResult.getCause() != null) {
Throwable ex = opResult.getCause();
detailsb.append(ex.getClass().getName());
detailsb.append(": ");
detailsb.append(ex.getMessage());
detailsb.append("\n");
StackTraceElement[] stackTrace = ex.getStackTrace();
for (StackTraceElement aStackTrace : stackTrace) {
detailsb.append(aStackTrace.toString());
detailsb.append("\n");
}
}
result.setDetails(detailsb.toString());
}
if (StringUtils.isNotEmpty(opResult.getLocalizationMessage())) {
LocalizedMessageType message = new LocalizedMessageType();
message.setKey(opResult.getLocalizationMessage());
if (opResult.getLocalizationArguments() != null) {
message.getArgument().addAll(opResult.getLocalizationArguments());
}
result.setLocalizedMessage(message);
}
result.setParams(ParamsTypeUtil.toParamsType(opResult.getParams()));
result.setContext(ParamsTypeUtil.toParamsType(opResult.getContext()));
result.setReturns(ParamsTypeUtil.toParamsType(opResult.getReturns()));
for (OperationResult subResult : opResult.getSubresults()) {
result.getPartialResults().add(opResult.createOperationResultType(subResult));
}
return result;
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.OperationResultType in project midpoint by Evolveum.
the class OperationResultFactory method createOperationResult.
public static OperationResultType createOperationResult(String operation, OperationResultStatusType status) {
if (StringUtils.isEmpty(operation)) {
throw new IllegalArgumentException("Operation name not defined.");
}
if (status == null) {
throw new IllegalArgumentException("Operation status not defined.");
}
ObjectFactory factory = new ObjectFactory();
OperationResultType result = factory.createOperationResultType();
result.setToken(getNextToken());
result.setOperation(operation);
result.setStatus(status);
return result;
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.OperationResultType in project midpoint by Evolveum.
the class AbstractTestForExchangeConnector method getOidFromDeltaOperationList.
/**
* Retrieves OID and OperationResult created by model Web Service from the returned list of ObjectDeltaOperations.
*
* @param operationListType result of the model web service executeChanges call
* @param originalDelta original request used to find corresponding ObjectDeltaOperationType instance. Must be of ADD type.
* @param operationResultHolder where the result will be put
* @return OID if found
*
* PRELIMINARY IMPLEMENTATION. Currently the first returned ADD delta with the same object type as original delta is returned.
*
* TODO move to ModelClientUtil
*/
public static String getOidFromDeltaOperationList(ObjectDeltaOperationListType operationListType, ObjectDeltaType originalDelta, Holder<OperationResultType> operationResultTypeHolder) {
Validate.notNull(operationListType);
Validate.notNull(originalDelta);
if (originalDelta.getChangeType() != ChangeTypeType.ADD) {
throw new IllegalArgumentException("Original delta is not of ADD type");
}
if (originalDelta.getObjectToAdd() == null) {
throw new IllegalArgumentException("Original delta contains no object-to-be-added");
}
for (ObjectDeltaOperationType operationType : operationListType.getDeltaOperation()) {
ObjectDeltaType objectDeltaType = operationType.getObjectDelta();
if (objectDeltaType.getChangeType() == ChangeTypeType.ADD && objectDeltaType.getObjectToAdd() != null) {
ObjectType objectAdded = (ObjectType) objectDeltaType.getObjectToAdd();
if (objectAdded.getClass().equals(originalDelta.getObjectToAdd().getClass())) {
operationResultTypeHolder.value = operationType.getExecutionResult();
return objectAdded.getOid();
}
}
}
return null;
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.OperationResultType in project midpoint by Evolveum.
the class AbstractTestForExchangeConnector method listUsers.
protected Collection<UserType> listUsers() throws SAXException, IOException, FaultMessage {
SelectorQualifiedGetOptionsType options = new SelectorQualifiedGetOptionsType();
Holder<ObjectListType> objectListHolder = new Holder<ObjectListType>();
Holder<OperationResultType> resultHolder = new Holder<OperationResultType>();
// let's say we want to get first 3 users, sorted alphabetically by user name
// holds search query + paging options
QueryType queryType = new QueryType();
PagingType pagingType = new PagingType();
pagingType.setMaxSize(3);
pagingType.setOrderBy(ModelClientUtil.createItemPathType("name"));
pagingType.setOrderDirection(OrderDirectionType.ASCENDING);
queryType.setPaging(pagingType);
modelPort.searchObjects(ModelClientUtil.getTypeQName(UserType.class), queryType, options, objectListHolder, resultHolder);
ObjectListType objectList = objectListHolder.value;
return (Collection) objectList.getObject();
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.OperationResultType in project midpoint by Evolveum.
the class AbstractTestForExchangeConnector method listResources.
protected Collection<ResourceType> listResources() throws SAXException, IOException, FaultMessage {
SelectorQualifiedGetOptionsType options = new SelectorQualifiedGetOptionsType();
Holder<ObjectListType> objectListHolder = new Holder<ObjectListType>();
Holder<OperationResultType> resultHolder = new Holder<OperationResultType>();
modelPort.searchObjects(ModelClientUtil.getTypeQName(ResourceType.class), null, options, objectListHolder, resultHolder);
ObjectListType objectList = objectListHolder.value;
return (Collection) objectList.getObject();
}
Aggregations