Search in sources :

Example 1 with ProjectionPolicyType

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

the class SystemConfigurationDto method getNewObject.

public SystemConfigurationType getNewObject() throws DatatypeConfigurationException {
    SystemConfigurationType newObject = oldObject.clone();
    if (StringUtils.isNotBlank(getPassPolicyDto().getOid())) {
        ObjectReferenceType globalPassPolicyRef = ObjectTypeUtil.createObjectRef(getPassPolicyDto().getOid(), ObjectTypes.PASSWORD_POLICY);
        newObject.setGlobalPasswordPolicyRef(globalPassPolicyRef);
    } else {
        newObject.setGlobalPasswordPolicyRef(null);
    }
    if (StringUtils.isNotBlank(getSecurityPolicyDto().getOid())) {
        ObjectReferenceType globalSecurityPolicyRef = ObjectTypeUtil.createObjectRef(getSecurityPolicyDto().getOid(), WebComponentUtil.createPolyFromOrigString(getSecurityPolicyDto().getName()), ObjectTypes.SECURITY_POLICY);
        newObject.setGlobalSecurityPolicyRef(globalSecurityPolicyRef);
    } else {
        newObject.setGlobalSecurityPolicyRef(null);
    }
    AssignmentPolicyEnforcementType globalAEP = AEPlevel.toAEPValueType(getAepLevel());
    if (globalAEP != null) {
        ProjectionPolicyType projectionPolicy = new ProjectionPolicyType();
        projectionPolicy.setAssignmentPolicyEnforcement(globalAEP);
        newObject.setGlobalAccountSynchronizationSettings(projectionPolicy);
    }
    Duration auditCleanupDuration = DatatypeFactory.newInstance().newDuration(getAuditCleanupValue());
    Duration cleanupTaskDuration = DatatypeFactory.newInstance().newDuration(getTaskCleanupValue());
    CleanupPolicyType auditCleanup = new CleanupPolicyType();
    CleanupPolicyType taskCleanup = new CleanupPolicyType();
    auditCleanup.setMaxAge(auditCleanupDuration);
    taskCleanup.setMaxAge(cleanupTaskDuration);
    CleanupPoliciesType cleanupPolicies = new CleanupPoliciesType();
    cleanupPolicies.setAuditRecords(auditCleanup);
    cleanupPolicies.setClosedTasks(taskCleanup);
    newObject.setCleanupPolicy(cleanupPolicies);
    SystemConfigurationTypeUtil.setEnableExperimentalCode(newObject, getEnableExperimentalCode());
    newObject.setLogging(loggingConfig.getNewObject());
    newObject.setNotificationConfiguration(notificationConfig.getNewObject(newObject));
    newObject.setProfilingConfiguration(profilingDto.getNewObject());
    ClassLoggerConfigurationType profilingClassLogger = profilingDto.getProfilingClassLogerConfig();
    if (newObject.getLogging() != null) {
        newObject.getLogging().getClassLogger().add(profilingClassLogger);
    } else {
        LoggingConfigurationType profLogging = new LoggingConfigurationType();
        profLogging.getClassLogger().add(profilingClassLogger);
        newObject.setLogging(profLogging);
    }
    return newObject;
}
Also used : ObjectReferenceType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType) CleanupPolicyType(com.evolveum.midpoint.xml.ns._public.common.common_3.CleanupPolicyType) LoggingConfigurationType(com.evolveum.midpoint.xml.ns._public.common.common_3.LoggingConfigurationType) AssignmentPolicyEnforcementType(com.evolveum.midpoint.xml.ns._public.common.common_3.AssignmentPolicyEnforcementType) CleanupPoliciesType(com.evolveum.midpoint.xml.ns._public.common.common_3.CleanupPoliciesType) SystemConfigurationType(com.evolveum.midpoint.xml.ns._public.common.common_3.SystemConfigurationType) Duration(javax.xml.datatype.Duration) ClassLoggerConfigurationType(com.evolveum.midpoint.xml.ns._public.common.common_3.ClassLoggerConfigurationType) ProjectionPolicyType(com.evolveum.midpoint.xml.ns._public.common.common_3.ProjectionPolicyType)

Example 2 with ProjectionPolicyType

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

the class TestDummyResourceAndSchemaCaching method test023ModifyRepoAndGetResource.

/**
	 * Change resource directly in repo. This simulates the change done by other node. The connector cache should
	 * be refreshed.
	 * 
	 * Change something that is not important. The cached resource should be refreshed, the schema re-parsed
	 * but the connector should still be cached.
	 */
