API:EPrints/Repository

From EPrints Documentation
Revision as of 18:29, 11 August 2009 by Tdb01r (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Latest Source Code (3.3, 3.2) | Revision Log | Before editing this page please read Pod2Wiki

NAME

EPrints::Repository - A single eprint repository

DESCRIPTION

This class is a single eprint repository with its own configuration, database and website.

new

 $repository = EPrints::Repository->new( $id, [$noxml] )

Returns the repository with the given repository ID. If $noxml is specified then it skips loading the XML based configuration files (this is needed when creating an repository as it first has to create the DTD files, and if it can't start you have a catch 22 situtation).

new_from_request

 $repository = EPrints::Repository->new_from_request( $request )

This creates a new repository object. It looks at the given Apache request object and decides which repository to load based on the value of the PerlVar "EPrints_ArchiveID".

Aborts with an error if this is not possible.

get_language

 $language = $repository->get_language( [$langid] )

Returns the EPrints::Language for the requested language id (or the default for this repository if $langid is not specified).

get_template_parts

 $template = $repository->get_template_parts( $langid, [$template_id] )

Returns an array of utf-8 strings alternating between XML and the id of a pin to replace. This is used for the faster template construction.

get_template

 $template = $repository->get_template( $langid, [$template_id] )

Returns the DOM document which is the webpage template for the given language. Do not modify the template without cloning it first.

get_types

 @type_ids = $repository->get_types( $type_set )

Return an array of keys for the named set. Comes from /cfg/types/foo.xml

get_dataset

 $dataset = $repository->get_dataset( $setname )

Returns the cached EPrints::DataSet with the given dataset id name.

get_conf

 $confitem = $repository->get_conf( $key, [@subkeys] )

Returns a named configuration setting. Probably set in ArchiveConfig.pm

$repository->get_conf( "stuff", "en", "foo" )

is equivalent to

$repository->get_conf( "stuff" )->{en}->{foo}

log

 $repository->log( $msg )

Calls the log method from ArchiveConfig.pm for this repository with the given parameters. Basically logs the comments wherever the site admin wants them to go. Printed to STDERR by default.

call

 $result = $repository->call( $cmd, @params )

Calls the subroutine named $cmd from the configuration perl modules for this repository with the given params and returns the result.

can_call

 $boolean = $repository->can_call( @cmd_conf_path )

Return true if the given subroutine exists in this repository's config package.

try_call

 $result = $repository->try_call( $cmd, @params )

Calls the subroutine named $cmd from the configuration perl modules for this repository with the given params and returns the result.

If the subroutine does not exist then quietly returns undef.

This is used to call deprecated callback subroutines.

get_store_dirs

 @dirs = $repository->get_store_dirs

Returns a list of directories available for storing documents. These may well be symlinks to other hard drives.

get_store_dir_size

 $size = $repository->get_store_dir_size( $dir )

Returns the current storage (in bytes) used by a given documents dir. $dir should be one of the values returned by $repository->get_store_dirs.

This should not be called if disable_df is set in SystemSettings.

parse_xml

 $domdocument = $repository->parse_xml( $file, $no_expand );

Turns the given $file into a XML DOM document. If $no_expand is true then load &entities; but do not expand them to the values in the DTD.

This function also sets the path in which the Parser will look for DTD files to the repository's config directory.

Returns undef if an error occurs during parsing.

get_id

 $id = $repository->get_id 

Returns the id string of this repository.

exec

 $returncode = $repository->exec( $cmd_id, %map )

Executes a system command. $cmd_id is the id of the command as set in SystemSettings and %map contains a list of things to "fill in the blanks" in the invocation line in SystemSettings.

invocation

 $commandstring = $repository->invocation( $cmd_id, %map )

Finds the invocation for the specified command from SystemSetting and fills in the blanks using %map. Returns a string which may be executed as a system call.

All arguments are ESCAPED using quotemeta() before being used (i.e. don't pre-escape arguments in %map).

get_field_defaults

 $defaults = $repository->get_field_defaults( $fieldtype )

Return the cached default properties for this metadata field type. or undef.

set_field_defaults

 $repository->set_field_defaults( $fieldtype, $defaults )

Cache the default properties for this metadata field type.

generate_dtd

 $success = $repository->generate_dtd

Regenerate the DTD file for each language. This file is used when loading some of the XML files. It contains entities such as &ruler; and &adminemail; which make maintaining the XML files easier.

The entites in the DTD file are configured by get_entities in the ArchiveConfig.pm module.

Returns true. Might return false on error (not checking yet).

test_config

 ( $returncode, $output) = $repository->test_config

This runs "epadmin test" as an external script to test if the current configuraion on disk loads OK. This can be used by the web interface to test if changes to config. files may be saved, or not.

$returncode will be zero if everything seems OK.

If not, then $output will contain the output of epadmin test

UNDOCUMENTED METHODS

Warning These methods were found in the source code but didn't have any POD associated with them. This may be because we haven't got around to documenting them yet or it could be because they are internal to the API and not intended for use by other parts of EPrints.

can_execute

can_invoke

check_secure_dirs

freshen_citation

freshen_template

get_citation_spec

get_citation_type

get_plugin_class

get_plugin_ids

get_workflow_config

new_archive_by_id