Remove deprecated vc web-services for API v1.1 (#771)
Change-Id: I67728a2ae770e56b56472b350a94f967ce0768fb
diff --git a/Changes b/Changes
index e7d2949..ce601e1 100644
--- a/Changes
+++ b/Changes
@@ -4,8 +4,7 @@
- Deprecated matchInfo web-service has been removed for API v1.1.
- Remove deprecated Authorization Post web-service for API v1.1 (#767)
- Remove deprecated user-group web-services for API v1.1 (#769)
-
-
+- Remove deprecated vc web-services for API v1.1 (#771)
# version 0.79.1
diff --git a/src/main/java/de/ids_mannheim/korap/web/controller/VirtualCorpusController.java b/src/main/java/de/ids_mannheim/korap/web/controller/VirtualCorpusController.java
index d379114..522cedb 100644
--- a/src/main/java/de/ids_mannheim/korap/web/controller/VirtualCorpusController.java
+++ b/src/main/java/de/ids_mannheim/korap/web/controller/VirtualCorpusController.java
@@ -9,8 +9,8 @@
import de.ids_mannheim.korap.constant.OAuth2Scope;
import de.ids_mannheim.korap.constant.QueryType;
-import de.ids_mannheim.korap.dto.RoleDto;
import de.ids_mannheim.korap.dto.QueryDto;
+import de.ids_mannheim.korap.dto.RoleDto;
import de.ids_mannheim.korap.exceptions.KustvaktException;
import de.ids_mannheim.korap.exceptions.StatusCodes;
import de.ids_mannheim.korap.oauth2.service.OAuth2ScopeService;
@@ -18,6 +18,7 @@
import de.ids_mannheim.korap.service.QueryService;
import de.ids_mannheim.korap.utils.ParameterChecker;
import de.ids_mannheim.korap.web.KustvaktResponseHandler;
+import de.ids_mannheim.korap.web.filter.APIDeprecationFilter;
import de.ids_mannheim.korap.web.filter.APIVersionFilter;
import de.ids_mannheim.korap.web.filter.AdminFilter;
import de.ids_mannheim.korap.web.filter.AuthenticationFilter;
@@ -271,6 +272,8 @@
@Deprecated
@GET
@Path("~{createdBy}")
+ @ResourceFilters({APIDeprecationFilter.class,
+ AuthenticationFilter.class, BlockingFilter.class})
public List<QueryDto> listUserOrSystemVC (
@PathParam("createdBy") String createdBy,
@Context SecurityContext securityContext) {
@@ -390,6 +393,8 @@
@Deprecated
@DELETE
@Path("access/{accessId}")
+ @ResourceFilters({APIDeprecationFilter.class,
+ AuthenticationFilter.class, BlockingFilter.class})
public Response deleteAccessById (
@Context SecurityContext securityContext,
@PathParam("accessId") int accessId) {
diff --git a/src/test/java/de/ids_mannheim/korap/web/controller/vc/VirtualCorpusDeprecationTest.java b/src/test/java/de/ids_mannheim/korap/web/controller/vc/VirtualCorpusDeprecationTest.java
new file mode 100644
index 0000000..ce43789
--- /dev/null
+++ b/src/test/java/de/ids_mannheim/korap/web/controller/vc/VirtualCorpusDeprecationTest.java
@@ -0,0 +1,65 @@
+package de.ids_mannheim.korap.web.controller.vc;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
+import org.junit.jupiter.api.Test;
+
+import com.fasterxml.jackson.databind.JsonNode;
+
+import de.ids_mannheim.korap.authentication.http.HttpAuthorizationHandler;
+import de.ids_mannheim.korap.config.Attributes;
+import de.ids_mannheim.korap.config.SpringJerseyTest;
+import de.ids_mannheim.korap.exceptions.KustvaktException;
+import de.ids_mannheim.korap.exceptions.StatusCodes;
+import de.ids_mannheim.korap.utils.JsonUtils;
+import jakarta.ws.rs.core.Response;
+import jakarta.ws.rs.core.Response.Status;
+
+public class VirtualCorpusDeprecationTest extends SpringJerseyTest{
+
+ private void testDeprecation (Response response) throws KustvaktException {
+ assertEquals(Status.BAD_REQUEST.getStatusCode(), response.getStatus());
+ String entity = response.readEntity(String.class);
+ JsonNode node = JsonUtils.readTree(entity);
+ assertEquals(StatusCodes.DEPRECATED,
+ node.at("/errors/0/0").asInt());
+ }
+
+ @Test
+ public void testV1_0 () throws KustvaktException {
+ // list user or system vc
+ Response response = target().path(API_VERSION_V1_0).path("vc")
+ .path("~dory").request()
+ .header(Attributes.AUTHORIZATION, HttpAuthorizationHandler
+ .createBasicAuthorizationHeaderValue("dory", "pass"))
+ .get();
+ testDeprecation(response);
+
+ // delete access by id
+ response = target().path(API_VERSION_V1_0).path("vc").path("access")
+ .path("1").request()
+ .header(Attributes.AUTHORIZATION, HttpAuthorizationHandler
+ .createBasicAuthorizationHeaderValue("dory", "pass"))
+ .delete();
+ testDeprecation(response);
+ }
+
+ @Test
+ public void testCurrentVersion () throws KustvaktException {
+ // list user or system vc
+ Response response = target().path(API_VERSION).path("vc")
+ .path("~dory").request()
+ .header(Attributes.AUTHORIZATION, HttpAuthorizationHandler
+ .createBasicAuthorizationHeaderValue("dory", "pass"))
+ .get();
+ assertEquals(Status.NOT_FOUND.getStatusCode(), response.getStatus());
+
+ // delete access by id
+ response = target().path(API_VERSION).path("vc").path("access")
+ .path("1").request()
+ .header(Attributes.AUTHORIZATION, HttpAuthorizationHandler
+ .createBasicAuthorizationHeaderValue("dory", "pass"))
+ .delete();
+ assertEquals(Status.NOT_FOUND.getStatusCode(), response.getStatus());
+ }
+}