Skip to content
Snippets Groups Projects
Commit b9ce5cb1 authored by gakin's avatar gakin
Browse files

SSDM-4501 : Parse the timestamp sent by the data source in <rs:md? "at" value in the XML

SVN: 37457
parent 5d4e7da5
No related branches found
No related tags found
No related merge requests found
......@@ -138,6 +138,7 @@ public class ResourceListParser
throw new UnsupportedOperationException("Not implemented!!!");
}
});
Date resourceListTimestamp = getResourceListTimestamp(doc, xpath);
List<String> uris = getResourceLocations(doc, xpath);
for (String uri : uris)
{
......@@ -147,6 +148,23 @@ public class ResourceListParser
return data;
}
private Date getResourceListTimestamp(Document doc, XPath xpath) throws XPathExpressionException
{
XPathExpression expr = xpath.compile("/s:urlset/rs:md");
Object result = expr.evaluate(doc, XPathConstants.NODESET);
NodeList nodes = (NodeList) result;
for (int i = 0; i < nodes.getLength(); i++)
{
String capability = nodes.item(i).getAttributes().getNamedItem("capability").getTextContent();
if (capability.equals("resourcelist"))
{
String timestamp = nodes.item(i).getAttributes().getNamedItem("at").getTextContent();
return convertFromW3CDate(timestamp);
}
}
throw new XPathExpressionException("The master data resurce list should send a timestamp.");
}
private List<String> getResourceLocations(Document doc, XPath xpath) throws XPathExpressionException
{
XPathExpression expr = xpath.compile("/s:urlset/s:url/s:loc");// "//*[local-name()='loc']/text()"); //"//s:loc/text()"
......@@ -243,6 +261,11 @@ public class ResourceListParser
String lastModDataStr = lastModNode.getTextContent().trim();
// TODO data source servlet that generates the XML on the data source side MUST use the same format
return convertFromW3CDate(lastModDataStr);
}
private Date convertFromW3CDate(String lastModDataStr) throws XPathExpressionException
{
DateFormat df1 = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss", Locale.US);
df1.setTimeZone(TimeZone.getTimeZone("GMT"));
// DateFormat df1 = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssZ");
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment