Search in sources :

Example 16 with ItemDeltaType

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());
        }
    }
}
Also used : ObjectDeltaOperationType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectDeltaOperationType) ObjectDeltaType(com.evolveum.prism.xml.ns._public.types_3.ObjectDeltaType) RoleType(com.evolveum.midpoint.xml.ns._public.common.common_3.RoleType) ObjectDeltaOperationListType(com.evolveum.midpoint.xml.ns._public.common.api_types_3.ObjectDeltaOperationListType) ObjectDeltaListType(com.evolveum.midpoint.xml.ns._public.common.api_types_3.ObjectDeltaListType) ItemDeltaType(com.evolveum.prism.xml.ns._public.types_3.ItemDeltaType)

Example 17 with ItemDeltaType

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);
}
Also used : ObjectDeltaType(com.evolveum.prism.xml.ns._public.types_3.ObjectDeltaType) UserType(com.evolveum.midpoint.xml.ns._public.common.common_3.UserType) ObjectDeltaListType(com.evolveum.midpoint.xml.ns._public.common.api_types_3.ObjectDeltaListType) ItemDeltaType(com.evolveum.prism.xml.ns._public.types_3.ItemDeltaType)

Example 18 with ItemDeltaType

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);
}
Also used : ObjectDeltaOperationType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectDeltaOperationType) ObjectDeltaType(com.evolveum.prism.xml.ns._public.types_3.ObjectDeltaType) ObjectDeltaOperationListType(com.evolveum.midpoint.xml.ns._public.common.api_types_3.ObjectDeltaOperationListType) ObjectDeltaListType(com.evolveum.midpoint.xml.ns._public.common.api_types_3.ObjectDeltaListType) ItemDeltaType(com.evolveum.prism.xml.ns._public.types_3.ItemDeltaType)

Example 19 with ItemDeltaType

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());
}
Also used : SystemException(com.evolveum.midpoint.util.exception.SystemException) ItemDelta(com.evolveum.midpoint.prism.delta.ItemDelta) ObjectAlreadyExistsException(com.evolveum.midpoint.util.exception.ObjectAlreadyExistsException) ItemDeltaType(com.evolveum.prism.xml.ns._public.types_3.ItemDeltaType)

Example 20 with ItemDeltaType

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);
    }
}
Also used : SchemaException(com.evolveum.midpoint.util.exception.SchemaException) SystemException(com.evolveum.midpoint.util.exception.SystemException) ItemDelta(com.evolveum.midpoint.prism.delta.ItemDelta) ItemDeltaType(com.evolveum.prism.xml.ns._public.types_3.ItemDeltaType)

Aggregations

ItemDeltaType (com.evolveum.prism.xml.ns._public.types_3.ItemDeltaType)39 ObjectDeltaType (com.evolveum.prism.xml.ns._public.types_3.ObjectDeltaType)28 RawType (com.evolveum.prism.xml.ns._public.types_3.RawType)14 ItemPath (com.evolveum.midpoint.prism.path.ItemPath)11 ObjectDeltaListType (com.evolveum.midpoint.xml.ns._public.common.api_types_3.ObjectDeltaListType)11 UserType (com.evolveum.midpoint.xml.ns._public.common.common_3.UserType)11 ItemPathType (com.evolveum.prism.xml.ns._public.types_3.ItemPathType)11 Test (org.testng.annotations.Test)11 ItemDelta (com.evolveum.midpoint.prism.delta.ItemDelta)8 QName (javax.xml.namespace.QName)8 Document (org.w3c.dom.Document)8 AbstractModelIntegrationTest (com.evolveum.midpoint.model.test.AbstractModelIntegrationTest)7 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)7 SchemaException (com.evolveum.midpoint.util.exception.SchemaException)7 PrismAsserts.assertEqualsPolyString (com.evolveum.midpoint.prism.util.PrismAsserts.assertEqualsPolyString)6 ObjectDeltaOperationListType (com.evolveum.midpoint.xml.ns._public.common.api_types_3.ObjectDeltaOperationListType)6 XNode (com.evolveum.midpoint.prism.xnode.XNode)4 ObjectModificationType (com.evolveum.midpoint.xml.ns._public.common.api_types_3.ObjectModificationType)4 ObjectDeltaOperationType (com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectDeltaOperationType)4 ResourceObjectShadowChangeDescriptionType (com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceObjectShadowChangeDescriptionType)4