Created
July 23, 2015 12:07
-
-
Save ianibo/89cdbb20fe043d3e9383 to your computer and use it in GitHub Desktop.
DOI LIst Handles Experiment
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
import net.handle.api.HSAdapterFactory | |
import net.handle.hdllib.*; | |
println("groovy -cp ./handle-client.jar test1.groovy"); | |
net.handle.api.HSAdapter hsadapter = HSAdapterFactory.newInstance() | |
def someHandle = "10.1126/science"; | |
String[] types = [] | |
int[] indexes = [] | |
HandleValue[] h = hsadapter.resolveHandle(someHandle, types, indexes); | |
println("Hello ${hsadapter}"); | |
println("Hello ${h}"); | |
def naming_authority_handle = Util.encodeString("10.1126/"); | |
AuthenticationInfo authInfo = null; | |
HandleResolver resolver = new HandleResolver(); | |
try { | |
def nahandle = resolver.getNAHandle(naming_authority_handle); | |
println("nahandle = ${nahandle} ${new String(nahandle)}"); | |
println("findLocalSitesForNA"); | |
// def siteinfo_result = resolver.findLocalSites(lhr) | |
// def siteinfo_result = resolver.findLocalSitesForNA(naming_authority_handle) | |
def siteinfo_result = resolver.findLocalSitesForNA(nahandle) | |
// def lhr = new ListHandlesRequest(naming_authority_handle, authInfo) | |
def lhr = new ListHandlesRequest(nahandle, authInfo) | |
siteinfo_result.each { siteinfo -> | |
println("\n\nSiteinfo : ${siteinfo}"); | |
siteinfo?.servers.each { it -> | |
println("ServerInfo: ${it}\n"); | |
try { | |
def remote_lh_resp = resolver.sendRequestToServer(lhr, it) | |
println(" lh resp -> ${remote_lh_resp}"); | |
} | |
catch (Exception e) { | |
println("err"); | |
} | |
} | |
} | |
println("Get namespace info"); | |
nsinfo = resolver.getNamespaceInfo(nahandle) | |
println("NSInfo : ${nsinfo}"); | |
} | |
catch ( Exception e) { | |
println(e); | |
} | |
finally { | |
println("All done"); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment