tika-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From max...@apache.org
Subject svn commit: r1304229 - /tika/trunk/tika-server/src/main/java/org/apache/tika/server/TikaResource.java
Date Fri, 23 Mar 2012 08:39:25 GMT
Author: maxcom
Date: Fri Mar 23 08:39:24 2012
New Revision: 1304229

URL: http://svn.apache.org/viewvc?rev=1304229&view=rev
Log:
TikaResource: improve exception logging/processing

Modified:
    tika/trunk/tika-server/src/main/java/org/apache/tika/server/TikaResource.java

Modified: tika/trunk/tika-server/src/main/java/org/apache/tika/server/TikaResource.java
URL: http://svn.apache.org/viewvc/tika/trunk/tika-server/src/main/java/org/apache/tika/server/TikaResource.java?rev=1304229&r1=1304228&r2=1304229&view=diff
==============================================================================
--- tika/trunk/tika-server/src/main/java/org/apache/tika/server/TikaResource.java (original)
+++ tika/trunk/tika-server/src/main/java/org/apache/tika/server/TikaResource.java Fri Mar
23 08:39:24 2012
@@ -19,10 +19,10 @@ package org.apache.tika.server;
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
-import org.apache.poi.EncryptedDocumentException;
 import org.apache.poi.extractor.ExtractorFactory;
 import org.apache.poi.hwpf.OldWordFileFormatException;
 import org.apache.tika.detect.Detector;
+import org.apache.tika.exception.EncryptedDocumentException;
 import org.apache.tika.exception.TikaException;
 import org.apache.tika.io.TikaInputStream;
 import org.apache.tika.metadata.Metadata;
@@ -157,7 +157,19 @@ public class TikaResource {
           parser.parse(tis, body, metadata);
         } catch (SAXException e) {
           throw new WebApplicationException(e);
+        } catch (EncryptedDocumentException e) {
+          logger.warn(String.format(
+                  "%s: Encrypted document",
+                  info.getPath()
+          ), e);
+
+          throw new WebApplicationException(e, Response.status(422).build());
         } catch (TikaException e) {
+          logger.warn(String.format(
+            "%s: Text extraction failed",
+            info.getPath()
+          ), e);
+
           if (e.getCause()!=null && e.getCause() instanceof WebApplicationException)
{
             throw (WebApplicationException) e.getCause();
           }
@@ -166,19 +178,10 @@ public class TikaResource {
             throw new WebApplicationException(Response.status(422).build());
           }
 
-          if (e.getCause()!=null && e.getCause() instanceof EncryptedDocumentException)
{
-            throw new WebApplicationException(Response.status(422).build());
-          }
-
           if (e.getCause()!=null && e.getCause() instanceof OldWordFileFormatException)
{
             throw new WebApplicationException(Response.status(422).build());
           }
 
-          logger.warn(String.format(
-                  "%s: Text extraction failed",
-                  info.getPath()
-          ), e);
-
           throw new WebApplicationException(Response.Status.INTERNAL_SERVER_ERROR);
         } finally {
           tis.close();



Mime
View raw message