def check_registry(request): try: #Get the oai registry URL form = Url(request.POST) if form.is_valid(): req = objectIdentifyByURL(request.POST.get("url")) #If the return status is HTTP_200_OK, the OAI Registry is available isAvailable = req.status_code == status.HTTP_200_OK else: isAvailable = False except: isAvailable = False return HttpResponse(json.dumps({'isAvailable' : isAvailable }), content_type='application/javascript')
def objectIdentify(request): """ POST http://localhost/oai_pmh/api/objectidentify POST data query='{"url":"value"}' """ try: serializer = IdentifySerializer(data=request.DATA) if serializer.is_valid(): url = request.DATA['url'] req = objectIdentifyByURL(url) return Response(req.data, status=req.status_code) else: raise OAIAPISerializeLabelledException(errors=serializer.errors, status=status.HTTP_400_BAD_REQUEST) except OAIAPIException as e: return e.response() except Exception: content = APIMessage.getMessageLabelled('An error occurred when attempting to identify resource') return Response(content, status=status.HTTP_500_INTERNAL_SERVER_ERROR)