Author: andrew.plotnikov
Date: 2011-12-23 08:38:34 -0500 (Fri, 23 Dec 2011)
New Revision: 5347
Modified:
ws/trunk/exo.ws.commons/src/main/java/org/exoplatform/common/http/client/Codecs.java
ws/trunk/exo.ws.commons/src/main/java/org/exoplatform/common/http/client/DefaultAuthHandler.java
ws/trunk/exo.ws.commons/src/main/java/org/exoplatform/common/http/client/HTTPConnection.java
Log:
EXOJCR-1687: Fixed new sonar violations in project
Modified:
ws/trunk/exo.ws.commons/src/main/java/org/exoplatform/common/http/client/Codecs.java
===================================================================
---
ws/trunk/exo.ws.commons/src/main/java/org/exoplatform/common/http/client/Codecs.java 2011-12-23
13:21:25 UTC (rev 5346)
+++
ws/trunk/exo.ws.commons/src/main/java/org/exoplatform/common/http/client/Codecs.java 2011-12-23
13:38:34 UTC (rev 5347)
@@ -740,8 +740,12 @@
{
int next = findEOL(data, start) + 2;
if (next - 2 <= start)
+ {
break; // empty line -> end of headers
+ }
+
hdr = new String(data, start, next - 2 - start, "8859_1");
+
start = next;
// handle line continuation
@@ -749,12 +753,13 @@
while (next < data.length - 1 && ((ch = data[next]) == ' '
|| ch == '\t'))
{
next = findEOL(data, start) + 2;
- hdr += new String(data, start, next - 2 - start, "8859_1");
+ hdr += new String(data, start, next - 2 - start, "8859_1");
//NOSONAR
start = next;
}
if (!hdr.regionMatches(true, 0, "Content-Disposition", 0, 19))
continue;
+
Vector pcd = Util.parseHeader(hdr.substring(hdr.indexOf(':') + 1));
HttpHeaderElement elem = Util.getElement(pcd, "form-data");
Modified:
ws/trunk/exo.ws.commons/src/main/java/org/exoplatform/common/http/client/DefaultAuthHandler.java
===================================================================
---
ws/trunk/exo.ws.commons/src/main/java/org/exoplatform/common/http/client/DefaultAuthHandler.java 2011-12-23
13:21:25 UTC (rev 5346)
+++
ws/trunk/exo.ws.commons/src/main/java/org/exoplatform/common/http/client/DefaultAuthHandler.java 2011-12-23
13:38:34 UTC (rev 5347)
@@ -841,10 +841,12 @@
A1 = extra[DI_A1];
A2 = method + ":" + params[uri].getValue();
+
if (qop != -1 &&
params[qop].getValue().equalsIgnoreCase("auth-int"))
{
- A2 += ":" + hash;
+ A2 += ":" + hash; //NOSONAR
}
+
A2 = MD5.hexDigest(A2);
if (qop == -1)
@@ -1215,8 +1217,12 @@
// draft-01 was: A2 = resp.getStatusCode() + ":" + uri;
A2 = ":" + uri;
+
if (qop.equalsIgnoreCase("auth-int"))
- A2 += ":" + MD5.toHex(hash);
+ {
+ A2 += ":" + MD5.toHex(hash); //NOSONAR
+ }
+
A2 = MD5.hexDigest(A2);
hash = MD5.digest(A1 + ":" + nonce + ":" + nc + ":" +
cnonce + ":" + qop + ":" + A2);
Modified:
ws/trunk/exo.ws.commons/src/main/java/org/exoplatform/common/http/client/HTTPConnection.java
===================================================================
---
ws/trunk/exo.ws.commons/src/main/java/org/exoplatform/common/http/client/HTTPConnection.java 2011-12-23
13:21:25 UTC (rev 5346)
+++
ws/trunk/exo.ws.commons/src/main/java/org/exoplatform/common/http/client/HTTPConnection.java 2011-12-23
13:38:34 UTC (rev 5347)
@@ -789,11 +789,16 @@
*/
public HTTPResponse Head(String file, NVPair[] form_data, NVPair[] headers) throws
IOException, ModuleException
{
- String File = stripRef(file), query = Codecs.nv2query(form_data);
+ String query = Codecs.nv2query(form_data);
+ StringBuffer resource = new StringBuffer(stripRef(file));
+
if (query != null && query.length() > 0)
- File += "?" + query;
+ {
+ resource.append("?");
+ resource.append(query);
+ }
- return setupRequest("HEAD", File, headers, null, null);
+ return setupRequest("HEAD", resource.toString(), headers, null, null);
}
/**
@@ -826,11 +831,15 @@
*/
public HTTPResponse Head(String file, String query, NVPair[] headers) throws
IOException, ModuleException
{
- String File = stripRef(file);
+ StringBuffer resource = new StringBuffer(stripRef(file));
+
if (query != null && query.length() > 0)
- File += "?" + Codecs.URLEncode(query);
+ {
+ resource.append("?");
+ resource.append(Codecs.URLEncode(query));
+ }
- return setupRequest("HEAD", File, headers, null, null);
+ return setupRequest("HEAD", resource.toString(), headers, null, null);
}
/**
@@ -876,11 +885,16 @@
*/
public HTTPResponse Get(String file, NVPair[] form_data, NVPair[] headers) throws
IOException, ModuleException
{
- String File = stripRef(file), query = Codecs.nv2query(form_data);
+ String query = Codecs.nv2query(form_data);
+ StringBuffer resource = new StringBuffer(stripRef(file));
+
if (query != null && query.length() > 0)
- File += "?" + query;
+ {
+ resource.append("?");
+ resource.append(query);
+ }
- return setupRequest("GET", File, headers, null, null);
+ return setupRequest("GET", resource.toString(), headers, null, null);
}
/**
@@ -913,11 +927,15 @@
@Deprecated
public HTTPResponse Get(String file, String query, NVPair[] headers) throws
IOException, ModuleException
{
- String File = stripRef(file);
+ StringBuffer resource = new StringBuffer(stripRef(file));
+
if (query != null && query.length() > 0)
- File += "?" + Codecs.URLEncode(query);
+ {
+ resource.append("?");
+ resource.append(Codecs.URLEncode(query));
+ }
- return setupRequest("GET", File, headers, null, null);
+ return setupRequest("GET", resource.toString(), headers, null, null);
}
/**
@@ -2166,8 +2184,10 @@
}
if (log.isDebugEnabled())
- log.debug("Added module " + module.getName() + " to " +
((list == DefaultModuleList) ? "default " : "")
+ {
+ log.debug("Added module " + module.getName() + " to " +
((list == DefaultModuleList) ? "default " : "") //NOSONAR
+ "list");
+ }
return true;
}
@@ -2181,9 +2201,10 @@
if (removed)
{
if (log.isDebugEnabled())
- log.debug("Removed module " + module.getName() + " from "
+ ((list == DefaultModuleList) ? "default " : "")
+ {
+ log.debug("Removed module " + module.getName() + " from "
+ ((list == DefaultModuleList) ? "default " : "") //NOSONAR
+ "list");
-
+ }
}
return removed;
@@ -3617,7 +3638,9 @@
try
{
if (!Util.hasToken(co_hdr, "TE"))
- co_hdr += ", TE";
+ {
+ co_hdr += ", TE"; //NOSONAR
+ }
}
catch (ParseException pe)
{
@@ -3625,10 +3648,14 @@
}
}
else
+ {
co_hdr = "TE";
+ }
if (ug_idx != -1)
- co_hdr += ", Upgrade";
+ {
+ co_hdr += ", Upgrade"; //NOSONAR
+ }
if (co_hdr != null)
{