Added storing authorization code and access token in cache; fixed bugs.
Change-Id: Ibc555ed65ebec8e7b40a76521311680a63c11a09
diff --git a/core/Changes b/core/Changes
index 409fd0d..c89564b 100644
--- a/core/Changes
+++ b/core/Changes
@@ -2,6 +2,7 @@
09/07/2018
- Fixed status codes (margaretha)
- Added KustvaktException for wrapping another exception (margaretha)
+ - Removed deprecated codes regarding KustvaktResource (margaretha)
version 0.60.4
25/06/2018
diff --git a/core/src/main/java/de/ids_mannheim/korap/config/KustvaktCacheable.java b/core/src/main/java/de/ids_mannheim/korap/config/KustvaktCacheable.java
index b58e66e..e905192 100644
--- a/core/src/main/java/de/ids_mannheim/korap/config/KustvaktCacheable.java
+++ b/core/src/main/java/de/ids_mannheim/korap/config/KustvaktCacheable.java
@@ -39,8 +39,8 @@
new CacheConfiguration(name, 20000)
.memoryStoreEvictionPolicy(MemoryStoreEvictionPolicy.LFU)
.eternal(false)
- .timeToLiveSeconds(20000)
- .timeToIdleSeconds(15000)
+ .timeToLiveSeconds(15000)
+ .timeToIdleSeconds(5000)
.diskExpiryThreadIntervalSeconds(0)
.persistence(new PersistenceConfiguration().strategy(PersistenceConfiguration.Strategy.LOCALTEMPSWAP)));
if (!CacheManager.getInstance().cacheExists(name))
diff --git a/core/src/main/java/de/ids_mannheim/korap/resources/Corpus.java b/core/src/main/java/de/ids_mannheim/korap/resources/Corpus.java
deleted file mode 100644
index 914fa1e..0000000
--- a/core/src/main/java/de/ids_mannheim/korap/resources/Corpus.java
+++ /dev/null
@@ -1,44 +0,0 @@
-package de.ids_mannheim.korap.resources;
-
-import lombok.Getter;
-import lombok.Setter;
-
-import java.util.Map;
-
-/**
- * User: hanl
- * Date: 11/8/13
- * Time: 5:15 PM
- */
-@Getter
-@Setter
-public class Corpus extends KustvaktResource {
-
- // todo: can be deprecated since resource offers data field here!
- @Deprecated
- private Map stats;
-
-
- public Corpus () {
- super();
- }
-
-
- public Corpus (String pers) {
- super(pers);
- }
-
-
- public Corpus (Integer id) {
- super(id);
- }
-
-
- @Override
- public Map toMap () {
- Map res = super.toMap();
- if (stats != null && !stats.isEmpty())
- res.put("statistics", stats);
- return res;
- }
-}
diff --git a/core/src/main/java/de/ids_mannheim/korap/resources/Foundry.java b/core/src/main/java/de/ids_mannheim/korap/resources/Foundry.java
deleted file mode 100644
index e2cba4d..0000000
--- a/core/src/main/java/de/ids_mannheim/korap/resources/Foundry.java
+++ /dev/null
@@ -1,23 +0,0 @@
-package de.ids_mannheim.korap.resources;
-
-/**
- * @author hanl
- * @date 25/06/2014
- */
-public class Foundry extends KustvaktResource {
-
- public Foundry () {
- super();
- }
-
-
- public Foundry (Integer id) {
- super(id);
- }
-
-
- public Foundry (String persistentID) {
- super(persistentID);
- }
-
-}
diff --git a/core/src/main/java/de/ids_mannheim/korap/resources/KustvaktResource.java b/core/src/main/java/de/ids_mannheim/korap/resources/KustvaktResource.java
index 6412835..90e294d 100644
--- a/core/src/main/java/de/ids_mannheim/korap/resources/KustvaktResource.java
+++ b/core/src/main/java/de/ids_mannheim/korap/resources/KustvaktResource.java
@@ -1,5 +1,10 @@
package de.ids_mannheim.korap.resources;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.joda.time.DateTime;
+
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.databind.JsonNode;
@@ -9,11 +14,6 @@
import lombok.AccessLevel;
import lombok.Getter;
import lombok.Setter;
-import org.joda.time.DateTime;
-
-import java.io.IOException;
-import java.util.HashMap;
-import java.util.Map;
/**
* Created by hanl on 5/21/14.
diff --git a/core/src/main/java/de/ids_mannheim/korap/resources/Layer.java b/core/src/main/java/de/ids_mannheim/korap/resources/Layer.java
deleted file mode 100644
index d8a2e09..0000000
--- a/core/src/main/java/de/ids_mannheim/korap/resources/Layer.java
+++ /dev/null
@@ -1,37 +0,0 @@
-package de.ids_mannheim.korap.resources;
-
-/**
- * @author hanl
- * @date 25/06/2014
- */
-public class Layer extends KustvaktResource {
-
- public Layer () {
- super();
- }
-
-
- public Layer (Integer id, int creator) {
- super(id);
- }
-
-
- // layer name must not be unique!
- public Layer (Integer id, String name) {
- super(id);
- this.setName(name);
- }
-
-
- public Layer (String persistentID, String name) {
- super(persistentID);
- this.setPersistentID(persistentID);
- this.setName(name);
- }
-
-
- public Layer (String persistentID) {
- super(persistentID);
- }
-
-}
diff --git a/core/src/main/java/de/ids_mannheim/korap/resources/Permissions.java b/core/src/main/java/de/ids_mannheim/korap/resources/Permissions.java
deleted file mode 100644
index e64af5c..0000000
--- a/core/src/main/java/de/ids_mannheim/korap/resources/Permissions.java
+++ /dev/null
@@ -1,50 +0,0 @@
-package de.ids_mannheim.korap.resources;
-
-/**
- * @author hanl
- * @date 21/01/2014
- */
-public class Permissions {
-
- public enum Permission {
-
- //fixme: add read_policy permission to allow read policy permissions
- READ(Permissions.READ), WRITE(Permissions.WRITE), DELETE(
- Permissions.DELETE),
-
- READ_POLICY(Permissions.READ_POLICY), CREATE_POLICY(
- Permissions.CREATE_POLICY), MODIFY_POLICY(
- Permissions.MODIFY_POLICY), DELETE_POLICY(
- Permissions.DELETE_POLICY), ALL(Permissions.ALL);
-
- private final byte b;
-
-
- Permission (byte b) {
- this.b = b;
- }
-
-
- public byte toByte () {
- return this.b;
- }
- }
-
-
- public static Permission[] read(String ... strings) {
- Permission[] p = new Permission[strings.length];
- for (int i = 0; i<strings.length; i++)
- p[i] = Permission.valueOf(strings[i]);
- return p;
- }
-
- private static final byte READ = 1;
- private static final byte WRITE = 2;
- private static final byte DELETE = 4;
- private static final byte READ_POLICY = 8;
- private static final byte CREATE_POLICY = 16;
- private static final byte MODIFY_POLICY = 32;
- private static final byte DELETE_POLICY = 64;
- private static final byte ALL = 127;
-
-}
\ No newline at end of file
diff --git a/core/src/main/java/de/ids_mannheim/korap/resources/Relation.java b/core/src/main/java/de/ids_mannheim/korap/resources/Relation.java
deleted file mode 100644
index 1d2c7a8..0000000
--- a/core/src/main/java/de/ids_mannheim/korap/resources/Relation.java
+++ /dev/null
@@ -1,9 +0,0 @@
-package de.ids_mannheim.korap.resources;
-
-/**
- * @author hanl
- * @date 29/04/2014
- */
-public enum Relation {
- OR, AND
-}
diff --git a/core/src/main/java/de/ids_mannheim/korap/resources/ResourceFactory.java b/core/src/main/java/de/ids_mannheim/korap/resources/ResourceFactory.java
deleted file mode 100644
index 7d2b770..0000000
--- a/core/src/main/java/de/ids_mannheim/korap/resources/ResourceFactory.java
+++ /dev/null
@@ -1,160 +0,0 @@
-package de.ids_mannheim.korap.resources;
-
-import de.ids_mannheim.korap.exceptions.KustvaktException;
-import de.ids_mannheim.korap.exceptions.StatusCodes;
-import de.ids_mannheim.korap.utils.JsonUtils;
-
-import org.apache.commons.codec.digest.DigestUtils;
-
-import java.util.ArrayList;
-import java.util.List;
-
-@SuppressWarnings("all")
-public class ResourceFactory {
-
- public static final List<Class<? extends KustvaktResource>> subTypes = new ArrayList<>();
- public static final int CORPUS = 0;
- public static final int FOUNDRY = 1;
- public static final int LAYER = 2;
- public static final int VIRTUALCOLLECTION = 3;
- public static final int USERQUERY = 4;
-
- static {
- subTypes.add(CORPUS, Corpus.class);
- subTypes.add(FOUNDRY, Foundry.class);
- subTypes.add(LAYER, Layer.class);
- subTypes.add(VIRTUALCOLLECTION, VirtualCollection.class);
- // subTypes.add(USERQUERY, UserQuery.class);
- }
-
-
- public static KustvaktResource getResource (
- Class<? extends KustvaktResource> clazz) {
- try {
- return (KustvaktResource) clazz.newInstance();
- }
- catch (InstantiationException | IllegalAccessException e) {
- // do nothing
- }
- return null;
- }
-
-
- public static int getResourceMapping (Class<? extends KustvaktResource> r) {
- int value = -1;
- if (r != null) {
- for (int i = 0; i < subTypes.size(); i++) {
- if (subTypes.get(i).getName().equals(r.getName()))
- value = i;
- }
- }
- return value;
- }
-
-
- public static KustvaktResource getResource (String type) throws KustvaktException {
- return getResource(getResourceClass(type));
- }
-
-
- public static KustvaktResource getResource (int j) {
- Class s = subTypes.get(j);
- if (s != null) {
- return getResource(s);
- }
- return null;
- }
-
-
- public static <T extends KustvaktResource> T createID (T resource) throws KustvaktException {
- if (resource.getData() != null && !resource.getStringData().isEmpty()){
- resource.setPersistentID(DigestUtils.sha1Hex(JsonUtils.toJSON(resource)));
- }
- return resource;
- }
-
-
- public static <T extends KustvaktResource> Class<T> getResourceClass (
- String type) throws KustvaktException {
-
- if (type == null || type.isEmpty()){
- throw new KustvaktException(StatusCodes.ILLEGAL_ARGUMENT,
- "resource type could not be identified!");
- }
-
- for (Class value : subTypes) {
- if (value == VirtualCollection.class
- && type.equalsIgnoreCase("collection"))
- return (Class<T>) VirtualCollection.class;
- //todo
- // else if (value == UserQuery.class && type.equalsIgnoreCase("query"))
- // return (Class<T>) UserQuery.class;
- else if (value.getSimpleName().equalsIgnoreCase(type.trim())) {
- return value;
- }
- }
- // todo: throw exception in case of missing parameter!
- throw new KustvaktException(StatusCodes.ILLEGAL_ARGUMENT,
- "resource type could not be identified!");
- }
-
-
- // all deprecated!
-
- public static VirtualCollection getCachedCollection (String query) {
- VirtualCollection v = new VirtualCollection(query);
- v.setName("");
- v.setDescription("");
- return v;
- }
-
-
- public static VirtualCollection getPermanentCollection (
- VirtualCollection mergable, String corpusName, String description) throws KustvaktException {
- VirtualCollection v = new VirtualCollection();
- v.merge(mergable);
- v.setName(corpusName);
- v.setDescription(description);
- return createID(v);
- }
-
-
- // public static VirtualCollection createCollection(String name, String query,
- // Integer owner) {
- // VirtualCollection v = new VirtualCollection(query);
- // v.setName(name);
- // v.setOwner(owner);
- // return v;
- // }
- //
- // public static VirtualCollection createCollection(String name,
- // Integer owner) {
- // VirtualCollection v = new VirtualCollection();
- // v.setOwner(owner);
- // v.setName(name);
- // return v;
- // }
- //
- // public static VirtualCollection getCollection(Integer collectionID,
- // boolean cache) {
- // VirtualCollection v = new VirtualCollection();
- // v.setId(collectionID);
- // v.setDescription("");
- // v.setName("");
- // return v;
- // }
- //
- // public static VirtualCollection createContainer(String name,
- // String description, String query, Integer owner) {
- // VirtualCollection v = new VirtualCollection(query);
- // v.setName(name);
- // v.setDescription(description);
- // v.setOwner(owner);
- // v.setManaged(true);
- // return v;
- // }
-
- public static VirtualCollection getIDContainer (Integer id) {
- return new VirtualCollection(id);
- }
-}
diff --git a/core/src/main/java/de/ids_mannheim/korap/resources/VirtualCollection.java b/core/src/main/java/de/ids_mannheim/korap/resources/VirtualCollection.java
deleted file mode 100644
index bda1eea..0000000
--- a/core/src/main/java/de/ids_mannheim/korap/resources/VirtualCollection.java
+++ /dev/null
@@ -1,74 +0,0 @@
-package de.ids_mannheim.korap.resources;
-
-import lombok.Getter;
-import lombok.Setter;
-
-import java.util.Map;
-
-@Getter
-@Setter
-public class VirtualCollection extends KustvaktResource {
-
- // private String query;
- // use ehcache instead and only save persisted values in the database
- // @Deprecated
- // private boolean cache = false;
- @Deprecated
- private Map stats;
-
-
- public VirtualCollection () {
- super();
- }
-
-
- public VirtualCollection (Integer id) {
- super(id);
- }
-
-
- public VirtualCollection (String persistentID) {
- super(persistentID);
- }
-
-
- @Override
- public void merge (KustvaktResource resource) {
- super.merge(resource);
- if (resource == null | !(resource instanceof VirtualCollection))
- return;
- VirtualCollection other = (VirtualCollection) resource;
- if (this.getFields() == null || this.getFields().isEmpty()){
- setFields(other.getFields());
- }
- }
-
-
- @Override
- @SuppressWarnings("unchecked")
- public void checkNull () {
- this.setDescription(this.getDescription() == null ? "" : this
- .getDescription());
- super.checkNull();
- }
-
-
- @Override
- public String toString () {
- return "VirtualCollection{" + "id='" + this.getId() + '\''
- + ", persistentID='" + this.getPersistentID() + '\''
- + ", created=" + created + ", path=" + this.getPath()
- + ", name='" + this.getName() + '\'' + ", data='"
- + this.getData() + '\'' + '}';
- }
-
- // @Override
- // public Map toMap() {
- // Map res = super.toMap();
- // res.put("query", JsonUtils.readTree());
- // if (stats != null && !stats.isEmpty())
- // res.put("statistics", stats);
- // return res;
- // }
-
-}