talk@lists.collectionspace.org

WE HAVE SUNSET THIS LISTSERV - Join us at collectionspace@lyrasislists.org

View all threads

Import services for Relations

DR
Dave Ross
Sat, Jul 9, 2016 3:42 AM

Hi All,

We’ve been able to import CollectionObjects and Locations (Movements) into the system but we are having trouble relating the records.  If I pass this payload to space-services/imports:

<?xml version="1.0" encoding="utf-8" ?>
 <imports>
   <import seq="1" service="Relations" type="Relation">
     <schema xmlns:collectionobjects_common="http://collectionspace.org/services/relation" name="relations_common">
     	<subjectCsid>32f37f3-1adb-4b2d-8419-6c51db253d7a</subjectCsid>
	<subjectDocumentType>collectionobject</subjectDocumentType>
		
	<relationshipType>association</relationshipType>
		
	<objectCsid>9715172f-82fa-41ec-9a22-8daaa53355ef</objectCsid>
	<objectDocumentType>movement</objectDocumentType>
  </schema>
</import> </imports>

I receive this response:

<?xml version="1.0"?><import><msg>SUCCESS</msg><importedRecords><importedRecord><doctype>Relation</doctype><csid>00d8e983-9bee-4309-b2fa-e61d84c8d16b</csid></importedRecord></importedRecords><status>Success</status><totalRecordsImported>1</totalRecordsImported><numRecordsImportedByDocType><numRecordsImported><docType>Relation</docType><numRecords>1</numRecords></numRecordsImported></numRecordsImportedByDocType><report>READ: /usr/local/share/apache-tomcat-7.0.57/temp/imports-8817893085556614325/Relations/00d8e983-9bee-4309-b2fa-e61d84c8d16b/document.xml

/Relations/00d8e983-9bee-4309-b2fa-e61d84c8d16b
</report></import>

The response suggests that all worked well however nothing appears to change in the app.  In the catalina.out log I see this error:
Making directory: /usr/local/share/apache-tomcat-7.0.57/temp/imports-8817893085556614325/Relations/00d8e983-9bee-4309-b2fa-e61d84c8d16b
2016-06-13 21:31:41,016 WARN  [http-bio-8180-exec-10] [org.nuxeo.ecm.core.io.impl.AbstractDocumentReader:57] no ID for document, won't add org.nuxeo.ecm.core.io.impl.ExportedDocumentImpl@6a13aa0
2016-06-13 21:31:41,018 WARN  [http-bio-8180-exec-10] [org.nuxeo.ecm.core.io.impl.AbstractDocumentReader:57] no ID for document, won't add org.nuxeo.ecm.core.io.impl.ExportedDocumentImpl@430fe1c6
2016-06-13 21:31:41,026 WARN  [http-bio-8180-exec-10] [org.collectionspace.services.listener.AbstractUpdateObjectLocationValues:115] Could not obtain CSID for Movement record from document event.
2016-06-13 21:31:41,027 WARN  [http-bio-8180-exec-10] [org.collectionspace.services.listener.AbstractUpdateObjectLocationValues:116] This event listener will not continue processing this event ...

I’ve confirmed that both the CollectionObject and Movement object exist for the IDs.  What would be causing this error?  I’m not seeing any additional logging info from Nuxeo that would shed light on this error- is there another place I can find more debugging info?

Any example Relation payloads would also be greatly appreciated.

Thank you,
-Dave
Balboa Park Online Collaborative/San Diego Chinese History Museum.

