Search in sources :

Example 86 with Task

use of com.evolveum.midpoint.task.api.Task in project midpoint by Evolveum.

the class PageSystemConfiguration method savePerformed.

private void savePerformed(AjaxRequestTarget target) {
    OperationResult result = new OperationResult(TASK_UPDATE_SYSTEM_CONFIG);
    String oid = SystemObjectsType.SYSTEM_CONFIGURATION.value();
    Task task = createSimpleTask(TASK_UPDATE_SYSTEM_CONFIG);
    try {
        SystemConfigurationType newObject = model.getObject().getNewObject();
        saveObjectPolicies(newObject);
        saveAdminGui(newObject);
        ObjectDelta<SystemConfigurationType> delta = DiffUtil.diff(model.getObject().getOldObject(), newObject);
        delta.normalize();
        if (LOGGER.isTraceEnabled()) {
            LOGGER.trace("System configuration delta:\n{}", delta.debugDump());
        }
        if (delta != null && !delta.isEmpty()) {
            getPrismContext().adopt(delta);
            getModelService().executeChanges(WebComponentUtil.createDeltaCollection(delta), null, task, result);
        }
        result.computeStatusIfUnknown();
    } catch (Exception e) {
        result.recomputeStatus();
        result.recordFatalError("Couldn't save system configuration.", e);
        LoggingUtils.logUnexpectedException(LOGGER, "Couldn't save system configuration.", e);
    }
    showResult(result);
    target.add(getFeedbackPanel());
    resetPerformed(target);
}
Also used : Task(com.evolveum.midpoint.task.api.Task) OperationResult(com.evolveum.midpoint.schema.result.OperationResult)

Example 87 with Task

use of com.evolveum.midpoint.task.api.Task in project midpoint by Evolveum.

the class ObjectPolicyPanel method createObjectTemplateList.

protected IModel<List<ObjectTemplateConfigTypeReferenceDto>> createObjectTemplateList() {
    return new AbstractReadOnlyModel<List<ObjectTemplateConfigTypeReferenceDto>>() {

        @Override
        public List<ObjectTemplateConfigTypeReferenceDto> getObject() {
            List<PrismObject<ObjectTemplateType>> templateList = null;
            List<ObjectTemplateConfigTypeReferenceDto> list = new ArrayList<>();
            OperationResult result = new OperationResult(OPERATION_LOAD_ALL_OBJECT_TEMPLATES);
            Task task = getPageBase().createSimpleTask(OPERATION_LOAD_ALL_OBJECT_TEMPLATES);
            try {
                templateList = getPageBase().getModelService().searchObjects(ObjectTemplateType.class, new ObjectQuery(), null, task, result);
                result.recomputeStatus();
            } catch (Exception e) {
                result.recordFatalError("Could not get list of object templates", e);
                LoggingUtils.logUnexpectedException(LOGGER, "Could not get list of object templates", e);
            // TODO - show this error in GUI
            }
            if (templateList != null) {
                ObjectTemplateType template;
                for (PrismObject<ObjectTemplateType> obj : templateList) {
                    template = obj.asObjectable();
                    list.add(new ObjectTemplateConfigTypeReferenceDto(template.getOid(), WebComponentUtil.getName(template)));
                }
            }
            return list;
        }
    };
}
Also used : AbstractReadOnlyModel(org.apache.wicket.model.AbstractReadOnlyModel) PrismObject(com.evolveum.midpoint.prism.PrismObject) ObjectTemplateConfigTypeReferenceDto(com.evolveum.midpoint.web.page.admin.configuration.dto.ObjectTemplateConfigTypeReferenceDto) Task(com.evolveum.midpoint.task.api.Task) ObjectTemplateType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectTemplateType) ArrayList(java.util.ArrayList) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) ObjectQuery(com.evolveum.midpoint.prism.query.ObjectQuery)

Example 88 with Task

use of com.evolveum.midpoint.task.api.Task in project midpoint by Evolveum.

the class PageDashboard method initInfoBoxes.

