|
From: <cw...@us...> - 2009-02-23 16:24:21
|
Revision: 30
http://proai.svn.sourceforge.net/proai/?rev=30&view=rev
Author: cwilper
Date: 2009-02-23 16:24:13 +0000 (Mon, 23 Feb 2009)
Log Message:
-----------
merged in dev-142339. This branch did misc cleanup and testing
improvements in prep for Fedora's OAIProvider service release v1.2
Modified Paths:
--------------
trunk/build.properties
trunk/src/java/proai/CloseableIterator.java
trunk/src/java/proai/Proai.properties
trunk/src/java/proai/cache/CachedRecordContentIterator.java
trunk/src/java/proai/cache/Committer.java
trunk/src/java/proai/cache/ParsedRecord.java
trunk/src/java/proai/cache/RCDatabase.java
trunk/src/java/proai/cache/RCDisk.java
trunk/src/java/proai/cache/RecordCache.java
trunk/src/java/proai/cache/StringResultIterator.java
trunk/src/java/proai/cache/Updater.java
trunk/src/java/proai/cache/Worker.java
trunk/src/java/proai/driver/OAIDriver.java
trunk/src/java/proai/driver/RemoteIterator.java
trunk/src/java/proai/driver/impl/OAIDriverImpl.java
trunk/src/java/proai/driver/impl/RecordImpl.java
trunk/src/java/proai/driver/impl/RemoteIteratorImpl.java
trunk/src/java/proai/error/BadArgumentException.java
trunk/src/java/proai/error/BadResumptionTokenException.java
trunk/src/java/proai/error/BadVerbException.java
trunk/src/java/proai/error/CannotDisseminateFormatException.java
trunk/src/java/proai/error/IdDoesNotExistException.java
trunk/src/java/proai/error/ImmediateShutdownException.java
trunk/src/java/proai/error/NoMetadataFormatsException.java
trunk/src/java/proai/error/NoRecordsMatchException.java
trunk/src/java/proai/error/NoSetHierarchyException.java
trunk/src/java/proai/error/ProtocolException.java
trunk/src/java/proai/error/RepositoryException.java
trunk/src/java/proai/error/ServerException.java
trunk/src/java/proai/service/CacheSession.java
trunk/src/java/proai/service/ListProvider.java
trunk/src/java/proai/service/ProviderServlet.java
trunk/src/java/proai/service/RecordListProvider.java
trunk/src/java/proai/service/Responder.java
trunk/src/java/proai/service/Session.java
trunk/src/java/proai/service/SessionManager.java
trunk/src/java/proai/service/SetListProvider.java
trunk/src/java/proai/service/SnapshotSession.java
trunk/src/java/proai/test/OAIDriverImplTest.java
trunk/src/java/proai/test/RecordCacheTest.java
trunk/src/java/proai/test/ResponderTest.java
trunk/src/java/proai/util/DDLConverter.java
trunk/src/java/proai/util/McKoiDDLConverter.java
trunk/src/java/proai/util/MySQLDDLConverter.java
trunk/src/java/proai/util/OracleDDLConverter.java
trunk/src/java/proai/util/PostgresDDLConverter.java
trunk/src/java/proai/util/SetSpec.java
trunk/src/java/proai/util/TableSpec.java
trunk/src/java/proai/util/TableSpecDeserializer.java
Added Paths:
-----------
trunk/.classpath
Copied: trunk/.classpath (from rev 29, branches/dev-142339/.classpath)
===================================================================
--- trunk/.classpath (rev 0)
+++ trunk/.classpath 2009-02-23 16:24:13 UTC (rev 30)
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="src" path="src/java"/>
+ <classpathentry kind="lib" path="lib/bvalid-0.8.1.jar"/>
+ <classpathentry kind="lib" path="lib/commons-codec-1.3.jar"/>
+ <classpathentry kind="lib" path="lib/commons-collections-3.1.jar"/>
+ <classpathentry kind="lib" path="lib/commons-dbcp-1.2.1.jar"/>
+ <classpathentry kind="lib" path="lib/commons-httpclient-3.1-beta1.jar"/>
+ <classpathentry kind="lib" path="lib/commons-logging.jar"/>
+ <classpathentry kind="lib" path="lib/commons-pool-1.2.jar"/>
+ <classpathentry kind="lib" path="lib/gnu-regexp-1.1.4.jar"/>
+ <classpathentry kind="lib" path="lib/javax.servlet-2.3.jar"/>
+ <classpathentry kind="lib" path="lib/junit.jar"/>
+ <classpathentry kind="lib" path="lib/log4j-1.2.14.jar"/>
+ <classpathentry kind="lib" path="lib/mckoidb.jar"/>
+ <classpathentry kind="lib" path="lib/mkjdbc.jar"/>
+ <classpathentry kind="lib" path="lib/mysql-connector-java-5.0.4-bin.jar"/>
+ <classpathentry kind="lib" path="lib/postgresql-8.2-504.jdbc3.jar"/>
+ <classpathentry kind="lib" path="lib/PropsToDocs.jar"/>
+ <classpathentry kind="lib" path="lib/xercesImpl.jar"/>
+ <classpathentry kind="lib" path="lib/xml-apis.jar"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
Modified: trunk/build.properties
===================================================================
--- trunk/build.properties 2008-03-04 21:15:21 UTC (rev 29)
+++ trunk/build.properties 2009-02-23 16:24:13 UTC (rev 30)
@@ -4,8 +4,8 @@
optimize = off
debug = on
-source = 1.4
-target = 1.4
+source = 1.5
+target = 1.5
#
# Libraries
Modified: trunk/src/java/proai/CloseableIterator.java
===================================================================
--- trunk/src/java/proai/CloseableIterator.java 2008-03-04 21:15:21 UTC (rev 29)
+++ trunk/src/java/proai/CloseableIterator.java 2009-02-23 16:24:13 UTC (rev 30)
@@ -4,11 +4,11 @@
import proai.error.ServerException;
-public interface CloseableIterator extends Iterator {
+public interface CloseableIterator<T> extends Iterator<T> {
public boolean hasNext() throws ServerException;
- public Object next() throws ServerException;
+ public T next() throws ServerException;
public void close() throws ServerException;
Modified: trunk/src/java/proai/Proai.properties
===================================================================
--- trunk/src/java/proai/Proai.properties 2008-03-04 21:15:21 UTC (rev 29)
+++ trunk/src/java/proai/Proai.properties 2009-02-23 16:24:13 UTC (rev 30)
@@ -1,2 +1,2 @@
-proai.version = 1.0
+proai.version = 1.1
proai.buildDate = @buildDate@
Modified: trunk/src/java/proai/cache/CachedRecordContentIterator.java
===================================================================
--- trunk/src/java/proai/cache/CachedRecordContentIterator.java 2008-03-04 21:15:21 UTC (rev 29)
+++ trunk/src/java/proai/cache/CachedRecordContentIterator.java 2009-02-23 16:24:13 UTC (rev 30)
@@ -3,15 +3,15 @@
import proai.CloseableIterator;
import proai.error.ServerException;
-public class CachedRecordContentIterator implements CloseableIterator {
+public class CachedRecordContentIterator implements CloseableIterator<CachedContent> {
- private CloseableIterator m_arrays;
+ private CloseableIterator<String[]> m_arrays;
private RCDisk m_rcDisk;
private boolean m_identifiers;
private boolean m_closed;
- public CachedRecordContentIterator(CloseableIterator paths,
+ public CachedRecordContentIterator(CloseableIterator<String[]> paths,
RCDisk rcDisk,
boolean identifiers) {
m_arrays = paths;
@@ -25,10 +25,10 @@
return m_arrays.hasNext();
}
- public Object next() throws ServerException {
+ public CachedContent next() throws ServerException {
if (!hasNext()) return null;
try {
- String[] array = (String[]) m_arrays.next();
+ String[] array = m_arrays.next();
return m_rcDisk.getContent(array[0], array[1], m_identifiers);
} catch (Exception e) {
close();
Modified: trunk/src/java/proai/cache/Committer.java
===================================================================
--- trunk/src/java/proai/cache/Committer.java 2008-03-04 21:15:21 UTC (rev 29)
+++ trunk/src/java/proai/cache/Committer.java 2009-02-23 16:24:13 UTC (rev 30)
@@ -30,9 +30,9 @@
private int _maxCommitQueueSize;
private int _maxRecordsPerTransaction;
- private Map _formatKeyMap;
+ private Map<String, Integer> _formatKeyMap;
- private List _commitQueue;
+ private List<QueueItem> _commitQueue;
private int _lastCommitQueueSize;
/**
@@ -66,7 +66,7 @@
_maxCommitQueueSize = maxCommitQueueSize;
_maxRecordsPerTransaction = maxRecordsPerTransaction;
- _commitQueue = new ArrayList(_maxCommitQueueSize);
+ _commitQueue = new ArrayList<QueueItem>(_maxCommitQueueSize);
// get this now -- it won't change while the thread is running
Connection conn = null;
@@ -91,7 +91,7 @@
* @return whether the handoff was successful. The handoff will only
* fail if the <code>Committer</code> thread has been stopped.
*/
- protected synchronized boolean handoff(List queueItems) {
+ protected synchronized boolean handoff(List<QueueItem> queueItems) {
int toAddSize = queueItems.size();
while (!_finishedRunning &&
@@ -124,7 +124,7 @@
// phase one
while (_updater.anyWorkersAreRunning()) {
- List nextItems = getNextTransactionItems();
+ List<QueueItem> nextItems = getNextTransactionItems();
while (nextItems == null && _updater.anyWorkersAreRunning()) {
// wait for the queue to have items
_LOG.debug("Commit queue is empty; waiting for worker(s)");
@@ -137,7 +137,7 @@
}
// phase two
- List lastItems = getNextTransactionItems();
+ List<QueueItem> lastItems = getNextTransactionItems();
while (!_updater.processingShouldStop() && lastItems != null) {
commit(lastItems);
lastItems = getNextTransactionItems();
@@ -148,7 +148,7 @@
}
- private void commit(List items) {
+ private void commit(List<QueueItem> items) {
Connection conn = null;
boolean startedTransaction = false;
@@ -161,9 +161,8 @@
startedTransaction = true;
// update the database for each record, as necessary
- Iterator iter = items.iterator();
- while (iter.hasNext()) {
- updateItem(conn, (QueueItem) iter.next());
+ for (QueueItem item : items) {
+ updateItem(conn, item);
}
// set the estimated commit date for all added/modified records
@@ -202,10 +201,9 @@
}
// ...delete uncommitted files
- Iterator toDelete = items.iterator();
- while (toDelete.hasNext()) {
- ParsedRecord pr = ((QueueItem) toDelete.next()).getParsedRecord();
- if (pr != null) pr.deleteFile();
+ for (QueueItem item : items) {
+ ParsedRecord pr = item.getParsedRecord();
+ if (pr != null) pr.deleteFile();
}
// ...then signal error to updater
@@ -264,13 +262,13 @@
*
* Otherwise, return <code>null</code>.
*/
- private List getNextTransactionItems() {
+ private List<QueueItem> getNextTransactionItems() {
synchronized (_commitQueue) {
if (_commitQueue.size() == 0) {
return null;
} else {
- List nextItems = new ArrayList();
+ List<QueueItem> nextItems = new ArrayList<QueueItem>();
while ( (_commitQueue.size() > 0) &&
(nextItems.size() < _maxRecordsPerTransaction) ) {
nextItems.add(_commitQueue.remove(0));
@@ -279,7 +277,6 @@
return nextItems;
}
}
-
}
Modified: trunk/src/java/proai/cache/ParsedRecord.java
===================================================================
--- trunk/src/java/proai/cache/ParsedRecord.java 2008-03-04 21:15:21 UTC (rev 29)
+++ trunk/src/java/proai/cache/ParsedRecord.java 2009-02-23 16:24:13 UTC (rev 30)
@@ -13,8 +13,6 @@
import org.xml.sax.helpers.DefaultHandler;
import proai.Record;
-import proai.Writable;
-import proai.driver.impl.OAIDriverImpl;
import proai.error.ServerException;
import proai.util.StreamUtil;
@@ -29,7 +27,7 @@
private File m_file;
private Date m_date;
- private List m_setSpecs;
+ private List<String> m_setSpecs;
private SimpleDateFormat m_formatter1;
private SimpleDateFormat m_formatter2;
@@ -48,7 +46,7 @@
m_sourceInfo = sourceInfo;
m_file = file;
m_date = new Date(0);
- m_setSpecs = new ArrayList();
+ m_setSpecs = new ArrayList<String>();
m_formatter1 = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'");
m_formatter2 = new SimpleDateFormat("yyyy-MM-dd");
@@ -151,7 +149,7 @@
return m_date;
}
- public List getSetSpecs() {
+ public List<String> getSetSpecs() {
return m_setSpecs;
}
Modified: trunk/src/java/proai/cache/RCDatabase.java
===================================================================
--- trunk/src/java/proai/cache/RCDatabase.java 2008-03-04 21:15:21 UTC (rev 29)
+++ trunk/src/java/proai/cache/RCDatabase.java 2009-02-23 16:24:13 UTC (rev 30)
@@ -12,12 +12,12 @@
import proai.CloseableIterator;
import proai.MetadataFormat;
+import proai.SetInfo;
import proai.driver.impl.RemoteIteratorImpl;
import proai.driver.impl.SetInfoImpl;
import proai.error.ServerException;
import proai.util.DBUtil;
import proai.util.DDLConverter;
-import proai.util.StreamUtil;
import proai.util.TableSpec;
/**
@@ -278,12 +278,13 @@
}
}
- public List getFormats(Connection conn) throws ServerException {
+ public List<CachedMetadataFormat> getFormats(Connection conn) throws ServerException {
return getFormats(conn, null);
}
- public List getFormats(Connection conn, String identifier) throws ServerException {
- List list = new ArrayList();
+ public List<CachedMetadataFormat> getFormats(Connection conn, String identifier)
+ throws ServerException {
+ List<CachedMetadataFormat> list = new ArrayList<CachedMetadataFormat>();
Statement stmt = null;
ResultSet rs = null;
try {
@@ -316,10 +317,10 @@
* Get a map of prefix (String) to formatKey (Integer) for all formats
* in the database.
*/
- public Map getFormatKeyMap(Connection conn) throws ServerException {
+ public Map<String, Integer> getFormatKeyMap(Connection conn) throws ServerException {
- Map map = new HashMap();
- Iterator iter = getFormats(conn).iterator();
+ Map<String, Integer> map = new HashMap<String, Integer>();
+ Iterator<CachedMetadataFormat> iter = getFormats(conn).iterator();
while (iter.hasNext()) {
CachedMetadataFormat format = (CachedMetadataFormat) iter.next();
map.put(format.getPrefix(), new Integer(format.getKey()));
@@ -394,8 +395,8 @@
}
}
- public List getSetInfo(Connection conn) throws ServerException {
- List list = new ArrayList();
+ public List<SetInfo> getSetInfo(Connection conn) throws ServerException {
+ List<SetInfo> list = new ArrayList<SetInfo>();
Statement stmt = null;
ResultSet rs = null;
try {
@@ -414,8 +415,8 @@
}
// return a closeableiterator of string[] (path)
- public List getSetInfoPaths(Connection conn) throws ServerException {
- List list = new ArrayList();
+ public List<String[]> getSetInfoPaths(Connection conn) throws ServerException {
+ List<String[]> list = new ArrayList<String[]>();
Statement stmt = null;
ResultSet rs = null;
try {
@@ -492,7 +493,7 @@
*/
public void putRecord(Connection conn,
ParsedRecord rec,
- Map formatKeyMap) throws ServerException {
+ Map<String, Integer> formatKeyMap) throws ServerException {
String xmlPath = rec.getSourceInfo();
Statement stmt = null;
ResultSet rs = null;
@@ -542,7 +543,7 @@
// Modified rcRecord. Now list the ids of the sets it WAS in,
// and rectify that with the ones it's NOW in
- List priorSetKeys = new ArrayList();
+ List<Integer> priorSetKeys = new ArrayList<Integer>();
rs = executeQuery(stmt, "SELECT setKey from rcMembership WHERE recordKey = " + recordKey);
while (rs.next()) {
priorSetKeys.add(new Integer(rs.getInt(1)));
@@ -561,9 +562,9 @@
}
// which sets is the record no longer a member of?
- Iterator liter = priorSetKeys.iterator();
+ Iterator<Integer> liter = priorSetKeys.iterator();
while (liter.hasNext()) {
- Integer priorSetKey = (Integer) liter.next();
+ Integer priorSetKey = liter.next();
int psk = priorSetKey.intValue();
boolean noLongerInSet = true;
for (int i = 0; i < setKeys.length; i++) {
@@ -608,16 +609,16 @@
}
}
- private int[] getSetKeys(Statement stmt, List specs) throws ServerException {
+ private int[] getSetKeys(Statement stmt, List<String> specs) throws ServerException {
ResultSet rs = null;
try {
int[] keys = new int[specs.size()];
for (int i = 0; i < specs.size(); i++) {
- rs = executeQuery(stmt, "SELECT setKey from rcSet WHERE setSpec = " + qs((String) specs.get(i)));
+ rs = executeQuery(stmt, "SELECT setKey from rcSet WHERE setSpec = " + qs(specs.get(i)));
if (rs.next()) {
keys[i] = rs.getInt(1);
} else {
- throw new ServerException("Record contains setSpec not listed sets: " + (String) specs.get(i));
+ throw new ServerException("Record contains setSpec not listed sets: " + specs.get(i));
}
}
return keys;
@@ -709,7 +710,7 @@
// the responsibility of releasing the connection in some cases.
// In particular, if this method does NOT return an iterator
// that is attached to a ResultSet, it must release the connection.
- public CloseableIterator findRecordInfo(Connection conn,
+ public CloseableIterator<String[]> findRecordInfo(Connection conn,
Date from,
Date until,
String prefix,
@@ -733,7 +734,7 @@
// no such format -- return an empty iterator
try { rs.close(); } catch (Exception e) { }
try { stmt.close(); } catch (Exception e) { }
- return new RemoteIteratorImpl(new ArrayList().iterator());
+ return new RemoteIteratorImpl<String[]>(new ArrayList<String[]>().iterator());
}
int formatKey = rs.getInt(1);
rs.close();
@@ -746,7 +747,7 @@
// no such set -- return an empty iterator
try { rs.close(); } catch (Exception e) { }
try { stmt.close(); } catch (Exception e) { }
- return new RemoteIteratorImpl(new ArrayList().iterator());
+ return new RemoteIteratorImpl<String[]>(new ArrayList<String[]>().iterator());
}
setKey = rs.getInt(1);
rs.close();
@@ -807,25 +808,25 @@
private void createTables(Connection conn,
DDLConverter ddlc) throws ServerException {
logger.debug("Creating tables...");
- List specs;
+ List<TableSpec> specs;
try {
InputStream in = this.getClass().getResourceAsStream("/dbspec.xml");
specs = TableSpec.getTableSpecs(in);
} catch (Exception e) {
throw new ServerException("Unable to initialize tablespecs", e);
}
- List createdCommands = new ArrayList();
- Iterator iter = specs.iterator();
+ List<String> createdCommands = new ArrayList<String>();
+ Iterator<TableSpec> iter = specs.iterator();
Statement stmt = null;
String tableName = null;
String command = null;
try {
stmt = getStatement(conn, false);
while (iter.hasNext()) {
- TableSpec spec = (TableSpec) iter.next();
+ TableSpec spec = iter.next();
tableName = spec.getName();
logger.info("Creating " + tableName + " table");
- List commands = ddlc.getDDL(spec);
+ List<String> commands = ddlc.getDDL(spec);
for (int i = 0; i < commands.size(); i++) {
command = (String) commands.get(i);
executeUpdate(stmt, command);
Modified: trunk/src/java/proai/cache/RCDisk.java
===================================================================
--- trunk/src/java/proai/cache/RCDisk.java 2008-03-04 21:15:21 UTC (rev 29)
+++ trunk/src/java/proai/cache/RCDisk.java 2009-02-23 16:24:13 UTC (rev 30)
@@ -8,7 +8,6 @@
import proai.Writable;
import proai.error.ServerException;
-import proai.util.StreamUtil;
/**
* The file-based portion of the record cache.
Modified: trunk/src/java/proai/cache/RecordCache.java
===================================================================
--- trunk/src/java/proai/cache/RecordCache.java 2008-03-04 21:15:21 UTC (rev 29)
+++ trunk/src/java/proai/cache/RecordCache.java 2009-02-23 16:24:13 UTC (rev 30)
@@ -16,7 +16,6 @@
import net.sf.bvalid.catalog.SchemaIndex;
import net.sf.bvalid.locator.SchemaLocator;
import net.sf.bvalid.locator.CachingSchemaLocator;
-import net.sf.bvalid.locator.CatalogSchemaLocator;
import net.sf.bvalid.locator.URLSchemaLocator;
import org.apache.commons.dbcp.BasicDataSource;
@@ -26,11 +25,9 @@
import proai.CloseableIterator;
import proai.MetadataFormat;
-import proai.Record;
import proai.SetInfo;
import proai.Writable;
import proai.driver.OAIDriver;
-import proai.driver.RemoteIterator;
import proai.error.ServerException;
import proai.util.DDLConverter;
import proai.util.StreamUtil;
@@ -82,7 +79,6 @@
private Updater m_updater;
private OAIDriver m_driver;
private File m_baseDir;
- private Validator m_validator;
private RCDatabase m_rcdb;
private RCDisk m_rcDisk;
@@ -91,11 +87,7 @@
String baseDir = getRequiredParam(props, PROP_BASEDIR);
String oaiDriverClassName = getRequiredParam(props, PROP_OAIDRIVERCLASSNAME);
- String pollSeconds = getRequiredParam(props, PROP_POLLSECONDS);
- String dbURL = getRequiredParam(props, PROP_DB_URL);
String dbDriverClassName = getRequiredParam(props, PROP_DB_DRIVERCLASSNAME);
- String dbUsername = getRequiredParam(props, PROP_DB_USERNAME);
- String dbPassword = getRequiredParam(props, PROP_DB_PASSWORD);
boolean mySQLTrickling = false;
String mt = props.getProperty(PROP_DB_MYSQL_TRICKLING);
@@ -129,7 +121,7 @@
.createDataSource(getDBProperties(props, false));
pool.setDriverClassName(dbDriverClassName);
Properties connProps = getDBProperties(props, true);
- Enumeration e = connProps.propertyNames();
+ Enumeration<?> e = connProps.propertyNames();
while (e.hasMoreElements()) {
String name = (String) e.nextElement();
pool.addConnectionProperty(name, (String) connProps.getProperty(name));
@@ -266,7 +258,7 @@
}
}
- Map opts = new HashMap();
+ Map<ValidatorOption, String> opts = new HashMap<ValidatorOption, String>();
opts.put(ValidatorOption.CACHE_PARSED_GRAMMARS, "true");
try {
validator = ValidatorFactory.getValidator(SchemaLanguage.XSD,
@@ -396,7 +388,7 @@
private static final Properties getDBProperties(Properties props,
boolean conn) {
Properties dbProps = new Properties();
- Enumeration e = props.propertyNames();
+ Enumeration<?> e = props.propertyNames();
while (e.hasMoreElements()) {
String name = (String) e.nextElement();
if (name.startsWith(dbpfx)) {
@@ -468,7 +460,7 @@
Connection conn = null;
try {
conn = getConnection();
- List formats = m_rcdb.getFormats(conn, identifier);
+ List<CachedMetadataFormat> formats = m_rcdb.getFormats(conn, identifier);
if (identifier != null && formats.size() == 0) return null;
return new CachedContent(getFormatsXMLString(formats));
} catch (SQLException e) {
@@ -478,12 +470,12 @@
}
}
- public CloseableIterator getSetInfoContent() throws ServerException {
+ public CloseableIterator<SetInfo> getSetInfoContent() throws ServerException {
Connection conn = null;
try {
conn = getConnection();
- List list = m_rcdb.getSetInfo(conn);
- CloseableIterator setInfo = new proai.driver.impl.RemoteIteratorImpl(list.iterator());
+ List<SetInfo> list = m_rcdb.getSetInfo(conn);
+ CloseableIterator<SetInfo> setInfo = new proai.driver.impl.RemoteIteratorImpl<SetInfo>(list.iterator());
return setInfo;
} catch (SQLException e) {
throw new ServerException("Error getting a database connection", e);
@@ -492,12 +484,12 @@
}
}
- public CloseableIterator getSetInfoPaths() throws ServerException {
+ public CloseableIterator<String[]> getSetInfoPaths() throws ServerException {
Connection conn = null;
try {
conn = getConnection();
- List list = m_rcdb.getSetInfoPaths(conn);
- CloseableIterator setInfo = new proai.driver.impl.RemoteIteratorImpl(list.iterator());
+ List<String[]> list = m_rcdb.getSetInfoPaths(conn);
+ CloseableIterator<String[]> setInfo = new proai.driver.impl.RemoteIteratorImpl<String[]>(list.iterator());
return setInfo;
} catch (SQLException e) {
throw new ServerException("Error getting a database connection", e);
@@ -506,7 +498,7 @@
}
}
- public CloseableIterator getRecordsContent(Date from,
+ public CloseableIterator<CachedContent> getRecordsContent(Date from,
Date until,
String prefix,
String set,
@@ -531,7 +523,7 @@
}
}
- public CloseableIterator getRecordsPaths(Date from,
+ public CloseableIterator<String[]> getRecordsPaths(Date from,
Date until,
String prefix,
String set) throws ServerException {
@@ -556,9 +548,9 @@
Connection conn = null;
try {
conn = getConnection();
- Iterator iter = m_rcdb.getFormats(conn).iterator();
+ Iterator<CachedMetadataFormat> iter = m_rcdb.getFormats(conn).iterator();
while (iter.hasNext()) {
- MetadataFormat fmt = (MetadataFormat) iter.next();
+ MetadataFormat fmt = iter.next();
if (fmt.getPrefix().equals(mdPrefix)) return true;
}
return false;
@@ -569,12 +561,12 @@
}
}
- private String getFormatsXMLString(List formats) {
+ private String getFormatsXMLString(List<? extends MetadataFormat> formats) {
StringBuffer buf = new StringBuffer();
buf.append("<ListMetadataFormats>\n");
- Iterator iter = formats.iterator();
+ Iterator<? extends MetadataFormat> iter = formats.iterator();
while (iter.hasNext()) {
- MetadataFormat fmt = (MetadataFormat) iter.next();
+ MetadataFormat fmt = iter.next();
buf.append(" <metadataFormat>\n");
buf.append(" <metadataPrefix>" + fmt.getPrefix() + "</metadataPrefix>\n");
buf.append(" <schema>" + fmt.getSchemaLocation() + "</schema>\n");
Modified: trunk/src/java/proai/cache/StringResultIterator.java
===================================================================
--- trunk/src/java/proai/cache/StringResultIterator.java 2008-03-04 21:15:21 UTC (rev 29)
+++ trunk/src/java/proai/cache/StringResultIterator.java 2009-02-23 16:24:13 UTC (rev 30)
@@ -24,7 +24,7 @@
* The first is the relative filesystem path and the second is an
* ISO8601-formatted date (second precision).
*/
-public class StringResultIterator implements CloseableIterator {
+public class StringResultIterator implements CloseableIterator<String[]> {
private static final Logger logger =
Logger.getLogger(StringResultIterator.class.getName());
@@ -54,7 +54,7 @@
return m_nextStringArray != null;
}
- public Object next() throws ServerException {
+ public String[] next() throws ServerException {
String[] next = m_nextStringArray;
m_nextStringArray = getNext();
return next;
Modified: trunk/src/java/proai/cache/Updater.java
===================================================================
--- trunk/src/java/proai/cache/Updater.java 2008-03-04 21:15:21 UTC (rev 29)
+++ trunk/src/java/proai/cache/Updater.java 2009-02-23 16:24:13 UTC (rev 30)
@@ -19,7 +19,6 @@
import proai.error.ServerException;
import proai.error.ImmediateShutdownException;
import proai.util.SetSpec;
-import proai.util.StreamUtil;
public class Updater extends Thread {
@@ -33,7 +32,6 @@
private int _maxRecordsPerTransaction;
private OAIDriver _driver;
- private RecordCache _cache;
private RCDatabase _db;
private RCDisk _disk;
private Validator _validator;
@@ -59,7 +57,6 @@
int maxRecordsPerTransaction,
Validator validator) {
_driver = driver;
- _cache = cache;
_db = db;
_disk = disk;
@@ -165,15 +162,12 @@
int pruneKey = Integer.parseInt(parts[0]);
File file = _disk.getFile(parts[1]);
- // attempt to delete from disk
- boolean removeFromPruneList = true;
if (file.exists()) {
boolean deleted = file.delete();
if (deleted) {
_LOG.debug("Deleted old cache file: " + parts[1]);
} else {
_LOG.warn("Unable to delete old cache file (will try again later): " + parts[1]);
- removeFromPruneList = false;
}
} else {
_LOG.debug("No need to delete non-existing old cache file: " + parts[1]);
@@ -260,7 +254,7 @@
updateIdentify(conn);
checkImmediateShutdown();
- List allPrefixes = updateFormats(conn);
+ List<String> allPrefixes = updateFormats(conn);
checkImmediateShutdown();
updateSets(conn);
@@ -311,13 +305,13 @@
* <p>This will add any new formats, modify any changed formats,
* and delete any no-longer-existing formats (and associated records).
*/
- private List updateFormats(Connection conn) throws Exception {
+ private List<String> updateFormats(Connection conn) throws Exception {
_LOG.info("Updating metadata formats...");
// apply new / updated
- RemoteIterator riter = _driver.listMetadataFormats();
- List newPrefixes = new ArrayList();
+ RemoteIterator<? extends MetadataFormat> riter = _driver.listMetadataFormats();
+ List<String> newPrefixes = new ArrayList<String>();
try {
while (riter.hasNext()) {
@@ -335,10 +329,10 @@
}
// apply deleted
- Iterator iter = _db.getFormats(conn).iterator();
+ Iterator<CachedMetadataFormat> iter = _db.getFormats(conn).iterator();
while (iter.hasNext()) {
- CachedMetadataFormat format = (CachedMetadataFormat) iter.next();
+ CachedMetadataFormat format = iter.next();
String oldPrefix = format.getPrefix();
if (!newPrefixes.contains(oldPrefix)) {
@@ -361,9 +355,9 @@
_LOG.info("Updating sets...");
// apply new / updated
- RemoteIterator riter = _driver.listSetInfo();
- Set newSpecs = new HashSet ();
- Set missingSpecs = new HashSet ();
+ RemoteIterator<? extends SetInfo> riter = _driver.listSetInfo();
+ Set<String> newSpecs = new HashSet<String> ();
+ Set<String> missingSpecs = new HashSet<String> ();
try {
while (riter.hasNext()) {
@@ -397,16 +391,14 @@
}
/* Add any sets that are IMPLIED to exist, but weren't defined */
- for (Iterator i = missingSpecs.iterator(); i.hasNext();) {
- String possiblyMissing = (String) i.next();
+ for (String possiblyMissing : missingSpecs) {
if (!SetSpec.isValid(possiblyMissing)) {
throw new RepositoryException("SetSpec '" + possiblyMissing
+ "' is malformed");
}
- for (Iterator m = SetSpec.allSetsFor(possiblyMissing).iterator(); m.hasNext();) {
- String spec = (String) m.next();
+ for (String spec : SetSpec.allSetsFor(possiblyMissing)) {
if (!newSpecs.contains(spec)) {
_db.putSetInfo(conn, spec, _disk.write(
SetSpec.defaultInfoFor(spec)));
@@ -417,7 +409,7 @@
}
// apply deleted
- Iterator iter = _db.getSetInfo(conn).iterator();
+ Iterator<SetInfo> iter = _db.getSetInfo(conn).iterator();
while (iter.hasNext()) {
String oldSpec = ((SetInfo) iter.next()).getSetSpec();
@@ -430,18 +422,16 @@
}
private void queueUpdatedRecords(Connection conn,
- List allPrefixes,
+ List<String> allPrefixes,
long latestRemoteDate) throws Exception {
_LOG.info("Querying and queueing updated records...");
long queueStartTime = System.currentTimeMillis();
int totalQueuedCount = 0;
-
- Iterator iter = allPrefixes.iterator();
- while (iter.hasNext()) {
-
- String mdPrefix = (String) iter.next();
+;
+ for (String mdPrefix : allPrefixes) {
+
long lastPollDate = _db.getLastPollDate(conn, mdPrefix);
// if something may have changed remotely *after* the last
@@ -453,7 +443,7 @@
+ lastPollDate + " is less than " + latestRemoteDate);
checkImmediateShutdown();
- RemoteIterator riter = _driver.listRecords(new Date(lastPollDate),
+ RemoteIterator<? extends Record> riter = _driver.listRecords(new Date(lastPollDate),
new Date(latestRemoteDate),
mdPrefix);
try {
@@ -462,7 +452,7 @@
while (riter.hasNext()) {
- Record record = (Record) riter.next();
+ Record record = riter.next();
checkImmediateShutdown();
_db.queueRemoteRecord(conn,
record.getItemID(),
@@ -634,9 +624,9 @@
}
// return null if no more batches or processing should stop
- protected List getNextBatch(List finishedItems) {
+ protected List<QueueItem> getNextBatch(List<QueueItem> finishedItems) {
- List nextBatch = null;
+ List<QueueItem> nextBatch = null;
if (!processingShouldStop()) {
@@ -647,7 +637,7 @@
try {
synchronized (_queueIterator) {
if (_queueIterator.hasNext()) {
- nextBatch = new ArrayList();
+ nextBatch = new ArrayList<QueueItem>();
while (_queueIterator.hasNext() &&
nextBatch.size() < _maxWorkBatchSize) {
nextBatch.add(_queueIterator.next());
Modified: trunk/src/java/proai/cache/Worker.java
===================================================================
--- trunk/src/java/proai/cache/Worker.java 2008-03-04 21:15:21 UTC (rev 29)
+++ trunk/src/java/proai/cache/Worker.java 2009-02-23 16:24:13 UTC (rev 30)
@@ -4,7 +4,6 @@
import java.util.*;
import net.sf.bvalid.Validator;
-import net.sf.bvalid.ValidationException;
import org.apache.log4j.Logger;
@@ -42,14 +41,14 @@
_LOG.info("Worker started");
- List queueItems = _updater.getNextBatch(null);
+ List<QueueItem> queueItems = _updater.getNextBatch(null);
while (queueItems != null && !_updater.processingShouldStop()) {
- Iterator iter = queueItems.iterator();
+ Iterator<QueueItem> iter = queueItems.iterator();
while (iter.hasNext() && !_updater.processingShouldStop()) {
- attempt((QueueItem) iter.next());
+ attempt(iter.next());
}
if (!_updater.processingShouldStop()) {
Modified: trunk/src/java/proai/driver/OAIDriver.java
===================================================================
--- trunk/src/java/proai/driver/OAIDriver.java 2008-03-04 21:15:21 UTC (rev 29)
+++ trunk/src/java/proai/driver/OAIDriver.java 2009-02-23 16:24:13 UTC (rev 30)
@@ -56,7 +56,7 @@
*
* @see proai.MetadataFormat
*/
- public RemoteIterator listMetadataFormats() throws RepositoryException;
+ public RemoteIterator<? extends MetadataFormat> listMetadataFormats() throws RepositoryException;
/**
* Get an iterator over a list of SetInfo objects representing all
@@ -71,7 +71,7 @@
*
* @see proai.SetInfo
*/
- public RemoteIterator listSetInfo() throws RepositoryException;
+ public RemoteIterator<? extends SetInfo> listSetInfo() throws RepositoryException;
/**
* Get an iterator of <code>Record</code> objects representing all records
@@ -84,7 +84,7 @@
*
* @see proai.Record
*/
- public RemoteIterator listRecords(Date from,
+ public RemoteIterator<? extends Record> listRecords(Date from,
Date until,
String mdPrefix) throws RepositoryException;
Modified: trunk/src/java/proai/driver/RemoteIterator.java
===================================================================
--- trunk/src/java/proai/driver/RemoteIterator.java 2008-03-04 21:15:21 UTC (rev 29)
+++ trunk/src/java/proai/driver/RemoteIterator.java 2009-02-23 16:24:13 UTC (rev 30)
@@ -3,11 +3,11 @@
import proai.CloseableIterator;
import proai.error.RepositoryException;
-public interface RemoteIterator extends CloseableIterator {
+public interface RemoteIterator<T> extends CloseableIterator<T> {
public boolean hasNext() throws RepositoryException;
- public Object next() throws RepositoryException;
+ public T next() throws RepositoryException;
public void close() throws RepositoryException;
Modified: trunk/src/java/proai/driver/impl/OAIDriverImpl.java
===================================================================
--- trunk/src/java/proai/driver/impl/OAIDriverImpl.java 2008-03-04 21:15:21 UTC (rev 29)
+++ trunk/src/java/proai/driver/impl/OAIDriverImpl.java 2009-02-23 16:24:13 UTC (rev 30)
@@ -4,10 +4,12 @@
import java.text.*;
import java.util.*;
+import proai.MetadataFormat;
+import proai.Record;
+import proai.SetInfo;
import proai.driver.OAIDriver;
import proai.driver.RemoteIterator;
import proai.error.RepositoryException;
-import proai.util.StreamUtil;
/**
* An simple OAIDriver for testing/demonstration purposes.
@@ -108,18 +110,20 @@
return new Date(latest);
}
- public RemoteIterator listMetadataFormats() {
- return new RemoteIteratorImpl(getMetadataFormatCollection().iterator());
+ public RemoteIterator<MetadataFormat> listMetadataFormats() {
+ return new RemoteIteratorImpl<MetadataFormat>(
+ getMetadataFormatCollection().iterator());
}
- public RemoteIterator listSetInfo() {
- return new RemoteIteratorImpl(getSetInfoCollection().iterator());
+ public RemoteIterator<SetInfo> listSetInfo() {
+ return new RemoteIteratorImpl<SetInfo>(
+ getSetInfoCollection().iterator());
}
- public RemoteIterator listRecords(Date from,
+ public RemoteIterator<Record> listRecords(Date from,
Date until,
String mdPrefix) {
- return new RemoteIteratorImpl(getRecordCollection(from,
+ return new RemoteIteratorImpl<Record>(getRecordCollection(from,
until,
mdPrefix).iterator());
}
@@ -155,9 +159,9 @@
}
}
- private Collection getSetInfoCollection() {
+ private Collection<SetInfo> getSetInfoCollection() {
try {
- List list = new ArrayList();
+ List<SetInfo> list = new ArrayList<SetInfo>();
String[] names = m_setsDir.list();
for (int i = 0; i < names.length; i++) {
if (names[i].endsWith(".xml")) {
@@ -172,9 +176,9 @@
}
}
- private Collection getMetadataFormatCollection() {
+ private Collection<MetadataFormat> getMetadataFormatCollection() {
try {
- List list = new ArrayList();
+ List<MetadataFormat> list = new ArrayList<MetadataFormat>();
String[] names = m_formatsDir.list();
for (int i = 0; i < names.length; i++) {
if (names[i].endsWith(".txt")) {
@@ -203,12 +207,11 @@
}
}
- private Collection getRecordCollection(Date from,
+ private Collection<Record> getRecordCollection(Date from,
Date until,
String mdPrefix) {
- List list = new ArrayList();
+ List<Record> list = new ArrayList<Record>();
DateFormat df = new SimpleDateFormat("yyyy-MM-dd'T'HH-mm-ss");
- long latest = 0;
String[] names = m_recordsDir.list();
for (int i = 0; i < names.length; i++) {
String[] temp = names[i].replaceFirst("-", " ")
Modified: trunk/src/java/proai/driver/impl/RecordImpl.java
===================================================================
--- trunk/src/java/proai/driver/impl/RecordImpl.java 2008-03-04 21:15:21 UTC (rev 29)
+++ trunk/src/java/proai/driver/impl/RecordImpl.java 2009-02-23 16:24:13 UTC (rev 30)
@@ -1,11 +1,8 @@
package proai.driver.impl;
import java.io.File;
-import java.io.PrintWriter;
import proai.Record;
-import proai.Writable;
-import proai.error.ServerException;
public class RecordImpl implements Record {
Modified: trunk/src/java/proai/driver/impl/RemoteIteratorImpl.java
===================================================================
--- trunk/src/java/proai/driver/impl/RemoteIteratorImpl.java 2008-03-04 21:15:21 UTC (rev 29)
+++ trunk/src/java/proai/driver/impl/RemoteIteratorImpl.java 2009-02-23 16:24:13 UTC (rev 30)
@@ -4,11 +4,11 @@
import proai.driver.RemoteIterator;
-public class RemoteIteratorImpl implements RemoteIterator {
+public class RemoteIteratorImpl<T> implements RemoteIterator<T> {
- private Iterator m_iter;
+ private Iterator<T> m_iter;
- public RemoteIteratorImpl(Iterator iter) {
+ public RemoteIteratorImpl(Iterator<T> iter) {
m_iter = iter;
}
@@ -16,7 +16,7 @@
return m_iter.hasNext();
}
- public Object next() {
+ public T next() {
return m_iter.next();
}
Modified: trunk/src/java/proai/error/BadArgumentException.java
===================================================================
--- trunk/src/java/proai/error/BadArgumentException.java 2008-03-04 21:15:21 UTC (rev 29)
+++ trunk/src/java/proai/error/BadArgumentException.java 2009-02-23 16:24:13 UTC (rev 30)
@@ -1,7 +1,8 @@
package proai.error;
public class BadArgumentException extends ProtocolException {
-
+ static final long serialVersionUID = 1;
+
public BadArgumentException() {
super("The request includes illegal arguments, is missing required arguments, includes a repeated argument, or values for arguments have an illegal syntax.");
}
Modified: trunk/src/java/proai/error/BadResumptionTokenException.java
===================================================================
--- trunk/src/java/proai/error/BadResumptionTokenException.java 2008-03-04 21:15:21 UTC (rev 29)
+++ trunk/src/java/proai/error/BadResumptionTokenException.java 2009-02-23 16:24:13 UTC (rev 30)
@@ -1,7 +1,8 @@
package proai.error;
public class BadResumptionTokenException extends ProtocolException {
-
+ static final long serialVersionUID = 1;
+
public BadResumptionTokenException() {
super("The value of the resumptionToken argument is invalid or expired.");
}
Modified: trunk/src/java/proai/error/BadVerbException.java
===================================================================
--- trunk/src/java/proai/error/BadVerbException.java 2008-03-04 21:15:21 UTC (rev 29)
+++ trunk/src/java/proai/error/BadVerbException.java 2009-02-23 16:24:13 UTC (rev 30)
@@ -1,7 +1,8 @@
package proai.error;
public class BadVerbException extends ProtocolException {
-
+ static final long serialVersionUID = 1;
+
public BadVerbException() {
super("Value of the verb argument is not a legal OAI-PMH verb, the verb argument is missing, or the verb argument is repeated.");
}
Modified: trunk/src/java/proai/error/CannotDisseminateFormatException.java
===================================================================
--- trunk/src/java/proai/error/CannotDisseminateFormatException.java 2008-03-04 21:15:21 UTC (rev 29)
+++ trunk/src/java/proai/error/CannotDisseminateFormatException.java 2009-02-23 16:24:13 UTC (rev 30)
@@ -1,7 +1,8 @@
package proai.error;
public class CannotDisseminateFormatException extends ProtocolException {
-
+ static final long serialVersionUID = 1;
+
public CannotDisseminateFormatException() {
super("The metadata format identified by the value given for the metadataPrefix argument is not supported by the item or by the repository.");
}
Modified: trunk/src/java/proai/error/IdDoesNotExistException.java
===================================================================
--- trunk/src/java/proai/error/IdDoesNotExistException.java 2008-03-04 21:15:21 UTC (rev 29)
+++ trunk/src/java/proai/error/IdDoesNotExistException.java 2009-02-23 16:24:13 UTC (rev 30)
@@ -1,7 +1,8 @@
package proai.error;
public class IdDoesNotExistException extends ProtocolException {
-
+ static final long serialVersionUID = 1;
+
public IdDoesNotExistException() {
super("The value of the identifier argument is unknown or illegal in this repository.");
}
Modified: trunk/src/java/proai/error/ImmediateShutdownException.java
===================================================================
--- trunk/src/java/proai/error/ImmediateShutdownException.java 2008-03-04 21:15:21 UTC (rev 29)
+++ trunk/src/java/proai/error/ImmediateShutdownException.java 2009-02-23 16:24:13 UTC (rev 30)
@@ -4,7 +4,8 @@
* Signals that an immediate shutdown has been requested.
*/
public class ImmediateShutdownException extends RuntimeException {
-
+ static final long serialVersionUID = 1;
+
public ImmediateShutdownException() {
super();
}
Modified: trunk/src/java/proai/error/NoMetadataFormatsException.java
===================================================================
--- trunk/src/java/proai/error/NoMetadataFormatsException.java 2008-03-04 21:15:21 UTC (rev 29)
+++ trunk/src/java/proai/error/NoMetadataFormatsException.java 2009-02-23 16:24:13 UTC (rev 30)
@@ -1,7 +1,8 @@
package proai.error;
public class NoMetadataFormatsException extends ProtocolException {
-
+ static final long serialVersionUID = 1;
+
public NoMetadataFormatsException() {
super("There are no metadata formats available for the specified item.");
}
Modified: trunk/src/java/proai/error/NoRecordsMatchException.java
===================================================================
--- trunk/src/java/proai/error/NoRecordsMatchException.java 2008-03-04 21:15:21 UTC (rev 29)
+++ trunk/src/java/proai/error/NoRecordsMatchException.java 2009-02-23 16:24:13 UTC (rev 30)
@@ -1,7 +1,8 @@
package proai.error;
public class NoRecordsMatchException extends ProtocolException {
-
+ static final long serialVersionUID = 1;
+
public NoRecordsMatchException() {
super("The combination of the values of the from, until, set and metadataPrefix arguments results in an empty list.");
}
Modified: trunk/src/java/proai/error/NoSetHierarchyException.java
===================================================================
--- trunk/src/java/proai/error/NoSetHierarchyException.java 2008-03-04 21:15:21 UTC (rev 29)
+++ trunk/src/java/proai/error/NoSetHierarchyException.java 2009-02-23 16:24:13 UTC (rev 30)
@@ -1,7 +1,8 @@
package proai.error;
public class NoSetHierarchyException extends ProtocolException {
-
+ static final long serialVersionUID = 1;
+
public NoSetHierarchyException() {
super("The repository does not support sets.");
}
Modified: trunk/src/java/proai/error/ProtocolException.java
===================================================================
--- trunk/src/java/proai/error/ProtocolException.java 2008-03-04 21:15:21 UTC (rev 29)
+++ trunk/src/java/proai/error/ProtocolException.java 2009-02-23 16:24:13 UTC (rev 30)
@@ -1,7 +1,8 @@
package proai.error;
public abstract class ProtocolException extends ServerException {
-
+ static final long serialVersionUID = 1;
+
public ProtocolException(String message) {
super(message);
}
Modified: trunk/src/java/proai/error/RepositoryException.java
===================================================================
--- trunk/src/java/proai/error/RepositoryException.java 2008-03-04 21:15:21 UTC (rev 29)
+++ trunk/src/java/proai/error/RepositoryException.java 2009-02-23 16:24:13 UTC (rev 30)
@@ -1,7 +1,8 @@
package proai.error;
public class RepositoryException extends ServerException {
-
+ static final long serialVersionUID = 1;
+
public RepositoryException(String message) {
super(message);
}
Modified: trunk/src/java/proai/error/ServerException.java
===================================================================
--- trunk/src/java/proai/error/ServerException.java 2008-03-04 21:15:21 UTC (rev 29)
+++ trunk/src/java/proai/error/ServerException.java 2009-02-23 16:24:13 UTC (rev 30)
@@ -4,7 +4,8 @@
* Signals an unexpected condition with the server.
*/
public class ServerException extends RuntimeException {
-
+ static final long serialVersionUID = 1;
+
public ServerException(String message) {
super(message);
}
Modified: trunk/src/java/proai/service/CacheSession.java
===================================================================
--- trunk/src/java/proai/service/CacheSession.java 2008-03-04 21:15:21 UTC (rev 29)
+++ trunk/src/java/proai/service/CacheSession.java 2009-02-23 16:24:13 UTC (rev 30)
@@ -9,7 +9,7 @@
import proai.cache.*;
import proai.error.*;
-public class CacheSession extends Thread
+public class CacheSession<T> extends Thread
implements Session {
private static final Logger _LOG =
@@ -18,7 +18,7 @@
private SessionManager _manager;
private File _baseDir;
private int _secondsBetweenRequests;
- private ListProvider _provider;
+ private ListProvider<T> _provider;
private String _sessionKey;
@@ -34,7 +34,7 @@
public CacheSession(SessionManager manager,
File baseDir,
int secondsBetweenRequests,
- ListProvider provider) {
+ ListProvider<T> provider) {
_manager = manager;
_baseDir = baseDir;
_secondsBetweenRequests = secondsBetweenRequests;
@@ -63,9 +63,8 @@
public void run() {
_LOG.info(_sessionKey + " retrieval thread started");
- RecordCache cache = _provider.getRecordCache();
int incompleteListSize = _provider.getIncompleteListSize();
- CloseableIterator iter = null;
+ CloseableIterator<String[]> iter = null;
PrintWriter out = null;
try {
iter = _provider.getPathList(); // if empty, the impl should throw the right exception here
Modified: trunk/src/java/proai/service/ListProvider.java
===================================================================
--- trunk/src/java/proai/service/ListProvider.java 2008-03-04 21:15:21 UTC (rev 29)
+++ trunk/src/java/proai/service/ListProvider.java 2009-02-23 16:24:13 UTC (rev 30)
@@ -4,12 +4,12 @@
import proai.cache.*;
import proai.error.*;
-public interface ListProvider {
+public interface ListProvider<T> {
- public CloseableIterator getList() throws ServerException;
+ public CloseableIterator<T> getList() throws ServerException;
// abbreviated form of above -- gets String[]s of ("cachePath" [, "dateString"])
- public CloseableIterator getPathList() throws ServerException;
+ public CloseableIterator<String[]> getPathList() throws ServerException;
public RecordCache getRecordCache();
Modified: trunk/src/java/proai/service/ProviderServlet.java
===================================================================
--- trunk/src/java/proai/service/ProviderServlet.java 2008-03-04 21:15:21 UTC (rev 29)
+++ trunk/src/java/proai/service/ProviderServlet.java 2009-02-23 16:24:13 UTC (rev 30)
@@ -17,6 +17,7 @@
import proai.util.StreamUtil;
public class ProviderServlet extends HttpServlet {
+ static final long serialVersionUID = 1;
private static final Logger logger =
Logger.getLogger(ProviderServlet.class.getName());
@@ -32,6 +33,7 @@
/**
* Entry point for handling OAI requests.
*/
+ @SuppressWarnings("unchecked")
public void doGet(HttpServletRequest request,
HttpServletResponse response) {
@@ -218,27 +220,11 @@
}
}
- private void sendBusy(HttpServletResponse response) {
- try {
- response.setStatus(HttpServletResponse.SC_SERVICE_UNAVAILABLE);
- response.setHeader("Retry-After", "" + m_retrySeconds);
- response.setContentType("text/plain; charset=UTF-8");
- PrintWriter writer = response.getWriter();
- writer.println("The OAI provider is too busy. Try again in " + m_retrySeconds + " seconds.");
- writer.flush();
- writer.close();
- } catch (Throwable th) {
- logger.warn("Error while sending SERVICE_UNAVAILABLE (503) response", th);
- }
- }
-
public void doPost(HttpServletRequest request,
HttpServletResponse response) {
doGet(request, response);
}
- private int m_retrySeconds;
-
private Responder m_responder;
public void init() throws ServletException {
@@ -257,7 +243,6 @@
public void init(Properties props) throws ServerException {
m_responder = new Responder(props);
- m_retrySeconds = 60;
}
/**
Modified: trunk/src/java/proai/service/RecordListProvider.java
===================================================================
--- trunk/src/java/proai/service/RecordListProvider.java 2008-03-04 21:15:21 UTC (rev 29)
+++ trunk/src/java/proai/service/RecordListProvider.java 2009-02-23 16:24:13 UTC (rev 30)
@@ -6,7 +6,7 @@
import proai.cache.*;
import proai.error.*;
-public class RecordListProvider implements ListProvider {
+public class RecordListProvider implements ListProvider<CachedContent> {
private RecordCache m_cache;
private int m_incompleteListSize;
@@ -33,12 +33,12 @@
m_set = set;
}
- public CloseableIterator getList() throws
+ public CloseableIterator<CachedContent> getList() throws
CannotDisseminateFormatException,
NoRecordsMatchException,
NoSetHierarchyException,
ServerException {
- CloseableIterator iter = m_cache.getRecordsContent(m_from,
+ CloseableIterator<CachedContent> iter = m_cache.getRecordsContent(m_from,
m_until,
m_prefix,
m_set,
@@ -49,7 +49,7 @@
throw new CannotDisseminateFormatException(Responder.ERR_NO_SUCH_FORMAT);
}
if (m_set != null) {
- CloseableIterator sic = m_cache.getSetInfoContent();
+ CloseableIterator<SetInfo> sic = m_cache.getSetInfoContent();
boolean supportsSets = sic.hasNext();
try { sic.close(); } catch (Exception e) { }
if (!supportsSets) {
@@ -59,12 +59,12 @@
throw new NoRecordsMatchException(Responder.ERR_NO_RECORDS_MATCH);
}
- public CloseableIterator getPathList() throws
+ public CloseableIterator<String[]> getPathList() throws
CannotDisseminateFormatException,
NoRecordsMatchException,
NoSetHierarchyException,
ServerException {
- CloseableIterator iter = m_cache.getRecordsPaths(m_from,
+ CloseableIterator<String[]> iter = m_cache.getRecordsPaths(m_from,
m_until,
m_prefix,
m_set);
@@ -74,7 +74,7 @@
throw new CannotDisseminateFormatException(Responder.ERR_NO_SUCH_FORMAT);
}
if (m_set != null) {
- CloseableIterator sic = m_cache.getSetInfoContent();
+ CloseableIterator<SetInfo> sic = m_cache.getSetInfoContent();
boolean supportsSets = sic.hasNext();
try { sic.close(); } catch (Exception e) { }
if (!supportsSets) {
Modified: trunk/src/java/proai/service/Responder.java
===================================================================
--- trunk/src/java/proai/service/Responder.java 2008-03-04 21:15:21 UTC (rev 29)
+++ trunk/src/java/proai/service/Responder.java 2009-02-23 16:24:13 UTC (rev 30)
@@ -251,7 +251,7 @@
checkGranularity(from, until);
checkFromUntil(fromDate, untilDate);
checkMetadataPrefix(metadataPrefix);
- ListProvider provider = new RecordListProvider(m_cache,
+ ListProvider<CachedContent> provider = new RecordListProvider(m_cache,
incompleteListSize,
identifiersOnly,
fromDate,
@@ -388,7 +388,7 @@
}
try {
if (resumptionToken == null) {
- ListProvider provider = new SetListProvider(m_cache, m_incompleteSetListSize);
+ ListProvider<SetInfo> provider = new SetListProvider(m_cache, m_incompleteSetListSize);
return m_sessionManager.list(provider);
} else {
return m_sessionManager.getResponseData(resumptionToken);
Modified: trunk/src/java/proai/service/Session.java
===================================================================
--- trunk/src/java/proai/service/Session.java 2008-03-04 21:15:21 UTC (rev 29)
+++ trunk/src/jav...
[truncated message content] |