Interface Storer

  • All Superinterfaces:
    Comparable<Storer>
    All Known Implementing Classes:
    AbstractStorer, FSStorer

    public interface Storer
    extends Comparable<Storer>
    The Storer manages the repository where document files are maintained and all general resources are stored.
    Author:
    Michael Scholz, Marco Meschieri
    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      void delete​(long docId)
      Deletes all resources of a document from the storage.
      void delete​(long docId, String resource)
      Deletes a specific resource of a document from the storage.
      void destroy()
      Destroy method
      boolean exists​(long docId, String resource)
      Checks if the passed resource exists in the document's container
      byte[] getBytes​(long docId, String resource)
      Obtains the document's raw bytes for the specified resource
      byte[] getBytes​(long docId, String resource, long start, long length)
      Obtains the document's raw bytes for the specified resource
      int getId()
      The unique identifier
      List<String> getParameterNames()
      Implementations should return the list of the required parameters.
      Map<String,​String> getParameters()
      Returns the map of parameters
      String getResourceName​(long docId, String fileVersion, String suffix)
      Computes the resource name inside the container
      String getResourceName​(Document doc, String fileVersion, String suffix)
      Computes the resource name inside the container
      InputStream getStream​(long docId, String resource)
      Obtains the document's content for the specified resource
      String getString​(long docId, String resource)
      Obtains the document's content as string for the specified resource
      long getTotalSize()
      Computes the total size of the documents repository(in bytes)
      void init()
      Initialization method
      boolean isEnabled()
      Tests if the storer is enabled
      List<String> listResources​(long docId, String fileVersion)
      Lists all resources in the document's container
      void setId​(int id)
      Sets the unique identifier
      long size​(long docId, String resource)
      Computed the size of a specific resource.
      void store​(File file, long docId, String resource)
      Stores a file
      void store​(InputStream stream, long docId, String resource)
      This method has to store a resource in the document's container.
      boolean test()
      Tests if the storer can read and write
      void writeToFile​(long docId, String resource, File out)
      Writes the specified resource in a file
      void writeToStream​(long docId, String resource, OutputStream output)
      Writes the specified resource in an output stream
      void writeToStream​(long docId, String resource, OutputStream output, long start, long length)
      Writes the specified resource in an output stream
    • Method Detail

      • getId

        int getId()
        The unique identifier
        Returns:
        the storer identifier
      • setId

        void setId​(int id)
        Sets the unique identifier
        Parameters:
        id - the storer identifier
      • store

        void store​(InputStream stream,
                   long docId,
                   String resource)
        This method has to store a resource in the document's container. The location where (DBMS, Filesystem, other) the document should be stored is defined by the concrete implementation. It is possible to store a new document or a new version of an existing document.
        Parameters:
        stream - Document as InputStream
        docId - The document identifier
        resource - Name of the resource to be stored
      • delete

        void delete​(long docId)
        Deletes all resources of a document from the storage.
        Parameters:
        docId - The document identifier
      • delete

        void delete​(long docId,
                    String resource)
        Deletes a specific resource of a document from the storage.
        Parameters:
        docId - The document identifier
        resource - Name of the resource to be deleted
      • getResourceName

        String getResourceName​(Document doc,
                               String fileVersion,
                               String suffix)
        Computes the resource name inside the container
        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

        String getResourceName​(long docId,
                               String fileVersion,
                               String suffix)
        Computes the resource name inside the container
        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
      • listResources

        List<String> listResources​(long docId,
                                   String fileVersion)
        Lists all resources in the document's container
        Parameters:
        docId - The document's identifier
        fileVersion - If specified, lists the resources for that specific file version only
        Returns:
        list of resource names
      • size

        long size​(long docId,
                  String resource)
        Computed the size of a specific resource.
        Parameters:
        docId - The document's identifier
        resource - The resource
        Returns:
        the size in bytes
      • exists

        boolean exists​(long docId,
                       String resource)
        Checks if the passed resource exists in the document's container
        Parameters:
        docId - ID of the document
        resource - Name of the resource
        Returns:
        true only if the resource already exists
      • writeToFile

        void writeToFile​(long docId,
                         String resource,
                         File out)
                  throws IOException
        Writes the specified resource in a file
        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
      • writeToStream

        void writeToStream​(long docId,
                           String resource,
                           OutputStream output,
                           long start,
                           long length)
                    throws IOException
        Writes the specified resource in an output stream
        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

        void writeToStream​(long docId,
                           String resource,
                           OutputStream output)
                    throws IOException
        Writes the specified resource in an output stream
        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
      • getStream

        InputStream getStream​(long docId,
                              String resource)
        Obtains the document's content for the specified resource
        Parameters:
        docId - The document's identifier
        resource - Name of the resource
        Returns:
        The document file's content
      • getBytes

        byte[] getBytes​(long docId,
                        String resource)
        Obtains the document's raw bytes for the specified resource
        Parameters:
        docId - The document's identifier
        resource - Name of the resource
        Returns:
        The document file's bytes
      • getBytes

        byte[] getBytes​(long docId,
                        String resource,
                        long start,
                        long length)
        Obtains the document's raw bytes for the specified resource
        Parameters:
        docId - The document's identifier
        resource - Name of the resource
        start - Index of the starting byte
        length - Total packet length
        Returns:
        The document file's bytes
      • getString

        String getString​(long docId,
                         String resource)
        Obtains the document's content as string for the specified resource
        Parameters:
        docId - The document's identifier
        resource - Name of the resource
        Returns:
        The document file's as string representation
      • getTotalSize

        long getTotalSize()
        Computes the total size of the documents repository(in bytes)
        Returns:
        sum of the sizes of all the documents expressed in bytes
      • getParameterNames

        List<String> getParameterNames()
        Implementations should return the list of the required parameters. A parameter is stored in the context as storer.id.parameter = value
        Returns:
        list of parameter names
      • getParameters

        Map<String,​String> getParameters()
        Returns the map of parameters
        Returns:
        a map with settings setting_name - setting_value
      • test

        boolean test()
        Tests if the storer can read and write
        Returns:
        if the storer can read and write
      • isEnabled

        boolean isEnabled()
        Tests if the storer is enabled
        Returns:
        if the storer is enabled
      • init

        void init()
        Initialization method
      • destroy

        void destroy()
        Destroy method