use of com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectDeltaOperationType in project midpoint by Evolveum.
the class Main method modifyRoleAssignment.
private static void modifyRoleAssignment(ModelPortType modelPort, String userOid, boolean isAdd, String... roleOids) throws FaultMessage {
ItemDeltaType assignmentDelta = new ItemDeltaType();
if (isAdd) {
assignmentDelta.setModificationType(ModificationTypeType.ADD);
} else {
assignmentDelta.setModificationType(ModificationTypeType.DELETE);
}
assignmentDelta.setPath(ModelClientUtil.createItemPathType("assignment"));
for (String roleOid : roleOids) {
assignmentDelta.getValue().add(ModelClientUtil.createRoleAssignment(roleOid));
}
ObjectDeltaType deltaType = new ObjectDeltaType();
deltaType.setObjectType(ModelClientUtil.getTypeQName(UserType.class));
deltaType.setChangeType(ChangeTypeType.MODIFY);
deltaType.setOid(userOid);
deltaType.getItemDelta().add(assignmentDelta);
ObjectDeltaOperationListType objectDeltaOperationList = modelPort.executeChanges(ModelClientUtil.createDeltaList(deltaType), null);
for (ObjectDeltaOperationType objectDeltaOperation : objectDeltaOperationList.getDeltaOperation()) {
if (!OperationResultStatusType.SUCCESS.equals(objectDeltaOperation.getExecutionResult().getStatus())) {
System.out.println("*** Operation result = " + objectDeltaOperation.getExecutionResult().getStatus() + ": " + objectDeltaOperation.getExecutionResult().getMessage());
}
}
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectDeltaOperationType in project midpoint by Evolveum.
the class TestSanity method addObjectViaModelWS.
private void addObjectViaModelWS(ObjectType objectType, ModelExecuteOptionsType options, Holder<String> oidHolder, Holder<OperationResultType> resultHolder) throws FaultMessage {
ObjectDeltaListType deltaList = new ObjectDeltaListType();
ObjectDeltaType objectDelta = new ObjectDeltaType();
objectDelta.setObjectToAdd(objectType);
QName type = objectType.asPrismObject().getDefinition().getTypeName();
objectDelta.setObjectType(type);
objectDelta.setChangeType(ChangeTypeType.ADD);
deltaList.getDelta().add(objectDelta);
ObjectDeltaOperationListType objectDeltaOperationListType = modelWeb.executeChanges(deltaList, options);
ObjectDeltaOperationType objectDeltaOperationType = getOdoFromDeltaOperationList(objectDeltaOperationListType, objectDelta);
resultHolder.value = objectDeltaOperationType.getExecutionResult();
oidHolder.value = ((ObjectType) objectDeltaOperationType.getObjectDelta().getObjectToAdd()).getOid();
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectDeltaOperationType in project midpoint by Evolveum.
the class TestExchangeConnectorLow method test220ModifyingNonexistingAccount.
@Test
public void test220ModifyingNonexistingAccount() 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_ACCOUNT);
shadow.setKind(ShadowKindType.ACCOUNT);
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"), "CN=wrong-GUID," + getContainer(), 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...");
ObjectDeltaOperationType odo = modifyObject(ShadowType.class, oid, "attributes/sn", ModificationTypeType.REPLACE, "xxxxxx", 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 TestExchangeConnectorLow method test140AssignConflictingAddress.
@Test
public void test140AssignConflictingAddress() throws Exception {
String mail = "pascal@clermont-ferrand.fr";
System.out.println("Disabling email address policy for Leibniz...");
modifyShadow(leibnizOid, "attributes/EmailAddressPolicyEnabled", ModificationTypeType.REPLACE, false);
System.out.println("Done");
System.out.println("Adding conflicting email addresses to Leibniz...");
ObjectDeltaOperationType result = modifyObject(ShadowType.class, leibnizOid, "attributes/EmailAddresses", ModificationTypeType.ADD, "smtp:" + mail, null, false);
System.out.println("Done; result = " + result.getExecutionResult().getStatus() + " / " + result.getExecutionResult().getMessage());
AssertJUnit.assertEquals("Unexpected operation status when adding conflicting address", OperationResultStatusType.FATAL_ERROR, result.getExecutionResult().getStatus());
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectDeltaOperationType in project midpoint by Evolveum.
the class Upload method uploadFile.
private static void uploadFile(File file, CommandLine cmdline, ModelPortType modelPort) {
System.out.println("Uploading file " + file);
Object content;
try {
content = unmarshalFile(file);
} catch (JAXBException | FileNotFoundException e) {
System.err.println("Cannot read " + file + ": " + e.getMessage());
e.printStackTrace();
error = true;
return;
}
if (content == null) {
System.err.println("Nothing to be uploaded.");
error = true;
return;
}
if (!(content instanceof ObjectType)) {
System.err.println("Expected an ObjectType to be uploaded; found " + content.getClass());
error = true;
return;
}
ObjectType objectType = (ObjectType) content;
ObjectDeltaType objectDeltaType = new ObjectDeltaType();
objectDeltaType.setChangeType(ChangeTypeType.ADD);
objectDeltaType.setObjectType(ModelClientUtil.getTypeQName(objectType.getClass()));
objectDeltaType.setObjectToAdd(objectType);
ObjectDeltaListType objectDeltaListType = new ObjectDeltaListType();
objectDeltaListType.getDelta().add(objectDeltaType);
ModelExecuteOptionsType optionsType = new ModelExecuteOptionsType();
optionsType.setIsImport(true);
optionsType.setReevaluateSearchFilters(true);
optionsType.setRaw(true);
optionsType.setOverwrite(true);
ExecuteChangesType executeChangesType = new ExecuteChangesType();
executeChangesType.setDeltaList(objectDeltaListType);
executeChangesType.setOptions(optionsType);
ObjectDeltaOperationListType response;
try {
response = modelPort.executeChanges(objectDeltaListType, optionsType);
} catch (Exception e) {
System.err.println("Got exception when trying to execute the changes " + e.getMessage());
error = true;
return;
}
System.out.println("-----------------------------------------------------------------");
if (response == null) {
System.err.println("Unexpected empty response");
error = true;
return;
}
OperationResultType overallResult = new OperationResultType();
boolean allSuccess = true;
for (ObjectDeltaOperationType objectDeltaOperation : response.getDeltaOperation()) {
if (objectDeltaOperation.getObjectDelta() != null) {
ObjectDeltaType delta = objectDeltaOperation.getObjectDelta();
System.out.print(delta.getChangeType() + " delta with OID " + delta.getOid() + " ");
}
OperationResultType resultType = objectDeltaOperation.getExecutionResult();
System.out.println("resulted in " + getResultStatus(resultType));
if (resultType == null || resultType.getStatus() != OperationResultStatusType.SUCCESS) {
allSuccess = false;
error = true;
}
overallResult.getPartialResults().add(resultType);
}
if (!cmdline.hasOption(OPT_HIDE_RESULT) && (cmdline.hasOption(OPT_SHOW_RESULT) || !allSuccess)) {
System.out.println("\n\n" + marshalResult(overallResult));
}
if (cmdline.hasOption(OPT_FILE_FOR_RESULT)) {
String filename = cmdline.getOptionValue(OPT_FILE_FOR_RESULT);
try {
FileWriter fileWriter = new FileWriter(filename, true);
IOUtils.write(marshalResult(overallResult), fileWriter);
} catch (IOException e) {
System.err.println("Couldn't write operation result to file " + filename + ": " + e.getMessage());
e.printStackTrace();
error = true;
}
}
}
Aggregations