Search in sources :

Example 1 with Link

use of org.apache.tika.sax.Link in project tika by apache.

the class RollbackSoftware method rollback.

public void rollback(File deployArea) throws IOException, SAXException, TikaException {
    LinkContentHandler handler = new LinkContentHandler();
    Metadata met = new Metadata();
    DeploymentAreaParser parser = new DeploymentAreaParser();
    parser.parse(IOUtils.toInputStream(deployArea.getAbsolutePath(), UTF_8), handler, met);
    List<Link> links = handler.getLinks();
    if (links.size() < 2)
        throw new IOException("Must have installed at least 2 versions!");
    Collections.sort(links, new Comparator<Link>() {

        public int compare(Link o1, Link o2) {
            return o1.getText().compareTo(o2.getText());
        }
    });
    this.updateVersion(links.get(links.size() - 2).getText());
}
Also used : LinkContentHandler(org.apache.tika.sax.LinkContentHandler) Metadata(org.apache.tika.metadata.Metadata) IOException(java.io.IOException) Link(org.apache.tika.sax.Link)

Aggregations

IOException (java.io.IOException)1 Metadata (org.apache.tika.metadata.Metadata)1 Link (org.apache.tika.sax.Link)1 LinkContentHandler (org.apache.tika.sax.LinkContentHandler)1