Hi All, We’ve been able to import CollectionObjects and Locations (Movements) into the system but we are having trouble relating the records. If I pass this payload to space-services/imports: <?xml version="1.0" encoding="utf-8" ?> <imports> <import seq="1" service="Relations" type="Relation"> <schema xmlns:collectionobjects_common="http://collectionspace.org/services/relation" name="relations_common"> <subjectCsid>32f37f3-1adb-4b2d-8419-6c51db253d7a</subjectCsid> <subjectDocumentType>collectionobject</subjectDocumentType> <relationshipType>association</relationshipType> <objectCsid>9715172f-82fa-41ec-9a22-8daaa53355ef</objectCsid> <objectDocumentType>movement</objectDocumentType> </schema> </import> </imports> I receive this response: <?xml version="1.0"?><import><msg>SUCCESS</msg><importedRecords><importedRecord><doctype>Relation</doctype><csid>00d8e983-9bee-4309-b2fa-e61d84c8d16b</csid></importedRecord></importedRecords><status>Success</status><totalRecordsImported>1</totalRecordsImported><numRecordsImportedByDocType><numRecordsImported><docType>Relation</docType><numRecords>1</numRecords></numRecordsImported></numRecordsImportedByDocType><report>READ: /usr/local/share/apache-tomcat-7.0.57/temp/imports-8817893085556614325/Relations/00d8e983-9bee-4309-b2fa-e61d84c8d16b/document.xml /Relations/00d8e983-9bee-4309-b2fa-e61d84c8d16b </report></import> The response suggests that all worked well however nothing appears to change in the app. In the catalina.out log I see this error: Making directory: /usr/local/share/apache-tomcat-7.0.57/temp/imports-8817893085556614325/Relations/00d8e983-9bee-4309-b2fa-e61d84c8d16b 2016-06-13 21:31:41,016 WARN [http-bio-8180-exec-10] [org.nuxeo.ecm.core.io.impl.AbstractDocumentReader:57] no ID for document, won't add org.nuxeo.ecm.core.io.impl.ExportedDocumentImpl@6a13aa0 2016-06-13 21:31:41,018 WARN [http-bio-8180-exec-10] [org.nuxeo.ecm.core.io.impl.AbstractDocumentReader:57] no ID for document, won't add org.nuxeo.ecm.core.io.impl.ExportedDocumentImpl@430fe1c6 2016-06-13 21:31:41,026 WARN [http-bio-8180-exec-10] [org.collectionspace.services.listener.AbstractUpdateObjectLocationValues:115] Could not obtain CSID for Movement record from document event. 2016-06-13 21:31:41,027 WARN [http-bio-8180-exec-10] [org.collectionspace.services.listener.AbstractUpdateObjectLocationValues:116] This event listener will not continue processing this event ... I’ve confirmed that both the CollectionObject and Movement object exist for the IDs. What would be causing this error? I’m not seeing any additional logging info from Nuxeo that would shed light on this error- is there another place I can find more debugging info? Any example Relation payloads would also be greatly appreciated. Thank you, -Dave Balboa Park Online Collaborative/San Diego Chinese History Museum.
PM
Peter Murray
Mon, Jul 11, 2016 11:18 PM

Hi Dave,

I use Jinja2 templates as a fill-in-the-blank way to create XML for uploading to CSpace.  Attached is the Relations template I used.  The relevant lines in Python look like this:

j2Env = Environment(loader=FileSystemLoader("{}/../templates".format(getScriptPath())), trim_blocks=True)
j2LocTemplate = j2Env.get_template('relation-template.xml')
relXml = j2LocTemplate.render(relRow)
r = requests.post(relationsRestUrl, data=relXml.encode('utf-8'), auth=HTTPBasicAuth(apiUser, apiPass), headers=apiHeaders, verify=False)
if r.status_code == 201:
    locUri = r.headers.get('Location')
    logger.info <http://logger.info/>('Relations record {} loaded: {}'.format(i + 1, locUri))
else:
    logger.error('Relations record {} did not load: {}'.format(i + 1, r.text))
    continue

...where 'relRow' is a dictionary with the keys pointing to values that will be filled in using the Jinja2 library.  The structure of XML that I'm using is slightly different from yours; I'm explicitly stating the XML namespaces, and that might be enough to cause the problem.

Peter

On Jul 8, 2016, at 11:42 PM, Dave Ross <dross@rossmail.us mailto:dross@rossmail.us> wrote:

Hi All,

We’ve been able to import CollectionObjects and Locations (Movements) into the system but we are having trouble relating the records.  If I pass this payload to space-services/imports:

<?xml version="1.0" encoding="utf-8" ?>
  <imports>
    <import seq="1" service="Relations" type="Relation">
      <schema xmlns:collectionobjects_common="http://collectionspace.org/services/relation <http://collectionspace.org/services/relation>" name="relations_common">
      	<subjectCsid>32f37f3-1adb-4b2d-8419-6c51db253d7a</subjectCsid>
	<subjectDocumentType>collectionobject</subjectDocumentType>
		
	<relationshipType>association</relationshipType>
		
	<objectCsid>9715172f-82fa-41ec-9a22-8daaa53355ef</objectCsid>
	<objectDocumentType>movement</objectDocumentType>
   </schema>
</import> </imports>

I receive this response:

<?xml version="1.0"?><import><msg>SUCCESS</msg><importedRecords><importedRecord><doctype>Relation</doctype><csid>00d8e983-9bee-4309-b2fa-e61d84c8d16b</csid></importedRecord></importedRecords><status>Success</status><totalRecordsImported>1</totalRecordsImported><numRecordsImportedByDocType><numRecordsImported><docType>Relation</docType><numRecords>1</numRecords></numRecordsImported></numRecordsImportedByDocType><report>READ: /usr/local/share/apache-tomcat-7.0.57/temp/imports-8817893085556614325/Relations/00d8e983-9bee-4309-b2fa-e61d84c8d16b/document.xml

/Relations/00d8e983-9bee-4309-b2fa-e61d84c8d16b
</report></import>

The response suggests that all worked well however nothing appears to change in the app.  In the catalina.out log I see this error:
Making directory: /usr/local/share/apache-tomcat-7.0.57/temp/imports-8817893085556614325/Relations/00d8e983-9bee-4309-b2fa-e61d84c8d16b
2016-06-13 21:31:41,016 WARN  [http-bio-8180-exec-10] [org.nuxeo.ecm.core.io.impl.AbstractDocumentReader:57] no ID for document, won't add org.nuxeo.ecm.core.io.impl.ExportedDocumentImpl@6a13aa0
2016-06-13 21:31:41,018 WARN  [http-bio-8180-exec-10] [org.nuxeo.ecm.core.io.impl.AbstractDocumentReader:57] no ID for document, won't add org.nuxeo.ecm.core.io.impl.ExportedDocumentImpl@430fe1c6
2016-06-13 21:31:41,026 WARN  [http-bio-8180-exec-10] [org.collectionspace.services.listener.AbstractUpdateObjectLocationValues:115] Could not obtain CSID for Movement record from document event.
2016-06-13 21:31:41,027 WARN  [http-bio-8180-exec-10] [org.collectionspace.services.listener.AbstractUpdateObjectLocationValues:116] This event listener will not continue processing this event ...

I’ve confirmed that both the CollectionObject and Movement object exist for the IDs.  What would be causing this error?  I’m not seeing any additional logging info from Nuxeo that would shed light on this error- is there another place I can find more debugging info?

Any example Relation payloads would also be greatly appreciated.

Thank you,
-Dave
Balboa Park Online Collaborative/San Diego Chinese History Museum.


Talk mailing list
Talk@lists.collectionspace.org mailto:Talk@lists.collectionspace.org
http://lists.collectionspace.org/mailman/listinfo/talk_lists.collectionspace.org http://lists.collectionspace.org/mailman/listinfo/talk_lists.collectionspace.org

--
Peter Murray
Dev/Ops Lead and Project Manager
Cherry Hill Company

