Class VFSRegistryHelper


  • @ApplicationScoped
    public class VFSRegistryHelper
    extends Object
    Helper class for implementing the different VFS based registries that are backed by using VFSRegistryEntry elements.
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      static class  VFSRegistryHelper.BySuffixFilter
      Helper class for filtering files by a suffix.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void deleteBatch​(org.uberfire.java.nio.file.Path path)
      Deletes a path by performing a batch delete operation.
      org.uberfire.java.nio.file.Path ensureDirectory​(String directory)
      Ensure that an expected directory under the VFS registries host directory exists.
      protected void init()  
      String md5Hex​(String content)
      Helper method calculating the MD5 digest for a String.
      List<Object> readEntries​(org.uberfire.java.nio.file.Path rootPath, org.uberfire.java.nio.file.DirectoryStream.Filter<org.uberfire.java.nio.file.Path> filter)
      Reads a list of entries from a path by filtering the files by a given filter.
      Object readEntry​(org.uberfire.java.nio.file.Path path)
      Reads an Object previously marshalled and stored as a VFSRegistryEntry in a given path.
      void storeEntry​(org.uberfire.java.nio.file.Path path, Object value)
      Stores an Object marshalled value as a VFSRegistryEntry in the target path.
      void writeBatch​(org.uberfire.java.nio.file.Path path, String content)
      Writes a content on a target path by performing a batch delete operation.
    • Constructor Detail

      • VFSRegistryHelper

        public VFSRegistryHelper()
      • VFSRegistryHelper

        @Inject
        public VFSRegistryHelper​(VFSMarshallerRegistry marshallerRegistry,
                                 @Named("ioStrategy")
                                 org.uberfire.io.IOService ioService,
                                 @Named("systemFS")
                                 org.uberfire.java.nio.file.FileSystem fileSystem)
    • Method Detail

      • ensureDirectory

        public org.uberfire.java.nio.file.Path ensureDirectory​(String directory)
        Ensure that an expected directory under the VFS registries host directory exists.
        Parameters:
        directory - a directory name.
        Returns:
        the path to the directory.
      • md5Hex

        public String md5Hex​(String content)
        Helper method calculating the MD5 digest for a String.
        Parameters:
        content - a String value for calculating the digest.
        Returns:
        returns the digest as a 32 character hex string or the empty string "" if content == null.
      • storeEntry

        public void storeEntry​(org.uberfire.java.nio.file.Path path,
                               Object value)
                        throws Exception
        Stores an Object marshalled value as a VFSRegistryEntry in the target path.
        Parameters:
        path - a path for storing the generated VFSRegistryEntry.
        value - an object value to marshall and store.
        Throws:
        Exception - exceptions might be thrown in cases of filesystem or marshalling errors.
      • readEntry

        public Object readEntry​(org.uberfire.java.nio.file.Path path)
                         throws Exception
        Reads an Object previously marshalled and stored as a VFSRegistryEntry in a given path.
        Parameters:
        path - the path where the VFSRegistryEntry is stored.
        Returns:
        the unmarshalled object backed by the VFSRegistryEntry.
        Throws:
        Exception - exceptions might be thrown in cases of filesystem or marshalling errors.
      • readEntries

        public List<Object> readEntries​(org.uberfire.java.nio.file.Path rootPath,
                                        org.uberfire.java.nio.file.DirectoryStream.Filter<org.uberfire.java.nio.file.Path> filter)
                                 throws Exception
        Reads a list of entries from a path by filtering the files by a given filter.
        Parameters:
        rootPath - a path for looking of the VFSRegistryEntry files.
        filter - a filter for selecting the files.
        Returns:
        a list with the unmarshalled objects backed by the filtered files.
        Throws:
        Exception
      • writeBatch

        public void writeBatch​(org.uberfire.java.nio.file.Path path,
                               String content)
        Writes a content on a target path by performing a batch delete operation.
        Parameters:
        path - a path to write.
        content - a content to write.
      • deleteBatch

        public void deleteBatch​(org.uberfire.java.nio.file.Path path)
        Deletes a path by performing a batch delete operation.
        Parameters:
        path - a path to delete.