org.eaglei.repository
Class DataRepository

java.lang.Object
  extended by org.eaglei.repository.DataRepository

public class DataRepository
extends java.lang.Object

This is a singleton class that encompasses the application state. It is created and destroyed by Java Servlet Container webapp lifecycle events. Important configuration variables: - Sesame repository object (not the connection, but what makes connections) - Default namespace - Title (in configuration)

Version:
$Id: $
Author:
Larry Stone Started April 2010

Field Summary
static java.lang.String AUTH_DB_NAME
          XXX this needs to move
static java.lang.String CONFIG_INSTANCE_CSS
          CSS stylesheet for HTML dissemination output, if any
static java.lang.String CONFIG_INSTANCE_JS
          List of JavaScript URLs to be included in HTML dissemination output
static java.lang.String CONFIG_INSTANCE_XSLT
          stylesheet for transforming HTML dissemination output, if any
static java.lang.String CONFIG_TITLE
          title of repository for UI labels
static java.util.Date STARTUP
          Mark the startup time for display in admin page, etc.
static org.openrdf.model.URI[] UPGRADEABLE_GRAPHS
          Graphs that can be reloaded as part of upgrade
 
Constructor Summary
DataRepository(javax.servlet.ServletContext sc)
          Constructor for DataRepository.
 
Method Summary
static void decacheAll()
          Call the decache() method of all classes with the HasContentCache annotation.
 void destroy(javax.servlet.ServletContext sc)
          destroy - shut down this application and release resources.
 void finishInitialize()
          finishInitialize - setup at construct time
 java.io.File getBackupDirectory()
          getBackupDirectory- get configured repository backup directory
 java.lang.String getBranch()
          Get the source SCM branch, if any.
 java.lang.String getConfigurationProperty(java.lang.String key)
          getConfigurationProperty
 java.lang.String getConfigurationProperty(java.lang.String key, java.lang.String dflt)
          return default if there is no value for the indicated property.
 java.lang.String[] getConfigurationPropertyArray(java.lang.String key, java.lang.String[] dfault)
          Gets a configuration property with multiple values, returned in an array.
 java.lang.String getDefaultNamespace()
          Get value of default namespace prefix for URIs created by the repository.
static java.lang.String getGraphInitFile(org.openrdf.model.URI uri)
          Get the init file (relative resource path) for given graph URI.
 java.io.File getHomeDirectory()
          getHomeDirectory - get configured repository home directory.
static java.lang.String getInitFileVersion(org.openrdf.model.URI uri)
          Gets the version that would be set by loading the RDF from given init file; this is the value of owl:versionInfo on the given URI, if any, in the serialized RDF fiel found on resourcePath.
static DataRepository getInstance()
          Get the singleton instance.
 java.util.Date getLastModified()
          Gets the most recent "last modified" timestamp applied to provenance metadata.
 java.lang.String getProjectVersion()
          Get the Maven project version
 java.lang.String getRevision()
          Get the source revision, e.g.
 org.openrdf.repository.Repository getSesameRepository()
          getSesameRepository
 java.lang.String getSesameVersion()
           
 java.lang.String getTimestamp()
          Get the time when this software version was built
 java.io.Reader getWebappResourceAsReader(java.lang.String path)
          Read a resource file out of the webapp, path is relative to webapp root and MUST NOT begin with '/' -- e.g.
static void initialize(javax.servlet.ServletContext sc)
          Web app initialization hook: 1.
 boolean isSessionStale(javax.servlet.http.HttpSession session)
          Compare current webapp generation with value (if any) cached in session, also update session's generation to current.
 void loadGraphFromInit(org.openrdf.repository.RepositoryConnection rc, org.openrdf.model.URI graphURI, boolean ifEmpty)
           
 void notifyDataReplaced()
          Hook to signal to the application that all RDF data has been replaced, e.g.
 void setLastModified(java.util.Date lm)
          Update the most recent "last modified" timestamp if profferred value is newer
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

