fedora.server.management
Class DBPIDGenerator

java.lang.Object
  extended byfedora.server.management.DBPIDGenerator
All Implemented Interfaces:
PIDGenerator

public class DBPIDGenerator
extends java.lang.Object
implements PIDGenerator

A PIDGenerator that uses a database to keep track of the highest pid it knows about for each namespace. -----------------------------------------------------------------------------

License and Copyright: The contents of this file are subject to the Mozilla Public License Version 1.1 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.mozilla.org/MPL/.

Software distributed under the License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for the specific language governing rights and limitations under the License.

The entire file consists of original code. Copyright © 2002-2005 by The Rector and Visitors of the University of Virginia and Cornell University. All rights reserved.

-----------------------------------------------------------------------------

Version:
$Id: DBPIDGenerator.java,v 1.4 2005/01/11 20:06:06 cwilper Exp $
Author:
cwilper@cs.cornell.edu

Constructor Summary
DBPIDGenerator(ConnectionPool cPool, java.io.File oldPidGenDir)
          Initialize the DBPIDGenerator.
 
Method Summary
 java.lang.String generatePID(java.lang.String namespace)
          Generate a new pid that is guaranteed to be unique, within the given namespace.
 java.lang.String getLastPID()
          Get the last pid that was generated.
 void neverGeneratePID(java.lang.String pid)
          Cause the given PID to never be generated by the PID generator.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DBPIDGenerator

public DBPIDGenerator(ConnectionPool cPool,
                      java.io.File oldPidGenDir)
               throws java.io.IOException
Initialize the DBPIDGenerator. This initializes the memory hash with values in the database, if any. If oldPidGenDir is not null, the constructor will then call neverGeneratePID on the most recently generated PID as reported by the log files in that directory. This is to support automatic upgrade of this functionality from versions of Fedora prior to 1.2.

Method Detail

generatePID

public java.lang.String generatePID(java.lang.String namespace)
                             throws java.io.IOException
Generate a new pid that is guaranteed to be unique, within the given namespace.

Specified by:
generatePID in interface PIDGenerator
Throws:
java.io.IOException

getLastPID

public java.lang.String getLastPID()
Get the last pid that was generated.

Specified by:
getLastPID in interface PIDGenerator

neverGeneratePID

public void neverGeneratePID(java.lang.String pid)
                      throws java.io.IOException
Cause the given PID to never be generated by the PID generator.

Specified by:
neverGeneratePID in interface PIDGenerator
Throws:
java.io.IOException