Hi Dave, I use Jinja2 templates as a fill-in-the-blank way to create XML for uploading to CSpace. Attached is the Relations template I used. The relevant lines in Python look like this: j2Env = Environment(loader=FileSystemLoader("{}/../templates".format(getScriptPath())), trim_blocks=True) j2LocTemplate = j2Env.get_template('relation-template.xml') relXml = j2LocTemplate.render(relRow) r = requests.post(relationsRestUrl, data=relXml.encode('utf-8'), auth=HTTPBasicAuth(apiUser, apiPass), headers=apiHeaders, verify=False) if r.status_code == 201: locUri = r.headers.get('Location') logger.info <http://logger.info/>('Relations record {} loaded: {}'.format(i + 1, locUri)) else: logger.error('Relations record {} did not load: {}'.format(i + 1, r.text)) continue ...where 'relRow' is a dictionary with the keys pointing to values that will be filled in using the Jinja2 library. The structure of XML that I'm using is slightly different from yours; I'm explicitly stating the XML namespaces, and that might be enough to cause the problem. Peter > On Jul 8, 2016, at 11:42 PM, Dave Ross <dross@rossmail.us <mailto:dross@rossmail.us>> wrote: > > Hi All, > > We’ve been able to import CollectionObjects and Locations (Movements) into the system but we are having trouble relating the records. If I pass this payload to space-services/imports: > > <?xml version="1.0" encoding="utf-8" ?> > <imports> > <import seq="1" service="Relations" type="Relation"> > <schema xmlns:collectionobjects_common="http://collectionspace.org/services/relation <http://collectionspace.org/services/relation>" name="relations_common"> > <subjectCsid>32f37f3-1adb-4b2d-8419-6c51db253d7a</subjectCsid> > <subjectDocumentType>collectionobject</subjectDocumentType> > > <relationshipType>association</relationshipType> > > <objectCsid>9715172f-82fa-41ec-9a22-8daaa53355ef</objectCsid> > <objectDocumentType>movement</objectDocumentType> > </schema> > </import> > </imports> > > > I receive this response: > <?xml version="1.0"?><import><msg>SUCCESS</msg><importedRecords><importedRecord><doctype>Relation</doctype><csid>00d8e983-9bee-4309-b2fa-e61d84c8d16b</csid></importedRecord></importedRecords><status>Success</status><totalRecordsImported>1</totalRecordsImported><numRecordsImportedByDocType><numRecordsImported><docType>Relation</docType><numRecords>1</numRecords></numRecordsImported></numRecordsImportedByDocType><report>READ: /usr/local/share/apache-tomcat-7.0.57/temp/imports-8817893085556614325/Relations/00d8e983-9bee-4309-b2fa-e61d84c8d16b/document.xml > /Relations/00d8e983-9bee-4309-b2fa-e61d84c8d16b > </report></import> > > The response suggests that all worked well however nothing appears to change in the app. In the catalina.out log I see this error: > Making directory: /usr/local/share/apache-tomcat-7.0.57/temp/imports-8817893085556614325/Relations/00d8e983-9bee-4309-b2fa-e61d84c8d16b > 2016-06-13 21:31:41,016 WARN [http-bio-8180-exec-10] [org.nuxeo.ecm.core.io.impl.AbstractDocumentReader:57] no ID for document, won't add org.nuxeo.ecm.core.io.impl.ExportedDocumentImpl@6a13aa0 > 2016-06-13 21:31:41,018 WARN [http-bio-8180-exec-10] [org.nuxeo.ecm.core.io.impl.AbstractDocumentReader:57] no ID for document, won't add org.nuxeo.ecm.core.io.impl.ExportedDocumentImpl@430fe1c6 > 2016-06-13 21:31:41,026 WARN [http-bio-8180-exec-10] [org.collectionspace.services.listener.AbstractUpdateObjectLocationValues:115] Could not obtain CSID for Movement record from document event. > 2016-06-13 21:31:41,027 WARN [http-bio-8180-exec-10] [org.collectionspace.services.listener.AbstractUpdateObjectLocationValues:116] This event listener will not continue processing this event ... > > I’ve confirmed that both the CollectionObject and Movement object exist for the IDs. What would be causing this error? I’m not seeing any additional logging info from Nuxeo that would shed light on this error- is there another place I can find more debugging info? > > Any example Relation payloads would also be greatly appreciated. > > Thank you, > -Dave > Balboa Park Online Collaborative/San Diego Chinese History Museum. > > > > _______________________________________________ > Talk mailing list > Talk@lists.collectionspace.org <mailto:Talk@lists.collectionspace.org> > http://lists.collectionspace.org/mailman/listinfo/talk_lists.collectionspace.org <http://lists.collectionspace.org/mailman/listinfo/talk_lists.collectionspace.org> -- Peter Murray Dev/Ops Lead and Project Manager Cherry Hill Company