Search in sources :

Example 6 with ObjectDelta

use of com.evolveum.midpoint.prism.delta.ObjectDelta in project midpoint by Evolveum.

the class PageUsers method deleteConfirmedPerformed.

private void deleteConfirmedPerformed(AjaxRequestTarget target, UserType userToDelete) {
    List<UserType> users = isAnythingSelected(target, userToDelete);
    if (users.isEmpty()) {
        return;
    }
    OperationResult result = new OperationResult(OPERATION_DELETE_USERS);
    for (UserType user : users) {
        OperationResult subResult = result.createSubresult(OPERATION_DELETE_USER);
        try {
            Task task = createSimpleTask(OPERATION_DELETE_USER);
            ObjectDelta delta = new ObjectDelta(UserType.class, ChangeType.DELETE, getPrismContext());
            delta.setOid(user.getOid());
            ExecuteChangeOptionsDto executeOptions = executeOptionsModel.getObject();
            ModelExecuteOptions options = executeOptions.createOptions();
            LOGGER.debug("Using options {}.", new Object[] { executeOptions });
            getModelService().executeChanges(WebComponentUtil.createDeltaCollection(delta), options, task, subResult);
            subResult.computeStatus();
        } catch (Exception ex) {
            subResult.recomputeStatus();
            subResult.recordFatalError("Couldn't delete user.", ex);
            LoggingUtils.logUnexpectedException(LOGGER, "Couldn't delete user", ex);
        }
    }
    result.computeStatusComposite();
    getTable().clearCache();
    showResult(result);
    target.add(getFeedbackPanel());
    getTable().refreshTable(UserType.class, target);
    getTable().clearCache();
}
Also used : Task(com.evolveum.midpoint.task.api.Task) ExecuteChangeOptionsDto(com.evolveum.midpoint.web.page.admin.users.component.ExecuteChangeOptionsDto) ModelExecuteOptions(com.evolveum.midpoint.model.api.ModelExecuteOptions) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) ObjectDelta(com.evolveum.midpoint.prism.delta.ObjectDelta)

Example 7 with ObjectDelta

use of com.evolveum.midpoint.prism.delta.ObjectDelta in project midpoint by Evolveum.

the class PageUsers method unlockPerformed.

private void unlockPerformed(AjaxRequestTarget target, UserType selectedUser) {
    List<UserType> users = isAnythingSelected(target, selectedUser);
    if (users.isEmpty()) {
        return;
    }
    OperationResult result = new OperationResult(OPERATION_UNLOCK_USERS);
    for (UserType user : users) {
        OperationResult opResult = result.createSubresult(getString(OPERATION_UNLOCK_USER, user));
        try {
            Task task = createSimpleTask(OPERATION_UNLOCK_USER + user);
            // TODO skip the operation if the user has no password
            // credentials specified (otherwise this would create
            // almost-empty password container)
            ObjectDelta delta = ObjectDelta.createModificationReplaceProperty(UserType.class, user.getOid(), new ItemPath(UserType.F_ACTIVATION, ActivationType.F_LOCKOUT_STATUS), getPrismContext(), LockoutStatusType.NORMAL);
            Collection<ObjectDelta<? extends ObjectType>> deltas = WebComponentUtil.createDeltaCollection(delta);
            getModelService().executeChanges(deltas, null, task, opResult);
            opResult.computeStatusIfUnknown();
        } catch (Exception ex) {
            opResult.recomputeStatus();
            opResult.recordFatalError("Couldn't unlock user " + user + ".", ex);
            LoggingUtils.logUnexpectedException(LOGGER, "Couldn't unlock user " + user + ".", ex);
        }
    }
    result.recomputeStatus();
    showResult(result);
    target.add(getFeedbackPanel());
    getTable().refreshTable(UserType.class, target);
    getTable().clearCache();
}
Also used : Task(com.evolveum.midpoint.task.api.Task) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) ObjectDelta(com.evolveum.midpoint.prism.delta.ObjectDelta) ItemPath(com.evolveum.midpoint.prism.path.ItemPath)

Example 8 with ObjectDelta

use of com.evolveum.midpoint.prism.delta.ObjectDelta in project midpoint by Evolveum.

the class FocusListInlineMenuHelper method deleteConfirmedPerformed.

