[Volute] r3600 - trunk/projects/registry/dois

Volute commit messages volutecommits at g-vo.org
Wed Oct 26 18:06:09 CEST 2016


Author: msdemlei
Date: Wed Oct  5 15:24:36 2016
New Revision: 3600

Log:
doitransform: uploading metadata before landingpage again.

Modified:
   trunk/projects/registry/dois/oai2datacite.py

Modified: trunk/projects/registry/dois/oai2datacite.py
==============================================================================
--- trunk/projects/registry/dois/oai2datacite.py	Wed Oct  5 15:14:29 2016	(r3599)
+++ trunk/projects/registry/dois/oai2datacite.py	Wed Oct  5 15:24:36 2016	(r3600)
@@ -60,8 +60,8 @@
 
 	(1) doi = d.get_DOI(ivoid)
 	(2) make sure doi is doesn't collide
-	(3) dc_tree = d.tranlate(parsed_dc_record, doi)
-	(4) d.upload(dc_tree, dest_uri)
+	(3) datacite_tree = d.tranlate(parsed_dc_record, doi)
+	(4) d.upload(datacite_tree, dest_uri)
 
 	-- where dest_uri is an appropriate landing page.
 	"""
@@ -86,16 +86,25 @@
 		"""uploads the datacite core metadata in the etree datacite_tree and
 		sets the resolved URI to landingpage_uri.
 		"""
-		doi = dc_tree.xpath("//d:identifier[@identifierType='DOI']",
+		doi = datacite_tree.xpath("//d:identifier[@identifierType='DOI']",
 			namespaces={'d': DC_NS})[0].text
+
+		# First, upload the metadata
 		response = requests.post(self.datacite_endpoint+"/metadata", 
-			auth=self.auth, data=str(datacite_tree))
+			auth=self.auth, 
+			data=unicode(datacite_tree).encode("utf-8"),
+			headers={'content-type': 'application/xml'})
 		response.raise_for_status()
 
-		response = requests.post(self.datacite_endpoint+"/doi",
-			auth=auth, data="doi=%s\nurl=%s\n"%(doi, landingpage_uri))
+		# then, link the the DOI with our landing page
+		response = requests.post(
+			self.datacite_endpoint+"/doi",
+			auth=self.auth, 
+			data=("doi=%s\r\nurl=%s"%(doi, landingpage_uri)).encode("utf-8"),
+			headers={'content-type': 'text/plain;charset=UTF-8'})
 		response.raise_for_status()
 
+
 	def translate(self, rec, doi):
 		"""returns an IVOID and the etree of datacite metadata for a 
 		VOResource record rec.


More information about the Volutecommits mailing list