0

I am using Spring Content https://paulcwarren.github.io/spring-content/ for managing files. There is method that I use for setting content

public interface ContentStore<S, SID extends Serializable> extends ContentRepository<S, SID> {

@LockParticipant
void setContent(S property, InputStream content);

The problem is that I want to create a custom method

void setArchivedContent(S property, List<Resource> resources);

This should take ZIP resources to one file. So I've created

public interface ArchiveStore<S, SID extends Serializable> extends ContentRepository<S, SID> {

implemented it in a place where standard methods are implemented and add an interface to Store

public class GoogleCloudStoreImpl<S, SID extends Serializable>
implements Store<SID>, AssociativeStore<S, SID>, ContentStore<S, SID>, ArchiveStore<S, SID> 

public interface MyEntryArchiveStore extends ContentStore<MyEntryArchive, UUID>,
AssociativeStore<MyEntryArchive, UUID>, ArchiveStore<MyEntryArchive, UUID> {

When I run code and try to trigger this method, I face a problem: Spring cannot find Implementation of this method. But it is in GoogleCloudStoreImpl

1 Answers1

1

Spring Content supports the same composability for stores as Spring Data for repositories. So, if you want to decorate your content store with additional methods you would:

  • create your custom interface and implementation class
interface ArchiveStore<S> {
  void setArchivedContent(S property, List<Resource> resources);
}
package com.examples.archival;

public class ArchiveStoreImpl<S> implements ArchiveStore<S> {
  public void setArchivedContent(S property, List<Resource> resources) {
     ...
  } 
}
  • make you regular content store implement the above interface
package com.example.mystores;

interface MyStore extends ContentStore<MyEntity, UUID> extends ArchiveStore<MyEntity> {}
  • make sure your implementation class can be found by the store bean factory by adding the package that you implementation lives in to your @EnableXXXStores annotation.
@Configuration
@EnableFilesystemStores(basePackages={"com.example.mystores", "com.examples.archival"})
Paul Warren
  • 2,411
  • 1
  • 15
  • 22