Skip to content

Commit

Permalink
Merge remote-tracking branch 'refs/remotes/origin/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
skublik committed Oct 18, 2021
2 parents 1ff0176 + dad8e61 commit 92b1b5c
Show file tree
Hide file tree
Showing 15 changed files with 429 additions and 72 deletions.
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
/*
* Copyright (c) 2020 Evolveum and contributors
* Copyright (C) 2020-2021 Evolveum and contributors
*
* This work is dual-licensed under the Apache License 2.0
* and European Union Public License. See LICENSE file for details.
*/

package com.evolveum.midpoint.schema.util;

import com.evolveum.midpoint.xml.ns._public.common.common_3.SystemConfigurationAuditType;

import org.apache.commons.lang3.ObjectUtils;

import com.evolveum.midpoint.xml.ns._public.common.common_3.OperationResultDetailLevel;
import com.evolveum.midpoint.xml.ns._public.common.common_3.SystemConfigurationAuditType;

/**
* Utility methods for audit-related system configuration options.
*/
Expand All @@ -24,4 +25,14 @@ public static boolean isEscapingInvalidCharacters(SystemConfigurationAuditType c
return ObjectUtils.defaultIfNull(configuration.getEventRecording().isEscapeIllegalCharacters(), defaultValue);
}
}

