Search in sources :

Example 1 with ObjectReferenceType

use of com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType 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)

Example 2 with ObjectReferenceType

use of com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType in project midpoint by Evolveum.

the class PageSelfRegistration method initDynamicFormLayout.

private void initDynamicFormLayout(final Form<?> mainForm) {
    WebMarkupContainer dynamicRegistrationForm = createMarkupContainer(ID_DYNAMIC_FORM, new VisibleEnableBehaviour() {

        private static final long serialVersionUID = 1L;

        @Override
        public boolean isVisible() {
            return getSelfRegistrationConfiguration().getFormRef() != null;
        }
    }, mainForm);
    DynamicFormPanel<UserType> dynamicForm = runPrivileged(() -> {
        final ObjectReferenceType ort = getSelfRegistrationConfiguration().getFormRef();
        if (ort == null) {
            return null;
        }
        Task task = createAnonymousTask(OPERATION_LOAD_DYNAMIC_FORM);
        return new DynamicFormPanel<UserType>(ID_DYNAMIC_FORM_PANEL, userModel, ort.getOid(), mainForm, task, PageSelfRegistration.this);
    });
    if (dynamicForm != null) {
        dynamicRegistrationForm.add(dynamicForm);
    }
}
Also used : ObjectReferenceType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType) Task(com.evolveum.midpoint.task.api.Task) DynamicFormPanel(com.evolveum.midpoint.web.component.prism.DynamicFormPanel) VisibleEnableBehaviour(com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour) UserType(com.evolveum.midpoint.xml.ns._public.common.common_3.UserType) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer)

Example 3 with ObjectReferenceType

use of com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType in project midpoint by Evolveum.

the class PageAdminResources method deleteSyncTokenPerformed.

protected void deleteSyncTokenPerformed(AjaxRequestTarget target, ResourceType resourceType) {
    //        ResourceDto dto = model.getObject();
    String resourceOid = resourceType.getOid();
    String handlerUri = "http://midpoint.evolveum.com/xml/ns/public/model/synchronization/task/live-sync/handler-3";
    ObjectReferenceType resourceRef = new ObjectReferenceType();
    resourceRef.setOid(resourceOid);
    PrismObject<TaskType> oldTask;
    OperationResult result = new OperationResult(OPERATION_DELETE_SYNC_TOKEN);
    ObjectQuery query = QueryBuilder.queryFor(TaskType.class, getPrismContext()).item(TaskType.F_OBJECT_REF).ref(resourceOid).and().item(TaskType.F_HANDLER_URI).eq(handlerUri).build();
    List<PrismObject<TaskType>> taskList = WebModelServiceUtils.searchObjects(TaskType.class, query, result, this);
    if (taskList.size() != 1) {
        error(getString("pageResource.message.invalidTaskSearch"));
    } else {
        oldTask = taskList.get(0);
        saveTask(oldTask, result);
    }
    result.recomputeStatus();
    showResult(result);
    target.add(getFeedbackPanel());
}
Also used : PrismObject(com.evolveum.midpoint.prism.PrismObject) ObjectReferenceType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType) TaskType(com.evolveum.midpoint.xml.ns._public.common.common_3.TaskType) OperationResult(com.evolveum.midpoint.schema.result.OperationResult)

Example 4 with ObjectReferenceType

use of com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType in project midpoint by Evolveum.

the class MidPointAsserts method assertAssignments.

public static <F extends FocusType> void assertAssignments(PrismObject<F> user, Class expectedType, int expectedNumber) {
    F userType = user.asObjectable();
    int actualAssignments = 0;
    List<AssignmentType> assignments = userType.getAssignment();
    for (AssignmentType assignment : assignments) {
        ObjectReferenceType targetRef = assignment.getTargetRef();
        if (targetRef != null) {
            QName type = targetRef.getType();
            if (type != null) {
                Class<? extends ObjectType> assignmentTargetClass = ObjectTypes.getObjectTypeFromTypeQName(type).getClassDefinition();
                if (expectedType.isAssignableFrom(assignmentTargetClass)) {
                    actualAssignments++;
                }
            }
        }
    }
    assertEquals("Unexepected number of assignments of type " + expectedType + " in " + user + ": " + userType.getAssignment(), expectedNumber, actualAssignments);
}
Also used : ObjectReferenceType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType) QName(javax.xml.namespace.QName) AssignmentType(com.evolveum.midpoint.xml.ns._public.common.common_3.AssignmentType)

Example 5 with ObjectReferenceType

use of com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType in project midpoint by Evolveum.

the class MidPointAsserts method assertAssignedResource.

public static <F extends FocusType> void assertAssignedResource(PrismObject<F> user, String resourceOid) {
    F userType = user.asObjectable();
    for (AssignmentType assignmentType : userType.getAssignment()) {
        if (assignmentType.getConstruction() == null) {
            continue;
        }
        ObjectReferenceType targetRef = assignmentType.getConstruction().getResourceRef();
        if (targetRef != null) {
            if (resourceOid.equals(targetRef.getOid())) {
                return;
            }
        }
    }
    AssertJUnit.fail(user + " does NOT have assigned resource " + resourceOid + " while expecting it");
}
Also used : ObjectReferenceType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType) AssignmentType(com.evolveum.midpoint.xml.ns._public.common.common_3.AssignmentType)

Aggregations

ObjectReferenceType (com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType)278 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)104 UserType (com.evolveum.midpoint.xml.ns._public.common.common_3.UserType)61 Test (org.testng.annotations.Test)61 ShadowType (com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType)56 Task (com.evolveum.midpoint.task.api.Task)53 QName (javax.xml.namespace.QName)46 ArrayList (java.util.ArrayList)44 AbstractModelIntegrationTest (com.evolveum.midpoint.model.test.AbstractModelIntegrationTest)42 PrismAsserts.assertEqualsPolyString (com.evolveum.midpoint.prism.util.PrismAsserts.assertEqualsPolyString)37 OperationResultType (com.evolveum.midpoint.xml.ns._public.common.common_3.OperationResultType)33 AssignmentType (com.evolveum.midpoint.xml.ns._public.common.common_3.AssignmentType)32 ObjectType (com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType)32 ObjectDeltaType (com.evolveum.prism.xml.ns._public.types_3.ObjectDeltaType)31 SchemaException (com.evolveum.midpoint.util.exception.SchemaException)30 ChangeRecordEntry (org.opends.server.util.ChangeRecordEntry)30 ItemPath (com.evolveum.midpoint.prism.path.ItemPath)26 PolyString (com.evolveum.midpoint.prism.polystring.PolyString)26 ObjectQuery (com.evolveum.midpoint.prism.query.ObjectQuery)23 List (java.util.List)23