Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
    Piotr Chłystek
    @pchlystek
    Resource it's a Entity class from my package, coincidence of names is accidental.
    In addition to spring-content-fs, I want spring-content-s3 (depending on deployment (and configuration) - onpremises / kubernetes installation), I want to keep files in other places.
    After adding the s3 starter to the application, the autoconfiguration does not create a ContentStore bean - ResourceContentStore.
    Piotr Chłystek
    @pchlystek
    Thank you for your interest in the problem.
    Paul Warren
    @paulcwarren
    Got it. Thanks for the clarifications. Then I think you are headed in the right direction. You should add both storage module dependencies. But because you have both that means Spring Content will enter a "strict" mode when parsing for Stores; i.e. because you have two storage modules on the classpath it wont know what implementation you want for ResourceContenStore so you will need to tell it by adding two stores that extend the implementation-specific ContentStores; i.e. FilesystemResourceContentStore extends FilesystemContentStoreand S3ResourceContentStore extends S3ContentStore. That will have a bit of a ripple effect into your storageService bean initializor methods but SpringContentStorageService can be typed to just ContentStore. I believe that might work for you.
    Also, Spring Content REST should work on top of this too (in case you are using it)
    Piotr Chłystek
    @pchlystek
    I confirm that the solution proposed by you works. Thank you very much for your help!
    Paul Warren
    @paulcwarren
    Excellent. Glad I could help
    乐哥
    @lmtoo
    workingCopy need unlock?
    I have a newContentCopy method ,which to handle workingCopy and locking
    like this ```java
        public static <T, ID extends Serializable> T newContentCopy(LockingAndVersioningRepository<T, ID> repository, T content, Consumer<T> onNewCopy) {
            content = repository.lock(content);
            try {
                T newContent = repository.workingCopy(content);
                try {
                    onNewCopy.accept(newContent);
                    return newContent;
                } finally {
                    repository.unlock(newContent);
                }
            } finally {
                repository.unlock(content);
            }
        }
    but , this will have too many ObjectOptimisticLockingFailureException, which is the right coding about this?
    I should return newContent or content ? which is latest version ?
    乐哥
    @lmtoo
    @paulcwarren
    Paul Warren
    @paulcwarren
    You should return newContent. BUT, I wouldn't expect an unlock before version is called.
    A working copy is meant to be a private working copy that only you can see. If you unlock someone else could then lock content and create another working copy. I am not sure that I have tested that! My assumption has always been that the lock extends across newWorkinCopy and version but that said, perhaps unlock should throw an error if a working copy exists.
    乐哥
    @lmtoo
    repository.unlock(newContent); will have a new version newContent , but if I change to ```java
    public static <T, ID extends Serializable> T newContentCopy(LockingAndVersioningRepository<T, ID> repository, T content, Predicate<T> predicate, Consumer<T> onNewCopy) {
        content = repository.lock(content);
        try {
            if (predicate.test(content)){
                T newContent = repository.workingCopy(content);
                try {
                    onNewCopy.accept(newContent);
                } finally {
                   return repository.unlock(newContent);
                }
            }
        } finally {
            repository.unlock(content);
        }
        return null;
    }```java
    IDEA will have >'return' inside 'finally' block
    'return' inside 'finally' block
    Paul Warren
    @paulcwarren
    newWorkingCopy creates a new object but but only partially sets it up in the version series. So unlocking immediately will leave it partially established. You should call version then unlock.
    Or alternatively, just call version instead on newWorkingCopy as it looks like you have no need for a real private working copy that can be edited multiple times and saved before versioning?
    乐哥
    @lmtoo
    'newWorkingCopy'? you mean LockingAndVersioningRepository.workingCopy?
    Paul Warren
    @paulcwarren
    Yes, sorry! Don't know my own code
    The more I look at your example the more I think you should be calling version, not workingCopy. Working copies is a construct brought over from CMIS and is meant for use cases where you have a user that will want to edit their 'word doc' many times before versioning it. Your code suggests you dont want working copies. You just want to version
    乐哥
    @lmtoo
    so, workingCopy will create a record to locks table? and version will not? workingCopy will have long time locking? version will have short time locking?
    yes, I will do that , thanks
    Paul Warren
    @paulcwarren
    lock and unlock create the entries in the locks table. Both workingCopy and version will transfer the lock to the new entity in the version series.
    are you trying to do automatic versioning? because I recently added support to spring content for spring data envers
    乐哥
    @lmtoo
    I just want to have new version entity, and handle lock and unlock
    Paul Warren
    @paulcwarren
    K. Spring data envers will automatically create a new version of an entity whenever you save it. And with the support in spring-content it will do that for every setContent operation too. This is all done through save and setContent and because it is handled by hibernate removes the need for the pessimistic locking. It is more of an auditing thing but I mention it because it might be a better solution for you, depending on your use case.
    Paul Warren
    @paulcwarren
    If that is of interest let me know as i need to document and cut a release to actually get it out there
    Luke Herron
    @lukeherron
    Hi @paulcwarren , I'm curious to know if its possible for renditions to process a collection of resources from a JPA content store? Have been testing renditions and it works really well but I have a use case where I'm looking to merge multiple related resources and render a single output.
    11 replies
    乐哥
    @lmtoo
    Hi @paulcwarren , when the @SuccessorId field be set, LockingAndVersioningRepository.version can't create new version from a nonleaf version?
    Paul Warren
    @paulcwarren
    That sounds right. We support a version series only at the moment. Not a version tree.
    Sounds like you need a version tree?
    乐哥
    @lmtoo
    yes , version tree
    workingCopy doesn't set @SuccessorId, I think I have to use this method
    If I don't have field annotated with @SuccessorId, Is version can replaced with workingCopy?
    Paul Warren
    @paulcwarren
    That's what it should do, yes. The idea is that the user creates a workingCopy that only they can see/edit and when they are ready (i.e. several days/edits later) they version that workingCopy and it becomes available to everyone.
    But it is a version series, not a tree I never intended workingCopy to be used as a version tree. I am not sure how you would do that actually. But if it works for you then great.
    乐哥
    @lmtoo
    I need to restore to history content when process is returned , and then create new version copy on that version
    Paul Warren
    @paulcwarren
    That should be what workingCopy does. The editor should get the workingCopy content. Everyone else should get the original content until it is versioned
    乐哥
    @lmtoo
    thanks.
    Paul Warren
    @paulcwarren
    But now you mention it I cant remember creating those tests actually so let me go check whether, or not, we have them. I can point you at them as a reference
    sumannewindia
    @sumannewindia
    Hi @paulcwarren - Does Spring content has "store support" for "Google cloud storage" also? I can find examples for Amazon S3 only.
    12 replies
    Holothuroid
    @Holothuroid
    Hi. I'm looking at spring content filesystem. Is there a way to customize the file paths? My customers would like the files be sorted by project and month for example. Is that possible with this library?
    4 replies
    Leon Galushko
    @leonaugust
    Hi. I have a problem, Hibernate generates 3 queries to fetch image for each product.
    How can we optimize image fetching? I created the question at stackoverflow with project that replicates the issue and generated queries https://stackoverflow.com/questions/65791927/spring-content-hibernate-executes-3-queries-to-fetch-image-for-each-product
    5 replies
    Martin Sefcik
    @martinsefcik
    Hi, are there any plans to replace aws sdk to version 2.0 ?
    12 replies