From do-not-reply at jboss.org Tue Feb 16 10:59:43 2010
Content-Type: multipart/mixed; boundary="===============6973055739330532694=="
MIME-Version: 1.0
From: do-not-reply at jboss.org
To: exo-jcr-commits at lists.jboss.org
Subject: [exo-jcr-commits] exo-jcr SVN: r1839 - in
core/trunk/exo.core.component.document/src/main/java/org/exoplatform/services/document:
impl and 1 other directory.
Date: Tue, 16 Feb 2010 10:59:43 -0500
Message-ID: <201002161559.o1GFxhGo012273@svn01.web.mwc.hst.phx2.redhat.com>
--===============6973055739330532694==
Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: quoted-printable
Author: areshetnyak
Date: 2010-02-16 10:59:42 -0500 (Tue, 16 Feb 2010)
New Revision: 1839
Added:
core/trunk/exo.core.component.document/src/main/java/org/exoplatform/ser=
vices/document/PDFDocumentReadException.java
Modified:
core/trunk/exo.core.component.document/src/main/java/org/exoplatform/ser=
vices/document/impl/PDFDocumentReader.java
Log:
EXOJCR-422 : The adding throw PDFDocumentReadException when IOException
Added: core/trunk/exo.core.component.document/src/main/java/org/exoplatform=
/services/document/PDFDocumentReadException.java
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- core/trunk/exo.core.component.document/src/main/java/org/exoplatform/se=
rvices/document/PDFDocumentReadException.java (rev =
0)
+++ core/trunk/exo.core.component.document/src/main/java/org/exoplatform/se=
rvices/document/PDFDocumentReadException.java 2010-02-16 15:59:42 UTC (rev =
1839)
@@ -0,0 +1,44 @@
+/*
+ * Copyright (C) 2003-2010 eXo Platform SAS.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Affero General Public License
+ * as published by the Free Software Foundation; either version 3
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, see.
+ */
+package org.exoplatform.services.document;
+
+import java.io.IOException;
+
+/**
+ * Created by The eXo Platform SAS.
+ * =
+ *
Date: 2010
+ *
+ * @author Alex Re=
shetnyak =
+ * @version $Id: PDFDocumentReaderException.java 111 2010-11-11 11:11:11Z =
rainf0x $
+ */
+public class PDFDocumentReadException
+ extends DocumentReadException
+{
+
+ /**
+ * Constructor.
+ * =
+ * @param message
+ * String, the message of exception =
+ * @param cause
+ * the cause of exception.
+ */
+ public PDFDocumentReadException(String message, Throwable cause) {
+ super(message, cause);
+ }
+}
\ No newline at end of file
Modified: core/trunk/exo.core.component.document/src/main/java/org/exoplatf=
orm/services/document/impl/PDFDocumentReader.java
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- core/trunk/exo.core.component.document/src/main/java/org/exoplatform/se=
rvices/document/impl/PDFDocumentReader.java 2010-02-16 15:45:59 UTC (rev 18=
38)
+++ core/trunk/exo.core.component.document/src/main/java/org/exoplatform/se=
rvices/document/impl/PDFDocumentReader.java 2010-02-16 15:59:42 UTC (rev 18=
39)
@@ -24,6 +24,7 @@
import org.exoplatform.commons.utils.ISO8601;
import org.exoplatform.services.document.DCMetaData;
import org.exoplatform.services.document.DocumentReadException;
+import org.exoplatform.services.document.PDFDocumentReadException;
import org.exoplatform.services.log.ExoLogger;
import org.exoplatform.services.log.Log;
import org.pdfbox.pdmodel.PDDocument;
@@ -84,13 +85,16 @@
StringWriter sw =3D new StringWriter();
try
{
+ if (is.available() =3D=3D 0)
+ return "";
+ =
try
{
pdDocument =3D PDDocument.load(is);
}
catch (IOException e)
{
- return "";
+ throw new PDFDocumentReadException("Can not load PDF documet."=
, e);
}
=
PDFTextStripper stripper =3D new PDFTextStripper();
--===============6973055739330532694==--