@Test
public void test023ModifyRepoAndGetResource() throws Exception {
    final String TEST_NAME = "test023ModifyRepoAndGetResource";
    TestUtil.displayTestTile(TEST_NAME);
    // GIVEN
    Task task = taskManager.createTaskInstance(TestDummyResourceAndSchemaCaching.class.getName() + "." + TEST_NAME);
    OperationResult result = task.getResult();
    // Change something that's not that important
    ProjectionPolicyType accountSynchronizationSettingsType = new ProjectionPolicyType();
    accountSynchronizationSettingsType.setLegalize(true);
    ObjectDelta<ResourceType> objectDelta = ObjectDelta.createModificationReplaceProperty(ResourceType.class, RESOURCE_DUMMY_OID, ResourceType.F_PROJECTION, prismContext, accountSynchronizationSettingsType);
    // WHEN
    repositoryService.modifyObject(ResourceType.class, RESOURCE_DUMMY_OID, objectDelta.getModifications(), result);
    // THEN
    result.computeStatus();
    TestUtil.assertSuccess(result);
    String versionAfter = repositoryService.getVersion(ResourceType.class, RESOURCE_DUMMY_OID, result);
    assertResourceVersionIncrement(versionAfter, 1);
    // WHEN
    PrismObject<ResourceType> resourceProvisioning = provisioningService.getObject(ResourceType.class, RESOURCE_DUMMY_OID, null, task, result);
    // THEN
    display("Resource", resource);
    result.computeStatus();
    TestUtil.assertSuccess(result);
    assertHasSchema(resourceProvisioning, "provisioning resource");
    assertSchemaMetadataUnchanged(resourceProvisioning);
    assertResourceSchemaFetchIncrement(0);
    assertConnectorSchemaParseIncrement(0);
    assertConnectorCapabilitiesFetchIncrement(0);
    assertConnectorInitializationCountIncrement(0);
    assertResourceSchemaParseCountIncrement(1);
    assertResourceVersionIncrement(resourceProvisioning, 0);
    display("Resource cache", InternalMonitor.getResourceCacheStats());
    assertResourceCacheHitsIncrement(0);
    assertResourceCacheMissesIncrement(1);
    // There are expected to be re-parsed
    rememberResourceSchema(RefinedResourceSchemaImpl.getResourceSchema(resourceProvisioning, prismContext));
    rememberRefinedResourceSchema(RefinedResourceSchemaImpl.getRefinedSchema(resourceProvisioning));
    assertResourceSchemaParseCountIncrement(0);
    assertConnectorInstanceUnchanged(resourceProvisioning);
}
Also used : Task(com.evolveum.midpoint.task.api.Task) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) ResourceType(com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType) ProjectionPolicyType(com.evolveum.midpoint.xml.ns._public.common.common_3.ProjectionPolicyType) Test(org.testng.annotations.Test)

Example 3 with ProjectionPolicyType

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

the class TestDummyResourceAndSchemaCaching method test020ModifyAndGetResource.

/**
	 * Change something that is not important. The cached resource should be refreshed, the schema re-parsed
	 * but the connector should still be cached.
	 */
@Test
public void test020ModifyAndGetResource() throws Exception {
    final String TEST_NAME = "test020ModifyAndGetResource";
    TestUtil.displayTestTile(TEST_NAME);
    // GIVEN
    Task task = taskManager.createTaskInstance(TestDummyResourceAndSchemaCaching.class.getName() + "." + TEST_NAME);
    OperationResult result = task.getResult();
    // Change something that's not that important
    ProjectionPolicyType accountSynchronizationSettingsType = new ProjectionPolicyType();
    accountSynchronizationSettingsType.setLegalize(true);
    ObjectDelta<ResourceType> objectDelta = ObjectDelta.createModificationReplaceProperty(ResourceType.class, RESOURCE_DUMMY_OID, ResourceType.F_PROJECTION, prismContext, accountSynchronizationSettingsType);
    // WHEN
    provisioningService.modifyObject(ResourceType.class, RESOURCE_DUMMY_OID, objectDelta.getModifications(), null, null, task, result);
    // THEN
    result.computeStatus();
    TestUtil.assertSuccess(result);
    String versionAfter = repositoryService.getVersion(ResourceType.class, RESOURCE_DUMMY_OID, result);
    assertResourceVersionIncrement(versionAfter, 1);
    // WHEN
    PrismObject<ResourceType> resourceProvisioning = provisioningService.getObject(ResourceType.class, RESOURCE_DUMMY_OID, null, task, result);
    // THEN
    display("Resource", resource);
    result.computeStatus();
    TestUtil.assertSuccess(result);
    assertHasSchema(resourceProvisioning, "provisioning resource");
    assertSchemaMetadataUnchanged(resourceProvisioning);
    assertResourceSchemaFetchIncrement(0);
    assertConnectorSchemaParseIncrement(0);
    assertConnectorCapabilitiesFetchIncrement(0);
    assertConnectorInitializationCountIncrement(0);
    assertResourceSchemaParseCountIncrement(1);
    assertResourceVersionIncrement(resourceProvisioning, 0);
    display("Resource cache", InternalMonitor.getResourceCacheStats());
    assertResourceCacheHitsIncrement(0);
    assertResourceCacheMissesIncrement(1);
    // There are expected to be re-parsed
    rememberResourceSchema(RefinedResourceSchemaImpl.getResourceSchema(resourceProvisioning, prismContext));
    rememberRefinedResourceSchema(RefinedResourceSchemaImpl.getRefinedSchema(resourceProvisioning));
    assertResourceSchemaParseCountIncrement(0);
    assertConnectorInstanceUnchanged(resourceProvisioning);
}
Also used : Task(com.evolveum.midpoint.task.api.Task) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) ResourceType(com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType) ProjectionPolicyType(com.evolveum.midpoint.xml.ns._public.common.common_3.ProjectionPolicyType) Test(org.testng.annotations.Test)

Example 4 with ProjectionPolicyType

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

the class TestSanityLegacy method assertSyncSettingsAssignmentPolicyEnforcement.

private void assertSyncSettingsAssignmentPolicyEnforcement(AssignmentPolicyEnforcementType assignmentPolicy) throws ObjectNotFoundException, SchemaException {
    OperationResult result = new OperationResult("Asserting sync settings");
    PrismObject<SystemConfigurationType> systemConfigurationType = repositoryService.getObject(SystemConfigurationType.class, SystemObjectsType.SYSTEM_CONFIGURATION.value(), null, result);
    result.computeStatus();
    TestUtil.assertSuccess("Asserting sync settings failed (result)", result);
    ProjectionPolicyType globalAccountSynchronizationSettings = systemConfigurationType.asObjectable().getGlobalAccountSynchronizationSettings();
    assertNotNull("globalAccountSynchronizationSettings is null", globalAccountSynchronizationSettings);
    AssignmentPolicyEnforcementType assignmentPolicyEnforcement = globalAccountSynchronizationSettings.getAssignmentPolicyEnforcement();
    assertNotNull("assignmentPolicyEnforcement is null", assignmentPolicyEnforcement);
    assertEquals("Assignment policy mismatch", assignmentPolicy, assignmentPolicyEnforcement);
}
Also used : AssignmentPolicyEnforcementType(com.evolveum.midpoint.xml.ns._public.common.common_3.AssignmentPolicyEnforcementType) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) SystemConfigurationType(com.evolveum.midpoint.xml.ns._public.common.common_3.SystemConfigurationType) ProjectionPolicyType(com.evolveum.midpoint.xml.ns._public.common.common_3.ProjectionPolicyType)

Example 5 with ProjectionPolicyType

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

the class TestSanity method assertSyncSettingsAssignmentPolicyEnforcement.

private void assertSyncSettingsAssignmentPolicyEnforcement(AssignmentPolicyEnforcementType assignmentPolicy) throws ObjectNotFoundException, SchemaException {
    OperationResult result = new OperationResult("Asserting sync settings");
    PrismObject<SystemConfigurationType> systemConfigurationType = repositoryService.getObject(SystemConfigurationType.class, SystemObjectsType.SYSTEM_CONFIGURATION.value(), null, result);
    result.computeStatus();
    TestUtil.assertSuccess("Asserting sync settings failed (result)", result);
    ProjectionPolicyType globalAccountSynchronizationSettings = systemConfigurationType.asObjectable().getGlobalAccountSynchronizationSettings();
    assertNotNull("globalAccountSynchronizationSettings is null", globalAccountSynchronizationSettings);
    AssignmentPolicyEnforcementType assignmentPolicyEnforcement = globalAccountSynchronizationSettings.getAssignmentPolicyEnforcement();
    assertNotNull("assignmentPolicyEnforcement is null", assignmentPolicyEnforcement);
    assertEquals("Assignment policy mismatch", assignmentPolicy, assignmentPolicyEnforcement);
}
Also used : AssignmentPolicyEnforcementType(com.evolveum.midpoint.xml.ns._public.common.common_3.AssignmentPolicyEnforcementType) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) SystemConfigurationType(com.evolveum.midpoint.xml.ns._public.common.common_3.SystemConfigurationType) ProjectionPolicyType(com.evolveum.midpoint.xml.ns._public.common.common_3.ProjectionPolicyType)

Aggregations

ProjectionPolicyType (com.evolveum.midpoint.xml.ns._public.common.common_3.ProjectionPolicyType)5 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)4 AssignmentPolicyEnforcementType (com.evolveum.midpoint.xml.ns._public.common.common_3.AssignmentPolicyEnforcementType)3 SystemConfigurationType (com.evolveum.midpoint.xml.ns._public.common.common_3.SystemConfigurationType)3 Task (com.evolveum.midpoint.task.api.Task)2 ResourceType (com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType)2 Test (org.testng.annotations.Test)2 ClassLoggerConfigurationType (com.evolveum.midpoint.xml.ns._public.common.common_3.ClassLoggerConfigurationType)1 CleanupPoliciesType (com.evolveum.midpoint.xml.ns._public.common.common_3.CleanupPoliciesType)1 CleanupPolicyType (com.evolveum.midpoint.xml.ns._public.common.common_3.CleanupPolicyType)1 LoggingConfigurationType (com.evolveum.midpoint.xml.ns._public.common.common_3.LoggingConfigurationType)1 ObjectReferenceType (com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType)1 Duration (javax.xml.datatype.Duration)1