Package org.guvnor.ala.registry.vfs
Class VFSRegistryHelper
- java.lang.Object
-
- org.guvnor.ala.registry.vfs.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 classVFSRegistryHelper.BySuffixFilterHelper class for filtering files by a suffix.
-
Field Summary
Fields Modifier and Type Field Description protected static StringPROVISIONING_BRANCHprotected static StringPROVISIONING_PATH
-
Constructor Summary
Constructors Constructor Description VFSRegistryHelper()VFSRegistryHelper(VFSMarshallerRegistry marshallerRegistry, org.uberfire.io.IOService ioService, org.uberfire.java.nio.file.FileSystem fileSystem)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voiddeleteBatch(org.uberfire.java.nio.file.Path path)Deletes a path by performing a batch delete operation.org.uberfire.java.nio.file.PathensureDirectory(String directory)Ensure that an expected directory under the VFS registries host directory exists.protected voidinit()Stringmd5Hex(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.ObjectreadEntry(org.uberfire.java.nio.file.Path path)Reads an Object previously marshalled and stored as a VFSRegistryEntry in a given path.voidstoreEntry(org.uberfire.java.nio.file.Path path, Object value)Stores an Object marshalled value as a VFSRegistryEntry in the target path.voidwriteBatch(org.uberfire.java.nio.file.Path path, String content)Writes a content on a target path by performing a batch delete operation.
-
-
-
Field Detail
-
PROVISIONING_BRANCH
protected static final String PROVISIONING_BRANCH
- See Also:
- Constant Field Values
-
PROVISIONING_PATH
protected static final String PROVISIONING_PATH
- See Also:
- Constant Field Values
-
-
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
-
init
@PostConstruct protected void init()
-
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 ExceptionStores 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.
-
-