Permalink
Browse files

XOAI Core Library (Version 2.2.9). Fixed incorrect virtual set count.…

… Fixed incorrect date issue [DS-1311]. Fixed incorrect count at last page (XSLT).
  • Loading branch information...
1 parent 34c0b3b commit d6cf7b540104fdacd946115576142ed14a1dc14a @lyncodev lyncodev committed Oct 27, 2012
View
2 dspace-oai/pom.xml
@@ -66,7 +66,7 @@
<dependency>
<groupId>com.lyncode</groupId>
<artifactId>xoai</artifactId>
- <version>2.2.8</version>
+ <version>2.2.9</version>
</dependency>
<dependency>
<groupId>org.dspace</groupId>
View
13 dspace-oai/src/main/java/org/dspace/xoai/app/XOAI.java
@@ -11,6 +11,7 @@
import java.io.IOException;
import java.net.ConnectException;
import java.sql.SQLException;
+import java.text.ParseException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
@@ -48,6 +49,7 @@
import org.dspace.xoai.solr.DSpaceSolrServer;
import org.dspace.xoai.solr.exceptions.DSpaceSolrException;
import org.dspace.xoai.solr.exceptions.DSpaceSolrIndexerException;
+import org.dspace.xoai.util.DateUtils;
import org.dspace.xoai.util.ItemUtils;
import org.dspace.xoai.util.XOAICacheManager;
import org.dspace.xoai.util.XOAIDatabaseManager;
@@ -224,7 +226,10 @@ private int index(TableRowIterator iterator)
catch (MetadataBindException e)
{
log.error(e.getMessage(), e);
- }
+ } catch (ParseException e)
+ {
+ log.error(e.getMessage(), e);
+ }
i++;
if (i % 100 == 0) System.out.println(i+" items imported so far...");
}
@@ -245,16 +250,16 @@ private int index(TableRowIterator iterator)
throw new DSpaceSolrIndexerException(ex.getMessage(), ex);
}
}
-
- private SolrInputDocument index(Item item) throws SQLException, MetadataBindException
+
+ private SolrInputDocument index(Item item) throws SQLException, MetadataBindException, ParseException
{
SolrInputDocument doc = new SolrInputDocument();
doc.addField("item.id", item.getID());
boolean pub = this.isPublic(item);
doc.addField("item.public", pub);
String handle = item.getHandle();
doc.addField("item.handle", handle);
- doc.addField("item.lastmodified", item.getLastModified());
+ doc.addField("item.lastmodified", DateUtils.toSolrDate(item.getLastModified()));
doc.addField("item.submitter", item.getSubmitter().getEmail());
doc.addField("item.deleted", item.isWithdrawn() ? "true" : "false");
for (Collection col : item.getCollections())
View
7 dspace-oai/src/main/java/org/dspace/xoai/filter/DateFromFilter.java
@@ -42,16 +42,11 @@ public boolean isShown(DSpaceItem item)
return false;
}
- private String dateToString(Date date)
- {
- return DateUtils.formatToSolr(date);
- }
-
@Override
public SolrFilterResult getQuery()
{
return new SolrFilterResult("item.lastmodified:["
- + ClientUtils.escapeQueryChars(this.dateToString(_date))
+ + ClientUtils.escapeQueryChars(DateUtils.formatToSolr(_date))
+ " TO *]");
}
View
12 dspace-oai/src/main/java/org/dspace/xoai/filter/DateUntilFilter.java
@@ -7,12 +7,12 @@
*/
package org.dspace.xoai.filter;
-import java.text.SimpleDateFormat;
import java.util.Date;
import org.apache.solr.client.solrj.util.ClientUtils;
import org.dspace.core.Context;
import org.dspace.xoai.data.DSpaceItem;
+import org.dspace.xoai.util.DateUtils;
/**
*
@@ -42,18 +42,12 @@ public boolean isShown(DSpaceItem item)
return false;
}
- private String dateToString(Date date)
- {
- SimpleDateFormat formatDate = new SimpleDateFormat(
- "yyyy-MM-dd'T'HH:mm:ss'Z'");
- return formatDate.format(date);
- }
-
@Override
public SolrFilterResult getQuery()
{
+ System.out.println("HEYYYY!!!!");
return new SolrFilterResult("item.lastmodified:[* TO "
- + ClientUtils.escapeQueryChars(this.dateToString(_date)) + "]");
+ + ClientUtils.escapeQueryChars(DateUtils.formatToSolr(_date, false)) + "]");
}
}
View
19 dspace-oai/src/main/java/org/dspace/xoai/util/DateUtils.java
@@ -11,7 +11,6 @@
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Locale;
-import java.util.TimeZone;
import org.apache.log4j.LogManager;
import org.apache.log4j.Logger;
@@ -27,11 +26,15 @@
public static String formatToSolr(Date date)
{
+ return formatToSolr(date, true);
+ }
+ public static String formatToSolr(Date date, boolean init)
+ {
// 2008-01-01T00:00:00Z
- SimpleDateFormat format = new SimpleDateFormat(
- "yyyy-MM-dd'T'HH:mm:ss'Z'", Locale.getDefault());
- format.setTimeZone(TimeZone.getTimeZone("UTC"));
- String ret = format.format(date);
+ SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.'000Z'");
+ if (!init) sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.'999Z'");
+ String ret = sdf.format(date);
+ System.out.println(ret);
return ret;
}
@@ -107,4 +110,10 @@ public static Date parseFromSolrDate(String date)
}
return new Date();
}
+
+ public static Date toSolrDate (Date date) throws ParseException {
+ SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'");
+ Date indexFormatExpiryDate = sdf.parse(sdf.format(date));
+ return indexFormatExpiryDate;
+ }
}
View
7 dspace-oai/src/main/java/org/dspace/xoai/util/ItemUtils.java
@@ -56,13 +56,6 @@ private static Element create(ObjectFactory factory, String name)
return e;
}
- private static Element.Field createValue(ObjectFactory factory, String value)
- {
- Element.Field e = factory.createElementField();
- e.setValue(value);
- return e;
- }
-
private static Element.Field createValue(ObjectFactory factory,
String name, String value)
{
View
2 dspace-oai/src/main/webapp/static/style.xsl
@@ -1267,7 +1267,7 @@
<xsl:choose>
<xsl:when test="$cursor">
<xsl:choose>
- <xsl:when test="$path/../oai:resumptionToken/text() = ''">
+ <xsl:when test="normalize-space($path/../oai:resumptionToken/text()) = ''">
<!-- on the last page of results we have to assume that @completeListSize is available -->
<xsl:value-of
select="$total - $count" />

0 comments on commit d6cf7b5

Please sign in to comment.