protected void setDefaultUserTemplate(String userTemplateOid) throws ObjectNotFoundException, SchemaException, ObjectAlreadyExistsException { PrismObjectDefinition<SystemConfigurationType> objectDefinition = prismContext .getSchemaRegistry() .findObjectDefinitionByCompileTimeClass(SystemConfigurationType.class); Collection<? extends ItemDelta> modifications; if (userTemplateOid == null) { modifications = ReferenceDelta.createModificationReplaceCollection( SystemConfigurationType.F_DEFAULT_USER_TEMPLATE_REF, objectDefinition, null); } else { PrismReferenceValue userTemplateRefVal = new PrismReferenceValue(userTemplateOid); modifications = ReferenceDelta.createModificationReplaceCollection( SystemConfigurationType.F_DEFAULT_USER_TEMPLATE_REF, objectDefinition, userTemplateRefVal); } OperationResult result = new OperationResult("Aplying default user template"); repositoryService.modifyObject( SystemConfigurationType.class, SystemObjectsType.SYSTEM_CONFIGURATION.value(), modifications, result); display("Aplying default user template result", result); result.computeStatus(); TestUtil.assertSuccess("Aplying default user template failed (result)", result); }
/** * 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)) { LoggingConfigurationType loggingConfig = ProfilingConfigurationManager.checkSystemProfilingConfiguration(config); LoggingConfigurationManager.configure(loggingConfig, versionInRepo, result); } 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) { LoggingConfigurationManager .resetCurrentlyUsedVersion(); // 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 :)] 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); } }