Skip to content
Snippets Groups Projects
Commit bfdf313c authored by Martin Lowe's avatar Martin Lowe :flag_ca:
Browse files

Fix openapi spec for legacy URL support, update tests + resource

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