AUTH_DB_NAME

public static final java.lang.String AUTH_DB_NAME
XXX this needs to move

See Also:
Constant Field Values

CONFIG_TITLE

public static final java.lang.String CONFIG_TITLE
title of repository for UI labels

See Also:
Constant Field Values

CONFIG_INSTANCE_XSLT

public static final java.lang.String CONFIG_INSTANCE_XSLT
stylesheet for transforming HTML dissemination output, if any

See Also:
Constant Field Values

CONFIG_INSTANCE_CSS

public static final java.lang.String CONFIG_INSTANCE_CSS
CSS stylesheet for HTML dissemination output, if any

See Also:
Constant Field Values

CONFIG_INSTANCE_JS

public static final java.lang.String CONFIG_INSTANCE_JS
List of JavaScript URLs to be included in HTML dissemination output

See Also:
Constant Field Values

UPGRADEABLE_GRAPHS

public static final org.openrdf.model.URI[] UPGRADEABLE_GRAPHS
Graphs that can be reloaded as part of upgrade


STARTUP

public static final java.util.Date STARTUP
Mark the startup time for display in admin page, etc.

Constructor Detail

DataRepository

public DataRepository(javax.servlet.ServletContext sc)

Constructor for DataRepository.

Parameters:
sc - a ServletContext object.
Method Detail

getInstance

public static DataRepository getInstance()
Get the singleton instance. Will return null unless the initialization has run.

Returns:
the singleton, a DataRepository object.

initialize

public static void initialize(javax.servlet.ServletContext sc)
Web app initialization hook: 1. find and load the configuration properties file. 2. configure log4j 3. set up sesame repository based on configs

Parameters:
sc - the ServletContext object.

finishInitialize

public void finishInitialize()
                      throws java.io.IOException,
                             org.openrdf.OpenRDFException

finishInitialize - setup at construct time

Throws:
java$io$IOException - if any.
org.openrdf.OpenRDFException - if any.
java.io.IOException

destroy

public void destroy(javax.servlet.ServletContext sc)
             throws org.openrdf.repository.RepositoryException

destroy - shut down this application and release resources.

Parameters:
sc - a ServletContext object.
Throws:
org.openrdf.repository.RepositoryException - if any.

getInitFileVersion

public static java.lang.String getInitFileVersion(org.openrdf.model.URI uri)
                                           throws java.io.IOException,
                                                  org.openrdf.rio.RDFParseException,
                                                  org.openrdf.rio.RDFHandlerException
Gets the version that would be set by loading the RDF from given init file; this is the value of owl:versionInfo on the given URI, if any, in the serialized RDF fiel found on resourcePath.

Parameters:
uri - the uri of the graph, subject of owl:versionInfo
Returns:
the exact content of the versionInfo literal or null if none found.
Throws:
java.io.IOException
org.openrdf.rio.RDFParseException
org.openrdf.rio.RDFHandlerException

getGraphInitFile

public static java.lang.String getGraphInitFile(org.openrdf.model.URI uri)
Get the init file (relative resource path) for given graph URI.

Returns:
relative path or null if there is none for this URI.

loadGraphFromInit

public void loadGraphFromInit(org.openrdf.repository.RepositoryConnection rc,
                              org.openrdf.model.URI graphURI,
                              boolean ifEmpty)
                       throws org.openrdf.repository.RepositoryException,
                              java.io.IOException,
                              org.openrdf.rio.RDFParseException
Throws:
org.openrdf.repository.RepositoryException
java.io.IOException
org.openrdf.rio.RDFParseException

getSesameRepository

public org.openrdf.repository.Repository getSesameRepository()
                                                      throws javax.servlet.ServletException

getSesameRepository

Returns:
the Repository object.
Throws:
javax.servlet.ServletException - if any.

getDefaultNamespace

