Class AbstractStorer

  • All Implemented Interfaces:
    Storer, Comparable<Storer>
    Direct Known Subclasses:
    FSStorer

    public abstract class AbstractStorer
    extends Object
    implements Storer
    Common methods for all the Storer implementations.
    Since:
    7.6.4
    Author:
    Marco Meschieri - LogicalDOC
    • Constructor Detail

      • AbstractStorer

        public AbstractStorer()
    • Method Detail

      • getId

        public int getId()
        Description copied from interface: Storer
        The unique identifier
        Specified by:
        getId in interface Storer
        Returns:
        the storer identifier
      • setId

        public void setId​(int id)
        Description copied from interface: Storer
        Sets the unique identifier
        Specified by:
        setId in interface Storer
        Parameters:
        id - the storer identifier
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object
      • getBytes

        public byte[] getBytes​(long docId,
                               String resource)
                        throws IOException
        Description copied from interface: Storer
        Obtains the document's raw bytes for the specified resource
        Specified by:
        getBytes in interface Storer
        Parameters:
        docId - The document's identifier
        resource - Name of the resource
        Returns:
        The document file's bytes
        Throws:
        IOException - cannot open the resource to get the bytes
      • writeToStream

        public void writeToStream​(long docId,
                                  String resource,
                                  OutputStream output,
                                  long start,
                                  long length)
                           throws IOException
        Description copied from interface: Storer
        Writes the specified resource in an output stream
        Specified by:
        writeToStream in interface Storer
        Parameters:
        docId - The document's identifier
        resource - Name of the resource
        output - The output stream
        start - Index of the starting byte
        length - Total packet length
        Throws:
        IOException - error writing the stream or reading the resource
      • writeToStream

        public void writeToStream​(long docId,
                                  String resource,
                                  OutputStream output)
                           throws IOException
        Description copied from interface: Storer
        Writes the specified resource in an output stream
        Specified by:
        writeToStream in interface Storer
        Parameters:
        docId - The document's identifier
        resource - Name of the resource
        output - The output stream
        Throws:
        IOException - error writing the stream or reading the resource
      • writeToFile

        public void writeToFile​(long docId,
                                String resource,
                                File out)
                         throws IOException
        Description copied from interface: Storer
        Writes the specified resource in a file
        Specified by:
        writeToFile in interface Storer
        Parameters:
        docId - The document identifier
        resource - Name of the resource
        out - File that will receive the resource's content
        Throws:
        IOException - error writing the file or reading the resource
      • getString

        public String getString​(long docId,
                                String resource)
        Description copied from interface: Storer
        Obtains the document's content as string for the specified resource
        Specified by:
        getString in interface Storer
        Parameters:
        docId - The document's identifier
        resource - Name of the resource
        Returns:
        The document file's as string representation
      • getResourceName

        public String getResourceName​(Document doc,
                                      String fileVersion,
                                      String suffix)
        Description copied from interface: Storer
        Computes the resource name inside the container
        Specified by:
        getResourceName in interface Storer
        Parameters:
        doc - The document representation
        fileVersion - The file version (use null for the latest version)
        suffix - The file suffix (use null if you want the exact document file)
        Returns:
        The document's resource name
      • getResourceName

        public String getResourceName​(long docId,
                                      String fileVersion,
                                      String suffix)
        Description copied from interface: Storer
        Computes the resource name inside the container
        Specified by:
        getResourceName in interface Storer
        Parameters:
        docId - The document identifier
        fileVersion - The file version (use null for the latest version)
        suffix - The file suffix (use null if you want the exact document file)
        Returns:
        The document's resource name
      • getParameters

        public Map<String,​String> getParameters()
        Description copied from interface: Storer
        Returns the map of parameters
        Specified by:
        getParameters in interface Storer
        Returns:
        a map with settings setting_name - setting_value
      • test

        public boolean test()
        Description copied from interface: Storer
        Tests if the storer can read and write
        Specified by:
        test in interface Storer
        Returns:
        if the storer can read and write
      • isEnabled

        public boolean isEnabled()
        Description copied from interface: Storer
        Tests if the storer is enabled
        Specified by:
        isEnabled in interface Storer
        Returns:
        if the storer is enabled
      • init

        public void init()
        Description copied from interface: Storer
        Initialization method
        Specified by:
        init in interface Storer
      • destroy

        public void destroy()
        Description copied from interface: Storer
        Destroy method
        Specified by:
        destroy in interface Storer