Added re-caching VC at closing-index service, resolved #44
Change-Id: I72bc0980da63f64f50b9bf92787550a9401fd1c3
diff --git a/full/src/main/java/de/ids_mannheim/de/init/VCLoaderImpl.java b/full/src/main/java/de/ids_mannheim/de/init/VCLoaderImpl.java
new file mode 100644
index 0000000..113a6cc
--- /dev/null
+++ b/full/src/main/java/de/ids_mannheim/de/init/VCLoaderImpl.java
@@ -0,0 +1,19 @@
+package de.ids_mannheim.de.init;
+
+import org.springframework.beans.factory.annotation.Autowired;
+
+import de.ids_mannheim.korap.KrillCollection;
+import de.ids_mannheim.korap.config.NamedVCLoader;
+
+public class VCLoaderImpl implements VCLoader{
+
+ @Autowired
+ private NamedVCLoader vcLoader;
+
+ @Override
+ public void recachePredefinedVC () {
+ KrillCollection.cache.removeAll();
+ Thread t = new Thread(vcLoader);
+ t.start();
+ }
+}
diff --git a/full/src/main/java/de/ids_mannheim/korap/config/NamedVCLoader.java b/full/src/main/java/de/ids_mannheim/korap/config/NamedVCLoader.java
index de7ac08..014a057 100644
--- a/full/src/main/java/de/ids_mannheim/korap/config/NamedVCLoader.java
+++ b/full/src/main/java/de/ids_mannheim/korap/config/NamedVCLoader.java
@@ -98,6 +98,7 @@
}
catch (KustvaktException e) {
// ignore
+ if (DEBUG) jlog.debug(e);
}
vcService.storeVC(filename, VirtualCorpusType.SYSTEM, json,
null, null, null, true, "system");
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 187b738..6b530bc 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
@@ -15,6 +15,7 @@
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.JsonNode;
+import de.ids_mannheim.korap.KrillCollection;
import de.ids_mannheim.korap.config.FullConfiguration;
import de.ids_mannheim.korap.constant.GroupMemberStatus;
import de.ids_mannheim.korap.constant.VirtualCorpusAccessStatus;
@@ -213,6 +214,9 @@
userGroupService.deleteAutoHiddenGroup(
access.getUserGroup().getId(), "system");
}
+ if (KrillCollection.cache.get(vc.getName())!=null){
+ KrillCollection.cache.remove(vc.getName());
+ }
vcDao.deleteVirtualCorpus(vc);
}
else {
diff --git a/full/src/main/java/de/ids_mannheim/korap/web/controller/AuthenticationController.java b/full/src/main/java/de/ids_mannheim/korap/web/controller/AuthenticationController.java
index b3594fd..bca7dc2 100644
--- a/full/src/main/java/de/ids_mannheim/korap/web/controller/AuthenticationController.java
+++ b/full/src/main/java/de/ids_mannheim/korap/web/controller/AuthenticationController.java
@@ -58,15 +58,16 @@
* @date 24/01/2014
*
* @author margaretha
- * @last-update 28/08/2018
+ * @last-update 01/07/2019
*
* - added user authentication time in token context
* - added api version filter
+ * - changed the response media-type
*/
@Controller
@Path("/{version}/auth")
@ResourceFilters({APIVersionFilter.class, PiwikFilter.class })
-@Produces(MediaType.TEXT_HTML + ";charset=utf-8")
+@Produces(MediaType.APPLICATION_JSON + ";charset=utf-8")
public class AuthenticationController {
@Autowired
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 60beaea..87a98c8 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
@@ -33,6 +33,7 @@
import de.ids_mannheim.korap.web.filter.APIVersionFilter;
import de.ids_mannheim.korap.web.filter.AuthenticationFilter;
import de.ids_mannheim.korap.web.filter.BlockingFilter;
+import de.ids_mannheim.korap.web.filter.DemoUserFilter;
import de.ids_mannheim.korap.web.filter.PiwikFilter;
import de.ids_mannheim.korap.web.input.VirtualCorpusJson;
@@ -115,6 +116,8 @@
@GET
@Path("{createdBy}/{vcName}")
@Produces(MediaType.APPLICATION_JSON + ";charset=utf-8")
+ @ResourceFilters({ APIVersionFilter.class, AuthenticationFilter.class,
+ DemoUserFilter.class, PiwikFilter.class })
public VirtualCorpusDto retrieveVCByName (
@Context SecurityContext securityContext,
@PathParam("createdBy") String createdBy,
diff --git a/full/src/main/resources/default-config.xml b/full/src/main/resources/default-config.xml
index a3de4ac..bd25718 100644
--- a/full/src/main/resources/default-config.xml
+++ b/full/src/main/resources/default-config.xml
@@ -193,7 +193,9 @@
<bean id="initializator" class="de.ids_mannheim.de.init.InitializatorImpl"
init-method="initAnnotation">
</bean>
-
+
+ <bean id="vcLoader" class="de.ids_mannheim.de.init.VCLoaderImpl"/>
+
<!-- Krill -->
<bean id="search_krill" class="de.ids_mannheim.korap.web.SearchKrill">
<constructor-arg value="${krill.indexDir}" />