Class AbstractStore

java.lang.Object
com.logicaldoc.core.store.AbstractStore
All Implemented Interfaces:
Store, Comparable<Store>
Direct Known Subclasses:
FSStore

public abstract class AbstractStore extends Object implements Store
Common methods for all the Store 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: Store
      The unique identifier
      Specified by:
      getId in interface Store
      Returns:
      the store identifier
    • setId

      public void setId(int id)
      Description copied from interface: Store
      Sets the unique identifier
      Specified by:
      setId in interface Store
      Parameters:
      id - the store identifier
    • compareTo

      public int compareTo(Store o)
      Specified by:
      compareTo in interface Comparable<Store>
    • 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: Store
      Stores a file
      Specified by:
      store in interface Store
      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: Store
      Obtains the document's raw bytes for the specified resource
      Specified by:
      getBytes in interface Store
      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: Store
      Writes the specified resource in an output stream
      Specified by:
      writeToStream in interface Store
      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: Store
      Writes the specified resource in an output stream
      Specified by:
      writeToStream in interface Store
      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: Store
      Writes the specified resource in a file
      Specified by:
      writeToFile in interface Store
      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: Store
      Obtains the document's content as string for the specified resource
      Specified by:
      getString in interface Store
      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: Store
      Computes the resource name inside the container
      Specified by:
      getResourceName in interface Store
      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: Store
      Computes the resource name inside the container
      Specified by:
      getResourceName in interface Store
      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: Store
      Returns the map of parameters
      Specified by:
      getParameters in interface Store
      Returns:
      a map with settings setting_name - setting_value
    • test

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

      public boolean isEnabled()
      Description copied from interface: Store
      Tests if the store is enabled
      Specified by:
      isEnabled in interface Store
      Returns:
      if the store is enabled
    • toString

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

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

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

      public Store newStore(int id)
      Instantiate a new store and fully configures it.+
      Specified by:
      newStore in interface Store
      Parameters:
      id - identifier of the store to create
      Returns:
      the created instance
    • getStoreDefinitions

      public Map<String,Store> getStoreDefinitions()
      Description copied from interface: Store
      Retrieves the stores definitions grouped by type
      Specified by:
      getStoreDefinitions in interface Store
      Returns:
      a map with definitions type - store prototype