Updated paths of user-group deletion-controllers
Change-Id: I3009489853f8a541e9f94966d1cfd75ce6ece780
diff --git a/full/Changes b/full/Changes
index 738c78f..449296e 100644
--- a/full/Changes
+++ b/full/Changes
@@ -20,6 +20,7 @@
- fixed OAuth2 client unique URL-hashcode (margaretha)
- migrated logging to log4j 2 and adapted java.util.logging to log4j(margaretha)
- Added support for unrestricted corpus statistics (ndiewald)
+ - updated paths of user-group deletion-controllers (margaretha)
version 0.60.3
06/06/2018
diff --git a/full/src/main/java/de/ids_mannheim/korap/web/controller/UserGroupController.java b/full/src/main/java/de/ids_mannheim/korap/web/controller/UserGroupController.java
index ec633fb..dd34a1f 100644
--- a/full/src/main/java/de/ids_mannheim/korap/web/controller/UserGroupController.java
+++ b/full/src/main/java/de/ids_mannheim/korap/web/controller/UserGroupController.java
@@ -171,9 +171,9 @@
* @return HTTP 200, if successful.
*/
@DELETE
- @Path("delete")
+ @Path("delete/{groupId}")
public Response deleteUserGroup (@Context SecurityContext securityContext,
- @QueryParam("groupId") int groupId) {
+ @PathParam("groupId") int groupId) {
TokenContext context =
(TokenContext) securityContext.getUserPrincipal();
try {
@@ -193,11 +193,11 @@
* @return if successful, HTTP response status OK
*/
@DELETE
- @Path("member/delete")
+ @Path("member/delete/{groupId}/{memberId}")
public Response deleteUserFromGroup (
@Context SecurityContext securityContext,
- @QueryParam("memberId") String memberId,
- @QueryParam("groupId") int groupId) {
+ @PathParam("memberId") String memberId,
+ @PathParam("groupId") int groupId) {
TokenContext context =
(TokenContext) securityContext.getUserPrincipal();
try {
diff --git a/full/src/main/resources/log4j2.properties b/full/src/main/resources/log4j2.properties
index 1038fe2..b616418 100644
--- a/full/src/main/resources/log4j2.properties
+++ b/full/src/main/resources/log4j2.properties
@@ -14,12 +14,12 @@
rootLogger.appenderRefs = stdout
rootLogger.appenderRef.stdout.ref = STDOUT
-#loggers=file
-#logger.file.name=de.ids_mannheim.korap
-#logger.file.level = error
-#logger.file.appenderRefs = file
-#logger.file.appenderRef.file.ref = ERRORLOG
-#logger.file.additivity=true
+loggers=file
+logger.file.name=de.ids_mannheim.korap
+logger.file.level = error
+logger.file.appenderRefs = file
+logger.file.appenderRef.file.ref = ERRORLOG
+logger.file.additivity=true
#loggers=file
#logger.file.name=com.sun.jersey.test.framework.spi.container
diff --git a/full/src/test/java/de/ids_mannheim/korap/web/controller/UserGroupControllerAdminTest.java b/full/src/test/java/de/ids_mannheim/korap/web/controller/UserGroupControllerAdminTest.java
index 2af5234..946dd8b 100644
--- a/full/src/test/java/de/ids_mannheim/korap/web/controller/UserGroupControllerAdminTest.java
+++ b/full/src/test/java/de/ids_mannheim/korap/web/controller/UserGroupControllerAdminTest.java
@@ -286,13 +286,13 @@
throws UniformInterfaceException, ClientHandlerException,
KustvaktException {
// delete group
- ClientResponse response = resource().path("group").path("delete")
- .queryParam("groupId", groupId)
- .header(Attributes.AUTHORIZATION,
- handler.createBasicAuthorizationHeaderValue(
- adminUsername, "pass"))
- .header(HttpHeaders.X_FORWARDED_FOR, "149.27.0.32")
- .delete(ClientResponse.class);
+ ClientResponse response =
+ resource().path("group").path("delete").path(groupId)
+ .header(Attributes.AUTHORIZATION,
+ handler.createBasicAuthorizationHeaderValue(
+ adminUsername, "pass"))
+ .header(HttpHeaders.X_FORWARDED_FOR, "149.27.0.32")
+ .delete(ClientResponse.class);
assertEquals(Status.OK.getStatusCode(), response.getStatus());
@@ -306,8 +306,7 @@
KustvaktException {
// delete marlin from group
ClientResponse response = resource().path("group").path("member")
- .path("delete").queryParam("memberId", "marlin")
- .queryParam("groupId", groupId)
+ .path("delete").path(groupId).path("marlin")
.header(Attributes.AUTHORIZATION,
handler.createBasicAuthorizationHeaderValue(
adminUsername, "pass"))
diff --git a/full/src/test/java/de/ids_mannheim/korap/web/controller/UserGroupControllerTest.java b/full/src/test/java/de/ids_mannheim/korap/web/controller/UserGroupControllerTest.java
index 17b2b51..8b7664c 100644
--- a/full/src/test/java/de/ids_mannheim/korap/web/controller/UserGroupControllerTest.java
+++ b/full/src/test/java/de/ids_mannheim/korap/web/controller/UserGroupControllerTest.java
@@ -63,7 +63,7 @@
.header(HttpHeaders.X_FORWARDED_FOR, "149.27.0.32")
.get(ClientResponse.class);
String entity = response.getEntity(String.class);
- // System.out.println(entity);
+ // System.out.println(entity);
assertEquals(Status.OK.getStatusCode(), response.getStatus());
JsonNode node = JsonUtils.readTree(entity);
@@ -85,7 +85,7 @@
.get(ClientResponse.class);
String entity = response.getEntity(String.class);
assertEquals(Status.OK.getStatusCode(), response.getStatus());
- // System.out.println(entity);
+ // System.out.println(entity);
JsonNode node = JsonUtils.readTree(entity);
assertEquals(2, node.at("/0/id").asInt());
@@ -118,7 +118,7 @@
.header(HttpHeaders.X_FORWARDED_FOR, "149.27.0.32")
.get(ClientResponse.class);
String entity = response.getEntity(String.class);
- // System.out.println(entity);
+ // System.out.println(entity);
JsonNode node = JsonUtils.readTree(entity);
assertEquals(Status.UNAUTHORIZED.getStatusCode(), response.getStatus());
@@ -155,7 +155,7 @@
.get(ClientResponse.class);
String entity = response.getEntity(String.class);
-// System.out.println(entity);
+ // System.out.println(entity);
JsonNode node = JsonUtils.readTree(entity);
assertEquals(1, node.size());
node = node.get(0);
@@ -193,8 +193,7 @@
KustvaktException {
// delete marlin from group
ClientResponse response = resource().path("group").path("member")
- .path("delete").queryParam("memberId", "marlin")
- .queryParam("groupId", groupId)
+ .path("delete").path(groupId).path("marlin")
.header(Attributes.AUTHORIZATION,
handler.createBasicAuthorizationHeaderValue(username,
"pass"))
@@ -219,8 +218,7 @@
KustvaktException {
// nemo is a group member
ClientResponse response = resource().path("group").path("member")
- .path("delete").queryParam("memberId", "marlin")
- .queryParam("groupId", groupId)
+ .path("delete").path(groupId).path("marlin")
.header(Attributes.AUTHORIZATION,
handler.createBasicAuthorizationHeaderValue("nemo",
"pass"))
@@ -228,7 +226,7 @@
.delete(ClientResponse.class);
String entity = response.getEntity(String.class);
- // System.out.println(entity);
+ // System.out.println(entity);
JsonNode node = JsonUtils.readTree(entity);
assertEquals(Status.UNAUTHORIZED.getStatusCode(), response.getStatus());
assertEquals(StatusCodes.AUTHORIZATION_FAILED,
@@ -242,9 +240,8 @@
ClientHandlerException, KustvaktException {
// dory delete pearl
ClientResponse response = resource().path("group").path("member")
- .path("delete").queryParam("memberId", "pearl")
// dory group
- .queryParam("groupId", "2")
+ .path("delete").path("2").path("pearl")
.header(Attributes.AUTHORIZATION,
handler.createBasicAuthorizationHeaderValue("dory",
"pass"))
@@ -262,9 +259,7 @@
public void testDeleteDeletedMember () throws UniformInterfaceException,
ClientHandlerException, KustvaktException {
ClientResponse response = resource().path("group").path("member")
- .path("delete").queryParam("memberId", "pearl")
- // dory group
- .queryParam("groupId", "2")
+ .path("delete").path("2").path("pearl")
.header(Attributes.AUTHORIZATION,
handler.createBasicAuthorizationHeaderValue("dory",
"pass"))
@@ -272,7 +267,7 @@
.delete(ClientResponse.class);
String entity = response.getEntity(String.class);
- // System.out.println(entity);
+ // System.out.println(entity);
JsonNode node = JsonUtils.readTree(entity);
assertEquals(Status.BAD_REQUEST.getStatusCode(), response.getStatus());
assertEquals(StatusCodes.GROUP_MEMBER_DELETED,
@@ -285,14 +280,14 @@
private void testDeleteGroup (String groupId)
throws UniformInterfaceException, ClientHandlerException,
KustvaktException {
- //delete group
- ClientResponse response = resource().path("group").path("delete")
- .queryParam("groupId", groupId)
- .header(Attributes.AUTHORIZATION,
- handler.createBasicAuthorizationHeaderValue(username,
- "pass"))
- .header(HttpHeaders.X_FORWARDED_FOR, "149.27.0.32")
- .delete(ClientResponse.class);
+ // delete group
+ ClientResponse response =
+ resource().path("group").path("delete").path(groupId)
+ .header(Attributes.AUTHORIZATION,
+ handler.createBasicAuthorizationHeaderValue(
+ username, "pass"))
+ .header(HttpHeaders.X_FORWARDED_FOR, "149.27.0.32")
+ .delete(ClientResponse.class);
assertEquals(Status.OK.getStatusCode(), response.getStatus());
@@ -322,16 +317,16 @@
public void testDeleteGroupUnauthorized () throws UniformInterfaceException,
ClientHandlerException, KustvaktException {
// dory is a group admin in marlin group
- ClientResponse response = resource().path("group").path("delete")
- .queryParam("groupId", "1")
- .header(Attributes.AUTHORIZATION,
- handler.createBasicAuthorizationHeaderValue("dory",
- "pass"))
- .header(HttpHeaders.X_FORWARDED_FOR, "149.27.0.32")
- .delete(ClientResponse.class);
+ ClientResponse response =
+ resource().path("group").path("delete").path("1")
+ .header(Attributes.AUTHORIZATION,
+ handler.createBasicAuthorizationHeaderValue(
+ "dory", "pass"))
+ .header(HttpHeaders.X_FORWARDED_FOR, "149.27.0.32")
+ .delete(ClientResponse.class);
String entity = response.getEntity(String.class);
- // System.out.println(entity);
+ // System.out.println(entity);
JsonNode node = JsonUtils.readTree(entity);
assertEquals(Status.UNAUTHORIZED.getStatusCode(), response.getStatus());
assertEquals(StatusCodes.AUTHORIZATION_FAILED,
@@ -343,13 +338,13 @@
@Test
public void testDeleteDeletedGroup () throws UniformInterfaceException,
ClientHandlerException, KustvaktException {
- ClientResponse response = resource().path("group").path("delete")
- .queryParam("groupId", "4")
- .header(Attributes.AUTHORIZATION,
- handler.createBasicAuthorizationHeaderValue("dory",
- "pass"))
- .header(HttpHeaders.X_FORWARDED_FOR, "149.27.0.32")
- .delete(ClientResponse.class);
+ ClientResponse response =
+ resource().path("group").path("delete").path("4")
+ .header(Attributes.AUTHORIZATION,
+ handler.createBasicAuthorizationHeaderValue(
+ "dory", "pass"))
+ .header(HttpHeaders.X_FORWARDED_FOR, "149.27.0.32")
+ .delete(ClientResponse.class);
assertEquals(Status.BAD_REQUEST.getStatusCode(), response.getStatus());
@@ -367,8 +362,7 @@
// delete marlin from marlin group
// dory is a group admin in marlin group
ClientResponse response = resource().path("group").path("member")
- .path("delete").queryParam("memberId", "marlin")
- .queryParam("groupId", "1")
+ .path("delete").path("1").path("marlin")
.header(Attributes.AUTHORIZATION,
handler.createBasicAuthorizationHeaderValue("dory",
"pass"))
@@ -376,7 +370,7 @@
.delete(ClientResponse.class);
String entity = response.getEntity(String.class);
- // System.out.println(entity);
+ // System.out.println(entity);
JsonNode node = JsonUtils.readTree(entity);
assertEquals(Status.BAD_REQUEST.getStatusCode(), response.getStatus());
assertEquals(StatusCodes.NOT_ALLOWED, node.at("/errors/0/0").asInt());
@@ -501,7 +495,7 @@
"pass"))
.entity(userGroup).post(ClientResponse.class);
String entity = response.getEntity(String.class);
- // System.out.println(entity);
+ // System.out.println(entity);
JsonNode node = JsonUtils.readTree(entity);
assertEquals(Status.BAD_REQUEST.getStatusCode(), response.getStatus());
assertEquals(StatusCodes.GROUP_MEMBER_EXISTS,
@@ -616,7 +610,8 @@
testUnsubscribeActiveMember(form);
checkGroupMemberRole("2", "marlin");
- // invite marlin to dory group to set back the GroupMemberStatus.PENDING
+ // invite marlin to dory group to set back the
+ // GroupMemberStatus.PENDING
testInviteDeletedMember();
}
@@ -673,7 +668,7 @@
"pass"))
.entity(form).post(ClientResponse.class);
String entity = response.getEntity(String.class);
- // System.out.println(entity);
+ // System.out.println(entity);
JsonNode node = JsonUtils.readTree(entity);
assertEquals(Status.BAD_REQUEST.getStatusCode(), response.getStatus());
@@ -696,7 +691,7 @@
"pass"))
.entity(form).post(ClientResponse.class);
String entity = response.getEntity(String.class);
- // System.out.println(entity);
+ // System.out.println(entity);
JsonNode node = JsonUtils.readTree(entity);
assertEquals(Status.BAD_REQUEST.getStatusCode(), response.getStatus());
@@ -774,7 +769,7 @@
public void testUnsubscribeDeletedMember ()
throws UniformInterfaceException, ClientHandlerException,
KustvaktException {
- // pearl unsubscribes from dory group
+ // pearl unsubscribes from dory group
MultivaluedMap<String, String> form = new MultivaluedMapImpl();
// dory group
form.add("groupId", "2");
@@ -788,7 +783,7 @@
.entity(form).post(ClientResponse.class);
String entity = response.getEntity(String.class);
- // System.out.println(entity);
+ // System.out.println(entity);
JsonNode node = JsonUtils.readTree(entity);
assertEquals(Status.BAD_REQUEST.getStatusCode(), response.getStatus());
assertEquals(StatusCodes.GROUP_MEMBER_DELETED,
@@ -823,7 +818,8 @@
node = retrieveUserGroups("marlin");
assertEquals(1, node.size());
- // invite marlin to dory group to set back the GroupMemberStatus.PENDING
+ // invite marlin to dory group to set back the
+ // GroupMemberStatus.PENDING
testInviteDeletedMember();
}
diff --git a/full/src/test/resources/log4j2-test.properties b/full/src/test/resources/log4j2-test.properties
new file mode 100644
index 0000000..909a154
--- /dev/null
+++ b/full/src/test/resources/log4j2-test.properties
@@ -0,0 +1,22 @@
+appenders = console
+appender.console.type = Console
+appender.console.name = STDOUT
+appender.console.layout.type = PatternLayout
+appender.console.layout.pattern = %d{yyyy-MM-dd, HH:mm:ss} %C{6} - %M%n %-5p: %m%n
+
+#appender.file.type = File
+#appender.file.name = ERRORLOG
+#appender.file.fileName=./logs/errors.log
+#appender.file.layout.type=PatternLayout
+#appender.file.layout.pattern= %d{yyyy-MM-dd, HH:mm:ss} %C{6} - %M%n %-5p: %m%n
+
+rootLogger.level = info
+rootLogger.appenderRefs = stdout
+rootLogger.appenderRef.stdout.ref = STDOUT
+
+#loggers=file
+#logger.file.name=com.sun.jersey.test.framework.spi.container
+#logger.file.level = info
+#logger.file.appenderRefs = file
+#logger.file.appenderRef.file.ref = ERRORLOG
+#logger.file.additivity=false
\ No newline at end of file