Example #1
0
 def get_identifier(self, identifier):
     resp = self._make_request(
         'GET',
         self._build_url('id', identifier),
         expects=(200, ),
     )
     return utils.from_anvl(resp.content.strip('\n'))
Example #2
0
 def get_identifier(self, identifier):
     resp = self._make_request(
         'GET',
         self._build_url('id', identifier),
         expects=(200, ),
     )
     return utils.from_anvl(resp.content.strip('\n'))
Example #3
0
 def update_identifier(self, object, category):
     metadata = self.build_metadata(object)
     status = self.get_status(object)
     metadata['_status'] = status
     identifier = self.build_doi(object)
     resp = self._make_request(
         'POST',
         self._build_url('id', identifier),
         data=utils.to_anvl(metadata or {}),
         expects=(200, ),
     )
     return utils.from_anvl(resp.content)
Example #4
0
 def update_identifier(self, object, category):
     metadata = self.build_metadata(object)
     status = self.get_status(object)
     metadata['_status'] = status
     identifier = self.build_doi(object)
     resp = self._make_request(
         'POST',
         self._build_url('id', identifier),
         data=utils.to_anvl(metadata or {}),
         expects=(200, ),
     )
     return utils.from_anvl(resp.content)
Example #5
0
 def update_identifier(self, object, category):
     if not waffle.switch_is_active(EZID_SWITCH):
         logger.info('ezid waffle switch is off. Doing nothing...')
         return None
     metadata = self.build_metadata(object)
     status = self.get_status(object)
     metadata['_status'] = status
     identifier = self.build_doi(object)
     resp = self._make_request(
         'POST',
         self._build_url('id', identifier),
         data=utils.to_anvl(metadata or {}),
         expects=(200, ),
     )
     return utils.from_anvl(resp.content)
Example #6
0
 def update_identifier(self, object, category):
     if not waffle.switch_is_active(features.EZID_SWITCH):
         logger.info('ezid waffle switch is off. Doing nothing...')
         return None
     metadata = self.build_metadata(object)
     status = self.get_status(object)
     metadata['_status'] = status
     identifier = self.build_doi(object)
     resp = self._make_request(
         'POST',
         self._build_url('id', identifier),
         data=utils.to_anvl(metadata or {}),
         expects=(200, ),
     )
     return utils.from_anvl(resp.content)
Example #7
0
 def create_identifier(self, object, category):
     if category in ['doi', 'ark']:
         metadata = self.build_metadata(object)
         doi = self.build_doi(object)
         resp = requests.request(
             'PUT',
             self._build_url('id', doi),
             data=utils.to_anvl(metadata or {}),
         )
         if resp.status_code != 201:
             if 'identifier already exists' in resp.content:
                 raise exceptions.IdentifierAlreadyExists()
             else:
                 raise exceptions.ClientResponseError(resp)
         resp = utils.from_anvl(resp.content)
         return dict([each.strip('/') for each in pair.strip().split(':')]
                     for pair in resp['success'].split('|'))
     else:
         raise NotImplementedError(
             'Create identifier method is not supported for category {}'.
             format(category))
Example #8
0
 def create_identifier(self, object, category):
     if category in ['doi', 'ark']:
         metadata = self.build_metadata(object)
         doi = self.build_doi(object)
         resp = requests.request(
             'PUT',
             self._build_url('id', doi),
             data=utils.to_anvl(metadata or {}),
         )
         if resp.status_code != 201:
             if 'identifier already exists' in resp.content:
                 raise exceptions.IdentifierAlreadyExists()
             else:
                 raise exceptions.ClientResponseError(resp)
         resp = utils.from_anvl(resp.content)
         return dict(
             [each.strip('/') for each in pair.strip().split(':')]
             for pair in resp['success'].split('|')
         )
     else:
         raise NotImplementedError('Create identifier method is not supported for category {}'.format(category))