Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
dariah
search
Commits
9565156b
Commit
9565156b
authored
Mar 02, 2021
by
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
Changes
27
Pipelines
1
Expand all
Hide whitespace changes
Inline
Side-by-side
build.gradle
View file @
9565156b
plugins
{
plugins
{
//
id 'io.spring.dependency-management' version "1.0.10.RELEASE"
id
'io.spring.dependency-management'
version
"1.0.10.RELEASE"
//
id 'org.springframework.boot' version "2.3.5.RELEASE" apply false
id
'org.springframework.boot'
version
"2.3.5.RELEASE"
apply
false
id
"nebula.ospackage"
version
"8.4.1"
apply
false
id
"nebula.ospackage"
version
"8.4.1"
apply
false
}
}
allprojects
{
allprojects
{
apply
plugin:
'eclipse'
apply
plugin:
'eclipse'
...
@@ -12,39 +13,29 @@ allprojects {
...
@@ -12,39 +13,29 @@ allprojects {
repositories
{
repositories
{
mavenLocal
()
mavenLocal
()
maven
{
maven
{
url
=
'https://minfba.de.dariah.eu/nexus/repository/minfba-central/'
url
=
'https://minfba.de.dariah.eu/nexus/repository/minfba-central/'
}
}
}
}
ext
{
ext
{
coreVersion
=
"5.4.1-SNAPSHOT"
coreVersion
=
"6.1-SNAPSHOT"
gtfVersion
=
"1.6.2-SNAPSHOT"
gtfVersion
=
"2.0.0-SNAPSHOT"
processingVersion
=
"4.0.2-SNAPSHOT"
processingVersion
=
"4.1.0-SNAPSHOT"
colregModelVersion
=
"3.15.0-RELEASE"
colregModelVersion
=
"4.2-SNAPSHOT"
dariahSpVersion
=
"1.4.0-SNAPSHOT"
dariahSpVersion
=
"2.1.4-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"
mavenRepo
=
'https://minfba.de.dariah.eu/nexus/repository/minfba-central/'
mavenRepo
=
'https://minfba.de.dariah.eu/nexus/repository/minfba-central/'
releasesRepo
=
"https://minfba.de.dariah.eu/nexus/repository/minfba-releases/"
releasesRepo
=
"https://minfba.de.dariah.eu/nexus/repository/minfba-releases/"
snapshotsRepo
=
"https://minfba.de.dariah.eu/nexus/repository/minfba-snapshots/"
snapshotsRepo
=
"https://minfba.de.dariah.eu/nexus/repository/minfba-snapshots/"
aptReleasesRepo
=
'https://minfba.de.dariah.eu/nexus/repository/minfba-apt-releases/'
aptReleasesRepo
=
'https://minfba.de.dariah.eu/nexus/repository/minfba-apt-releases/'
aptTestingRepo
=
'https://minfba.de.dariah.eu/nexus/repository/minfba-apt-testing/'
aptTestingRepo
=
'https://minfba.de.dariah.eu/nexus/repository/minfba-apt-testing/'
yumRepo
=
'https://minfba.de.dariah.eu/nexus/repository/minfba-yum/'
yumRepo
=
'https://minfba.de.dariah.eu/nexus/repository/minfba-yum/'
repoUser
=
project
.
hasProperty
(
'nexususer'
)
?
project
.
getProperty
(
'nexususer'
)
:
'?'
;
repoUser
=
project
.
hasProperty
(
'nexususer'
)
?
project
.
getProperty
(
'nexususer'
)
:
'?'
;
repoPass
=
project
.
hasProperty
(
'nexuspass'
)
?
project
.
getProperty
(
'nexuspass'
)
:
''
repoPass
=
project
.
hasProperty
(
'nexuspass'
)
?
project
.
getProperty
(
'nexuspass'
)
:
''
// Filled dynamically by packaging tasks
// Filled dynamically by packaging tasks
debFile
=
""
debFile
=
""
rpmFile
=
""
rpmFile
=
""
aptRepo
=
""
aptRepo
=
""
}
}
...
@@ -54,13 +45,36 @@ allprojects {
...
@@ -54,13 +45,36 @@ allprojects {
subprojects
{
subprojects
{
apply
plugin:
'java'
apply
plugin:
'java'
apply
plugin:
'maven-publish'
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
{
imports
{
mavenBom
(
org
.
springframework
.
boot
.
gradle
.
plugin
.
SpringBootPlugin
.
BOM_COORDINATES
)
mavenBom
(
org
.
springframework
.
boot
.
gradle
.
plugin
.
SpringBootPlugin
.
BOM_COORDINATES
)
}
}
}
*/
}
publishing
{
publishing
{
publications
{
publications
{
...
@@ -111,27 +125,4 @@ subprojects {
...
@@ -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
}
}
}
search-core/build.gradle
View file @
9565156b
...
@@ -4,10 +4,65 @@ plugins {
...
@@ -4,10 +4,65 @@ plugins {
description
=
"DARIAH-DE Generic Search - Core library"
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
{
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-web:$coreVersion"
implementation
"de.unibamberg.minf.core:core-util:$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-base:$gtfVersion"
implementation
"de.unibamberg.minf.gtf:gtf-core:$gtfVersion"
implementation
"de.unibamberg.minf.gtf:gtf-core:$gtfVersion"
implementation
"de.unibamberg.minf.gtf:gtf-extension-file:$gtfVersion"
implementation
"de.unibamberg.minf.gtf:gtf-extension-file:$gtfVersion"
...
@@ -16,45 +71,72 @@ dependencies {
...
@@ -16,45 +71,72 @@ dependencies {
implementation
"de.unibamberg.minf.gtf:gtf-extension-nlp:$gtfVersion"
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-vocabulary:$gtfVersion"
implementation
"de.unibamberg.minf.gtf:gtf-extension-dai:$gtfVersion"
implementation
"de.unibamberg.minf.gtf:gtf-extension-dai:$gtfVersion"
implementation
"de.unibamberg.minf.processing:processing-core:$processingVersion"
implementation
"de.unibamberg.minf.processing:processing-core:$processingVersion"
implementation
"de.unibamberg.minf.processing:processing-adapters:$processingVersion"
implementation
"de.unibamberg.minf.processing:processing-adapters:$processingVersion"
implementation
"eu.dariah.de:colreg-model:$colregModelVersion"
implementation
"eu.dariah.de:dariahsp-core:$dariahSpVersion"
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"
implementation
"org.apache.httpcomponents:httpclient:$httpComponentsVersion"
//implementation "org.elasticsearch:elasticsearch"
implementation
"org.elasticsearch:elasticsearch:$elasticsearchVersion"
implementation
"org.elasticsearch.client:elasticsearch-rest-high-level-client:$elasticsearchVersion"
implementation
"org.slf4j:slf4j-api"
implementation
"org.springframework.data:spring-data-mongodb:1.10.0.RELEASE"
implementation
"joda-time:joda-time:$jodaTimeVersion"
implementation
"org.slf4j:slf4j-api:$slf4jVersion"
//implementation "joda-time:joda-time-jsptags:1.1.1"
implementation
"joda-time:joda-time:2.9.9"
//implementation "commons-io:commons-io"
implementation
"joda-time:joda-time-jsptags:1.1.1"
//implementation "org.apache.commons:commons-compress"
implementation
"commons-io:commons-io:2.5"
implementation
"org.apache.commons:commons-compress:1.15"
//implementation "com.fasterxml.jackson.dataformat:jackson-dataformat-xml"
implementation
"com.fasterxml.jackson.core:jackson-core:$jacksonVersion"
//implementation "com.fasterxml.jackson.datatype:jackson-datatype-joda"
implementation
"com.fasterxml.jackson.core:jackson-databind:$jacksonVersion"
//implementation "org.skyscreamer:jsonassert:1.4.0"
implementation
"com.fasterxml.jackson.core:jackson-annotations:$jacksonVersion"
implementation
"org.apache.tika:tika-core:$tikaVersion"
implementation
"com.fasterxml.jackson.dataformat:jackson-dataformat-xml:$jacksonVersion"
implementation
"org.apache.tika:tika-parsers:$tikaVersion"
implementation
"com.fasterxml.jackson.datatype:jackson-datatype-joda:$jacksonVersion"
implementation
"org.skyscreamer:jsonassert:1.4.0"
implementation
"org.elasticsearch:elasticsearch"
implementation
"org.apache.tika:tika-core:1.22"
implementation
"org.apache.tika:tika-parsers:1.22"
testImplementation
"org.springframework:spring-test:$springVersion"
//testImplementation "org.springframework.boot:spring-boot-starter-test"
testImplementation
"junit:junit:4.12"
testImplementation
"org.mockito:mockito-all:1.10.19"
testImplementation
"org.springframework:spring-test"
testImplementation
"org.elasticsearch.plugin:transport-netty4-client:$elasticsearchVersion"
testImplementation
"org.junit.jupiter:junit-jupiter-api"
testImplementation
"org.slf4j:jcl-over-slf4j:$slf4jVersion"
testImplementation
"org.junit.jupiter:junit-jupiter-engine"
testImplementation
"org.slf4j:log4j-over-slf4j:$slf4jVersion"
testImplementation
"org.mockito:mockito-core:$mockitoVersion"
testImplementation
"ch.qos.logback:logback-core:$logbackVersion"
testImplementation
"org.mockito:mockito-junit-jupiter:$mockitoVersion"
testImplementation
"ch.qos.logback:logback-classic:$logbackVersion"
compileOnly
"javax.servlet:servlet-api:2.5"
//testImplementation "junit:junit:4.12"
compileOnly
"org.projectlombok:lombok:$lombokVersion"
//
annotationProcessor
"org.projectlombok:lombok:$lombokVersion"
testCompileOnly
"org.projectlombok:lombok:$lombokVersion"
//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
{
jar
{
enabled
=
true
enabled
=
true
}
publishing
{
publications
{
maven
(
MavenPublication
)
{
from
(
components
.
java
)
artifact
(
sourcesJar
)
{}
artifact
(
javadocJar
)
{}
}
}
}
}
\ No newline at end of file
search-core/src/main/java/eu/dariah/de/search/api/client/CollectionSyncClient.java
View file @
9565156b
This diff is collapsed.
Click to expand it.
search-core/src/main/java/eu/dariah/de/search/controller/CustomSearchController.java
View file @
9565156b
...
@@ -13,7 +13,7 @@ import javax.servlet.http.HttpServletRequest;
...
@@ -13,7 +13,7 @@ import javax.servlet.http.HttpServletRequest;
import
javax.servlet.http.HttpServletResponse
;
import
javax.servlet.http.HttpServletResponse
;
import
javax.validation.Valid
;
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.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.security.access.prepost.PreAuthorize
;
import
org.springframework.security.access.prepost.PreAuthorize
;
...
@@ -29,7 +29,7 @@ import com.fasterxml.jackson.core.JsonProcessingException;
...
@@ -29,7 +29,7 @@ import com.fasterxml.jackson.core.JsonProcessingException;
import
de.unibamberg.minf.core.web.controller.DataTableList
;
import
de.unibamberg.minf.core.web.controller.DataTableList
;
import
de.unibamberg.minf.core.web.pojo.ModelActionPojo
;
import
de.unibamberg.minf.core.web.pojo.ModelActionPojo
;
import
eu.dariah.de.dariahsp.model.User
;
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.Collection
;
import
eu.dariah.de.search.model.CustomSearch
;
import
eu.dariah.de.search.model.CustomSearch
;
import
eu.dariah.de.search.model.CustomSearch.UserRole
;
import
eu.dariah.de.search.model.CustomSearch.UserRole
;
...
@@ -85,7 +85,7 @@ public class CustomSearchController extends BaseController {
...
@@ -85,7 +85,7 @@ public class CustomSearchController extends BaseController {
@RequestMapping
(
method
=
RequestMethod
.
GET
,
value
=
"/async/getData"
)
@RequestMapping
(
method
=
RequestMethod
.
GET
,
value
=
"/async/getData"
)
public
@ResponseBody
DataTableList
<
CustomSearchPojo
>
getCustomSearches
(
HttpServletRequest
request
,
Model
model
,
Locale
locale
)
{
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
());
List
<
CustomSearch
>
customSearches
=
customSearchService
.
findByUserId
(
auth
.
getUserId
());
if
(
customSearches
!=
null
)
{
if
(
customSearches
!=
null
)
{
List
<
CustomSearchPojo
>
pojos
=
new
ArrayList
<
CustomSearchPojo
>();
List
<
CustomSearchPojo
>
pojos
=
new
ArrayList
<
CustomSearchPojo
>();
...
@@ -127,7 +127,7 @@ public class CustomSearchController extends BaseController {
...
@@ -127,7 +127,7 @@ public class CustomSearchController extends BaseController {
@RequestMapping
(
method
=
RequestMethod
.
GET
,
value
=
"{customSearchId}/async/get"
)
@RequestMapping
(
method
=
RequestMethod
.
GET
,
value
=
"{customSearchId}/async/get"
)
public
@ResponseBody
CustomSearchPojo
getUserCollection
(
@PathVariable
String
customSearchId
,
HttpServletRequest
request
,
Model
model
,
Locale
locale
)
{
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
);
CustomSearch
customSearch
=
customSearchService
.
findById
(
customSearchId
);
if
(
customSearch
==
null
||
customSearch
.
getUserRoleMap
()==
null
||
!
customSearch
.
getUserRoleMap
().
containsKey
(
auth
.
getUserId
()))
{
if
(
customSearch
==
null
||
customSearch
.
getUserRoleMap
()==
null
||
!
customSearch
.
getUserRoleMap
().
containsKey
(
auth
.
getUserId
()))
{
return
new
CustomSearchPojo
();
return
new
CustomSearchPojo
();
...
@@ -160,7 +160,7 @@ public class CustomSearchController extends BaseController {
...
@@ -160,7 +160,7 @@ public class CustomSearchController extends BaseController {
@PreAuthorize
(
"isAuthenticated()"
)
@PreAuthorize
(
"isAuthenticated()"
)
@RequestMapping
(
method
=
POST
,
value
=
"/async/save"
,
produces
=
"application/json; charset=utf-8"
)
@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
)
{
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
);
customSearchValidator
.
validate
(
cs
,
bindingResult
);
ModelActionPojo
result
=
getActionResult
(
bindingResult
,
locale
);
ModelActionPojo
result
=
getActionResult
(
bindingResult
,
locale
);
...
@@ -174,7 +174,7 @@ public class CustomSearchController extends BaseController {
...
@@ -174,7 +174,7 @@ public class CustomSearchController extends BaseController {
saveUc
.
getUserRoleMap
().
put
(
auth
.
getUserId
(),
UserRole
.
Owner
);
saveUc
.
getUserRoleMap
().
put
(
auth
.
getUserId
(),
UserRole
.
Owner
);
}
}
saveUc
.
setName
(
cs
.
getName
());
saveUc
.
setName
(
cs
.
getName
());
saveUc
.
setDescription
(
StringEscapeUtils
.
escapeHtml
(
cs
.
getDescription
()));
saveUc
.
setDescription
(
StringEscapeUtils
.
escapeHtml
4
(
cs
.
getDescription
()));
saveUc
.
setBrandedSearch
(
cs
.
isBrandedSearch
());
saveUc
.
setBrandedSearch
(
cs
.
isBrandedSearch
());
saveUc
.
setDatamodelId
(
cs
.
getDatamodelId
());
saveUc
.
setDatamodelId
(
cs
.
getDatamodelId
());
...
@@ -339,7 +339,7 @@ public class CustomSearchController extends BaseController {
...
@@ -339,7 +339,7 @@ public class CustomSearchController extends BaseController {
@RequestMapping
(
method
=
POST
,
value
=
"{customSearchId}/async/quickSaveUserCollection"
,
produces
=
"application/json; charset=utf-8"
)
@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
)
{
public
@ResponseBody
ModelActionPojo
quickSaveUserCollection
(
@PathVariable
String
customSearchId
,
@Valid
CustomSearchPojo
customSearch
,
BindingResult
bindingResult
,
HttpServletRequest
request
,
Model
model
,
Locale
locale
)
{
ModelActionPojo
result
=
getActionResult
(
bindingResult
,
locale
);
ModelActionPojo
result
=
getActionResult
(
bindingResult
,
locale
);
AuthPojo
auth
=
authInfoHelper
.
getAuth
(
request
);
AuthPojo
auth
=
authInfoHelper
.
getAuth
();
if
(
result
.
isSuccess
())
{
if
(
result
.
isSuccess
())
{
CustomSearch
saveCs
;
CustomSearch
saveCs
;
...
...
search-core/src/main/java/eu/dariah/de/search/controller/ElementCollectionController.java
View file @
9565156b
...
@@ -28,8 +28,8 @@ import com.fasterxml.jackson.databind.JsonNode;
...
@@ -28,8 +28,8 @@ import com.fasterxml.jackson.databind.JsonNode;
import
de.unibamberg.minf.core.web.controller.BaseTranslationController
;
import
de.unibamberg.minf.core.web.controller.BaseTranslationController
;
import
de.unibamberg.minf.core.web.exception.PermissionDeniedException
;
import
de.unibamberg.minf.core.web.exception.PermissionDeniedException
;
import
de.unibamberg.minf.core.web.pojo.ModelActionPojo
;
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.AuthInfoHelper
;
import
eu.dariah.de.dariahsp.web.model.AuthPojo
;
import
eu.dariah.de.search.es.service.SearchService
;
import
eu.dariah.de.search.es.service.SearchService
;
import
eu.dariah.de.search.es.service.params.SearchParams
;
import
eu.dariah.de.search.es.service.params.SearchParams
;
import
eu.dariah.de.search.model.ElementCollection
;
import
eu.dariah.de.search.model.ElementCollection
;
...
@@ -50,13 +50,13 @@ public class ElementCollectionController extends BaseTranslationController {
...
@@ -50,13 +50,13 @@ public class ElementCollectionController extends BaseTranslationController {
@RequestMapping
(
method
=
GET
,
value
=
"/list"
)
@RequestMapping
(
method
=
GET
,
value
=
"/list"
)
public
@ResponseBody
List
<
ElementCollection
>
listAllElementCollections
(
HttpServletRequest
request
)
{
public
@ResponseBody
List
<
ElementCollection
>
listAllElementCollections
(
HttpServletRequest
request
)
{
return
elementCollectionService
.
findByUserId
(
authInfoHelper
.
getUserId
(
request
));
return
elementCollectionService
.
findByUserId
(
authInfoHelper
.
getUserId
());
}
}
@PreAuthorize
(
"isAuthenticated()"
)
@PreAuthorize
(
"isAuthenticated()"
)
@RequestMapping
(
method
=
GET
,
value
=
"/{elementCollectionId}/items"
)
@RequestMapping
(
method
=
GET
,
value
=
"/{elementCollectionId}/items"
)
public
@ResponseBody
List
<
ElementCollectionItem
>
listElementCollectionItems
(
@PathVariable
String
elementCollectionId
,
HttpServletRequest
request
)
{
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
)
{
if
(
rc
==
null
)
{
return
null
;
return
null
;
}
}
...
@@ -71,11 +71,11 @@ public class ElementCollectionController extends BaseTranslationController {
...
@@ -71,11 +71,11 @@ public class ElementCollectionController extends BaseTranslationController {
if
(
elementCollectionId
==
null
||
elementCollectionId
.
isEmpty
()
||
elementCollectionId
.
equals
(
"new"
))
{
if
(
elementCollectionId
==
null
||
elementCollectionId
.
isEmpty
()
||
elementCollectionId
.
equals
(
"new"
))
{
rc
=
new
ElementCollection
();
rc
=
new
ElementCollection
();
}
else
{
}
else
{
AuthPojo
auth
=
authInfoHelper
.
getAuth
(
request
);
AuthPojo
auth
=
authInfoHelper
.
getAuth
();
if
(!
elementCollectionService
.
hasUserWriteAccess
(
elementCollectionId
,
auth
.
getUserId
()))
{
if
(!
elementCollectionService
.
hasUserWriteAccess
(
elementCollectionId
,
auth
.
getUserId
()))
{
throw
new
PermissionDeniedException
();
throw
new
PermissionDeniedException
();
}
}
rc
=
elementCollectionService
.
findById
(
elementCollectionId
,
authInfoHelper
.
getUserId
(
request
));
rc
=
elementCollectionService
.
findById
(
elementCollectionId
,
authInfoHelper
.
getUserId
());
}
}
model
.
addAttribute
(
"elementCollection"
,
rc
);
model
.
addAttribute
(
"elementCollection"
,
rc
);
model
.
addAttribute
(
"actionPath"
,
"/elementCollections/"
+
(
rc
.
getId
()==
null
?
"new"
:
rc
.
getId
())
+
"/save"
);
model
.
addAttribute
(
"actionPath"
,
"/elementCollections/"
+
(
rc
.
getId
()==
null
?
"new"
:
rc
.
getId
())
+
"/save"
);
...
@@ -86,7 +86,7 @@ public class ElementCollectionController extends BaseTranslationController {
...
@@ -86,7 +86,7 @@ public class ElementCollectionController extends BaseTranslationController {
@PreAuthorize
(
"isAuthenticated()"
)
@PreAuthorize
(
"isAuthenticated()"
)
@RequestMapping
(
method
=
GET
,
value
=
"/{elementCollectionId}/remove"
)
@RequestMapping
(
method
=
GET
,
value
=
"/{elementCollectionId}/remove"
)
public
@ResponseBody
ModelActionPojo
removeElementCollection
(
@PathVariable
String
elementCollectionId
,
HttpServletRequest
request
)
throws
PermissionDeniedException
{
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()"
)
@PreAuthorize
(
"isAuthenticated()"
)
...
@@ -99,7 +99,7 @@ public class ElementCollectionController extends BaseTranslationController {
...
@@ -99,7 +99,7 @@ public class ElementCollectionController extends BaseTranslationController {
}
else
{
}
else
{
elementCollection
.
setId
(
elementCollectionId
);
elementCollection
.
setId
(
elementCollectionId
);
}
}
elementCollectionService
.
saveElementCollection
(
elementCollection
,
authInfoHelper
.
getUserId
(
request
));
elementCollectionService
.
saveElementCollection
(
elementCollection
,
authInfoHelper
.
getUserId
());
}
}
return
result
;
return
result
;
}
}
...
@@ -107,7 +107,7 @@ public class ElementCollectionController extends BaseTranslationController {
...
@@ -107,7 +107,7 @@ public class ElementCollectionController extends BaseTranslationController {
@PreAuthorize
(
"isAuthenticated()"
)
@PreAuthorize
(
"isAuthenticated()"
)
@RequestMapping
(
method
=
GET
,
value
=
"/forms/addItem"
)
@RequestMapping
(
method
=
GET
,
value
=
"/forms/addItem"
)
public
String
getAddItemForm
(
@RequestParam
String
itemId
,
Model
model
,
HttpServletRequest
request
)
throws
PermissionDeniedException
{
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
));
SearchParams
params
=
new
SearchParams
(
searchService
.
getIndexNames
(),
QueryBuilders
.
termQuery
(
"_id"
,
itemId
));
params
.
setSize
(
2
);
params
.
setSize
(
2
);
SearchResponse
resp
=
searchService
.
query
(
params
);
SearchResponse
resp
=
searchService
.
query
(
params
);
...
@@ -141,7 +141,7 @@ public class ElementCollectionController extends BaseTranslationController {
...
@@ -141,7 +141,7 @@ public class ElementCollectionController extends BaseTranslationController {
@PreAuthorize
(
"isAuthenticated()"
)
@PreAuthorize
(
"isAuthenticated()"
)
@RequestMapping
(
method
=
GET
,
value
=
"/forms/removeItem"
)
@RequestMapping
(
method
=
GET
,
value
=
"/forms/removeItem"
)
public
String
getRemoveItemForm
(
@RequestParam
String
itemId
,
Model
model
,
HttpServletRequest
request
)
throws
PermissionDeniedException
{
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
));
SearchParams
params
=
new
SearchParams
(
searchService
.
getIndexNames
(),
QueryBuilders
.
termQuery
(
"_id"
,
itemId
));
params
.
setSize
(
2
);
params
.
setSize
(
2
);
SearchResponse
resp
=
searchService
.
query
(
params
);
SearchResponse
resp
=
searchService
.
query
(
params
);
...
@@ -172,13 +172,13 @@ public class ElementCollectionController extends BaseTranslationController {
...
@@ -172,13 +172,13 @@ public class ElementCollectionController extends BaseTranslationController {
@PreAuthorize
(
"isAuthenticated()"
)
@PreAuthorize
(
"isAuthenticated()"
)
@RequestMapping
(
method
=
GET
,
value
=
"/removeItem/{itemId}"
)
@RequestMapping
(
method
=
GET
,
value
=
"/removeItem/{itemId}"
)
public
@ResponseBody
ModelActionPojo
removeElementCollectionItem
(
@PathVariable
String
itemId
,
@RequestParam
String
elementCollectionId
,
HttpServletRequest
request
)
throws
PermissionDeniedException
{
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()"
)
@PreAuthorize
(
"isAuthenticated()"
)
@RequestMapping
(
method
=
POST
,
value
=
"/{elementCollectionId}/remove"
)
@RequestMapping
(
method
=
POST
,
value
=
"/{elementCollectionId}/remove"
)
public
@ResponseBody
ModelActionPojo
removeElementCollectionItem
(
@PathVariable
String
elementCollectionId
,
@RequestParam
String
index
,
@RequestParam
String
id
,
HttpServletRequest
request
)
throws
PermissionDeniedException
{
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()"
)
@PreAuthorize
(
"isAuthenticated()"
)
...
@@ -205,6 +205,6 @@ public class ElementCollectionController extends BaseTranslationController {
...
@@ -205,6 +205,6 @@ public class ElementCollectionController extends BaseTranslationController {
logger
.
warn
(
"Failed to convert source for search hit"
,
e
);
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
()));
}
}
}
}
search-core/src/main/java/eu/dariah/de/search/controller/HomeController.java
View file @
9565156b
...
@@ -15,7 +15,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
...
@@ -15,7 +15,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
import
org.springframework.web.bind.annotation.RequestMethod
;