Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Genesys PGR
Genesys Backend
Commits
678f3992
Commit
678f3992
authored
Sep 25, 2017
by
Matija Obreza
Browse files
Log effective bytes storage configuration
parent
92a4715e
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/main/java/org/genesys2/spring/config/FileRepositoryConfig.java
View file @
678f3992
...
...
@@ -20,6 +20,7 @@ import java.io.File;
import
java.util.ArrayList
;
import
java.util.List
;
import
org.apache.commons.io.FileUtils
;
import
org.apache.commons.lang.StringUtils
;
import
org.apache.ftpserver.ftplet.Authentication
;
import
org.apache.ftpserver.ftplet.AuthenticationFailedException
;
...
...
@@ -63,6 +64,7 @@ import org.springframework.web.multipart.commons.CommonsMultipartResolver;
*/
@Configuration
public
class
FileRepositoryConfig
implements
InitializingBean
{
public
static
final
Logger
LOG
=
LoggerFactory
.
getLogger
(
ApplicationConfig
.
class
);
private
static
final
String
DEFAULT_REPOSITORY_KEYSTORE_RESOURCE
=
"/repository/ftpserver.jks"
;
private
static
final
String
DEFAULT_REPOSITORY_KEYSTORE_PASSWORD
=
"changeit!"
;
...
...
@@ -103,6 +105,7 @@ public class FileRepositoryConfig implements InitializingBean {
public
BytesStorageService
bytesStorageService
()
{
if
(
StringUtils
.
isNotBlank
(
s3AccessKey
))
{
// We have some S3 configuration, let's do that!
LOG
.
warn
(
"Initializing S3 bytes storage"
);
return
new
S3StorageServiceImpl
();
}
else
{
// Stick to FS storage
...
...
@@ -113,13 +116,16 @@ public class FileRepositoryConfig implements InitializingBean {
private
BytesStorageService
fileSystemStorage
()
{
FilesystemStorageServiceImpl
storageService
=
new
FilesystemStorageServiceImpl
();
if
(
f
ile
R
epo
sitoryDir
!=
null
)
{
File
repoDir
=
new
File
(
fileRepositoryDir
)
;
storageService
.
setRepositoryBaseDirectory
(
repo
Dir
);
F
ile
r
epo
Dir
;
if
(
StringUtils
.
isNotBlank
(
fileRepositoryDir
)
)
{
repoDir
=
new
File
(
fileRepository
Dir
);
}
else
{
// Using tmpdir
storageService
.
setRepositoryBaseDirectory
(
new
File
(
System
.
getProperty
(
"java.io.tmpdir"
)));
repoDir
=
new
File
(
FileUtils
.
getTempDirectory
(),
"repository"
);
}
LOG
.
warn
(
"Initializing filesystem bytes storage at base path={}"
,
repoDir
.
getAbsolutePath
());
storageService
.
setRepositoryBaseDirectory
(
repoDir
);
return
storageService
;
}
...
...
@@ -274,12 +280,12 @@ public class FileRepositoryConfig implements InitializingBean {
@Override
public
void
afterPropertiesSet
()
throws
Exception
{
if
(
StringUtils
.
isBlank
(
ftpKeystorePath
))
{
System
.
err
.
printl
n
(
"Using built-in keystore for FTP server /repository/ftpserver.jks"
);
LOG
.
war
n
(
"Using built-in keystore for FTP server /repository/ftpserver.jks"
);
ftpKeystorePath
=
getClass
().
getResource
(
DEFAULT_REPOSITORY_KEYSTORE_RESOURCE
).
getPath
();
}
if
(
StringUtils
.
isBlank
(
ftpKeystorePwd
))
{
System
.
err
.
printl
n
(
"Using built-in keystore password"
);
LOG
.
war
n
(
"Using built-in keystore password"
);
ftpKeystorePwd
=
DEFAULT_REPOSITORY_KEYSTORE_PASSWORD
;
}
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment