Examples of DroidsException


Examples of org.apache.droids.exception.DroidsException

  public void handle(URI uri, ContentEntity entity) throws IOException, DroidsException {
    SolrInputDocument doc = createSolrInputDocument(uri, entity);
    try {
      server.add(doc);
    } catch (SolrServerException e) {
      throw new DroidsException(e);
    }
  }
View Full Code Here

Examples of org.apache.droids.exception.DroidsException

      ParseImpl parse = new ParseImpl(handler.toString(),null);
     
      return parse;

    } catch (SAXException ex) {
      throw new DroidsException("Failure parsing document " + link.getId(), ex);
    } catch (TikaException ex) {
      throw new DroidsException("Failure parsing document " + link.getId(), ex);
    } finally {
      instream.close();
    }
  }
View Full Code Here

Examples of org.apache.droids.exception.DroidsException

    try {
      parser.parse(instream, parallelHandler, metadata);
     
      return new ParseImpl(data.toString(), extractor.getLinks());
    } catch (SAXException ex) {
      throw new DroidsException("Failure parsing document " + link.getId(), ex);
    } catch (TikaException ex) {
      throw new DroidsException("Failure parsing document " + link.getId(), ex);
    } finally {
      instream.close();
    }
  }
View Full Code Here

Examples of org.apache.droids.exception.DroidsException

    SolrInputDocument doc = createSolrInputDocument(uri, entity);
    try {
      solr.add( doc );
    }
    catch (SolrServerException e) {
      throw new DroidsException( e );
    }
  }
View Full Code Here

Examples of org.apache.droids.exception.DroidsException

  public void handle(URI uri, ContentEntity entity) throws IOException, DroidsException {
    SolrInputDocument doc = createSolrInputDocument(uri, entity);
    try {
      server.add(doc);
    } catch (SolrServerException e) {
      throw new DroidsException(e);
    }
  }
View Full Code Here

Examples of org.apache.droids.exception.DroidsException

    SAXTransformerFactory factory = (SAXTransformerFactory) SAXTransformerFactory.newInstance();
    TransformerHandler xmlHandler;
    try {
      xmlHandler = factory.newTransformerHandler();
    } catch (TransformerConfigurationException e) {
      throw new DroidsException(e);
    }
    xmlHandler.getTransformer().setOutputProperty(OutputKeys.METHOD, "xml");
    xmlHandler.setResult(new StreamResult(dataBuffer));
   
    BoilerpipeContentHandler mainContentHandler = new BoilerpipeContentHandler(mainContentBuffer);
    BodyContentHandler bodyHandler = new BodyContentHandler(bodyBuffer);
    LinkContentHandler linkHandler = new LinkContentHandler();
   
    TeeContentHandler parallelHandler = new TeeContentHandler(xmlHandler, mainContentHandler, bodyHandler, linkHandler );

    InputStream instream = entity.obtainContent();
    try {
      parser.parse(instream, parallelHandler, metadata, new ParseContext());
     
      ArrayList<Link> extractedTasks = new ArrayList<Link>();
      int depth = task.getDepth() + 1;
      if (task instanceof LinkTask) {
        for(org.apache.tika.sax.Link tikaLink : linkHandler.getLinks()) {
          try {
            URI uri = new URI(tikaLink.getUri());
            // Test to see if the scheme is empty
            // This would indicate a relative URL, so resolve it against the task URI
            if(uri.getScheme() == null) {
              uri = ((Link) task).getURI().resolve(uri);
            }
            extractedTasks.add(new LinkTask((Link)task, uri, depth, tikaLink.getText()));
          } catch (URISyntaxException e) {
            if(LOG.isWarnEnabled()) {
              LOG.warn("URI not valid: "+ tikaLink.getUri());
            }
          }
        }
      }
      return new TikaParseImpl(dataBuffer.toString(), extractedTasks, bodyBuffer.toString(), mainContentBuffer.toString(), metadata);
    } catch (SAXException ex) {
      throw new DroidsException("Failure parsing document " + task.getId(), ex);
    } catch (TikaException ex) {
      throw new DroidsException("Failure parsing document " + task.getId(), ex);
    } finally {
      instream.close();
    }
  }
View Full Code Here

Examples of org.apache.droids.exception.DroidsException

    SAXTransformerFactory factory = (SAXTransformerFactory) SAXTransformerFactory.newInstance();
    TransformerHandler xmlHandler;
    try {
      xmlHandler = factory.newTransformerHandler();
    } catch (TransformerConfigurationException e) {
      throw new DroidsException(e);
    }
    xmlHandler.getTransformer().setOutputProperty(OutputKeys.METHOD, "xml");
    xmlHandler.setResult(new StreamResult(dataBuffer));
   
    BoilerpipeContentHandler mainContentHandler = new BoilerpipeContentHandler(mainContentBuffer);
    BodyContentHandler bodyHandler = new BodyContentHandler(bodyBuffer);
    LinkContentHandler linkHandler = new LinkContentHandler();
   
    TeeContentHandler parallelHandler = new TeeContentHandler(xmlHandler, mainContentHandler, bodyHandler, linkHandler );

    InputStream instream = entity.obtainContent();
    try {
      parser.parse(instream, parallelHandler, metadata, new ParseContext());
     
      ArrayList<Link> extractedTasks = new ArrayList<Link>();
      if (task instanceof Link) {
        int depth = task.getDepth() + 1;
        for(org.apache.tika.sax.Link tikaLink : linkHandler.getLinks()) {
          try {
            URI uri = new URI(tikaLink.getUri());
            // Test to see if the scheme is empty
            // This would indicate a relative URL, so resolve it against the task URI
            if(uri.getScheme() == null) {
              uri = ((Link) task).getURI().resolve(uri);
            }
            extractedTasks.add(new LinkTask((Link)task, uri, depth, tikaLink.getText()));
          } catch (URISyntaxException e) {
            if(log.isWarnEnabled()) {
              log.warn("URI not valid: "+ tikaLink.getUri());
            }
          }
        }
      }
      return new TikaParseImpl(dataBuffer.toString(), extractedTasks, bodyBuffer.toString(), mainContentBuffer.toString(), metadata);
    } catch (SAXException ex) {
      throw new DroidsException("Failure parsing document " + task.getId(), ex);
    } catch (TikaException ex) {
      throw new DroidsException("Failure parsing document " + task.getId(), ex);
    } finally {
      instream.close();
    }
  }
View Full Code Here

Examples of org.apache.droids.exception.DroidsException

      ManagedContentEntity entity = null;
      try {
        entity = protocol.load(uri);
      } catch(OutOfMemoryError e) {
        LOG.error("Out of memory processing: " + uri + " skipping", e);
        throw new DroidsException(e);
      }
      try {
        String contentType = entity.getMimeType();
        if (LOG.isDebugEnabled()) {
          LOG.debug("Content type " + contentType);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.