Project

General

Profile

« Previous | Next » 

Revision 10329

Added by Jing Tao over 7 years ago

Modified the query to find the previous version of the ore document in the publish method.

View differences:

src/edu/ucsb/nceas/metacat/dataone/MNodeService.java
2029 2029
				oreInputStream = this.get(session, potentialOreIdentifier);
2030 2030
			} catch (NotFound nf) {
2031 2031
				// this is probably okay for many sci meta data docs
2032
				logMetacat.warn("No potential ORE map found for: " + potentialOreIdentifier.getValue());
2032
				logMetacat.warn("No potential ORE map found for: " + potentialOreIdentifier.getValue()+" by the name convention.");
2033 2033
				// try the SOLR index
2034
				List<Identifier> potentialOreIdentifiers = this.lookupOreFor(originalIdentifier, false);
2034
				List<Identifier> potentialOreIdentifiers = this.lookupOreFor(originalIdentifier);
2035 2035
				if (potentialOreIdentifiers != null) {
2036 2036
					potentialOreIdentifier = potentialOreIdentifiers.get(0);
2037 2037
					try {
......
2040 2040
						// this is probably okay for many sci meta data docs
2041 2041
						logMetacat.warn("No potential ORE map found for: " + potentialOreIdentifier.getValue());
2042 2042
					}
2043
				} else {
2044
				    logMetacat.warn("MNodeService.publish - No potential ORE map found for the metadata object" + originalIdentifier.getValue()+" by both the name convention or the solr query.");
2043 2045
				}
2044 2046
			}
2045 2047
			if (oreInputStream != null) {
2048
			    logMetacat.info("MNodeService.publish - we find the old ore document "+potentialOreIdentifier+" for the metacat object "+originalIdentifier);
2046 2049
				Identifier newOreIdentifier = MNodeService.getInstance(request).generateIdentifier(session, MNodeService.UUID_SCHEME, null);
2047 2050
	
2048 2051
				Map<Identifier, Map<Identifier, List<Identifier>>> resourceMapStructure = ResourceMapFactory.getInstance().parseResourceMap(oreInputStream);
......
2096 2099
				}
2097 2100
				
2098 2101
				// save the updated ORE
2102
				logMetacat.info("MNodeService.publish - the new ore document is "+newOreIdentifier.getValue()+" for the doi "+newIdentifier.getValue());
2099 2103
				this.update(
2100 2104
						session, 
2101 2105
						potentialOreIdentifier, 
......
2266 2270
		return retList;
2267 2271
	}
2268 2272
	
2273
	
2274
	/**
2275
     * Determines if we already have registered an ORE map for this package
2276
     * NOTE: uses a solr query to locate OREs for the object
2277
     * @todo should be consolidate with the above method.
2278
     * @param guid of the EML/packaging object
2279
     */
2280
    private List<Identifier> lookupOreFor(Identifier guid) {
2281
        // Search for the ORE if we can find it
2282
        String pid = guid.getValue();
2283
        List<Identifier> retList = null;
2284
        try {
2285
            String query = "fl=id,resourceMap&wt=xml&q=id:\"" + pid + "\"";
2286
            InputStream results = this.query(null, "solr", query);
2287
            org.w3c.dom.Node rootNode = XMLUtilities.getXMLReaderAsDOMTreeRootNode(new InputStreamReader(results, "UTF-8"));
2288
            //String resultString = XMLUtilities.getDOMTreeAsString(rootNode);
2289
            org.w3c.dom.NodeList nodeList = XMLUtilities.getNodeListWithXPath(rootNode, "//arr[@name=\"resourceMap\"]/str");
2290
            if (nodeList != null && nodeList.getLength() > 0) {
2291
                retList = new ArrayList<Identifier>();
2292
                for (int i = 0; i < nodeList.getLength(); i++) {
2293
                    String found = nodeList.item(i).getFirstChild().getNodeValue();
2294
                    logMetacat.debug("MNodeService.lookupOreRor - found the resource map"+found);
2295
                    Identifier oreId = new Identifier();
2296
                    oreId.setValue(found);
2297
                    retList.add(oreId);
2298
                }
2299
            }
2300
        } catch (Exception e) {
2301
            logMetacat.error("Error checking for resourceMap[s] on pid " + pid + ". " + e.getMessage(), e);
2302
        }
2303
        
2304
        return retList;
2305
    }
2269 2306

  
2270 2307
	@Override
2271 2308
	public InputStream getPackage(Session session, ObjectFormatIdentifier formatId,

Also available in: Unified diff