use of com.evolveum.midpoint.task.api.Task in project midpoint by Evolveum.
the class OrgMemberPanel method deleteManagerConfirmPerformed.
private void deleteManagerConfirmPerformed(FocusType manager, AjaxRequestTarget target) {
getPageBase().hideMainPopup(target);
OperationResult parentResult = new OperationResult("Remove manager");
Task task = getPageBase().createSimpleTask("Remove manager");
try {
ObjectDelta delta = ObjectDelta.createDeleteDelta(manager.asPrismObject().getCompileTimeClass(), manager.getOid(), getPageBase().getPrismContext());
getPageBase().getModelService().executeChanges(WebComponentUtil.createDeltaCollection(delta), null, task, parentResult);
parentResult.computeStatus();
} catch (SchemaException | ObjectAlreadyExistsException | ObjectNotFoundException | ExpressionEvaluationException | CommunicationException | ConfigurationException | PolicyViolationException | SecurityViolationException e) {
parentResult.recordFatalError("Failed to remove manager " + e.getMessage(), e);
LoggingUtils.logUnexpectedException(LOGGER, "Failed to remove manager", e);
getPageBase().showResult(parentResult);
}
target.add(getPageBase().getFeedbackPanel());
}
use of com.evolveum.midpoint.task.api.Task in project midpoint by Evolveum.
the class OrgMemberPanel method recomputeManagersPerformed.
protected void recomputeManagersPerformed(QueryScope scope, AjaxRequestTarget target) {
Task operationalTask = getPageBase().createSimpleTask(getTaskName("Recompute", scope, true));
executeMemberOperation(operationalTask, FocusType.COMPLEX_TYPE, createQueryForMemberAction(scope, SchemaConstants.ORG_MANAGER, true), null, TaskCategory.RECOMPUTATION, target);
}
use of com.evolveum.midpoint.task.api.Task in project midpoint by Evolveum.
the class OrgTreeProvider method getChildren.
@Override
public Iterator<? extends SelectableBean<OrgType>> getChildren(SelectableBean<OrgType> node) {
// getAvailableData().clear();
LOGGER.debug("Loading children for {}", new Object[] { node });
Iterator<SelectableBean<OrgType>> iterator = null;
ObjectQuery query = QueryBuilder.queryFor(ObjectType.class, getPageBase().getPrismContext()).isDirectChildOf(// TODO what if getValue==null
node.getValue().getOid()).asc(ObjectType.F_NAME).build();
OperationResult result = new OperationResult(LOAD_ORG_UNITS);
try {
// Collection<SelectorOptions<GetOperationOptions>> options = WebModelServiceUtils.createOptionsForParentOrgRefs();
Collection<SelectorOptions<GetOperationOptions>> options = null;
Task task = getPageBase().createSimpleTask(LOAD_ORG_UNITS);
List<PrismObject<OrgType>> units = getModelService().searchObjects(OrgType.class, query, options, task, result);
LOGGER.debug("Found {} units.", units.size());
List<SelectableBean<OrgType>> list = new ArrayList<SelectableBean<OrgType>>();
for (PrismObject<OrgType> unit : units) {
SelectableBean<OrgType> selectable = createObjectWrapper(node, unit);
list.add(selectable);
// if (getAvailableData().contains(selectable)){
// getAvailableData().remove(selectable);
// }
// getAvailableData().add(selectable);
}
getAvailableData().addAll(list);
// Collections.sort(list);
iterator = list.iterator();
} catch (Exception ex) {
LoggingUtils.logUnexpectedException(LOGGER, "Couldn't load children", ex);
result.recordFatalError("Unable to load org unit", ex);
} finally {
result.computeStatus();
}
if (WebComponentUtil.showResultInPage(result)) {
getPageBase().showResult(result);
throw new RestartResponseException(PageOrgTree.class);
}
if (iterator == null) {
iterator = new ArrayList<SelectableBean<OrgType>>().iterator();
}
LOGGER.debug("Finished loading children.");
return iterator;
}
use of com.evolveum.midpoint.task.api.Task in project midpoint by Evolveum.
the class PageRegistrationConfirmation method assignAdditionalRoleIfPresent.
private OperationResult assignAdditionalRoleIfPresent(String userOid, NonceType nonceType, OperationResult result) {
// SecurityContextHolder.getContext().setAuthentication(token);
return runPrivileged(() -> {
List<ItemDelta> userDeltas = new ArrayList<>();
if (nonceType.getName() != null) {
Task task = createAnonymousTask(OPERATION_FINISH_REGISTRATION);
ObjectDelta<UserType> assignRoleDelta = null;
try {
AssignmentType assignment = new AssignmentType();
assignment.setTargetRef(ObjectTypeUtil.createObjectRef(nonceType.getName(), ObjectTypes.ABSTRACT_ROLE));
getPrismContext().adopt(assignment);
userDeltas.add((ItemDelta) ContainerDelta.createModificationAdd(UserType.F_ASSIGNMENT, UserType.class, getPrismContext(), assignment));
assignRoleDelta = ObjectDelta.createModifyDelta(userOid, userDeltas, UserType.class, getPrismContext());
assignRoleDelta.setPrismContext(getPrismContext());
} catch (SchemaException e) {
result.recordFatalError("Could not create delta");
return result;
}
WebModelServiceUtils.save(assignRoleDelta, result, task, PageRegistrationConfirmation.this);
result.computeStatusIfUnknown();
}
return result;
});
// SecurityContextHolder.getContext().setAuthentication(null);
}
use of com.evolveum.midpoint.task.api.Task in project midpoint by Evolveum.
the class PageRegistrationConfirmation method assignDefaultRoles.
private OperationResult assignDefaultRoles(final String userOid) {
List<ContainerDelta<AssignmentType>> assignments = new ArrayList<>();
for (ObjectReferenceType defaultRole : getSelfRegistrationConfiguration().getDefaultRoles()) {
AssignmentType assignment = new AssignmentType();
assignment.setTargetRef(defaultRole);
try {
getPrismContext().adopt(assignment);
assignments.add(ContainerDelta.createModificationAdd(UserType.F_ASSIGNMENT, UserType.class, getPrismContext(), assignment));
} catch (SchemaException e) {
//nothing to do
}
}
final ObjectDelta<UserType> delta = ObjectDelta.createModifyDelta(userOid, assignments, UserType.class, getPrismContext());
return runPrivileged(new Producer<OperationResult>() {
@Override
public OperationResult run() {
OperationResult result = new OperationResult(OPERATION_ASSIGN_DEFAULT_ROLES);
Task task = createAnonymousTask(OPERATION_ASSIGN_DEFAULT_ROLES);
WebModelServiceUtils.save(delta, result, task, PageRegistrationConfirmation.this);
result.computeStatusIfUnknown();
return result;
}
});
}
Aggregations