Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
O
openbis
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
sispub
openbis
Commits
b9ce5cb1
Commit
b9ce5cb1
authored
8 years ago
by
gakin
Browse files
Options
Downloads
Patches
Plain Diff
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
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
datastore_server/source/java/ch/ethz/sis/openbis/generic/server/dss/plugins/harvester/synchronizer/ResourceListParser.java
+23
-0
23 additions, 0 deletions
...ss/plugins/harvester/synchronizer/ResourceListParser.java
with
23 additions
and
0 deletions
datastore_server/source/java/ch/ethz/sis/openbis/generic/server/dss/plugins/harvester/synchronizer/ResourceListParser.java
+
23
−
0
View file @
b9ce5cb1
...
...
@@ -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");
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment