Search in sources :

Example 11 with Task

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());
}
Also used : SchemaException(com.evolveum.midpoint.util.exception.SchemaException) Task(com.evolveum.midpoint.task.api.Task) ExpressionEvaluationException(com.evolveum.midpoint.util.exception.ExpressionEvaluationException) CommunicationException(com.evolveum.midpoint.util.exception.CommunicationException) SecurityViolationException(com.evolveum.midpoint.util.exception.SecurityViolationException) ConfigurationException(com.evolveum.midpoint.util.exception.ConfigurationException) ObjectNotFoundException(com.evolveum.midpoint.util.exception.ObjectNotFoundException) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) ObjectDelta(com.evolveum.midpoint.prism.delta.ObjectDelta) PolicyViolationException(com.evolveum.midpoint.util.exception.PolicyViolationException) ObjectAlreadyExistsException(com.evolveum.midpoint.util.exception.ObjectAlreadyExistsException)

Example 12 with Task

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);
}
Also used : Task(com.evolveum.midpoint.task.api.Task)

Example 13 with Task

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;
}
Also used : Task(com.evolveum.midpoint.task.api.Task) ArrayList(java.util.ArrayList) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) ObjectQuery(com.evolveum.midpoint.prism.query.ObjectQuery) RestartResponseException(org.apache.wicket.RestartResponseException) ObjectType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType) PrismObject(com.evolveum.midpoint.prism.PrismObject) SelectorOptions(com.evolveum.midpoint.schema.SelectorOptions) RestartResponseException(org.apache.wicket.RestartResponseException) OrgType(com.evolveum.midpoint.xml.ns._public.common.common_3.OrgType) SelectableBean(com.evolveum.midpoint.web.component.util.SelectableBean)

Example 14 with Task

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);
}
Also used : SchemaException(com.evolveum.midpoint.util.exception.SchemaException) Task(com.evolveum.midpoint.task.api.Task) AssignmentType(com.evolveum.midpoint.xml.ns._public.common.common_3.AssignmentType) ArrayList(java.util.ArrayList) ItemDelta(com.evolveum.midpoint.prism.delta.ItemDelta) UserType(com.evolveum.midpoint.xml.ns._public.common.common_3.UserType)

Example 15 with Task

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;
        }
    });
}
Also used : SchemaException(com.evolveum.midpoint.util.exception.SchemaException) ObjectReferenceType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType) Task(com.evolveum.midpoint.task.api.Task) ContainerDelta(com.evolveum.midpoint.prism.delta.ContainerDelta) AssignmentType(com.evolveum.midpoint.xml.ns._public.common.common_3.AssignmentType) ArrayList(java.util.ArrayList) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) UserType(com.evolveum.midpoint.xml.ns._public.common.common_3.UserType)

Aggregations

Task (com.evolveum.midpoint.task.api.Task)4943 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)4698 Test (org.testng.annotations.Test)3991 AbstractInitializedModelIntegrationTest (com.evolveum.midpoint.model.intest.AbstractInitializedModelIntegrationTest)599 UserType (com.evolveum.midpoint.xml.ns._public.common.common_3.UserType)542 PolyString (com.evolveum.midpoint.prism.polystring.PolyString)464 PrismObject (com.evolveum.midpoint.prism.PrismObject)327 ObjectDelta (com.evolveum.midpoint.prism.delta.ObjectDelta)323 ShadowType (com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType)290 ObjectQuery (com.evolveum.midpoint.prism.query.ObjectQuery)282 ArrayList (java.util.ArrayList)249 QName (javax.xml.namespace.QName)208 SchemaException (com.evolveum.midpoint.util.exception.SchemaException)199 XMLGregorianCalendar (javax.xml.datatype.XMLGregorianCalendar)193 ItemPath (com.evolveum.midpoint.prism.path.ItemPath)175 DummyAccount (com.evolveum.icf.dummy.resource.DummyAccount)159 AbstractConfiguredModelIntegrationTest (com.evolveum.midpoint.model.intest.AbstractConfiguredModelIntegrationTest)140 AbstractModelIntegrationTest (com.evolveum.midpoint.model.test.AbstractModelIntegrationTest)123 SelectorOptions (com.evolveum.midpoint.schema.SelectorOptions)108 ObjectNotFoundException (com.evolveum.midpoint.util.exception.ObjectNotFoundException)108