Search in sources :

Example 16 with SystemConfigurationType

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

the class TestMachineIntelligence method test000Sanity.

@Test
public void test000Sanity() throws Exception {
    final String TEST_NAME = "test000Sanity";
    TestUtil.displayTestTile(this, TEST_NAME);
    Task task = taskManager.createTaskInstance(TestTrafo.class.getName() + "." + TEST_NAME);
    OperationResult result = modelService.testResource(RESOURCE_HR_OID, task);
    modifyObjectReplaceProperty(ResourceType.class, RESOURCE_HR_OID, new ItemPath(ResourceType.F_CONNECTOR_CONFIGURATION, SchemaConstants.ICF_CONFIGURATION_PROPERTIES, new QName(NS_RESOURCE_CSV, "filePath")), task, result, sourceFilePath);
    OperationResult testResultOpenDj = modelService.testResource(RESOURCE_HR_OID, task);
    TestUtil.assertSuccess(testResultOpenDj);
    SystemConfigurationType systemConfiguration = getSystemConfiguration();
    assertNotNull("No system configuration", systemConfiguration);
    display("System config", systemConfiguration);
}
Also used : Task(com.evolveum.midpoint.task.api.Task) QName(javax.xml.namespace.QName) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) SystemConfigurationType(com.evolveum.midpoint.xml.ns._public.common.common_3.SystemConfigurationType) ItemPath(com.evolveum.midpoint.prism.path.ItemPath) Test(org.testng.annotations.Test)

Example 17 with SystemConfigurationType

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

the class TestEntertainment method test000Sanity.

@Test
public void test000Sanity() throws Exception {
    final String TEST_NAME = "test000Sanity";
    displayTestTile(TEST_NAME);
    Task task = taskManager.createTaskInstance(TestTrafo.class.getName() + "." + TEST_NAME);
    OperationResult result = task.getResult();
    OperationResult testResultOpenDj = modelService.testResource(RESOURCE_OPENDJ_OID, task);
    assertSuccess(testResultOpenDj);
    SystemConfigurationType systemConfiguration = getSystemConfiguration();
    assertNotNull("No system configuration", systemConfiguration);
    display("System config", systemConfiguration);
    PrismObject<RoleType> metaRole = modelService.getObject(RoleType.class, ROLE_META_CREATE_ORG_GROUPS_OID, null, task, result);
    assertNotNull("No metarole, probably probelm with initialization", metaRole);
    result.computeStatus();
    assertSuccess("Role not fetch successfully", result);
}
Also used : Task(com.evolveum.midpoint.task.api.Task) RoleType(com.evolveum.midpoint.xml.ns._public.common.common_3.RoleType) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) SystemConfigurationType(com.evolveum.midpoint.xml.ns._public.common.common_3.SystemConfigurationType) Test(org.testng.annotations.Test)

Example 18 with SystemConfigurationType

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

the class TestLdap method initSystem.

