Package org.exoplatform.services.document

Examples of org.exoplatform.services.document.DocumentReadException


                     parser.parse(is, handler, metadata, context);
                     return handler.toString();
                  }
                  catch (SAXException e)
                  {
                     throw new DocumentReadException(e.getMessage(), e);
                  }
                  catch (TikaException e)
                  {
                     throw new DocumentReadException(e.getMessage(), e);
                  }
               }
               finally
               {
                  try
View Full Code Here


                     parser.parse(is, handler, metadata, context);
                     return handler.toString();
                  }
                  catch (SAXException e)
                  {
                     throw new DocumentReadException(e.getMessage(), e);
                  }
                  catch (TikaException e)
                  {
                     throw new DocumentReadException(e.getMessage(), e);
                  }
               }
               finally
               {
                  try
View Full Code Here

                  {
                     parser.parse(is, handler, metadata, context);
                  }
                  catch (SAXException e)
                  {
                     throw new DocumentReadException(e.getMessage(), e);
                  }
                  catch (TikaException e)
                  {
                     throw new DocumentReadException(e.getMessage(), e);
                  }

                  // construct Properties set
                  Properties props = new Properties();
                  convertProperty(metadata, props, DCMetaData.CONTRIBUTOR, new String[]{DublinCore.CONTRIBUTOR.getName(),
                     MSOffice.LAST_AUTHOR});
                  convertProperty(metadata, props, DCMetaData.COVERAGE, DublinCore.COVERAGE);
                  convertProperty(metadata, props, DCMetaData.CREATOR,
                     new String[]{MSOffice.AUTHOR, DublinCore.CREATOR.getName()});
                  // different parsers return date in different formats, so keep it as String
                  convertProperty(metadata, props, DCMetaData.DATE, new Property[]{DublinCore.DATE,
                     MSOffice.LAST_SAVED, MSOffice.CREATION_DATE});
                  convertProperty(metadata, props, DCMetaData.DESCRIPTION, new String[]{DublinCore.DESCRIPTION.getName(),
                     MSOffice.COMMENTS});
                  convertProperty(metadata, props, DCMetaData.FORMAT, DublinCore.FORMAT);
                  convertProperty(metadata, props, DCMetaData.IDENTIFIER, DublinCore.IDENTIFIER);
                  convertProperty(metadata, props, DCMetaData.LANGUAGE, DublinCore.LANGUAGE);
                  //convertProperty(metadata, props, DCMetaData.?, DublinCore.MODIFIED);
                  convertProperty(metadata, props, DCMetaData.PUBLISHER, DublinCore.PUBLISHER);
                  convertProperty(metadata, props, DCMetaData.RELATION, DublinCore.RELATION);
                  convertProperty(metadata, props, DCMetaData.RESOURCE, DublinCore.SOURCE);
                  convertProperty(metadata, props, DCMetaData.RIGHTS, DublinCore.RIGHTS);
                  convertProperty(metadata, props, DCMetaData.SUBJECT, new String[]{Metadata.SUBJECT,
                     OfficeOpenXMLCore.SUBJECT.getName(), DublinCore.SUBJECT.getName(), MSOffice.KEYWORDS});
                  convertProperty(metadata, props, DCMetaData.TITLE, DublinCore.TITLE);
                  convertProperty(metadata, props, DCMetaData.TYPE, DublinCore.TYPE);

                  return props;
               }
               finally
               {
                  try
                  {
                     is.close();
                  }
                  catch (IOException e)
                  {
                     if (LOG.isTraceEnabled())
                     {
                        LOG.trace("An exception occurred: " + e.getMessage());
                     }
                  }
               }
            }
         });
      }
      catch (PrivilegedActionException pae)
      {
         Throwable cause = pae.getCause();
         if (cause instanceof IOException)
         {
            throw (IOException)cause;
         }
         else
         {
            throw new DocumentReadException("Can not get properties: " + cause.getMessage(), cause);
         }
      }
   }
View Full Code Here

         {
            pdDocument = PDDocument.load(is);
         }
         catch (IOException e)
         {
            throw new DocumentReadException("Can not load PDF document.", e);
         }

         PDFTextStripper stripper = new PDFTextStripper();
         stripper.setStartPage(1);
         stripper.setEndPage(Integer.MAX_VALUE);
View Full Code Here

            {
               pdDocument.decrypt("");
            }
            catch (InvalidPasswordException e)
            {
               throw new DocumentReadException("The pdf document is encrypted.", e);
            }
            catch (org.apache.pdfbox.exceptions.CryptographyException e)
            {
               throw new DocumentReadException(e.getMessage(), e);
            }
         }

         PDDocumentCatalog catalog = pdDocument.getDocumentCatalog();
         PDMetadata meta = catalog.getMetadata();
View Full Code Here

            return new String(bytes, encoding);
         }
      }
      catch (UnsupportedEncodingException e)
      {
         throw new DocumentReadException(e.getMessage(), e);
      }
   }
View Full Code Here

               }
            }
            catch (NoPropertySetStreamException e)
            {
               throw new POIRuntimeException(new DocumentReadException(e.getMessage(), e));
            }
            catch (MarkUnsupportedException e)
            {
               throw new POIRuntimeException(new DocumentReadException(e.getMessage(), e));
            }
            catch (UnsupportedEncodingException e)
            {
               throw new POIRuntimeException(new DocumentReadException(e.getMessage(), e));
            }
            catch (IOException e)
            {
               throw new POIRuntimeException(e);
            }
View Full Code Here

         {
            ppe = new PowerPointExtractor(is);
         }
         catch (IOException e)
         {
            throw new DocumentReadException("Can't open presentation.", e);
         }
         return ppe.getText(true, true);
      }
      finally
      {
View Full Code Here

                  {
                     pdDocument = PDDocument.load(is);
                  }
                  catch (IOException e)
                  {
                     throw new DocumentReadException("Can not load PDF document.", e);
                  }

                  PDFTextStripper stripper = new PDFTextStripper();
                  stripper.setStartPage(1);
                  stripper.setEndPage(Integer.MAX_VALUE);
View Full Code Here

         catch (PrivilegedActionException pae)
         {
            Throwable cause = pae.getCause();
            if (cause instanceof IOException)
            {
               throw new DocumentReadException("Can't open presentation.", cause);
            }
            else if (cause instanceof OpenXML4JRuntimeException)
            {
               throw new DocumentReadException("Can't open presentation.", cause);
            }
            else if (cause instanceof OpenXML4JException)
            {
               throw new DocumentReadException("Can't open presentation.", cause);
            }
            else if (cause instanceof XmlException)
            {
               throw new DocumentReadException("Can't open presentation.", cause);
            }
            else if (cause instanceof RuntimeException)
            {
               throw (RuntimeException)cause;
            }
View Full Code Here

TOP

Related Classes of org.exoplatform.services.document.DocumentReadException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.