Added comments & updated code structure.
Change-Id: I2ff7adb2954b87e8345a6e0619b14614883c4200
diff --git a/core/Changes b/core/Changes
index c5ba7df..4b47cb8 100644
--- a/core/Changes
+++ b/core/Changes
@@ -5,7 +5,13 @@
- Updated RewriteHandler (margaretha)
19/12/2018
- Added debug flags (margaretha)
- - Added order on the fields parameter of search get request (margaretha)
+ - Added order on the fields parameter of search get request (margaretha)
+07/01/2019
+ - Disabled send shutdown to existing jetty web server at start (margaretha)
+09/01/2019
+ - Added comments (margaretha)
+ - Updated code structure (margaretha)
+ - Removed spring security libraries and ManagerInterface (margaretha)
version 0.61.4
14/11/2018
diff --git a/core/pom.xml b/core/pom.xml
index 869823c..dfd73fe 100644
--- a/core/pom.xml
+++ b/core/pom.xml
@@ -3,12 +3,12 @@
<modelVersion>4.0.0</modelVersion>
<groupId>de.ids_mannheim.korap</groupId>
<artifactId>Kustvakt-core</artifactId>
- <version>0.61.4</version>
+ <version>0.61.5</version>
<properties>
<java.version>1.8</java.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
- <spring.version>5.1.1.RELEASE</spring.version>
+ <spring.version>5.1.2.RELEASE</spring.version>
<jersey.version>1.19.4</jersey.version>
<jetty.version>9.4.12.v20180830</jetty.version>
<hibernate.version>5.3.7.Final</hibernate.version>
@@ -153,6 +153,12 @@
<artifactId>json-smart</artifactId>
<version>1.0.9</version>
</dependency>
+ <!-- JSON support in Jersey -->
+ <dependency>
+ <groupId>com.fasterxml.jackson.jaxrs</groupId>
+ <artifactId>jackson-jaxrs-json-provider</artifactId>
+ <version>[2.9.5,)</version>
+ </dependency>
<!-- Flyway -->
<dependency>
@@ -335,7 +341,7 @@
<artifactId>spring-tx</artifactId>
<version>${spring.version}</version>
</dependency>
- <dependency>
+ <!-- <dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-core</artifactId>
<version>${spring.version}</version>
@@ -344,7 +350,7 @@
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-web</artifactId>
<version>${spring.version}</version>
- </dependency>
+ </dependency> -->
<!-- EM: done -->
<dependency>
<groupId>org.springframework</groupId>
diff --git a/core/src/main/java/de/ids_mannheim/korap/annotation/AnnotationParser.java b/core/src/main/java/de/ids_mannheim/korap/annotation/AnnotationParser.java
index 5b9cd87..8aca637 100644
--- a/core/src/main/java/de/ids_mannheim/korap/annotation/AnnotationParser.java
+++ b/core/src/main/java/de/ids_mannheim/korap/annotation/AnnotationParser.java
@@ -23,6 +23,11 @@
import de.ids_mannheim.korap.entity.AnnotationKey;
import de.ids_mannheim.korap.entity.AnnotationLayer;
+/** Parser for extracting annotation descriptions from Kalamar javascripts
+ *
+ * @author margaretha
+ *
+ */
@Component
public class AnnotationParser {
diff --git a/core/src/main/java/de/ids_mannheim/korap/config/KustvaktConfiguration.java b/core/src/main/java/de/ids_mannheim/korap/config/KustvaktConfiguration.java
index 7aab419..2d0d720 100644
--- a/core/src/main/java/de/ids_mannheim/korap/config/KustvaktConfiguration.java
+++ b/core/src/main/java/de/ids_mannheim/korap/config/KustvaktConfiguration.java
@@ -11,7 +11,6 @@
import java.util.Properties;
import java.util.Set;
import java.util.regex.Pattern;
-import java.util.stream.Collectors;
import de.ids_mannheim.korap.util.KrillProperties;
import de.ids_mannheim.korap.utils.TimeUtils;
@@ -19,14 +18,15 @@
import lombok.Setter;
/**
- * if configuration class is extended, loadSubTypes method should be
+ * Describes configuration for Kustvakt by importing properties
+ * from kustvakt.conf file and setting default values if they are
+ * not configured.
+ *
+ * MH: if configuration class is extended, loadSubTypes method should be
* overriden
*
* @author hanl
- * @date 05/02/2014
- *
* @author margaretha
- * - cleaned up log4j loader
*/
@Setter
diff --git a/core/src/main/java/de/ids_mannheim/korap/constant/AnnotationType.java b/core/src/main/java/de/ids_mannheim/korap/constant/AnnotationType.java
index 560d401..ea91e16 100644
--- a/core/src/main/java/de/ids_mannheim/korap/constant/AnnotationType.java
+++ b/core/src/main/java/de/ids_mannheim/korap/constant/AnnotationType.java
@@ -1,5 +1,10 @@
package de.ids_mannheim.korap.constant;
+/** Defines various annotation types as constants
+ *
+ * @author margaretha
+ *
+ */
public class AnnotationType {
public static String FOUNDRY = "foundry";
public static String LAYER = "layer";
diff --git a/core/src/main/java/de/ids_mannheim/korap/constant/OAuth2Scope.java b/core/src/main/java/de/ids_mannheim/korap/constant/OAuth2Scope.java
index 9993541..dea8ca7 100644
--- a/core/src/main/java/de/ids_mannheim/korap/constant/OAuth2Scope.java
+++ b/core/src/main/java/de/ids_mannheim/korap/constant/OAuth2Scope.java
@@ -1,5 +1,10 @@
package de.ids_mannheim.korap.constant;
+/** Defines all possible authorization scopes
+ *
+ * @author margaretha
+ *
+ */
public enum OAuth2Scope {
ALL,
diff --git a/core/src/main/java/de/ids_mannheim/korap/constant/TokenType.java b/core/src/main/java/de/ids_mannheim/korap/constant/TokenType.java
index 418be0b..76bac5b 100644
--- a/core/src/main/java/de/ids_mannheim/korap/constant/TokenType.java
+++ b/core/src/main/java/de/ids_mannheim/korap/constant/TokenType.java
@@ -2,6 +2,15 @@
import org.apache.commons.lang.StringUtils;
+import de.ids_mannheim.korap.security.context.TokenContext;
+
+/** Defines the types of authentication tokens. Token types are used to
+ * create {@link TokenContext} and determine which authentication provider
+ * must be used to create a TokenContext and parse given tokens.
+ *
+ * @author margaretha
+ *
+ */
public enum TokenType {
BASIC, API, SESSION,
// openid token, e.g. within oauth2 response (json body)
diff --git a/core/src/main/java/de/ids_mannheim/korap/dao/AnnotationDao.java b/core/src/main/java/de/ids_mannheim/korap/dao/AnnotationDao.java
index ef54fda..0c527d7 100644
--- a/core/src/main/java/de/ids_mannheim/korap/dao/AnnotationDao.java
+++ b/core/src/main/java/de/ids_mannheim/korap/dao/AnnotationDao.java
@@ -25,7 +25,7 @@
import de.ids_mannheim.korap.utils.ParameterChecker;
/**
- * AnnotationDao manages SQL queries regarding annotations including
+ * AnnotationDao manages queries to database regarding annotations including
* foundry and layer pairs.
*
* @author margaretha
diff --git a/core/src/main/java/de/ids_mannheim/korap/entity/AnnotationKey.java b/core/src/main/java/de/ids_mannheim/korap/entity/AnnotationKey.java
index d65ffb2..a4ccdaa 100644
--- a/core/src/main/java/de/ids_mannheim/korap/entity/AnnotationKey.java
+++ b/core/src/main/java/de/ids_mannheim/korap/entity/AnnotationKey.java
@@ -18,6 +18,14 @@
import lombok.Getter;
import lombok.Setter;
+/**
+ * Describes the annotation key mapping to annotation_key table in the
+ * database and annotation key relations to {@link AnnotationLayer}
+ * and {@link Annotation}.
+ *
+ * @author margaretha
+ *
+ */
@Setter
@Getter
@Entity
diff --git a/core/src/main/java/de/ids_mannheim/korap/entity/AnnotationLayer.java b/core/src/main/java/de/ids_mannheim/korap/entity/AnnotationLayer.java
index c16abec..00f6d6e 100644
--- a/core/src/main/java/de/ids_mannheim/korap/entity/AnnotationLayer.java
+++ b/core/src/main/java/de/ids_mannheim/korap/entity/AnnotationLayer.java
@@ -22,7 +22,7 @@
import lombok.Setter;
/**
- * Describes annotations as a pair, e.g. foundry and layer where
+ * Describes annotation layers as a pair of foundry and layer where
* foundry denotes where the annotation comes from e.g. Tree tagger
* parser, and layer denotes the annotation layer e.g. part of speech.
*
diff --git a/core/src/main/java/de/ids_mannheim/korap/entity/Resource.java b/core/src/main/java/de/ids_mannheim/korap/entity/Resource.java
index 813adc5..246d80d 100644
--- a/core/src/main/java/de/ids_mannheim/korap/entity/Resource.java
+++ b/core/src/main/java/de/ids_mannheim/korap/entity/Resource.java
@@ -16,8 +16,8 @@
/**
* Describes resources having free licenses. Primarily for
- * accommodating
- * clients in providing data without login such as KorapSRU.
+ * accommodating clients in providing data without login such as
+ * KorapSRU.
*
* @author margaretha
*
diff --git a/core/src/main/java/de/ids_mannheim/korap/managers/ManagerInterface.java b/core/src/main/java/de/ids_mannheim/korap/managers/ManagerInterface.java
deleted file mode 100644
index 946dfc2..0000000
--- a/core/src/main/java/de/ids_mannheim/korap/managers/ManagerInterface.java
+++ /dev/null
@@ -1,61 +0,0 @@
-package de.ids_mannheim.korap.managers;
-
-import java.util.Set;
-
-/**
- * @author hanl
- * @date 17/02/2016
- */
-public interface ManagerInterface {
-
- String name ();
-
-
- Set<Function> getFunctions ();
-
-
- Result process ();
-
- class Result {
-
- }
-
- class Function {
-
- private String name;
- private String[] args;
-
-
- @Override
- public boolean equals (Object o) {
- if (this == o)
- return true;
- if (o == null || getClass() != o.getClass())
- return false;
-
- Function function = (Function) o;
-
- return name != null ? name.equals(function.name)
- : function.name == null;
-
- }
-
-
- @Override
- public int hashCode () {
- return name != null ? name.hashCode() : 0;
- }
-
-
- public void setName (String name) {
- this.name = name;
- }
-
-
- public void setArgs (String ... args) {
- this.args = args;
- }
-
- }
-
-}
diff --git a/core/src/main/java/de/ids_mannheim/korap/resource/rewrite/CollectionCleanRewrite.java b/core/src/main/java/de/ids_mannheim/korap/rewrite/CollectionCleanRewrite.java
similarity index 97%
rename from core/src/main/java/de/ids_mannheim/korap/resource/rewrite/CollectionCleanRewrite.java
rename to core/src/main/java/de/ids_mannheim/korap/rewrite/CollectionCleanRewrite.java
index 7a4ab70..6cacd4b 100644
--- a/core/src/main/java/de/ids_mannheim/korap/resource/rewrite/CollectionCleanRewrite.java
+++ b/core/src/main/java/de/ids_mannheim/korap/rewrite/CollectionCleanRewrite.java
@@ -1,4 +1,4 @@
-package de.ids_mannheim.korap.resource.rewrite;
+package de.ids_mannheim.korap.rewrite;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.node.ObjectNode;
diff --git a/core/src/main/java/de/ids_mannheim/korap/resource/rewrite/FoundryInject.java b/core/src/main/java/de/ids_mannheim/korap/rewrite/FoundryInject.java
similarity index 92%
rename from core/src/main/java/de/ids_mannheim/korap/resource/rewrite/FoundryInject.java
rename to core/src/main/java/de/ids_mannheim/korap/rewrite/FoundryInject.java
index 1048f1b..f682414 100644
--- a/core/src/main/java/de/ids_mannheim/korap/resource/rewrite/FoundryInject.java
+++ b/core/src/main/java/de/ids_mannheim/korap/rewrite/FoundryInject.java
@@ -1,4 +1,4 @@
-package de.ids_mannheim.korap.resource.rewrite;
+package de.ids_mannheim.korap.rewrite;
import java.util.Collection;
@@ -8,8 +8,7 @@
import de.ids_mannheim.korap.config.ContextHolder;
import de.ids_mannheim.korap.config.KustvaktConfiguration;
import de.ids_mannheim.korap.exceptions.KustvaktException;
-import de.ids_mannheim.korap.resource.LayerMapper;
-import de.ids_mannheim.korap.resource.rewrite.KoralNode.RewriteIdentifier;
+import de.ids_mannheim.korap.rewrite.KoralNode.RewriteIdentifier;
import de.ids_mannheim.korap.user.User;
import edu.emory.mathcs.backport.java.util.Collections;
diff --git a/core/src/main/java/de/ids_mannheim/korap/resource/rewrite/IdWriter.java b/core/src/main/java/de/ids_mannheim/korap/rewrite/IdWriter.java
similarity index 95%
rename from core/src/main/java/de/ids_mannheim/korap/resource/rewrite/IdWriter.java
rename to core/src/main/java/de/ids_mannheim/korap/rewrite/IdWriter.java
index 4dc91b9..1f0dad6 100644
--- a/core/src/main/java/de/ids_mannheim/korap/resource/rewrite/IdWriter.java
+++ b/core/src/main/java/de/ids_mannheim/korap/rewrite/IdWriter.java
@@ -1,4 +1,4 @@
-package de.ids_mannheim.korap.resource.rewrite;
+package de.ids_mannheim.korap.rewrite;
import com.fasterxml.jackson.databind.JsonNode;
import de.ids_mannheim.korap.config.BeanInjectable;
diff --git a/core/src/main/java/de/ids_mannheim/korap/resource/rewrite/KoralNode.java b/core/src/main/java/de/ids_mannheim/korap/rewrite/KoralNode.java
similarity index 99%
rename from core/src/main/java/de/ids_mannheim/korap/resource/rewrite/KoralNode.java
rename to core/src/main/java/de/ids_mannheim/korap/rewrite/KoralNode.java
index 0bf497f..a8870b7 100644
--- a/core/src/main/java/de/ids_mannheim/korap/resource/rewrite/KoralNode.java
+++ b/core/src/main/java/de/ids_mannheim/korap/rewrite/KoralNode.java
@@ -1,4 +1,4 @@
-package de.ids_mannheim.korap.resource.rewrite;
+package de.ids_mannheim.korap.rewrite;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.node.ArrayNode;
diff --git a/core/src/main/java/de/ids_mannheim/korap/resource/LayerMapper.java b/core/src/main/java/de/ids_mannheim/korap/rewrite/LayerMapper.java
similarity index 98%
rename from core/src/main/java/de/ids_mannheim/korap/resource/LayerMapper.java
rename to core/src/main/java/de/ids_mannheim/korap/rewrite/LayerMapper.java
index fa6459b..672f7e7 100644
--- a/core/src/main/java/de/ids_mannheim/korap/resource/LayerMapper.java
+++ b/core/src/main/java/de/ids_mannheim/korap/rewrite/LayerMapper.java
@@ -1,4 +1,4 @@
-package de.ids_mannheim.korap.resource;
+package de.ids_mannheim.korap.rewrite;
import de.ids_mannheim.korap.config.KustvaktConfiguration;
import de.ids_mannheim.korap.config.Attributes;
diff --git a/core/src/main/java/de/ids_mannheim/korap/resource/rewrite/MetaConstraint.java b/core/src/main/java/de/ids_mannheim/korap/rewrite/MetaConstraint.java
similarity index 94%
rename from core/src/main/java/de/ids_mannheim/korap/resource/rewrite/MetaConstraint.java
rename to core/src/main/java/de/ids_mannheim/korap/rewrite/MetaConstraint.java
index f0e90e3..a9380b9 100644
--- a/core/src/main/java/de/ids_mannheim/korap/resource/rewrite/MetaConstraint.java
+++ b/core/src/main/java/de/ids_mannheim/korap/rewrite/MetaConstraint.java
@@ -1,4 +1,4 @@
-package de.ids_mannheim.korap.resource.rewrite;
+package de.ids_mannheim.korap.rewrite;
import com.fasterxml.jackson.databind.JsonNode;
import de.ids_mannheim.korap.config.BeanInjectable;
diff --git a/core/src/main/java/de/ids_mannheim/korap/resource/rewrite/RewriteHandler.java b/core/src/main/java/de/ids_mannheim/korap/rewrite/RewriteHandler.java
similarity index 99%
rename from core/src/main/java/de/ids_mannheim/korap/resource/rewrite/RewriteHandler.java
rename to core/src/main/java/de/ids_mannheim/korap/rewrite/RewriteHandler.java
index 6469d57..ddd7538 100644
--- a/core/src/main/java/de/ids_mannheim/korap/resource/rewrite/RewriteHandler.java
+++ b/core/src/main/java/de/ids_mannheim/korap/rewrite/RewriteHandler.java
@@ -1,4 +1,4 @@
-package de.ids_mannheim.korap.resource.rewrite;
+package de.ids_mannheim.korap.rewrite;
import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
diff --git a/core/src/main/java/de/ids_mannheim/korap/resource/rewrite/RewriteTask.java b/core/src/main/java/de/ids_mannheim/korap/rewrite/RewriteTask.java
similarity index 97%
rename from core/src/main/java/de/ids_mannheim/korap/resource/rewrite/RewriteTask.java
rename to core/src/main/java/de/ids_mannheim/korap/rewrite/RewriteTask.java
index deb4cd7..79065a5 100644
--- a/core/src/main/java/de/ids_mannheim/korap/resource/rewrite/RewriteTask.java
+++ b/core/src/main/java/de/ids_mannheim/korap/rewrite/RewriteTask.java
@@ -1,4 +1,4 @@
-package de.ids_mannheim.korap.resource.rewrite;
+package de.ids_mannheim.korap.rewrite;
import com.fasterxml.jackson.databind.JsonNode;
import de.ids_mannheim.korap.config.KustvaktConfiguration;
diff --git a/core/src/main/java/de/ids_mannheim/korap/resource/rewrite/TreeConstraint.java b/core/src/main/java/de/ids_mannheim/korap/rewrite/TreeConstraint.java
similarity index 97%
rename from core/src/main/java/de/ids_mannheim/korap/resource/rewrite/TreeConstraint.java
rename to core/src/main/java/de/ids_mannheim/korap/rewrite/TreeConstraint.java
index 5235359..1315c7a 100644
--- a/core/src/main/java/de/ids_mannheim/korap/resource/rewrite/TreeConstraint.java
+++ b/core/src/main/java/de/ids_mannheim/korap/rewrite/TreeConstraint.java
@@ -1,4 +1,4 @@
-package de.ids_mannheim.korap.resource.rewrite;
+package de.ids_mannheim.korap.rewrite;
import com.fasterxml.jackson.databind.JsonNode;
import de.ids_mannheim.korap.config.BeanInjectable;
diff --git a/core/src/main/java/de/ids_mannheim/korap/service/SearchService.java b/core/src/main/java/de/ids_mannheim/korap/service/SearchService.java
index 1552bf3..10414bf 100644
--- a/core/src/main/java/de/ids_mannheim/korap/service/SearchService.java
+++ b/core/src/main/java/de/ids_mannheim/korap/service/SearchService.java
@@ -23,7 +23,7 @@
import de.ids_mannheim.korap.exceptions.StatusCodes;
import de.ids_mannheim.korap.query.serialize.MetaQueryBuilder;
import de.ids_mannheim.korap.query.serialize.QuerySerializer;
-import de.ids_mannheim.korap.resource.rewrite.RewriteHandler;
+import de.ids_mannheim.korap.rewrite.RewriteHandler;
import de.ids_mannheim.korap.user.User;
import de.ids_mannheim.korap.user.User.CorpusAccess;
import de.ids_mannheim.korap.web.ClientsHandler;
diff --git a/core/src/main/java/de/ids_mannheim/korap/web/controller/AnnotationController.java b/core/src/main/java/de/ids_mannheim/korap/web/controller/AnnotationController.java
index 06b9957..63e19de 100644
--- a/core/src/main/java/de/ids_mannheim/korap/web/controller/AnnotationController.java
+++ b/core/src/main/java/de/ids_mannheim/korap/web/controller/AnnotationController.java
@@ -23,7 +23,7 @@
import de.ids_mannheim.korap.service.AnnotationService;
import de.ids_mannheim.korap.utils.JsonUtils;
import de.ids_mannheim.korap.web.KustvaktResponseHandler;
-import de.ids_mannheim.korap.web.APIVersionFilter;
+import de.ids_mannheim.korap.web.filter.APIVersionFilter;
import de.ids_mannheim.korap.web.filter.DemoUserFilter;
import de.ids_mannheim.korap.web.filter.PiwikFilter;
diff --git a/core/src/main/java/de/ids_mannheim/korap/web/controller/SearchController.java b/core/src/main/java/de/ids_mannheim/korap/web/controller/SearchController.java
index d83ce1f..0cd61a3 100644
--- a/core/src/main/java/de/ids_mannheim/korap/web/controller/SearchController.java
+++ b/core/src/main/java/de/ids_mannheim/korap/web/controller/SearchController.java
@@ -29,8 +29,8 @@
import de.ids_mannheim.korap.oauth2.service.OAuth2ScopeService;
import de.ids_mannheim.korap.security.context.TokenContext;
import de.ids_mannheim.korap.service.SearchService;
-import de.ids_mannheim.korap.web.APIVersionFilter;
import de.ids_mannheim.korap.web.KustvaktResponseHandler;
+import de.ids_mannheim.korap.web.filter.APIVersionFilter;
import de.ids_mannheim.korap.web.filter.AuthenticationFilter;
import de.ids_mannheim.korap.web.filter.DemoUserFilter;
import de.ids_mannheim.korap.web.filter.PiwikFilter;
diff --git a/core/src/main/java/de/ids_mannheim/korap/web/controller/StatisticController.java b/core/src/main/java/de/ids_mannheim/korap/web/controller/StatisticController.java
index 61bf57a..ff21813 100644
--- a/core/src/main/java/de/ids_mannheim/korap/web/controller/StatisticController.java
+++ b/core/src/main/java/de/ids_mannheim/korap/web/controller/StatisticController.java
@@ -23,7 +23,7 @@
import de.ids_mannheim.korap.utils.KoralCollectionQueryBuilder;
import de.ids_mannheim.korap.web.CoreResponseHandler;
import de.ids_mannheim.korap.web.SearchKrill;
-import de.ids_mannheim.korap.web.APIVersionFilter;
+import de.ids_mannheim.korap.web.filter.APIVersionFilter;
import de.ids_mannheim.korap.web.filter.PiwikFilter;
/**
diff --git a/core/src/main/java/de/ids_mannheim/korap/web/APIVersionFilter.java b/core/src/main/java/de/ids_mannheim/korap/web/filter/APIVersionFilter.java
similarity index 97%
rename from core/src/main/java/de/ids_mannheim/korap/web/APIVersionFilter.java
rename to core/src/main/java/de/ids_mannheim/korap/web/filter/APIVersionFilter.java
index 0a36153..db9536d 100644
--- a/core/src/main/java/de/ids_mannheim/korap/web/APIVersionFilter.java
+++ b/core/src/main/java/de/ids_mannheim/korap/web/filter/APIVersionFilter.java
@@ -1,4 +1,4 @@
-package de.ids_mannheim.korap.web;
+package de.ids_mannheim.korap.web.filter;
import java.util.List;
diff --git a/core/src/main/java/de/ids_mannheim/korap/web/filter/AuthenticationFilter.java b/core/src/main/java/de/ids_mannheim/korap/web/filter/AuthenticationFilter.java
index d0e4562..1f54669 100644
--- a/core/src/main/java/de/ids_mannheim/korap/web/filter/AuthenticationFilter.java
+++ b/core/src/main/java/de/ids_mannheim/korap/web/filter/AuthenticationFilter.java
@@ -21,7 +21,11 @@
import de.ids_mannheim.korap.utils.TimeUtils;
import de.ids_mannheim.korap.web.KustvaktResponseHandler;
-/**
+/** Authentication filter extracts an authentication token from
+ * authorization header and uses an authentication provider
+ * with respect to the token type to create a token context as
+ * a security context.
+ *
* @author hanl, margaretha
* @date 28/01/2014
* @last update 12/2017
diff --git a/core/src/main/java/de/ids_mannheim/korap/web/utils/JsonExceptionMapper.java b/core/src/main/java/de/ids_mannheim/korap/web/utils/JsonExceptionMapper.java
index 1136dd1..126f34d 100644
--- a/core/src/main/java/de/ids_mannheim/korap/web/utils/JsonExceptionMapper.java
+++ b/core/src/main/java/de/ids_mannheim/korap/web/utils/JsonExceptionMapper.java
@@ -10,12 +10,20 @@
import de.ids_mannheim.korap.exceptions.StatusCodes;
import de.ids_mannheim.korap.web.CoreResponseHandler;
-@Priority(value=1)
+/**
+ * Creates appropriate responses in case of incorrect JSON
+ * deserialization or JsonMappingException, for instance when a
+ * request parameter should be deserialized as an ENUM but the
+ * parameter value does not match any of the available ENUM values.
+ *
+ * @author margaretha
+ *
+ */
+@Priority(value = 1)
@Provider
public class JsonExceptionMapper
implements ExceptionMapper<JsonMappingException> {
-
@Override
public Response toResponse (JsonMappingException exception) {
String entity = CoreResponseHandler.buildNotification(
diff --git a/core/src/main/java/de/ids_mannheim/korap/web/utils/NotFoundMapper.java b/core/src/main/java/de/ids_mannheim/korap/web/utils/NotFoundMapper.java
index e8db76d..d2536f6 100644
--- a/core/src/main/java/de/ids_mannheim/korap/web/utils/NotFoundMapper.java
+++ b/core/src/main/java/de/ids_mannheim/korap/web/utils/NotFoundMapper.java
@@ -19,12 +19,18 @@
import de.ids_mannheim.korap.config.KustvaktConfiguration;
+/**
+ * Handles not found API version by redirecting the request URI to a
+ * similar URI with current API version.
+ *
+ * @author margaretha
+ *
+ */
@Component
@Provider
public class NotFoundMapper implements ExceptionMapper<NotFoundException> {
- private static Logger jlog =
- LogManager.getLogger(NotFoundMapper.class);
+ private static Logger jlog = LogManager.getLogger(NotFoundMapper.class);
public static final Pattern VERSION_PATTERN =
Pattern.compile("/(v[0-9][^/]*)(/.*)");
private static final boolean DEBUG = false;
@@ -47,19 +53,19 @@
path = baseUrl + "/" + config.getCurrentVersion() + path;
URI redirectUri = UriBuilder.fromUri(notFoundUri)
.replacePath(path).build();
- if (DEBUG){
- jlog.debug("REDIRECT: "+redirectUri.toString());
+ if (DEBUG) {
+ jlog.debug("REDIRECT: " + redirectUri.toString());
}
return Response.status(HttpStatus.PERMANENT_REDIRECT_308)
.location(redirectUri).build();
}
- else if (!matcher.group(1).equals(config.getCurrentVersion())){
+ else if (!matcher.group(1).equals(config.getCurrentVersion())) {
path = baseUrl + "/" + config.getCurrentVersion()
+ matcher.group(2);
URI redirectUri = UriBuilder.fromUri(notFoundUri)
.replacePath(path).build();
- if (DEBUG){
- jlog.debug("REDIRECT replace: "+ redirectUri.toString());
+ if (DEBUG) {
+ jlog.debug("REDIRECT replace: " + redirectUri.toString());
}
return Response.status(HttpStatus.PERMANENT_REDIRECT_308)
.location(redirectUri).build();