@Test public void testDonatorGet() throws ParserConfigurationException, SAXException, IOException, XPathExpressionException { URL resource = RelsExtHelperTest.class.getResource("donator.xml"); Assert.assertNotNull(resource); Document document = XMLUtils.parseDocument(resource.openStream(),true); String donator = RelsExtHelper.getDonator(document); Assert.assertNotNull(donator); Assert.assertEquals(donator,"donator:norway"); }
public static String getDonator(Document reslExtDoc) throws IOException, XPathExpressionException { XPathFactory xpfactory = XPathFactory.newInstance(); XPath xpath = xpfactory.newXPath(); xpath.setNamespaceContext(new FedoraNamespaceContext()); XPathExpression expr = xpath.compile(" Object donator = expr.evaluate(reslExtDoc, XPathConstants.NODE); if (donator != null) { Element elm = (Element) donator; Attr ref = elm.getAttributeNodeNS(FedoraNamespaces.RDF_NAMESPACE_URI, "resource"); if (ref != null) { try { PIDParser pidParser = new PIDParser(ref.getValue()); pidParser.disseminationURI(); return pidParser.getObjectPid(); } catch (LexerException e) { LOGGER.log(Level.SEVERE,e.getMessage(),e); return null; } } else return null; } else return null; }
RelsExtHelper { public static String getDonator(Document reslExtDoc) throws IOException, XPathExpressionException { XPathFactory xpfactory = XPathFactory.newInstance(); XPath xpath = xpfactory.newXPath(); xpath.setNamespaceContext(new FedoraNamespaceContext()); XPathExpression expr = xpath.compile(" Object donator = expr.evaluate(reslExtDoc, XPathConstants.NODE); if (donator != null) { Element elm = (Element) donator; Attr ref = elm.getAttributeNodeNS(FedoraNamespaces.RDF_NAMESPACE_URI, "resource"); if (ref != null) { try { PIDParser pidParser = new PIDParser(ref.getValue()); pidParser.disseminationURI(); return pidParser.getObjectPid(); } catch (LexerException e) { LOGGER.log(Level.SEVERE,e.getMessage(),e); return null; } } else return null; } else return null; } }
RelsExtHelper { public static String getDonator(Document reslExtDoc) throws IOException, XPathExpressionException { XPathFactory xpfactory = XPathFactory.newInstance(); XPath xpath = xpfactory.newXPath(); xpath.setNamespaceContext(new FedoraNamespaceContext()); XPathExpression expr = xpath.compile(" Object donator = expr.evaluate(reslExtDoc, XPathConstants.NODE); if (donator != null) { Element elm = (Element) donator; Attr ref = elm.getAttributeNodeNS(FedoraNamespaces.RDF_NAMESPACE_URI, "resource"); if (ref != null) { try { PIDParser pidParser = new PIDParser(ref.getValue()); pidParser.disseminationURI(); return pidParser.getObjectPid(); } catch (LexerException e) { LOGGER.log(Level.SEVERE,e.getMessage(),e); return null; } } else return null; } else return null; }  }
RelsExtHelper { public static String getDonator(Document reslExtDoc) throws IOException, XPathExpressionException { XPathFactory xpfactory = XPathFactory.newInstance(); XPath xpath = xpfactory.newXPath(); xpath.setNamespaceContext(new FedoraNamespaceContext()); XPathExpression expr = xpath.compile(" Object donator = expr.evaluate(reslExtDoc, XPathConstants.NODE); if (donator != null) { Element elm = (Element) donator; Attr ref = elm.getAttributeNodeNS(FedoraNamespaces.RDF_NAMESPACE_URI, "resource"); if (ref != null) { try { PIDParser pidParser = new PIDParser(ref.getValue()); pidParser.disseminationURI(); return pidParser.getObjectPid(); } catch (LexerException e) { LOGGER.log(Level.SEVERE,e.getMessage(),e); return null; } } else return null; } else return null; }  static String getReplicatedFromUrl(String uuid, FedoraAccess fedoraAccess); static String getRelsExtTilesUrl(String uuid, FedoraAccess fedoraAccess); static String getRelsExtTilesUrl(Document reslExtDoc); static String getDonator(Document reslExtDoc); }
RelsExtHelper { public static String getDonator(Document reslExtDoc) throws IOException, XPathExpressionException { XPathFactory xpfactory = XPathFactory.newInstance(); XPath xpath = xpfactory.newXPath(); xpath.setNamespaceContext(new FedoraNamespaceContext()); XPathExpression expr = xpath.compile(" Object donator = expr.evaluate(reslExtDoc, XPathConstants.NODE); if (donator != null) { Element elm = (Element) donator; Attr ref = elm.getAttributeNodeNS(FedoraNamespaces.RDF_NAMESPACE_URI, "resource"); if (ref != null) { try { PIDParser pidParser = new PIDParser(ref.getValue()); pidParser.disseminationURI(); return pidParser.getObjectPid(); } catch (LexerException e) { LOGGER.log(Level.SEVERE,e.getMessage(),e); return null; } } else return null; } else return null; }  static String getReplicatedFromUrl(String uuid, FedoraAccess fedoraAccess); static String getRelsExtTilesUrl(String uuid, FedoraAccess fedoraAccess); static String getRelsExtTilesUrl(Document reslExtDoc); static String getDonator(Document reslExtDoc); static final Logger LOGGER; static final String CACHE_RELS_EXT_LITERAL; }