use of com.evolveum.midpoint.xml.ns._public.common.common_3.SystemConfigurationType in project midpoint by Evolveum.
the class SchemaTransformer method determineObjectTemplate.
public <O extends ObjectType> ObjectTemplateType determineObjectTemplate(Class<O> objectClass, AuthorizationPhaseType phase, OperationResult result) throws SchemaException, ConfigurationException, ObjectNotFoundException {
PrismObject<SystemConfigurationType> systemConfiguration = systemObjectCache.getSystemConfiguration(result);
if (systemConfiguration == null) {
return null;
}
ObjectPolicyConfigurationType objectPolicyConfiguration = ModelUtils.determineObjectPolicyConfiguration(objectClass, null, systemConfiguration.asObjectable());
if (objectPolicyConfiguration == null) {
return null;
}
ObjectReferenceType objectTemplateRef = objectPolicyConfiguration.getObjectTemplateRef();
if (objectTemplateRef == null) {
return null;
}
PrismObject<ObjectTemplateType> template = cacheRepositoryService.getObject(ObjectTemplateType.class, objectTemplateRef.getOid(), null, result);
return template.asObjectable();
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.SystemConfigurationType in project midpoint by Evolveum.
the class SystemConfigurationHandler method invoke.
@Override
public <O extends ObjectType> HookOperationMode invoke(@NotNull ModelContext<O> context, @NotNull Task task, @NotNull OperationResult parentResult) {
ModelState state = context.getState();
if (state != ModelState.FINAL) {
if (LOGGER.isTraceEnabled()) {
LOGGER.trace("sysconfig handler called in state = " + state + ", exiting.");
}
return HookOperationMode.FOREGROUND;
} else {
if (LOGGER.isTraceEnabled()) {
LOGGER.trace("sysconfig handler called in state = " + state + ", proceeding.");
}
}
if (context.getFocusClass() != SystemConfigurationType.class) {
LOGGER.trace("invoke() EXITING: Changes not related to systemConfiguration");
return HookOperationMode.FOREGROUND;
}
ModelContext<SystemConfigurationType> confContext = (ModelContext<SystemConfigurationType>) context;
ModelElementContext<SystemConfigurationType> focusContext = confContext.getFocusContext();
// is this config-related change a deletion?
boolean isDeletion = false;
PrismObject<SystemConfigurationType> object = focusContext.getObjectNew();
if (object == null) {
isDeletion = true;
object = focusContext.getObjectOld();
}
if (object == null) {
// if the handler would not work because of this, for us to see the reason
LOGGER.warn("Probably invalid projection context: both old and new objects are null");
}
LOGGER.trace("change relates to sysconfig, is deletion: {}", isDeletion);
OperationResult result = parentResult.createSubresult(DOT_CLASS + "invoke");
try {
if (isDeletion) {
// because the new config (if any) will have version number probably starting at 1 - so to be sure to read it when it comes
LoggingConfigurationManager.resetCurrentlyUsedVersion();
LOGGER.trace("invoke() EXITING because operation is DELETION");
return HookOperationMode.FOREGROUND;
}
/*
* Because we need to know actual version of the system configuration (generated by repo), we have to re-read
* current configuration. (At this moment, it is already stored there.)
*/
PrismObject<SystemConfigurationType> config = cacheRepositoryService.getObject(SystemConfigurationType.class, SystemObjectsType.SYSTEM_CONFIGURATION.value(), null, result);
LOGGER.trace("invoke() SystemConfig from repo: {}, ApplyingLoggingConfiguration", config.getVersion());
SystemConfigurationHolder.setCurrentConfiguration(config.asObjectable());
SecurityUtil.setRemoteHostAddressHeaders(config.asObjectable());
applyLoggingConfiguration(ProfilingConfigurationManager.checkSystemProfilingConfiguration(config), config.asObjectable().getVersion(), result);
cacheRepositoryService.applyFullTextSearchConfiguration(config.asObjectable().getFullTextSearch());
result.recordSuccessIfUnknown();
} catch (ObjectNotFoundException e) {
String message = "Cannot read system configuration because it does not exist in repository: " + e.getMessage();
LoggingUtils.logException(LOGGER, message, e);
result.recordFatalError(message, e);
} catch (SchemaException e) {
String message = "Cannot read system configuration because of schema exception: " + e.getMessage();
LoggingUtils.logException(LOGGER, message, e);
result.recordFatalError(message, e);
}
return HookOperationMode.FOREGROUND;
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.SystemConfigurationType in project midpoint by Evolveum.
the class TestProjector method test451GuybrushInboundFromAbsolute.
@Test
public void test451GuybrushInboundFromAbsolute() throws Exception {
final String TEST_NAME = "test451GuybrushInboundFromAbsolute";
TestUtil.displayTestTile(this, TEST_NAME);
// GIVEN
Task task = taskManager.createTaskInstance(TestProjector.class.getName() + "." + TEST_NAME);
OperationResult result = task.getResult();
assumeAssignmentPolicy(AssignmentPolicyEnforcementType.POSITIVE);
PrismObject<ValuePolicyType> passPolicy = PrismTestUtil.parseObject(PASSWORD_POLICY_GLOBAL_FILE);
ObjectDelta delta = ObjectDelta.createAddDelta(passPolicy);
Collection<ObjectDelta<? extends ObjectType>> deltas = new ArrayList<ObjectDelta<? extends ObjectType>>();
deltas.add(delta);
modelService.executeChanges(deltas, null, task, result);
deltas = new ArrayList<ObjectDelta<? extends ObjectType>>();
ObjectDelta refDelta = ObjectDelta.createModificationAddReference(SystemConfigurationType.class, SYSTEM_CONFIGURATION_OID, SystemConfigurationType.F_GLOBAL_PASSWORD_POLICY_REF, prismContext, passPolicy);
// We need to execute this using repo. Otherwise logging config will be ruined
repositoryService.modifyObject(SystemConfigurationType.class, SYSTEM_CONFIGURATION_OID, refDelta.getModifications(), result);
PrismObject<ValuePolicyType> passPol = modelService.getObject(ValuePolicyType.class, PASSWORD_POLICY_GLOBAL_OID, null, task, result);
assertNotNull(passPol);
PrismObject<SystemConfigurationType> sysConfig = modelService.getObject(SystemConfigurationType.class, SYSTEM_CONFIGURATION_OID, null, task, result);
assertNotNull("No global password policy", sysConfig.asObjectable().getGlobalPasswordPolicyRef());
assertEquals(PASSWORD_POLICY_GLOBAL_OID, sysConfig.asObjectable().getGlobalPasswordPolicyRef().getOid());
// GIVEN
LensContext<UserType> context = createUserLensContext();
fillContextWithUser(context, USER_GUYBRUSH_OID, result);
fillContextWithAccountFromFile(context, ACCOUNT_GUYBRUSH_DUMMY_FILE, task, result);
LensProjectionContext guybrushAccountContext = context.findProjectionContextByOid(ACCOUNT_SHADOW_GUYBRUSH_OID);
guybrushAccountContext.setFullShadow(true);
guybrushAccountContext.setDoReconciliation(true);
context.recompute();
display("Input context", context);
assertFocusModificationSanity(context);
// WHEN
projector.project(context, "test", task, result);
// THEN
display("Output context", context);
assertNoUserPrimaryDelta(context);
assertUserSecondaryDelta(context);
ObjectDelta<UserType> userSecondaryDelta = context.getFocusContext().getSecondaryDelta();
assertTrue(userSecondaryDelta.getChangeType() == ChangeType.MODIFY);
PrismAsserts.assertPropertyAdd(userSecondaryDelta, UserType.F_ORGANIZATIONAL_UNIT, PrismTestUtil.createPolyString("The crew of The Sea Monkey"));
assertOriginWithSideEffectChanges(userSecondaryDelta, OriginType.INBOUND);
}
Aggregations