DMS access works somewhat like database access. You create a
DMS::Repository
object and use it as a kind of
"connection" to set/get files. Each repository instance represents a single
connection to the repository. It manages its own distinct set of locks on behalf
of the client. The DMS::Repository
class takes three
arguments:
A database connection connected to a database containing a DMS table.
The path to the file store (the root folder of the DMS file system).
The repository UUID.
The following illustrates creating a repository instance:
require 'jw/dbi' require 'jw/dms/repository' db = JW::DBI::Database.new() connected = db.open( host '127.0.0.1', db: 'docs.db', username: 'jujyfruit', password: 'yumyum', driver: 'QPSQL' ) if not connected puts db.error() end $path = '/path/to/dms/root' @uuid = '4ca89a4e-e649-11dc-b1f5-0019b96bd466' dms = JW::DMS::Repository.new(db, $path, uuid)
The repository UUID corresponds to the UUID of the repository identity
file. Each repository must have a single file whose sole contents
contain the UUID of the repository. This file is located in
{dmsroot}/000/001
. Furthermore, there has to be a record in
the database that points to this file whose guid
value
matches the UUID in the respository identity file. This mechanism ensures that
the database corresponds to the file store. Writing to a file store with a
different database would corrupt the file store and the database, most likely
beyond the capacity to accurately determine or reverse the damage. Thus, the
Repository
class's constructor always performs this check
and will throw an exception if the UUID does not match up with the contents of
the identity file. (Setting up the identity file is covered in Section 2, “Configuration”.)
The main Repository
class methods are listed in
Table 2.1, “Repository Methods”. The complete RDoc documentation is here.
Table 2.1. Repository Methods
Name | Description |
---|---|
| Registers a new file in the system. Takes a single
argument — |
| Opens the document with id of |
| Deletes a file from the system with the id given be
|
| Returns |
| Returns a read-only |
| Updates the metadata for the file whose id is given by
|
| Creates a repository directory structure on disk given by
|