Merge branch 'log4j2'

This commit is contained in:
Konstantinos Triantafyllou 2022-11-22 17:43:46 +02:00
commit 29cc52a65f
19 changed files with 263 additions and 127 deletions

94
pom.xml
View File

@ -3,28 +3,21 @@
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<groupId>eu.dnetlib</groupId>
<artifactId>uoa-monitor-service</artifactId> <artifactId>uoa-monitor-service</artifactId>
<version>1.0.4-SNAPSHOT</version> <version>1.0.4-SNAPSHOT</version>
<packaging>war</packaging> <packaging>war</packaging>
<name>uoa-monitor-service</name> <name>uoa-monitor-service</name>
<scm> <scm>
<connection>scm:git:gitea@code-repo.d4science.org:MaDgIK/uoa-monitor-service.git</connection>
<developerConnection>scm:git:gitea@code-repo.d4science.org:MaDgIK/uoa-monitor-service.git</developerConnection> <developerConnection>scm:git:gitea@code-repo.d4science.org:MaDgIK/uoa-monitor-service.git</developerConnection>
<url>https://code-repo.d4science.org/MaDgIK/uoa-monitor-service/</url>
</scm> </scm>
<!-- Use parent with artifact spring-boot-starter-parent and add plugin with artifact spring-boot-maven-plugin in order to run springboot run command-->
<parent> <parent>
<groupId>org.springframework.boot</groupId> <groupId>eu.dnetlib</groupId>
<artifactId>spring-boot-starter-parent</artifactId> <artifactId>uoa-spring-boot-parent</artifactId>
<version>1.5.8.RELEASE</version> <version>1.0.0</version>
<relativePath/> <!-- lookup parent from repository -->
</parent> </parent>
<properties> <properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding> <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
<timestamp>${maven.build.timestamp}</timestamp> <timestamp>${maven.build.timestamp}</timestamp>
<maven.build.timestamp.format>E MMM dd HH:mm:ss z yyyy</maven.build.timestamp.format> <maven.build.timestamp.format>E MMM dd HH:mm:ss z yyyy</maven.build.timestamp.format>
</properties> </properties>
@ -33,74 +26,49 @@
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-mongodb</artifactId> <artifactId>spring-boot-starter-data-mongodb</artifactId>
</dependency> </dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<exclusions>
<exclusion>
<groupId> org.springframework.boot</groupId>
<artifactId>spring-boot-starter-logging</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.17</version>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.8.2</version>
</dependency>
<dependency> <!-- this dependency includes dependency to uoa-authorization-library --> <dependency> <!-- this dependency includes dependency to uoa-authorization-library -->
<groupId>eu.dnetlib</groupId> <groupId>eu.dnetlib</groupId>
<artifactId>uoa-admin-tools-library</artifactId> <artifactId>uoa-admin-tools-library</artifactId>
<version>1.0.5</version> <version>1.0.6</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>eu.dnetlib</groupId> <groupId>eu.dnetlib</groupId>
<artifactId>uoa-notification-service</artifactId> <artifactId>uoa-notification-service</artifactId>
<version>1.0.5</version> <version>1.0.6</version>
</dependency> </dependency>
<!--swagger-->
<dependency> <dependency>
<groupId>org.springframework.boot</groupId> <groupId>io.springfox</groupId>
<artifactId>spring-boot-starter-test</artifactId> <artifactId>springfox-swagger2</artifactId>
<scope>test</scope> <version>${swagger-version}</version>
</dependency> </dependency>
<!--swagger official ui-->
<dependency> <dependency>
<groupId>org.springframework.boot</groupId> <groupId>io.springfox</groupId>
<artifactId>spring-boot-starter-security</artifactId> <artifactId>springfox-swagger-ui</artifactId>
<version>${swagger-version}</version>
</dependency> </dependency>
</dependencies> </dependencies>
<build> <build>
<plugins> <plugins>
<!-- Use parent with artifact spring-boot-starter-parent and add plugin with artifact spring-boot-maven-plugin in order to run springboot run command-->
<plugin> <plugin>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId> <artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<!--3d answer: https://stackoverflow.com/questions/23260057/the-forked-vm-terminated-without-saying-properly-goodbye-vm-crash-or-system-exi-->
<!--If you use openjdk there might be a problem with surfire plugin - uncomment following lines-->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.19.1</version>
<configuration> <configuration>
<!--<testFailureIgnore>true</testFailureIgnore>--> <mainClass>eu.dnetlib.uoamonitorservice.UoaMonitorServiceApplication</mainClass>
<useSystemClassLoader>false</useSystemClassLoader> <executable>true</executable>
</configuration> </configuration>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
</plugin> </plugin>
<plugin> <plugin>
<groupId>org.apache.maven.plugins</groupId> <groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId> <artifactId>maven-war-plugin</artifactId>
@ -109,7 +77,6 @@
<failOnMissingWebXml>false</failOnMissingWebXml> <failOnMissingWebXml>false</failOnMissingWebXml>
</configuration> </configuration>
</plugin> </plugin>
</plugins> </plugins>
<finalName>uoa-monitor-service</finalName> <finalName>uoa-monitor-service</finalName>
<resources> <resources>
@ -119,19 +86,4 @@
</resource> </resource>
</resources> </resources>
</build> </build>
<repositories>
<repository>
<id>dnet45-releases</id>
<name>D-Net 45 Releases</name>
<url>http://maven.research-infrastructures.eu/nexus/content/repositories/dnet45-releases</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
<layout>default</layout>
</repository>
</repositories>
</project> </project>

