Skip to content

Commit 9cb7a7b

Browse files
committed
code review comments and code reviews fixes
1 parent 3a20f6a commit 9cb7a7b

20 files changed

Lines changed: 418 additions & 549 deletions

java/src/main/java/com/cybersource/ws/client/Client.java

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
import static com.cybersource.ws.client.Utility.*;
4141

4242
/**
43-
* Class containing runTransaction() methods that accept the requests in the
43+
* Containing runTransaction() methods that accept the requests in the
4444
* form of a Map object.
4545
*/
4646
public class Client {
@@ -62,7 +62,7 @@ public class Client {
6262
* @throws FaultException if a fault occurs.
6363
* @throws ClientException if any other exception occurs.
6464
*/
65-
public static Map runTransaction(Map<String,String> request, Properties props)
65+
public static Map<String,String> runTransaction(Map<String,String> request, Properties props)
6666
throws FaultException, ClientException {
6767
return (runTransaction(
6868
request, props, null, true, true));
@@ -248,8 +248,18 @@ private static Document soapWrapAndSign(
248248
return resultDocument ;
249249
}
250250

251+
252+
/**
253+
* Wraps the given Map object in SOAP envelope.
254+
*
255+
* @param request Map object containing the request.
256+
* @param mc MerchantConfig object.
257+
* @param builder DocumentBuilder object.
258+
* @return document.
259+
* @throws IOException if reading from string fails.
260+
* @throws SAXException
261+
*/
251262
private static Document soapWrap(Map request, MerchantConfig mc, DocumentBuilder builder) throws SAXException, IOException{
252-
// wrap in SOAP envelope
253263
Object[] arguments
254264
= {mc.getEffectiveNamespaceURI(),
255265
mapToString(request, false, PCI.REQUEST)};
@@ -277,7 +287,6 @@ private static HashMap<String, String> soapUnwrap(
277287

278288
boolean logSignedData = mc.getLogSignedData();
279289

280-
281290
if (logSignedData) {
282291
logger.log(Logger.LT_REPLY,
283292
Utility.nodeToString(doc, PCI.REPLY));

java/src/main/java/com/cybersource/ws/client/ClientException.java

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@
2121
import java.net.HttpURLConnection;
2222

2323
/**
24-
* Exception class used by both Basic and XML clients.
24+
* Used by both Basic and XML clients.
25+
* All exceptions other than faults are wrapped in ClientException.
2526
*/
2627
public class ClientException
2728
extends Exception {
@@ -31,7 +32,6 @@ public class ClientException
3132
private String httpError = null;
3233

3334
/**
34-
* Constructor.
3535
*
3636
* @param _innerException the actual exception that occurred.
3737
* @param logger used to log the exception details.
@@ -43,7 +43,6 @@ public ClientException(
4343
}
4444

4545
/**
46-
* Constructor.
4746
*
4847
* @param _innerException the actual exception that occurred.
4948
* @param _critical flag that tells whether or not the exception
@@ -59,7 +58,6 @@ public ClientException(
5958
}
6059

6160
/**
62-
* Constructor.
6361
*
6462
* @param _httpStatusCode HTTP status code
6563
* @param logger used to log the exception details.
@@ -72,7 +70,6 @@ public ClientException(int _httpStatusCode, Logger logger) {
7270
}
7371

7472
/**
75-
* Constructor.
7673
*
7774
* @param _httpStatusCode HTTP status code
7875
* @param _httpError Additional HTTP error information; may be null.
@@ -86,7 +83,6 @@ public ClientException(
8683
}
8784

8885
/**
89-
* Constructor.
9086
*
9187
* @param _httpStatusCode HTTP status code
9288
* @param _httpError Additional HTTP error information; may be null.

java/src/main/java/com/cybersource/ws/client/ConfigException.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
*/
2727
public class ConfigException extends Exception {
2828
/**
29-
* Constructor.
3029
*
3130
* @param message exception message.
3231
*/

java/src/main/java/com/cybersource/ws/client/Connection.java

Lines changed: 47 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
11
/*
2-
* Copyright 2003-2014 CyberSource Corporation
3-
*
4-
* THE SOFTWARE AND THE DOCUMENTATION ARE PROVIDED ON AN "AS IS" AND "AS
5-
* AVAILABLE" BASIS WITH NO WARRANTY. YOU AGREE THAT YOUR USE OF THE SOFTWARE AND THE
6-
* DOCUMENTATION IS AT YOUR SOLE RISK AND YOU ARE SOLELY RESPONSIBLE FOR ANY DAMAGE TO YOUR
7-
* COMPUTER SYSTEM OR OTHER DEVICE OR LOSS OF DATA THAT RESULTS FROM SUCH USE. TO THE FULLEST
8-
* EXTENT PERMISSIBLE UNDER APPLICABLE LAW, CYBERSOURCE AND ITS AFFILIATES EXPRESSLY DISCLAIM ALL
9-
* WARRANTIES OF ANY KIND, EXPRESS OR IMPLIED, WITH RESPECT TO THE SOFTWARE AND THE
10-
* DOCUMENTATION, INCLUDING ALL WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE,
11-
* SATISFACTORY QUALITY, ACCURACY, TITLE AND NON-INFRINGEMENT, AND ANY WARRANTIES THAT MAY ARISE
12-
* OUT OF COURSE OF PERFORMANCE, COURSE OF DEALING OR USAGE OF TRADE. NEITHER CYBERSOURCE NOR
13-
* ITS AFFILIATES WARRANT THAT THE FUNCTIONS OR INFORMATION CONTAINED IN THE SOFTWARE OR THE
14-
* DOCUMENTATION WILL MEET ANY REQUIREMENTS OR NEEDS YOU MAY HAVE, OR THAT THE SOFTWARE OR
15-
* DOCUMENTATION WILL OPERATE ERROR FREE, OR THAT THE SOFTWARE OR DOCUMENTATION IS COMPATIBLE
16-
* WITH ANY PARTICULAR OPERATING SYSTEM.
17-
*/
2+
* Copyright 2003-2014 CyberSource Corporation
3+
*
4+
* THE SOFTWARE AND THE DOCUMENTATION ARE PROVIDED ON AN "AS IS" AND "AS
5+
* AVAILABLE" BASIS WITH NO WARRANTY. YOU AGREE THAT YOUR USE OF THE SOFTWARE AND THE
6+
* DOCUMENTATION IS AT YOUR SOLE RISK AND YOU ARE SOLELY RESPONSIBLE FOR ANY DAMAGE TO YOUR
7+
* COMPUTER SYSTEM OR OTHER DEVICE OR LOSS OF DATA THAT RESULTS FROM SUCH USE. TO THE FULLEST
8+
* EXTENT PERMISSIBLE UNDER APPLICABLE LAW, CYBERSOURCE AND ITS AFFILIATES EXPRESSLY DISCLAIM ALL
9+
* WARRANTIES OF ANY KIND, EXPRESS OR IMPLIED, WITH RESPECT TO THE SOFTWARE AND THE
10+
* DOCUMENTATION, INCLUDING ALL WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE,
11+
* SATISFACTORY QUALITY, ACCURACY, TITLE AND NON-INFRINGEMENT, AND ANY WARRANTIES THAT MAY ARISE
12+
* OUT OF COURSE OF PERFORMANCE, COURSE OF DEALING OR USAGE OF TRADE. NEITHER CYBERSOURCE NOR
13+
* ITS AFFILIATES WARRANT THAT THE FUNCTIONS OR INFORMATION CONTAINED IN THE SOFTWARE OR THE
14+
* DOCUMENTATION WILL MEET ANY REQUIREMENTS OR NEEDS YOU MAY HAVE, OR THAT THE SOFTWARE OR
15+
* DOCUMENTATION WILL OPERATE ERROR FREE, OR THAT THE SOFTWARE OR DOCUMENTATION IS COMPATIBLE
16+
* WITH ANY PARTICULAR OPERATING SYSTEM.
17+
*/
1818

1919
package com.cybersource.ws.client;
2020

@@ -38,33 +38,32 @@
3838

3939

4040
/**
41-
* Connection class is a factory class for creating an instance for HttpClientConnection or
41+
* It is a factory class for creating an instance for HttpClientConnection or
4242
* JDKHttpURLConnection or PoolingHttpClientConnection.
43-
*
44-
* @author sunagara
4543
*/
4644
abstract public class Connection {
4745
final MerchantConfig mc;
4846
private final DocumentBuilder builder;
4947
final LoggerWrapper logger;
50-
51-
/**
52-
* Constructor.
53-
* It initializes three arguments MerchantConfig, DocumentBuilder and Logger
54-
* Any class extending this class must implement three argument constructor
55-
* @param mc
56-
* @param builder
57-
* @param logger
58-
*/
59-
protected Connection(MerchantConfig mc, DocumentBuilder builder,
60-
LoggerWrapper logger) {
48+
49+
/**
50+
* It initializes three arguments MerchantConfig, DocumentBuilder and Logger
51+
* Any class extending this class must implement three argument constructor
52+
*
53+
* @param mc
54+
* @param builder
55+
* @param logger
56+
*/
57+
protected Connection(MerchantConfig mc, DocumentBuilder builder,
58+
LoggerWrapper logger) {
6159
this.mc = mc;
6260
this.builder = builder;
6361
this.logger = logger;
6462
}
6563

6664
/**
6765
* Get connection instance based on properties
66+
*
6867
* @param mc
6968
* @param builder
7069
* @param logger
@@ -73,30 +72,33 @@ protected Connection(MerchantConfig mc, DocumentBuilder builder,
7372
*/
7473
public static Connection getInstance(
7574
MerchantConfig mc, DocumentBuilder builder, LoggerWrapper logger) throws ClientException {
76-
if (mc.getUseHttpClient()) {
77-
return new HttpClientConnection(mc, builder, logger);
78-
} else if (mc.getUseHttpClientWithConnectionPool()) {
75+
if (mc.getUseHttpClientWithConnectionPool()) {
7976
return new PoolingHttpClientConnection(mc, builder, logger);
77+
} else if (mc.getUseHttpClient()) {
78+
return new HttpClientConnection(mc, builder, logger);
8079
} else {
8180
// HttpClient is not set in properties file then JDKHttpURLConnection class instance.
8281
return new JDKHttpURLConnection(mc, builder, logger);
8382
}
8483
}
8584

8685
/**
87-
* Abstract method to check is request sent or not
86+
* method to check is request sent or not
87+
*
8888
* @return boolean
8989
*/
9090
abstract public boolean isRequestSent();
9191

9292
/**
93-
* Abstract method to release the connection related objects
93+
* method to release the connection related objects
94+
*
9495
* @throws ClientException
9596
*/
9697
abstract public void release() throws ClientException;
9798

9899
/**
99-
* Abstract method to post request
100+
* method to post request
101+
*
100102
* @param request
101103
* @param startTime
102104
* @throws IOException
@@ -111,23 +113,20 @@ abstract void postDocument(Document request, long startTime)
111113
ProtocolException;
112114

113115
/**
114-
* Abstract method to get http response code
115116
* @return int
116117
* @throws IOException
117118
*/
118119
abstract int getHttpResponseCode()
119120
throws IOException;
120121

121122
/**
122-
* Abstract method to get response stream
123123
* @return InputStream
124124
* @throws IOException
125125
*/
126126
abstract InputStream getResponseStream()
127127
throws IOException;
128128

129129
/**
130-
* Abstract method to get response error stream
131130
* @return InputStram
132131
* @throws IOException
133132
*/
@@ -136,6 +135,7 @@ abstract InputStream getResponseErrorStream()
136135

137136
/**
138137
* Post the request document and validate the response for any faults from the Server.
138+
*
139139
* @param request - Request document
140140
* @return - Response XML as Document object.
141141
* @throws ClientException
@@ -162,7 +162,8 @@ public Document post(Document request, long startTime)
162162

163163

164164
/**
165-
* Validate the Http response for any faults returned from the server.
165+
* Validate the Http response for any faults returned from the server.
166+
*
166167
* @throws FaultException
167168
* @throws ClientException
168169
*/
@@ -230,7 +231,8 @@ private void checkForFault()
230231
}
231232

232233
/**
233-
* Method helps to parse/read the response xml into Document object.
234+
* Helps to parse/read the response xml into Document object.
235+
*
234236
* @return - returns a Document object
235237
* @throws IOException
236238
* @throws SAXException
@@ -246,7 +248,8 @@ private Document parseReceivedDocument()
246248

247249
/**
248250
* Converts the Document object into ByteArrayStream.
249-
* @param doc - Document object
251+
*
252+
* @param doc - Document object
250253
* @return ByteArrayStream
251254
* @throws TransformerConfigurationException
252255
* @throws TransformerException
@@ -263,15 +266,9 @@ static ByteArrayOutputStream makeStream(Document doc)
263266
return baos;
264267
}
265268

266-
/**
267-
* Log Request Headers
268-
*/
269-
abstract public void logRequestHeaders();
269+
abstract public void logRequestHeaders();
270270

271-
/**
272-
* Log Response Headers
273-
*/
274-
abstract public void logResponseHeaders();
271+
abstract public void logResponseHeaders();
275272
}
276273

277274

java/src/main/java/com/cybersource/ws/client/ConnectionHelper.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@
3030
/**
3131
* Helps in creating the Proxy and adding Proxy credentials to JDKHttpURLConnection.
3232
*
33-
* @author sunagara
3433
*/
3534
public class ConnectionHelper {
3635

0 commit comments

Comments
 (0)