Revision 8189
Added by ben leinfelder over 10 years ago
SystemMetadataFactory.java | ||
---|---|---|
28 | 28 |
import java.io.File; |
29 | 29 |
import java.io.IOException; |
30 | 30 |
import java.io.InputStream; |
31 |
import java.io.InputStreamReader; |
|
31 | 32 |
import java.math.BigInteger; |
32 | 33 |
import java.net.URL; |
33 | 34 |
import java.net.URLConnection; |
... | ... | |
70 | 71 |
import org.dataone.service.util.DateTimeMarshaller; |
71 | 72 |
import org.dspace.foresite.ResourceMap; |
72 | 73 |
import org.jibx.runtime.JiBXException; |
74 |
import org.w3c.dom.Node; |
|
75 |
import org.w3c.dom.NodeList; |
|
73 | 76 |
import org.xml.sax.SAXException; |
74 | 77 |
|
75 | 78 |
import java.util.Calendar; |
... | ... | |
93 | 96 |
import edu.ucsb.nceas.metacat.util.DocumentUtil; |
94 | 97 |
import edu.ucsb.nceas.utilities.ParseLSIDException; |
95 | 98 |
import edu.ucsb.nceas.utilities.PropertyNotFoundException; |
99 |
import edu.ucsb.nceas.utilities.XMLUtilities; |
|
96 | 100 |
|
97 | 101 |
public class SystemMetadataFactory { |
98 | 102 |
|
... | ... | |
660 | 664 |
|
661 | 665 |
/** |
662 | 666 |
* Determines if we already have registered an ORE map for this package |
667 |
* NOTE: uses a solr query to locate OREs for the object |
|
663 | 668 |
* @param guid of the EML/packaging object |
664 | 669 |
* @return true if there is an ORE map for the given package |
665 | 670 |
*/ |
666 |
private static boolean oreExistsFor(Identifier guid) { |
|
667 |
// TODO: implement call to CN.search() |
|
671 |
public static boolean oreExistsFor(Identifier guid) { |
|
672 |
// Search for the ORE if we can find it |
|
673 |
String pid = guid.getValue(); |
|
674 |
MockHttpServletRequest request = new MockHttpServletRequest(null, null, null); |
|
675 |
String query = "fl=id,resourceMap&wt=xml&q=formatType:METADATA+-obsoletedBy:*+resourceMap:*+id:\"" + pid + "\""; |
|
676 |
try { |
|
677 |
InputStream results = MNodeService.getInstance(request).query("solr", query); |
|
678 |
Node rootNode = XMLUtilities.getXMLReaderAsDOMTreeRootNode(new InputStreamReader(results, "UTF-8")); |
|
679 |
//String resultString = XMLUtilities.getDOMTreeAsString(rootNode); |
|
680 |
NodeList nodeList = XMLUtilities.getNodeListWithXPath(rootNode, "//arr[@name=\"resourceMap\"]/str"); |
|
681 |
if (nodeList != null && nodeList.getLength() > 0) { |
|
682 |
//String found = nodeList.item(0).getFirstChild().getNodeValue(); |
|
683 |
return true; |
|
684 |
} |
|
685 |
} catch (Exception e) { |
|
686 |
logMetacat.error("Error checking for resourceMap[s] on pid " + pid + ". " + e.getMessage(), e); |
|
687 |
} |
|
688 |
|
|
668 | 689 |
return false; |
669 | 690 |
} |
670 | 691 |
|
Also available in: Unified diff
implement ORE check method to actually query the MN for OREs that reference the given pid.
https://projects.ecoinformatics.org/ecoinfo/issues/6061