Author: andrew.plotnikov
Date: 2012-02-10 04:10:28 -0500 (Fri, 10 Feb 2012)
New Revision: 5599
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/HTTPConnection.java
ws/trunk/exo.ws.commons/src/main/java/org/exoplatform/common/http/client/HTTPResponse.java
ws/trunk/exo.ws.commons/src/main/java/org/exoplatform/common/http/client/HttpURLConnection.java
ws/trunk/exo.ws.commons/src/main/java/org/exoplatform/common/http/client/RedirectionModule.java
ws/trunk/exo.ws.commons/src/main/java/org/exoplatform/common/http/client/Response.java
ws/trunk/exo.ws.commons/src/main/java/org/exoplatform/common/http/client/StreamDemultiplexor.java
ws/trunk/exo.ws.frameworks.json/src/main/java/org/exoplatform/ws/frameworks/json/impl/ObjectBuilder.java
ws/trunk/exo.ws.frameworks.servlet/src/main/java/org/exoplatform/ws/frameworks/servlet/StandaloneContainerInitializedListener.java
ws/trunk/exo.ws.rest.core/src/main/java/org/exoplatform/services/rest/impl/RequestHandlerImpl.java
ws/trunk/exo.ws.rest.core/src/main/java/org/exoplatform/services/rest/impl/method/DefaultMethodInvoker.java
ws/trunk/exo.ws.rest.core/src/main/java/org/exoplatform/services/rest/impl/method/ParameterHelper.java
ws/trunk/exo.ws.rest.core/src/main/java/org/exoplatform/services/rest/impl/provider/IOHelper.java
ws/trunk/exo.ws.rest.core/src/main/java/org/exoplatform/services/rest/impl/provider/JsonEntityProvider.java
ws/trunk/exo.ws.rest.ext/src/main/java/org/exoplatform/services/rest/ext/management/RestResource.java
Log:
EXOJCR-1725: Fixed the Blocker/Critical violations and the easiest Major ones raised by
eXo Quality Level 1.2
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 2012-02-10
08:29:10 UTC (rev 5598)
+++
ws/trunk/exo.ws.commons/src/main/java/org/exoplatform/common/http/client/DefaultAuthHandler.java 2012-02-10
09:10:28 UTC (rev 5599)
@@ -1651,7 +1651,7 @@
{
Runtime.getRuntime().exec(cmd).waitFor();
}
- catch (Exception e)
+ catch (Throwable e)
{
if (LOG.isTraceEnabled())
{
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 2012-02-10
08:29:10 UTC (rev 5598)
+++
ws/trunk/exo.ws.commons/src/main/java/org/exoplatform/common/http/client/HTTPConnection.java 2012-02-10
09:10:28 UTC (rev 5599)
@@ -3279,26 +3279,60 @@
}
if (req.getStream() != null)
+ {
req.getStream().goAhead(req, sock_out, 0);
+ }
else
+ {
sock_out.flush();
+ }
// get a new response.
// Note: this does not do a read on the socket.
if (resp == null)
+ {
resp = new Response(req, (Proxy_Host != null && Protocol !=
HTTPS), input_demux);
+ }
}
- catch (IOException ioe)
+ catch (UnknownHostException e)
{
+ LOG.error("Send request error", e);
- LOG.error("Send request error", ioe);
+ closeDemux(e, true);
- closeDemux(ioe, true);
+ throw e;
+ }
+ catch (ConnectException e)
+ {
+ LOG.error("Send request error", e);
- if (try_count == 0 || ioe instanceof UnknownHostException || ioe
instanceof ConnectException
- || ioe instanceof NoRouteToHostException || ioe instanceof
InterruptedIOException || req.aborted)
+ closeDemux(e, true);
+
+ throw e;
+ }
+ catch (NoRouteToHostException e)
+ {
+ LOG.error("Send request error", e);
+
+ closeDemux(e, true);
+
+ throw e;
+ }
+ catch (InterruptedIOException e)
+ {
+ LOG.error("Send request error", e);
+
+ closeDemux(e, true);
+
+ throw e;
+ }
+ catch (IOException ioe)
+ {
+ if (try_count == 0 || req.aborted)
+ {
throw ioe;
+ }
LOG.info("Retrying request");
continue;
Modified:
ws/trunk/exo.ws.commons/src/main/java/org/exoplatform/common/http/client/HTTPResponse.java
===================================================================
---
ws/trunk/exo.ws.commons/src/main/java/org/exoplatform/common/http/client/HTTPResponse.java 2012-02-10
08:29:10 UTC (rev 5598)
+++
ws/trunk/exo.ws.commons/src/main/java/org/exoplatform/common/http/client/HTTPResponse.java 2012-02-10
09:10:28 UTC (rev 5599)
@@ -514,7 +514,7 @@
{
inp_stream.close();
}
- catch (Exception e)
+ catch (IOException e)
{
if (LOG.isTraceEnabled())
{
@@ -648,15 +648,18 @@
{
handleResponse();
}
- catch (Exception e)
+ catch (ModuleException e)
{
- if (!(e instanceof InterruptedIOException))
- {
- LOG.error(method + " " + OriginalURI.getPathAndQuery());
- }
+ LOG.error(method + " " + OriginalURI.getPathAndQuery());
return "Failed to read headers: " + e;
}
+ catch (IOException e)
+ {
+ LOG.error(method + " " + OriginalURI.getPathAndQuery());
+
+ return "Failed to read headers: " + e;
+ }
}
String nl = PrivilegedSystemHelper.getProperty("line.separator",
"\n");
Modified:
ws/trunk/exo.ws.commons/src/main/java/org/exoplatform/common/http/client/HttpURLConnection.java
===================================================================
---
ws/trunk/exo.ws.commons/src/main/java/org/exoplatform/common/http/client/HttpURLConnection.java 2012-02-10
08:29:10 UTC (rev 5598)
+++
ws/trunk/exo.ws.commons/src/main/java/org/exoplatform/common/http/client/HttpURLConnection.java 2012-02-10
09:10:28 UTC (rev 5599)
@@ -40,11 +40,13 @@
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
+import java.net.MalformedURLException;
import java.net.ProtocolException;
import java.net.URL;
import java.util.Date;
import java.util.Enumeration;
import java.util.Hashtable;
+import java.util.NoSuchElementException;
/**
* This class is a wrapper around HTTPConnection providing the interface defined
@@ -377,13 +379,19 @@
try
{
if (!connected)
+ {
connect();
+ }
return resp.getHeader(name);
}
- catch (Exception e)
+ catch (IOException e)
{
return null;
}
+ catch (ModuleException e)
+ {
+ return null;
+ }
}
/**
@@ -400,13 +408,23 @@
try
{
if (!connected)
+ {
connect();
+ }
return resp.getHeaderAsInt(name);
}
- catch (Exception e)
+ catch (NumberFormatException e)
{
return def;
}
+ catch (IOException e)
+ {
+ return def;
+ }
+ catch (ModuleException e)
+ {
+ return def;
+ }
}
/**
@@ -424,13 +442,23 @@
try
{
if (!connected)
+ {
connect();
+ }
return resp.getHeaderAsDate(name).getTime();
}
- catch (Exception e)
+ catch (IllegalArgumentException e)
{
return def;
}
+ catch (IOException e)
+ {
+ return def;
+ }
+ catch (ModuleException e)
+ {
+ return def;
+ }
}
private String[] hdr_keys, hdr_values;
@@ -480,7 +508,9 @@
try
{
if (!connected)
+ {
connect();
+ }
// count number of headers
int num = 1;
@@ -506,10 +536,18 @@
// the 0'th field is special
hdr_values[0] = resp.getVersion() + " " + resp.getStatusCode() +
" " + resp.getReasonLine();
}
- catch (Exception e)
+ catch (NoSuchElementException e)
{
hdr_keys = hdr_values = new String[0];
}
+ catch (IOException e)
+ {
+ hdr_keys = hdr_values = new String[0];
+ }
+ catch (ModuleException e)
+ {
+ hdr_keys = hdr_values = new String[0];
+ }
}
/**
@@ -557,14 +595,24 @@
try
{
if (!doInput || !connected || resp.getStatusCode() < 300 ||
resp.getHeaderAsInt("Content-length") <= 0)
+ {
return null;
+ }
return resp.getInputStream();
}
- catch (Exception e)
+ catch (IOException e)
{
return null;
}
+ catch (NumberFormatException e)
+ {
+ return null;
+ }
+ catch (ModuleException e)
+ {
+ return null;
+ }
}
/**
@@ -643,10 +691,18 @@
{
return resp.getEffectiveURI().toURL();
}
- catch (Exception e)
+ catch (MalformedURLException e)
{
return null;
}
+ catch (IOException e)
+ {
+ return null;
+ }
+ catch (ModuleException e)
+ {
+ return null;
+ }
}
return url;
Modified:
ws/trunk/exo.ws.commons/src/main/java/org/exoplatform/common/http/client/RedirectionModule.java
===================================================================
---
ws/trunk/exo.ws.commons/src/main/java/org/exoplatform/common/http/client/RedirectionModule.java 2012-02-10
08:29:10 UTC (rev 5598)
+++
ws/trunk/exo.ws.commons/src/main/java/org/exoplatform/common/http/client/RedirectionModule.java 2012-02-10
09:10:28 UTC (rev 5599)
@@ -155,7 +155,7 @@
{
con = new HTTPConnection(new_loc);
}
- catch (Exception e)
+ catch (ProtocolNotSuppException e)
{
throw new Error("HTTPClient Internal Error: unexpected " +
"exception '" + e + "'");
}
@@ -324,7 +324,7 @@
mvd = new HTTPConnection(loc);
nres = loc.getPathAndQuery();
}
- catch (Exception e)
+ catch (ProtocolNotSuppException e)
{
if (req.getConnection().getProxyHost() == null ||
!loc.getScheme().equalsIgnoreCase("ftp"))
return RSP_CONTINUE;
Modified:
ws/trunk/exo.ws.commons/src/main/java/org/exoplatform/common/http/client/Response.java
===================================================================
---
ws/trunk/exo.ws.commons/src/main/java/org/exoplatform/common/http/client/Response.java 2012-02-10
08:29:10 UTC (rev 5598)
+++
ws/trunk/exo.ws.commons/src/main/java/org/exoplatform/common/http/client/Response.java 2012-02-10
09:10:28 UTC (rev 5599)
@@ -583,7 +583,7 @@
{
inp_stream.close();
}
- catch (Exception e)
+ catch (IOException e)
{
if (LOG.isTraceEnabled())
{
@@ -689,18 +689,25 @@
while ((StatusCode == 100 && skip_cont) || // Continue
(StatusCode > 101 && StatusCode < 200)); // Unknown
}
- catch (IOException ioe)
+ catch (InterruptedIOException ioe)
{
- if (!(ioe instanceof InterruptedIOException))
- exception = ioe;
- if (ioe instanceof ProtocolException) // thrown internally
+ throw ioe;
+ }
+ catch (ProtocolException ioe)// thrown internally
+ {
+ exception = ioe;
+ cd_type = CD_CLOSE;
+ if (stream_handler != null)
{
- cd_type = CD_CLOSE;
- if (stream_handler != null)
- stream_handler.markForClose(this);
+ stream_handler.markForClose(this);
}
throw ioe;
}
+ catch (IOException ioe)
+ {
+ exception = ioe;
+ throw ioe;
+ }
finally
{
reading_headers = false;
@@ -1042,10 +1049,13 @@
readLines(inp);
trailers_read = true;
}
+ catch (InterruptedIOException ioe)
+ {
+ throw ioe;
+ }
catch (IOException ioe)
{
- if (!(ioe instanceof InterruptedIOException))
- exception = ioe;
+ exception = ioe;
throw ioe;
}
}
Modified:
ws/trunk/exo.ws.commons/src/main/java/org/exoplatform/common/http/client/StreamDemultiplexor.java
===================================================================
---
ws/trunk/exo.ws.commons/src/main/java/org/exoplatform/common/http/client/StreamDemultiplexor.java 2012-02-10
08:29:10 UTC (rev 5598)
+++
ws/trunk/exo.ws.commons/src/main/java/org/exoplatform/common/http/client/StreamDemultiplexor.java 2012-02-10
09:10:28 UTC (rev 5599)
@@ -219,15 +219,14 @@
{
head.stream.readAll(timeout);
}
+ catch (InterruptedIOException ioe)
+ {
+ throw ioe;
+ }
catch (IOException ioe)
{
- if (ioe instanceof InterruptedIOException)
- throw ioe;
- else
- {
- resph.exception.fillInStackTrace();
- throw resph.exception;
- }
+ resph.exception.fillInStackTrace();
+ throw resph.exception;
}
}
Modified:
ws/trunk/exo.ws.frameworks.json/src/main/java/org/exoplatform/ws/frameworks/json/impl/ObjectBuilder.java
===================================================================
---
ws/trunk/exo.ws.frameworks.json/src/main/java/org/exoplatform/ws/frameworks/json/impl/ObjectBuilder.java 2012-02-10
08:29:10 UTC (rev 5598)
+++
ws/trunk/exo.ws.frameworks.json/src/main/java/org/exoplatform/ws/frameworks/json/impl/ObjectBuilder.java 2012-02-10
09:10:28 UTC (rev 5599)
@@ -25,6 +25,7 @@
import java.lang.reflect.Array;
import java.lang.reflect.Constructor;
+import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
import java.lang.reflect.ParameterizedType;
@@ -192,10 +193,14 @@
{
constructor = collectionClass.getConstructor(new
Class[]{Collection.class});
}
- catch (Exception e)
+ catch (SecurityException e)
{
throw new JsonException(e.getMessage(), e);
}
+ catch (NoSuchMethodException e)
+ {
+ throw new JsonException(e.getMessage(), e);
+ }
}
if (constructor == null)
@@ -221,10 +226,26 @@
{
collection = constructor.newInstance(sourceCollection);
}
- catch (Exception e)
+ catch (IllegalAccessException e)
{
throw new JsonException(e.getMessage(), e);
}
+ catch (IllegalArgumentException e)
+ {
+ throw new JsonException(e.getMessage(), e);
+ }
+ catch (InstantiationException e)
+ {
+ throw new JsonException(e.getMessage(), e);
+ }
+ catch (InvocationTargetException e)
+ {
+ throw new JsonException(e.getMessage(), e);
+ }
+ catch (ExceptionInInitializerError e)
+ {
+ throw new JsonException(e.getMessage(), e);
+ }
}
return collection;
}
@@ -304,10 +325,14 @@
{
constructor = mapClass.getConstructor(new Class[]{Map.class});
}
- catch (Exception e)
+ catch (SecurityException e)
{
throw new JsonException(e.getMessage(), e);
}
+ catch (NoSuchMethodException e)
+ {
+ throw new JsonException(e.getMessage(), e);
+ }
}
if (constructor == null)
@@ -334,10 +359,26 @@
{
map = constructor.newInstance(sourceMap);
}
- catch (Exception e)
+ catch (ExceptionInInitializerError e)
{
throw new JsonException(e.getMessage(), e);
}
+ catch (IllegalAccessException e)
+ {
+ throw new JsonException(e.getMessage(), e);
+ }
+ catch (IllegalArgumentException e)
+ {
+ throw new JsonException(e.getMessage(), e);
+ }
+ catch (InstantiationException e)
+ {
+ throw new JsonException(e.getMessage(), e);
+ }
+ catch (InvocationTargetException e)
+ {
+ throw new JsonException(e.getMessage(), e);
+ }
}
return map;
}
@@ -377,10 +418,22 @@
{
object = clazz.newInstance();
}
- catch (Exception e)
+ catch (ExceptionInInitializerError e)
{
throw new JsonException("Unable instantiate object. " +
e.getMessage(), e);
}
+ catch (SecurityException e)
+ {
+ throw new JsonException("Unable instantiate object. " +
e.getMessage(), e);
+ }
+ catch (IllegalAccessException e)
+ {
+ throw new JsonException("Unable instantiate object. " +
e.getMessage(), e);
+ }
+ catch (InstantiationException e)
+ {
+ throw new JsonException("Unable instantiate object. " +
e.getMessage(), e);
+ }
Method[] methods = clazz.getMethods();
Modified:
ws/trunk/exo.ws.frameworks.servlet/src/main/java/org/exoplatform/ws/frameworks/servlet/StandaloneContainerInitializedListener.java
===================================================================
---
ws/trunk/exo.ws.frameworks.servlet/src/main/java/org/exoplatform/ws/frameworks/servlet/StandaloneContainerInitializedListener.java 2012-02-10
08:29:10 UTC (rev 5598)
+++
ws/trunk/exo.ws.frameworks.servlet/src/main/java/org/exoplatform/ws/frameworks/servlet/StandaloneContainerInitializedListener.java 2012-02-10
09:10:28 UTC (rev 5599)
@@ -73,7 +73,7 @@
event.getServletContext().getResource(configurationURL.substring(PREFIX_WAR.length())).toExternalForm();
}
}
- catch (Exception e)
+ catch (MalformedURLException e)
{
LOG.error("Error of configurationURL read", e);
}
Modified:
ws/trunk/exo.ws.rest.core/src/main/java/org/exoplatform/services/rest/impl/RequestHandlerImpl.java
===================================================================
---
ws/trunk/exo.ws.rest.core/src/main/java/org/exoplatform/services/rest/impl/RequestHandlerImpl.java 2012-02-10
08:29:10 UTC (rev 5598)
+++
ws/trunk/exo.ws.rest.core/src/main/java/org/exoplatform/services/rest/impl/RequestHandlerImpl.java 2012-02-10
09:10:28 UTC (rev 5599)
@@ -52,8 +52,8 @@
import javax.ws.rs.WebApplicationException;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
-import javax.ws.rs.core.StreamingOutput;
import javax.ws.rs.core.Response.ResponseBuilder;
+import javax.ws.rs.core.StreamingOutput;
import javax.ws.rs.ext.ExceptionMapper;
/**
@@ -155,87 +155,80 @@
}
}
}
- catch (Exception e)
+ catch (WebApplicationException e)
{
- if (e instanceof WebApplicationException)
+ Response errorResponse = ((WebApplicationException)e).getResponse();
+ ExceptionMapper excmap =
context.getProviders().getExceptionMapper(WebApplicationException.class);
+ int errorStatus = errorResponse.getStatus();
+ // should be some of 4xx status
+ if (errorStatus < 500)
{
- Response errorResponse = ((WebApplicationException)e).getResponse();
- ExceptionMapper excmap =
context.getProviders().getExceptionMapper(WebApplicationException.class);
- int errorStatus = errorResponse.getStatus();
- // should be some of 4xx status
- if (errorStatus < 500)
+ // Warn about error in debug mode only.
+ if (LOG.isDebugEnabled() && e.getCause() != null)
{
- // Warn about error in debug mode only.
- if (LOG.isDebugEnabled() && e.getCause() != null)
- {
- LOG.warn("WebApplication exception occurs.",
e.getCause());
- }
+ LOG.warn("WebApplication exception occurs.", e.getCause());
}
- else
+ }
+ else
+ {
+ if (e.getCause() != null)
{
- if (e.getCause() != null)
- {
- LOG.warn("WebApplication exception occurs.",
e.getCause());
- }
+ LOG.warn("WebApplication exception occurs.", e.getCause());
}
- if (errorResponse.getEntity() == null)
+ }
+ if (errorResponse.getEntity() == null)
+ {
+ if (excmap != null)
{
- if (excmap != null)
- {
- errorResponse = excmap.toResponse(e);
- }
- else
- {
- if (e.getMessage() != null)
- {
- errorResponse = createErrorResponse(errorStatus,
e.getMessage());
- }
- }
+ errorResponse = excmap.toResponse(e);
}
else
{
- if
(errorResponse.getMetadata().getFirst(ExtHttpHeaders.JAXRS_BODY_PROVIDED) == null)
+ if (e.getMessage() != null)
{
- String jaxrsHeader = getJaxrsHeader(errorStatus);
- if (jaxrsHeader != null)
- {
-
errorResponse.getMetadata().putSingle(ExtHttpHeaders.JAXRS_BODY_PROVIDED, jaxrsHeader);
- }
+ errorResponse = createErrorResponse(errorStatus, e.getMessage());
}
}
- response.setResponse(errorResponse);
}
- else if (e instanceof InternalException)
+ else
{
- Throwable cause = e.getCause();
- Class causeClazz = cause.getClass();
- ExceptionMapper excmap =
context.getProviders().getExceptionMapper(causeClazz);
- while (causeClazz != null && excmap == null)
+ if
(errorResponse.getMetadata().getFirst(ExtHttpHeaders.JAXRS_BODY_PROVIDED) == null)
{
- excmap = context.getProviders().getExceptionMapper(causeClazz);
- if (excmap == null)
+ String jaxrsHeader = getJaxrsHeader(errorStatus);
+ if (jaxrsHeader != null)
{
- causeClazz = causeClazz.getSuperclass();
+
errorResponse.getMetadata().putSingle(ExtHttpHeaders.JAXRS_BODY_PROVIDED, jaxrsHeader);
}
}
- if (excmap != null)
+ }
+ response.setResponse(errorResponse);
+ }
+ catch (InternalException e)
+ {
+ Throwable cause = e.getCause();
+ Class causeClazz = cause.getClass();
+ ExceptionMapper excmap =
context.getProviders().getExceptionMapper(causeClazz);
+ while (causeClazz != null && excmap == null)
+ {
+ excmap = context.getProviders().getExceptionMapper(causeClazz);
+ if (excmap == null)
{
- if (LOG.isDebugEnabled())
- {
- // Hide error message if exception mapper exists.
- LOG.warn("Internal error occurs.", cause);
- }
- response.setResponse(excmap.toResponse(e.getCause()));
+ causeClazz = causeClazz.getSuperclass();
}
- else
+ }
+ if (excmap != null)
+ {
+ if (LOG.isDebugEnabled())
{
- LOG.error("Internal error occurs.", cause);
- throw new UnhandledException(e.getCause());
+ // Hide error message if exception mapper exists.
+ LOG.warn("Internal error occurs.", cause);
}
+ response.setResponse(excmap.toResponse(e.getCause()));
}
else
{
- throw new UnhandledException(e);
+ LOG.error("Internal error occurs.", cause);
+ throw new UnhandledException(e.getCause());
}
}
Modified:
ws/trunk/exo.ws.rest.core/src/main/java/org/exoplatform/services/rest/impl/method/DefaultMethodInvoker.java
===================================================================
---
ws/trunk/exo.ws.rest.core/src/main/java/org/exoplatform/services/rest/impl/method/DefaultMethodInvoker.java 2012-02-10
08:29:10 UTC (rev 5598)
+++
ws/trunk/exo.ws.rest.core/src/main/java/org/exoplatform/services/rest/impl/method/DefaultMethodInvoker.java 2012-02-10
09:10:28 UTC (rev 5599)
@@ -157,16 +157,22 @@
entityReader.readFrom(mp.getParameterClass(),
mp.getGenericType(), mp.getAnnotations(),
contentType, headers, entityStream);
}
- catch (Exception e)
+ catch (WebApplicationException e)
{
if (LOG.isDebugEnabled())
{
LOG.debug(e.getLocalizedMessage(), e);
}
- if (e instanceof WebApplicationException)
+
+ throw e;
+ }
+ catch (Exception e)
+ {
+ if (LOG.isDebugEnabled())
{
- throw (WebApplicationException)e;
+ LOG.debug(e.getLocalizedMessage(), e);
}
+
throw new InternalException(e);
}
}
Modified:
ws/trunk/exo.ws.rest.core/src/main/java/org/exoplatform/services/rest/impl/method/ParameterHelper.java
===================================================================
---
ws/trunk/exo.ws.rest.core/src/main/java/org/exoplatform/services/rest/impl/method/ParameterHelper.java 2012-02-10
08:29:10 UTC (rev 5598)
+++
ws/trunk/exo.ws.rest.core/src/main/java/org/exoplatform/services/rest/impl/method/ParameterHelper.java 2012-02-10
09:10:28 UTC (rev 5599)
@@ -28,6 +28,7 @@
import java.lang.reflect.Modifier;
import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;
+import java.security.PrivilegedActionException;
import java.security.PrivilegedExceptionAction;
import java.util.ArrayList;
import java.util.Arrays;
@@ -273,7 +274,7 @@
return Modifier.isStatic(method.getModifiers()) ? method : null;
}
- catch (Exception e)
+ catch (PrivilegedActionException e)
{
return null;
}
@@ -293,10 +294,14 @@
{
return clazz.getConstructor(String.class);
}
- catch (Exception e)
+ catch (SecurityException e)
{
return null;
}
+ catch (NoSuchMethodException e)
+ {
+ return null;
+ }
}
Modified:
ws/trunk/exo.ws.rest.core/src/main/java/org/exoplatform/services/rest/impl/provider/IOHelper.java
===================================================================
---
ws/trunk/exo.ws.rest.core/src/main/java/org/exoplatform/services/rest/impl/provider/IOHelper.java 2012-02-10
08:29:10 UTC (rev 5598)
+++
ws/trunk/exo.ws.rest.core/src/main/java/org/exoplatform/services/rest/impl/provider/IOHelper.java 2012-02-10
09:10:28 UTC (rev 5599)
@@ -26,6 +26,8 @@
import java.io.Reader;
import java.io.Writer;
import java.nio.charset.Charset;
+import java.nio.charset.IllegalCharsetNameException;
+import java.nio.charset.UnsupportedCharsetException;
/**
* @author <a href="mailto:andrew00x@gmail.com">Andrey
Parfonov</a>
@@ -131,10 +133,18 @@
{
charset = cs != null ? Charset.forName(cs) : DEFAULT_CHARSET;
}
- catch (Exception e)
+ catch (IllegalCharsetNameException e)
{
charset = DEFAULT_CHARSET;
}
+ catch (UnsupportedCharsetException e)
+ {
+ charset = DEFAULT_CHARSET;
+ }
+ catch (IllegalArgumentException e)
+ {
+ charset = DEFAULT_CHARSET;
+ }
Writer w = new OutputStreamWriter(out, charset);
try
{
Modified:
ws/trunk/exo.ws.rest.core/src/main/java/org/exoplatform/services/rest/impl/provider/JsonEntityProvider.java
===================================================================
---
ws/trunk/exo.ws.rest.core/src/main/java/org/exoplatform/services/rest/impl/provider/JsonEntityProvider.java 2012-02-10
08:29:10 UTC (rev 5598)
+++
ws/trunk/exo.ws.rest.core/src/main/java/org/exoplatform/services/rest/impl/provider/JsonEntityProvider.java 2012-02-10
09:10:28 UTC (rev 5599)
@@ -137,7 +137,7 @@
return ObjectBuilder.createObject(type, jsonValue);
}
- catch (Exception e)
+ catch (JsonException e)
{
throw new IOException("Can't read from input stream " + e);
}
Modified:
ws/trunk/exo.ws.rest.ext/src/main/java/org/exoplatform/services/rest/ext/management/RestResource.java
===================================================================
---
ws/trunk/exo.ws.rest.ext/src/main/java/org/exoplatform/services/rest/ext/management/RestResource.java 2012-02-10
08:29:10 UTC (rev 5598)
+++
ws/trunk/exo.ws.rest.ext/src/main/java/org/exoplatform/services/rest/ext/management/RestResource.java 2012-02-10
09:10:28 UTC (rev 5599)
@@ -30,6 +30,8 @@
import org.exoplatform.services.rest.impl.ApplicationContextImpl;
import org.exoplatform.services.rest.impl.MultivaluedMapImpl;
+import java.io.IOException;
+import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Type;
import java.util.ArrayList;
import java.util.Collection;
@@ -45,6 +47,7 @@
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
+import javax.ws.rs.WebApplicationException;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.MultivaluedMap;
@@ -240,11 +243,16 @@
Object ret = invoker.invoke(resource, argMap);
return ret == null ? Response.ok() : ValueWrapper.wrap(ret);
}
- catch (Exception e)
+ catch (IllegalAccessException e)
{
LOG.error("An exception occured: " + e.getMessage());
return Response.serverError();
}
+ catch (InvocationTargetException e)
+ {
+ LOG.error("An exception occured: " + e.getMessage());
+ return Response.serverError();
+ }
finally
{
managedResource.afterInvoke(resource);
@@ -276,13 +284,27 @@
context.getHttpHeaders().getRequestHeaders(),
context.getContainerRequest().getEntityStream());
}
}
- catch (Exception e)
+ catch (IllegalStateException e)
{
if (LOG.isTraceEnabled())
{
LOG.trace("An exception occurred: " + e.getMessage());
}
}
+ catch (WebApplicationException e)
+ {
+ if (LOG.isTraceEnabled())
+ {
+ LOG.trace("An exception occurred: " + e.getMessage());
+ }
+ }
+ catch (IOException e)
+ {
+ if (LOG.isTraceEnabled())
+ {
+ LOG.trace("An exception occurred: " + e.getMessage());
+ }
+ }
parameters.putAll(form);
return parameters;