当前位置: 首页>>代码示例>>Java>>正文


Java HandleException类代码示例

本文整理汇总了Java中net.handle.hdllib.HandleException的典型用法代码示例。如果您正苦于以下问题:Java HandleException类的具体用法?Java HandleException怎么用?Java HandleException使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


HandleException类属于net.handle.hdllib包,在下文中一共展示了HandleException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: isHandleRegistered

import net.handle.hdllib.HandleException; //导入依赖的package包/类
public boolean isHandleRegistered(String handle){
    boolean handleRegistered = false;
    ResolutionRequest req = buildResolutionRequest(handle);
    AbstractResponse response = null;
    HandleResolver resolver = new HandleResolver();
    try {
        response = resolver.processRequest(req);
    } catch (HandleException ex) {
        logger.info("Caught exception trying to process lookup request");
        ex.printStackTrace();
    }
    if((response!=null && response.responseCode==AbstractMessage.RC_SUCCESS)) {
        logger.info("Handle "+handle+" registered.");
        handleRegistered = true;
    } 
    return handleRegistered;
}
 
开发者ID:pengchengluo,项目名称:Peking-University-Open-Research-Data-Platform,代码行数:18,代码来源:HandlenetServiceBean.java

示例2: getHandlesForNA

import net.handle.hdllib.HandleException; //导入依赖的package包/类
/**
 * Return an enumeration of all the handles for a given naming authority.  This could be 
 * a very expensive call as it retrieves all of the handles at once.
 * 
 * @param namingAuthorityBytes
 * @return
 * @throws HandleException
 */
@SuppressWarnings("unchecked")
public Enumeration getHandlesForNA(byte[] namingAuthorityBytes) throws HandleException {
	log.debug("Get handles for na called ");
	String namingAuthority = Util.decodeString(namingAuthorityBytes);
	log.debug("Naming authority = " + namingAuthority);
	
	List<HandleInfo> handles = handleService.getAllHandlesForAuthority(namingAuthority);
	
	List<byte[]> handleValues = new LinkedList<byte[]>();
	
	for(HandleInfo hi : handles)
	{
		String handle = namingAuthority + "/" + hi.getLocalName();
		handleValues.add(Util.encodeString(handle));
	}
	return Collections.enumeration(handleValues);
}
 
开发者ID:nate-rcl,项目名称:irplus,代码行数:26,代码来源:IrHandleStorage.java

示例3: deleteValue

import net.handle.hdllib.HandleException; //导入依赖的package包/类
/**
 * Delete a value from the handle 
 * 
 * @return boolean
 *           <code>true</code> if the value was deleted else <code>false</code>
 * @param index
 *           the index of the value to delete
 * @throws HandleException
 */
public boolean deleteValue(int index) throws HandleException
{
    byte idHandle[] = Util.encodeString(Constants.NA_HANDLE_PREFIX + handleConfig.getPrefix());
    
    PublicKeyAuthenticationInfo pubKeyAuthInfo = new PublicKeyAuthenticationInfo(idHandle,
          Constants.SEC_KEY_IDX,
          handleConfig.getPrivateKey());
            
    RemoveValueRequest req = new RemoveValueRequest(Util.encodeString(this.getHandle()), index, pubKeyAuthInfo);
    
    AbstractResponse response = resolver.getResolver().processRequest(req);
    
    if (response.responseCode == AbstractMessage.RC_SUCCESS)
    {
        return true;
    }
    else
    {
        log.error("Error deleting handle value from handle " + getHandle() + ": " + AbstractMessage.getResponseCodeMessage(response.responseCode));
        return false;
    }
}
 
开发者ID:au-research,项目名称:ANDS-PIDS-Service,代码行数:32,代码来源:Handle.java

示例4: getHandlesByData

import net.handle.hdllib.HandleException; //导入依赖的package包/类
/**
 * Get a list of handles matching a data value
 * 
* @param data
*          A string contained within hamdles handles are to be returned
* @param type
*          The handle value type (or null if all types)
* @param pubReadOnly
*          Only include publicly readable values
 * @return List<Handle>
 *          A list of handles with data matching the string. If type 
 *          is provided only matches within that type will be returned
 * @throws DAOException
 */
public static List<Handle> getHandlesByData(String data,
                                            String type,
                                            boolean pubReadOnly) throws HandleException, DAOException
{
    HandleDAO hdao = new HandleDAO();
    List<String> l = hdao.getHandlesByData(data, type, pubReadOnly);
    List<Handle> handleObjects = new ArrayList<Handle>();
    
    try
    {
        for (Iterator<String> i = l.iterator(); i.hasNext();)
        {
            handleObjects.add(Handle.find(i.next()));
        }
    }
    catch (HandleException he)
    {
        log.info("Handle exception caught", he);
    }
    
    return handleObjects;
}
 
开发者ID:au-research,项目名称:ANDS-PIDS-Service,代码行数:37,代码来源:Handle.java

示例5: find

import net.handle.hdllib.HandleException; //导入依赖的package包/类
/**
* Obtain the Handle object associated with the provided handle string  
* 
* @return Handle
*           The Handle object if found else <code>null</code>
* @param handleString
*          A handle string
* @throws HandleException
*/
public static Handle find(String handleString) throws HandleException
{
    Handle handle = null;
    
    try
    {
        Resolver resolver = new Resolver();
        HandleValue[] hv = resolver.resolveHandle(handleString);
        if (hv.length > 0)
        {
            handle = new Handle();
            handle.setHandle(handleString);
        }
    }
    catch (HandleException he)
    {
        log.info("Handle exception caught", he);
    }
    
    return handle;
}
 
开发者ID:au-research,项目名称:ANDS-PIDS-Service,代码行数:31,代码来源:Handle.java

示例6: deleteAllowed

import net.handle.hdllib.HandleException; //导入依赖的package包/类
/**
 * Indicate whether a handle value can be deleted. A handle value
 * must be one of the allowed types in order for it to be deleted 
 * 
 * @return boolean
 *           <code>true</code> if the value can be deleted
 *           else <code>false</code>
 * @param index
 *           the index of the value
 * @throws HandleException
 */
public boolean deleteAllowed(int index) throws HandleException
{
    String[] types = {Constants.STD_TYPE_URL_STRING, Constants.XT_TYPE_DESC_STRING};
    
    HandleValue[] hv = resolver.resolveHandle(getHandle(), types);
    
    boolean allowed = false;
    
    for (int i=0; i < hv.length; i++)
    {
        if (hv[i].getIndex() == index)
        {
            allowed = true;
            break;
        }
    }
    
    return allowed;
}
 
开发者ID:au-research,项目名称:ANDS-PIDS-Service,代码行数:31,代码来源:Handle.java

示例7: getValueIndex

import net.handle.hdllib.HandleException; //导入依赖的package包/类
/**
      * Obtain the index the provided value is located at 
      * 
      * @return int
      *           the index the provided value is located at
      * @param value
      *           the value whose index is to be returned
      * @throws HandleException
      */
     public int getValueIndex(String value) throws HandleException
     {
         int index = -1;
         
//         String[] types = {Constants.STD_TYPE_URL_STRING, Constants.XT_TYPE_DESC_STRING};
         
//         HandleValue[] hv = resolver.resolveHandle(getHandle(), types);
         HandleValue[] hv = resolveAllowedValues(resolver.resolveHandle(getHandle()));
         
         for (int i=0; i < hv.length; i++)
         {
             if (hv[i].getDataAsString().equals(value))
             {
                 index = hv[i].getIndex();
                 break;
             }
         }
         
         return index;
     }
 
开发者ID:au-research,项目名称:ANDS-PIDS-Service,代码行数:30,代码来源:Handle.java

示例8: haveNA

import net.handle.hdllib.HandleException; //导入依赖的package包/类
public boolean haveNA(byte[] naBytes) throws HandleException {
	
	boolean haveNa = false;
	String namingAuthority = Util.decodeString(naBytes);
	log.debug("checking to see if we have naming authority : " + namingAuthority);
	String[] namingAuthorityParts = namingAuthority.split("/");
	
	if( namingAuthorityParts.length < 2 )
	{
		// false
	}
	else
	{
		String prefix = namingAuthorityParts[1];
		log.debug("Checing for prefix " + prefix);
		if( handleService.getNameAuthority(prefix) != null )
		{
		    haveNa = true;	
		}
		else
		{
			// false
		}
	}
	log.debug("returning haveNa = " + haveNa);
	return haveNa;

}
 
开发者ID:nate-rcl,项目名称:irplus,代码行数:29,代码来源:IrHandleStorage.java

示例9: createHandle

import net.handle.hdllib.HandleException; //导入依赖的package包/类
/**
 * Create a new handle record on the handle server 
 * 
 * @return AbstractResponse
 *           the handle server response to the create request
 * @param HandleValue[]
 *          An array of HandleValue objects
 * @throws HandleException
 */
private AbstractResponse createHandle(HandleValue[] hv) throws HandleException
{
    byte idHandle[] = Util.encodeString(Constants.NA_HANDLE_PREFIX + handleConfig.getPrefix());
    
    PublicKeyAuthenticationInfo pubKeyAuthInfo = new PublicKeyAuthenticationInfo(idHandle,
          Constants.SEC_KEY_IDX,
          handleConfig.getPrivateKey());

    CreateHandleRequest req = new CreateHandleRequest(Util.encodeString(this.getHandle()), hv, pubKeyAuthInfo);
    HandleResolver resolver = new HandleResolver();
    resolver.traceMessages = true;
    return resolver.processRequest(req);
}
 
开发者ID:au-research,项目名称:ANDS-PIDS-Service,代码行数:23,代码来源:Handle.java

示例10: isEmptyIndex

import net.handle.hdllib.HandleException; //导入依赖的package包/类
/**
 * Determine whether an index is in use 
 * 
 * @return boolean
 *           <code>true</code> if the index is available otherwise
 *           <code>false</code>
 * @param index
 *           the index to check
 * @throws HandleException
 */
public boolean isEmptyIndex(int index) throws HandleException
{
    HandleValue[] hvs = resolver.resolveHandle(this.getHandle());

    for (int i=0; i < hvs.length; i++)
    {
        if (hvs[i].getIndex() == index)
        {
            return false;
        }
    }

    return true;
}
 
开发者ID:au-research,项目名称:ANDS-PIDS-Service,代码行数:25,代码来源:Handle.java

示例11: deleteHandle

import net.handle.hdllib.HandleException; //导入依赖的package包/类
public boolean deleteHandle(byte[] arg0) throws HandleException {
	log.debug("delete all handle called - NOT IMPLEMENTED");
	return false;
}
 
开发者ID:nate-rcl,项目名称:irplus,代码行数:5,代码来源:IrHandleStorage.java

示例12: setHaveNA

import net.handle.hdllib.HandleException; //导入依赖的package包/类
public void setHaveNA(byte[] arg0, boolean arg1) throws HandleException {
	log.debug("set have na called - NOT IMPLEMENTED");
}
 
开发者ID:nate-rcl,项目名称:irplus,代码行数:4,代码来源:IrHandleStorage.java

示例13: updateValue

import net.handle.hdllib.HandleException; //导入依赖的package包/类
public void updateValue(byte[] arg0, HandleValue[] arg1)
		throws HandleException {
	log.debug("update value called - NOT IMPLEMENTED");
}
 
开发者ID:nate-rcl,项目名称:irplus,代码行数:5,代码来源:IrHandleStorage.java

示例14: create

import net.handle.hdllib.HandleException; //导入依赖的package包/类
/** 
 * Create a Handle object object using the provided Identifier and
 * handle values
 * 
 * @return Handle
 *           the Handle object
 * @param identifier
 *           the agent Identifier object
 * @param hv
 *           an array of HandleValue objects to be added to the handle
 * @throws DAOException
 * @throws HandleException
 */
public static Handle create(Identifier identifier,
                            HandleValue[] hv) throws DAOException, HandleException
{
    Handle handleObject = new Handle();
    
    HandleConfig hc = HandleConfig.getHandleConfig();
    handleObject.setHandle(hc.getPrefix() + '/' + Handle.getNextSuffix());
    
    String idHash = null;
    AdminRecord admin = handleObject.createAdminRecord(Constants.NA_HANDLE_PREFIX + hc.getPrefix(), Constants.ADMIN_GROUP_IDX);
    
    HandleValue values[] = new HandleValue[hv.length + 2];

    // load the passed values into the value array
    int i;
    
    for (i = 0; i < hv.length; i++)
    {
        values[i] = hv[i];
    }
    
    // add the admin values
    values[i] = new HandleValue();
    values[i].setIndex(Constants.ADMIN_IDX);
    values[i].setType(Common.STD_TYPE_HSADMIN);
    values[i].setData(Encoder.encodeAdminRecord(admin));
    values[i].setTTL(Constants.DEFAULT_TTL);
    
    values[i+1] = new HandleValue();
    values[i+1].setIndex(Constants.AGENT_IDX);
    values[i+1].setType(Constants.XT_AGENTID);
    values[i+1].setData(Util.encodeString(identifier.getHandle()));
    values[i+1].setTTL(Constants.DEFAULT_TTL);
    
    AbstractResponse response = handleObject.createHandle(values);

    if (response.responseCode == AbstractMessage.RC_SUCCESS)
    {
        log.info("Successfully created handle: " + handleObject.getHandle());
        return handleObject;
    }
    else
    {
        log.info("Failed to create handle: " + response);
        return null;
    }
}
 
开发者ID:au-research,项目名称:ANDS-PIDS-Service,代码行数:61,代码来源:Handle.java

示例15: createAdmin

import net.handle.hdllib.HandleException; //导入依赖的package包/类
/** 
 * Create an agent admin Handle object object using the provided identifier
 * string and authentication domain string
 * 
 * @return Handle
 *           the Handle object
 * @param identifier
 *           the agent identifier string
 * @param authDomain
 *           the agent authentication domain string
 * @throws DAOException
 * @throws HandleException
 */
public static Handle createAdmin(String identifier,
		                         String authDomain,
		                         String appId) throws DAOException, HandleException
{
    Handle handleObject = new Handle();

    HandleConfig hc = HandleConfig.getHandleConfig();

    handleObject.setHandle(hc.getPrefix() + '/' + Handle.getNextSuffix());

    AdminRecord admin = handleObject.createAdminRecord(Constants.NA_HANDLE_PREFIX + hc.getPrefix(), Constants.ADMIN_GROUP_IDX);

    HandleValue values[] = new HandleValue[4];

    values[0] = new HandleValue();
    values[0].setIndex(Constants.AGENT_DESC_IDX);
    values[0].setType(Constants.XT_TYPE_DESC);
    values[0].setAnyoneCanRead(false);
    values[0].setData(Util.encodeString(identifier + Identifier.separator + authDomain));
    values[0].setTTL(Constants.DEFAULT_TTL);
    
    values[1] = new HandleValue();
    values[1].setIndex(Constants.ADMIN_IDX);
    values[1].setType(Common.STD_TYPE_HSADMIN);
    values[1].setData(Encoder.encodeAdminRecord(admin));
    values[1].setTTL(Constants.DEFAULT_TTL);
    
    values[2] = new HandleValue();
    values[2].setIndex(Constants.AGENT_IDX);
    values[2].setType(Constants.XT_AGENTID);
    values[2].setData(Util.encodeString(handleObject.getHandle()));
    values[2].setTTL(Constants.DEFAULT_TTL);
    
    values[3] = new HandleValue();
    values[3].setIndex(Constants.AGENT_DESC_APPIDX);
    values[3].setType(Constants.XT_APPID);
    values[3].setAnyoneCanRead(false);
    values[3].setData(Util.encodeString(appId));
    values[3].setTTL(Constants.DEFAULT_TTL);

    AbstractResponse response = handleObject.createHandle(values);

    if (response.responseCode == AbstractMessage.RC_SUCCESS)
    {
        log.info("Successfully created admin handle: " + handleObject.getHandle());
        return handleObject;
    }
    else
    {
        log.info("Failed to create admin handle: " + response);
        return null;
    }
}
 
开发者ID:au-research,项目名称:ANDS-PIDS-Service,代码行数:67,代码来源:Handle.java


注:本文中的net.handle.hdllib.HandleException类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。