@Override
public void initSystem(Task initTask, OperationResult initResult) throws Exception {
    super.initSystem(initTask, initResult);
    modelService.postInit(initResult);
    // System Configuration
    PrismObject<SystemConfigurationType> config;
    try {
        config = repoAddObjectFromFile(SYSTEM_CONFIGURATION_FILE, initResult);
    } catch (ObjectAlreadyExistsException e) {
        throw new ObjectAlreadyExistsException("System configuration already exists in repository;" + "looks like the previous test haven't cleaned it up", e);
    }
    // to get profiling facilities (until better API is available)
    //        LoggingConfigurationManager.configure(
    //                ProfilingConfigurationManager.checkSystemProfilingConfiguration(config),
    //                config.asObjectable().getVersion(), initResult);
    // administrator
    PrismObject<UserType> userAdministrator = repoAddObjectFromFile(USER_ADMINISTRATOR_FILE, initResult);
    repoAddObjectFromFile(ROLE_SUPERUSER_FILE, initResult);
    login(userAdministrator);
    // Users
    repoAddObjectFromFile(USER_BARBOSSA_FILE, initResult);
    repoAddObjectFromFile(USER_GUYBRUSH_FILE, initResult);
    // Roles
    repoAddObjectFromFile(ROLE_PIRATE_FILE, initResult);
    // Resources
    resourceOpenDj = importAndGetObjectFromFile(ResourceType.class, RESOURCE_OPENDJ_FILE, RESOURCE_OPENDJ_OID, initTask, initResult);
    resourceOpenDjType = resourceOpenDj.asObjectable();
    openDJController.setResource(resourceOpenDj);
    assumeAssignmentPolicy(AssignmentPolicyEnforcementType.RELATIVE);
    //initProfiling - start
    ProfilingDataManager profilingManager = ProfilingDataManager.getInstance();
    Map<ProfilingDataManager.Subsystem, Boolean> subsystems = new HashMap<>();
    subsystems.put(ProfilingDataManager.Subsystem.MODEL, true);
    subsystems.put(ProfilingDataManager.Subsystem.REPOSITORY, true);
    profilingManager.configureProfilingDataManagerForTest(subsystems, true);
    profilingManager.appendProfilingToTest();
    //initProfiling - end
    display("initial LDAP content", openDJController.dumpEntries());
}
Also used : ProfilingDataManager(com.evolveum.midpoint.util.aspect.ProfilingDataManager) HashMap(java.util.HashMap) SystemConfigurationType(com.evolveum.midpoint.xml.ns._public.common.common_3.SystemConfigurationType) ResourceType(com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType) ObjectAlreadyExistsException(com.evolveum.midpoint.util.exception.ObjectAlreadyExistsException) UserType(com.evolveum.midpoint.xml.ns._public.common.common_3.UserType)

Example 19 with SystemConfigurationType

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

the class NotificationManagerImpl method processEvent.

public void processEvent(@Nullable Event event, Task task, OperationResult result) {
    if (event == null) {
        return;
    }
    if (event instanceof BaseEvent) {
        ((BaseEvent) event).setNotificationFunctions(notificationFunctions);
    }
    LOGGER.trace("NotificationManager processing event {}", event);
    if (event.getAdHocHandler() != null) {
        processEvent(event, event.getAdHocHandler(), task, result);
    }
    SystemConfigurationType systemConfigurationType = NotificationFunctionsImpl.getSystemConfiguration(cacheRepositoryService, result);
    if (systemConfigurationType == null) {
        // something really wrong happened (or we are doing initial import of objects)
        return;
    }
    if (systemConfigurationType.getNotificationConfiguration() == null) {
        LOGGER.trace("No notification configuration in repository, finished event processing.");
        return;
    }
    NotificationConfigurationType notificationConfigurationType = systemConfigurationType.getNotificationConfiguration();
    processNotifications(notificationConfigurationType, event, task, result);
    LOGGER.trace("NotificationManager successfully processed event {} ({} top level handler(s))", event, notificationConfigurationType.getHandler().size());
}
Also used : NotificationConfigurationType(com.evolveum.midpoint.xml.ns._public.common.common_3.NotificationConfigurationType) BaseEvent(com.evolveum.midpoint.notifications.api.events.BaseEvent) SystemConfigurationType(com.evolveum.midpoint.xml.ns._public.common.common_3.SystemConfigurationType)

Example 20 with SystemConfigurationType

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

the class ClusterManager method checkSystemConfigurationChanged.

/**
     * Check whether system configuration has not changed in repository (e.g. by another node in cluster).
     * Applies new configuration if so.
     *
     * @param parentResult
     */
