Skip to content
This repository has been archived by the owner on Aug 10, 2021. It is now read-only.

ModelSEED Store Private

Scott Devoid edited this page May 4, 2012 · 2 revisions

ModelSEED::Store::Private

Base storage interface layer; not for public use.

NOTE

DO NOT USE Directly! This class has a complete, unauthenticated access to the datastore. While the datastore is designed to limit the visibility of objects to particular users, this class does nothing to prevent people from accessing data. The "user" is passed into each API function, therefore there is no assumption of security when using this interface. Use ModelSEED::Store instead.

Initialization

new

my $PStore = ModelSEED::Store::Private->new(\%)

Initialize a private storage interface object. This accepts a hash reference to configuration details. There are no current configuration options.

User Functions

These functions manipulate user objects within the storage layer. Since a user must be defined for almost every call into the storage interface, these functions are critical to add, remove or inspect user objects.

create_user

$PStore->create_user($user);

Creates a user object. $user is a ModelSEED::MS::User object.

get_user

$PStore->get_user($username);

Returns a ModelSEED::MS::User object. If no user is found, returns undef.

delete_user

$PStore->delete_user($username);

Removes the user object from the storage interface. Not that this has wide-ranging affects; that user will no longer be able to access objects within the Store. This does not delete objects owned by that user, however.

Object Methods

These functions deal with checking for the existence of, getting and saving objects. In most cases, objects are assumed to be instances of classes under the ModelSEED::MS hierarchy. For each of these functions, $username is the user's login name, a string. $type is a string representing the type of the object, e.g. "biochemistry". $alias is a string, representing a unique pointer to an object in the datastore. These generally have the form "$username/arbitraryString".

has_object

$ps->has_object($username, $type, $alias);

Returns a boolean, true if the the object exists in the datastore.

get_object

$ps->get_object($username, $type, $alias);

Returns a ModelSEED::MS object of the type $type or undef if no object exists.

save_object

$ps->save_object($username, $type, $alias, $object);

Saves $object, a ModelSEED::MS object of the correct $type to the datastore at $alias. Note that if there was an object already at $alias, this does not overwrite that object, but changes the reference $alias to point to the new object, $object.

delete_object

$ps->delete_object($username, $type, $alias);

Removes the alias pointer $alias that points to an object in the datastore. This does not actually remove the object, but it will no longer be accessible via that alias.

Data Methods

These methods are like the Object Methods, except that they return raw Perl data-structures instead of ModelSEED::MS objects.

get_data

$ps->get_data($username, $type, $alias);

Same as get_object except that it is not marshaled into an object.

Querying

Getting a specific object is good, but sometimes we need to query what objects are available. These functions allow for different types of queries against the data store.

get_aliases_for_type

$ps->get_aliases_for_type($username, $type);

get_metadata

$ps->get_metadata($username, $type, $alias, $selection);

set_metadata

$ps->set_metadata($username, $type, $alias, $selection, $metadata);

remove_metadata

$ps->remove_metadata($username, $type, $alias, $selection);

find_objects

$ps->find_objects($username, $type, $query);

Returns an iterator which allows you to individually access the objects, or gather them all into an array (interface to come)

Permissions: Editing and Viewing

Permissions are handled via the "alias" attribute and the following functions. As an overview, any object with an alias like $username/aribtraryString is "owned" by $username. That user may perform a save_object call against the alias. No other users may do this. So we have single-user write-access to objects.

For visibility, by default an object is only visible by the owner. However, using the following functions, an owner may extend visibility to other users. Finally, an object may be "public", visible to all users.

add_viewer

$ps->add_viewer($username, $type, $alias, $viewerUsername);

$username must be the owner of the object of $type, $alias. This extends viewing permissions to $viewerUsername.

remove_viewer

$ps->remove_viewer($username, $type, $alias, $viewerUsername);

$username must be the owner of the object of $type, $alias. This retracts viewing permissions to $viewerUsername.

set_public

$ps->set_public($username, $type, $alias, $bool);

$username must be the owner of the object of $type, $alias. This sets the public bit of the object to $bool.