mirror of
https://github.com/DSpace/DSpace.git
synced 2025-10-07 10:04:21 +00:00
[DS-1834] Collection content source harvesting test does not check sets properly
This commit is contained in:
@@ -29,6 +29,7 @@ import java.util.TimeZone;
|
|||||||
import javax.xml.parsers.ParserConfigurationException;
|
import javax.xml.parsers.ParserConfigurationException;
|
||||||
import javax.xml.transform.TransformerException;
|
import javax.xml.transform.TransformerException;
|
||||||
|
|
||||||
|
import ORG.oclc.oai.harvester2.verb.*;
|
||||||
import org.apache.commons.lang.StringUtils;
|
import org.apache.commons.lang.StringUtils;
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
import org.dspace.authorize.AuthorizeException;
|
import org.dspace.authorize.AuthorizeException;
|
||||||
@@ -64,12 +65,6 @@ import org.jdom.input.DOMBuilder;
|
|||||||
import org.jdom.output.XMLOutputter;
|
import org.jdom.output.XMLOutputter;
|
||||||
import org.xml.sax.SAXException;
|
import org.xml.sax.SAXException;
|
||||||
|
|
||||||
import ORG.oclc.oai.harvester2.verb.GetRecord;
|
|
||||||
import ORG.oclc.oai.harvester2.verb.Identify;
|
|
||||||
import ORG.oclc.oai.harvester2.verb.ListMetadataFormats;
|
|
||||||
import ORG.oclc.oai.harvester2.verb.ListRecords;
|
|
||||||
import ORG.oclc.oai.harvester2.verb.ListSets;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This class handles OAI harvesting of externally located records into this repository.
|
* This class handles OAI harvesting of externally located records into this repository.
|
||||||
@@ -958,29 +953,21 @@ public class OAIHarvester {
|
|||||||
try {
|
try {
|
||||||
//If we do not want to harvest from one set, then skip this.
|
//If we do not want to harvest from one set, then skip this.
|
||||||
if(!"all".equals(oaiSetId)){
|
if(!"all".equals(oaiSetId)){
|
||||||
ListSets ls = new ListSets(oaiSource);
|
ListIdentifiers ls = new ListIdentifiers(oaiSource, null, null, oaiSetId, DMDOAIPrefix);
|
||||||
|
|
||||||
// The only error we can really get here is "noSetHierarchy"
|
// The only error we can really get here is "noSetHierarchy"
|
||||||
if (ls.getErrors() != null && ls.getErrors().getLength() > 0) {
|
if (ls.getErrors() != null && ls.getErrors().getLength() > 0) {
|
||||||
for (int i=0; i<ls.getErrors().getLength(); i++) {
|
for (int i=0; i<ls.getErrors().getLength(); i++) {
|
||||||
String errorCode = ls.getErrors().item(i).getAttributes().getNamedItem("code").getTextContent();
|
String errorCode = ls.getErrors().item(i).getAttributes().getNamedItem("code").getTextContent();
|
||||||
errorSet.add(errorCode);
|
errorSet.add(OAI_SET_ERROR + ": The OAI server does not have a set with the specified setSpec (" + errorCode + ")");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// Drilling down to /OAI-PMH/ListSets/set
|
// Drilling down to /OAI-PMH/ListSets/set
|
||||||
Document reply = db.build(ls.getDocument());
|
Document reply = db.build(ls.getDocument());
|
||||||
Element root = reply.getRootElement();
|
Element root = reply.getRootElement();
|
||||||
List<Element> sets= root.getChild("ListSets",OAI_NS).getChildren("set",OAI_NS);
|
//Check if we can find items, if so this indicates that we have children and our sets exist
|
||||||
|
foundSet = 0 < root.getChild("ListIdentifiers",OAI_NS).getChildren().size();
|
||||||
for (Element set : sets)
|
|
||||||
{
|
|
||||||
String setSpec = set.getChildText("setSpec", OAI_NS);
|
|
||||||
if (setSpec.equals(oaiSetId)) {
|
|
||||||
foundSet = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!foundSet) {
|
if (!foundSet) {
|
||||||
errorSet.add(OAI_SET_ERROR + ": The OAI server does not have a set with the specified setSpec");
|
errorSet.add(OAI_SET_ERROR + ": The OAI server does not have a set with the specified setSpec");
|
||||||
|
Reference in New Issue
Block a user