Permalink
Browse files

h1. OAI v2.1

h2. Bug fixes:

* Default context without restricted items
* Solr Timezone
* Compilable with 1.6
* DS-1902
* DS-1898

h2. New Features:

* Operators over filters (combination of filters) - foundation work for OpenAIRE guidelines v3.
* Redesigned interface
* Root context (/oai) now displays the list of available contexts

h2. Other:

Using new XOAI 3.2.7 core
  • Loading branch information...
1 parent 049eb50 commit 403d7fbee53f8a9d21b059669999e649d4838ecf @lyncodev lyncodev committed Feb 5, 2014
@@ -333,7 +333,7 @@ private void clearIndex() throws DSpaceSolrIndexerException {
}
}
- private static void cleanCache(XOAIItemCacheService xoaiItemCacheService, XOAICacheService xoaiCacheService) {
+ private static void cleanCache(XOAIItemCacheService xoaiItemCacheService, XOAICacheService xoaiCacheService) throws IOException {
System.out.println("Purging cached OAI responses.");
xoaiItemCacheService.deleteAll();
xoaiCacheService.deleteAll();
@@ -438,7 +438,7 @@ public static void main(String[] argv) throws IOException, ConfigurationExceptio
}
}
- private static void cleanCompiledItems(XOAIItemCacheService itemCacheService) {
+ private static void cleanCompiledItems(XOAIItemCacheService itemCacheService) throws IOException {
System.out.println("Purging compiled items");
itemCacheService.deleteAll();
}
@@ -136,9 +136,11 @@ public String contextAction (Model model, HttpServletRequest request, HttpServle
closeContext(context);
response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR,
"Unexpected error while writing the output. For more information visit the log files.");
+ } finally {
+ closeContext(context);
}
- return null;
+ return null; // response without content
}
private void closeContext(Context context) {
@@ -16,5 +16,19 @@
package org.dspace.xoai.exceptions;
-public class InvalidSetSpecException {
+public class InvalidSetSpecException extends Exception {
+ public InvalidSetSpecException() {
+ }
+
+ public InvalidSetSpecException(String message) {
+ super(message);
+ }
+
+ public InvalidSetSpecException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ public InvalidSetSpecException(Throwable cause) {
+ super(cause);
+ }
}
@@ -0,0 +1,119 @@
+/**
+ * The contents of this file are subject to the license and copyright
+ * detailed in the LICENSE and NOTICE files at the root of the source
+ * tree and available online at
+ *
+ * http://www.dspace.org/license/
+ */
+package org.dspace.xoai.filter;
+
+import com.lyncode.xoai.dataprovider.core.ReferenceSet;
+import org.apache.commons.lang.StringUtils;
+import org.apache.log4j.LogManager;
+import org.apache.log4j.Logger;
+import org.apache.solr.client.solrj.util.ClientUtils;
+import org.dspace.content.DSpaceObject;
+import org.dspace.core.Context;
+import org.dspace.xoai.data.DSpaceItem;
+import org.dspace.xoai.filter.results.DatabaseFilterResult;
+import org.dspace.xoai.filter.results.SolrFilterResult;
+import org.dspace.xoai.services.api.database.CollectionsService;
+import org.dspace.xoai.services.api.database.HandleResolver;
+
+import java.util.List;
+
+/**
+ *
+ * @author Lyncode Development Team <dspace@lyncode.com>
+ */
+public class DSpaceSetSpecFilter extends DSpaceFilter
+{
+ private static Logger log = LogManager.getLogger(DSpaceSetSpecFilter.class);
+
+ private String setSpec;
+ private HandleResolver handleResolver;
+ private CollectionsService collectionsService;
+
+ public DSpaceSetSpecFilter(CollectionsService collectionsService, HandleResolver handleResolver, String spec)
+ {
+ this.collectionsService = collectionsService;
+ this.handleResolver = handleResolver;
+ this.setSpec = spec;
+ }
+
+ @Override
+ public DatabaseFilterResult buildDatabaseQuery(Context context)
+ {
+ if (setSpec.startsWith("col_"))
+ {
+ try
+ {
+ DSpaceObject dso = handleResolver.resolve(setSpec.replace("col_", ""));
+ return new DatabaseFilterResult(
+ "EXISTS (SELECT tmp.* FROM collection2item tmp WHERE tmp.item_id=i.item_id AND collection_id = ?)",
+ dso.getID());
+ }
+ catch (Exception ex)
+ {
+ log.error(ex.getMessage(), ex);
+ }
+ }
+ else if (setSpec.startsWith("com_"))
+ {
+ try
+ {
+ DSpaceObject dso = handleResolver.resolve(setSpec.replace("com_", ""));
+ List<Integer> list = collectionsService.getAllSubCollections(dso.getID());
+ String subCollections = StringUtils.join(list.iterator(), ",");
+ return new DatabaseFilterResult(
+ "EXISTS (SELECT tmp.* FROM collection2item tmp WHERE tmp.item_id=i.item_id AND collection_id IN ("
+ + subCollections + "))");
+ }
+ catch (Exception e)
+ {
+ log.error(e.getMessage(), e);
+ }
+ }
+ return new DatabaseFilterResult();
+ }
+
+ @Override
+ public boolean isShown(DSpaceItem item)
+ {
+ for (ReferenceSet s : item.getSets())
+ if (s.getSetSpec().equals(setSpec))
+ return true;
+ return false;
+ }
+
+ @Override
+ public SolrFilterResult buildSolrQuery()
+ {
+ if (setSpec.startsWith("col_"))
+ {
+ try
+ {
+ return new SolrFilterResult("item.collections:"
+ + ClientUtils.escapeQueryChars(setSpec));
+ }
+ catch (Exception ex)
+ {
+ log.error(ex.getMessage(), ex);
+ }
+ }
+ else if (setSpec.startsWith("com_"))
+ {
+ try
+ {
+ return new SolrFilterResult("item.communities:"
+ + ClientUtils.escapeQueryChars(setSpec));
+ }
+ catch (Exception e)
+ {
+ log.error(e.getMessage(), e);
+ }
+ }
+ return new SolrFilterResult();
+ }
+
+}
@@ -19,5 +19,5 @@
void handle (String requestID, OutputStream out) throws IOException;
void store (String requestID, OAIPMH response) throws IOException;
void delete (String requestID);
- void deleteAll ();
+ void deleteAll () throws IOException;
}
@@ -18,5 +18,5 @@
Metadata get (Item item) throws IOException;
void put (Item item, Metadata metadata) throws IOException;
void delete (Item item);
- void deleteAll();
+ void deleteAll() throws IOException;
}
@@ -21,8 +21,4 @@ public XOAIManagerResolverException(String message, Throwable cause) {
public XOAIManagerResolverException(Throwable cause) {
super(cause);
}
-
- public XOAIManagerResolverException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) {
- super(message, cause, enableSuppression, writableStackTrace);
- }
}
@@ -22,8 +22,4 @@ public ContextServiceException(String message, Throwable cause) {
public ContextServiceException(Throwable cause) {
super(cause);
}
-
- public ContextServiceException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) {
- super(message, cause, enableSuppression, writableStackTrace);
- }
}
@@ -24,6 +24,7 @@
import java.util.Date;
import static com.lyncode.xoai.dataprovider.core.Granularity.Second;
+import static org.apache.commons.io.FileUtils.deleteDirectory;
import static org.apache.commons.io.IOUtils.copy;
import static org.apache.commons.io.IOUtils.write;
@@ -115,12 +116,12 @@ public void store(String requestID, OAIPMH response) throws IOException {
@Override
public void delete(String requestID) {
- FileUtils.deleteQuietly(this.getCacheFile(requestID));
+ this.getCacheFile(requestID).delete();
}
@Override
- public void deleteAll() {
- FileUtils.deleteQuietly(new File(getBaseDir()));
+ public void deleteAll() throws IOException {
+ deleteDirectory(new File(getBaseDir()));
}
}
@@ -24,7 +24,7 @@
import java.io.IOException;
import static com.lyncode.xoai.dataprovider.core.Granularity.Second;
-import static org.apache.commons.io.FileUtils.deleteQuietly;
+import static org.apache.commons.io.FileUtils.deleteDirectory;
public class DSpaceXOAIItemCacheService implements XOAIItemCacheService {
@@ -104,13 +104,13 @@ public void put(Item item, Metadata metadata) throws IOException {
@Override
public void delete(Item item) {
- deleteQuietly(this.getMetadataCache(item));
+ this.getMetadataCache(item).delete();
}
@Override
- public void deleteAll() {
- deleteQuietly(new File(getBaseDir()));
+ public void deleteAll() throws IOException {
+ deleteDirectory(new File(getBaseDir()));
}
}
@@ -17,7 +17,6 @@
<xsl:template match="/">
<junii2
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
version="3.0">
<!-- title:none = title -->
<xsl:for-each select="doc:metadata/doc:element[@name='dc']/doc:element[@name='title']/doc:element/doc:field">

0 comments on commit 403d7fb

Please sign in to comment.