public void deleteConfirmedPerformed(AjaxRequestTarget target, F selectedObject) {
    List<F> objects = getObjectsToActOn(target, selectedObject);
    if (objects.isEmpty()) {
        return;
    }
    OperationResult result = new OperationResult(getOperationName(OPERATION_DELETE_OBJECTS));
    for (F object : objects) {
        OperationResult subResult = result.createSubresult(getOperationName(OPERATION_DELETE_OBJECT));
        try {
            Task task = parentPage.createSimpleTask(getOperationName(OPERATION_DELETE_OBJECT));
            ObjectDelta delta = new ObjectDelta(objectClass, ChangeType.DELETE, parentPage.getPrismContext());
            delta.setOid(object.getOid());
            parentPage.getModelService().executeChanges(WebComponentUtil.createDeltaCollection(delta), null, task, subResult);
            subResult.computeStatus();
        } catch (CommonException | RuntimeException ex) {
            subResult.recomputeStatus();
            subResult.recordFatalError("Couldn't delete object.", ex);
            LoggingUtils.logUnexpectedException(LOGGER, "Couldn't delete object", ex);
        }
    }
    result.computeStatusComposite();
    focusListComponent.getObjectListPanel().clearCache();
    parentPage.showResult(result);
    target.add(parentPage.getFeedbackPanel());
    focusListComponent.getObjectListPanel().refreshTable(objectClass, target);
    focusListComponent.getObjectListPanel().clearCache();
}
Also used : Task(com.evolveum.midpoint.task.api.Task) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) CommonException(com.evolveum.midpoint.util.exception.CommonException) ObjectDelta(com.evolveum.midpoint.prism.delta.ObjectDelta)

Example 9 with ObjectDelta

use of com.evolveum.midpoint.prism.delta.ObjectDelta in project midpoint by Evolveum.

the class ConfigurationStep method saveChanges.

private void saveChanges() {
    Task task = parentPage.createSimpleTask(OPERATION_SAVE);
    OperationResult result = task.getResult();
    boolean saved = false;
    try {
        List<ContainerWrapper> wrappers = configurationPropertiesModel.getObject();
        ObjectDelta delta = ObjectDelta.createEmptyModifyDelta(ResourceType.class, parentPage.getEditedResourceOid(), parentPage.getPrismContext());
        for (ContainerWrapper wrapper : wrappers) {
            wrapper.collectModifications(delta);
        }
        if (!delta.isEmpty()) {
            parentPage.logDelta(delta);
            WebModelServiceUtils.save(delta, result, parentPage);
            parentPage.resetModels();
            saved = true;
        }
    } catch (Exception ex) {
        LoggingUtils.logUnexpectedException(LOGGER, "Error occurred during saving changes", ex);
        result.recordFatalError("Couldn't save configuration changes.", ex);
    } finally {
        result.computeStatusIfUnknown();
        setResult(result);
    }
    if (parentPage.showSaveResultInPage(saved, result)) {
        parentPage.showResult(result);
    }
    configurationPropertiesModel.reset();
    updateConfigurationTabs();
}
Also used : Task(com.evolveum.midpoint.task.api.Task) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) ObjectDelta(com.evolveum.midpoint.prism.delta.ObjectDelta) ContainerWrapper(com.evolveum.midpoint.web.component.prism.ContainerWrapper) SchemaException(com.evolveum.midpoint.util.exception.SchemaException) ObjectNotFoundException(com.evolveum.midpoint.util.exception.ObjectNotFoundException) SystemException(com.evolveum.midpoint.util.exception.SystemException)

Example 10 with ObjectDelta

use of com.evolveum.midpoint.prism.delta.ObjectDelta in project midpoint by Evolveum.

the class RoleMemberPanel method removeMembersPerformed.

@Override
protected void removeMembersPerformed(QueryScope scope, AjaxRequestTarget target) {
    Task operationalTask = getPageBase().createSimpleTask(getTaskName("Remove", scope));
    ObjectDelta delta = prepareDelta(FocusType.COMPLEX_TYPE, null, MemberOperation.REMOVE, operationalTask.getResult());
    executeMemberOperation(operationalTask, FocusType.COMPLEX_TYPE, getActionQuery(scope), delta, TaskCategory.EXECUTE_CHANGES, target);
}
Also used : Task(com.evolveum.midpoint.task.api.Task) ObjectDelta(com.evolveum.midpoint.prism.delta.ObjectDelta)

Aggregations

ObjectDelta (com.evolveum.midpoint.prism.delta.ObjectDelta)445 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)363 Task (com.evolveum.midpoint.task.api.Task)326 Test (org.testng.annotations.Test)303 ObjectType (com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType)242 UserType (com.evolveum.midpoint.xml.ns._public.common.common_3.UserType)218 ShadowType (com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType)148 ArrayList (java.util.ArrayList)126 PolyString (com.evolveum.midpoint.prism.polystring.PolyString)103 SchemaException (com.evolveum.midpoint.util.exception.SchemaException)55 ItemPath (com.evolveum.midpoint.prism.path.ItemPath)47 ObjectNotFoundException (com.evolveum.midpoint.util.exception.ObjectNotFoundException)42 ReferenceDelta (com.evolveum.midpoint.prism.delta.ReferenceDelta)41 AbstractInitializedModelIntegrationTest (com.evolveum.midpoint.model.intest.AbstractInitializedModelIntegrationTest)38 ShadowDiscriminatorObjectDelta (com.evolveum.midpoint.common.refinery.ShadowDiscriminatorObjectDelta)32 ModelExecuteOptions (com.evolveum.midpoint.model.api.ModelExecuteOptions)31 ItemDelta (com.evolveum.midpoint.prism.delta.ItemDelta)31 Collection (java.util.Collection)31 XMLGregorianCalendar (javax.xml.datatype.XMLGregorianCalendar)31 ResourceType (com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType)26