Class AbstractStorer

java.lang.Object
com.logicaldoc.core.store.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
  • Method Details

    • getConfig

      public ContextProperties getConfig()
    • setConfig

      public void setConfig(ContextProperties config)
    • 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
    • compareTo

      public int compareTo(Storer o)
      Specified by:
      compareTo in interface Comparable<Storer>
    • hashCode

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

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
    • store

      public void store(File file, long docId, String resource) throws IOException
      Description copied from interface: Storer
      Stores a file
      Specified by:
      store in interface Storer
      Parameters:
      file - the file to store
      docId - identifier of the document
      resource - name of the resource
      Throws:
      IOException - the content cannot be stored
      See Also:
    • 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
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • init

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

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

      public Storer newStorer(int id)
      Instantiate a new storer and fully configures it.
      Specified by:
      newStorer in interface Storer
      Parameters:
      id - identifier of the storer to create
      Returns:
      the created instance
    • getStorerDefinitions

      public Map<String,Storer> getStorerDefinitions()
      Description copied from interface: Storer
      Retrieves the storers definitions grouped by type
      Specified by:
      getStorerDefinitions in interface Storer
      Returns:
      a map with definitions type - storer prototype