Difference between revisions of "API:EPrints/Repository"

From EPrints Documentation
Jump to: navigation, search
Line 25: Line 25:
 
The Repository object also knows about the current apache connection, if there is one, including the CGI parameters.  
 
The Repository object also knows about the current apache connection, if there is one, including the CGI parameters.  
  
If the connection requires a username and password then it can also  give access to the EPrints::DataObj::User object representing the user who is causing this request. See current_user().
+
If the connection requires a username and password then it can also  give access to the [[API:EPrints/DataObj/User|EPrints::DataObj::User]] object representing the user who is causing this request. See current_user().
  
The Repository object also provides access to the XHTML class which contains many methods for creating XHTML results which can be returned via the web  interface.  
+
The Repository object also provides access to the [[API:EPrints/XHTML|EPrints::XHTML]] class which contains many methods for creating XHTML results which can be returned via the web  interface.  
  
 
<div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce;  padding: 0em 1em 0em 1em; font-size: 80%; '>
 
<div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce;  padding: 0em 1em 0em 1em; font-size: 80%; '>
Line 38: Line 38:
 
<!-- Pod2Wiki=head_methods -->
 
<!-- Pod2Wiki=head_methods -->
 
==METHODS==
 
==METHODS==
 +
<div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce;  padding: 0em 1em 0em 1em; font-size: 80%; '>
 +
<span style='display:none'>User Comments</span>
 +
<!-- Edit below this comment -->
 +
 +
 +
<!-- Pod2Wiki= -->
 +
</div>
 +
<!-- Pod2Wiki=item_new -->
 +
===new===
 +
 +
$repository = EPrints::Repository-&gt;new( %opts )
 +
Creates and returns a new repository object. This is a utility object only and will only have the basic system configuration available.
 +
 +
<div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce;  padding: 0em 1em 0em 1em; font-size: 80%; '>
 +
<span style='display:none'>User Comments</span>
 +
<!-- Edit below this comment -->
 +
 +
 +
<!-- Pod2Wiki= -->
 +
</div>
 +
<!-- Pod2Wiki=item_new -->
 +
===new===
 +
 +
$repository = EPrints::Repository-&gt;new( $repository_id, %opts )
 +
Create a connection to an EPrints repository $repository_id which provides access to the database and to the repository configuration.
 +
 +
Options:
 +
 +
  db_connect - 1
 +
  check_db - 1
 +
  noise - 0
 +
 
 
<div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce;  padding: 0em 1em 0em 1em; font-size: 80%; '>
 
<div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce;  padding: 0em 1em 0em 1em; font-size: 80%; '>
 
<span style='display:none'>User Comments</span>
 
<span style='display:none'>User Comments</span>
Line 50: Line 82:
 
  $query = $repository-&gt;query
 
  $query = $repository-&gt;query
 
Return the {{API:PodLink|file=CGI|package_name=CGI|section=|text=CGI}} object describing the current HTTP query, or  undefined if this isn't a CGI script.
 
Return the {{API:PodLink|file=CGI|package_name=CGI|section=|text=CGI}} object describing the current HTTP query, or  undefined if this isn't a CGI script.
 +
 +
<div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce;  padding: 0em 1em 0em 1em; font-size: 80%; '>
 +
<span style='display:none'>User Comments</span>
 +
<!-- Edit below this comment -->
 +
 +
 +
<!-- Pod2Wiki= -->
 +
</div>
 +
<!-- Pod2Wiki=item_param -->
 +
===param===
 +
 +
$value or @values = $repository-&gt;param( $name )
 +
Passes through to CGI.pm param method.
 +
 +
$value = $repository-&gt;param( $name ): returns the value of CGI parameter $name.
 +
 +
$value = $repository-&gt;param( $name ): returns the value of CGI parameter $name.
 +
 +
@values = $repository-&gt;param: returns an array of the names of all the CGI parameters in the current request.
  
 
<div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce;  padding: 0em 1em 0em 1em; font-size: 80%; '>
 
<div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce;  padding: 0em 1em 0em 1em; font-size: 80%; '>
Line 62: Line 113:
  
 
  $xml = $repo-&gt;xml
 
  $xml = $repo-&gt;xml
Return an XML object for working with XML.
+
Return an [[API:EPrints/XML|EPrints::XML]] object for working with XML.
  
 
<div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce;  padding: 0em 1em 0em 1em; font-size: 80%; '>
 
<div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce;  padding: 0em 1em 0em 1em; font-size: 80%; '>
Line 75: Line 126:
  
 
  $xhtml = $repo-&gt;xhtml
 
  $xhtml = $repo-&gt;xhtml
Return an XHTML object for working with XHTML.
+
Return an [[API:EPrints/XHTML|EPrints::XHTML]] object for working with XHTML.
  
 
<div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce;  padding: 0em 1em 0em 1em; font-size: 80%; '>
 
<div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce;  padding: 0em 1em 0em 1em; font-size: 80%; '>
Line 88: Line 139:
  
 
  $eprint = $repository-&gt;eprint( $eprint_id );
 
  $eprint = $repository-&gt;eprint( $eprint_id );
Return the eprint with the given ID, or undef.
+
A convience method to return the [[API:EPrints/DataObj/EPrint|EPrints::DataObj::EPrint]] with the given ID, or undef.
 +
 
 +
Equivent to $repository-&gt;dataset("eprint")-&gt;dataobj( $eprint_id )
 +
 
 +
<div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce;  padding: 0em 1em 0em 1em; font-size: 80%; '>
 +
<span style='display:none'>User Comments</span>
 +
<!-- Edit below this comment -->
 +
 
 +
 
 +
<!-- Pod2Wiki= -->
 +
</div>
 +
<!-- Pod2Wiki=item_current_user -->
 +
===current_user===
 +
 
 +
$user = $repository-&gt;current_user
 +
Return the current logged in [[API:EPrints/DataObj/User|EPrints::DataObj::User]] for this session.
 +
 
 +
Return undef if there isn't one.
  
 
<div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce;  padding: 0em 1em 0em 1em; font-size: 80%; '>
 
<div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce;  padding: 0em 1em 0em 1em; font-size: 80%; '>
Line 101: Line 169:
  
 
  $user = $repository-&gt;user( $user_id );
 
  $user = $repository-&gt;user( $user_id );
Return the user with the given ID, or undef.
+
A convience method to return the [[API:EPrints/DataObj/User|EPrints::DataObj::User]] with the given ID, or undef.
 +
 
 +
Equivent to $repository-&gt;dataset("user")-&gt;dataobj( $user_id )
  
 
<div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce;  padding: 0em 1em 0em 1em; font-size: 80%; '>
 
<div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce;  padding: 0em 1em 0em 1em; font-size: 80%; '>
Line 127: Line 197:
  
 
  $user = $repository-&gt;user_by_email( $email );
 
  $user = $repository-&gt;user_by_email( $email );
Return the user with the given email, or undef.
+
Return the [[API:EPrints/DataObj/User|EPrints::DataObj::User]] with the given email, or undef.
  
 
<div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce;  padding: 0em 1em 0em 1em; font-size: 80%; '>
 
<div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce;  padding: 0em 1em 0em 1em; font-size: 80%; '>
Line 140: Line 210:
  
 
  $dataset = $repository-&gt;dataset( $setname )
 
  $dataset = $repository-&gt;dataset( $setname )
Return a given dataset or undef if it doesn't exist.
+
Return a given [[API:EPrints/DataSet|EPrints::DataSet]] or undef if it doesn't exist.
  
 
<div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce;  padding: 0em 1em 0em 1em; font-size: 80%; '>
 
<div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce;  padding: 0em 1em 0em 1em; font-size: 80%; '>
Line 224: Line 294:
 
<!-- Pod2Wiki= -->
 
<!-- Pod2Wiki= -->
 
</div>
 
</div>
<!-- Pod2Wiki=item_get_id -->
+
<!-- Pod2Wiki=item_test_config -->
===get_id===
+
===test_config===
  
  $id = $repository-&gt;get_id
+
  ( $returncode, $output) = $repository-&gt;test_config
Returns the id string of this repository.
+
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.
  
<div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce;  padding: 0em 1em 0em 1em; font-size: 80%; '>
+
$returncode will be zero if everything seems OK.
<span style='display:none'>User Comments</span>
 
<!-- Edit below this comment -->
 
  
 +
If not, then $output will contain the output of epadmin test
  
<!-- Pod2Wiki= -->
 
</div>
 
<!-- Pod2Wiki=head_accessor_methods -->
 
===Accessor Methods===
 
 
<div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce;  padding: 0em 1em 0em 1em; font-size: 80%; '>
 
<div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce;  padding: 0em 1em 0em 1em; font-size: 80%; '>
 
<span style='display:none'>User Comments</span>
 
<span style='display:none'>User Comments</span>
Line 246: Line 311:
 
<!-- Pod2Wiki= -->
 
<!-- Pod2Wiki= -->
 
</div>
 
</div>
<!-- Pod2Wiki=item_param -->
+
<!-- Pod2Wiki=item_reload_config -->
====param====
+
===reload_config===
  
  $value or @values = $repository-&gt;param( $name )
+
  $ok = $repository-&gt;reload_config
Passes through to CGI.pm param method.
+
Trigger a configuration reload on the next request/index.
 
 
$value = $repository-&gt;param( $name ): returns the value of CGI parameter $name.
 
  
$value = $repository-&gt;param( $name ): returns the value of CGI parameter $name.
+
To reload the configuration right now just call [[API:EPrints/Repository#load_config|load_config]].
 
 
@values = $repository-&gt;param: returns an array of the names of all the CGI parameters in the current request.
 
  
 
<div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce;  padding: 0em 1em 0em 1em; font-size: 80%; '>
 
<div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce;  padding: 0em 1em 0em 1em; font-size: 80%; '>
Line 265: Line 326:
 
<!-- Pod2Wiki= -->
 
<!-- Pod2Wiki= -->
 
</div>
 
</div>
<!-- Pod2Wiki=item_current_user -->
+
<!-- Pod2Wiki=head_copyright -->
====current_user====
+
==COPYRIGHT==
 
 
$user = $repository-&gt;current_user
 
Return the current EPrints::DataObj::User for this session.
 
 
 
Return undef if there isn't one.
 
 
 
 
<div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce;  padding: 0em 1em 0em 1em; font-size: 80%; '>
 
<div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce;  padding: 0em 1em 0em 1em; font-size: 80%; '>
 
<span style='display:none'>User Comments</span>
 
<span style='display:none'>User Comments</span>

Revision as of 10:46, 25 August 2011

EPrints 3 Reference: Directory Structure - Metadata Fields - Repository Configuration - XML Config Files - XML Export Format - EPrints data structure - Core API - Data Objects


API: Core API

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


NAME

EPrints::Repository - Single connection to a specific EPrints Repository

User Comments


DESCRIPTION

This module is really a Repository, REALLY. The name is up to date and everything :-)

EPrints::Repository represents a connection to the EPrints system. It connects to a single EPrints repository, and the database used by that repository.

Each Repository has a "current language". If you are running in a multilingual mode, this is used by the HTML rendering functions to choose what language to return text in.

The Repository object also knows about the current apache connection, if there is one, including the CGI parameters.

If the connection requires a username and password then it can also give access to the EPrints::DataObj::User object representing the user who is causing this request. See current_user().

The Repository object also provides access to the EPrints::XHTML class which contains many methods for creating XHTML results which can be returned via the web interface.

User Comments


METHODS

User Comments


new

$repository = EPrints::Repository->new( %opts )

Creates and returns a new repository object. This is a utility object only and will only have the basic system configuration available.

User Comments


new

$repository = EPrints::Repository->new( $repository_id, %opts )

Create a connection to an EPrints repository $repository_id which provides access to the database and to the repository configuration.

Options:

 db_connect - 1
 check_db - 1
 noise - 0
 

User Comments


query

$query = $repository->query

Return the CGI object describing the current HTTP query, or undefined if this isn't a CGI script.

User Comments


param

$value or @values = $repository->param( $name )

Passes through to CGI.pm param method.

$value = $repository->param( $name ): returns the value of CGI parameter $name.

$value = $repository->param( $name ): returns the value of CGI parameter $name.

@values = $repository->param: returns an array of the names of all the CGI parameters in the current request.

User Comments


xml

$xml = $repo->xml

Return an EPrints::XML object for working with XML.

User Comments


xhtml

$xhtml = $repo->xhtml

Return an EPrints::XHTML object for working with XHTML.

User Comments


eprint

$eprint = $repository->eprint( $eprint_id );

A convience method to return the EPrints::DataObj::EPrint with the given ID, or undef.

Equivent to $repository->dataset("eprint")->dataobj( $eprint_id )

User Comments


current_user

$user = $repository->current_user

Return the current logged in EPrints::DataObj::User for this session.

Return undef if there isn't one.

User Comments


user

$user = $repository->user( $user_id );

A convience method to return the EPrints::DataObj::User with the given ID, or undef.

Equivent to $repository->dataset("user")->dataobj( $user_id )

User Comments


user_by_username

$user = $repository->user_by_username( $username );

Return the user with the given username, or undef.

User Comments


user_by_email

$user = $repository->user_by_email( $email );

Return the EPrints::DataObj::User with the given email, or undef.

User Comments


dataset

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

Return a given EPrints::DataSet or undef if it doesn't exist.

User Comments


config

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

Returns a named configuration setting including those defined in archvies/<archive_id>/cfg/cfg.d/

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

is equivalent to

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

User Comments


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.

User Comments


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.

User Comments


can_call

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

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

User Comments


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.

User Comments


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

User Comments


reload_config

$ok = $repository->reload_config

Trigger a configuration reload on the next request/index.

To reload the configuration right now just call load_config.

User Comments


COPYRIGHT

User Comments