Search in sources :

Example 26 with ObjectDeltaListType

use of com.evolveum.midpoint.xml.ns._public.common.api_types_3.ObjectDeltaListType 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 27 with ObjectDeltaListType

use of com.evolveum.midpoint.xml.ns._public.common.api_types_3.ObjectDeltaListType 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 28 with ObjectDeltaListType

use of com.evolveum.midpoint.xml.ns._public.common.api_types_3.ObjectDeltaListType in project midpoint by Evolveum.

the class AbstractTestForExchangeConnector method deleteUser.

protected void deleteUser(String oid) throws FaultMessage {
    ObjectDeltaType deltaType = new ObjectDeltaType();
    deltaType.setObjectType(ModelClientUtil.getTypeQName(UserType.class));
    deltaType.setChangeType(ChangeTypeType.DELETE);
    deltaType.setOid(oid);
    ObjectDeltaListType deltaListType = new ObjectDeltaListType();
    deltaListType.getDelta().add(deltaType);
    ModelExecuteOptionsType executeOptionsType = new ModelExecuteOptionsType();
    executeOptionsType.setRaw(true);
    modelPort.executeChanges(deltaListType, executeOptionsType);
}
Also used : ObjectDeltaType(com.evolveum.prism.xml.ns._public.types_3.ObjectDeltaType) ModelExecuteOptionsType(com.evolveum.midpoint.xml.ns._public.common.common_3.ModelExecuteOptionsType) UserType(com.evolveum.midpoint.xml.ns._public.common.common_3.UserType) ObjectDeltaListType(com.evolveum.midpoint.xml.ns._public.common.api_types_3.ObjectDeltaListType)

Example 29 with ObjectDeltaListType

use of com.evolveum.midpoint.xml.ns._public.common.api_types_3.ObjectDeltaListType in project midpoint by Evolveum.

the class AbstractTestForExchangeConnector method deleteObject.

protected void deleteObject(Class objectClass, String oid, boolean ignoreFailures, ModelExecuteOptionsType executeOptionsType) throws FaultMessage {
    System.out.println("Deleting " + objectClass.getSimpleName() + " " + oid);
    ObjectDeltaType deltaType = new ObjectDeltaType();
    deltaType.setObjectType(ModelClientUtil.getTypeQName(objectClass));
    deltaType.setChangeType(ChangeTypeType.DELETE);
    deltaType.setOid(oid);
    ObjectDeltaListType deltaListType = new ObjectDeltaListType();
    deltaListType.getDelta().add(deltaType);
    if (!ignoreFailures) {
        modelPort.executeChanges(deltaListType, executeOptionsType);
    } else {
        try {
            modelPort.executeChanges(deltaListType, executeOptionsType);
        } catch (Exception e) {
            System.err.println("Cannot remove " + oid + ": " + e.getMessage());
        }
    }
}
Also used : ObjectDeltaType(com.evolveum.prism.xml.ns._public.types_3.ObjectDeltaType) ObjectDeltaListType(com.evolveum.midpoint.xml.ns._public.common.api_types_3.ObjectDeltaListType) JAXBException(javax.xml.bind.JAXBException) FileNotFoundException(java.io.FileNotFoundException) SAXException(org.xml.sax.SAXException) IOException(java.io.IOException)

Example 30 with ObjectDeltaListType

use of com.evolveum.midpoint.xml.ns._public.common.api_types_3.ObjectDeltaListType 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;
        }
    }
}
Also used : JAXBException(javax.xml.bind.JAXBException) FileWriter(java.io.FileWriter) FileNotFoundException(java.io.FileNotFoundException) ModelExecuteOptionsType(com.evolveum.midpoint.xml.ns._public.common.common_3.ModelExecuteOptionsType) ExecuteChangesType(com.evolveum.midpoint.xml.ns._public.model.model_3.ExecuteChangesType) IOException(java.io.IOException) IOException(java.io.IOException) JAXBException(javax.xml.bind.JAXBException) FileNotFoundException(java.io.FileNotFoundException) ObjectDeltaOperationType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectDeltaOperationType) ObjectType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType) ObjectDeltaType(com.evolveum.prism.xml.ns._public.types_3.ObjectDeltaType) OperationResultType(com.evolveum.midpoint.xml.ns._public.common.common_3.OperationResultType) ObjectDeltaOperationListType(com.evolveum.midpoint.xml.ns._public.common.api_types_3.ObjectDeltaOperationListType) ObjectDeltaListType(com.evolveum.midpoint.xml.ns._public.common.api_types_3.ObjectDeltaListType)

Aggregations

ObjectDeltaListType (com.evolveum.midpoint.xml.ns._public.common.api_types_3.ObjectDeltaListType)52 ObjectDeltaType (com.evolveum.prism.xml.ns._public.types_3.ObjectDeltaType)37 ObjectDeltaOperationListType (com.evolveum.midpoint.xml.ns._public.common.api_types_3.ObjectDeltaOperationListType)31 UserType (com.evolveum.midpoint.xml.ns._public.common.common_3.UserType)17 Test (org.testng.annotations.Test)17 LogfileTestTailer (com.evolveum.midpoint.test.util.LogfileTestTailer)13 ItemDeltaType (com.evolveum.prism.xml.ns._public.types_3.ItemDeltaType)11 ModelExecuteOptionsType (com.evolveum.midpoint.xml.ns._public.common.common_3.ModelExecuteOptionsType)10 ObjectDeltaOperationType (com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectDeltaOperationType)8 ObjectReferenceType (com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType)4 RoleType (com.evolveum.midpoint.xml.ns._public.common.common_3.RoleType)4 FaultMessage (com.evolveum.midpoint.xml.ns._public.common.fault_3.FaultMessage)4 QName (javax.xml.namespace.QName)4 SOAPFaultException (javax.xml.ws.soap.SOAPFaultException)4 AbstractInitializedModelIntegrationTest (com.evolveum.midpoint.model.intest.AbstractInitializedModelIntegrationTest)3 Task (com.evolveum.midpoint.task.api.Task)3 OperationResultType (com.evolveum.midpoint.xml.ns._public.common.common_3.OperationResultType)3 ProtectedStringType (com.evolveum.prism.xml.ns._public.types_3.ProtectedStringType)3 Collection (java.util.Collection)3 Document (org.w3c.dom.Document)3