def harvest_registry(registryId): try: #Harvest req = harvest_model(registryId) data = req.data return "Message: {!s}, Status code: {!s}".format(data[APIMessage.label], str(req.status_code)) except Exception as e: return e.message
def harvest(request): if request.method == 'POST': try: #Get the ID registry_id = request.POST['registry_id'] try: r = harvest_model(registry_id) return HttpResponse(json.dumps({}), content_type='application/javascript') except Exception as e: return HttpResponseBadRequest('An error occurred. Please contact your administrator.') except Exception as e: return HttpResponseBadRequest('An error occurred. Please contact your administrator.')
def harvest(request): """ POST http://localhost/oai_pmh/api/harvest POST data query='{"registry_id":"value"}' """ #List of errors allErrors = [] try: serializer = HarvestSerializer(data=request.DATA) if serializer.is_valid(): registry_id = request.DATA['registry_id'] return harvest_model(registry_id) else: raise OAIAPISerializeLabelledException(errors=serializer.errors, status=status.HTTP_400_BAD_REQUEST) except OAIAPIException as e: return e.response() except Exception as e: content = APIMessage.getMessageLabelled('An error occurred during the harvest process: %s'%e.message) return Response(content, status=status.HTTP_500_INTERNAL_SERVER_ERROR)