Search in sources :

Example 66 with ObjectDeltaType

use of com.evolveum.prism.xml.ns._public.types_3.ObjectDeltaType 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 67 with ObjectDeltaType

use of com.evolveum.prism.xml.ns._public.types_3.ObjectDeltaType in project midpoint by Evolveum.

the class WorkItemDto method getFocus.

// Expects that we deal with primary changes of the focus (i.e. not of projections)
// Beware: returns the full object; regardless of the security settings
public ObjectType getFocus(PageBase pageBase) {
    if (focus != null) {
        return focus;
    }
    WfContextType wfc = getWorkflowContext();
    WfPrimaryChangeProcessorStateType state = WfContextUtil.getPrimaryChangeProcessorState(wfc);
    if (state == null || state.getDeltasToProcess() == null || state.getDeltasToProcess().getFocusPrimaryDelta() == null) {
        return null;
    }
    ObjectDeltaType delta = state.getDeltasToProcess().getFocusPrimaryDelta();
    if (delta.getChangeType() == ChangeTypeType.ADD) {
        focus = CloneUtil.clone((ObjectType) delta.getObjectToAdd());
    } else if (delta.getChangeType() == ChangeTypeType.MODIFY) {
        String oid = delta.getOid();
        if (oid == null) {
            throw new IllegalStateException("No OID in object modify delta: " + delta);
        }
        if (delta.getObjectType() == null) {
            throw new IllegalStateException("No object type in object modify delta: " + delta);
        }
        Class<? extends ObjectType> clazz = ObjectTypes.getObjectTypeFromTypeQName(delta.getObjectType()).getClassDefinition();
        Task task = pageBase.createSimpleTask("getObject");
        PrismObject<?> object = pageBase.getSecurityEnforcer().runPrivileged(() -> WebModelServiceUtils.loadObject(clazz, oid, pageBase, task, task.getResult()));
        if (object != null) {
            focus = (ObjectType) object.asObjectable();
            try {
                ObjectDelta<Objectable> objectDelta = DeltaConvertor.createObjectDelta(delta, pageBase.getPrismContext());
                objectDelta.applyTo((PrismObject) focus.asPrismObject());
            } catch (SchemaException e) {
                throw new SystemException("Cannot apply delta to focus object: " + e.getMessage(), e);
            }
            focus = (ObjectType) object.asObjectable();
        }
    } else {
    // DELETE case: nothing to do here
    }
    return focus;
}
Also used : ObjectDeltaType(com.evolveum.prism.xml.ns._public.types_3.ObjectDeltaType) PrismObject(com.evolveum.midpoint.prism.PrismObject) SchemaException(com.evolveum.midpoint.util.exception.SchemaException) Task(com.evolveum.midpoint.task.api.Task) SystemException(com.evolveum.midpoint.util.exception.SystemException) PolyString(com.evolveum.midpoint.prism.polystring.PolyString) ObjectDelta(com.evolveum.midpoint.prism.delta.ObjectDelta)

Example 68 with ObjectDeltaType

use of com.evolveum.prism.xml.ns._public.types_3.ObjectDeltaType in project midpoint by Evolveum.

the class RObjectDeltaOperation method fromRepo.

public static ObjectDeltaOperation fromRepo(RObjectDeltaOperation operation, PrismContext prismContext) throws DtoTranslationException {
    ObjectDeltaOperation odo = new ObjectDeltaOperation();
    try {
        if (operation.getDelta() != null) {
            ObjectDeltaType delta = prismContext.parserFor(operation.getDelta()).parseRealValue(ObjectDeltaType.class);
            odo.setObjectDelta(DeltaConvertor.createObjectDelta(delta, prismContext));
        }
        if (operation.getFullResult() != null) {
            OperationResultType resultType = prismContext.parserFor(operation.getFullResult()).parseRealValue(OperationResultType.class);
            odo.setExecutionResult(OperationResult.createOperationResult(resultType));
        }
        odo.setObjectName(RPolyString.fromRepo(operation.getObjectName()));
        odo.setResourceOid(operation.getResourceOid());
        odo.setResourceName(RPolyString.fromRepo(operation.getResourceName()));
    } catch (Exception ex) {
        throw new DtoTranslationException(ex.getMessage(), ex);
    }
    return odo;
}
Also used : ObjectDeltaType(com.evolveum.prism.xml.ns._public.types_3.ObjectDeltaType) DtoTranslationException(com.evolveum.midpoint.repo.sql.util.DtoTranslationException) ObjectDeltaOperation(com.evolveum.midpoint.schema.ObjectDeltaOperation) OperationResultType(com.evolveum.midpoint.xml.ns._public.common.common_3.OperationResultType) DtoTranslationException(com.evolveum.midpoint.repo.sql.util.DtoTranslationException)