private void initInfoBoxes() {
    Task task = createSimpleTask("PageDashboard.infobox");
    OperationResult result = task.getResult();
    add(createFocusInfoBoxPanel(ID_INFO_BOX_USERS, UserType.class, "object-user-bg", GuiStyleConstants.CLASS_OBJECT_USER_ICON, "PageDashboard.infobox.users", PageUsers.class, result, task));
    add(createFocusInfoBoxPanel(ID_INFO_BOX_ORGS, OrgType.class, "object-org-bg", GuiStyleConstants.CLASS_OBJECT_ORG_ICON, "PageDashboard.infobox.orgs", PageOrgTree.class, result, task));
    add(createFocusInfoBoxPanel(ID_INFO_BOX_ROLES, RoleType.class, "object-role-bg", GuiStyleConstants.CLASS_OBJECT_ROLE_ICON, "PageDashboard.infobox.roles", PageRoles.class, result, task));
    add(createFocusInfoBoxPanel(ID_INFO_BOX_SERVICES, ServiceType.class, "object-service-bg", GuiStyleConstants.CLASS_OBJECT_SERVICE_ICON, "PageDashboard.infobox.services", PageServices.class, result, task));
    add(createResourceInfoBoxPanel(result, task));
    add(createTaskInfoBoxPanel(result, task));
}
Also used : PageOrgTree(com.evolveum.midpoint.web.page.admin.users.PageOrgTree) Task(com.evolveum.midpoint.task.api.Task) PageRoles(com.evolveum.midpoint.web.page.admin.roles.PageRoles) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) PageUsers(com.evolveum.midpoint.web.page.admin.users.PageUsers) PageServices(com.evolveum.midpoint.web.page.admin.services.PageServices)

Example 89 with Task

use of com.evolveum.midpoint.task.api.Task in project midpoint by Evolveum.

the class TestProjectorPersona method test100AssignRolePersonaAdminToJack.

@Test
public void test100AssignRolePersonaAdminToJack() throws Exception {
    final String TEST_NAME = "test100AssignRolePersonaAdminToJack";
    TestUtil.displayTestTile(this, TEST_NAME);
    // GIVEN
    Task task = taskManager.createTaskInstance(TestProjectorPersona.class.getName() + "." + TEST_NAME);
    OperationResult result = task.getResult();
    assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL);
    LensContext<UserType> context = createUserLensContext();
    fillContextWithUser(context, USER_JACK_OID, result);
    ObjectDelta<UserType> focusDelta = createAssignmentFocusDelta(UserType.class, USER_JACK_OID, ROLE_PERSONA_ADMIN_OID, RoleType.COMPLEX_TYPE, null, null, null, true);
    addFocusDeltaToContext(context, focusDelta);
    display("Input context", context);
    assertFocusModificationSanity(context);
    rememberShadowFetchOperationCount();
    // WHEN
    projector.project(context, "test", task, result);
    // THEN
    display("Output context", context);
    assertShadowFetchOperationCountIncrement(0);
    assertTrue(context.getFocusContext().getPrimaryDelta().getChangeType() == ChangeType.MODIFY);
    assertSideEffectiveDeltasOnly(context.getFocusContext().getSecondaryDelta(), "user secondary delta", ActivationStatusType.ENABLED);
    assertTrue("Unexpected projection changes", context.getProjectionContexts().isEmpty());
    DeltaSetTriple<EvaluatedAssignmentImpl<?>> evaluatedAssignmentTriple = context.getEvaluatedAssignmentTriple();
    assertNotNull("No evaluatedAssignmentTriple", evaluatedAssignmentTriple);
    assertTrue("Unexpected evaluatedAssignmentTriple zero set", evaluatedAssignmentTriple.getZeroSet().isEmpty());
    assertTrue("Unexpected evaluatedAssignmentTriple minus set", evaluatedAssignmentTriple.getMinusSet().isEmpty());
    assertNotNull("No evaluatedAssignmentTriple plus set", evaluatedAssignmentTriple.getPlusSet());
    assertEquals("Wrong size of evaluatedAssignmentTriple plus set", 1, evaluatedAssignmentTriple.getPlusSet().size());
    EvaluatedAssignmentImpl<UserType> evaluatedAssignment = (EvaluatedAssignmentImpl<UserType>) evaluatedAssignmentTriple.getPlusSet().iterator().next();
    display("evaluatedAssignment", evaluatedAssignment);
    assertNotNull("No evaluatedAssignment", evaluatedAssignment);
    DeltaSetTriple<PersonaConstruction<UserType>> personaConstructionTriple = evaluatedAssignment.getPersonaConstructionTriple();
    display("personaConstructionTriple", personaConstructionTriple);
    assertNotNull("No personaConstructionTriple", personaConstructionTriple);
    assertFalse("Empty personaConstructionTriple", personaConstructionTriple.isEmpty());
    assertTrue("Unexpected personaConstructionTriple plus set", personaConstructionTriple.getPlusSet().isEmpty());
    assertTrue("Unexpected personaConstructionTriple minus set", personaConstructionTriple.getMinusSet().isEmpty());
    assertNotNull("No personaConstructionTriple zero set", personaConstructionTriple.getZeroSet());
    assertEquals("Wrong size of personaConstructionTriple zero set", 1, personaConstructionTriple.getZeroSet().size());
    PersonaConstruction<UserType> personaConstruction = personaConstructionTriple.getZeroSet().iterator().next();
    assertNotNull("No personaConstruction", personaConstruction);
    PersonaConstructionType personaConstructionType = personaConstruction.getConstructionType();
    assertNotNull("No personaConstructionType", personaConstructionType);
    assertTrue("Wrong type: " + personaConstructionType.getTargetType(), QNameUtil.match(UserType.COMPLEX_TYPE, personaConstructionType.getTargetType()));
    PrismAsserts.assertEqualsCollectionUnordered("Wrong subtype", personaConstructionType.getTargetSubtype(), "admin");
}
Also used : Task(com.evolveum.midpoint.task.api.Task) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) PersonaConstructionType(com.evolveum.midpoint.xml.ns._public.common.common_3.PersonaConstructionType) UserType(com.evolveum.midpoint.xml.ns._public.common.common_3.UserType) Test(org.testng.annotations.Test)

