|
From: <cw...@us...> - 2007-08-13 18:02:44
|
Revision: 23
http://proai.svn.sourceforge.net/proai/?rev=23&view=rev
Author: cwilper
Date: 2007-08-13 11:02:41 -0700 (Mon, 13 Aug 2007)
Log Message:
-----------
added patch contributed by Juan Corrales,
to fix OpenArchives validation issue
Modified Paths:
--------------
trunk/src/java/proai/service/ProviderServlet.java
trunk/src/java/proai/service/Responder.java
Added Paths:
-----------
trunk/CONTRIBUTORS.txt
Added: trunk/CONTRIBUTORS.txt
===================================================================
--- trunk/CONTRIBUTORS.txt (rev 0)
+++ trunk/CONTRIBUTORS.txt 2007-08-13 18:02:41 UTC (rev 23)
@@ -0,0 +1,3 @@
+Juan Corrales - jco...@us...
+ Submitted patch to pass OpenArchives registration validation.
+ Sourceforge bug #1773259
Modified: trunk/src/java/proai/service/ProviderServlet.java
===================================================================
--- trunk/src/java/proai/service/ProviderServlet.java 2007-01-18 18:14:36 UTC (rev 22)
+++ trunk/src/java/proai/service/ProviderServlet.java 2007-08-13 18:02:41 UTC (rev 23)
@@ -60,7 +60,7 @@
try {
url = request.getRequestURL().toString();
verb = request.getParameter("verb");
- if (verb == null) throw new BadArgumentException("must specify a verb");
+ if (verb == null) throw new BadVerbException("request did not specify a verb");
identifier = request.getParameter("identifier");
from = request.getParameter("from");
until = request.getParameter("until");
@@ -107,7 +107,7 @@
if (argCount > 1) throw new BadArgumentException("one or zero arguments needed, got " + argCount);
data = m_responder.listSets(resumptionToken);
} else {
- throw new BadArgumentException("bad verb: " + verb);
+ throw new BadVerbException("bad verb: " + verb);
}
response.setStatus(HttpServletResponse.SC_OK);
response.setContentType("text/xml; charset=UTF-8");
@@ -274,4 +274,4 @@
}
}
-}
\ No newline at end of file
+}
Modified: trunk/src/java/proai/service/Responder.java
===================================================================
--- trunk/src/java/proai/service/Responder.java 2007-01-18 18:14:36 UTC (rev 22)
+++ trunk/src/java/proai/service/Responder.java 2007-08-13 18:02:41 UTC (rev 23)
@@ -248,6 +248,7 @@
Date fromDate = validDate(from);
Date untilDate = validDate(until);
+ checkGranularity(from, until);
checkFromUntil(fromDate, untilDate);
checkMetadataPrefix(metadataPrefix);
ListProvider provider = new RecordListProvider(m_cache,
@@ -460,6 +461,22 @@
}
/**
+ * Checks that the granularity of the from and until arguments match.
+ */
+ private static void checkGranularity(String from, String until)
+ throws BadArgumentException {
+ if (from!= null && until!=null) {
+ if ( ( (from.endsWith("Z"))
+ && (!until.endsWith("Z")) )
+ || ( (until.endsWith("Z"))
+ && (!from.endsWith("Z")) ) ) {
+ throw new BadArgumentException("Date granularities of from and "
+ + "until arguments do not match.");
+ }
+ }
+ }
+
+ /**
* If <code>from</code> is later than <code>until</code>, throw a
* <code>BadArgumentException</code>.
*
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|