Class VaultFileImpl

  • All Implemented Interfaces:
    Dumpable, VaultFile

    public class VaultFileImpl
    extends Object
    implements VaultFile
    Implements the bridge between the repository based artifacts nodes and their file system representation as a collection of artifacts.
    • Field Detail

      • log

        protected static org.slf4j.Logger log
        The default logger
    • Constructor Detail

      • VaultFileImpl

        protected VaultFileImpl​(VaultFileSystem fs,
                                String rootPath,
                                VaultFileNode node)
                         throws javax.jcr.RepositoryException
        Internal constructor for the root file
        Parameters:
        fs - the file system
        rootPath - path of the root node
        node - the node
        Throws:
        javax.jcr.RepositoryException - if an error occurs
      • VaultFileImpl

        protected VaultFileImpl​(VaultFileSystem fs,
                                String name,
                                VaultFileNode node,
                                Artifact artifact)
                         throws javax.jcr.RepositoryException
        Internal constructor
        Parameters:
        fs - the file system
        name - the file entry name
        node - the node
        artifact - the underlying artifact. can be null
        Throws:
        javax.jcr.RepositoryException - if an error occurs
    • Method Detail

      • init

        protected void init​(VaultFileNode node,
                            Artifact a)
                     throws javax.jcr.RepositoryException
        (re)initializes this file
        Parameters:
        node - the artifacts node
        a - the artifact
        Throws:
        javax.jcr.RepositoryException - if an error occurs
      • getPath

        public String getPath()
        Description copied from interface: VaultFile
        Returns the os path
        Specified by:
        getPath in interface VaultFile
        Returns:
        the os path.
      • getName

        public String getName()
        Description copied from interface: VaultFile
        Returns the name of this file.
        Specified by:
        getName in interface VaultFile
        Returns:
        the name of this file.
      • getArtifact

        public Artifact getArtifact()
        Description copied from interface: VaultFile
        Returns the underlying artifact for this os file. If this file represents the Meta-Directory null is returned.
        Specified by:
        getArtifact in interface VaultFile
        Returns:
        the artifact or null.
      • isDirectory

        public boolean isDirectory()
        Description copied from interface: VaultFile
        Checks if this file is a directory.
        Specified by:
        isDirectory in interface VaultFile
        Returns:
        true if this file is a directory.
      • isTransient

        public boolean isTransient()
        Description copied from interface: VaultFile
        Checks if this file is transient. a file is transient if it's only used as hierarchical node for a deeper 'real' file. i.e.
        Specified by:
        isTransient in interface VaultFile
        Returns:
        true if this file is transient
      • getParent

        public VaultFileImpl getParent()
                                throws IOException,
                                       javax.jcr.RepositoryException
        Description copied from interface: VaultFile
        Returns the parent file or null if this is the root file.
        Specified by:
        getParent in interface VaultFile
        Returns:
        the parent file.
        Throws:
        IOException - if an I/O error occurs.
        javax.jcr.RepositoryException - if a repository error occurs.
      • getAggregate

        public Aggregate getAggregate()
        Description copied from interface: VaultFile
        Returns the artifacts node of this file or null if it's transient
        Specified by:
        getAggregate in interface VaultFile
        Returns:
        the artifacts node
      • getControllingAggregate

        public Aggregate getControllingAggregate()
        Description copied from interface: VaultFile
        Returns the aggregate that controls this file.
        Specified by:
        getControllingAggregate in interface VaultFile
        Returns:
        the artifacts node
      • getChild

        public VaultFileImpl getChild​(String name)
                               throws javax.jcr.RepositoryException
        Description copied from interface: VaultFile
        Returns the child with the given name or null
        Specified by:
        getChild in interface VaultFile
        Parameters:
        name - the name of the child
        Returns:
        the child or null
        Throws:
        javax.jcr.RepositoryException - if an error occurs
      • getChildren

        public Collection<? extends VaultFile> getChildren()
                                                    throws javax.jcr.RepositoryException
        Description copied from interface: VaultFile
        Returns a collection of the children
        Specified by:
        getChildren in interface VaultFile
        Returns:
        a collection of the children
        Throws:
        javax.jcr.RepositoryException - if an error occurs
      • addPendingNode

        protected void addPendingNode​(VaultFileNode n)
                               throws javax.jcr.RepositoryException
        Adds a node to the map of pending ones
        Parameters:
        n - the node
        Throws:
        javax.jcr.RepositoryException - if an error occurs
      • getOrAddChild

        protected VaultFileImpl getOrAddChild​(String name)
                                       throws javax.jcr.RepositoryException
        Returns the child of the given name or creates and adds a new one.
        Parameters:
        name - the name of the file
        Returns:
        the child
        Throws:
        javax.jcr.RepositoryException - if an error occurs
      • getRelated

        public Collection<? extends VaultFile> getRelated()
                                                   throws javax.jcr.RepositoryException
        Description copied from interface: VaultFile
        Returns the os file set for this file. The set contains those are the files that are generated from the same jcr file.
        Specified by:
        getRelated in interface VaultFile
        Returns:
        the file set of related files
        Throws:
        javax.jcr.RepositoryException - if an error occurs.
      • canRead

        public boolean canRead()
        Description copied from interface: VaultFile
        Checks if this file can be read from (eg. if it's not a directory)
        Specified by:
        canRead in interface VaultFile
        Returns:
        true if this file can be read from.
      • lastModified

        public long lastModified()
        Description copied from interface: VaultFile
        Returns the last modified date or 0 if not known.
        Specified by:
        lastModified in interface VaultFile
        Returns:
        the last modified date or 0
      • length

        public long length()
        Description copied from interface: VaultFile
        Returns the length of the serialized data if it's known without doing the actual serialization.
        Specified by:
        length in interface VaultFile
        Returns:
        the length or -1 if the length cannot be determined.
      • getContentType

        public String getContentType()
        Description copied from interface: VaultFile
        Returns the content type of this file or null if the type cannot be determined or if it's a directory.
        Specified by:
        getContentType in interface VaultFile
        Returns:
        the content type or null.
      • invalidate

        public void invalidate()
                        throws javax.jcr.RepositoryException
        Specified by:
        invalidate in interface VaultFile
        Throws:
        javax.jcr.RepositoryException
      • dump

        public void dump​(DumpContext ctx,
                         boolean isLast)
        Dumps some human readable information using the given context.
        Specified by:
        dump in interface Dumpable
        Parameters:
        ctx - the dump context
        isLast - specifies if this is the last element to dump on this level