use of com.evolveum.prism.xml.ns._public.types_3.ItemDeltaType in project midpoint by Evolveum.
the class Main method modifyRoleReplaceInducement.
// removes inducement with a given ID and replaces it with a new one
private static void modifyRoleReplaceInducement(ModelPortType modelPort, String roleOid, int oldId, String newInducementOid) throws FaultMessage, IOException, SAXException {
ItemDeltaType inducementDeleteDelta = new ItemDeltaType();
inducementDeleteDelta.setModificationType(ModificationTypeType.DELETE);
inducementDeleteDelta.setPath(ModelClientUtil.createItemPathType("inducement"));
inducementDeleteDelta.getValue().add(ModelClientUtil.parseElement("<value><id>" + oldId + "</id></value>"));
ItemDeltaType inducementAddDelta = new ItemDeltaType();
inducementAddDelta.setModificationType(ModificationTypeType.ADD);
inducementAddDelta.setPath(ModelClientUtil.createItemPathType("inducement"));
inducementAddDelta.getValue().add(ModelClientUtil.createRoleAssignment(newInducementOid));
ObjectDeltaType deltaType = new ObjectDeltaType();
deltaType.setObjectType(ModelClientUtil.getTypeQName(RoleType.class));
deltaType.setChangeType(ChangeTypeType.MODIFY);
deltaType.setOid(roleOid);
deltaType.getItemDelta().add(inducementDeleteDelta);
deltaType.getItemDelta().add(inducementAddDelta);
ObjectDeltaListType deltaListType = new ObjectDeltaListType();
deltaListType.getDelta().add(deltaType);
ObjectDeltaOperationListType objectDeltaOperationList = modelPort.executeChanges(deltaListType, 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.prism.xml.ns._public.types_3.ItemDeltaType in project midpoint by Evolveum.
the class AbstractTestForExchangeConnector method changeUserPassword.
protected void changeUserPassword(String oid, String newPassword) throws FaultMessage {
ItemDeltaType passwordDelta = new ItemDeltaType();
passwordDelta.setModificationType(ModificationTypeType.REPLACE);
passwordDelta.setPath(ModelClientUtil.createItemPathType("credentials/password/value"));
passwordDelta.getValue().add(ModelClientUtil.createProtectedString(newPassword));
ObjectDeltaType deltaType = new ObjectDeltaType();
deltaType.setObjectType(ModelClientUtil.getTypeQName(UserType.class));
deltaType.setChangeType(ChangeTypeType.MODIFY);
deltaType.setOid(oid);
deltaType.getItemDelta().add(passwordDelta);
ObjectDeltaListType deltaListType = new ObjectDeltaListType();
deltaListType.getDelta().add(deltaType);
modelPort.executeChanges(deltaListType, null);
}
use of com.evolveum.prism.xml.ns._public.types_3.ItemDeltaType in project midpoint by Evolveum.
the class AbstractTestForExchangeConnector method modifyRoleAssignment.
protected boolean modifyRoleAssignment(Class clazz, String oid, 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) {
AssertJUnit.assertNotNull("role OID is null", roleOid);
assignmentDelta.getValue().add(createRoleAssignment(roleOid));
}
ObjectDeltaType deltaType = new ObjectDeltaType();
deltaType.setObjectType(ModelClientUtil.getTypeQName(clazz));
deltaType.setChangeType(ChangeTypeType.MODIFY);
deltaType.setOid(oid);
deltaType.getItemDelta().add(assignmentDelta);
ObjectDeltaListType deltaListType = new ObjectDeltaListType();
deltaListType.getDelta().add(deltaType);
ObjectDeltaOperationListType objectDeltaOperationList = modelPort.executeChanges(deltaListType, null);
Boolean success = null;
for (ObjectDeltaOperationType objectDeltaOperation : objectDeltaOperationList.getDeltaOperation()) {
if (oid.equals(objectDeltaOperation.getObjectDelta().getOid())) {
if (!OperationResultStatusType.SUCCESS.equals(objectDeltaOperation.getExecutionResult().getStatus())) {
System.out.println("*** Operation result = " + objectDeltaOperation.getExecutionResult().getStatus() + ": " + objectDeltaOperation.getExecutionResult().getMessage());
success = false;
} else {
if (success == null) {
success = true;
}
}
}
}
return Boolean.TRUE.equals(success);
}
use of com.evolveum.prism.xml.ns._public.types_3.ItemDeltaType in project midpoint by Evolveum.
the class TaskQuartzImpl method finishHandler.
// @Override
// public void replaceCurrentHandlerUri(String newUri, ScheduleType schedule) {
//
// checkHandlerUriConsistency();
// setHandlerUri(newUri);
// setSchedule(schedule);
// }
@Override
public void finishHandler(OperationResult parentResult) throws ObjectNotFoundException, SchemaException {
// let us drop the current handler URI and nominate the top of the other
// handlers stack as the current one
LOGGER.trace("finishHandler called for handler URI {}, task {}", this.getHandlerUri(), this);
UriStack otherHandlersUriStack = getOtherHandlersUriStack();
if (otherHandlersUriStack != null && !otherHandlersUriStack.getUriStackEntry().isEmpty()) {
UriStackEntry use = popFromOtherHandlersUriStack();
setHandlerUri(use.getHandlerUri());
setRecurrenceStatus(use.getRecurrence() != null ? TaskRecurrence.fromTaskType(use.getRecurrence()) : recurrenceFromSchedule(use.getSchedule()));
setSchedule(use.getSchedule());
if (use.getBinding() != null) {
setBinding(TaskBinding.fromTaskType(use.getBinding()));
} else {
setBinding(bindingFromSchedule(use.getSchedule()));
}
for (ItemDeltaType itemDeltaType : use.getExtensionDelta()) {
ItemDelta itemDelta = DeltaConvertor.createItemDelta(itemDeltaType, TaskType.class, taskManager.getPrismContext());
LOGGER.trace("Applying ItemDelta to task extension; task = {}; itemDelta = {}", this, itemDelta.debugDump());
this.modifyExtension(itemDelta);
}
this.setRecreateQuartzTrigger(true);
} else {
//setHandlerUri(null); // we want the last handler to remain set so the task can be revived
// as there are no more handlers, let us close this task
taskManager.closeTaskWithoutSavingState(this, parentResult);
}
try {
savePendingModifications(parentResult);
checkDependentTasksOnClose(parentResult);
} catch (ObjectAlreadyExistsException ex) {
throw new SystemException(ex);
}
LOGGER.trace("finishHandler: new current handler uri = {}, new number of handlers = {}", getHandlerUri(), getHandlersCount());
}
use of com.evolveum.prism.xml.ns._public.types_3.ItemDeltaType in project midpoint by Evolveum.
the class TaskQuartzImpl method storeExtensionDeltas.
private void storeExtensionDeltas(List<ItemDeltaType> result, Collection<ItemDelta<?, ?>> extensionDeltas) {
for (ItemDelta itemDelta : extensionDeltas) {
Collection<ItemDeltaType> deltaTypes = null;
try {
deltaTypes = DeltaConvertor.toItemDeltaTypes(itemDelta);
} catch (SchemaException e) {
throw new SystemException("Unexpected SchemaException when converting extension ItemDelta to ItemDeltaType", e);
}
result.addAll(deltaTypes);
}
}
Aggregations