What I want: I'd like to move content from one ContentStore
(regular) to another ContentStore
(e.g. an archive) with Spring-Content
version 1.2.7.
What I did is this (and it does work at least with DefaultFilesystemStoreImpl
s):
- Creating two
ContentStore
s like this:
@Bean(name = "mytmpfsstore1")
public ContentStore<File, String> getFileContentStore1() {
FileSystemResourceLoader loader = new FileSystemResourceLoader(".\\tmpstore1");
PlacementService placementService = new PlacementServiceImpl();
return new DefaultFilesystemStoreImpl<File, String>(loader, placementService, new FileServiceImpl());
}
- Moving content from one
ContentStore
to another like this:
Optional<File> fileEntity = filesRepo.findById(id);
if (fileEntity.isPresent()) {
Resource resource = regularContentStore.getResource(fileEntity.get());
archiveContentStore.setContent(fileEntity.get(), resource);
filesRepo.save(fileEntity.get());
if (resource instanceof DeletableResource) {
((DeletableResource) resource).delete();
}
}
Question: Is this the intended way of moving (/archiving) content with Spring-Content
or is there a more elegant / more convenient / more intended way of moving/archiving files (especially from filesystem to S3 and back again)?