Created
February 15, 2010 18:57
-
-
Save cbeer/304883 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
RewriteEngine On | |
RewriteMap fedora-map prg:/wgbh/http/openvault/map.fedora.py | |
RewriteCond %{REQUEST_URI} Proxy #map just URIs with Proxy in them.. | |
RewriteRule ^/fedora/get/([a-zA-Z0-9/:\-\.]+)$ ${fedora-map:$1} [QSA] # send along the query string.. hopefully the regex is about right.. ought to check it someday. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# -*- coding: utf-8 -*- | |
# map fedora commons datastream requests to files for an apache_rewrite handler | |
import sys,os | |
from elementtree import ElementTree | |
import urllib2 | |
from urllib import urlencode | |
datastream_store_base = '/Users/chris/fedora-3.3/data/datastreams' | |
fedora_http = 'http://localhost:8080/fedora/' | |
username='fedoraAdmin' | |
password='fedora' | |
passman = urllib2.HTTPPasswordMgrWithDefaultRealm() | |
passman.add_password(None, fedora_http, username, password) | |
authhandler = urllib2.HTTPBasicAuthHandler(passman) | |
opener = urllib2.build_opener(authhandler) | |
urllib2.install_opener(opener) | |
while sys.stdin: | |
id = sys.stdin.readline().rstrip() | |
pid, dsid = id.split('/') | |
content = urllib2.urlopen(fedora_http + 'objects/' + pid + '/datastreams/' + dsid + '/?format=xml').read() | |
e = ElementTree.fromstring(content) | |
l = e.find('.//dsLocation').text | |
t = e.find('.//dsLocationType').text | |
if(t == 'INTERNAL_ID'): | |
print(os.popen('find ' + datastream_store_base + " -name " + l + " -print").readline().rstrip()) | |
else: | |
print(l) | |
sys.stdout.flush() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment