Contents
See also
BASE has support for storing files in two locations, the primary storage and
the secondary storage. The primary storage is always disk-based and must be
accessible by the BASE server as a path on the file system. The path to the
primary storage is configured by the userfiles
setting in the
base.config
file. The primary storage is internal to the core.
Client applications don't get access to read or manipulate the files directly
from the file system.
The secondary storage can be anything that can store files. It could for
example be another directory, a remote FTP server, or a tape based
archiving system. A file located in the secondary storage is not accessible
by the core or client applications. The secondary storage can only be accessed
by the secondary storage controller and the core (and client) applications uses
flags on the File
item to handle the interaction with the secondary
storage.
Each file has an action
attribute which default's to
File.Action.NOTHING
. It can take two other values:
File.Action.MOVE_TO_SECONDARY
File.Action.MOVE_TO_PRIMARY
All files with the action attribute set to MOVE_TO_SECONDARY
should be moved to the secondary storage by the controller, and all files
with the action attribute set to MOVE_TO_PRIMARY
should be
brought back to primary storage.
The moving of files between primary and secondary storage doesn't happen
immediately. It is up to the server administrator to configure how often
and at what times the controller should check for files that should be moved.
This is configured by the secondary.storage.interval
and
secondary.storage.time
settings in the base.config
file.
SecondaryStorageController
interface
All you have to do to create a secondary storage controller is
to create a class that implements the
SecondaryStorageController
interface. In your base.config
file you then specify the
class name in the secondary.storage.driver
setting and it's
initialisation parameters in the secondary.storage.driver
setting.
Your class must have a public no-argument constructor. The BASE application will create only one instance of the class for lifetime of the BASE server. Here are the methods that you must implement:
secondary.storage.driver
setting in your base.config
file. This method is only
called once for an object.
secondary.storage.interval
and
secondary.storage.time
settings in the base.config
file.
When this method is called the controller should:
action=MOVE_TO_SECONDARY
to the secondary storage. When the file has been moved call
File.setLocation(Location.SECONDARY)
to tell the core
that the file is now in the secondary storage. You should also call
File.setAction(File.Action.NOTHING)
to reset the action
attribute.
action=MOVE_TO_PRIMARY
.
The core will set the location attribute automatically, but
you should call File.setAction(File.Action.NOTHING)
to reset the
action attribute.
location=Location.SECONDARY
. This includes files
which has been deleted and files that have been moved offline or re-uploaded.
As a final act the method should send a message to each user owning files that has been moved from one location to the other. The message should include a list of files that has been moved to the secondary storage and a list of files moved from the secondary storage and a list of files that has been deleted due to some of the reasons above.
The configuration settings for the secondary storage controller is
located in the base.config
file. Here is an overview of
the settings. For more information read the
base.config reference
init()
method.