Commit 678f3992 authored by Matija Obreza's avatar Matija Obreza

Log effective bytes storage configuration

parent 92a4715e
......@@ -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 (fileRepositoryDir != null) {
File repoDir = new File(fileRepositoryDir);
storageService.setRepositoryBaseDirectory(repoDir);
File repoDir;
if (StringUtils.isNotBlank(fileRepositoryDir)) {
repoDir = new File(fileRepositoryDir);
} 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.println("Using built-in keystore for FTP server /repository/ftpserver.jks");
LOG.warn("Using built-in keystore for FTP server /repository/ftpserver.jks");
ftpKeystorePath = getClass().getResource(DEFAULT_REPOSITORY_KEYSTORE_RESOURCE).getPath();
}
if (StringUtils.isBlank(ftpKeystorePwd)) {
System.err.println("Using built-in keystore password");
LOG.warn("Using built-in keystore password");
ftpKeystorePwd = DEFAULT_REPOSITORY_KEYSTORE_PASSWORD;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment