[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: [Handle-info] how to resolve a handle prefix owner?



Hi Bernd,

it depends "what information you need" or better, what you are intending to do. As Mark already mentioned, to get the eMail adresse is a possibility. In our case (we are part of DataCite), we needed to check, if any handle is owned by crossref or by datacite. The eMail information is therefore not really useful to get this information. But Instead we use the HS_SERV record, which returns the handle of the responsible handle server for the prefix. This is very nice to find out, which handle server is responsible and based on that to make a decision.

Here is our Java code to do this information. Please note: Util.getZeroNAHandle(Util.encodeString(hdl)) <-- this returns the 0.NA/prefix-Handle of a given Handle. If you want to use Mark's approach (get the e-Mail address), just change Common.STD_TYPE_HSSERV to Common.STD_TYPE_EMAIL. Of course you can get any other information from the list of values in the corresponding 0.NA handle.

public static final HandleType getHandleType(String hdl) throws HandleException {
  ResolutionRequest req=new ResolutionRequest(
    Util.getZeroNAHandle(Util.encodeString(hdl)),
    new byte[][]{ Common.STD_TYPE_HSSERV },
    new int[0],
    null);
  AbstractResponse response=handleResolver.processRequest(req, null);
  if(response.responseCode==AbstractMessage.RC_HANDLE_NOT_FOUND) {
    throw new HandleException(HandleException.HANDLE_DOES_NOT_EXIST);
  } else  if (response instanceof ErrorResponse){
    String msg = Util.decodeString( ((ErrorResponse)response).message );
    throw new HandleException(HandleException.INTERNAL_ERROR,AbstractMessage.getResponseCodeMessage(response.responseCode)+": "+msg);
  }
  
  HandleValue values[] = ((ResolutionResponse)response).getHandleValues();
  if (values==null || values.length==0)
    throw new HandleException(HandleException.HANDLE_DOES_NOT_EXIST, "Handle contains no HS_SERV.");
  for (HandleValue hv : values) {
    if (Util.equals(Common.STD_TYPE_HSSERV, hv.getType())){
      return HandleType.lookup(hv.getDataAsString());
    }
  }
  throw new HandleException(HandleException.HANDLE_DOES_NOT_EXIST,"Handle contains no HS_SERV."); }

public static enum HandleType {
  UNKNOWN, CROSSREF, DATACITE;

  public static HandleType lookup(String hsServ) {
    if (hsServ.equalsIgnoreCase("0.SERV/10.crossref")) {
      return CROSSREF;
    } else if (hsServ.equalsIgnoreCase("0.SERV/10.TIB")) {
      return DATACITE;
    } else {
      return UNKNOWN;
    }
  }		
}

-----
UWE SCHINDLER
Webserver/Middleware Development
PANGAEA - Data Publisher for Earth & Environmental Science
MARUM (Cognium building) - University of Bremen
Room 0510, Hochschulring 18, D-28359 Bremen
Tel.: +49 421 218 65595
Fax:  +49 421 218 65505
http://www.pangaea.de/
E-mail: uschindler@pangaea.de


> -----Original Message-----
> From: handle-info-admin@cnri.reston.va.us [mailto:handle-info-
> admin@cnri.reston.va.us] On Behalf Of Bernd Fehling
> Sent: Wednesday, February 27, 2013 8:23 AM
> To: handle-info@cnri.reston.va.us
> Subject: [Handle-info] how to resolve a handle prefix owner?
> 
> Hi list,
> 
> i tried to figure out how to resolve an owner of a prefix handle but couldn't
> find any way to solve this.
> 
> Any idea how to lookup a prefix owner?
> 
> Regards
> Bernd
> 
> _______________________________________________
> Handle-Info mailing list
> Handle-Info@cnri.reston.va.us
> http://www.handle.net/mailman/listinfo/handle-info


_______________________________________________
Handle-Info mailing list
Handle-Info@cnri.reston.va.us
http://www.handle.net/mailman/listinfo/handle-info