public java.lang.String getDefaultNamespace()
Get value of default namespace prefix for URIs created by the repository. This is a critically important value that ought to be configured by the administrator, so that URIs are resolved correctly by the server. Since it is so essential, we have to provide a usable default. Also, sanity-check the configured value. It must be a legal absolute URI.

Returns:
the default namespace prefix as a String object.

getConfigurationProperty

public java.lang.String getConfigurationProperty(java.lang.String key)

getConfigurationProperty

Parameters:
key - a String object.
Returns:
property value or null if not set.

getConfigurationProperty

public java.lang.String getConfigurationProperty(java.lang.String key,
                                                 java.lang.String dflt)
return default if there is no value for the indicated property.

Parameters:
key - a String object.
dflt - default value to return if not set a String object.
Returns:
the property value or dflt if not set.

getConfigurationPropertyArray

public java.lang.String[] getConfigurationPropertyArray(java.lang.String key,
                                                        java.lang.String[] dfault)
Gets a configuration property with multiple values, returned in an array. The values are expected to be separated by comma and optional whitespace. Returns the default value (which may be null) when there is no such key

Parameters:
key - a String object.
Returns:
property value as an array of String objects, or null if not set.

notifyDataReplaced

public void notifyDataReplaced()
Hook to signal to the application that all RDF data has been replaced, e.g. after restoring a complete backup of all graphs. This is responsible for updating or invalidating all memory caches that depend on the RDF contents.


isSessionStale

public boolean isSessionStale(javax.servlet.http.HttpSession session)
Compare current webapp generation with value (if any) cached in session, also update session's generation to current.

Parameters:
session - a HttpSession object.
Returns:
a boolean, true if the session is "stale" (e.g. after a global restore of RDF db)

getWebappResourceAsReader

public java.io.Reader getWebappResourceAsReader(java.lang.String path)
                                         throws javax.servlet.ServletException
Read a resource file out of the webapp, path is relative to webapp root and MUST NOT begin with '/' -- e.g. "repository/styles/foo.xsl".

Parameters:
path - relative path to resource file, a String object.
Returns:
a Reader object open on the resource, or null if not available.
Throws:
javax.servlet.ServletException

getProjectVersion

public java.lang.String getProjectVersion()
Get the Maven project version

Returns:
version as an opaque a String object.

getRevision

public java.lang.String getRevision()
Get the source revision, e.g. the subversion revision number

Returns:
revision as an opaque a String object.

getBranch

public java.lang.String getBranch()
Get the source SCM branch, if any.

Returns:
branch or tag name, or null if on the trunk.

getTimestamp

public java.lang.String getTimestamp()
Get the time when this software version was built

Returns:
time as an opaque a String object.

getHomeDirectory

public java.io.File getHomeDirectory()
                              throws java.io.IOException

getHomeDirectory - get configured repository home directory.

Returns:
repository home directory as a File object.
Throws:
java$io$IOException - if any.
java.io.IOException

getBackupDirectory

public java.io.File getBackupDirectory()
                                throws java.io.IOException

getBackupDirectory- get configured repository backup directory

Returns:
repository backup directory as a File object.
Throws:
java$io$IOException - if any.
java.io.IOException

setLastModified

public void setLastModified(java.util.Date lm)
Update the most recent "last modified" timestamp if profferred value is newer

Parameters:
lm - date of new most recent dcterms:modified

getLastModified

public java.util.Date getLastModified()
Gets the most recent "last modified" timestamp applied to provenance metadata.

Returns:
date of most recent dcterms:modified, or repository startup time by default

getSesameVersion

public java.lang.String getSesameVersion()
                                  throws java.io.IOException
Throws:
java.io.IOException

decacheAll

public static void decacheAll()
Call the decache() method of all classes with the HasContentCache annotation. This gets called when the RDF database was replaced so in-memory caches must be invalidated.



Copyright © 2009-2011 Eagle-I. All Rights Reserved.