svn commit: r1819764 - /ofbiz/ofbiz-framework/trunk/applications/content/src/main/java/org/apache/ofbiz/content/compdoc/CompDocEvents.java

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

svn commit: r1819764 - /ofbiz/ofbiz-framework/trunk/applications/content/src/main/java/org/apache/ofbiz/content/compdoc/CompDocEvents.java

jleroux@apache.org
Author: jleroux
Date: Mon Jan  1 12:23:18 2018
New Revision: 1819764

URL: http://svn.apache.org/viewvc?rev=1819764&view=rev
Log:
No functional refactoring changes while reviewing r1819730

Removes useless exceptions handling.
Uses try-w/-ress for ByteArrayInputStream

Modified:
    ofbiz/ofbiz-framework/trunk/applications/content/src/main/java/org/apache/ofbiz/content/compdoc/CompDocEvents.java

Modified: ofbiz/ofbiz-framework/trunk/applications/content/src/main/java/org/apache/ofbiz/content/compdoc/CompDocEvents.java
URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/applications/content/src/main/java/org/apache/ofbiz/content/compdoc/CompDocEvents.java?rev=1819764&r1=1819763&r2=1819764&view=diff
==============================================================================
--- ofbiz/ofbiz-framework/trunk/applications/content/src/main/java/org/apache/ofbiz/content/compdoc/CompDocEvents.java (original)
+++ ofbiz/ofbiz-framework/trunk/applications/content/src/main/java/org/apache/ofbiz/content/compdoc/CompDocEvents.java Mon Jan  1 12:23:18 2018
@@ -43,7 +43,6 @@ import org.apache.ofbiz.entity.util.Enti
 import org.apache.ofbiz.service.GenericServiceException;
 import org.apache.ofbiz.service.LocalDispatcher;
 import org.apache.ofbiz.service.ModelService;
-import org.apache.ofbiz.service.ServiceAuthException;
 import org.apache.ofbiz.service.ServiceUtil;
 import org.apache.ofbiz.webapp.event.CoreEvents;
 import org.apache.ofbiz.webapp.website.WebSiteWorker;
@@ -176,15 +175,9 @@ public class CompDocEvents {
                 Debug.logError(errorMessage, module);
                 return "error";
             }
-        } catch (ServiceAuthException e) {
-            request.setAttribute("_ERROR_MESSAGE_", e.toString());
-            return "error";
         } catch (GenericServiceException e) {
             request.setAttribute("_ERROR_MESSAGE_", e.toString());
             return "error";
-        } catch (Exception e) {
-            request.setAttribute("_ERROR_MESSAGE_", e.toString());
-            return "error";
         }
 
         ByteBuffer outByteBuffer = (ByteBuffer) results.get("outByteBuffer");
@@ -192,9 +185,7 @@ public class CompDocEvents {
         // setup content type
         String contentType = "application/pdf; charset=ISO-8859-1";
 
-        ByteArrayInputStream bais = new ByteArrayInputStream(outByteBuffer.array());
-
-        try {
+        try (ByteArrayInputStream bais = new ByteArrayInputStream(outByteBuffer.array())) {
             UtilHttp.streamContentToBrowser(response, bais, outByteBuffer.limit(), contentType);
         } catch (IOException e) {
             request.setAttribute("_ERROR_MESSAGE_", e.toString());
@@ -233,15 +224,9 @@ public class CompDocEvents {
                 Debug.logError(errorMessage, module);
                 return "error";
             }
-        } catch (ServiceAuthException e) {
-            request.setAttribute("_ERROR_MESSAGE_", e.toString());
-            return "error";
         } catch (GenericServiceException e) {
             request.setAttribute("_ERROR_MESSAGE_", e.toString());
             return "error";
-        } catch (Exception e) {
-            request.setAttribute("_ERROR_MESSAGE_", e.toString());
-            return "error";
         }
 
         ByteBuffer outByteBuffer = (ByteBuffer) results.get("outByteBuffer");
@@ -249,9 +234,7 @@ public class CompDocEvents {
         // setup content type
         String contentType = "application/pdf; charset=ISO-8859-1";
 
-        ByteArrayInputStream bais = new ByteArrayInputStream(outByteBuffer.array());
-
-        try {
+        try (ByteArrayInputStream bais = new ByteArrayInputStream(outByteBuffer.array())) {
             UtilHttp.streamContentToBrowser(response, bais, outByteBuffer.limit(), contentType);
         } catch (IOException e) {
             request.setAttribute("_ERROR_MESSAGE_", e.toString());