Removed createdBy from VirtualCorpusJson.
Change-Id: I9769beba284952ebb894f56c7bde6786f9359d69
diff --git a/full/Changes b/full/Changes
index 247ac09..809ebc0 100644
--- a/full/Changes
+++ b/full/Changes
@@ -15,8 +15,9 @@
- added hidden access removal when deleting published VC (margaretha)
- added check for hidden groups in VC controller tests (margaretha)
- added search user-group controller (margaretha)
+ - removed createdBy from VirtualCorpusJson (margaretha)
-version 0.60 release
+version 0.60
14/03/2018
- set up mail settings using localhost port 25 (margaretha)
- added mail template in kustvakt configuration (margaretha)
diff --git a/full/src/main/java/de/ids_mannheim/korap/service/VirtualCorpusService.java b/full/src/main/java/de/ids_mannheim/korap/service/VirtualCorpusService.java
index 429440d..0643baa 100644
--- a/full/src/main/java/de/ids_mannheim/korap/service/VirtualCorpusService.java
+++ b/full/src/main/java/de/ids_mannheim/korap/service/VirtualCorpusService.java
@@ -20,7 +20,6 @@
import de.ids_mannheim.korap.dao.AdminDao;
import de.ids_mannheim.korap.dao.VirtualCorpusAccessDao;
import de.ids_mannheim.korap.dao.VirtualCorpusDao;
-import de.ids_mannheim.korap.dto.UserGroupDto;
import de.ids_mannheim.korap.dto.VirtualCorpusAccessDto;
import de.ids_mannheim.korap.dto.VirtualCorpusDto;
import de.ids_mannheim.korap.dto.converter.VirtualCorpusAccessConverter;
@@ -224,7 +223,6 @@
ParameterChecker.checkStringValue(vc.getName(), "name");
ParameterChecker.checkObjectValue(vc.getType(), "type");
ParameterChecker.checkStringValue(vc.getCorpusQuery(), "corpusQuery");
- ParameterChecker.checkStringValue(vc.getCreatedBy(), "createdBy");
if (vc.getType().equals(VirtualCorpusType.SYSTEM)
@@ -238,7 +236,7 @@
int vcId = vcDao.createVirtualCorpus(vc.getName(), vc.getType(),
requiredAccess, koralQuery, vc.getDefinition(),
- vc.getDescription(), vc.getStatus(), vc.getCreatedBy());
+ vc.getDescription(), vc.getStatus(), username);
if (vc.getType().equals(VirtualCorpusType.PUBLISHED)) {
publishVC(vcId);
@@ -454,6 +452,4 @@
}
return false;
}
-
-
}
diff --git a/full/src/main/java/de/ids_mannheim/korap/web/controller/VirtualCorpusController.java b/full/src/main/java/de/ids_mannheim/korap/web/controller/VirtualCorpusController.java
index 94cc93d..a0f937f 100644
--- a/full/src/main/java/de/ids_mannheim/korap/web/controller/VirtualCorpusController.java
+++ b/full/src/main/java/de/ids_mannheim/korap/web/controller/VirtualCorpusController.java
@@ -66,9 +66,10 @@
@Autowired
private VirtualCorpusService service;
+ // EM: should system admins be able to create VC for other users?
/** Creates a user virtual corpus, also for system admins
*
- * EM: should system admins be able to create VC for other users?
+ * @see VirtualCorpusJson
*
* @param securityContext
* @param vc a JSON object describing the virtual corpus
@@ -94,8 +95,11 @@
return Response.ok().build();
}
- /** Only the virtual corpus owner and system admins can edit
- * a virtual corpus.
+ /** Edits a virtual corpus attributes including name, type and corpus
+ * query. Only the virtual corpus owner and system admins can edit
+ * a virtual corpus.
+ *
+ * @see VirtualCorpusJson
*
* @param securityContext
* @param vc a JSON object describing the virtual corpus
@@ -119,7 +123,7 @@
return Response.ok().build();
}
- /** Searches for a specific virtual corpus.
+ /** Searches for a specific VC given the VC id.
*
* @param securityContext
* @param vcId a virtual corpus id
diff --git a/full/src/main/java/de/ids_mannheim/korap/web/input/VirtualCorpusJson.java b/full/src/main/java/de/ids_mannheim/korap/web/input/VirtualCorpusJson.java
index ac09516..a67876a 100644
--- a/full/src/main/java/de/ids_mannheim/korap/web/input/VirtualCorpusJson.java
+++ b/full/src/main/java/de/ids_mannheim/korap/web/input/VirtualCorpusJson.java
@@ -23,7 +23,6 @@
private String name;
private VirtualCorpusType type;
private String corpusQuery;
- private String createdBy;
// required in editing VCs
private int id;
diff --git a/full/src/test/java/de/ids_mannheim/korap/service/VirtualCorpusServiceTest.java b/full/src/test/java/de/ids_mannheim/korap/service/VirtualCorpusServiceTest.java
index e9511a4..6ae2e3d 100644
--- a/full/src/test/java/de/ids_mannheim/korap/service/VirtualCorpusServiceTest.java
+++ b/full/src/test/java/de/ids_mannheim/korap/service/VirtualCorpusServiceTest.java
@@ -32,7 +32,6 @@
VirtualCorpusJson vc = new VirtualCorpusJson();
vc.setCorpusQuery("corpusSigle=GOE");
- vc.setCreatedBy(username);
vc.setName("new published vc");
vc.setType(VirtualCorpusType.PUBLISHED);
int vcId = vcService.storeVC(vc, "VirtualCorpusServiceTest");
diff --git a/full/src/test/java/de/ids_mannheim/korap/web/controller/SearchControllerTest.java b/full/src/test/java/de/ids_mannheim/korap/web/controller/SearchControllerTest.java
index 5814029..ecede59 100644
--- a/full/src/test/java/de/ids_mannheim/korap/web/controller/SearchControllerTest.java
+++ b/full/src/test/java/de/ids_mannheim/korap/web/controller/SearchControllerTest.java
@@ -17,28 +17,21 @@
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.query.serialize.QuerySerializer;
import de.ids_mannheim.korap.utils.JsonUtils;
-import de.ids_mannheim.korap.web.FastJerseyTest;
/**
- * @author hanl, margaretha
- * @lastUpdate 30/05/2017
+ * @author margaretha, hanl
+ * @lastUpdate 22/03/2018
*
*/
-public class SearchControllerTest extends FastJerseyTest {
+public class SearchControllerTest extends SpringJerseyTest {
@Autowired
- HttpAuthorizationHandler handler;
+ private HttpAuthorizationHandler handler;
- @Override
- public void initMethod () throws KustvaktException {
-// helper().runBootInterfaces();
-// helper().setupAccount();
- }
-
-
@Test
public void testSearchQueryPublicCorpora () throws KustvaktException{
@@ -46,8 +39,8 @@
.path("search").queryParam("q", "[orth=der]")
.queryParam("ql", "poliqarp")
.accept(MediaType.APPLICATION_JSON).get(ClientResponse.class);
-// assertEquals(ClientResponse.Status.OK.getStatusCode(),
-// response.getStatus());
+ assertEquals(ClientResponse.Status.OK.getStatusCode(),
+ response.getStatus());
String ent = response.getEntity(String.class);
// System.out.println(ent);
JsonNode node = JsonUtils.readTree(ent);
diff --git a/full/src/test/java/de/ids_mannheim/korap/web/controller/VirtualCorpusControllerAdminTest.java b/full/src/test/java/de/ids_mannheim/korap/web/controller/VirtualCorpusControllerAdminTest.java
index 225d83e..d8ff61b 100644
--- a/full/src/test/java/de/ids_mannheim/korap/web/controller/VirtualCorpusControllerAdminTest.java
+++ b/full/src/test/java/de/ids_mannheim/korap/web/controller/VirtualCorpusControllerAdminTest.java
@@ -107,8 +107,7 @@
@Test
public void testCreateSystemVC () throws KustvaktException {
String json = "{\"name\": \"new system vc\",\"type\": \"SYSTEM\","
- + "\"createdBy\": \"admin\",\"corpusQuery\": \"creationDate "
- + "since 1820\"}";
+ + "\"corpusQuery\": \"creationDate since 1820\"}";
ClientResponse response = resource().path("vc").path("create")
.header(Attributes.AUTHORIZATION,
@@ -147,10 +146,8 @@
@Test
public void testPrivateVC () throws UniformInterfaceException,
ClientHandlerException, KustvaktException {
- String json =
- "{\"name\": \"new vc\",\"type\": \"PRIVATE\",\"createdBy\": "
- + "\"" + username
- + "\",\"corpusQuery\": \"corpusSigle=GOE\"}";
+ String json = "{\"name\": \"new vc\",\"type\": \"PRIVATE\","
+ + "\"corpusQuery\": \"corpusSigle=GOE\"}";
ClientResponse response = resource().path("vc").path("create")
.header(Attributes.AUTHORIZATION,
@@ -236,7 +233,7 @@
JsonNode node = JsonUtils.readTree(entity);
assertEquals(1, node.size());
node = node.get(0);
-
+
assertEquals(admin, node.at("/createdBy").asText());
assertEquals(5, node.at("/vcId").asInt());
assertEquals("marlin VC", node.at("/vcName").asText());
@@ -246,7 +243,8 @@
return node.at("/accessId").asText();
}
- private void testlistAccessByGroup (String groupId) throws KustvaktException {
+ private void testlistAccessByGroup (String groupId)
+ throws KustvaktException {
ClientResponse response = resource().path("vc").path("access")
.path("list").path("byGroup").queryParam("groupId", groupId)
.header(Attributes.AUTHORIZATION,
@@ -268,7 +266,7 @@
testCreateVCAccess(vcId, groupId);
testlistAccessByGroup(groupId);
-
+
String accessId = testlistAccessByVC(vcId);
testDeleteVCAccess(accessId);
}
diff --git a/full/src/test/java/de/ids_mannheim/korap/web/controller/VirtualCorpusControllerTest.java b/full/src/test/java/de/ids_mannheim/korap/web/controller/VirtualCorpusControllerTest.java
index bbe68bd..b61c972 100644
--- a/full/src/test/java/de/ids_mannheim/korap/web/controller/VirtualCorpusControllerTest.java
+++ b/full/src/test/java/de/ids_mannheim/korap/web/controller/VirtualCorpusControllerTest.java
@@ -294,9 +294,8 @@
@Test
public void testCreatePrivateVC () throws KustvaktException {
- String json =
- "{\"name\": \"new vc\",\"type\": \"PRIVATE\",\"createdBy\": "
- + "\"VirtualCorpusControllerTest\",\"corpusQuery\": \"corpusSigle=GOE\"}";
+ String json = "{\"name\": \"new vc\",\"type\": \"PRIVATE\","
+ + "\"corpusQuery\": \"corpusSigle=GOE\"}";
ClientResponse response = resource().path("vc").path("create")
.header(Attributes.AUTHORIZATION,
@@ -326,9 +325,8 @@
@Test
public void testCreatePublishVC () throws KustvaktException {
- String json =
- "{\"name\": \"new published vc\",\"type\": \"PUBLISHED\",\"createdBy\": "
- + "\"VirtualCorpusControllerTest\",\"corpusQuery\": \"corpusSigle=GOE\"}";
+ String json = "{\"name\": \"new published vc\",\"type\": \"PUBLISHED\""
+ + ",\"corpusQuery\": \"corpusSigle=GOE\"}";
ClientResponse response = resource().path("vc").path("create")
.header(Attributes.AUTHORIZATION,
handler.createBasicAuthorizationHeaderValue(
@@ -388,7 +386,6 @@
public void testCreateVCWithExpiredToken ()
throws IOException, KustvaktException {
String json = "{\"name\": \"new vc\",\"type\": \"PRIVATE\","
- + "\"createdBy\": \"VirtualCorpusControllerTest\","
+ "\"corpusQuery\": \"corpusSigle=GOE\"}";
InputStream is = getClass().getClassLoader()
@@ -422,7 +419,6 @@
@Test
public void testCreateSystemVC () throws KustvaktException {
String json = "{\"name\": \"new vc\",\"type\": \"SYSTEM\","
- + "\"createdBy\": \"VirtualCorpusControllerTest\","
+ "\"corpusQuery\": \"creationDate since 1820\"}";
ClientResponse response = resource().path("vc").path("create")
@@ -447,9 +443,8 @@
@Test
public void testCreateVCUnauthorized () throws KustvaktException {
- String json =
- "{\"name\": \"new vc\",\"type\": \"PRIVATE\",\"createdBy\": "
- + "\"VirtualCorpusControllerTest\",\"corpusQuery\": \"creationDate since 1820\"}";
+ String json = "{\"name\": \"new vc\",\"type\": \"PRIVATE\","
+ + "\"corpusQuery\": \"creationDate since 1820\"}";
ClientResponse response = resource().path("vc").path("create")
.header(HttpHeaders.CONTENT_TYPE, ContentType.APPLICATION_JSON)
@@ -469,9 +464,7 @@
@Test
public void testCreateVCWithoutcorpusQuery () throws KustvaktException {
- String json =
- "{\"name\": \"new vc\",\"type\": \"PRIVATE\",\"createdBy\": "
- + "\"VirtualCorpusControllerTest\"}";
+ String json = "{\"name\": \"new vc\",\"type\": \"PRIVATE\"}";
ClientResponse response = resource().path("vc").path("create")
.header(Attributes.AUTHORIZATION,
@@ -492,8 +485,8 @@
@Test
public void testCreateVCWithoutType () throws KustvaktException {
- String json = "{\"name\": \"new vc\",\"createdBy\": "
- + "\"VirtualCorpusControllerTest\",\"corpusQuery\": \"creationDate since 1820\"}";
+ String json = "{\"name\": \"new vc\",\"corpusQuery\": "
+ + "\"creationDate since 1820\"}";
ClientResponse response = resource().path("vc").path("create")
.header(Attributes.AUTHORIZATION,
@@ -514,9 +507,8 @@
@Test
public void testCreateVCWithWrongType () throws KustvaktException {
- String json =
- "{\"name\": \"new vc\",\"type\": \"PRIVAT\",\"createdBy\": "
- + "\"VirtualCorpusControllerTest\",\"corpusQuery\": \"creationDate since 1820\"}";
+ String json = "{\"name\": \"new vc\",\"type\": \"PRIVAT\","
+ + "\"corpusQuery\": \"creationDate since 1820\"}";
ClientResponse response = resource().path("vc").path("create")
.header(Attributes.AUTHORIZATION,