public void checkSystemConfigurationChanged(OperationResult parentResult) {
    OperationResult result = parentResult.createSubresult(CHECK_SYSTEM_CONFIGURATION_CHANGED);
    PrismObject<SystemConfigurationType> systemConfiguration;
    try {
        PrismObject<SystemConfigurationType> config = getRepositoryService().getObject(SystemConfigurationType.class, SystemObjectsType.SYSTEM_CONFIGURATION.value(), null, result);
        String versionInRepo = config.getVersion();
        String versionApplied = LoggingConfigurationManager.getCurrentlyUsedVersion();
        // we do not try to determine which one is "newer" - we simply use the one from repo
        if (!versionInRepo.equals(versionApplied)) {
            Configuration systemConfigFromFile = taskManager.getMidpointConfiguration().getConfiguration(MidpointConfiguration.SYSTEM_CONFIGURATION_SECTION);
            if (systemConfigFromFile != null && versionApplied == null && systemConfigFromFile.getBoolean(LoggingConfigurationManager.SYSTEM_CONFIGURATION_SKIP_REPOSITORY_LOGGING_SETTINGS, false)) {
                LOGGER.warn("Skipping application of repository logging configuration because {}=true (version={})", LoggingConfigurationManager.SYSTEM_CONFIGURATION_SKIP_REPOSITORY_LOGGING_SETTINGS, versionInRepo);
                // But pretend that this was applied so the next update works normally
                LoggingConfigurationManager.setCurrentlyUsedVersion(versionInRepo);
            } else {
                LoggingConfigurationType loggingConfig = ProfilingConfigurationManager.checkSystemProfilingConfiguration(config);
                LoggingConfigurationManager.configure(loggingConfig, versionInRepo, result);
            }
            SystemConfigurationHolder.setCurrentConfiguration(// we rely on LoggingConfigurationManager to correctly record the current version
            config.asObjectable());
            SecurityUtil.setRemoteHostAddressHeaders(config.asObjectable());
            getRepositoryService().applyFullTextSearchConfiguration(config.asObjectable().getFullTextSearch());
        } else {
            if (LOGGER.isTraceEnabled()) {
                LOGGER.trace("System configuration change check: version in repo = version currently applied = {}", versionApplied);
            }
        }
        if (result.isUnknown()) {
            result.computeStatus();
        }
    } catch (ObjectNotFoundException e) {
        // because the new config (if any) will have version number probably starting at 1 - so to be sure to read it when it comes [hope this never occurs :)]
        LoggingConfigurationManager.resetCurrentlyUsedVersion();
        String message = "No system configuration found, skipping application of system settings";
        LOGGER.error(message + ": " + e.getMessage(), e);
        result.recordWarning(message, e);
    } catch (SchemaException e) {
        String message = "Schema error in system configuration, skipping application of system settings";
        LOGGER.error(message + ": " + e.getMessage(), e);
        result.recordWarning(message, e);
    } catch (RuntimeException e) {
        String message = "Runtime exception in system configuration processing, skipping application of system settings";
        LOGGER.error(message + ": " + e.getMessage(), e);
        result.recordWarning(message, e);
    }
}
Also used : SchemaException(com.evolveum.midpoint.util.exception.SchemaException) MidpointConfiguration(com.evolveum.midpoint.common.configuration.api.MidpointConfiguration) Configuration(org.apache.commons.configuration.Configuration) ObjectNotFoundException(com.evolveum.midpoint.util.exception.ObjectNotFoundException) LoggingConfigurationType(com.evolveum.midpoint.xml.ns._public.common.common_3.LoggingConfigurationType) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) SystemConfigurationType(com.evolveum.midpoint.xml.ns._public.common.common_3.SystemConfigurationType)

Aggregations

SystemConfigurationType (com.evolveum.midpoint.xml.ns._public.common.common_3.SystemConfigurationType)40 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)28 Task (com.evolveum.midpoint.task.api.Task)14 Test (org.testng.annotations.Test)12 SchemaException (com.evolveum.midpoint.util.exception.SchemaException)11 ObjectNotFoundException (com.evolveum.midpoint.util.exception.ObjectNotFoundException)10 ObjectReferenceType (com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType)10 ObjectType (com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType)9 ObjectDelta (com.evolveum.midpoint.prism.delta.ObjectDelta)8 ObjectAlreadyExistsException (com.evolveum.midpoint.util.exception.ObjectAlreadyExistsException)8 LoggingConfigurationType (com.evolveum.midpoint.xml.ns._public.common.common_3.LoggingConfigurationType)8 ResourceType (com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType)8 LogfileTestTailer (com.evolveum.midpoint.test.util.LogfileTestTailer)7 UserType (com.evolveum.midpoint.xml.ns._public.common.common_3.UserType)7 PrismObject (com.evolveum.midpoint.prism.PrismObject)6 ConfigurationException (com.evolveum.midpoint.util.exception.ConfigurationException)6 ObjectPolicyConfigurationType (com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectPolicyConfigurationType)6 ValuePolicyType (com.evolveum.midpoint.xml.ns._public.common.common_3.ValuePolicyType)6 PolyString (com.evolveum.midpoint.prism.polystring.PolyString)5 ItemPath (com.evolveum.midpoint.prism.path.ItemPath)4