Search in sources :

Example 11 with ModelExecuteOptionsType

use of com.evolveum.midpoint.xml.ns._public.common.common_3.ModelExecuteOptionsType in project midpoint by Evolveum.

the class Main method deleteTask.

private static void deleteTask(ModelPortType modelPort, String oid) throws FaultMessage {
    ObjectDeltaType deltaType = new ObjectDeltaType();
    deltaType.setObjectType(ModelClientUtil.getTypeQName(TaskType.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) TaskType(com.evolveum.midpoint.xml.ns._public.common.common_3.TaskType) ModelExecuteOptionsType(com.evolveum.midpoint.xml.ns._public.common.common_3.ModelExecuteOptionsType) ObjectDeltaListType(com.evolveum.midpoint.xml.ns._public.common.api_types_3.ObjectDeltaListType)

Example 12 with ModelExecuteOptionsType

use of com.evolveum.midpoint.xml.ns._public.common.common_3.ModelExecuteOptionsType in project midpoint by Evolveum.

the class Main method reconcileUser.

private static void reconcileUser(ModelPortType modelPort, String oid) throws FaultMessage {
    Document doc = ModelClientUtil.getDocumnent();
    ObjectDeltaType userDelta = new ObjectDeltaType();
    userDelta.setOid(oid);
    userDelta.setObjectType(ModelClientUtil.getTypeQName(UserType.class));
    userDelta.setChangeType(ChangeTypeType.MODIFY);
    ObjectDeltaListType deltaList = new ObjectDeltaListType();
    deltaList.getDelta().add(userDelta);
    ModelExecuteOptionsType optionsType = new ModelExecuteOptionsType();
    optionsType.setReconcile(true);
    modelPort.executeChanges(deltaList, optionsType);
}
Also used : ObjectDeltaType(com.evolveum.prism.xml.ns._public.types_3.ObjectDeltaType) ModelExecuteOptionsType(com.evolveum.midpoint.xml.ns._public.common.common_3.ModelExecuteOptionsType) Document(org.w3c.dom.Document) UserType(com.evolveum.midpoint.xml.ns._public.common.common_3.UserType) ObjectDeltaListType(com.evolveum.midpoint.xml.ns._public.common.api_types_3.ObjectDeltaListType)

Example 13 with ModelExecuteOptionsType

use of com.evolveum.midpoint.xml.ns._public.common.common_3.ModelExecuteOptionsType 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 14 with ModelExecuteOptionsType

use of com.evolveum.midpoint.xml.ns._public.common.common_3.ModelExecuteOptionsType 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 15 with ModelExecuteOptionsType

use of com.evolveum.midpoint.xml.ns._public.common.common_3.ModelExecuteOptionsType 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

ModelExecuteOptionsType (com.evolveum.midpoint.xml.ns._public.common.common_3.ModelExecuteOptionsType)18 ObjectDeltaListType (com.evolveum.midpoint.xml.ns._public.common.api_types_3.ObjectDeltaListType)17 ObjectDeltaType (com.evolveum.prism.xml.ns._public.types_3.ObjectDeltaType)17 ObjectDeltaOperationListType (com.evolveum.midpoint.xml.ns._public.common.api_types_3.ObjectDeltaOperationListType)10 OperationResultType (com.evolveum.midpoint.xml.ns._public.common.common_3.OperationResultType)8 ObjectDeltaOperationType (com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectDeltaOperationType)6 ResourceType (com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType)6 Test (org.testng.annotations.Test)6 AbstractModelIntegrationTest (com.evolveum.midpoint.model.test.AbstractModelIntegrationTest)4 PrismAsserts.assertEqualsPolyString (com.evolveum.midpoint.prism.util.PrismAsserts.assertEqualsPolyString)4 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)4 FaultMessage (com.evolveum.midpoint.xml.ns._public.common.fault_3.FaultMessage)4 File (java.io.File)4 QName (javax.xml.namespace.QName)4 UserType (com.evolveum.midpoint.xml.ns._public.common.common_3.UserType)3 Holder (javax.xml.ws.Holder)3 TaskType (com.evolveum.midpoint.xml.ns._public.common.common_3.TaskType)2 ObjectAlreadyExistsFaultType (com.evolveum.midpoint.xml.ns._public.common.fault_3.ObjectAlreadyExistsFaultType)2 ModelPortType (com.evolveum.midpoint.xml.ns._public.model.model_3.ModelPortType)2 ItemDeltaType (com.evolveum.prism.xml.ns._public.types_3.ItemDeltaType)2