Example usage for org.apache.commons.rdf.api IRI toString

List of usage examples for org.apache.commons.rdf.api IRI toString

Introduction

In this page you can find the example usage for org.apache.commons.rdf.api IRI toString.

Prototype

public String toString() 

Source Link

Document

Returns a string representation of the object.

Usage

From source file:org.trellisldp.rosid.file.FileResourceService.java

@Override
public Stream<IRI> tryPurge(final IRI identifier) {
    final List<IRI> binaries = new ArrayList<>();
    final File directory = resourceDirectory(partitions, identifier);

    try (final Stream<String> lineStream = lines(new File(directory, RESOURCE_JOURNAL).toPath())) {
        lineStream.flatMap(line -> {/*ww  w . j av a 2s. co  m*/
            final String[] parts = line.split(" ", 6);
            if (parts.length == 6 && parts[0].equals("A") && parts[1].equals(identifier.toString())
                    && parts[2].equals(DC.hasPart.toString())
                    && parts[4].equals(Trellis.PreferServerManaged.toString())) {
                return of(parts[3]);
            }
            return empty();
        }).map(iri -> iri.substring(1, iri.length() - 1)).map(rdf::createIRI).forEach(binaries::add);
    } catch (final IOException ex) {
        LOGGER.error("Error processing journal file: {}", ex.getMessage());
        throw new UncheckedIOException(ex);
    }

    try {
        deleteIfExists(new File(directory, RESOURCE_CACHE).toPath());
        deleteIfExists(new File(directory, RESOURCE_QUADS).toPath());
        // Truncate history file, rather than actually deleting it
        try (final BufferedWriter writer = newBufferedWriter(new File(directory, RESOURCE_JOURNAL).toPath(),
                UTF_8, WRITE, TRUNCATE_EXISTING)) {
            writer.write("");
        }
    } catch (final IOException ex) {
        LOGGER.error("Error deleting files: {}", ex.getMessage());
        throw new UncheckedIOException(ex);
    }

    return binaries.stream();
}