def publish_dataverse(self, sub_id): # get url for dataverse self.host = Submission().get_dataverse_details(sub_id) self.headers = {'X-Dataverse-key': self.host['apikey']} submission = Submission().get_record(sub_id) dvAlias = submission['accessions']['dataverse_alias'] dsId = submission['accessions']['dataset_id'] conn = self._get_connection() dv = conn.get_dataverse(dvAlias) # ds = dv.get_dataset_by_doi(dsDoi) if not dv.is_published: dv.publish() # POST http://$SERVER/api/datasets/$id/actions/:publish?type=$type&key=$apiKey url = submission['destination_repo']['url'] url = url + '/api/datasets/' + str( dsId) + '/actions/:publish?type=major' print(url) resp = requests.post(url, data={ 'type': 'major', 'key': self.host['apikey'] }, headers=self.headers) if resp.status_code != 200 or resp.status_code != 201: raise OperationFailedError('The Dataset could not be published. ' + resp.content) doc = Submission().mark_as_published(sub_id) return doc
def publish(self): edit_uri = '{0}/edit/dataverse/{1}'.format( self.connection.sword_base_url, self.alias) resp = requests.post( edit_uri, headers={'In-Progress': 'false'}, auth=self.connection.auth, ) if resp.status_code != 200: raise OperationFailedError('The Dataverse could not be published.')
def _add_dataset(self, dataset): resp = requests.post( self.collection.get('href'), data=dataset.get_entry(), headers={'Content-type': 'application/atom+xml'}, auth=self.connection.auth,verify=self.connection.verify ) if resp.status_code != 201: raise OperationFailedError('This dataset could not be added.') dataset.dataverse = self dataset._refresh(receipt=resp.content) self.get_collection_info(refresh=True)
def publish_dataset(self, dataset_id): url = self.host['url'] + '/api/datasets/' + str( dataset_id) + '/actions/:publish?type=major' resp = requests.post(url, data={ 'type': 'major', 'key': self.host['apikey'] }, headers=self.headers) if resp.status_code not in (200, 201): raise OperationFailedError('Dataset could not be published. ' + resp.content) return False return True
def _add_dataset(self, dataset): resp = requests.post( self.collection.get('href'), data=dataset.get_entry(), headers={'Content-type': 'application/atom+xml'}, auth=self.connection.auth, ) if resp.status_code != 201: raise OperationFailedError('This dataset could not be added.') response = resp.content if self.connection.host != 'localhost' and self.connection.host.endswith( ':8080'): response = resp.content.replace("8080:8080", "8080") response = response.replace("https", "http") dataset.dataverse = self dataset._refresh(receipt=response) self.get_collection_info(refresh=True)