Skip to content

Commit

Permalink
Development mode, internals config in config.xml (MID-3529,MID-4982)
Browse files Browse the repository at this point in the history
  • Loading branch information
semancik committed Nov 19, 2018
1 parent 91dfdc6 commit 2e39abb
Show file tree
Hide file tree
Showing 5 changed files with 87 additions and 5 deletions.
@@ -0,0 +1,46 @@
/**
* Copyright (c) 2018 Evolveum
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.evolveum.midpoint.common;

import javax.annotation.PostConstruct;

import org.apache.commons.configuration.Configuration;

import com.evolveum.midpoint.common.configuration.api.MidpointConfiguration;
import com.evolveum.midpoint.schema.internals.InternalsConfig;

/**
* @author semancik
*
*/
public class InternalsConfigController {

private MidpointConfiguration midpointConfiguration;

public MidpointConfiguration getMidpointConfiguration() {
return midpointConfiguration;
}

public void setMidpointConfiguration(MidpointConfiguration midpointConfiguration) {
this.midpointConfiguration = midpointConfiguration;
}

@PostConstruct
public void init() {
Configuration internalsConfig = midpointConfiguration.getConfiguration(MidpointConfiguration.INTERNALS_CONFIGURATION);
InternalsConfig.set(internalsConfig);
}
}
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2010-2014 Evolveum
* Copyright (c) 2010-2018 Evolveum
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -49,6 +49,7 @@ public interface MidpointConfiguration {
String DOT_CONFIGURATION = "midpoint.dot";
String WEB_APP_CONFIGURATION = "midpoint.webApplication";
String WORKFLOW_CONFIGURATION = "midpoint.workflow";
String INTERNALS_CONFIGURATION = "midpoint.internals";

String getMidpointHome();

Expand Down
8 changes: 7 additions & 1 deletion infra/common/src/main/resources/ctx-common.xml
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ Copyright (c) 2010-2017 Evolveum
~ Copyright (c) 2010-2018 Evolveum
~
~ Licensed under the Apache License, Version 2.0 (the "License");
~ you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -44,4 +44,10 @@
<bean id="messageSource" name="messageSource" class="com.evolveum.midpoint.common.LocalizationMessageSource">
<constructor-arg ref="localizationService"/>
</bean>

<bean id="internalsConfigController" class="com.evolveum.midpoint.common.InternalsConfigController">
<property name="midpointConfiguration">
<ref bean="midpointConfiguration"/>
</property>
</bean>
</beans>
4 changes: 4 additions & 0 deletions infra/schema/pom.xml
Expand Up @@ -116,6 +116,10 @@
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
</dependency>
<dependency>
<groupId>commons-configuration</groupId>
<artifactId>commons-configuration</artifactId>
</dependency>

<!-- Testing dependecies -->
<dependency>
Expand Down
Expand Up @@ -15,6 +15,8 @@
*/
package com.evolveum.midpoint.schema.internals;

import org.apache.commons.configuration.Configuration;

/**
* @author semancik
*
Expand All @@ -24,12 +26,12 @@ public class InternalsConfig {
/**
* Checks for consistency of data structures (e.g. prism objects, containers, contexts).
*/
public static boolean consistencyChecks = true;
public static boolean consistencyChecks = false;

/**
* Additional checks that method arguments make sense (e.g. deltas are not duplicated)
*/
private static boolean sanityChecks = true;
private static boolean sanityChecks = false;

public static boolean encryptionChecks = true;

Expand Down Expand Up @@ -146,9 +148,32 @@ public static void setAllowClearDataLogging(boolean allowClearDataLogging) {
public static void resetTestingPaths() {
testingPaths = null;
}

public static void set(Configuration internalsConfig) {
if (internalsConfig.containsKey("developmentMode")) {
boolean developmentMode = internalsConfig.getBoolean("developmentMode");
if (developmentMode) {
setDevelopmentMode();
} else {
reset();
}
}

consistencyChecks = internalsConfig.getBoolean("consistencyChecks", consistencyChecks);
sanityChecks = internalsConfig.getBoolean("sanityChecks", sanityChecks);
encryptionChecks = internalsConfig.getBoolean("encryptionChecks", encryptionChecks);
readEncryptionChecks = internalsConfig.getBoolean("readEncryptionChecks", readEncryptionChecks);
avoidLoggingChange = internalsConfig.getBoolean("avoidLoggingChange", avoidLoggingChange);
allowClearDataLogging = internalsConfig.getBoolean("allowClearDataLogging", allowClearDataLogging);
prismMonitoring = internalsConfig.getBoolean("prismMonitoring", prismMonitoring);
modelProfiling = internalsConfig.getBoolean("modelProfiling", modelProfiling);
// TODO: testingPaths
detailedAuhotizationLog = internalsConfig.getBoolean("detailedAuhotizationLog", detailedAuhotizationLog);

}

public static void reset() {
consistencyChecks = true;
consistencyChecks = false;
sanityChecks = false;
encryptionChecks = true;
readEncryptionChecks = false;
Expand Down

0 comments on commit 2e39abb

Please sign in to comment.