public static OperationResultDetailLevel getDeltaSuccessExecutionResult(
SystemConfigurationAuditType configuration) {
OperationResultDetailLevel defaultValue = OperationResultDetailLevel.CLEANED_UP;
if (configuration == null || configuration.getEventRecording() == null) {
return defaultValue;
} else {
return ObjectUtils.defaultIfNull(configuration.getEventRecording().getDeltaSuccessExecutionResult(), defaultValue);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14605,10 +14605,84 @@
</xsd:appinfo>
</xsd:annotation>
</xsd:element>
<xsd:element name="deltaSuccessExecutionResult" type="tns:OperationResultDetailLevel" minOccurs="0">
<xsd:annotation>
<xsd:documentation>
Specifies how the successful operation result from delta execution is stored in the repository.
Operation results from delta execution can take a lot of space and are often not that important
if the result status is `success`.
By default, the result is cleaned up from successful minor results, but there
is also option to store only the top level result (root) without any subresults
or even nothing at all.
Finally, there is also option to store the original full result.

[NOTE] This option only works for new Native repository audit.
</xsd:documentation>
<xsd:appinfo>
<a:since>4.4</a:since>
<a:displayName>SystemConfigurationAuditEventRecordingType.deltaSuccessExecutionResult</a:displayName>
</xsd:appinfo>
</xsd:annotation>
</xsd:element>
</xsd:sequence>
<xsd:attribute name="id" type="xsd:long"/>
</xsd:complexType>

<xsd:simpleType name="OperationResultDetailLevel">
<xsd:annotation>
<xsd:documentation>
Specifies what level of detail should be preserved in the operation result.
</xsd:documentation>
<xsd:appinfo>
<jaxb:typesafeEnumClass/>
<a:since>4.4</a:since>
</xsd:appinfo>
</xsd:annotation>
<xsd:restriction base="xsd:string">
<xsd:enumeration value="full">
<xsd:annotation>
<xsd:appinfo>
<jaxb:typesafeEnumMember name="FULL"/>
</xsd:appinfo>
<xsd:documentation>
Full operation result is preserved, no changes are made.
</xsd:documentation>
</xsd:annotation>
</xsd:enumeration>
<xsd:enumeration value="cleanedUp">
<xsd:annotation>
<xsd:appinfo>
<jaxb:typesafeEnumMember name="CLEANED_UP"/>
</xsd:appinfo>
<xsd:documentation>
Operation result is cleaned up from minor successful subresults.
Only first level subresults are cleaned up this way.
</xsd:documentation>
</xsd:annotation>
</xsd:enumeration>
<xsd:enumeration value="top">
<xsd:annotation>
<xsd:appinfo>
<jaxb:typesafeEnumMember name="TOP"/>
</xsd:appinfo>
<xsd:documentation>
Only the top level result (root) is preserved, all subresults are removed.
</xsd:documentation>
</xsd:annotation>
</xsd:enumeration>
<xsd:enumeration value="none">
<xsd:annotation>
<xsd:appinfo>
<jaxb:typesafeEnumMember name="NONE"/>
</xsd:appinfo>
<xsd:documentation>
Nothing is stored, just like no operation result (null) was provided.
</xsd:documentation>
</xsd:annotation>
</xsd:enumeration>
</xsd:restriction>
</xsd:simpleType>

<xsd:complexType name="SystemConfigurationAuditEventRecordingPropertyType">
<xsd:annotation>
<xsd:documentation>
Expand Down
54 changes: 53 additions & 1 deletion model/model-common/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -126,10 +126,14 @@
<groupId>org.apache.velocity</groupId>
<artifactId>velocity-engine-core</artifactId>
</dependency>
<!-- Python is optional, must be provided in ${midpoint.home}/lib if desired. -->
<!--
Python is optional, must be provided in ${midpoint.home}/lib if desired.
For more see: https://docs.evolveum.com/midpoint/reference/expressions/expressions/script/python/
-->
<dependency>
<groupId>org.python</groupId>
<artifactId>jython-standalone</artifactId>
<version>2.7.2</version>
<scope>test</scope>
</dependency>
<dependency>
Expand Down Expand Up @@ -176,4 +180,52 @@
<scope>test</scope>
</dependency>
</dependencies>

<profiles>
<profile>
<!--
JavaScript/ECMAScript is optional. It is not provided with newer JDKs or distributed with midPoint.
If desired the JAR from this dependency can be provided in ${midpoint.home}/lib.
For more see: https://docs.evolveum.com/midpoint/reference/expressions/expressions/script/javascript/
-->
<id>javascript</id>
<activation>
<jdk>[15,)</jdk>
</activation>
<dependencyManagement>
<dependencies>
<!-- This one is needed by GUI too, so midPoint brings it in. -->
<dependency>
<groupId>org.ow2.asm</groupId>
<artifactId>asm</artifactId>
<version>${asm.version}</version>
</dependency>
<!-- The rest must be provided in midpoint.home manually if we want JavaScript/ECMAScript. -->
<dependency>
<groupId>org.ow2.asm</groupId>
<artifactId>asm-commons</artifactId>
<version>${asm.version}</version>
</dependency>
<dependency>
<groupId>org.ow2.asm</groupId>
<artifactId>asm-tree</artifactId>
<version>${asm.version}</version>
</dependency>
<dependency>
<groupId>org.ow2.asm</groupId>
<artifactId>asm-util</artifactId>
<version>${asm.version}</version>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>org.openjdk.nashorn</groupId>
<artifactId>nashorn-core</artifactId>
<version>15.3</version>
<scope>test</scope>
</dependency>
</dependencies>
</profile>
</profiles>
</project>
5 changes: 0 additions & 5 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -375,11 +375,6 @@
<artifactId>groovy</artifactId>
<version>${groovy.version}</version>
</dependency>
<dependency>
<groupId>org.python</groupId>
<artifactId>jython-standalone</artifactId>
<version>2.7.2</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,9 @@ public interface AuditService {

/**
* Called when audit configuration is established or changed.
* Setting to null means to use default values for the settings.
*/
default void applyAuditConfiguration(SystemConfigurationAuditType configuration) {
default void applyAuditConfiguration(@Nullable SystemConfigurationAuditType configuration) {
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
import com.evolveum.midpoint.repo.sqlbase.SupportedDatabase;
import com.evolveum.midpoint.repo.sqlbase.TransactionIsolation;
import com.evolveum.midpoint.repo.sqlbase.perfmon.SqlPerformanceMonitorImpl;
import com.evolveum.midpoint.util.annotation.Experimental;
import com.evolveum.midpoint.util.exception.SystemException;

/**
Expand All @@ -37,13 +36,6 @@ public class SqaleRepositoryConfiguration implements JdbcRepositoryConfiguration
private static final String DEFAULT_JDBC_PASSWORD = "password";
private static final String DEFAULT_FULL_OBJECT_FORMAT = PrismContext.LANG_JSON;

@Experimental
public static final String PROPERTY_DELTA_EXECUTION_RESULT = "deltaExecutionResult";
public static final String AUDIT_DELTA_EXECUTION_RESULT_FULL = "full";
public static final String AUDIT_DELTA_EXECUTION_RESULT_CLEANED_UP = "cleanedup";
public static final String AUDIT_DELTA_EXECUTION_RESULT_TOP = "top";
public static final String AUDIT_DELTA_EXECUTION_RESULT_NONE = "none";

/**
* We need at least two connections, because ext item/URI cache can start nested transaction
* using separate connection to add missing entry into the database.
Expand Down Expand Up @@ -91,10 +83,6 @@ public class SqaleRepositoryConfiguration implements JdbcRepositoryConfiguration
private int iterativeSearchByPagingBatchSize;
private boolean createMissingCustomColumns;

// new repo audit specific
@Experimental
private String deltaExecutionResult;

// Provided with configuration node "midpoint.repository".
public SqaleRepositoryConfiguration(@NotNull Configuration configuration) {
this.configuration = configuration;
Expand Down Expand Up @@ -142,9 +130,6 @@ public void init() throws RepositoryServiceFactoryException {
createMissingCustomColumns =
configuration.getBoolean(PROPERTY_CREATE_MISSING_CUSTOM_COLUMNS, false);

deltaExecutionResult = configuration.getString(
PROPERTY_DELTA_EXECUTION_RESULT, AUDIT_DELTA_EXECUTION_RESULT_FULL).toLowerCase();

validateConfiguration();
}

Expand Down Expand Up @@ -307,18 +292,10 @@ public static SqaleRepositoryConfiguration initForAudit(
PROPERTY_ITERATIVE_SEARCH_BY_PAGING_BATCH_SIZE, mainRepoConfig.iterativeSearchByPagingBatchSize);
config.createMissingCustomColumns = auditConfig.getBoolean(
PROPERTY_CREATE_MISSING_CUSTOM_COLUMNS, mainRepoConfig.createMissingCustomColumns);
config.deltaExecutionResult =
auditConfig.getString(PROPERTY_DELTA_EXECUTION_RESULT, mainRepoConfig.deltaExecutionResult)
.toLowerCase();

// perf stats settings must be copied to allow proper perf monitoring of audit
config.performanceStatisticsFile = mainRepoConfig.performanceStatisticsFile;
config.performanceStatisticsLevel = mainRepoConfig.performanceStatisticsLevel;
return config;
}

@Experimental
public String getDeltaExecutionResult() {
return deltaExecutionResult;
}
}

0 comments on commit 92b1b5c

Please sign in to comment.