Example 90 with Task

use of com.evolveum.midpoint.task.api.Task in project midpoint by Evolveum.

the class TestCorrelationConfiramtionEvaluator method test005CorrelationMatchCaseInsensitive.

@Test
public void test005CorrelationMatchCaseInsensitive() throws Exception {
    String TEST_NAME = "test005CorrelationMatchCaseInsensitive";
    TestUtil.displayTestTile(this, TEST_NAME);
    Task task = taskManager.createTaskInstance(TEST_NAME);
    OperationResult result = task.getResult();
    //		importObjectFromFile(USER_JACK_FILENAME);
    PrismObject<UserType> userType = repositoryService.getObject(UserType.class, USER_JACK_OID, null, result);
    //assert jack
    assertNotNull(userType);
    ShadowType shadow = parseObjectType(ACCOUNT_SHADOW_JACK_DUMMY_FILE, ShadowType.class);
    ConditionalSearchFilterType query = PrismTestUtil.parseAtomicValue(new File(CORRELATION_CASE_INSENSITIVE_EMPL_NUMBER), ConditionalSearchFilterType.COMPLEX_TYPE);
    //		ObjectQuery query = ObjectQuery.createObjectQuery(EqualsFilter.createEqual(null, userType.getDefinition().findItemDefinition(UserType.F_EMPLOYEE_NUMBER), "stringIgnoreCase", "ps1234"));
    //		List<QueryType> queries = new ArrayList<QueryType>();
    //		queries.add(query);
    //		
    ResourceType resourceType = parseObjectType(RESOURCE_DUMMY_FILE, ResourceType.class);
    resourceType.getSynchronization().getObjectSynchronization().get(0).getCorrelation().clear();
    resourceType.getSynchronization().getObjectSynchronization().get(0).getCorrelation().add(query);
    userType.asObjectable().setEmployeeNumber("JaCk");
    ObjectSynchronizationType objectSynchronizationType = resourceType.getSynchronization().getObjectSynchronization().get(0);
    try {
        boolean matchedUsers = evaluator.matchUserCorrelationRule(UserType.class, shadow.asPrismObject(), userType, objectSynchronizationType, resourceType, getSystemConfiguration(), task, result);
        System.out.println("matched users " + matchedUsers);
        AssertJUnit.assertTrue(matchedUsers);
    } catch (Exception ex) {
        LOGGER.error("exception occured: {}", ex.getMessage(), ex);
        throw ex;
    }
//		assertNotNull("Correlation evaluator returned null collection of matched users.", matchedUsers);
//		assertEquals("Found more than one user.", 1, matchedUsers.size());
//		
//		PrismObject<UserType> jack = matchedUsers.get(0);
//		assertUser(jack, "c0c010c0-d34d-b33f-f00d-111111111111", "jack", "Jack Sparrow", "Jack", "Sparrow");
}
Also used : Task(com.evolveum.midpoint.task.api.Task) ObjectSynchronizationType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectSynchronizationType) ShadowType(com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType) ConditionalSearchFilterType(com.evolveum.midpoint.xml.ns._public.common.common_3.ConditionalSearchFilterType) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) ResourceType(com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType) PolyString(com.evolveum.midpoint.prism.polystring.PolyString) UserType(com.evolveum.midpoint.xml.ns._public.common.common_3.UserType) File(java.io.File) Test(org.testng.annotations.Test) AbstractInternalModelIntegrationTest(com.evolveum.midpoint.model.impl.AbstractInternalModelIntegrationTest)

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