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();
}
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();
}
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();
}
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();
}
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);
}
Aggregations