Fixed unrecognized application/json and velocity template.
Change-Id: I2c718fbdba86fcdc20fd20893c3c8f803809f460
diff --git a/core/Changes b/core/Changes
index 7434a31..3b341f8 100644
--- a/core/Changes
+++ b/core/Changes
@@ -1,5 +1,5 @@
version 0.59.10
-07/02/2018
+20/02/2018
- updated hibernate and reflection versions (margaretha)
- added Changes file (margaretha)
- merged BeanConfigBaseTest to BeanConfigTest in /full (margaretha)
@@ -7,6 +7,7 @@
- updated library versions and java environment (margaretha)
- added status codes (margaretha)
- moved validation.properties (margaretha)
+ - fixed unrecognize media-type application/json (margaretha)
version 0.59.9
08/11/2017
diff --git a/core/pom.xml b/core/pom.xml
index a8420e4..9089163 100644
--- a/core/pom.xml
+++ b/core/pom.xml
@@ -261,7 +261,7 @@
<dependency>
<groupId>de.ids_mannheim.korap</groupId>
<artifactId>Krill</artifactId>
- <version>0.56.1</version>
+ <version>0.56.2</version>
<exclusions>
<exclusion>
<groupId>org.xerial</groupId>
diff --git a/core/src/main/java/de/ids_mannheim/korap/web/KustvaktBaseServer.java b/core/src/main/java/de/ids_mannheim/korap/web/KustvaktBaseServer.java
index 904e04e..8496d04 100644
--- a/core/src/main/java/de/ids_mannheim/korap/web/KustvaktBaseServer.java
+++ b/core/src/main/java/de/ids_mannheim/korap/web/KustvaktBaseServer.java
@@ -24,7 +24,7 @@
public abstract class KustvaktBaseServer {
protected static KustvaktConfiguration config;
-
+
protected static String rootPackages;
protected static KustvaktArgs kargs;
@@ -62,35 +62,37 @@
return kargs;
}
- protected void start(){
-
- if (kargs.port == -1){
+ protected void start () {
+
+ if (kargs.port == -1) {
kargs.setPort(config.getPort());
}
Server server = new Server();
-
- ServletContextHandler contextHandler = new ServletContextHandler(
- ServletContextHandler.NO_SESSIONS);
+
+ ServletContextHandler contextHandler =
+ new ServletContextHandler(ServletContextHandler.NO_SESSIONS);
contextHandler.setContextPath("/");
contextHandler.setInitParameter("contextConfigLocation",
"classpath:" + kargs.getConfig());
-
+
ServletContextListener listener = new ContextLoaderListener();
contextHandler.addEventListener(listener);
ServletHolder servletHolder = new ServletHolder(new SpringServlet());
servletHolder.setInitParameter(
"com.sun.jersey.config.property.packages", rootPackages);
+ servletHolder.setInitParameter(
+ "com.sun.jersey.api.json.POJOMappingFeature", "true");
servletHolder.setInitOrder(1);
contextHandler.addServlet(servletHolder, config.getBaseURL());
ServerConnector connector = new ServerConnector(server);
connector.setPort(kargs.port);
connector.setIdleTimeout(60000);
-
+
server.setHandler(contextHandler);
-
+
server.setConnectors(new Connector[] { connector });
try {
server.start();
diff --git a/full/Changes b/full/Changes
index be40c69..40a067f 100644
--- a/full/Changes
+++ b/full/Changes
@@ -17,7 +17,8 @@
- updated status codes and error messages to be more detailed (margaretha)
- testing mail implementation using embedded jetty jndi (margaretha)
- fixed collection rewrite regarding OR operation with other fields (margaretha)
- - implemented sending mail using spring injection and removed jetty jndi (margaretha)
+ - implemented sending mail using spring injection and removed jetty jndi (margaretha)
+ - fixed and updated velocity template (margaretha)
version 0.59.9
19/01/2018
diff --git a/full/notification.vm b/full/notification.vm
deleted file mode 100644
index 02cf5c6..0000000
--- a/full/notification.vm
+++ /dev/null
@@ -1,13 +0,0 @@
-<html>
- <body>
- <h3>Hi ${username}, you are invited to group {$group} by ${inviter}!</h3>
- <p>
- Login to KorAP to accept or reject the invitation.
- <br />
- The invitation is valid for 30 minutes.
- </p>
- <p>
- Do not reply! This is an automated generated email.
- </p>
- </body>
-</html>
\ No newline at end of file
diff --git a/full/pom.xml b/full/pom.xml
index df0d2a8..1391cc4 100644
--- a/full/pom.xml
+++ b/full/pom.xml
@@ -25,6 +25,7 @@
<include>**/*.kustvakt</include>
<include>**/*.properties</include>
<include>**/*.sql</include>
+ <include>**/*.vm</include>
</includes>
</resource>
</resources>
@@ -224,6 +225,11 @@
<version>${jersey.version}</version>
<scope>test</scope>
</dependency>
+ <dependency>
+ <groupId>com.sun.jersey</groupId>
+ <artifactId>jersey-json</artifactId>
+ <version>${jersey.version}</version>
+ </dependency>
<!-- Spring -->
<dependency>
@@ -248,7 +254,7 @@
</dependency>
<!-- jetty -->
- <dependency>
+ <!-- <dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-jndi</artifactId>
<version>${jetty.version}</version>
@@ -257,7 +263,7 @@
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-plus</artifactId>
<version>${jetty.version}</version>
- </dependency>
+ </dependency> -->
<!-- velocity -->
<dependency>
diff --git a/full/src/main/java/de/ids_mannheim/korap/service/MailService.java b/full/src/main/java/de/ids_mannheim/korap/service/MailService.java
index 75d5176..ff05bbe 100644
--- a/full/src/main/java/de/ids_mannheim/korap/service/MailService.java
+++ b/full/src/main/java/de/ids_mannheim/korap/service/MailService.java
@@ -45,7 +45,7 @@
MimeMessageHelper message = new MimeMessageHelper(mimeMessage);
message.setTo(new InternetAddress(invitee.getEmail()));
message.setFrom(sender);
- message.setSubject("Invitation to join group");
+ message.setSubject("Invitation to join "+groupName);
message.setText(prepareText(inviteeName, groupName, inviter),
true);
}
@@ -62,12 +62,8 @@
context.put("inviter", inviter);
StringWriter stringWriter = new StringWriter();
-// URL url = getClass().getClassLoader().getResource("notification.vm");
-// System.out.println(url);
-// Template t = velocityEngine.getTemplate(url.toString());
-// System.out.println(t);
- velocityEngine.mergeTemplate("notification.vm",
+ velocityEngine.mergeTemplate("templates/notification.vm",
StandardCharsets.UTF_8.name(), context, stringWriter);
String message = stringWriter.toString();
diff --git a/full/src/main/resources/WEB-INF/web.xml b/full/src/main/resources/WEB-INF/web.xml
deleted file mode 100644
index 4c2a254..0000000
--- a/full/src/main/resources/WEB-INF/web.xml
+++ /dev/null
@@ -1,5 +0,0 @@
-<resource-ref>
- <res-ref-name>mail/Session</res-ref-name>
- <res-type>javax.mail.Session</res-type>
- <res-auth>Container</res-auth>
-</resource-ref>
\ No newline at end of file
diff --git a/full/src/main/resources/log4j.properties b/full/src/main/resources/log4j.properties
index e688b81..c747b68 100644
--- a/full/src/main/resources/log4j.properties
+++ b/full/src/main/resources/log4j.properties
@@ -4,9 +4,10 @@
log4j.rootLogger=ERROR, stdout, debugLog
log4j.logger.log=ERROR, errorLog
-#log4j.logger.de.ids_mannheim.korap.service.VirtualCorpusService = error, debugLog
#log4j.logger.de.ids_mannheim.korap.web.controller.AuthenticationController = debug, debugLog, stdout
-#log4j.logger.de.ids_mannheim.korap.service.UserGroupService= stdout, debugLog
+#log4j.logger.de.ids_mannheim.korap.service.UserGroupService= debug, stdout, debugLog
+#log4j.logger.de.ids_mannheim.korap.rewrite.CollectionRewrite= debug, stdout, debugLog
+#log4j.logger.de.ids_mannheim.korap.service.MailService= debug, stdout, debugLog
# Direct log messages to stdout
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
diff --git a/full/src/main/resources/templates/notification.vm b/full/src/main/resources/templates/notification.vm
new file mode 100644
index 0000000..254ad83
--- /dev/null
+++ b/full/src/main/resources/templates/notification.vm
@@ -0,0 +1,12 @@
+<html>
+ <body>
+ <h3>Hi $username,</h3>
+ <p> you have been invited to group $group by $inviter! </p>
+ <p> Please login to <a href="https://korap.ids-mannheim.de/kalamar">KorAP</a> with your
+ account to accept or reject this invitation within 30 minutes. </p>
+ <p>After joining a group, you will be able to access virtual corpora shared with members of
+ the group. If you would like share your virtual corpus to a group, please contact the
+ group admin.</p>
+ <p> This is an automated generated email. Please do not reply directly to this e-mail. </p>
+ </body>
+</html>
\ No newline at end of file
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 f5f44cb..be39d02 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
@@ -445,8 +445,10 @@
assertEquals(Status.BAD_REQUEST.getStatusCode(), response.getStatus());
assertEquals(StatusCodes.GROUP_MEMBER_EXISTS,
node.at("/errors/0/0").asInt());
- assertEquals("Username marlin with status PENDING exists in the user-group "
- + "dory group", node.at("/errors/0/1").asText());
+ assertEquals(
+ "Username marlin with status PENDING exists in the user-group "
+ + "dory group",
+ node.at("/errors/0/1").asText());
assertEquals("[marlin, PENDING, dory group]",
node.at("/errors/0/2").asText());
}
@@ -470,8 +472,7 @@
"pass"))
.entity(userGroup).post(ClientResponse.class);
- String entity = response.getEntity(String.class);
- System.out.println(entity);
+ String entity = response.getEntity(String.class);
assertEquals(Status.OK.getStatusCode(), response.getStatus());
// check member
@@ -653,7 +654,7 @@
node.at("/errors/0/1").asText());
assertEquals("[pearl, dory group]", node.at("/errors/0/2").asText());
}
-
+
@Test
public void testUnsubscribePendingMember ()
throws UniformInterfaceException, ClientHandlerException,
@@ -661,7 +662,7 @@
JsonNode node = retrieveUserGroups("marlin");
assertEquals(2, node.size());
-
+
MultivaluedMap<String, String> form = new MultivaluedMapImpl();
// dory group
form.add("groupId", "2");
@@ -678,9 +679,9 @@
// System.out.println(entity);
assertEquals(Status.OK.getStatusCode(), response.getStatus());
- node = retrieveUserGroups("marlin");
+ node = retrieveUserGroups("marlin");
assertEquals(1, node.size());
-
+
// invite marlin to dory group to set back the GroupMemberStatus.PENDING
testInviteDeletedMember();
}