View File

@ -3,6 +3,7 @@ package eu.dnetlib.uoamonitorservice;
import eu.dnetlib.uoaadmintoolslibrary.UoaAdminToolsLibraryConfiguration; import eu.dnetlib.uoaadmintoolslibrary.UoaAdminToolsLibraryConfiguration;
import eu.dnetlib.uoaauthorizationlibrary.configuration.AuthorizationConfiguration; import eu.dnetlib.uoaauthorizationlibrary.configuration.AuthorizationConfiguration;
import eu.dnetlib.uoamonitorservice.configuration.GlobalVars; import eu.dnetlib.uoamonitorservice.configuration.GlobalVars;
import eu.dnetlib.uoamonitorservice.configuration.properties.APIProperties;
import eu.dnetlib.uoamonitorservice.configuration.properties.MongoConfig; import eu.dnetlib.uoamonitorservice.configuration.properties.MongoConfig;
import eu.dnetlib.uoanotificationservice.configuration.NotificationConfiguration; import eu.dnetlib.uoanotificationservice.configuration.NotificationConfiguration;
import org.springframework.boot.SpringApplication; import org.springframework.boot.SpringApplication;
@ -20,7 +21,7 @@ import org.springframework.context.annotation.PropertySources;
@PropertySource("classpath:monitorservice.properties"), @PropertySource("classpath:monitorservice.properties"),
@PropertySource(value = "classpath:dnet-override.properties", ignoreResourceNotFound = true) @PropertySource(value = "classpath:dnet-override.properties", ignoreResourceNotFound = true)
}) })
@EnableConfigurationProperties({ MongoConfig.class, GlobalVars.class}) @EnableConfigurationProperties({ MongoConfig.class, GlobalVars.class, APIProperties.class})
@Import({AuthorizationConfiguration.class, UoaAdminToolsLibraryConfiguration.class, NotificationConfiguration.class}) @Import({AuthorizationConfiguration.class, UoaAdminToolsLibraryConfiguration.class, NotificationConfiguration.class})
public class UoaMonitorServiceApplication { public class UoaMonitorServiceApplication {
public static void main(String[] args) { public static void main(String[] args) {

View File

@ -1,6 +1,7 @@
package eu.dnetlib.uoamonitorservice; package eu.dnetlib.uoamonitorservice;
import org.apache.log4j.Logger; import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
import org.springframework.context.support.PropertySourcesPlaceholderConfigurer; import org.springframework.context.support.PropertySourcesPlaceholderConfigurer;
@ -8,7 +9,7 @@ import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter
@Configuration @Configuration
public class UoaMonitorServiceConfiguration extends WebMvcConfigurerAdapter { public class UoaMonitorServiceConfiguration extends WebMvcConfigurerAdapter {
private final Logger log = Logger.getLogger(this.getClass()); private final Logger log = LogManager.getLogger(this.getClass());
@Bean @Bean
public static PropertySourcesPlaceholderConfigurer propertySourcesPlaceholderConfigurer() { public static PropertySourcesPlaceholderConfigurer propertySourcesPlaceholderConfigurer() {

View File

@ -0,0 +1,119 @@
package eu.dnetlib.uoamonitorservice.configuration;
import eu.dnetlib.uoamonitorservice.configuration.properties.APIProperties;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Profile;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.ViewControllerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.ParameterBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.schema.ModelRef;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Parameter;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;
import java.util.Collections;
import java.util.List;
/**
* Swagger configuration class
*/
@Configuration
@Profile({"swagger"})
@EnableSwagger2
public class SwaggerConfig extends WebMvcConfigurerAdapter {
private final APIProperties apiProperties;
@Autowired
public SwaggerConfig(APIProperties apiProperties) {
this.apiProperties = apiProperties;
}
@Bean
public Docket createRestApi() {
return new Docket(DocumentationType.SWAGGER_2)
// .globalOperationParameters(globalParameterList())
.apiInfo(apiInfo())
.select()
.apis(RequestHandlerSelectors.basePackage("eu.dnetlib.uoamonitorservice.controllers"))
.paths(PathSelectors.any())
.build();
}
@Bean
public Docket createRestApiLibrary() {
return new Docket(DocumentationType.SWAGGER_2)
.apiInfo(apiInfo())
.groupName("Library")
.select()
.apis(RequestHandlerSelectors.basePackage("eu.dnetlib.uoaadmintoolslibrary.controllers"))
.paths(PathSelectors.any())
.build();
}
@Bean
public Docket createRestApiAuthorizationLibrary() {
return new Docket(DocumentationType.SWAGGER_2)
.apiInfo(apiInfo())
.groupName("Authorization Library")
.select()
.apis(RequestHandlerSelectors.basePackage("eu.dnetlib.uoaauthorizationlibrary.controllers"))
.paths(PathSelectors.any())
.build();
}
@Bean
public Docket createRestApiNotificationLibrary() {
return new Docket(DocumentationType.SWAGGER_2)
.apiInfo(apiInfo())
.groupName("Notification Service")
.select()
.apis(RequestHandlerSelectors.basePackage("eu.dnetlib.uoanotificationservice.controllers"))
.paths(PathSelectors.any())
.build();
}
private ApiInfo apiInfo() {
return new ApiInfoBuilder()
.title(this.apiProperties.getTitle())
.description(this.apiProperties.getDescription())
.version(this.apiProperties.getVersion())
.build();
}
private List<Parameter> globalParameterList() {
Parameter authTokenHeader = new ParameterBuilder()
.name("Session") // name of the header
.modelRef(new ModelRef("string")) // data-type of the header
.required(false)
.parameterType("header")
.description("Session ID")
.build();
return Collections.singletonList(authTokenHeader);
}
@Override
public void addViewControllers(ViewControllerRegistry registry) {
registry.addRedirectViewController("/v2/api-docs", "/v2/api-docs");
registry.addRedirectViewController("/swagger-resources/configuration/ui", "/swagger-resources/configuration/ui");
registry.addRedirectViewController("/swagger-resources/configuration/security", "/swagger-resources/configuration/security");
registry.addRedirectViewController("/swagger-resources", "/swagger-resources");
}
@Override
public void addResourceHandlers(ResourceHandlerRegistry registry) {
registry.addResourceHandler("/swagger-ui.html**").addResourceLocations("classpath:/META-INF/resources/swagger-ui.html");
registry.addResourceHandler("/webjars/**").addResourceLocations("classpath:/META-INF/resources/webjars/");
}
}

View File

@ -0,0 +1,38 @@
package eu.dnetlib.uoamonitorservice.configuration.properties;
import org.springframework.boot.context.properties.ConfigurationProperties;
@ConfigurationProperties("api")
public class APIProperties {
private String title;
private String description;
private String version;
public APIProperties() {
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public String getVersion() {
return version;
}
public void setVersion(String version) {
this.version = version;
}
}

View File

@ -6,9 +6,9 @@ import eu.dnetlib.uoamonitorservice.entities.*;
import eu.dnetlib.uoamonitorservice.handlers.EntityNotFoundException; import eu.dnetlib.uoamonitorservice.handlers.EntityNotFoundException;
import eu.dnetlib.uoaadmintoolslibrary.handlers.ForbiddenException; import eu.dnetlib.uoaadmintoolslibrary.handlers.ForbiddenException;
import eu.dnetlib.uoamonitorservice.handlers.PathNotValidException; import eu.dnetlib.uoamonitorservice.handlers.PathNotValidException;
import org.apache.log4j.Logger; import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.AccessDeniedException;
import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
@ -20,7 +20,7 @@ import java.util.List;
@RestController @RestController
@CrossOrigin(origins = "*") @CrossOrigin(origins = "*")
public class CategoryController { public class CategoryController {
private final Logger log = Logger.getLogger(this.getClass()); private final Logger log = LogManager.getLogger(this.getClass());
@Autowired @Autowired
private RolesUtils rolesUtils; private RolesUtils rolesUtils;

View File

@ -1,16 +1,12 @@
package eu.dnetlib.uoamonitorservice.controllers; package eu.dnetlib.uoamonitorservice.controllers;
//import eu.dnetlib.uoahelptexts.emailSender.EmailSender;
//import eu.dnetlib.uoahelptexts.entities.EmailRecaptcha;
//import eu.dnetlib.uoahelptexts.entities.Email;
//import eu.dnetlib.uoahelptexts.handlers.InvalidReCaptchaException;
//import eu.dnetlib.uoahelptexts.recaptcha.VerifyRecaptcha;
import eu.dnetlib.uoaadmintoolslibrary.emailSender.EmailSender; import eu.dnetlib.uoaadmintoolslibrary.emailSender.EmailSender;
import eu.dnetlib.uoaadmintoolslibrary.entities.email.Email; import eu.dnetlib.uoaadmintoolslibrary.entities.email.Email;
import eu.dnetlib.uoaadmintoolslibrary.entities.email.EmailRecaptcha; import eu.dnetlib.uoaadmintoolslibrary.entities.email.EmailRecaptcha;
import eu.dnetlib.uoaadmintoolslibrary.handlers.InvalidReCaptchaException; import eu.dnetlib.uoaadmintoolslibrary.handlers.InvalidReCaptchaException;
import eu.dnetlib.uoaadmintoolslibrary.recaptcha.VerifyRecaptcha; import eu.dnetlib.uoaadmintoolslibrary.recaptcha.VerifyRecaptcha;
import org.apache.log4j.Logger; import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
@ -19,7 +15,7 @@ import java.util.*;
@RestController @RestController
@CrossOrigin(origins = "*") @CrossOrigin(origins = "*")
public class EmailController { public class EmailController {
private final Logger log = Logger.getLogger(this.getClass()); private final Logger log = LogManager.getLogger(this.getClass());
@Autowired @Autowired
private EmailSender emailSender; private EmailSender emailSender;

View File

@ -7,7 +7,8 @@ import eu.dnetlib.uoamonitorservice.entities.*;
import eu.dnetlib.uoamonitorservice.handlers.EntityNotFoundException; import eu.dnetlib.uoamonitorservice.handlers.EntityNotFoundException;
import eu.dnetlib.uoaadmintoolslibrary.handlers.ForbiddenException; import eu.dnetlib.uoaadmintoolslibrary.handlers.ForbiddenException;
import eu.dnetlib.uoamonitorservice.handlers.PathNotValidException; import eu.dnetlib.uoamonitorservice.handlers.PathNotValidException;
import org.apache.log4j.Logger; import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
@ -18,7 +19,7 @@ import java.util.*;
@RestController @RestController
@CrossOrigin(origins = "*") @CrossOrigin(origins = "*")
public class IndicatorController { public class IndicatorController {
private final Logger log = Logger.getLogger(this.getClass()); private final Logger log = LogManager.getLogger(this.getClass());
@Autowired @Autowired
private RolesUtils rolesUtils; private RolesUtils rolesUtils;

View File

@ -3,7 +3,8 @@ package eu.dnetlib.uoamonitorservice.controllers;
import eu.dnetlib.uoaadmintoolslibrary.entities.Portal; import eu.dnetlib.uoaadmintoolslibrary.entities.Portal;
import eu.dnetlib.uoaadmintoolslibrary.entities.fullEntities.*; import eu.dnetlib.uoaadmintoolslibrary.entities.fullEntities.*;
import eu.dnetlib.uoaadmintoolslibrary.services.PortalService; import eu.dnetlib.uoaadmintoolslibrary.services.PortalService;
import org.apache.log4j.Logger; import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
@ -13,7 +14,7 @@ import java.util.*;
@RequestMapping(value={"/monitor", "/funder", "/project", "/ri", "/organization"}) @RequestMapping(value={"/monitor", "/funder", "/project", "/ri", "/organization"})
@CrossOrigin(origins = "*") @CrossOrigin(origins = "*")
public class MonitorController { public class MonitorController {
private final Logger log = Logger.getLogger(this.getClass()); private final Logger log = LogManager.getLogger(this.getClass());
// //
// @Autowired // @Autowired
// private LayoutService layoutService; // private LayoutService layoutService;

View File

@ -6,7 +6,8 @@ import com.mongodb.DBObject;
import eu.dnetlib.uoamonitorservice.configuration.GlobalVars; import eu.dnetlib.uoamonitorservice.configuration.GlobalVars;
import eu.dnetlib.uoamonitorservice.configuration.mongo.MongoConnection; import eu.dnetlib.uoamonitorservice.configuration.mongo.MongoConnection;
import eu.dnetlib.uoamonitorservice.configuration.properties.MongoConfig; import eu.dnetlib.uoamonitorservice.configuration.properties.MongoConfig;
import org.apache.log4j.Logger; import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.mongodb.core.MongoTemplate; import org.springframework.data.mongodb.core.MongoTemplate;
import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.security.access.prepost.PreAuthorize;
@ -15,14 +16,13 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import java.util.Date;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
@RestController @RestController
@CrossOrigin(origins = "*") @CrossOrigin(origins = "*")
public class MonitorServiceCheckDeployController { public class MonitorServiceCheckDeployController {
private final Logger log = Logger.getLogger(this.getClass()); private final Logger log = LogManager.getLogger(this.getClass());
@Autowired @Autowired
private MongoConnection mongoConnection; private MongoConnection mongoConnection;

View File

@ -6,9 +6,9 @@ import eu.dnetlib.uoamonitorservice.entities.*;
import eu.dnetlib.uoamonitorservice.handlers.EntityNotFoundException; import eu.dnetlib.uoamonitorservice.handlers.EntityNotFoundException;
import eu.dnetlib.uoaadmintoolslibrary.handlers.ForbiddenException; import eu.dnetlib.uoaadmintoolslibrary.handlers.ForbiddenException;
import eu.dnetlib.uoamonitorservice.handlers.PathNotValidException; import eu.dnetlib.uoamonitorservice.handlers.PathNotValidException;
import org.apache.log4j.Logger; import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.AccessDeniedException;
import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
@ -20,7 +20,7 @@ import java.util.List;
@RestController @RestController
@CrossOrigin(origins = "*") @CrossOrigin(origins = "*")
public class SectionController { public class SectionController {
private final Logger log = Logger.getLogger(this.getClass()); private final Logger log = LogManager.getLogger(this.getClass());
@Autowired @Autowired
private RolesUtils rolesUtils; private RolesUtils rolesUtils;

View File

@ -7,7 +7,8 @@ import eu.dnetlib.uoamonitorservice.dao.*;
import eu.dnetlib.uoamonitorservice.entities.*; import eu.dnetlib.uoamonitorservice.entities.*;
import eu.dnetlib.uoamonitorservice.handlers.EntityNotFoundException; import eu.dnetlib.uoamonitorservice.handlers.EntityNotFoundException;
import eu.dnetlib.uoaadmintoolslibrary.handlers.ForbiddenException; import eu.dnetlib.uoaadmintoolslibrary.handlers.ForbiddenException;
import org.apache.log4j.Logger; import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.AccessDeniedException; import org.springframework.security.access.AccessDeniedException;
@ -19,7 +20,7 @@ import java.util.*;
@RestController @RestController
@CrossOrigin(origins = "*") @CrossOrigin(origins = "*")
public class StakeholderController { public class StakeholderController {
private final Logger log = Logger.getLogger(this.getClass()); private final Logger log = LogManager.getLogger(this.getClass());
@Autowired @Autowired
private RolesUtils rolesUtils; private RolesUtils rolesUtils;

View File

@ -6,9 +6,9 @@ import eu.dnetlib.uoamonitorservice.entities.*;
import eu.dnetlib.uoamonitorservice.handlers.EntityNotFoundException; import eu.dnetlib.uoamonitorservice.handlers.EntityNotFoundException;
import eu.dnetlib.uoaadmintoolslibrary.handlers.ForbiddenException; import eu.dnetlib.uoaadmintoolslibrary.handlers.ForbiddenException;
import eu.dnetlib.uoamonitorservice.handlers.PathNotValidException; import eu.dnetlib.uoamonitorservice.handlers.PathNotValidException;
import org.apache.log4j.Logger; import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.AccessDeniedException;
import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
@ -20,7 +20,7 @@ import java.util.List;
@RestController @RestController
@CrossOrigin(origins = "*") @CrossOrigin(origins = "*")
public class SubCategoryController { public class SubCategoryController {
private final Logger log = Logger.getLogger(this.getClass()); private final Logger log = LogManager.getLogger(this.getClass());
@Autowired @Autowired
private RolesUtils rolesUtils; private RolesUtils rolesUtils;

View File

@ -1,9 +1,9 @@
package eu.dnetlib.uoamonitorservice.controllers; package eu.dnetlib.uoamonitorservice.controllers;
import eu.dnetlib.uoamonitorservice.dao.StakeholderDAO; import eu.dnetlib.uoamonitorservice.dao.StakeholderDAO;
import eu.dnetlib.uoamonitorservice.entities.Stakeholder; import eu.dnetlib.uoamonitorservice.entities.Stakeholder;
import org.apache.log4j.Logger; import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
@ -12,7 +12,7 @@ import java.util.List;
@RestController @RestController
@CrossOrigin(origins = "*") @CrossOrigin(origins = "*")
public class TestController { public class TestController {
private final Logger log = Logger.getLogger(this.getClass()); private final Logger log = LogManager.getLogger(this.getClass());
@Autowired @Autowired
private StakeholderDAO stakeholderDAO; private StakeholderDAO stakeholderDAO;

View File

@ -6,7 +6,8 @@ import eu.dnetlib.uoamonitorservice.entities.*;
import eu.dnetlib.uoamonitorservice.handlers.EntityNotFoundException; import eu.dnetlib.uoamonitorservice.handlers.EntityNotFoundException;
import eu.dnetlib.uoaadmintoolslibrary.handlers.ForbiddenException; import eu.dnetlib.uoaadmintoolslibrary.handlers.ForbiddenException;
import eu.dnetlib.uoamonitorservice.handlers.PathNotValidException; import eu.dnetlib.uoamonitorservice.handlers.PathNotValidException;
import org.apache.log4j.Logger; import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
@ -19,7 +20,7 @@ import java.util.List;
@RestController @RestController
@CrossOrigin(origins = "*") @CrossOrigin(origins = "*")
public class TopicController { public class TopicController {
private final Logger log = Logger.getLogger(this.getClass()); private final Logger log = LogManager.getLogger(this.getClass());
@Autowired @Autowired
private RolesUtils rolesUtils; private RolesUtils rolesUtils;

View File

@ -1,7 +1,8 @@
package eu.dnetlib.uoamonitorservice.handlers; package eu.dnetlib.uoamonitorservice.handlers;
import eu.dnetlib.uoaadmintoolslibrary.responses.ExceptionResponse; import eu.dnetlib.uoaadmintoolslibrary.responses.ExceptionResponse;
import org.apache.log4j.Logger; import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.http.HttpStatus; import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.ControllerAdvice; import org.springframework.web.bind.annotation.ControllerAdvice;
@ -11,7 +12,7 @@ import org.springframework.web.bind.annotation.RestController;
@ControllerAdvice @ControllerAdvice
@RestController @RestController
public class ExceptionsHandler { public class ExceptionsHandler {
private final Logger log = Logger.getLogger(this.getClass()); private final Logger log = LogManager.getLogger(this.getClass());
@ExceptionHandler(EntityNotFoundException.class) @ExceptionHandler(EntityNotFoundException.class)
public ResponseEntity<ExceptionResponse> entityNotFoundException(Exception ex) { public ResponseEntity<ExceptionResponse> entityNotFoundException(Exception ex) {

View File

@ -17,3 +17,8 @@
spring.data.mongodb.host=localhost spring.data.mongodb.host=localhost
spring.data.mongodb.port=27017 spring.data.mongodb.port=27017
spring.data.mongodb.database=openaire_monitor spring.data.mongodb.database=openaire_monitor
#static properties
api.title = Uoa Monitor Service Documentation Swagger
api.description = Uoa Monitor Service is a service which serves and saves dynamic content and indicators (numbers & charts)
api.version = ${project.version}

View File

@ -1,20 +0,0 @@
log4j.rootLogger = DEBUG, R
log4j.logger.eu.dnetlib = DEBUG
log4j.logger.org.springframework = DEBUG, S
log4j.additivity.org.springframework = false
log4j.appender.R=org.apache.log4j.RollingFileAppender
log4j.appender.R.File=/var/log/dnet/uoa-monitor-service/uoa-monitor-service.log
log4j.appender.R.MaxFileSize=10MB
log4j.appender.R.MaxBackupIndex=10
log4j.appender.R.layout=org.apache.log4j.PatternLayout
log4j.appender.R.layout.ConversionPattern= %d %p %t [%c] - %m%n
log4j.appender.S=org.apache.log4j.RollingFileAppender
log4j.appender.S.File=/var/log/dnet/uoa-monitor-service/uoa-monitor-service-spring.log
log4j.appender.S.MaxFileSize=10MB
log4j.appender.S.MaxBackupIndex=10
log4j.appender.S.layout=org.apache.log4j.PatternLayout
log4j.appender.S.layout.ConversionPattern= %d %p %t [%c] - %m%n

View File

@ -0,0 +1,39 @@
<?xml version="1.0" encoding="UTF-8"?>
<Configuration status="WARN" monitorInterval="30">
<Properties>
<Property name="LOG_PATTERN">
%d %p %t [%c] - %m%n
</Property>
</Properties>
<Appenders>
<!-- Rolling File Appender -->
<RollingFile name="R" fileName="/var/log/dnet/uoa-monitor-service/uoa-monitor-service.log"
filePattern="/var/log/dnet/uoa-monitor-service/uoa-monitor-service-%d{yyyy-MM-dd}-%i.log">
<PatternLayout>
<Pattern>${LOG_PATTERN}</Pattern>
</PatternLayout>
<Policies>
<SizeBasedTriggeringPolicy size="10MB" />
</Policies>
<DefaultRolloverStrategy max="10"/>
</RollingFile>
<RollingFile name="S" fileName="/var/log/dnet/uoa-monitor-service/uoa-monitor-service-spring.log"
filePattern="/var/log/dnet/uoa-monitor-service/uoa-monitor-service-spring-%d{yyyy-MM-dd}-%i.log">
<PatternLayout>
<Pattern>${LOG_PATTERN}</Pattern>
</PatternLayout>
<Policies>
<SizeBasedTriggeringPolicy size="10MB" />
</Policies>
<DefaultRolloverStrategy max="10"/>
</RollingFile>
</Appenders>
<Loggers>
<Logger name="eu.dnetlib" level="debug" additivity="false">
<AppenderRef ref="R"/>
</Logger>
<Root level="info">
<AppenderRef ref="S"/>
</Root>
</Loggers>
</Configuration>