Deprecate VC access deletion.
Change-Id: I56871c5058a561756f51411c63f142162dc3c7e1
diff --git a/Changes b/Changes
index cf11729..2bda9a9 100644
--- a/Changes
+++ b/Changes
@@ -17,6 +17,7 @@
- Remove unsubscribe member (#764)
- Added deprecation messages to deprecated services
- Removed mail configuration (#764)
+- Deprecate VC access deletion.
# version 0.74
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 cb1ceda..27aff66 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
@@ -392,16 +392,10 @@
public Response deleteAccessById (
@Context SecurityContext securityContext,
@PathParam("accessId") int accessId) {
- TokenContext context = (TokenContext) securityContext
- .getUserPrincipal();
- try {
- scopeService.verifyScope(context, OAuth2Scope.DELETE_VC_ACCESS);
- service.deleteRoleById(accessId, context.getUsername());
- }
- catch (KustvaktException e) {
- throw kustvaktResponseHandler.throwit(e);
- }
- return Response.ok().build();
+ throw kustvaktResponseHandler.throwit(new KustvaktException(
+ StatusCodes.DEPRECATED,
+ "This web-service is deprecated and will be completely removed "
+ + "in API v1.1."));
}
/**
diff --git a/src/test/java/de/ids_mannheim/korap/web/controller/vc/VirtualCorpusAccessTest.java b/src/test/java/de/ids_mannheim/korap/web/controller/vc/VirtualCorpusAccessTest.java
deleted file mode 100644
index 8eca508..0000000
--- a/src/test/java/de/ids_mannheim/korap/web/controller/vc/VirtualCorpusAccessTest.java
+++ /dev/null
@@ -1,48 +0,0 @@
-package de.ids_mannheim.korap.web.controller.vc;
-
-import static org.junit.jupiter.api.Assertions.assertEquals;
-
-import org.apache.http.HttpStatus;
-import org.junit.jupiter.api.Test;
-
-import com.fasterxml.jackson.databind.JsonNode;
-
-import de.ids_mannheim.korap.constant.PredefinedRole;
-import de.ids_mannheim.korap.constant.ResourceType;
-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.ProcessingException;
-import jakarta.ws.rs.core.Form;
-import jakarta.ws.rs.core.Response;
-import jakarta.ws.rs.core.Response.Status;
-
-public class VirtualCorpusAccessTest extends VirtualCorpusTestBase {
-
- private String testUser = "VirtualCorpusAccessTest";
-
-
-
- private void testShareVC_nonUniqueAccess (String vcCreator, String vcName,
- String groupName) throws ProcessingException, KustvaktException {
- Response response = shareVCByCreator(vcCreator, vcName, groupName);
- JsonNode node = JsonUtils.readTree(response.readEntity(String.class));
- assertEquals(HttpStatus.SC_BAD_REQUEST, response.getStatus());
- assertEquals(StatusCodes.DB_INSERT_FAILED,
- node.at("/errors/0/0").asInt());
- // EM: message differs depending on the database used
- // for testing. The message below is from sqlite.
- // assertTrue(node.at("/errors/0/1").asText()
- // .startsWith("[SQLITE_CONSTRAINT_UNIQUE]"));
- }
-
- @Test
- public void testDeleteNonExistingAccess ()
- throws ProcessingException, KustvaktException {
- Response response = deleteAccess("dory", "100");
- assertEquals(Status.NOT_FOUND.getStatusCode(), response.getStatus());
- JsonNode node = JsonUtils.readTree(response.readEntity(String.class));
- assertEquals(StatusCodes.NO_RESOURCE_FOUND,
- node.at("/errors/0/0").asInt());
- }
-}
diff --git a/src/test/java/de/ids_mannheim/korap/web/controller/vc/VirtualCorpusControllerAdminTest.java b/src/test/java/de/ids_mannheim/korap/web/controller/vc/VirtualCorpusControllerAdminTest.java
index 08ca16e..6678ca1 100644
--- a/src/test/java/de/ids_mannheim/korap/web/controller/vc/VirtualCorpusControllerAdminTest.java
+++ b/src/test/java/de/ids_mannheim/korap/web/controller/vc/VirtualCorpusControllerAdminTest.java
@@ -177,13 +177,13 @@
JsonNode node = listRolesByGroup("admin",groupName);
assertEquals(1, node.size());
- String roleId = node.at("/0/roleId").asText();
+
node2 = testAdminListVC_UsingAdminToken(vcCreator,
ResourceType.PROJECT);
assertEquals(1, node2.size());
- Response response = deleteAccess("admin",roleId);
- assertEquals(Status.OK.getStatusCode(), response.getStatus());
+ // delete role
+ deleteRoleByGroupAndQuery(vcCreator, vcName, groupName, "admin");
node = listRolesByGroup("admin",groupName);
assertEquals(0, node.size());
diff --git a/src/test/java/de/ids_mannheim/korap/web/controller/vc/VirtualCorpusTestBase.java b/src/test/java/de/ids_mannheim/korap/web/controller/vc/VirtualCorpusTestBase.java
index d9604fb..4babd96 100644
--- a/src/test/java/de/ids_mannheim/korap/web/controller/vc/VirtualCorpusTestBase.java
+++ b/src/test/java/de/ids_mannheim/korap/web/controller/vc/VirtualCorpusTestBase.java
@@ -244,17 +244,6 @@
assertEquals(Status.OK.getStatusCode(), response.getStatus());
}
- @Deprecated
- protected Response deleteAccess (String username, String accessId)
- throws ProcessingException, KustvaktException {
- Response response = target().path(API_VERSION).path("vc").path("access")
- .path(accessId).request()
- .header(Attributes.AUTHORIZATION, HttpAuthorizationHandler
- .createBasicAuthorizationHeaderValue(username, "pass"))
- .delete();
- return response;
- }
-
protected Response deleteRoleByGroupAndQuery (String vcCreator, String vcName,
String groupName, String deleteBy)
throws ProcessingException, KustvaktException {