[Trunk | Orcid Service]:

1. MetricsController.java: Added @PreAuthorize in "calculateMetrics()" (/report/calc) method, to be executed only by Portal Administrators.
2. pom.xml: Revert from r61634 changes for parent and plugins: now from "dnet45-parent" to "spring-boot-starter-parent".
This commit is contained in:
Konstantina Galouni 2021-10-07 13:14:02 +00:00
parent 7b572041aa
commit 604f5d790c
2 changed files with 30 additions and 28 deletions

56
pom.xml
View File

@ -10,20 +10,20 @@
<name>uoa-orcid-service</name>
<!-- 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>-->
<!-- <groupId>org.springframework.boot</groupId>-->
<!-- <artifactId>spring-boot-starter-parent</artifactId>-->
<!-- <version>1.5.11.RELEASE</version>-->
<!-- <relativePath/> &lt;!&ndash; lookup parent from repository &ndash;&gt;-->
<!-- </parent>-->
<!-- 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>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.5.11.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<!-- Comment parent with artifact dnet45-parent and <dependencyManagement> in order to run springboot run command -->
<parent>
<groupId>eu.dnetlib</groupId>
<artifactId>dnet45-parent</artifactId>
<version>1.0.0</version>
</parent>
<!-- <parent>-->
<!-- <groupId>eu.dnetlib</groupId>-->
<!-- <artifactId>dnet45-parent</artifactId>-->
<!-- <version>1.0.0</version>-->
<!-- </parent>-->
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
@ -34,17 +34,17 @@
</properties>
<!-- Comment parent with artifact dnet45-parent and <dependencyManagement> in order to run springboot run command -->
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-dependencies</artifactId>
<version>1.5.11.RELEASE</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<!-- <dependencyManagement>-->
<!-- <dependencies>-->
<!-- <dependency>-->
<!-- <groupId>org.springframework.boot</groupId>-->
<!-- <artifactId>spring-boot-dependencies</artifactId>-->
<!-- <version>1.5.11.RELEASE</version>-->
<!-- <type>pom</type>-->
<!-- <scope>import</scope>-->
<!-- </dependency>-->
<!-- </dependencies>-->
<!-- </dependencyManagement>-->
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
@ -112,11 +112,11 @@
<build>
<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>-->
<!-- <groupId>org.springframework.boot</groupId>-->
<!-- <artifactId>spring-boot-maven-plugin</artifactId>-->
<!-- </plugin>-->
<!-- 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>
<groupId>org.springframework.boot</groupId>
<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>-->

View File

@ -4,6 +4,7 @@ import eu.dnetlib.uoaorcidservice.configuration.properties.OrcidConfig;
import eu.dnetlib.uoaorcidservice.services.MetricsService;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
@ -81,6 +82,7 @@ public class MetricsController {
return metricsService.getMetrics();
}
@PreAuthorize("hasAnyAuthority(@AuthorizationService.PORTAL_ADMIN)")
@RequestMapping(value = "/report/calc", method = RequestMethod.GET)
public String calculateMetrics() {
metricsService.calculateMetrics();