Package org.apache.tika.exception

Examples of org.apache.tika.exception.TikaException


            SAXParser parser = factory.newSAXParser();
            parser.parse(
                    new CloseShieldInputStream(stream),
                    new OfflineContentHandler(xhtml));
        } catch (ParserConfigurationException e) {
            throw new TikaException("XML parser configuration error", e);
        }
    }
View Full Code Here


            while ((is.read(buf, 0, 512)) != -1) {
                os.write(buf);
            }
        } catch (Exception e) {
            e.printStackTrace();
            throw new TikaException(e.getMessage());
        }
    }
View Full Code Here

            metadata.set(Metadata.CONTENT_TYPE, TYPE.toString());
            if (skipToPropertyInfoSection(stream, header)) {
                get2007and2010Props(stream,metadata,xhtml);
            }
        } else {
            throw new TikaException(
                    "Unsupported AutoCAD drawing version: " + version);
        }

        xhtml.endDocument();
    }
View Full Code Here

       XMLSlideShow slideShow = (XMLSlideShow) extractor.getDocument();
       XSLFSlideShow document = null;
       try {
          document = slideShow._getXSLFSlideShow(); // TODO Avoid this in future
       } catch(Exception e) {
          throw new TikaException(e.getMessage()); // Shouldn't happen
       }
      
       for (CTSlideIdListEntry ctSlide : document.getSlideReferences().getSldIdList()) {
          // Add the slide
          PackagePart slidePart;
          try {
             slidePart = document.getSlidePart(ctSlide);
          } catch(IOException e) {
             throw new TikaException("Broken OOXML file", e);
          } catch(XmlException xe) {
             throw new TikaException("Broken OOXML file", xe);
          }
          parts.add(slidePart);
         
          // If it has drawings, return those too
          try {
             for(PackageRelationship rel : slidePart.getRelationshipsByType(XSLFRelation.VML_DRAWING.getRelation())) {
               if(rel.getTargetMode() == TargetMode.INTERNAL) {
                   PackagePartName relName = PackagingURIHelper.createPartName(rel.getTargetURI());
                   parts.add( rel.getPackage().getPart(relName) );
                }
             }
          } catch(InvalidFormatException e) {
             throw new TikaException("Broken OOXML file", e);
          }
       }

       return parts;
    }
View Full Code Here

        IOUtils.readFully(stream, signature);
        if(signature[0] == (byte)'8' && signature[1] == (byte)'B' &&
           signature[2] == (byte)'P' && signature[3] == (byte)'S') {
           // Good, signature found
        } else {
           throw new TikaException("PSD/PSB magic signature invalid");
        }
       
        // Check the version
        int version = EndianUtils.readUShortBE(stream);
        if(version == 1 || version == 2) {
           // Good, we support these two
        } else {
           throw new TikaException("Invalid PSD/PSB version " + version);
        }
       
        // Skip the reserved block
        IOUtils.readFully(stream, new byte[6]);
       
View Full Code Here

       private int totalLength;
       private ResourceBlock(InputStream stream) throws IOException, TikaException {
          // Verify the signature
          long sig = EndianUtils.readIntBE(stream);
          if(sig != SIGNATURE) {
             throw new TikaException("Invalid Image Resource Block Signature Found, got " +
                   sig + " 0x" + Long.toHexString(sig) + " but the spec defines " + SIGNATURE);
          }
         
          // Read the block
          id = EndianUtils.readUShortBE(stream);
View Full Code Here

        } catch (FileNotFoundException e) {
            // entry does not exist, just skip it
        } catch (NoPropertySetStreamException e) {
            // no property stream, just skip it
        } catch (UnexpectedPropertySetTypeException e) {
            throw new TikaException("Unexpected HPSF document", e);
        } catch (MarkUnsupportedException e) {
            throw new TikaException("Invalid DocumentInputStream", e);
        }
    }
View Full Code Here

            CMSSignedDataParser parser =
                    new CMSSignedDataParser(new CloseShieldInputStream(stream));
            try {
                CMSTypedStream content = parser.getSignedContent();    
                if (content == null) {
                  throw new TikaException("cannot parse detached pkcs7 signature (no signed data to parse)");
                }
                InputStream input = content.getContentStream();
                try {
                    Parser delegate =
                            context.get(Parser.class, EmptyParser.INSTANCE);
                    delegate.parse(input, handler, metadata, context);
                } finally {
                    input.close();
                }
            } finally {
                parser.close();
            }
        } catch (CMSException e) {
            throw new TikaException("Unable to parse pkcs7 signed data", e);
        }
    }
View Full Code Here

        super(context);
       
        try {
            this.msg = new MAPIMessage(root);
        } catch (IOException e) {
            throw new TikaException("Failed to parse Outlook message", e);
        }
    }
View Full Code Here

               }

               xhtml.endElement("div");
           }
        } catch(ChunkNotFoundException e) {
           throw new TikaException("POI MAPIMessage broken - didn't return null on missing chunk", e);
        }
    }
View Full Code Here

TOP

Related Classes of org.apache.tika.exception.TikaException

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.