diff options
author | Ade Lee <alee@redhat.com> | 2011-12-07 16:58:12 -0500 |
---|---|---|
committer | Ade Lee <alee@redhat.com> | 2011-12-07 16:58:12 -0500 |
commit | 32150d3ee32f8ac27118af7c792794b538c78a2f (patch) | |
tree | 52dd96f664a6fa51be25b28b6f10adc5f2c9f660 /pki/base/common/src/com/netscape/cmscore/connector/HttpConnector.java | |
parent | f05d58a46795553beb8881039cc922974b40db34 (diff) | |
download | pki-32150d3ee32f8ac27118af7c792794b538c78a2f.tar.gz pki-32150d3ee32f8ac27118af7c792794b538c78a2f.tar.xz pki-32150d3ee32f8ac27118af7c792794b538c78a2f.zip |
Formatting
Formatted project according to eclipse project settings
Diffstat (limited to 'pki/base/common/src/com/netscape/cmscore/connector/HttpConnector.java')
-rw-r--r-- | pki/base/common/src/com/netscape/cmscore/connector/HttpConnector.java | 96 |
1 files changed, 52 insertions, 44 deletions
diff --git a/pki/base/common/src/com/netscape/cmscore/connector/HttpConnector.java b/pki/base/common/src/com/netscape/cmscore/connector/HttpConnector.java index fefbe0f31..83635b50b 100644 --- a/pki/base/common/src/com/netscape/cmscore/connector/HttpConnector.java +++ b/pki/base/common/src/com/netscape/cmscore/connector/HttpConnector.java @@ -17,7 +17,6 @@ // --- END COPYRIGHT BLOCK --- package com.netscape.cmscore.connector; - import java.util.Vector; import com.netscape.certsrv.apps.CMS; @@ -36,7 +35,6 @@ import com.netscape.certsrv.request.RequestStatus; import com.netscape.cmsutil.http.JssSSLSocketFactory; import com.netscape.cmsutil.net.ISocketFactory; - public class HttpConnector implements IConnector { protected IAuthority mSource = null; protected IRemoteAuthority mDest = null; @@ -45,13 +43,15 @@ public class HttpConnector implements IConnector { // XXX todo make this a pool. // XXX use CMMF in the future. protected IHttpConnection mConn = null; - private Thread mResendThread = null; + private Thread mResendThread = null; private IResender mResender = null; private int mTimeout; private HttpConnFactory mConnFactory = null; + public HttpConnector(IAuthority source, String nickName, - IRemoteAuthority dest, int resendInterval, IConfigStore config) throws EBaseException { + IRemoteAuthority dest, int resendInterval, IConfigStore config) + throws EBaseException { mTimeout = 0; mSource = source; @@ -65,46 +65,48 @@ public class HttpConnector implements IConnector { CMS.debug("HttpConn: max " + maxConns); try { - mConnFactory = new HttpConnFactory(minConns, maxConns, source, dest, nickName, 0); + mConnFactory = new HttpConnFactory(minConns, maxConns, source, + dest, nickName, 0); } catch (EBaseException e) { CMS.debug("can't create new HttpConnFactory " + e.toString()); } - // mConn = CMS.getHttpConnection(dest, mFactory); - // this will start resending past requests in parallel. - mResender = CMS.getResender(mSource, nickName, dest, resendInterval); + // mConn = CMS.getHttpConnection(dest, mFactory); + // this will start resending past requests in parallel. + mResender = CMS.getResender(mSource, nickName, dest, resendInterval); mResendThread = new Thread(mResender, "HttpConnector"); } - + // Inserted by beomsuk public HttpConnector(IAuthority source, String nickName, - IRemoteAuthority dest, int resendInterval, IConfigStore config, int timeout) throws EBaseException { + IRemoteAuthority dest, int resendInterval, IConfigStore config, + int timeout) throws EBaseException { mSource = source; mDest = dest; mTimeout = timeout; mFactory = new JssSSLSocketFactory(nickName); int minConns = config.getInteger("minHttpConns", 1); - int maxConns = config.getInteger("maxHttpConns", 15); + int maxConns = config.getInteger("maxHttpConns", 15); CMS.debug("HttpConn: min " + minConns); CMS.debug("HttpConn: max " + maxConns); try { - mConnFactory = new HttpConnFactory(minConns, maxConns, source, dest, nickName, timeout); + mConnFactory = new HttpConnFactory(minConns, maxConns, source, + dest, nickName, timeout); } catch (EBaseException e) { CMS.debug("can't create new HttpConnFactory"); } - // this will start resending past requests in parallel. - mResender = CMS.getResender(mSource, nickName, dest, resendInterval); + // this will start resending past requests in parallel. + mResender = CMS.getResender(mSource, nickName, dest, resendInterval); mResendThread = new Thread(mResender, "HttpConnector"); } // Insert end - - public boolean send(IRequest r) - throws EBaseException { + + public boolean send(IRequest r) throws EBaseException { IHttpConnection curConn = null; try { @@ -141,55 +143,61 @@ public class HttpConnector implements IConnector { CMS.debug("reply status " + replyStatus); // non terminal states. - // XXX hack: don't resend get revocation info requests since + // XXX hack: don't resend get revocation info requests since // resent results are ignored. - if ((!r.getRequestType().equals( - IRequest.GETREVOCATIONINFO_REQUEST)) && - (replyStatus == RequestStatus.BEGIN || - replyStatus == RequestStatus.PENDING || - replyStatus == RequestStatus.SVC_PENDING || - replyStatus == RequestStatus.APPROVED)) { - CMS.debug("HttpConn: remote request id still pending " + - r.getRequestId() + " state " + replyStatus); - mSource.log(ILogger.LL_INFO, CMS.getLogMessage("CMSCORE_CONNECTOR_REQUEST_NOT_COMPLETED", r.getRequestId().toString())); + if ((!r.getRequestType().equals(IRequest.GETREVOCATIONINFO_REQUEST)) + && (replyStatus == RequestStatus.BEGIN + || replyStatus == RequestStatus.PENDING + || replyStatus == RequestStatus.SVC_PENDING || replyStatus == RequestStatus.APPROVED)) { + CMS.debug("HttpConn: remote request id still pending " + + r.getRequestId() + " state " + replyStatus); + mSource.log(ILogger.LL_INFO, CMS.getLogMessage( + "CMSCORE_CONNECTOR_REQUEST_NOT_COMPLETED", r + .getRequestId().toString())); mResender.addRequest(r); return false; } // request was completed. - replymsg.toRequest(r); // this only copies contents. + replymsg.toRequest(r); // this only copies contents. // terminal states other than completed - if (replyStatus == RequestStatus.REJECTED || - replyStatus == RequestStatus.CANCELED) { - CMS.debug( - "remote request id " + r.getRequestId() + - " was rejected or cancelled."); + if (replyStatus == RequestStatus.REJECTED + || replyStatus == RequestStatus.CANCELED) { + CMS.debug("remote request id " + r.getRequestId() + + " was rejected or cancelled."); r.setExtData(IRequest.REMOTE_STATUS, replyStatus.toString()); r.setExtData(IRequest.RESULT, IRequest.RES_ERROR); - r.setExtData(IRequest.ERROR, - new EBaseException(CMS.getUserMessage("CMS_BASE_REMOTE_AUTHORITY_ERROR"))); - // XXX overload svcerrors for now. - Vector policyErrors = r.getExtDataInStringVector(IRequest.ERRORS); + r.setExtData( + IRequest.ERROR, + new EBaseException( + CMS.getUserMessage("CMS_BASE_REMOTE_AUTHORITY_ERROR"))); + // XXX overload svcerrors for now. + Vector policyErrors = r + .getExtDataInStringVector(IRequest.ERRORS); if (policyErrors != null && policyErrors.size() > 0) { r.setExtData(IRequest.SVCERRORS, policyErrors); } } - CMS.debug( - "remote request id " + r.getRequestId() + " was completed"); + CMS.debug("remote request id " + r.getRequestId() + + " was completed"); return true; } catch (EBaseException e) { CMS.debug("HttpConn: inside EBaseException " + e.toString()); - + if (!r.getRequestType().equals(IRequest.GETREVOCATIONINFO_REQUEST)) mResender.addRequest(r); - CMS.debug("HttpConn: error sending request to cert " + e.toString()); - mSource.log(ILogger.LL_FAILURE, CMS.getLogMessage("CMSCORE_CONNECTOR_SEND_REQUEST", r.getRequestId().toString(), mDest.getHost(), Integer.toString(mDest.getPort()))); - // mSource.log(ILogger.LL_INFO, - // "Queing " + r.getRequestId() + " for resend."); + CMS.debug("HttpConn: error sending request to cert " + + e.toString()); + mSource.log(ILogger.LL_FAILURE, CMS.getLogMessage( + "CMSCORE_CONNECTOR_SEND_REQUEST", r.getRequestId() + .toString(), mDest.getHost(), Integer + .toString(mDest.getPort()))); + // mSource.log(ILogger.LL_INFO, + // "Queing " + r.getRequestId() + " for resend."); return false; } finally { |