Search in sources :

Example 1 with ExecuteChangeOptionsDto

use of com.evolveum.midpoint.web.page.admin.users.component.ExecuteChangeOptionsDto 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 2 with ExecuteChangeOptionsDto

use of com.evolveum.midpoint.web.page.admin.users.component.ExecuteChangeOptionsDto in project midpoint by Evolveum.

the class MainObjectListPanel method deleteConfirmedPerformed.

private void deleteConfirmedPerformed(AjaxRequestTarget target, O objectToDelete) {
    List<O> objects = isAnythingSelected(target, objectToDelete);
    if (objects.isEmpty()) {
        return;
    }
    OperationResult result = new OperationResult(objects.size() == 1 ? OPERATION_DELETE_OBJECT : OPERATION_DELETE_OBJECTS);
    for (O object : objects) {
        OperationResult subResult = result.createSubresult(OPERATION_DELETE_OBJECT);
        try {
            Task task = getPageBase().createSimpleTask(OPERATION_DELETE_OBJECT);
            ObjectDelta delta = getPrismContext().deltaFactory().object().create(objectToDelete.getClass(), ChangeType.DELETE);
            delta.setOid(object.getOid());
            ExecuteChangeOptionsDto executeOptions = getExecuteOptions();
            ModelExecuteOptions options = executeOptions.createOptions(getPrismContext());
            LOGGER.debug("Using options {}.", executeOptions);
            getPageBase().getModelService().executeChanges(MiscUtil.createCollection(delta), options, task, subResult);
            subResult.computeStatus();
        } catch (Exception ex) {
            subResult.recomputeStatus();
            subResult.recordFatalError(getString("PageUsers.message.delete.fatalError"), ex);
            LoggingUtils.logUnexpectedException(LOGGER, "Couldn't delete user", ex);
        }
    }
    result.computeStatusComposite();
    clearCache();
    getPageBase().showResult(result);
    target.add(getFeedbackPanel());
    refreshTable(target);
    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) SchemaException(com.evolveum.midpoint.util.exception.SchemaException) RestartResponseException(org.apache.wicket.RestartResponseException)

Example 3 with ExecuteChangeOptionsDto

use of com.evolveum.midpoint.web.page.admin.users.component.ExecuteChangeOptionsDto in project midpoint by Evolveum.

the class PageUsers method updateActivationPerformed.

/**
 * This method updates user activation. If userOid parameter is not null,
 * than it updates only that user, otherwise it checks table for selected
 * users.
 */
private void updateActivationPerformed(AjaxRequestTarget target, boolean enabling, UserType selectedUser) {
    List<UserType> users = getTable().isAnythingSelected(target, selectedUser);
    if (users.isEmpty()) {
        return;
    }
    String operation = enabling ? OPERATION_ENABLE_USERS : OPERATION_DISABLE_USERS;
    OperationResult result = new OperationResult(operation);
    for (UserType user : users) {
        operation = enabling ? OPERATION_ENABLE_USER : OPERATION_DISABLE_USER;
        OperationResult subResult = result.createSubresult(operation);
        try {
            Task task = createSimpleTask(operation);
            ObjectDelta objectDelta = WebModelServiceUtils.createActivationAdminStatusDelta(UserType.class, user.getOid(), enabling, getPrismContext());
            ExecuteChangeOptionsDto executeOptions = getTable().getExecuteOptions();
            ModelExecuteOptions options = executeOptions.createOptions(getPrismContext());
            LOGGER.debug("Using options {}.", executeOptions);
            getModelService().executeChanges(MiscUtil.createCollection(objectDelta), options, task, subResult);
            subResult.recordSuccess();
        } catch (Exception ex) {
            subResult.recomputeStatus();
            if (enabling) {
                subResult.recordFatalError(getString("PageUsers.message.enable.fatalError"), ex);
                LoggingUtils.logUnexpectedException(LOGGER, "Couldn't enable user", ex);
            } else {
                subResult.recordFatalError(getString("PageUsers.message.disable.fatalError"), ex);
                LoggingUtils.logUnexpectedException(LOGGER, "Couldn't disable user", ex);
            }
        }
    }
    result.recomputeStatus();
    showResult(result);
    target.add(getFeedbackPanel());
    getTable().clearCache();
    getTable().refreshTable(target);
}
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) SchemaException(com.evolveum.midpoint.util.exception.SchemaException) ObjectNotFoundException(com.evolveum.midpoint.util.exception.ObjectNotFoundException)

Example 4 with ExecuteChangeOptionsDto

use of com.evolveum.midpoint.web.page.admin.users.component.ExecuteChangeOptionsDto in project midpoint by Evolveum.

the class AbstractPageObjectDetails method saveOrPreviewPerformed.

// private ObjectDelta<O> delta;
public Collection<ObjectDeltaOperation<? extends ObjectType>> saveOrPreviewPerformed(AjaxRequestTarget target, OperationResult result, boolean previewOnly, Task task) {
    PrismObjectWrapper<O> objectWrapper = getModelWrapperObject();
    LOGGER.debug("Saving object {}", objectWrapper);
    if (task == null) {
        task = createSimpleTask(OPERATION_SEND_TO_SUBMIT);
    }
    ExecuteChangeOptionsDto options = getExecuteChangesOptionsDto();
    Collection<ObjectDelta<? extends ObjectType>> deltas;
    try {
        deltas = objectDetailsModels.collectDeltas(result);
        checkValidationErrors(target, objectDetailsModels.getValidationErrors());
    } catch (Throwable ex) {
        result.recordFatalError(getString("pageAdminObjectDetails.message.cantCreateObject"), ex);
        LoggingUtils.logUnexpectedException(LOGGER, "Create Object failed", ex);
        showResult(result);
        target.add(getFeedbackPanel());
        return null;
    }
    LOGGER.trace("returning from saveOrPreviewPerformed");
    Collection<ObjectDeltaOperation<? extends ObjectType>> executedDeltas = executeChanges(deltas, previewOnly, options, task, result, target);
    postProcessResult(result, executedDeltas, target);
    return executedDeltas;
}
Also used : ObjectDeltaOperation(com.evolveum.midpoint.schema.ObjectDeltaOperation) ExecuteChangeOptionsDto(com.evolveum.midpoint.web.page.admin.users.component.ExecuteChangeOptionsDto) ObjectDelta(com.evolveum.midpoint.prism.delta.ObjectDelta)

Aggregations

ObjectDelta (com.evolveum.midpoint.prism.delta.ObjectDelta)4 ExecuteChangeOptionsDto (com.evolveum.midpoint.web.page.admin.users.component.ExecuteChangeOptionsDto)4 ModelExecuteOptions (com.evolveum.midpoint.model.api.ModelExecuteOptions)3 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)3 Task (com.evolveum.midpoint.task.api.Task)3 SchemaException (com.evolveum.midpoint.util.exception.SchemaException)2 ObjectDeltaOperation (com.evolveum.midpoint.schema.ObjectDeltaOperation)1 ObjectNotFoundException (com.evolveum.midpoint.util.exception.ObjectNotFoundException)1 RestartResponseException (org.apache.wicket.RestartResponseException)1