use of com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectDeltaOperationType in project midpoint by Evolveum.
the class AbstractTestForExchangeConnector method modifyObject.
// values: path -> value or collection of values
protected ObjectDeltaOperationType modifyObject(Class objectType, String oid, ModificationTypeType modType, Map<String, Object> values, ModelExecuteOptionsType optionsType, boolean assertSuccess) throws Exception {
System.out.println("Modifying " + objectType.getSimpleName() + " " + oid + " (values: " + values + ")");
ObjectDeltaType deltaType = new ObjectDeltaType();
deltaType.setObjectType(ModelClientUtil.getTypeQName(objectType));
deltaType.setChangeType(ChangeTypeType.MODIFY);
deltaType.setOid(oid);
for (Map.Entry<String, Object> entry : values.entrySet()) {
ItemDeltaType itemDelta = new ItemDeltaType();
itemDelta.setModificationType(modType);
itemDelta.setPath(createNonDefaultItemPathType(entry.getKey()));
if (!(entry.getValue() instanceof Collection)) {
itemDelta.getValue().add(entry.getValue());
} else {
itemDelta.getValue().addAll((Collection) (entry.getValue()));
}
deltaType.getItemDelta().add(itemDelta);
}
ObjectDeltaListType deltaListType = new ObjectDeltaListType();
deltaListType.getDelta().add(deltaType);
ObjectDeltaOperationListType odolist = modelPort.executeChanges(deltaListType, optionsType);
return assertExecuteChangesSuccess(odolist, deltaType, assertSuccess);
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectDeltaOperationType in project midpoint by Evolveum.
the class TestExchangeConnectorLow method test210ModifyingNonexistingPowerShellObject.
@Test
public void test210ModifyingNonexistingPowerShellObject() throws Exception {
// create shadow with non-existing GUID
System.out.println("Creating shadow with non-existing GUID...");
Document doc = ModelClientUtil.getDocumnent();
String name = "Wrong GUID shadow";
ShadowType shadow = new ShadowType();
shadow.setName(ModelClientUtil.createPolyStringType(name, doc));
shadow.setResourceRef(createObjectReferenceType(ResourceType.class, getResourceOid()));
shadow.setObjectClass(OC_ACCEPTED_DOMAIN);
shadow.setKind(ShadowKindType.GENERIC);
shadow.setIntent("custom-accepted-domain");
ShadowAttributesType attributes = new ShadowAttributesType();
attributes.getAny().add(ModelClientUtil.createTextElement(new QName(NS_ICFS, "name"), name, doc));
attributes.getAny().add(ModelClientUtil.createTextElement(new QName(NS_ICFS, "uid"), "wrong-GUID", doc));
shadow.setAttributes(attributes);
String oid = createObject(ShadowType.class, shadow, createRaw());
System.out.println("Done, reading it back...");
ShadowType shadowReadAgain = getObjectNoFetch(ShadowType.class, oid);
dumpAttributes(shadowReadAgain);
System.out.println("Now launching modifyObject operation...");
//Class objectType, String oid, String path, ModificationTypeType modType, Object value, ModelExecuteOptionsType optionsType, boolean assertSuccess
ObjectDeltaOperationType odo = modifyObject(ShadowType.class, oid, "attributes/DomainType", ModificationTypeType.REPLACE, "InternalRelay", null, false);
OperationResultType r = odo.getExecutionResult();
System.out.println("Done: " + r.getStatus() + ":" + r.getMessage());
OperationResultType found = findOperationResult(r, new OperationResultMatcher() {
@Override
public boolean match(OperationResultType r) {
return r.getDetails() != null && r.getDetails().contains("UnknownUidException");
}
});
AssertJUnit.assertNotNull("UnknownUidException was not detected", found);
System.out.println("======================================================================================================");
System.out.println("Details: " + found.getDetails());
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectDeltaOperationType in project midpoint by Evolveum.
the class TestSanityLegacy method getOdoFromDeltaOperationList.
// ugly hack...
private static ObjectDeltaOperationType getOdoFromDeltaOperationList(ObjectDeltaOperationListType operationListType, ObjectDeltaType originalDelta) {
Validate.notNull(operationListType);
Validate.notNull(originalDelta);
for (ObjectDeltaOperationType operationType : operationListType.getDeltaOperation()) {
ObjectDeltaType objectDeltaType = operationType.getObjectDelta();
if (originalDelta.getChangeType() == ChangeTypeType.ADD) {
if (objectDeltaType.getChangeType() == originalDelta.getChangeType() && objectDeltaType.getObjectToAdd() != null) {
ObjectType objectAdded = (ObjectType) objectDeltaType.getObjectToAdd();
if (objectAdded.getClass().equals(originalDelta.getObjectToAdd().getClass())) {
return operationType;
}
}
} else {
if (objectDeltaType.getChangeType() == originalDelta.getChangeType() && originalDelta.getOid().equals(objectDeltaType.getOid())) {
return operationType;
}
}
}
throw new IllegalStateException("No suitable ObjectDeltaOperationType (" + originalDelta.getChangeType() + ")found. We have: " + operationListType);
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectDeltaOperationType in project midpoint by Evolveum.
the class DeltaConvertor method toObjectDeltaOperationType.
public static ObjectDeltaOperationType toObjectDeltaOperationType(ObjectDeltaOperation objectDeltaOperation, DeltaConversionOptions options) throws SchemaException {
ObjectDeltaOperationType rv = new ObjectDeltaOperationType();
toObjectDeltaOperationType(objectDeltaOperation, rv, options);
return rv;
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectDeltaOperationType in project midpoint by Evolveum.
the class ModelClientUtil method findInDeltaOperationList.
public static ObjectDeltaOperationType findInDeltaOperationList(ObjectDeltaOperationListType operationListType, ObjectDeltaType originalDelta) {
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())) {
return operationType;
}
}
}
return null;
}
Aggregations