Example 69 with ObjectDeltaType

use of com.evolveum.prism.xml.ns._public.types_3.ObjectDeltaType in project midpoint by Evolveum.

the class Main method changeUserPassword.

private static void changeUserPassword(ModelPortType modelPort, 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 70 with ObjectDeltaType

use of com.evolveum.prism.xml.ns._public.types_3.ObjectDeltaType in project midpoint by Evolveum.

the class Main method modifyRoleModifyInducement.

private static void modifyRoleModifyInducement(ModelPortType modelPort, String roleOid) throws IOException, SAXException, FaultMessage {
    ItemDeltaType inducementDelta = new ItemDeltaType();
    inducementDelta.setModificationType(ModificationTypeType.ADD);
    inducementDelta.setPath(ModelClientUtil.createItemPathType("inducement[3]/construction/attribute"));
    inducementDelta.getValue().add(ModelClientUtil.parseElement("<value>\n" + "        <ref xmlns:ri=\"http://midpoint.evolveum.com/xml/ns/public/resource/instance-3\">ri:pager</ref>\n" + "        <outbound>\n" + "            <expression>\n" + "                <value>00-000-001</value>\n" + "                <value>00-000-003</value>\n" + "            </expression>\n" + "        </outbound>\n" + "    </value>"));
    ObjectDeltaType deltaType = new ObjectDeltaType();
    deltaType.setObjectType(ModelClientUtil.getTypeQName(RoleType.class));
    deltaType.setChangeType(ChangeTypeType.MODIFY);
    deltaType.setOid(roleOid);
    deltaType.getItemDelta().add(inducementDelta);
    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)

Aggregations

ObjectDeltaType (com.evolveum.prism.xml.ns._public.types_3.ObjectDeltaType)136 Test (org.testng.annotations.Test)55 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)53 UserType (com.evolveum.midpoint.xml.ns._public.common.common_3.UserType)50 AbstractModelIntegrationTest (com.evolveum.midpoint.model.test.AbstractModelIntegrationTest)47 PrismAsserts.assertEqualsPolyString (com.evolveum.midpoint.prism.util.PrismAsserts.assertEqualsPolyString)47 OperationResultType (com.evolveum.midpoint.xml.ns._public.common.common_3.OperationResultType)42 ShadowType (com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType)41 ObjectDeltaListType (com.evolveum.midpoint.xml.ns._public.common.api_types_3.ObjectDeltaListType)37 ObjectReferenceType (com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType)30 ChangeRecordEntry (org.opends.server.util.ChangeRecordEntry)30 ItemDeltaType (com.evolveum.prism.xml.ns._public.types_3.ItemDeltaType)29 ObjectDeltaOperationListType (com.evolveum.midpoint.xml.ns._public.common.api_types_3.ObjectDeltaOperationListType)23 ObjectType (com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType)17 ObjectDelta (com.evolveum.midpoint.prism.delta.ObjectDelta)16 SchemaException (com.evolveum.midpoint.util.exception.SchemaException)16 ObjectDeltaOperationType (com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectDeltaOperationType)14 QName (javax.xml.namespace.QName)14 ItemPath (com.evolveum.midpoint.prism.path.ItemPath)13 TaskType (com.evolveum.midpoint.xml.ns._public.common.common_3.TaskType)12