Loading pom.xml +15 −106 Original line number Diff line number Diff line Loading @@ -3,10 +3,9 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> <version>2.4.5</version> <relativePath/> <!-- lookup parent from repository --> <groupId>it.inaf.ia2</groupId> <artifactId>vospace-parent</artifactId> <version>0.0.1-SNAPSHOT</version> </parent> <groupId>it.inaf.ia2</groupId> <artifactId>vospace-file-service</artifactId> Loading @@ -18,61 +17,14 @@ <finalName>${project.artifactId}-${project.version}</finalName> <!-- File catalog repository directory --> <init_database_scripts_path>../../../vospace-file-catalog</init_database_scripts_path> <zonky.postgres-binaries.version>12.5.0</zonky.postgres-binaries.version> </properties> <dependencies> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-jdbc</artifactId> </dependency> <dependency> <groupId>org.postgresql</groupId> <artifactId>postgresql</artifactId> <scope>runtime</scope> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-devtools</artifactId> <scope>runtime</scope> <optional>true</optional> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-test</artifactId> <scope>test</scope> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-configuration-processor</artifactId> <optional>true</optional> </dependency> <dependency> <groupId>${project.groupId}</groupId> <artifactId>rap-client</artifactId> <version>1.0-SNAPSHOT</version> </dependency> <!-- Embedded PostgreSQL: --> <dependency> <groupId>com.opentable.components</groupId> <artifactId>otj-pg-embedded</artifactId> <version>0.13.3</version> <scope>test</scope> </dependency> <dependency> <groupId>it.oats.inaf</groupId> <artifactId>vospace-datamodel</artifactId> <version>1.0-SNAPSHOT</version> <groupId>it.inaf.ia2</groupId> <artifactId>vospace-parent-classes</artifactId> <version>0.0.1-SNAPSHOT</version> </dependency> <dependency> <groupId>org.kamranzafar</groupId> <artifactId>jtar</artifactId> Loading @@ -80,49 +32,6 @@ </dependency> </dependencies> <profiles> <profile> <id>platform-linux</id> <activation> <os> <family>unix</family> </os> </activation> <dependencies> <dependency> <groupId>io.zonky.test.postgres</groupId> <artifactId>embedded-postgres-binaries-linux-amd64</artifactId> <version>${zonky.postgres-binaries.version}</version> <scope>test</scope> </dependency> </dependencies> </profile> <profile> <id>platform-windows</id> <activation> <os> <family>windows</family> </os> </activation> <dependencies> <dependency> <groupId>io.zonky.test.postgres</groupId> <artifactId>embedded-postgres-binaries-windows-amd64</artifactId> <version>${zonky.postgres-binaries.version}</version> <scope>test</scope> </dependency> </dependencies> </profile> </profiles> <repositories> <repository> <id>ia2-snapshots</id> <name>your custom repo</name> <url>http://repo.ia2.inaf.it/maven/repository/snapshots</url> </repository> </repositories> <build> <finalName>${finalName}</finalName> <testResources> Loading @@ -145,13 +54,6 @@ </testResource> </testResources> <plugins> <plugin> <artifactId>maven-surefire-plugin</artifactId> <version>2.22.2</version> <configuration> <trimStackTrace>false</trimStackTrace> </configuration> </plugin> <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> Loading @@ -162,7 +64,6 @@ <plugin> <groupId>org.jacoco</groupId> <artifactId>jacoco-maven-plugin</artifactId> <version>0.8.6</version> <executions> <execution> <goals> Loading @@ -181,4 +82,12 @@ </plugins> </build> <repositories> <repository> <id>ia2-snapshots</id> <name>IA2 snapshot repository</name> <url>http://repo.ia2.inaf.it/maven/repository/snapshots</url> </repository> </repositories> </project> src/main/java/it/inaf/ia2/transfer/controller/ArchiveFileController.java +1 −0 Original line number Diff line number Diff line Loading @@ -9,6 +9,7 @@ import it.inaf.ia2.transfer.auth.TokenPrincipal; import it.inaf.ia2.transfer.service.ArchiveJob; import it.inaf.ia2.transfer.service.ArchiveJob.Type; import it.inaf.ia2.transfer.service.ArchiveService; import it.inaf.oats.vospace.exception.PermissionDeniedException; import java.io.File; import java.util.concurrent.CompletableFuture; import javax.servlet.http.HttpServletResponse; Loading src/main/java/it/inaf/ia2/transfer/controller/ErrorController.java 0 → 100644 +20 −0 Original line number Diff line number Diff line /* * This file is part of vospace-rest * Copyright (C) 2021 Istituto Nazionale di Astrofisica * SPDX-License-Identifier: GPL-3.0-or-later */ package it.inaf.ia2.transfer.controller; import it.inaf.oats.vospace.exception.DefaultErrorController; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.web.servlet.error.ErrorAttributes; import org.springframework.web.bind.annotation.RestController; @RestController public class ErrorController extends DefaultErrorController { @Autowired public ErrorController(ErrorAttributes errorAttributes) { super(errorAttributes); } } src/main/java/it/inaf/ia2/transfer/controller/FileController.java +6 −6 Original line number Diff line number Diff line Loading @@ -5,8 +5,9 @@ */ package it.inaf.ia2.transfer.controller; import it.inaf.ia2.transfer.exception.JobException; import it.inaf.ia2.transfer.persistence.JobDAO; import it.inaf.oats.vospace.exception.InternalFaultException; import it.inaf.oats.vospace.exception.VoSpaceErrorSummarizableException; import java.net.URLDecoder; import java.nio.charset.StandardCharsets; import java.util.Arrays; Loading Loading @@ -44,13 +45,12 @@ public abstract class FileController { jobDAO.updateJobPhase(ExecutionPhase.COMPLETED, jobId); } } catch (Throwable t) { JobException jobException; if (t instanceof JobException) { jobException = (JobException) t; VoSpaceErrorSummarizableException jobException; if (t instanceof VoSpaceErrorSummarizableException) { jobException = (VoSpaceErrorSummarizableException) t; } else { LOG.error("Unexpected error happened", t); jobException = new JobException(JobException.Type.FATAL, "Internal Fault") .setErrorDetail("InternalFault: Unexpected error happened"); jobException = new InternalFaultException("Unexpected error happened"); } if (jobId != null) { jobDAO.setJobError(jobId, jobException); Loading src/main/java/it/inaf/ia2/transfer/controller/FileResponseUtil.java +4 −5 Original line number Diff line number Diff line Loading @@ -5,8 +5,8 @@ */ package it.inaf.ia2.transfer.controller; import it.inaf.ia2.transfer.exception.FileNotFoundException; import it.inaf.ia2.transfer.exception.JobException; import it.inaf.oats.vospace.exception.InternalFaultException; import it.inaf.oats.vospace.exception.NodeNotFoundException; import java.io.File; import java.io.FileInputStream; import java.io.IOException; Loading @@ -33,13 +33,12 @@ public class FileResponseUtil { if (!file.exists()) { LOG.error("File not found: " + file.getAbsolutePath()); throw new FileNotFoundException(vosPath == null ? file.getAbsolutePath() : vosPath); throw new NodeNotFoundException(vosPath == null ? file.getAbsolutePath() : vosPath); } if (!file.canRead()) { LOG.error("File not readable: " + file.getAbsolutePath()); throw new JobException(JobException.Type.FATAL, "Internal Fault") .setErrorDetail("InternalFault: File " + file.getName() + " is not readable"); throw new InternalFaultException("File " + file.getName() + " is not readable"); } response.setHeader("Content-Disposition", "attachment; filename=" Loading Loading
pom.xml +15 −106 Original line number Diff line number Diff line Loading @@ -3,10 +3,9 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> <version>2.4.5</version> <relativePath/> <!-- lookup parent from repository --> <groupId>it.inaf.ia2</groupId> <artifactId>vospace-parent</artifactId> <version>0.0.1-SNAPSHOT</version> </parent> <groupId>it.inaf.ia2</groupId> <artifactId>vospace-file-service</artifactId> Loading @@ -18,61 +17,14 @@ <finalName>${project.artifactId}-${project.version}</finalName> <!-- File catalog repository directory --> <init_database_scripts_path>../../../vospace-file-catalog</init_database_scripts_path> <zonky.postgres-binaries.version>12.5.0</zonky.postgres-binaries.version> </properties> <dependencies> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-jdbc</artifactId> </dependency> <dependency> <groupId>org.postgresql</groupId> <artifactId>postgresql</artifactId> <scope>runtime</scope> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-devtools</artifactId> <scope>runtime</scope> <optional>true</optional> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-test</artifactId> <scope>test</scope> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-configuration-processor</artifactId> <optional>true</optional> </dependency> <dependency> <groupId>${project.groupId}</groupId> <artifactId>rap-client</artifactId> <version>1.0-SNAPSHOT</version> </dependency> <!-- Embedded PostgreSQL: --> <dependency> <groupId>com.opentable.components</groupId> <artifactId>otj-pg-embedded</artifactId> <version>0.13.3</version> <scope>test</scope> </dependency> <dependency> <groupId>it.oats.inaf</groupId> <artifactId>vospace-datamodel</artifactId> <version>1.0-SNAPSHOT</version> <groupId>it.inaf.ia2</groupId> <artifactId>vospace-parent-classes</artifactId> <version>0.0.1-SNAPSHOT</version> </dependency> <dependency> <groupId>org.kamranzafar</groupId> <artifactId>jtar</artifactId> Loading @@ -80,49 +32,6 @@ </dependency> </dependencies> <profiles> <profile> <id>platform-linux</id> <activation> <os> <family>unix</family> </os> </activation> <dependencies> <dependency> <groupId>io.zonky.test.postgres</groupId> <artifactId>embedded-postgres-binaries-linux-amd64</artifactId> <version>${zonky.postgres-binaries.version}</version> <scope>test</scope> </dependency> </dependencies> </profile> <profile> <id>platform-windows</id> <activation> <os> <family>windows</family> </os> </activation> <dependencies> <dependency> <groupId>io.zonky.test.postgres</groupId> <artifactId>embedded-postgres-binaries-windows-amd64</artifactId> <version>${zonky.postgres-binaries.version}</version> <scope>test</scope> </dependency> </dependencies> </profile> </profiles> <repositories> <repository> <id>ia2-snapshots</id> <name>your custom repo</name> <url>http://repo.ia2.inaf.it/maven/repository/snapshots</url> </repository> </repositories> <build> <finalName>${finalName}</finalName> <testResources> Loading @@ -145,13 +54,6 @@ </testResource> </testResources> <plugins> <plugin> <artifactId>maven-surefire-plugin</artifactId> <version>2.22.2</version> <configuration> <trimStackTrace>false</trimStackTrace> </configuration> </plugin> <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> Loading @@ -162,7 +64,6 @@ <plugin> <groupId>org.jacoco</groupId> <artifactId>jacoco-maven-plugin</artifactId> <version>0.8.6</version> <executions> <execution> <goals> Loading @@ -181,4 +82,12 @@ </plugins> </build> <repositories> <repository> <id>ia2-snapshots</id> <name>IA2 snapshot repository</name> <url>http://repo.ia2.inaf.it/maven/repository/snapshots</url> </repository> </repositories> </project>
src/main/java/it/inaf/ia2/transfer/controller/ArchiveFileController.java +1 −0 Original line number Diff line number Diff line Loading @@ -9,6 +9,7 @@ import it.inaf.ia2.transfer.auth.TokenPrincipal; import it.inaf.ia2.transfer.service.ArchiveJob; import it.inaf.ia2.transfer.service.ArchiveJob.Type; import it.inaf.ia2.transfer.service.ArchiveService; import it.inaf.oats.vospace.exception.PermissionDeniedException; import java.io.File; import java.util.concurrent.CompletableFuture; import javax.servlet.http.HttpServletResponse; Loading
src/main/java/it/inaf/ia2/transfer/controller/ErrorController.java 0 → 100644 +20 −0 Original line number Diff line number Diff line /* * This file is part of vospace-rest * Copyright (C) 2021 Istituto Nazionale di Astrofisica * SPDX-License-Identifier: GPL-3.0-or-later */ package it.inaf.ia2.transfer.controller; import it.inaf.oats.vospace.exception.DefaultErrorController; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.web.servlet.error.ErrorAttributes; import org.springframework.web.bind.annotation.RestController; @RestController public class ErrorController extends DefaultErrorController { @Autowired public ErrorController(ErrorAttributes errorAttributes) { super(errorAttributes); } }
src/main/java/it/inaf/ia2/transfer/controller/FileController.java +6 −6 Original line number Diff line number Diff line Loading @@ -5,8 +5,9 @@ */ package it.inaf.ia2.transfer.controller; import it.inaf.ia2.transfer.exception.JobException; import it.inaf.ia2.transfer.persistence.JobDAO; import it.inaf.oats.vospace.exception.InternalFaultException; import it.inaf.oats.vospace.exception.VoSpaceErrorSummarizableException; import java.net.URLDecoder; import java.nio.charset.StandardCharsets; import java.util.Arrays; Loading Loading @@ -44,13 +45,12 @@ public abstract class FileController { jobDAO.updateJobPhase(ExecutionPhase.COMPLETED, jobId); } } catch (Throwable t) { JobException jobException; if (t instanceof JobException) { jobException = (JobException) t; VoSpaceErrorSummarizableException jobException; if (t instanceof VoSpaceErrorSummarizableException) { jobException = (VoSpaceErrorSummarizableException) t; } else { LOG.error("Unexpected error happened", t); jobException = new JobException(JobException.Type.FATAL, "Internal Fault") .setErrorDetail("InternalFault: Unexpected error happened"); jobException = new InternalFaultException("Unexpected error happened"); } if (jobId != null) { jobDAO.setJobError(jobId, jobException); Loading
src/main/java/it/inaf/ia2/transfer/controller/FileResponseUtil.java +4 −5 Original line number Diff line number Diff line Loading @@ -5,8 +5,8 @@ */ package it.inaf.ia2.transfer.controller; import it.inaf.ia2.transfer.exception.FileNotFoundException; import it.inaf.ia2.transfer.exception.JobException; import it.inaf.oats.vospace.exception.InternalFaultException; import it.inaf.oats.vospace.exception.NodeNotFoundException; import java.io.File; import java.io.FileInputStream; import java.io.IOException; Loading @@ -33,13 +33,12 @@ public class FileResponseUtil { if (!file.exists()) { LOG.error("File not found: " + file.getAbsolutePath()); throw new FileNotFoundException(vosPath == null ? file.getAbsolutePath() : vosPath); throw new NodeNotFoundException(vosPath == null ? file.getAbsolutePath() : vosPath); } if (!file.canRead()) { LOG.error("File not readable: " + file.getAbsolutePath()); throw new JobException(JobException.Type.FATAL, "Internal Fault") .setErrorDetail("InternalFault: File " + file.getName() + " is not readable"); throw new InternalFaultException("File " + file.getName() + " is not readable"); } response.setHeader("Content-Disposition", "attachment; filename=" Loading