Package com.logicaldoc.core.store

# 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 Summary

Modifier and Type
Method
Description
`int`
`compareTo(Store o)`
`void`
`destroy()`
Destroy method
`boolean`
`equals(Object obj)`
`byte[]`
`getBytes(StoreResource resource)`
Obtains the document's raw bytes for the specified resource
`ContextProperties`
`getConfig()`
`int`
`getId()`
The unique identifier
`Map<String,String>`
`getParameters()`
Returns the map of parameters
`Map<String,Store>`
`getStoreDefinitions()`
Retrieves the stores definitions grouped by type
`String`
`getString(StoreResource resource)`
Obtains the resource's content as string for the specified resource
`int`
`hashCode()`
`void`
`init()`
Initialization method
`boolean`
`isEnabled()`
Tests if the store is enabled
`Store`
`newStore(int id)`
Instantiate a new store and fully configures it.+
`void`
`setConfig(ContextProperties config)`
`void`
`setId(int id)`
Sets the unique identifier
`void`
`store(File file, StoreResource resource)`
Stores a file
`boolean`
`test()`
Tests if the store can read and write
`String`
`toString()`
`void`
`writeToFile(StoreResource resource, File out)`
Writes the specified resource in a file
`void`
`writeToStream(StoreResource resource, OutputStream output)`
Writes the specified resource in an output stream
`void`
`writeToStream(StoreResource resource, OutputStream output, long start, long length)`
Writes the specified resource in an output stream

### Methods inherited from class java.lang.Object

`getClass, notify, notifyAll, wait, wait, wait`

### Methods inherited from interface com.logicaldoc.core.store.Store

`delete, delete, exists, getBytes, getParameterNames, getStream, getTotalSize, listResources, moveResourcesToStore, size, store`

## 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, StoreResource resource) throws IOException
Description copied from interface: `Store`
Stores a file

Specified by:
  `store` in interface `Store`
Parameters:
  `file` - the file to store
  `resource` - Resource to be stored, make sure to provide the right document's ID
Throws:
  `IOException` - the content cannot be stored

### getBytes

public byte[] getBytes(StoreResource 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:
  `resource` - The resource
Returns:
  The document file's bytes
Throws:
  `IOException` - cannot open the resource to get the bytes

### writeToStream

public void writeToStream(StoreResource 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:
  `resource` - 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(StoreResource 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:
  `resource` - The resource
  `output` - The output stream
Throws:
  `IOException` - error writing the stream or reading the resource

### writeToFile

public void writeToFile(StoreResource resource, File out) throws IOException
Description copied from interface: `Store`
Writes the specified resource in a file

Specified by:
  `writeToFile` in interface `Store`
Parameters:
  `resource` - 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(StoreResource resource)
Description copied from interface: `Store`
Obtains the resource's content as string for the specified resource

Specified by:
  `getString` in interface `Store`
Parameters:
  `resource` - The resource
Returns:
  The document file's as string representation

### 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