Skip to main content

Searching

Searching for a Handle. The search_handle() is responsible to search for Handles with a specific key and value. Please note that searching requires access to a search servlet whose access information, if it differs from the handle server, has to be specified at client instantiation.

In the definition of the credentials file, we found the entries reverselookup_username and reverselookup_password. These are used to authenticate with a specific local Handle server to retrieve the PID when given some key-value pair in the Handle record. Assume you just know some of the metadata stored with a PID but not the full PID. How can you get to the URL field to retrieve the data?

We can fetch all data with a certain checksum. Make sure that your credential json file contains the keys reverselookup_username and reverselookup_password.

credentials = PIDClientCredentials.load_from_JSON('<full_path>/cred_file.json')
client = EUDATHandleClient.instantiate_with_credentials(credentials)
args = dict([('CHECKSUM', md5sum)])
result = ec.search_handle(**args)

result conatins a list of all PIDs where a fiels CHECKSUM is defined and has the value stored in md5sum. Now we can retrieve the location of the first hit in the list.

url = ec.get_value_from_handle(result[0], 'URL')
print(url)

Note, that this functionality is an EUDAT extension to the standard Handle server functionalities. You can also only query reversely on a local Handle server, not across the global Handle server.

The reverse look up function works also with wildcards: We know that B2SAFE uses PIDs and stores the iRODS path in te field URL

rev = dict([('URL', 'irods:*')])
result = ec.search_handle(**rev)

This will return a list of all PIDs stored in iRODS.