You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ofbiz.apache.org by jl...@apache.org on 2018/01/01 12:23:18 UTC
svn commit: r1819764 -
/ofbiz/ofbiz-framework/trunk/applications/content/src/main/java/org/apache/ofbiz/content/compdoc/CompDocEvents.java
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());