Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Genesys Backend
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
19
Issues
19
List
Boards
Labels
Service Desk
Milestones
Operations
Operations
Incidents
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Genesys PGR
Genesys Backend
Commits
7f295600
Commit
7f295600
authored
Oct 07, 2017
by
Matija Obreza
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Renamed classes in org.genesys2.spring.config
parent
de2322f5
Changes
20
Hide whitespace changes
Inline
Side-by-side
Showing
20 changed files
with
217 additions
and
208 deletions
+217
-208
src/main/java/org/genesys2/spring/config/ApplicationConfig.java
...in/java/org/genesys2/spring/config/ApplicationConfig.java
+9
-12
src/main/java/org/genesys2/spring/config/CacheConfig.java
src/main/java/org/genesys2/spring/config/CacheConfig.java
+19
-19
src/main/java/org/genesys2/spring/config/CommonConfig.java
src/main/java/org/genesys2/spring/config/CommonConfig.java
+8
-9
src/main/java/org/genesys2/spring/config/DatabaseConfig.java
src/main/java/org/genesys2/spring/config/DatabaseConfig.java
+15
-15
src/main/java/org/genesys2/spring/config/ElasticsearchConfig.java
.../java/org/genesys2/spring/config/ElasticsearchConfig.java
+11
-11
src/main/java/org/genesys2/spring/config/ElasticsearchConfigAWS.java
...va/org/genesys2/spring/config/ElasticsearchConfigAWS.java
+7
-7
src/main/java/org/genesys2/spring/config/ElasticsearchConfigDev.java
...va/org/genesys2/spring/config/ElasticsearchConfigDev.java
+9
-11
src/main/java/org/genesys2/spring/config/FileRepositoryConfig.java
...java/org/genesys2/spring/config/FileRepositoryConfig.java
+15
-15
src/main/java/org/genesys2/spring/config/HazelcastConfig.java
...main/java/org/genesys2/spring/config/HazelcastConfig.java
+44
-46
src/main/java/org/genesys2/spring/config/MailConfig.java
src/main/java/org/genesys2/spring/config/MailConfig.java
+8
-8
src/main/java/org/genesys2/spring/config/NewGUIViewResolver.java
...n/java/org/genesys2/spring/config/NewGUIViewResolver.java
+19
-17
src/main/java/org/genesys2/spring/config/OAuth2ServerConfig.java
...n/java/org/genesys2/spring/config/OAuth2ServerConfig.java
+4
-4
src/main/java/org/genesys2/spring/config/SchedulerConfig.java
...main/java/org/genesys2/spring/config/SchedulerConfig.java
+7
-7
src/main/java/org/genesys2/spring/config/SecurityConfig.java
src/main/java/org/genesys2/spring/config/SecurityConfig.java
+13
-16
src/main/java/org/genesys2/spring/config/SwaggerConfig.java
src/main/java/org/genesys2/spring/config/SwaggerConfig.java
+18
-3
src/main/java/org/genesys2/spring/config/WebConfiguration.java
...ain/java/org/genesys2/spring/config/WebConfiguration.java
+4
-1
src/main/java/org/genesys2/spring/config/WebInitializer.java
src/main/java/org/genesys2/spring/config/WebInitializer.java
+1
-1
src/test/java/org/genesys2/server/test/BatchRESTServiceTest.java
...t/java/org/genesys2/server/test/BatchRESTServiceTest.java
+2
-2
src/test/java/org/genesys2/server/test/TaxonomyEnsureTest.java
...est/java/org/genesys2/server/test/TaxonomyEnsureTest.java
+2
-2
src/test/java/org/genesys2/tests/BaseSpringTest.java
src/test/java/org/genesys2/tests/BaseSpringTest.java
+2
-2
No files found.
src/main/java/org/genesys2/spring/config/ApplicationConfig.java
View file @
7f295600
/*
*
* Copyright 201
4
Global Crop Diversity Trust
*
/*
* Copyright 201
7
Global Crop Diversity Trust
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*
/
*/
package
org.genesys2.spring.config
;
...
...
@@ -39,8 +39,8 @@ import org.springframework.core.io.FileSystemResource;
import
org.springframework.core.io.Resource
;
@Configuration
@Import
({
SpringCommonConfig
.
class
,
SpringSchedulerConfig
.
class
,
SpringDataBas
eConfig
.
class
,
SpringMailConfig
.
class
,
OAuth2ServerConfig
.
class
,
SecurityConfig
.
class
,
SpringCacheConfig
.
class
,
ElasticsearchConfig
.
class
,
FileRepositoryConfig
.
class
,
WebConfiguration
.
class
})
@Import
({
CommonConfig
.
class
,
SchedulerConfig
.
class
,
DatabaseConfig
.
class
,
MailConfig
.
class
,
OAuth2ServerConfig
.
class
,
SecurityConfig
.
class
,
Cach
eConfig
.
class
,
ElasticsearchConfig
.
class
,
FileRepositoryConfig
.
class
,
WebConfiguration
.
class
})
public
class
ApplicationConfig
{
public
static
final
Log
LOG
=
LogFactory
.
getLog
(
ApplicationConfig
.
class
);
...
...
@@ -53,7 +53,6 @@ public class ApplicationConfig {
public
BrAPIService
brapiService
()
{
return
new
BrAPIServiceImpl
();
}
@Bean
public
static
PropertyPlaceholderConfigurer
propertyPlaceholderConfigurer
()
{
...
...
@@ -80,7 +79,6 @@ public class ApplicationConfig {
propertyPlaceholderConfigurer
.
setLocations
(
locations
.
toArray
(
new
Resource
[]
{}));
return
propertyPlaceholderConfigurer
;
}
@Bean
public
ResourceBundleMessageSource
messageSource
()
{
...
...
@@ -90,14 +88,13 @@ public class ApplicationConfig {
source
.
setUseCodeAsDefaultMessage
(
true
);
return
source
;
}
/**
* localeURLFilter in web.xml: en es de fr fa ar ru zh pt
*/
@Bean
public
static
Set
<
String
>
supportedLocales
()
{
final
Set
<
String
>
supportedLocales
=
new
HashSet
<
String
>();
final
Set
<
String
>
supportedLocales
=
new
HashSet
<>();
supportedLocales
.
add
(
"en"
);
supportedLocales
.
add
(
"es"
);
supportedLocales
.
add
(
"de"
);
...
...
src/main/java/org/genesys2/spring/config/
Spring
CacheConfig.java
→
src/main/java/org/genesys2/spring/config/CacheConfig.java
View file @
7f295600
/*
*
* Copyright 201
4
Global Crop Diversity Trust
*
/*
* Copyright 201
7
Global Crop Diversity Trust
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*
/
*/
package
org.genesys2.spring.config
;
...
...
@@ -38,7 +38,7 @@ import org.springframework.security.core.session.SessionRegistryImpl;
@Configuration
@EnableCaching
@Import
({
HazelcastConfig
.
class
})
public
class
Spring
CacheConfig
{
public
class
CacheConfig
{
@Value
(
"${hazelcast.instanceName}"
)
protected
String
instanceName
=
"genesys"
;
...
...
@@ -52,36 +52,36 @@ public class SpringCacheConfig {
private
String
cookieHttpOnly
;
@Bean
public
HazelcastCacheManager
cacheManager
(
HazelcastInstance
hazelcastInstance
)
{
HazelcastCacheManager
cm
=
new
HazelcastCacheManager
(
hazelcastInstance
);
public
HazelcastCacheManager
cacheManager
(
final
HazelcastInstance
hazelcastInstance
)
{
final
HazelcastCacheManager
cm
=
new
HazelcastCacheManager
(
hazelcastInstance
);
return
cm
;
}
@Bean
public
IMap
<
Object
,
Object
>
tileserverMap
(
HazelcastInstance
hazelcast
)
{
IMap
<
Object
,
Object
>
x
=
hazelcast
.
getMap
(
"tileserver"
);
public
IMap
<
Object
,
Object
>
tileserverMap
(
final
HazelcastInstance
hazelcast
)
{
final
IMap
<
Object
,
Object
>
x
=
hazelcast
.
getMap
(
"tileserver"
);
return
x
;
}
@Bean
public
IQueue
<
Object
>
elasticRemoveQueue
(
HazelcastInstance
hazelcast
)
{
public
IQueue
<
Object
>
elasticRemoveQueue
(
final
HazelcastInstance
hazelcast
)
{
return
hazelcast
.
getQueue
(
"es-remove"
);
}
@Bean
public
IQueue
<
Object
>
elasticUpdateQueue
(
HazelcastInstance
hazelcast
)
{
public
IQueue
<
Object
>
elasticUpdateQueue
(
final
HazelcastInstance
hazelcast
)
{
return
hazelcast
.
getQueue
(
"es-update"
);
}
@Bean
public
IExecutorService
distributedExecutor
(
HazelcastInstance
hazelcast
)
{
IExecutorService
executorService
=
hazelcast
.
getExecutorService
(
"hazel-exec"
);
public
IExecutorService
distributedExecutor
(
final
HazelcastInstance
hazelcast
)
{
final
IExecutorService
executorService
=
hazelcast
.
getExecutorService
(
"hazel-exec"
);
return
executorService
;
}
@Bean
public
IMap
<
String
,
AttemptStatistics
>
accountLockoutMap
(
HazelcastInstance
hazelcast
)
{
IMap
<
String
,
AttemptStatistics
>
x
=
hazelcast
.
getMap
(
"accountLocks"
);
public
IMap
<
String
,
AttemptStatistics
>
accountLockoutMap
(
final
HazelcastInstance
hazelcast
)
{
final
IMap
<
String
,
AttemptStatistics
>
x
=
hazelcast
.
getMap
(
"accountLocks"
);
return
x
;
}
...
...
@@ -89,7 +89,7 @@ public class SpringCacheConfig {
public
WebFilter
hazelcastWebFilter
()
{
return
new
SpringAwareWebFilter
(
filterProps
());
}
@Bean
public
SessionRegistry
SessionRegistry
()
{
return
new
SessionRegistryImpl
();
...
...
src/main/java/org/genesys2/spring/config/
Spring
CommonConfig.java
→
src/main/java/org/genesys2/spring/config/CommonConfig.java
View file @
7f295600
/**
* Copyright 2014 Global Crop Diversity Trust
*
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
...
...
@@ -18,6 +18,9 @@ package org.genesys2.spring.config;
import
javax.persistence.Entity
;
import
com.fasterxml.jackson.databind.DeserializationFeature
;
import
com.fasterxml.jackson.databind.SerializationFeature
;
import
org.genesys2.spring.validation.oval.spring.SpringOvalValidator
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.context.annotation.Bean
;
...
...
@@ -32,15 +35,11 @@ import org.springframework.security.web.access.expression.DefaultWebSecurityExpr
import
org.springframework.stereotype.Controller
;
import
org.springframework.validation.Validator
;
import
com.fasterxml.jackson.databind.DeserializationFeature
;
import
com.fasterxml.jackson.databind.SerializationFeature
;
@EnableAspectJAutoProxy
@ComponentScan
(
basePackages
=
{
"org.genesys2.spring"
,
"org.genesys2.server"
},
excludeFilters
=
{
@ComponentScan
.
Filter
(
value
=
Controller
.
class
,
type
=
FilterType
.
ANNOTATION
),
@ComponentScan
(
basePackages
=
{
"org.genesys2.spring"
,
"org.genesys2.server"
},
excludeFilters
=
{
@ComponentScan
.
Filter
(
value
=
Controller
.
class
,
type
=
FilterType
.
ANNOTATION
),
@ComponentScan
.
Filter
(
value
=
Configuration
.
class
,
type
=
FilterType
.
ANNOTATION
)
},
includeFilters
=
@ComponentScan
.
Filter
(
value
=
Entity
.
class
,
type
=
FilterType
.
ANNOTATION
))
@Configuration
public
class
Spring
CommonConfig
{
public
class
CommonConfig
{
@Autowired
private
AclPermissionEvaluator
aclPermissionEvaluator
;
...
...
src/main/java/org/genesys2/spring/config/
SpringDataB
aseConfig.java
→
src/main/java/org/genesys2/spring/config/
Datab
aseConfig.java
View file @
7f295600
/*
*
* Copyright 201
4
Global Crop Diversity Trust
*
/*
* Copyright 201
7
Global Crop Diversity Trust
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*
/
*/
package
org.genesys2.spring.config
;
...
...
@@ -43,7 +43,7 @@ import liquibase.integration.spring.SpringLiquibase;
@EnableJpaAuditing
(
auditorAwareRef
=
"auditorAware"
)
@EnableTransactionManagement
@Configuration
public
class
SpringDataB
aseConfig
{
public
class
Datab
aseConfig
{
@Value
(
"${db.url}"
)
private
String
dbUrl
;
...
...
@@ -80,7 +80,7 @@ public class SpringDataBaseConfig {
private
int
maxActive
;
// max allowed age for any connection
private
long
maxAgeSeconds
=
60
*
5
;
private
final
long
maxAgeSeconds
=
60
*
5
;
@Value
(
"${db.pool.maxIdleSeconds}"
)
private
int
maxIdleSeconds
;
...
...
@@ -108,13 +108,13 @@ public class SpringDataBaseConfig {
}
@Bean
public
JdbcTemplate
jdbcTemplate
(
DataSource
dataSource
)
{
public
JdbcTemplate
jdbcTemplate
(
final
DataSource
dataSource
)
{
return
new
JdbcTemplate
(
dataSource
);
}
@Bean
(
name
=
"databaseMigration"
)
public
SpringLiquibase
databaseMigration
()
{
SpringLiquibase
liquibase
=
new
SpringLiquibase
();
final
SpringLiquibase
liquibase
=
new
SpringLiquibase
();
// Run controlled database migration only when not generating schema
// automatically
liquibase
.
setShouldRun
(!
dbGenerateDdl
);
...
...
@@ -125,14 +125,14 @@ public class SpringDataBaseConfig {
@Bean
(
name
=
"entityManagerFactory"
)
@DependsOn
(
"databaseMigration"
)
public
LocalContainerEntityManagerFactoryBean
entityManagerFactory
(
HazelcastCacheRegionFactoryWrapper
wrp
)
throws
Exception
{
public
LocalContainerEntityManagerFactoryBean
entityManagerFactory
(
final
HazelcastCacheRegionFactoryWrapper
wrp
)
throws
Exception
{
final
LocalContainerEntityManagerFactoryBean
entityManager
=
new
LocalContainerEntityManagerFactoryBean
();
entityManager
.
setDataSource
(
dataSource
());
entityManager
.
setPersistenceUnitName
(
"spring-jpa"
);
entityManager
.
setJpaVendorAdapter
(
jpaVendorAdapter
());
entityManager
.
setPersistenceProvider
(
new
HibernatePersistenceProvider
());
Properties
jpaProperties
=
jpaProperties
();
for
(
Object
key
:
jpaProperties
.
keySet
())
{
final
Properties
jpaProperties
=
jpaProperties
();
for
(
final
Object
key
:
jpaProperties
.
keySet
())
{
System
.
err
.
println
(
"JPA: "
+
key
+
" = "
+
jpaProperties
.
get
(
key
));
}
entityManager
.
setJpaProperties
(
jpaProperties
);
...
...
@@ -143,7 +143,7 @@ public class SpringDataBaseConfig {
}
@Bean
public
JpaTransactionManager
transactionManager
(
DataSource
dataSource
,
EntityManagerFactory
emf
)
{
public
JpaTransactionManager
transactionManager
(
final
DataSource
dataSource
,
final
EntityManagerFactory
emf
)
{
final
JpaTransactionManager
transactionManager
=
new
JpaTransactionManager
();
transactionManager
.
setDataSource
(
dataSource
);
transactionManager
.
setEntityManagerFactory
(
emf
);
...
...
@@ -151,7 +151,7 @@ public class SpringDataBaseConfig {
}
private
Properties
jpaProperties
()
throws
Exception
{
Properties
jpaProp
=
new
Properties
();
final
Properties
jpaProp
=
new
Properties
();
jpaProp
.
load
(
getClass
().
getResourceAsStream
(
"/hibernate.properties"
));
jpaProp
.
put
(
"hibernate.dialect"
,
hibernateDialect
);
return
jpaProp
;
...
...
src/main/java/org/genesys2/spring/config/ElasticsearchConfig.java
View file @
7f295600
/*
*
* Copyright 201
4
Global Crop Diversity Trust
*
/*
* Copyright 201
7
Global Crop Diversity Trust
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*
/
*/
package
org.genesys2.spring.config
;
...
...
@@ -37,8 +37,8 @@ import org.springframework.data.elasticsearch.repository.config.EnableElasticsea
public
class
ElasticsearchConfig
{
@Bean
public
ElasticsearchTemplate
elasticsearchTemplate
(
Client
client
,
EntityMapper
entityMapper
)
{
ElasticsearchTemplate
t
=
new
ElasticsearchTemplate
(
client
,
entityMapper
);
public
ElasticsearchTemplate
elasticsearchTemplate
(
final
Client
client
,
final
EntityMapper
entityMapper
)
{
final
ElasticsearchTemplate
t
=
new
ElasticsearchTemplate
(
client
,
entityMapper
);
return
t
;
}
...
...
@@ -49,7 +49,7 @@ public class ElasticsearchConfig {
public
class
GenesysEntityMapper
implements
EntityMapper
{
private
ObjectMapper
objectMapper
;
private
final
ObjectMapper
objectMapper
;
public
GenesysEntityMapper
()
{
objectMapper
=
new
ObjectMapper
();
...
...
@@ -60,12 +60,12 @@ public class ElasticsearchConfig {
}
@Override
public
String
mapToString
(
Object
object
)
throws
IOException
{
public
String
mapToString
(
final
Object
object
)
throws
IOException
{
return
objectMapper
.
writeValueAsString
(
object
);
}
@Override
public
<
T
>
T
mapToObject
(
String
source
,
Class
<
T
>
clazz
)
throws
IOException
{
public
<
T
>
T
mapToObject
(
final
String
source
,
final
Class
<
T
>
clazz
)
throws
IOException
{
return
objectMapper
.
readValue
(
source
,
clazz
);
}
}
...
...
src/main/java/org/genesys2/spring/config/ElasticsearchConfigAWS.java
View file @
7f295600
/*
*
* Copyright 201
4
Global Crop Diversity Trust
*
/*
* Copyright 201
7
Global Crop Diversity Trust
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*
/
*/
package
org.genesys2.spring.config
;
...
...
@@ -35,7 +35,7 @@ public class ElasticsearchConfigAWS {
@Bean
public
TransportClientFactoryBean
tcfb
()
{
System
.
out
.
println
(
"Setting up external ES cluster.name="
+
clusterName
+
" and nodes="
+
clusterNodes
);
TransportClientFactoryBean
tcfb
=
new
TransportClientFactoryBean
();
final
TransportClientFactoryBean
tcfb
=
new
TransportClientFactoryBean
();
tcfb
.
setClusterName
(
clusterName
);
tcfb
.
setClusterNodes
(
clusterNodes
);
tcfb
.
setClientPingTimeout
(
"10s"
);
...
...
src/main/java/org/genesys2/spring/config/ElasticsearchConfigDev.java
View file @
7f295600
/*
*
* Copyright 201
4
Global Crop Diversity Trust
*
/*
* Copyright 201
7
Global Crop Diversity Trust
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*
/
*/
package
org.genesys2.spring.config
;
import
static
org
.
elasticsearch
.
node
.
NodeBuilder
.
*
;
import
static
org
.
elasticsearch
.
node
.
NodeBuilder
.
nodeBuilder
;
import
org.elasticsearch.client.node.NodeClient
;
import
org.elasticsearch.common.settings.ImmutableSettings
;
...
...
@@ -43,10 +43,8 @@ public class ElasticsearchConfigDev {
@Bean
public
NodeClient
nodeClient
()
{
ImmutableSettings
.
Builder
settings
=
ImmutableSettings
.
settingsBuilder
().
put
(
"http.enabled"
,
String
.
valueOf
(
this
.
enableHttp
)).
put
(
"path.home"
,
this
.
dataPath
);
final
ImmutableSettings
.
Builder
settings
=
ImmutableSettings
.
settingsBuilder
().
put
(
"http.enabled"
,
String
.
valueOf
(
this
.
enableHttp
)).
put
(
"path.home"
,
this
.
dataPath
);
return
(
NodeClient
)
nodeBuilder
().
settings
(
settings
).
clusterName
(
this
.
clusterName
).
local
(
true
).
node
()
.
client
();
return
(
NodeClient
)
nodeBuilder
().
settings
(
settings
).
clusterName
(
this
.
clusterName
).
local
(
true
).
node
().
client
();
}
}
src/main/java/org/genesys2/spring/config/FileRepositoryConfig.java
View file @
7f295600
...
...
@@ -114,7 +114,7 @@ public class FileRepositoryConfig implements InitializingBean {
}
private
BytesStorageService
fileSystemStorage
()
{
FilesystemStorageServiceImpl
storageService
=
new
FilesystemStorageServiceImpl
();
final
FilesystemStorageServiceImpl
storageService
=
new
FilesystemStorageServiceImpl
();
File
repoDir
;
if
(
StringUtils
.
isNotBlank
(
fileRepositoryDir
))
{
...
...
@@ -131,7 +131,7 @@ public class FileRepositoryConfig implements InitializingBean {
@Bean
public
CommonsMultipartResolver
multipartResolver
()
{
CommonsMultipartResolver
resolver
=
new
CommonsMultipartResolver
();
final
CommonsMultipartResolver
resolver
=
new
CommonsMultipartResolver
();
resolver
.
setDefaultEncoding
(
"utf-8"
);
return
resolver
;
}
...
...
@@ -178,7 +178,7 @@ public class FileRepositoryConfig implements InitializingBean {
@Bean
public
RepositoryFtpServer
ftpServer
()
{
RepositoryFtpServer
ftpServer
=
new
RepositoryFtpServer
();
final
RepositoryFtpServer
ftpServer
=
new
RepositoryFtpServer
();
ftpServer
.
setFtpPort
(
ftpServerPort
);
ftpServer
.
setUserManager
(
ftpUserManager
());
...
...
@@ -202,16 +202,16 @@ public class FileRepositoryConfig implements InitializingBean {
private
UserService
userService
;
@Override
public
void
save
(
User
user
)
throws
FtpException
{
public
void
save
(
final
User
user
)
throws
FtpException
{
// Noop
}
@Override
public
User
getUserByName
(
String
username
)
throws
FtpException
{
FtpUser
user
=
new
FtpUser
(
username
);
public
User
getUserByName
(
final
String
username
)
throws
FtpException
{
final
FtpUser
user
=
new
FtpUser
(
username
);
// user.setPassword(username + "1!");
user
.
setEnabled
(
true
);
List
<
Authority
>
authorities
=
new
ArrayList
<>();
final
List
<
Authority
>
authorities
=
new
ArrayList
<>();
authorities
.
add
(
new
ConcurrentLoginPermission
(
10
,
0
));
authorities
.
add
(
new
WritePermission
());
user
.
setAuthorities
(
authorities
);
...
...
@@ -225,26 +225,26 @@ public class FileRepositoryConfig implements InitializingBean {
}
@Override
public
boolean
doesExist
(
String
username
)
throws
FtpException
{
public
boolean
doesExist
(
final
String
username
)
throws
FtpException
{
return
userService
.
getUserByEmail
(
username
)
!=
null
;
}
@Override
public
void
delete
(
String
username
)
throws
FtpException
{
public
void
delete
(
final
String
username
)
throws
FtpException
{
// Noop
}
@Override
public
User
authenticate
(
Authentication
authentication
)
throws
AuthenticationFailedException
{
public
User
authenticate
(
final
Authentication
authentication
)
throws
AuthenticationFailedException
{
if
(
authentication
instanceof
UsernamePasswordAuthentication
)
{
UsernamePasswordAuthentication
upauth
=
(
UsernamePasswordAuthentication
)
authentication
;
final
UsernamePasswordAuthentication
upauth
=
(
UsernamePasswordAuthentication
)
authentication
;
String
username
=
upauth
.
getUsername
();
final
String
username
=
upauth
.
getUsername
();
String
password
=
upauth
.
getPassword
();
org
.
genesys2
.
server
.
model
.
impl
.
User
user
=
userService
.
getUserByEmail
(
upauth
.
getUsername
());
final
org
.
genesys2
.
server
.
model
.
impl
.
User
user
=
userService
.
getUserByEmail
(
upauth
.
getUsername
());
if
(
user
==
null
||
!
user
.
isActive
()
||
user
.
isAccountLocked
()
||
user
.
isAccountExpired
()
||
!
user
.
isEnabled
()
||
user
.
isPasswordExpired
())
{
if
(
(
user
==
null
)
||
!
user
.
isActive
()
||
user
.
isAccountLocked
()
||
user
.
isAccountExpired
()
||
!
user
.
isEnabled
()
||
user
.
isPasswordExpired
())
{
// user not found
throw
new
AuthenticationFailedException
(
"Authentication failed"
);
}
...
...
@@ -262,7 +262,7 @@ public class FileRepositoryConfig implements InitializingBean {
LOG
.
info
(
"FTP login successful for {}"
,
username
);
try
{
return
getUserByName
(
username
);
}
catch
(
FtpException
e
)
{
}
catch
(
final
FtpException
e
)
{
LOG
.
warn
(
"FTP login failed"
,
e
);
throw
new
AuthenticationFailedException
(
e
.
getMessage
(),
e
);
}
...
...
src/main/java/org/genesys2/spring/config/HazelcastConfig.java
View file @
7f295600
/*
* Copyright 2017 Global Crop Diversity Trust
*
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
...
...
@@ -51,7 +51,7 @@ import org.springframework.context.annotation.Configuration;
@Configuration
@EnableCaching
public
abstract
class
HazelcastConfig
{
protected
final
Logger
LOG
=
LoggerFactory
.
getLogger
(
HazelcastConfig
.
class
);
/// Interfaces on which HZ should bind
...
...
@@ -75,13 +75,13 @@ public abstract class HazelcastConfig {
@Value
(
"${cache.defaultCacheSize}"
)
protected
int
defaultCacheSize
;
@Value
(
"${cache.time-to-live-seconds}"
)
private
int
cacheTimeToLiveSeconds
;
@Value
(
"${cache.max-idle-seconds}"
)
private
int
cacheMaxIdleSeconds
;
@Value
(
"${cache.eviction-policy}"
)
protected
EvictionPolicy
cacheEvictionPolicy
;
...
...
@@ -89,18 +89,17 @@ public abstract class HazelcastConfig {
public
ManagedContext
managedContext
()
{
return
new
SpringManagedContext
();
}
@Value
(
"${hazelcast.members}"
)
private
List
<
String
>
hazelcastMembers
;
@Bean
public
HazelcastInstance
hazelcast
(
ManagedContext
managedContext
)
{
Config
cfg
=
new
Config
();
public
HazelcastInstance
hazelcast
(
final
ManagedContext
managedContext
)
{
final
Config
cfg
=
new
Config
();
cfg
.
setManagedContext
(
managedContext
);
cfg
.
setInstanceName
(
instanceName
);
GroupConfig
groupConfig
=
cfg
.
getGroupConfig
();
final
GroupConfig
groupConfig
=
cfg
.
getGroupConfig
();
groupConfig
.
setName
(
name
);
groupConfig
.
setPassword
(
password
);
...
...
@@ -109,32 +108,32 @@ public abstract class HazelcastConfig {
cfg
.
setProperty
(
"hazelcast.logging.type"
,
"log4j"
);
cfg
.
setProperty
(
"hazelcast.icmp.enabled"
,
"true"
);
NetworkConfig
network
=
cfg
.
getNetworkConfig
();
final
NetworkConfig
network
=
cfg
.
getNetworkConfig
();
network
.
setPort
(
hazelPort
);
network
.
setPortAutoIncrement
(
true
);
if
(
StringUtils
.
isNotBlank
(
hazelPublicAddress
))
{
System
.
out
.
println
(
"Hazelcast: Using public address "
+
hazelPublicAddress
);
try
{
InetAddress
ipAddress
=
InetAddress
.
getByName
(
hazelPublicAddress
);
final
InetAddress
ipAddress
=
InetAddress
.
getByName
(
hazelPublicAddress
);
LOG