Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/Evolveum/midpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
KaterynaHonchar committed Dec 17, 2020
2 parents 497243c + 1ad2579 commit aec144d
Show file tree
Hide file tree
Showing 33 changed files with 51 additions and 72 deletions.
2 changes: 1 addition & 1 deletion gui/admin-gui/pom.xml
Expand Up @@ -382,7 +382,7 @@
</dependency>
<dependency>
<groupId>com.evolveum.midpoint.repo</groupId>
<artifactId>audit-impl</artifactId>
<artifactId>audit-log-impl</artifactId>
<version>${project.version}</version>
<scope>runtime</scope>
</dependency>
Expand Down
Expand Up @@ -6,7 +6,11 @@
*/
package com.evolveum.midpoint.common;

import java.io.*;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.InputStream;
import java.io.PrintStream;
import java.nio.charset.StandardCharsets;

import ch.qos.logback.classic.Level;
import ch.qos.logback.classic.Logger;
Expand Down Expand Up @@ -112,13 +116,7 @@ public static void configure(LoggingConfigurationType config, String version,
StatusPrinter.setPrintStream(new PrintStream(baos));
StatusPrinter.print(lc);

String internalLog = null;
try {
internalLog = baos.toString("UTF8");
} catch (UnsupportedEncodingException e) {
// should never happen
LOGGER.error("Whoops?", e);
}
String internalLog = baos.toString(StandardCharsets.UTF_8);

if (!StringUtils.isEmpty(internalLog)) {
//Parse internal log
Expand Down Expand Up @@ -466,8 +464,4 @@ private static void defineSubsystemTurboFilter(StringBuilder sb, SubSystemLogger
private static String defineProfilingLogbackFilter() {
return ("\t<filter class=\"" + ProfilingLogbackFilter.class.getName() + "\" />\n");
}

public static void dummy() {
}

}
2 changes: 1 addition & 1 deletion model/certification-impl/pom.xml
Expand Up @@ -223,7 +223,7 @@
</dependency>
<dependency>
<groupId>com.evolveum.midpoint.repo</groupId>
<artifactId>audit-impl</artifactId>
<artifactId>audit-log-impl</artifactId>
<version>4.3-SNAPSHOT</version>
<scope>test</scope>
</dependency>
Expand Down
2 changes: 1 addition & 1 deletion model/model-impl/pom.xml
Expand Up @@ -259,7 +259,7 @@
</dependency>
<dependency>
<groupId>com.evolveum.midpoint.repo</groupId>
<artifactId>audit-impl</artifactId>
<artifactId>audit-log-impl</artifactId>
<version>4.3-SNAPSHOT</version>
<scope>test</scope>
</dependency>
Expand Down
2 changes: 1 addition & 1 deletion model/model-intest/pom.xml
Expand Up @@ -161,7 +161,7 @@
</dependency>
<dependency>
<groupId>com.evolveum.midpoint.repo</groupId>
<artifactId>audit-impl</artifactId>
<artifactId>audit-log-impl</artifactId>
<version>4.3-SNAPSHOT</version>
<scope>test</scope>
</dependency>
Expand Down
2 changes: 1 addition & 1 deletion model/model-test/pom.xml
Expand Up @@ -215,7 +215,7 @@
</dependency>
<dependency>
<groupId>com.evolveum.midpoint.repo</groupId>
<artifactId>audit-impl</artifactId>
<artifactId>audit-log-impl</artifactId>
<version>4.3-SNAPSHOT</version>
<scope>test</scope>
</dependency>
Expand Down
2 changes: 1 addition & 1 deletion model/notifications-impl/pom.xml
Expand Up @@ -200,7 +200,7 @@
</dependency>
<dependency>
<groupId>com.evolveum.midpoint.repo</groupId>
<artifactId>audit-impl</artifactId>
<artifactId>audit-log-impl</artifactId>
<version>${project.version}</version>
<scope>test</scope>
</dependency>
Expand Down
2 changes: 1 addition & 1 deletion model/report-impl/pom.xml
Expand Up @@ -207,7 +207,7 @@
</dependency>
<dependency>
<groupId>com.evolveum.midpoint.repo</groupId>
<artifactId>audit-impl</artifactId>
<artifactId>audit-log-impl</artifactId>
<version>4.3-SNAPSHOT</version>
<scope>test</scope>
</dependency>
Expand Down
2 changes: 1 addition & 1 deletion model/workflow-impl/pom.xml
Expand Up @@ -219,7 +219,7 @@
</dependency>
<dependency>
<groupId>com.evolveum.midpoint.repo</groupId>
<artifactId>audit-impl</artifactId>
<artifactId>audit-log-impl</artifactId>
<version>4.3-SNAPSHOT</version>
<scope>test</scope>
</dependency>
Expand Down
2 changes: 1 addition & 1 deletion provisioning/provisioning-impl/pom.xml
Expand Up @@ -136,7 +136,7 @@
</dependency>
<dependency>
<groupId>com.evolveum.midpoint.repo</groupId>
<artifactId>audit-impl</artifactId>
<artifactId>audit-log-impl</artifactId>
<version>4.3-SNAPSHOT</version>
<scope>test</scope>
</dependency>
Expand Down
2 changes: 1 addition & 1 deletion provisioning/ucf-impl-builtin/pom.xml
Expand Up @@ -137,7 +137,7 @@
</dependency>
<dependency>
<groupId>com.evolveum.midpoint.repo</groupId>
<artifactId>audit-impl</artifactId>
<artifactId>audit-log-impl</artifactId>
<version>4.3-SNAPSHOT</version>
<scope>test</scope>
</dependency>
Expand Down
2 changes: 1 addition & 1 deletion provisioning/ucf-impl-connid/pom.xml
Expand Up @@ -108,7 +108,7 @@
</dependency>
<dependency>
<groupId>com.evolveum.midpoint.repo</groupId>
<artifactId>audit-impl</artifactId>
<artifactId>audit-log-impl</artifactId>
<version>${project.version}</version>
<scope>test</scope>
</dependency>
Expand Down
5 changes: 3 additions & 2 deletions repo/audit-impl/pom.xml → repo/audit-log-impl/pom.xml
Expand Up @@ -15,10 +15,11 @@
<version>4.3-SNAPSHOT</version>
</parent>

<artifactId>audit-impl</artifactId>
<artifactId>audit-log-impl</artifactId>
<packaging>jar</packaging>

<name>midPoint Audit - impl</name>
<name>midPoint Audit - logging impl</name>
<description>Audit implementation writing to logs, currently using SLF4J API.</description>

<dependencies>
<dependency>
Expand Down
Expand Up @@ -168,12 +168,6 @@ public boolean supportsRetrieval() {
return false;
}

// This method is never used. It is here only for maven dependency plugin to properly detect common component usage.
@SuppressWarnings("unused")
private void fakeMethod() {
LoggingConfigurationManager.dummy();
}

@Override
public void reindexEntry(AuditEventRecord record) {
throw new UnsupportedOperationException("Reindex entry not supported");
Expand Down
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion repo/pom.xml
Expand Up @@ -22,7 +22,7 @@

<modules>
<module>audit-api</module>
<module>audit-impl</module>
<module>audit-log-impl</module>
<module>repo-api</module>
<module>repo-cache</module>
<module>system-init</module>
Expand Down
2 changes: 1 addition & 1 deletion repo/repo-common/pom.xml
Expand Up @@ -120,7 +120,7 @@
</dependency>
<dependency>
<groupId>com.evolveum.midpoint.repo</groupId>
<artifactId>audit-impl</artifactId>
<artifactId>audit-log-impl</artifactId>
<version>${project.version}</version>
<scope>test</scope>
</dependency>
Expand Down
19 changes: 8 additions & 11 deletions repo/repo-sql-impl-test/src/main/resources/ctx-repository-test.xml
Expand Up @@ -8,26 +8,23 @@

<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd"
default-lazy-init="true">

<context:annotation-config/>
<context:component-scan base-package="com.evolveum.midpoint.repo.sql"/>
<!-- This @Configuration drives component-scan + can use @Conditional... -->
<bean id="sqlRepositoryBeanConfig" class="com.evolveum.midpoint.repo.sql.SqlRepositoryBeanConfig"/>

<!--
TODO: what about TestSqlRepositoryBeanConfig which would be analog of the above + have
all the beans below.
-->
<bean id="testInterceptor"
class="com.evolveum.midpoint.repo.sql.testing.TestInterceptor"/>

<bean id="testSqlRepositoryBeanPostProcessor"
class="com.evolveum.midpoint.repo.sql.testing.TestSqlRepositoryBeanPostProcessor"/>

<!--<bean id="testSqlRepositoryFactory"-->
<!-- class="com.evolveum.midpoint.repo.sql.testing.TestSqlRepositoryFactory"/>-->

<bean id="sqlAuditFactory" class="com.evolveum.midpoint.repo.sql.SqlAuditServiceFactory"/>

<bean id="testDataSourceFactory"
Expand Down
Expand Up @@ -10,8 +10,10 @@
import javax.sql.DataSource;

import org.hibernate.SessionFactory;
import org.springframework.boot.autoconfigure.condition.ConditionalOnExpression;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.orm.hibernate5.HibernateTransactionManager;
import org.springframework.orm.hibernate5.LocalSessionFactoryBean;
Expand All @@ -30,6 +32,14 @@
* would happen when combined with alternative configurations (e.g. context XMLs for test).
*/
@Configuration
// TODO: WIP - works for SqlRepositoryFactory, but probably we need to add Test version too.
// Also, this seems to have to be this ugly, because the following does NOT work:
// - @ConditionalOnBean(SqlRepositoryFactory.class) (RepositoryServiceFactory does, but that does not help)
// - @ConditionalOnExpression("#{repositoryFactory... something reasonable here,
// because RepositoryFactory is not initialized yet and all injected stuff is still null
@ConditionalOnExpression("#{midpointConfiguration.getConfiguration('midpoint.repository')"
+ ".getString('repositoryServiceFactoryClass').startsWith('com.evolveum.midpoint.repo.sql.')}")
@ComponentScan
public class SqlRepositoryBeanConfig {

@Bean
Expand Down
25 changes: 4 additions & 21 deletions repo/repo-sql-impl/src/main/resources/ctx-repository.xml
Expand Up @@ -8,29 +8,12 @@

<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd"
default-lazy-init="true">

<!-- TODO: consider the necessity of the whole config:
1. let SqlAuditServiceFactory initialize like SqlRepositoryFactory (AuditFactory creating the bean)
2. component-scan: probably necessary for EntityRegistry, SqlRepositoryBeanConfig and tons of @Components
Best thing would be to have a configuration that would recognize that SqlRepositoryFactory is used
(created by RepositoryFactory) and then autoscan the sql package, ignoring it otherwise.
Perhaps auto-configuration is a way... not sure yet.
Perhaps making RepositoryFactory @Configuration would help too.
-->

<!--<bean id="sqlRepositoryFactory"-->
<!-- class="com.evolveum.midpoint.repo.sql.SqlRepositoryFactory"/>-->
<!-- This @Configuration drives component-scan + can use @Conditional... -->
<bean id="sqlRepositoryBeanConfig" class="com.evolveum.midpoint.repo.sql.SqlRepositoryBeanConfig"/>

<bean id="sqlAuditFactory" class="com.evolveum.midpoint.repo.sql.SqlAuditServiceFactory"/>

<context:annotation-config/>
<context:component-scan base-package="com.evolveum.midpoint.repo.sql"/>
</beans>
2 changes: 1 addition & 1 deletion repo/security-impl/pom.xml
Expand Up @@ -130,7 +130,7 @@
</dependency>
<dependency>
<groupId>com.evolveum.midpoint.repo</groupId>
<artifactId>audit-impl</artifactId>
<artifactId>audit-log-impl</artifactId>
<version>4.3-SNAPSHOT</version>
<scope>test</scope>
</dependency>
Expand Down
2 changes: 1 addition & 1 deletion repo/task-quartz-impl/pom.xml
Expand Up @@ -163,7 +163,7 @@
</dependency>
<dependency>
<groupId>com.evolveum.midpoint.repo</groupId>
<artifactId>audit-impl</artifactId>
<artifactId>audit-log-impl</artifactId>
<version>4.3-SNAPSHOT</version>
<scope>test</scope>
</dependency>
Expand Down
2 changes: 1 addition & 1 deletion testing/conntest/pom.xml
Expand Up @@ -97,7 +97,7 @@
</dependency>
<dependency>
<groupId>com.evolveum.midpoint.repo</groupId>
<artifactId>audit-impl</artifactId>
<artifactId>audit-log-impl</artifactId>
<version>4.3-SNAPSHOT</version>
<scope>runtime</scope>
</dependency>
Expand Down
2 changes: 1 addition & 1 deletion testing/longtest/pom.xml
Expand Up @@ -86,7 +86,7 @@
</dependency>
<dependency>
<groupId>com.evolveum.midpoint.repo</groupId>
<artifactId>audit-impl</artifactId>
<artifactId>audit-log-impl</artifactId>
<version>4.3-SNAPSHOT</version>
<scope>runtime</scope>
</dependency>
Expand Down
2 changes: 1 addition & 1 deletion testing/rest/pom.xml
Expand Up @@ -98,7 +98,7 @@
</dependency>
<dependency>
<groupId>com.evolveum.midpoint.repo</groupId>
<artifactId>audit-impl</artifactId>
<artifactId>audit-log-impl</artifactId>
<version>4.3-SNAPSHOT</version>
<scope>runtime</scope>
</dependency>
Expand Down
2 changes: 1 addition & 1 deletion testing/story/pom.xml
Expand Up @@ -127,7 +127,7 @@
</dependency>
<dependency>
<groupId>com.evolveum.midpoint.repo</groupId>
<artifactId>audit-impl</artifactId>
<artifactId>audit-log-impl</artifactId>
<version>4.3-SNAPSHOT</version>
<scope>runtime</scope>
</dependency>
Expand Down
2 changes: 1 addition & 1 deletion tools/ninja/pom.xml
Expand Up @@ -125,7 +125,7 @@
</dependency>
<dependency>
<groupId>com.evolveum.midpoint.repo</groupId>
<artifactId>audit-impl</artifactId>
<artifactId>audit-log-impl</artifactId>
<version>${midpoint.version}</version>
<scope>runtime</scope>
</dependency>
Expand Down

0 comments on commit aec144d

Please sign in to comment.