Package org.apache.tika.exception

Examples of org.apache.tika.exception.TikaException


            try {
                Class<? extends Parser> parserClass =
                        loader.getServiceClass(Parser.class, name);
                // https://issues.apache.org/jira/browse/TIKA-866
                if (AutoDetectParser.class.isAssignableFrom(parserClass)) {
                    throw new TikaException(
                            "AutoDetectParser not supported in a <parser>"
                            + " configuration element: " + name);
                }
                Parser parser = parserClass.newInstance();

                NodeList mimes = node.getElementsByTagName("mime");
                if (mimes.getLength() > 0) {
                    Set<MediaType> types = new HashSet<MediaType>();
                    for (int j = 0; j < mimes.getLength(); j++) {
                        String mime = getText(mimes.item(j));
                        MediaType type = MediaType.parse(mime);
                        if (type != null) {
                            types.add(type);
                        } else {
                            throw new TikaException(
                                    "Invalid media type name: " + mime);
                        }
                    }
                    parser = ParserDecorator.withTypes(parser, types);
                }

                parsers.add(parser);
            } catch (ClassNotFoundException e) {
                throw new TikaException(
                        "Unable to find a parser class: " + name, e);
            } catch (IllegalAccessException e) {
                throw new TikaException(
                        "Unable to access a parser class: " + name, e);
            } catch (InstantiationException e) {
                throw new TikaException(
                        "Unable to instantiate a parser class: " + name, e);
            }
        }
        if (parsers.isEmpty()) {
            return getDefaultParser(mimeTypes, loader);
View Full Code Here


           try {
               Class<? extends Detector> detectorClass =
                       loader.getServiceClass(Detector.class, name);
               detectors.add(detectorClass.newInstance());
           } catch (ClassNotFoundException e) {
               throw new TikaException(
                       "Unable to find a detector class: " + name, e);
           } catch (IllegalAccessException e) {
               throw new TikaException(
                       "Unable to access a detector class: " + name, e);
           } catch (InstantiationException e) {
               throw new TikaException(
                       "Unable to instantiate a detector class: " + name, e);
           }
       }
       if (detectors.isEmpty()) {
           return getDefaultDetector(mimeTypes, loader);
View Full Code Here

            }
        }

        // Else, use the global charset
        if (globalCharset == null) {
            throw new TikaException("unable to determine charset");
        }

        return globalCharset;
    }
View Full Code Here

                int bytesToRead = param;
                byte[] tmpArray = new byte[Math.min(1024, bytesToRead)];
                while (bytesToRead > 0) {
                    int r = in.read(tmpArray, 0, Math.min(bytesToRead, tmpArray.length));
                    if (r < 0) {
                        throw new TikaException("unexpected end of file: need " + param + " bytes of binary data, found " + (param-bytesToRead));
                    }
                    bytesToRead -= r;
                }
            } else {
                // log some warning?
View Full Code Here

        } catch (IOException e) {
            if (e.getCause() instanceof SAXException) {
                throw (SAXException) e.getCause();
            } else {
                throw new TikaException("Unable to extract PDF content", e);
            }
        }
    }
View Full Code Here

                   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

        } 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);
        } catch (Exception e) {
            logger.warn("Ignoring unexpected exception while parsing summary entry " + entryName, e);
        }
    }
View Full Code Here

                    tis.mark(0);
                    Font.createFont(Font.TRUETYPE_FONT, stream);
                    tis.reset();
                }
            } catch (FontFormatException ex) {
                throw new TikaException("Bad TrueType font.");
            }
        }
       
        // Ask FontBox to parse the file for us
        TrueTypeFont font;
View Full Code Here

                if (prevBlock != null && prevBlock.getState() != null)
                    previousBlockType = prevBlock.getState().getBlockType();

                extractContent();
            } else
                throw new TikaException("Check your chm lzx block parameters");
        } catch (Exception e) {
            // TODO: handle exception
        }
    }
View Full Code Here

                        getLzxBlocksCache().clear();
                    }
                }
            }
        } catch (Exception e) {
            throw new TikaException(e.getMessage());
        }

        return buffer.toByteArray();
    }
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.