def describe(self, pid): try: return self.client.describe(pid) except d1_common.types.exceptions.DataONEException as e: raise workspace_exception.WorkspaceException(e.description) except (ssl.SSLError, socket.error) as e: raise workspace_exception.WorkspaceException(str(e))
def get_system_metadata(self, pid): """This method causes an implicit validation of the retrieved System Metadata""" try: return self.client.getSystemMetadata(pid) except d1_common.types.exceptions.DataONEException as e: raise workspace_exception.WorkspaceException(e.description) except (ssl.SSLError, socket.error) as e: raise workspace_exception.WorkspaceException(str(e))
def get_system_metadata_as_string(self, pid): """This method does not include validation of the System Metadata""" try: result = self.client.getSystemMetadataResponse(pid) return result.read() except d1_common.types.exceptions.DataONEException as e: raise workspace_exception.WorkspaceException(e.description) except (ssl.SSLError, socket.error) as e: raise workspace_exception.WorkspaceException(str(e))
def get_science_object(self, pid): try: d1client = d1_client.d1client.DataONEClient( cnBaseUrl=self._options['base_url']) return d1client.get(pid) except d1_common.types.exceptions.DataONEException as e: raise workspace_exception.WorkspaceException(e.description) except (ssl.SSLError, socket.error) as e: raise workspace_exception.WorkspaceException(str(e))
def get_solr_record(self, pid): query = u'id:{0}'.format(self._solr_client.escape_query_term_string(pid)) response = self.run_solr_query(query) try: return response[0] except IndexError: raise workspace_exception.WorkspaceException( 'Object does not exist. pid={0}'.format(pid) )
def _get_wcache_folder_recursive(self, path, folder=None): logging.debug('path={0}'.format(path)) if folder is None: folder = self._wcache['tree'] if not path: return folder try: return self._get_wcache_folder_recursive( path[1:], folder['dirs'][path[0]] ) except KeyError: raise workspace_exception.WorkspaceException('Invalid path')
def _get_uncached_object_record(self, pid): self._create_wcache_item_for_pid(None, pid) try: return self._wcache['records'][pid] except KeyError: raise workspace_exception.WorkspaceException('Unknown PID')