use of org.molgenis.data.file.FileStore in project molgenis by molgenis.
the class MolgenisWebAppConfig method fileStore.
@Bean
public FileStore fileStore() {
// get molgenis home directory
String molgenisHomeDir = System.getProperty(MOLGENIS_HOME);
if (molgenisHomeDir == null) {
throw new IllegalArgumentException(String.format("missing required java system property '%s'", MOLGENIS_HOME));
}
if (!molgenisHomeDir.endsWith(File.separator))
molgenisHomeDir = molgenisHomeDir + File.separator;
// create molgenis store directory in molgenis data directory if not exists
String molgenisFileStoreDirStr = molgenisHomeDir + "data" + File.separator + "filestore";
File molgenisDataDir = new File(molgenisFileStoreDirStr);
if (!molgenisDataDir.exists() && !molgenisDataDir.mkdirs()) {
throw new RuntimeException("failed to create directory: " + molgenisFileStoreDirStr);
}
return new FileStore(molgenisFileStoreDirStr);
}
use of org.molgenis.data.file.FileStore in project molgenis by molgenis.
the class RestServiceTest method setUpBeforeMethod.
@BeforeMethod
public void setUpBeforeMethod() {
dataService = mock(DataService.class);
idGenerator = mock(IdGenerator.class);
FileStore fileStore = mock(FileStore.class);
fileMetaFactory = mock(FileMetaFactory.class);
entityManager = mock(EntityManager.class);
servletUriComponentsBuilderFactory = mock(ServletUriComponentsBuilderFactory.class);
this.restService = new RestService(dataService, idGenerator, fileStore, fileMetaFactory, entityManager, servletUriComponentsBuilderFactory);
}
use of org.molgenis.data.file.FileStore in project molgenis by molgenis.
the class AmazonBucketClientImplTest method setUp.
@BeforeTest
public void setUp() {
client = mock(AmazonS3Client.class);
fileStore = mock(FileStore.class);
s3Object = mock(S3Object.class);
httpRequestBase = mock(HttpRequestBase.class);
amazonBucketClient = new AmazonBucketClientImpl();
}
use of org.molgenis.data.file.FileStore in project molgenis by molgenis.
the class FileTestConfig method fileStore.
@Bean
public FileStore fileStore() {
// get molgenis home directory
String currentDir = System.getProperty("java.io.tmpdir") + File.separator + UUID.randomUUID().toString().replaceAll("-", "");
if (!currentDir.endsWith(File.separator)) {
currentDir = currentDir + File.separator;
}
// create molgenis store directory in molgenis data directory if not exists
String molgenisFileStoreDirStr = currentDir + "data" + File.separator + "filestore";
File molgenisDataDir = new File(molgenisFileStoreDirStr);
if (!molgenisDataDir.exists() && !molgenisDataDir.mkdirs()) {
throw new RuntimeException("failed to create directory: " + molgenisFileStoreDirStr);
}
return new FileStore(molgenisFileStoreDirStr);
}
use of org.molgenis.data.file.FileStore in project molgenis by molgenis.
the class MolgenisWebAppConfig method addResourceHandlers.
@Override
public void addResourceHandlers(ResourceHandlerRegistry registry) {
int cachePeriod;
if (environment.equals("development")) {
cachePeriod = 0;
} else {
// a year
cachePeriod = 31536000;
}
registry.addResourceHandler(PATTERN_CSS).addResourceLocations("/css/", "classpath:/css/").setCachePeriod(cachePeriod);
registry.addResourceHandler(PATTERN_IMG).addResourceLocations("/img/", "classpath:/img/").setCachePeriod(cachePeriod);
registry.addResourceHandler(PATTERN_JS).addResourceLocations("/js/", "classpath:/js/").setCachePeriod(cachePeriod);
registry.addResourceHandler(PATTERN_FONTS).addResourceLocations("/fonts/", "classpath:/fonts/").setCachePeriod(cachePeriod);
registry.addResourceHandler(PATTERN_SWAGGER).addResourceLocations("/swagger/", "classpath:/swagger/").setCachePeriod(cachePeriod);
registry.addResourceHandler("/generated-doc/**").addResourceLocations("/generated-doc/").setCachePeriod(3600);
registry.addResourceHandler("/html/**").addResourceLocations("/html/", "classpath:/html/").setCachePeriod(3600);
// Add resource handler for apps
FileStore fileStore = fileStore();
registry.addResourceHandler("/" + PATH_SEGMENT_APPS + "/**").addResourceLocations("file:///" + fileStore.getStorageDir() + '/' + FILE_STORE_PLUGIN_APPS_PATH + '/');
registry.addResourceHandler("/webjars/**").addResourceLocations("classpath:/META-INF/resources/webjars/").setCachePeriod(3600).resourceChain(true);
// see https://github.com/spring-projects/spring-boot/issues/4403 for why the resourceChain needs to be explicitly added.
}
Aggregations