diff --git a/pom.xml b/pom.xml index 19697432a0f3195f4d63b2a8affea42889e151a5..11820302a78cfd84a9170bb6c5f542b8f03c316e 100644 --- a/pom.xml +++ b/pom.xml @@ -1,290 +1,289 @@ <?xml version="1.0"?> -<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd" - xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> - <modelVersion>4.0.0</modelVersion> - <groupId>org.eclipsefoundation</groupId> - <artifactId>eclipsefdn-downloads-api</artifactId> - <version>0.0.1-SNAPSHOT</version> - <properties> - <eclipse-api-version>0.4-SNAPSHOT</eclipse-api-version> - <surefire-plugin.version>2.22.1</surefire-plugin.version> - <compiler-plugin.version>3.8.1</compiler-plugin.version> - <maven.compiler.target>11</maven.compiler.target> - <maven.compiler.source>11</maven.compiler.source> - <quarkus.platform.artifact-id>quarkus-universe-bom</quarkus.platform.artifact-id> - <quarkus.platform.group-id>io.quarkus</quarkus.platform.group-id> - <quarkus.platform.version>2.1.4.Final</quarkus.platform.version> - <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> - <project.reporting.outputEncoding>${project.build.sourceEncoding}</project.reporting.outputEncoding> - <maven.compiler.parameters>true</maven.compiler.parameters> - <auto-value.version>1.8.2</auto-value.version> - <org.mapstruct.version>1.4.1.Final</org.mapstruct.version> - </properties> - <repositories> - <repository> - <id>eclipsefdn</id> - <url>https://repo.eclipse.org/content/repositories/eclipsefdn/</url> - <releases> - <enabled>true</enabled> - </releases> - <snapshots> - <enabled>true</enabled> - </snapshots> - </repository> - </repositories> - <dependencyManagement> - <dependencies> - <dependency> - <groupId>${quarkus.platform.group-id}</groupId> - <artifactId>${quarkus.platform.artifact-id}</artifactId> - <version>${quarkus.platform.version}</version> - <type>pom</type> - <scope>import</scope> - </dependency> - </dependencies> - </dependencyManagement> - <dependencies> - <dependency> - <groupId>org.eclipsefoundation</groupId> - <artifactId>quarkus-core</artifactId> - <version>${eclipse-api-version}</version> +<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> + <modelVersion>4.0.0</modelVersion> + <groupId>org.eclipsefoundation</groupId> + <artifactId>eclipsefdn-downloads-api</artifactId> + <version>0.0.1-SNAPSHOT</version> + <properties> + <eclipse-api-version>0.5-SNAPSHOT</eclipse-api-version> + <surefire-plugin.version>2.22.1</surefire-plugin.version> + <compiler-plugin.version>3.8.1</compiler-plugin.version> + <maven.compiler.target>11</maven.compiler.target> + <maven.compiler.source>11</maven.compiler.source> + <quarkus.platform.artifact-id>quarkus-universe-bom</quarkus.platform.artifact-id> + <quarkus.platform.group-id>io.quarkus</quarkus.platform.group-id> + <quarkus.platform.version>2.6.3.Final</quarkus.platform.version> + <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> + <project.reporting.outputEncoding>${project.build.sourceEncoding}</project.reporting.outputEncoding> + <maven.compiler.parameters>true</maven.compiler.parameters> + <auto-value.version>1.8.2</auto-value.version> + <org.mapstruct.version>1.4.1.Final</org.mapstruct.version> + </properties> + <repositories> + <repository> + <id>eclipsefdn</id> + <url>https://repo.eclipse.org/content/repositories/eclipsefdn/</url> + <releases> + <enabled>true</enabled> + </releases> + <snapshots> + <enabled>true</enabled> + </snapshots> + </repository> + </repositories> + <dependencyManagement> + <dependencies> + <dependency> + <groupId>${quarkus.platform.group-id}</groupId> + <artifactId>${quarkus.platform.artifact-id}</artifactId> + <version>${quarkus.platform.version}</version> + <type>pom</type> + <scope>import</scope> + </dependency> + </dependencies> + </dependencyManagement> + <dependencies> + <dependency> + <groupId>org.eclipsefoundation</groupId> + <artifactId>quarkus-core</artifactId> + <version>${eclipse-api-version}</version> <!-- Can be removed once dependency is removed from base package https://stackoverflow.com/questions/67510802/logging-in-quarkus-works-in-dev-mode-but-doesnt-output-in-jvm-docker-image --> - <exclusions> - <exclusion> - <groupId>org.jboss.logmanager</groupId> - <artifactId>jboss-logmanager</artifactId> - </exclusion> - </exclusions> - </dependency> - <dependency> - <groupId>org.eclipsefoundation</groupId> - <artifactId>quarkus-persistence</artifactId> - <version>${eclipse-api-version}</version> - </dependency> - <dependency> - <groupId>io.quarkus</groupId> - <artifactId>quarkus-resteasy</artifactId> - </dependency> - <dependency> - <groupId>io.quarkus</groupId> - <artifactId>quarkus-resteasy-jackson</artifactId> - </dependency> - <dependency> - <groupId>io.quarkus</groupId> - <artifactId>quarkus-rest-client</artifactId> - </dependency> - <dependency> - <groupId>io.quarkus</groupId> - <artifactId>quarkus-cache</artifactId> - </dependency> - <dependency> - <groupId>io.quarkus</groupId> - <artifactId>quarkus-arc</artifactId> - </dependency> - <dependency> - <groupId>io.quarkus</groupId> - <artifactId>quarkus-hibernate-validator</artifactId> - </dependency> - <dependency> - <groupId>org.apache.commons</groupId> - <artifactId>commons-text</artifactId> - <version>1.9</version> - </dependency> - <dependency> - <groupId>com.google.guava</groupId> - <artifactId>guava</artifactId> - </dependency> - + <exclusions> + <exclusion> + <groupId>org.jboss.logmanager</groupId> + <artifactId>jboss-logmanager</artifactId> + </exclusion> + </exclusions> + </dependency> + <dependency> + <groupId>org.eclipsefoundation</groupId> + <artifactId>quarkus-persistence</artifactId> + <version>${eclipse-api-version}</version> + </dependency> + <dependency> + <groupId>io.quarkus</groupId> + <artifactId>quarkus-resteasy</artifactId> + </dependency> + <dependency> + <groupId>io.quarkus</groupId> + <artifactId>quarkus-resteasy-jackson</artifactId> + </dependency> + <dependency> + <groupId>io.quarkus</groupId> + <artifactId>quarkus-rest-client</artifactId> + </dependency> + <dependency> + <groupId>io.quarkus</groupId> + <artifactId>quarkus-cache</artifactId> + </dependency> + <dependency> + <groupId>io.quarkus</groupId> + <artifactId>quarkus-arc</artifactId> + </dependency> + <dependency> + <groupId>io.quarkus</groupId> + <artifactId>quarkus-hibernate-validator</artifactId> + </dependency> + <dependency> + <groupId>org.apache.commons</groupId> + <artifactId>commons-text</artifactId> + <version>1.9</version> + </dependency> + <dependency> + <groupId>com.google.guava</groupId> + <artifactId>guava</artifactId> + </dependency> + <!-- Annotation preprocessors - reduce all of the boiler plate --> - <dependency> - <groupId>com.google.auto.value</groupId> - <artifactId>auto-value</artifactId> - <version>${auto-value.version}</version> - <scope>provided</scope> - </dependency> - <dependency> - <groupId>com.google.auto.value</groupId> - <artifactId>auto-value-annotations</artifactId> - <version>${auto-value.version}</version> - </dependency> - <dependency> - <groupId>com.google.code.findbugs</groupId> - <artifactId>jsr305</artifactId> - <version>3.0.0</version> - </dependency> + <dependency> + <groupId>com.google.auto.value</groupId> + <artifactId>auto-value</artifactId> + <version>${auto-value.version}</version> + <scope>provided</scope> + </dependency> + <dependency> + <groupId>com.google.auto.value</groupId> + <artifactId>auto-value-annotations</artifactId> + <version>${auto-value.version}</version> + </dependency> + <dependency> + <groupId>com.google.code.findbugs</groupId> + <artifactId>jsr305</artifactId> + <version>3.0.0</version> + </dependency> <!-- Testing dependencies only --> - <dependency> - <groupId>io.quarkus</groupId> - <artifactId>quarkus-junit5</artifactId> - <scope>test</scope> - </dependency> - <dependency> - <groupId>io.rest-assured</groupId> - <artifactId>rest-assured</artifactId> - <scope>test</scope> - </dependency> - <dependency> - <groupId>io.rest-assured</groupId> - <artifactId>json-schema-validator</artifactId> - <scope>test</scope> - </dependency> - <dependency> - <groupId>io.quarkus</groupId> - <artifactId>quarkus-junit5-mockito</artifactId> - <scope>test</scope> - </dependency> - + <dependency> + <groupId>io.quarkus</groupId> + <artifactId>quarkus-junit5</artifactId> + <scope>test</scope> + </dependency> + <dependency> + <groupId>io.rest-assured</groupId> + <artifactId>rest-assured</artifactId> + <scope>test</scope> + </dependency> + <dependency> + <groupId>io.rest-assured</groupId> + <artifactId>json-schema-validator</artifactId> + <scope>test</scope> + </dependency> + <dependency> + <groupId>io.quarkus</groupId> + <artifactId>quarkus-junit5-mockito</artifactId> + <scope>test</scope> + </dependency> + <!-- Following H2/devservices deps are made to circumvent need for docker --> - <dependency> - <groupId>io.quarkus</groupId> - <artifactId>quarkus-devservices-h2</artifactId> - <scope>test</scope> - </dependency> - <dependency> - <groupId>io.quarkus</groupId> - <artifactId>quarkus-jdbc-h2</artifactId> - <scope>test</scope> - </dependency> - <dependency> - <groupId>com.h2database</groupId> - <artifactId>h2</artifactId> - <scope>test</scope> - </dependency> + <dependency> + <groupId>io.quarkus</groupId> + <artifactId>quarkus-devservices-h2</artifactId> + <scope>test</scope> + </dependency> + <dependency> + <groupId>io.quarkus</groupId> + <artifactId>quarkus-jdbc-h2</artifactId> + <scope>test</scope> + </dependency> + <dependency> + <groupId>com.h2database</groupId> + <artifactId>h2</artifactId> + <scope>test</scope> + </dependency> <!-- Flyway specific dependencies, used to setup tables in test --> - <dependency> - <groupId>io.quarkus</groupId> - <artifactId>quarkus-flyway</artifactId> - <scope>test</scope> - </dependency> - </dependencies> - <build> - <plugins> - <plugin> - <groupId>${quarkus.platform.group-id}</groupId> - <artifactId>quarkus-maven-plugin</artifactId> - <version>${quarkus.platform.version}</version> - <extensions>true</extensions> - <executions> - <execution> - <goals> - <goal>build</goal> - <goal>generate-code</goal> - <goal>generate-code-tests</goal> - </goals> - </execution> - </executions> - </plugin> - <plugin> - <artifactId>maven-compiler-plugin</artifactId> - <version>${compiler-plugin.version}</version> - <configuration> - <annotationProcessorPaths> - <path> - <groupId>com.google.auto.value</groupId> - <artifactId>auto-value</artifactId> - <version>${auto-value.version}</version> - </path> - </annotationProcessorPaths> - </configuration> - </plugin> - <plugin> - <groupId>org.codehaus.mojo</groupId> - <artifactId>exec-maven-plugin</artifactId> - <version>1.3.2</version> - <executions> - <execution> - <id>npm install (initialize)</id> - <goals> - <goal>exec</goal> - </goals> - <phase>initialize</phase> - <configuration> - <executable>npm</executable> - <arguments> - <argument>install</argument> - <argument>-f</argument> - </arguments> - </configuration> - </execution> - <execution> - <id>npm clean</id> - <goals> - <goal>exec</goal> - </goals> - <phase>clean</phase> - <configuration> - <executable>npm</executable> - <arguments> - <argument>run</argument> - <argument>clean</argument> - </arguments> - </configuration> - </execution> - <execution> - <id>npm run pre-test</id> - <goals> - <goal>exec</goal> - </goals> - <phase>generate-test-resources</phase> - <configuration> - <executable>npm</executable> - <skip>${maven.test.skip}</skip> - <arguments> - <argument>run</argument> - <argument>generate-json-schema</argument> - </arguments> - </configuration> - </execution> - </executions> - </plugin> - <plugin> - <artifactId>maven-surefire-plugin</artifactId> - <version>${surefire-plugin.version}</version> - <configuration> - <skipTests>false</skipTests> - <systemPropertyVariables> - <java.util.logging.manager>org.jboss.logmanager.LogManager</java.util.logging.manager> - <maven.home>${maven.home}</maven.home> - </systemPropertyVariables> - </configuration> - </plugin> - </plugins> - </build> - <profiles> - <profile> - <id>native</id> - <activation> - <property> - <name>native</name> - </property> - </activation> - <build> - <plugins> - <plugin> - <artifactId>maven-failsafe-plugin</artifactId> - <version>${surefire-plugin.version}</version> - <executions> - <execution> - <goals> - <goal>integration-test</goal> - <goal>verify</goal> - </goals> - <configuration> - <systemPropertyVariables> - <native.image.path>${project.build.directory}/${project.build.finalName}-runner</native.image.path> - <java.util.logging.manager>org.jboss.logmanager.LogManager</java.util.logging.manager> - <maven.home>${maven.home}</maven.home> - </systemPropertyVariables> - </configuration> - </execution> - </executions> - </plugin> - </plugins> - </build> - <properties> - <quarkus.package.type>native</quarkus.package.type> - </properties> - </profile> - </profiles> -</project> + <dependency> + <groupId>io.quarkus</groupId> + <artifactId>quarkus-flyway</artifactId> + <scope>test</scope> + </dependency> + </dependencies> + <build> + <plugins> + <plugin> + <groupId>${quarkus.platform.group-id}</groupId> + <artifactId>quarkus-maven-plugin</artifactId> + <version>${quarkus.platform.version}</version> + <extensions>true</extensions> + <executions> + <execution> + <goals> + <goal>build</goal> + <goal>generate-code</goal> + <goal>generate-code-tests</goal> + </goals> + </execution> + </executions> + </plugin> + <plugin> + <artifactId>maven-compiler-plugin</artifactId> + <version>${compiler-plugin.version}</version> + <configuration> + <annotationProcessorPaths> + <path> + <groupId>com.google.auto.value</groupId> + <artifactId>auto-value</artifactId> + <version>${auto-value.version}</version> + </path> + </annotationProcessorPaths> + </configuration> + </plugin> + <plugin> + <groupId>org.codehaus.mojo</groupId> + <artifactId>exec-maven-plugin</artifactId> + <version>1.3.2</version> + <executions> + <execution> + <id>npm install (initialize)</id> + <goals> + <goal>exec</goal> + </goals> + <phase>initialize</phase> + <configuration> + <executable>npm</executable> + <arguments> + <argument>install</argument> + <argument>-f</argument> + </arguments> + </configuration> + </execution> + <execution> + <id>npm clean</id> + <goals> + <goal>exec</goal> + </goals> + <phase>clean</phase> + <configuration> + <executable>npm</executable> + <arguments> + <argument>run</argument> + <argument>clean</argument> + </arguments> + </configuration> + </execution> + <execution> + <id>npm run pre-test</id> + <goals> + <goal>exec</goal> + </goals> + <phase>generate-test-resources</phase> + <configuration> + <executable>npm</executable> + <skip>${maven.test.skip}</skip> + <arguments> + <argument>run</argument> + <argument>generate-json-schema</argument> + </arguments> + </configuration> + </execution> + </executions> + </plugin> + <plugin> + <artifactId>maven-surefire-plugin</artifactId> + <version>${surefire-plugin.version}</version> + <configuration> + <skipTests>false</skipTests> + <systemPropertyVariables> + <java.util.logging.manager>org.jboss.logmanager.LogManager</java.util.logging.manager> + <maven.home>${maven.home}</maven.home> + </systemPropertyVariables> + </configuration> + </plugin> + </plugins> + </build> + <profiles> + <profile> + <id>native</id> + <activation> + <property> + <name>native</name> + </property> + </activation> + <build> + <plugins> + <plugin> + <artifactId>maven-failsafe-plugin</artifactId> + <version>${surefire-plugin.version}</version> + <executions> + <execution> + <goals> + <goal>integration-test</goal> + <goal>verify</goal> + </goals> + <configuration> + <systemPropertyVariables> + <native.image.path>${project.build.directory}/${project.build.finalName}-runner</native.image.path> + <java.util.logging.manager>org.jboss.logmanager.LogManager</java.util.logging.manager> + <maven.home>${maven.home}</maven.home> + </systemPropertyVariables> + </configuration> + </execution> + </executions> + </plugin> + </plugins> + </build> + <properties> + <quarkus.package.type>native</quarkus.package.type> + </properties> + </profile> + </profiles> +</project> \ No newline at end of file diff --git a/spec/openapi.yaml b/spec/openapi.yaml index d2908ececb0f4de4fe0918a0fa1200918e3035ae..3ff44dd06606ca2a5154d431b6b5237e907434aa 100644 --- a/spec/openapi.yaml +++ b/spec/openapi.yaml @@ -15,6 +15,13 @@ tags: description: Definitions in relation to retrieval of mailing lists paths: /file/{file_id}: + parameters: + - name: file_id + in: path + description: The ID of the file to retrieve + required: true + schema: + type: string get: tags: - Files @@ -65,7 +72,7 @@ paths: $ref: '#/components/schemas/Release' 500: description: Error while retrieving data - /release/{releaseName}: + /releases/{releaseName}: parameters: - name: releaseName in: path @@ -87,7 +94,7 @@ paths: $ref: '#/components/schemas/Releases' 500: description: Error while retrieving data - /release/{releaseName}/{releaseVersion}: + /releases/{releaseName}/{releaseVersion}: parameters: - name: releaseName in: path diff --git a/src/main/java/org/eclipsefoundation/downloads/resources/DownloadsResource.java b/src/main/java/org/eclipsefoundation/downloads/resources/DownloadsResource.java index 6db586784e40d560e44a5621987b56a026c580b2..6f5c77032a9c7dc4fdd3180ca749ab5b2026eb57 100644 --- a/src/main/java/org/eclipsefoundation/downloads/resources/DownloadsResource.java +++ b/src/main/java/org/eclipsefoundation/downloads/resources/DownloadsResource.java @@ -75,7 +75,7 @@ public class DownloadsResource { // get the index, and make sure we have a result Optional<List<DownloadFileIndex>> dfis = cache.get(id, params, DownloadFileIndex.class, () -> dao.get(new RDBMSQuery<>(wrap, filters.get(DownloadFileIndex.class), params))); - if (dfis.isEmpty()) { + if (dfis.isEmpty() || dfis.get().isEmpty()) { String message = String.format("No DownloadFileIndex found with id '%s'", id); LOGGER.debug(message); return new Error(404, message).asResponse(); @@ -98,13 +98,13 @@ public class DownloadsResource { } @GET - @Path("release/active") + @Path("releases/active") public Response activeReleases() { return Response.ok(releaseTrackerService.getActiveReleases()).build(); } @GET - @Path("release/{releaseName}") + @Path("releases/{releaseName}") public Response release(@PathParam("releaseName") String releaseName) { // check that the release name is valid Optional<Release> r = releaseTrackerService.getReleaseByName(releaseName); @@ -128,7 +128,7 @@ public class DownloadsResource { } @GET - @Path("release/{releaseName}/{version}") + @Path("releases/{releaseName}/{version}") public Response releaseVersion(@PathParam("releaseName") String releaseName, @PathParam("version") String version) { // check that the release name is valid Optional<Release> r = releaseTrackerService.getReleaseByName(releaseName); diff --git a/src/main/java/org/eclipsefoundation/downloads/services/impl/DefaultReleaseTrackerService.java b/src/main/java/org/eclipsefoundation/downloads/services/impl/DefaultReleaseTrackerService.java index b4a4e867d1fc14c0dfa723bf39819cbbced9d0c7..b34e316851a04bb0cf9298540dec7b3ea1c550d3 100644 --- a/src/main/java/org/eclipsefoundation/downloads/services/impl/DefaultReleaseTrackerService.java +++ b/src/main/java/org/eclipsefoundation/downloads/services/impl/DefaultReleaseTrackerService.java @@ -35,7 +35,7 @@ public class DefaultReleaseTrackerService implements ReleaseTrackerService { @Override public Optional<Release> getReleaseByName(String releaseName) { - return Optional.of(releases().getReleases().get(releaseName)); + return Optional.ofNullable(releases().getReleases().get(releaseName)); } @Override diff --git a/src/test/java/org/eclipsefoundation/downloads/resources/DownloadsResourceTest.java b/src/test/java/org/eclipsefoundation/downloads/resources/DownloadsResourceTest.java index 616af102da8ea6c675c25e029def9cd043973d27..d5040d13389ffa90af8918bcf3a81fa4a208782f 100644 --- a/src/test/java/org/eclipsefoundation/downloads/resources/DownloadsResourceTest.java +++ b/src/test/java/org/eclipsefoundation/downloads/resources/DownloadsResourceTest.java @@ -21,8 +21,8 @@ public class DownloadsResourceTest { public static final String DOWNLOADS_BASE_URL = "/downloads"; public static final String FILE_BY_ID_URL = DOWNLOADS_BASE_URL + "/file/{id}"; - public static final String RELEASE_BASE_URL = DOWNLOADS_BASE_URL + "/release"; - public static final String LEGACY_RELEASE_URL = RELEASE_BASE_URL + "/{releaseType}"; + public static final String RELEASE_BASE_URL = DOWNLOADS_BASE_URL + "/releases"; + public static final String LEGACY_RELEASE_URL = DOWNLOADS_BASE_URL + "/release/{releaseType}"; public static final String RELEASES_URL = RELEASE_BASE_URL + "/{releaseName}"; public static final String RELEASE_VERSION_URL = RELEASES_URL + "/{releaseVersion}";