Exemplo n.º 1
0
 /** {@inheritDoc} */
 @Override
 public <T> T execute(
     ConnectionCallback<T> action,
     RpcHost host,
     String division,
     String accessCode,
     String verifyCode)
     throws DataAccessException {
   return execute(
       action,
       new RpcRequest(
           host,
           RpcUriUtils.toCredentials(division, accessCode, verifyCode, null, null),
           null,
           null,
           (List) null));
 }
Exemplo n.º 2
0
 protected RpcRequest createRpcRequest(
     RpcHost host,
     String division,
     String accessCode,
     String verifyCode,
     String rpcContext,
     String rpcName,
     List params) {
   RpcRequest request =
       new RpcRequest(
           host,
           RpcUriUtils.toCredentials(division, accessCode, verifyCode, null, null),
           rpcContext,
           rpcName,
           params);
   if (getTimeout() > 0) request.setTimeout(getTimeout());
   return request;
 }
Exemplo n.º 3
0
  protected RpcResponse doExecute(RpcRequest request) {
    Connection c = null;
    ConnectionSpec auth = null;
    try {
      try {
        outputRequestInfo("doExecute: Before validateRequest...", request);
        request = validateRequest(request);
        outputRequestInfo("doExecute: After validateRequest...", request);
        RpcHost host = request.getHost();
        auth = createConnectionSpec(request);
        outputAuthInfo(auth);
        c = this.connectionFactory.getConnection(host, auth);
      } catch (RpcException e) {
        logger.error("doExecute: RpcException occurred.  Error: " + e.getMessage(), e);
        fireRpcExceptionEvent(request, e);
        throw getExceptionTranslator()
            .translate("open", RpcUriUtils.sanitize(request.getUriString(), auth), e);
      }
      try {
        logger.debug("executing {}", RpcUriUtils.sanitize(request.getUriString(), auth));

        RpcResponse response = c.send(request);

        logger.debug("received  {}", response.toString());

        fireRpcResponseEvent(request, response);

        return response;
      } catch (RpcException e) {
        fireRpcExceptionEvent(request, e);
        throw getExceptionTranslator()
            .translate("send", RpcUriUtils.sanitize(request.getUriString(), auth), e);
      }
    } catch (DataAccessException e) {
      if (e instanceof PermissionDeniedDataAccessException) {
        logger.debug(
            "permission denied in " + RpcUriUtils.sanitize(request.getUriString(), auth), e);
      } else {
        logger.error("error in  " + RpcUriUtils.sanitize(request.getUriString(), auth), e);
      }
      throw e;
    } finally {
      try {
        if (c != null) c.close();
      } catch (RpcException e) {
        fireRpcExceptionEvent(request, e);
        throw getExceptionTranslator()
            .translate("close", RpcUriUtils.sanitize(request.getUriString(), auth), e);
      }
    }
  }
Exemplo n.º 4
0
  protected <T> T doExecute(ConnectionCallback<T> action, RpcRequest request) {
    Assert.notNull(action, "Callback object must not be null");

    Connection c = null;
    ConnectionSpec auth = null;
    try {

      try {
        request = validateRequest(request);
        RpcHost host = request.getHost();
        auth = createConnectionSpec(request);
        logger.debug("connect   {}", RpcUriUtils.sanitize(request.getUriString(), auth));
        c = this.connectionFactory.getConnection(host, auth);
      } catch (RpcException e) {
        throw getExceptionTranslator()
            .translate("open", RpcUriUtils.sanitize(request.getUriString(), auth), e);
      }
      try {
        return action.doInConnection(c);
      } catch (RpcException e) {
        throw getExceptionTranslator()
            .translate("callback", RpcUriUtils.sanitize(request.getUriString(), auth), e);
      }
    } catch (DataAccessException e) {
      if (e instanceof PermissionDeniedDataAccessException) {
        logger.debug(
            "permission denied in " + RpcUriUtils.sanitize(request.getUriString(), auth), e);
      } else {
        logger.error("error in  " + RpcUriUtils.sanitize(request.getUriString(), auth), e);
      }
      throw e;
    } finally {
      try {
        if (c != null) c.close();
      } catch (RpcException e) {
        throw getExceptionTranslator()
            .translate("close", RpcUriUtils.sanitize(request.getUriString(), auth), e);
      }
    }
  }