Skip to content

Commit

Permalink
Feature/remove api version (#180)
Browse files Browse the repository at this point in the history
* remove apiVersion annotation to remove 'v1' from path

* remove 'v1' constant, uses and tests for versioning

* stop overriding the RequestMapping to insert the api version

* delete api version annotation

* upgrade testcontainer version

* hide detailed logging output for tests

Co-authored-by: salmma <github@mielie.de>
  • Loading branch information
manuwei and salmma authored Apr 1, 2021
1 parent 099bd0b commit e2b7248
Show file tree
Hide file tree
Showing 27 changed files with 1,016 additions and 1,263 deletions.
6 changes: 3 additions & 3 deletions org.planqk.atlas.core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -48,19 +48,19 @@
<dependency>
<groupId>org.testcontainers</groupId>
<artifactId>testcontainers</artifactId>
<version>1.14.3</version>
<version>1.15.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.testcontainers</groupId>
<artifactId>postgresql</artifactId>
<version>1.14.3</version>
<version>1.15.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.testcontainers</groupId>
<artifactId>junit-jupiter</artifactId>
<version>1.14.3</version>
<version>1.15.2</version>
<scope>test</scope>
</dependency>
</dependencies>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertTrue;

import java.net.URI;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
Expand Down Expand Up @@ -68,7 +67,7 @@ void updateSketch() {
final MockMultipartFile file = new MockMultipartFile("image", testFile);

final String description = "description";
final String baseURL = "http://localhost:8080/atlas/v1";
final String baseURL = "http://localhost:8080/atlas";
// call
final Sketch persistedSketch = sketchService.addSketchToAlgorithm(algorithm.getId(), file, description, baseURL);

Expand Down Expand Up @@ -114,7 +113,7 @@ void addSketchToAlgorithm() {
final MockMultipartFile file = new MockMultipartFile("image", testFile);

final String description = "description";
final String baseURL = "http://localhost:8080/atlas/v1";
final String baseURL = "http://localhost:8080/atlas";
// call
final Sketch persistedSketch = sketchService.addSketchToAlgorithm(algorithm.getId(), file, description, baseURL);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@
public final class Constants {

// URL snippets
public static final String API_VERSION = "v1";

public static final String ALGORITHMS = "algorithms";

public static final String ALGORITHM_RELATIONS = "algorithm-relations";
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,6 @@

package org.planqk.atlas.web.annotation;

import java.lang.reflect.Method;

import org.springframework.core.annotation.AnnotatedElementUtils;
import org.springframework.web.servlet.mvc.condition.PatternsRequestCondition;
import org.springframework.web.servlet.mvc.method.RequestMappingInfo;
import org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping;

/**
Expand All @@ -39,29 +34,4 @@ public void populateFromHandler(Object handler) {
detectHandlerMethods(handler);
}

@Override
protected RequestMappingInfo getMappingForMethod(Method method, Class<?> handlerType) {
RequestMappingInfo info = super.getMappingForMethod(method, handlerType);
if (info != null) {
final ApiVersion methodAnnotation = AnnotatedElementUtils.findMergedAnnotation(method, ApiVersion.class);
if (methodAnnotation != null) {
// Prepend our version mapping to the real method mapping.
info = createApiVersionInfo(methodAnnotation).combine(info);
}

final ApiVersion typeAnnotation = AnnotatedElementUtils.findMergedAnnotation(handlerType, ApiVersion.class);
if (methodAnnotation == null && typeAnnotation != null) {
// Append our version mapping to the real controller mapping.
info = createApiVersionInfo(typeAnnotation).combine(info);
}
}
return info;
}

private RequestMappingInfo createApiVersionInfo(ApiVersion annotation) {
return new RequestMappingInfo(
new PatternsRequestCondition(annotation.value(), getUrlPathHelper(), getPathMatcher(),
useSuffixPatternMatch(), useTrailingSlashMatch(), getFileExtensions()),
null, null, null, null, null, null);
}
}
Loading

0 comments on commit e2b7248

Please sign in to comment.