Commit 9565156b authored by Gradl, Tobias's avatar Gradl, Tobias
Browse files

410: Convert to Spring Boot library and application (OPENED)

Task-Url: #410
parent 17fde40e
Pipeline #22556 passed with stage
in 49 seconds
plugins {
//id 'io.spring.dependency-management' version "1.0.10.RELEASE"
//id 'org.springframework.boot' version "2.3.5.RELEASE" apply false
id "nebula.ospackage" version "8.4.1" apply false
id 'io.spring.dependency-management' version "1.0.10.RELEASE"
id 'org.springframework.boot' version "2.3.5.RELEASE" apply false
id "nebula.ospackage" version "8.4.1" apply false
}
allprojects {
apply plugin: 'eclipse'
......@@ -12,39 +13,29 @@ allprojects {
repositories {
mavenLocal()
maven {
maven {
url = 'https://minfba.de.dariah.eu/nexus/repository/minfba-central/'
}
}
ext {
coreVersion = "5.4.1-SNAPSHOT"
gtfVersion = "1.6.2-SNAPSHOT"
processingVersion = "4.0.2-SNAPSHOT"
colregModelVersion = "3.15.0-RELEASE"
dariahSpVersion = "1.4.0-SNAPSHOT"
springVersion = "4.3.6.RELEASE"
jacksonVersion = "2.9.6"
slf4jVersion = "1.7.22"
commonsLangVersion = "3.3.2"
httpComponentsVersion = "4.5.5"
elasticsearchVersion = "7.3.0"
logbackVersion = "1.1.3"
lombokVersion = "1.18.12"
coreVersion = "6.1-SNAPSHOT"
gtfVersion = "2.0.0-SNAPSHOT"
processingVersion = "4.1.0-SNAPSHOT"
colregModelVersion = "4.2-SNAPSHOT"
dariahSpVersion = "2.1.4-SNAPSHOT"
mavenRepo = 'https://minfba.de.dariah.eu/nexus/repository/minfba-central/'
releasesRepo = "https://minfba.de.dariah.eu/nexus/repository/minfba-releases/"
snapshotsRepo = "https://minfba.de.dariah.eu/nexus/repository/minfba-snapshots/"
aptReleasesRepo = 'https://minfba.de.dariah.eu/nexus/repository/minfba-apt-releases/'
aptTestingRepo = 'https://minfba.de.dariah.eu/nexus/repository/minfba-apt-testing/'
yumRepo = 'https://minfba.de.dariah.eu/nexus/repository/minfba-yum/'
repoUser = project.hasProperty('nexususer') ? project.getProperty('nexususer') : '?';
repoPass = project.hasProperty('nexuspass') ? project.getProperty('nexuspass') : ''
mavenRepo = 'https://minfba.de.dariah.eu/nexus/repository/minfba-central/'
releasesRepo = "https://minfba.de.dariah.eu/nexus/repository/minfba-releases/"
snapshotsRepo = "https://minfba.de.dariah.eu/nexus/repository/minfba-snapshots/"
aptReleasesRepo = 'https://minfba.de.dariah.eu/nexus/repository/minfba-apt-releases/'
aptTestingRepo = 'https://minfba.de.dariah.eu/nexus/repository/minfba-apt-testing/'
yumRepo = 'https://minfba.de.dariah.eu/nexus/repository/minfba-yum/'
repoUser = project.hasProperty('nexususer') ? project.getProperty('nexususer') : '?';
repoPass = project.hasProperty('nexuspass') ? project.getProperty('nexuspass') : ''
// Filled dynamically by packaging tasks
debFile = ""
// Filled dynamically by packaging tasks
debFile = ""
rpmFile = ""
aptRepo = ""
}
......@@ -54,13 +45,36 @@ allprojects {
subprojects {
apply plugin: 'java'
apply plugin: 'maven-publish'
/*apply plugin: 'io.spring.dependency-management'
apply plugin: 'io.spring.dependency-management'
java {
sourceCompatibility = JavaVersion.VERSION_11
}
tasks.withType(JavaCompile) {
options.encoding = 'UTF-8'
}
task sourcesJar(type: Jar, dependsOn: classes) {
classifier = 'sources'
from sourceSets.main.allSource
}
dependencyManagement {
task javadocJar(type: Jar, dependsOn: javadoc) {
classifier = 'javadoc'
from javadoc.destinationDir
}
artifacts {
archives sourcesJar
archives javadocJar
}
dependencyManagement {
imports {
mavenBom(org.springframework.boot.gradle.plugin.SpringBootPlugin.BOM_COORDINATES)
}
}*/
}
publishing {
publications {
......@@ -111,27 +125,4 @@ subprojects {
}
}
}
java {
sourceCompatibility = JavaVersion.VERSION_1_8
}
tasks.withType(JavaCompile) {
options.encoding = 'UTF-8'
}
task sourcesJar(type: Jar, dependsOn: classes) {
classifier = 'sources'
from sourceSets.main.allSource
}
task javadocJar(type: Jar, dependsOn: javadoc) {
classifier = 'javadoc'
from javadoc.destinationDir
}
artifacts {
archives sourcesJar
archives javadocJar
}
}
......@@ -4,10 +4,65 @@ plugins {
description = "DARIAH-DE Generic Search - Core library"
// https://stackoverflow.com/a/53824670
configurations {
implementation {
exclude group: 'xml-apis', module: 'xml-apis'
exclude group: 'xml-apis', module: 'xml-apis-ext'
exclude group: 'xerces', module: 'xercesImpl'
}
}
/*configurations.all {
transitive = false
}*/
ext {
jsonAssertVersion = "1.5.0"
jodaTimeVersion = "2.10.10"
commonsTextVersion = "1.9"
commonsCompressVersion = "1.20"
commonsIoVersion = "2.8.0"
commonsCodecVersion = "1.15"
tikaVersion = "1.25"
mockitoVersion = "3.8.0"
}
dependencies {
implementation "de.unibamberg.minf.core:core-metamodel:$coreVersion"
implementation "de.unibamberg.minf.core:core-metamodel:$coreVersion"
implementation "de.unibamberg.minf.core:core-web:$coreVersion"
implementation "de.unibamberg.minf.core:core-util:$coreVersion"
implementation "eu.dariah.de:colreg-model:$colregModelVersion"
implementation "org.springframework:spring-core"
implementation "org.springframework:spring-context"
implementation "org.springframework:spring-beans"
implementation "org.springframework:spring-web"
implementation "org.springframework:spring-webmvc"
implementation "org.springframework.data:spring-data-commons"
implementation "org.springframework.data:spring-data-mongodb"
implementation "org.springframework.data:spring-data-elasticsearch"
implementation "org.mongodb:mongodb-driver-sync"
implementation "org.mongodb:bson"
api "com.fasterxml.jackson.core:jackson-core"
api "com.fasterxml.jackson.core:jackson-databind"
api "com.fasterxml.jackson.core:jackson-annotations"
implementation "org.apache.commons:commons-compress:$commonsCompressVersion"
implementation "org.apache.commons:commons-text:$commonsTextVersion"
implementation "commons-io:commons-io:$commonsIoVersion"
implementation "commons-codec:commons-codec:$commonsCodecVersion"
implementation "org.skyscreamer:jsonassert:$jsonAssertVersion"
implementation "org.hibernate.validator:hibernate-validator"
implementation "javax.validation:validation-api"
implementation "de.unibamberg.minf.gtf:gtf-base:$gtfVersion"
implementation "de.unibamberg.minf.gtf:gtf-core:$gtfVersion"
implementation "de.unibamberg.minf.gtf:gtf-extension-file:$gtfVersion"
......@@ -16,45 +71,72 @@ dependencies {
implementation "de.unibamberg.minf.gtf:gtf-extension-nlp:$gtfVersion"
implementation "de.unibamberg.minf.gtf:gtf-extension-vocabulary:$gtfVersion"
implementation "de.unibamberg.minf.gtf:gtf-extension-dai:$gtfVersion"
implementation "de.unibamberg.minf.processing:processing-core:$processingVersion"
implementation "de.unibamberg.minf.processing:processing-adapters:$processingVersion"
implementation "eu.dariah.de:colreg-model:$colregModelVersion"
implementation "de.unibamberg.minf.processing:processing-adapters:$processingVersion"
implementation "eu.dariah.de:dariahsp-core:$dariahSpVersion"
implementation "org.springframework:spring-context:$springVersion"
implementation "org.springframework:spring-beans:$springVersion"
implementation "org.springframework:spring-core:$springVersion"
implementation "org.apache.httpcomponents:httpclient:$httpComponentsVersion"
implementation "org.elasticsearch:elasticsearch:$elasticsearchVersion"
implementation "org.elasticsearch.client:elasticsearch-rest-high-level-client:$elasticsearchVersion"
implementation "org.springframework.data:spring-data-mongodb:1.10.0.RELEASE"
implementation "org.slf4j:slf4j-api:$slf4jVersion"
implementation "joda-time:joda-time:2.9.9"
implementation "joda-time:joda-time-jsptags:1.1.1"
implementation "commons-io:commons-io:2.5"
implementation "org.apache.commons:commons-compress:1.15"
implementation "com.fasterxml.jackson.core:jackson-core:$jacksonVersion"
implementation "com.fasterxml.jackson.core:jackson-databind:$jacksonVersion"
implementation "com.fasterxml.jackson.core:jackson-annotations:$jacksonVersion"
implementation "com.fasterxml.jackson.dataformat:jackson-dataformat-xml:$jacksonVersion"
implementation "com.fasterxml.jackson.datatype:jackson-datatype-joda:$jacksonVersion"
implementation "org.skyscreamer:jsonassert:1.4.0"
implementation "org.apache.tika:tika-core:1.22"
implementation "org.apache.tika:tika-parsers:1.22"
testImplementation "org.springframework:spring-test:$springVersion"
testImplementation "junit:junit:4.12"
testImplementation "org.mockito:mockito-all:1.10.19"
testImplementation "org.elasticsearch.plugin:transport-netty4-client:$elasticsearchVersion"
testImplementation "org.slf4j:jcl-over-slf4j:$slf4jVersion"
testImplementation "org.slf4j:log4j-over-slf4j:$slf4jVersion"
testImplementation "ch.qos.logback:logback-core:$logbackVersion"
testImplementation "ch.qos.logback:logback-classic:$logbackVersion"
compileOnly "javax.servlet:servlet-api:2.5"
compileOnly "org.projectlombok:lombok:$lombokVersion"
annotationProcessor "org.projectlombok:lombok:$lombokVersion"
testCompileOnly "org.projectlombok:lombok:$lombokVersion"
implementation "org.apache.httpcomponents:httpclient"
//implementation "org.elasticsearch:elasticsearch"
implementation "org.slf4j:slf4j-api"
implementation "joda-time:joda-time:$jodaTimeVersion"
//implementation "joda-time:joda-time-jsptags:1.1.1"
//implementation "commons-io:commons-io"
//implementation "org.apache.commons:commons-compress"
//implementation "com.fasterxml.jackson.dataformat:jackson-dataformat-xml"
//implementation "com.fasterxml.jackson.datatype:jackson-datatype-joda"
//implementation "org.skyscreamer:jsonassert:1.4.0"
implementation "org.apache.tika:tika-core:$tikaVersion"
implementation "org.apache.tika:tika-parsers:$tikaVersion"
implementation "org.elasticsearch:elasticsearch"
//testImplementation "org.springframework.boot:spring-boot-starter-test"
testImplementation "org.springframework:spring-test"
testImplementation "org.junit.jupiter:junit-jupiter-api"
testImplementation "org.junit.jupiter:junit-jupiter-engine"
testImplementation "org.mockito:mockito-core:$mockitoVersion"
testImplementation "org.mockito:mockito-junit-jupiter:$mockitoVersion"
//testImplementation "junit:junit:4.12"
//
//testImplementation "org.junit.jupiter:junit-jupiter-engine"
///testImplementation "org.junit.jupiter:junit-jupiter-api"
//testImplementation "org.junit.jupiter:junit-jupiter-params"
//testImplementation "org.slf4j:jcl-over-slf4j"
//testImplementation "org.slf4j:log4j-over-slf4j"
//testImplementation "ch.qos.logback:logback-core"
//testImplementation "ch.qos.logback:logback-classic"
compileOnly "javax.servlet:javax.servlet-api"
compileOnly "org.projectlombok:lombok"
annotationProcessor "org.projectlombok:lombok"
testCompileOnly "org.projectlombok:lombok"
}
jar {
enabled = true
}
publishing {
publications {
maven(MavenPublication) {
from(components.java)
artifact(sourcesJar) {}
artifact(javadocJar) {}
}
}
}
\ No newline at end of file
......@@ -13,7 +13,7 @@ import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid;
import org.apache.commons.lang.StringEscapeUtils;
import org.apache.commons.text.StringEscapeUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.security.access.prepost.PreAuthorize;
......@@ -29,7 +29,7 @@ import com.fasterxml.jackson.core.JsonProcessingException;
import de.unibamberg.minf.core.web.controller.DataTableList;
import de.unibamberg.minf.core.web.pojo.ModelActionPojo;
import eu.dariah.de.dariahsp.model.User;
import eu.dariah.de.dariahsp.model.web.AuthPojo;
import eu.dariah.de.dariahsp.web.model.AuthPojo;
import eu.dariah.de.search.model.Collection;
import eu.dariah.de.search.model.CustomSearch;
import eu.dariah.de.search.model.CustomSearch.UserRole;
......@@ -85,7 +85,7 @@ public class CustomSearchController extends BaseController {
@RequestMapping(method = RequestMethod.GET, value = "/async/getData")
public @ResponseBody DataTableList<CustomSearchPojo> getCustomSearches(HttpServletRequest request, Model model, Locale locale) {
AuthPojo auth = authInfoHelper.getAuth(request);
AuthPojo auth = authInfoHelper.getAuth();
List<CustomSearch> customSearches = customSearchService.findByUserId(auth.getUserId());
if (customSearches!=null) {
List<CustomSearchPojo> pojos = new ArrayList<CustomSearchPojo>();
......@@ -127,7 +127,7 @@ public class CustomSearchController extends BaseController {
@RequestMapping(method = RequestMethod.GET, value = "{customSearchId}/async/get")
public @ResponseBody CustomSearchPojo getUserCollection(@PathVariable String customSearchId, HttpServletRequest request, Model model, Locale locale) {
AuthPojo auth = authInfoHelper.getAuth(request);
AuthPojo auth = authInfoHelper.getAuth();
CustomSearch customSearch = customSearchService.findById(customSearchId);
if (customSearch==null || customSearch.getUserRoleMap()==null || !customSearch.getUserRoleMap().containsKey(auth.getUserId())) {
return new CustomSearchPojo();
......@@ -160,7 +160,7 @@ public class CustomSearchController extends BaseController {
@PreAuthorize("isAuthenticated()")
@RequestMapping(method=POST, value="/async/save", produces = "application/json; charset=utf-8")
public @ResponseBody ModelActionPojo saveUserCollection(CustomSearchPojo cs, @RequestParam(required=false, name="organizationImage[]") String[] organizationImage, BindingResult bindingResult, HttpServletRequest request, Locale locale) {
AuthPojo auth = authInfoHelper.getAuth(request);
AuthPojo auth = authInfoHelper.getAuth();
customSearchValidator.validate(cs, bindingResult);
ModelActionPojo result = getActionResult(bindingResult, locale);
......@@ -174,7 +174,7 @@ public class CustomSearchController extends BaseController {
saveUc.getUserRoleMap().put(auth.getUserId(), UserRole.Owner);
}
saveUc.setName(cs.getName());
saveUc.setDescription(StringEscapeUtils.escapeHtml(cs.getDescription()));
saveUc.setDescription(StringEscapeUtils.escapeHtml4(cs.getDescription()));
saveUc.setBrandedSearch(cs.isBrandedSearch());
saveUc.setDatamodelId(cs.getDatamodelId());
......@@ -339,7 +339,7 @@ public class CustomSearchController extends BaseController {
@RequestMapping(method=POST, value="{customSearchId}/async/quickSaveUserCollection", produces = "application/json; charset=utf-8")
public @ResponseBody ModelActionPojo quickSaveUserCollection(@PathVariable String customSearchId, @Valid CustomSearchPojo customSearch, BindingResult bindingResult, HttpServletRequest request, Model model, Locale locale) {
ModelActionPojo result = getActionResult(bindingResult, locale);
AuthPojo auth = authInfoHelper.getAuth(request);
AuthPojo auth = authInfoHelper.getAuth();
if (result.isSuccess()) {
CustomSearch saveCs;
......
......@@ -28,8 +28,8 @@ import com.fasterxml.jackson.databind.JsonNode;
import de.unibamberg.minf.core.web.controller.BaseTranslationController;
import de.unibamberg.minf.core.web.exception.PermissionDeniedException;
import de.unibamberg.minf.core.web.pojo.ModelActionPojo;
import eu.dariah.de.dariahsp.model.web.AuthPojo;
import eu.dariah.de.dariahsp.web.AuthInfoHelper;
import eu.dariah.de.dariahsp.web.model.AuthPojo;
import eu.dariah.de.search.es.service.SearchService;
import eu.dariah.de.search.es.service.params.SearchParams;
import eu.dariah.de.search.model.ElementCollection;
......@@ -50,13 +50,13 @@ public class ElementCollectionController extends BaseTranslationController {
@RequestMapping(method=GET, value="/list")
public @ResponseBody List<ElementCollection> listAllElementCollections(HttpServletRequest request) {
return elementCollectionService.findByUserId(authInfoHelper.getUserId(request));
return elementCollectionService.findByUserId(authInfoHelper.getUserId());
}
@PreAuthorize("isAuthenticated()")
@RequestMapping(method=GET, value="/{elementCollectionId}/items")
public @ResponseBody List<ElementCollectionItem> listElementCollectionItems(@PathVariable String elementCollectionId, HttpServletRequest request) {
ElementCollection rc = elementCollectionService.findById(elementCollectionId, authInfoHelper.getUserId(request));
ElementCollection rc = elementCollectionService.findById(elementCollectionId, authInfoHelper.getUserId());
if (rc==null) {
return null;
}
......@@ -71,11 +71,11 @@ public class ElementCollectionController extends BaseTranslationController {
if (elementCollectionId==null || elementCollectionId.isEmpty() || elementCollectionId.equals("new")) {
rc = new ElementCollection();
} else {
AuthPojo auth = authInfoHelper.getAuth(request);
AuthPojo auth = authInfoHelper.getAuth();
if (!elementCollectionService.hasUserWriteAccess(elementCollectionId, auth.getUserId())) {
throw new PermissionDeniedException();
}
rc = elementCollectionService.findById(elementCollectionId, authInfoHelper.getUserId(request));
rc = elementCollectionService.findById(elementCollectionId, authInfoHelper.getUserId());
}
model.addAttribute("elementCollection", rc);
model.addAttribute("actionPath", "/elementCollections/" + (rc.getId()==null ? "new" : rc.getId()) + "/save");
......@@ -86,7 +86,7 @@ public class ElementCollectionController extends BaseTranslationController {
@PreAuthorize("isAuthenticated()")
@RequestMapping(method=GET, value="/{elementCollectionId}/remove")
public @ResponseBody ModelActionPojo removeElementCollection(@PathVariable String elementCollectionId, HttpServletRequest request) throws PermissionDeniedException {
return new ModelActionPojo(elementCollectionService.deleteElementCollection(elementCollectionId, authInfoHelper.getUserId(request)));
return new ModelActionPojo(elementCollectionService.deleteElementCollection(elementCollectionId, authInfoHelper.getUserId()));
}
@PreAuthorize("isAuthenticated()")
......@@ -99,7 +99,7 @@ public class ElementCollectionController extends BaseTranslationController {
} else {
elementCollection.setId(elementCollectionId);
}
elementCollectionService.saveElementCollection(elementCollection, authInfoHelper.getUserId(request));
elementCollectionService.saveElementCollection(elementCollection, authInfoHelper.getUserId());
}
return result;
}
......@@ -107,7 +107,7 @@ public class ElementCollectionController extends BaseTranslationController {
@PreAuthorize("isAuthenticated()")
@RequestMapping(method=GET, value="/forms/addItem")
public String getAddItemForm(@RequestParam String itemId, Model model, HttpServletRequest request) throws PermissionDeniedException {
List<ElementCollection> possibleCollections = elementCollectionService.findByUserId(authInfoHelper.getUserId(request), true);
List<ElementCollection> possibleCollections = elementCollectionService.findByUserId(authInfoHelper.getUserId(), true);
SearchParams params = new SearchParams(searchService.getIndexNames(), QueryBuilders.termQuery("_id", itemId));
params.setSize(2);
SearchResponse resp = searchService.query(params);
......@@ -141,7 +141,7 @@ public class ElementCollectionController extends BaseTranslationController {
@PreAuthorize("isAuthenticated()")
@RequestMapping(method=GET, value="/forms/removeItem")
public String getRemoveItemForm(@RequestParam String itemId, Model model, HttpServletRequest request) throws PermissionDeniedException {
List<ElementCollection> possibleCollections = elementCollectionService.findByUserId(authInfoHelper.getUserId(request), true);
List<ElementCollection> possibleCollections = elementCollectionService.findByUserId(authInfoHelper.getUserId(), true);
SearchParams params = new SearchParams(searchService.getIndexNames(), QueryBuilders.termQuery("_id", itemId));
params.setSize(2);
SearchResponse resp = searchService.query(params);
......@@ -172,13 +172,13 @@ public class ElementCollectionController extends BaseTranslationController {
@PreAuthorize("isAuthenticated()")
@RequestMapping(method=GET, value="/removeItem/{itemId}")
public @ResponseBody ModelActionPojo removeElementCollectionItem(@PathVariable String itemId, @RequestParam String elementCollectionId, HttpServletRequest request) throws PermissionDeniedException {
return new ModelActionPojo(elementCollectionService.removeItemFromElementCollection(elementCollectionId, itemId, authInfoHelper.getUserId(request)));
return new ModelActionPojo(elementCollectionService.removeItemFromElementCollection(elementCollectionId, itemId, authInfoHelper.getUserId()));
}
@PreAuthorize("isAuthenticated()")
@RequestMapping(method=POST, value="/{elementCollectionId}/remove")
public @ResponseBody ModelActionPojo removeElementCollectionItem(@PathVariable String elementCollectionId, @RequestParam String index, @RequestParam String id, HttpServletRequest request) throws PermissionDeniedException {
return new ModelActionPojo(elementCollectionService.removeItemFromElementCollection(elementCollectionId, index, id, authInfoHelper.getUserId(request)));
return new ModelActionPojo(elementCollectionService.removeItemFromElementCollection(elementCollectionId, index, id, authInfoHelper.getUserId()));
}
@PreAuthorize("isAuthenticated()")
......@@ -205,6 +205,6 @@ public class ElementCollectionController extends BaseTranslationController {
logger.warn("Failed to convert source for search hit", e);
}
return new ModelActionPojo(elementCollectionService.addItemToElementCollection(elementCollectionId, cItem, authInfoHelper.getUserId(request)));
return new ModelActionPojo(elementCollectionService.addItemToElementCollection(elementCollectionId, cItem, authInfoHelper.getUserId()));
}
}
......@@ -15,7 +15,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import eu.dariah.de.dariahsp.web.model.AuthPojo;
import eu.dariah.de.dariahsp.web.AuthInfoHelper;
import eu.dariah.de.search.pojo.TagPojo;
import eu.dariah.de.search.query.execution.AggregationService;
......@@ -64,9 +64,11 @@ public class HomeController extends BaseController {
@RequestMapping(value = "/logout", method = RequestMethod.GET)
public String getLogout(@RequestParam(value = "error", required = false) String error, @RequestParam(value = "url", defaultValue = "/") String url, HttpServletRequest request, HttpServletResponse response, Model model) throws IOException {
if (saml && authInfoHelper.getCurrentUserDetails(request).isAuth()) {
AuthPojo auth = authInfoHelper.getAuth();
if (saml && auth.isAuth()) {
return "redirect:/saml/logout" + (!url.equals("/") ? "?loginRedirectUrl=" + url : "");
} else if (!saml && authInfoHelper.getCurrentUserDetails(request).isAuth()) {
} else if (!saml && auth.isAuth()) {
return "redirect:/localsec/logout" + (!url.equals("/") ? "?loginRedirectUrl=" + url : "");
}
return "common/logout";
......@@ -100,6 +102,6 @@ public class HomeController extends BaseController {
@RequestMapping(method = RequestMethod.GET, value = "/async/isAuthenticated", produces = "application/json; charset=UTF-8")
public @ResponseBody boolean getIsLoggedIn(HttpServletRequest request) {
return authInfoHelper.getAuth(request).isAuth();
return authInfoHelper.getAuth().isAuth();
}
}
......@@ -52,13 +52,20 @@ import eu.dariah.de.search.model.ExtendedDatamodelContainer;
public class XmlChunker extends BaseFileStreamCrawler implements Crawler {
@Override protected String getInputFilename() { return "/"; }
@Override protected String getOutputFilename() { return "/"; }
@Override
protected String getInputFilename() {
return "/";
}
@Override
protected String getOutputFilename() {
return "/";
}
private String outputFilePattern = "%s_%08d.xml";
private long chunkByteSize = 2000000; // ~ 2MiB
private int totalNodes = -1;
private XMLInputFactory xif;
private TransformerFactory tf;
private DocumentBuilderFactory docBuilderFactory;
......@@ -67,22 +74,35 @@ public class XmlChunker extends BaseFileStreamCrawler implements Crawler {
private XPathExpression compiledExpression;
private LinkedList<Document> documentQueue;
private int fileIndex = 0;
private QName processingRootXmlName;
private ExtendedDatamodelContainer datamodel;
public String getOutputFilePattern() { return outputFilePattern; }
public void setOutputFilePattern(String outputFilePattern) { this.outputFilePattern = outputFilePattern; }
public long getChunkByteSize() { return chunkByteSize; }
public void setChunkByteSize(long chunkByteSize) { this.chunkByteSize = chunkByteSize; }
public int getTotalNodes() { return totalNodes; }
public void setTotalNodes(int totalNodes) { this.totalNodes = totalNodes; }
public String getOutputFilePattern() {
return outputFilePattern;
}
public void setOutputFilePattern(String outputFilePattern) {
this.outputFilePattern = outputFilePattern;
}
public long getChunkByteSize() {
return chunkByteSize;
}
public void setChunkByteSize(long chunkByteSize) {
this.chunkByteSize = chunkByteSize;
}
public int getTotalNodes() {
return totalNodes;
}
public void setTotalNodes(int totalNodes) {
this.totalNodes = totalNodes;
}
@Override
public String getUnitMessageCode() {
return "~eu.dariah.de.minfba.search.crawling.file.chunker.unit";
......@@ -92,49 +112,50 @@ public class XmlChunker extends BaseFileStreamCrawler implements Crawler {
public String getTitleMessageCode() {
return "~eu.dariah.de.minfba.search.crawling.file.chunker.title";
}
@Override
public void init(Endpoint endpoint, Crawl crawl, ExtendedDatamodelContainer sc) {
super.init(endpoint, crawl, sc);
try {
this.setupPaths(crawl);
this.datamodel = sc;
System.setProperty("javax.xml.transform.TransformerFactory", "com.sun.org.apache.xalan.internal.xsltc.trax.TransformerFactoryImpl");
System.setProperty("javax.xml.transform.TransformerFactory",
"com.sun.org.apache.xalan.internal.xsltc.trax.TransformerFactoryImpl");
ModelElement processingRoot = sc.getOrRenderProcessingRoot(true);