Search in sources :

Example 1 with FileInputSource

use of org.exist.util.FileInputSource in project exist by eXist-db.

the class FileSystemBackupDescriptor method getBlobInputSource.

@Override
public EXistInputSource getBlobInputSource(final String blobId) {
    final Path blobFile = root.resolve("blob").resolve(blobId);
    EXistInputSource is = null;
    if ((!Files.isDirectory(blobFile)) && Files.isReadable(blobFile)) {
        is = new FileInputSource(blobFile);
    }
    return is;
}
Also used : Path(java.nio.file.Path) FileInputSource(org.exist.util.FileInputSource) EXistInputSource(org.exist.util.EXistInputSource)

Example 2 with FileInputSource

use of org.exist.util.FileInputSource in project exist by eXist-db.

the class RecoverBinaryTest method storeAndVerify.

@Override
protected void storeAndVerify(final DBBroker broker, final Txn transaction, final Collection collection, final InputSource data, final String dbFilename) throws EXistException, PermissionDeniedException, IOException, SAXException, LockException {
    final Path file = ((FileInputSource) data).getFile();
    broker.storeDocument(transaction, XmldbURI.create(dbFilename), new FileInputSource(file), MimeType.BINARY_TYPE, collection);
    final BinaryDocument doc = (BinaryDocument) collection.getDocument(broker, XmldbURI.create(dbFilename));
    assertNotNull(doc);
    assertEquals(Files.size(file), doc.getContentLength());
}
Also used : Path(java.nio.file.Path) BinaryDocument(org.exist.dom.persistent.BinaryDocument) FileInputSource(org.exist.util.FileInputSource)

Example 3 with FileInputSource

use of org.exist.util.FileInputSource in project exist by eXist-db.

the class GMLIndexTest method setup.

@BeforeClass
public static void setup() throws EXistException, PermissionDeniedException, IOException, SAXException, CollectionConfigurationException, URISyntaxException, LockException {
    final BrokerPool pool = server.getBrokerPool();
    try (final DBBroker broker = pool.get(Optional.of(pool.getSecurityManager().getSystemSubject()));
        final Txn transaction = pool.getTransactionManager().beginTransaction();
        final Collection testCollection = broker.getOrCreateCollection(transaction, TEST_COLLECTION_URI)) {
        final CollectionConfigurationManager mgr = pool.getConfigurationManager();
        mgr.addConfiguration(transaction, broker, testCollection, COLLECTION_CONFIG);
        for (int i = 0; i < FILES.length; i++) {
            final URL url = GMLIndexTest.class.getResource("/" + FILES[i]);
            broker.storeDocument(transaction, XmldbURI.create(FILES[i]), new FileInputSource(Paths.get(url.toURI())), MimeType.XML_TYPE, testCollection);
        }
        transaction.commit();
    }
}
Also used : DBBroker(org.exist.storage.DBBroker) FileInputSource(org.exist.util.FileInputSource) Collection(org.exist.collections.Collection) Txn(org.exist.storage.txn.Txn) CollectionConfigurationManager(org.exist.collections.CollectionConfigurationManager) BrokerPool(org.exist.storage.BrokerPool) URL(java.net.URL)

Example 4 with FileInputSource

use of org.exist.util.FileInputSource in project exist by eXist-db.

the class JournalBinaryTest method storeAndVerify.

@Override
protected BinaryDocLocator storeAndVerify(final DBBroker broker, final Txn transaction, final Collection collection, final InputSource data, final String dbFilename) throws EXistException, PermissionDeniedException, IOException, SAXException, LockException {
    assertTrue(data instanceof FileInputSource);
    broker.storeDocument(transaction, XmldbURI.create(dbFilename), data, MimeType.BINARY_TYPE, collection);
    final BinaryDocument doc = (BinaryDocument) collection.getDocument(broker, XmldbURI.create(dbFilename));
    assertNotNull(doc);
    assertEquals(Files.size(((FileInputSource) data).getFile()), doc.getContentLength());
    return new BinaryDocLocator(collection.getURI().append(dbFilename).getRawCollectionPath(), doc.getBlobId());
}
Also used : BinaryDocument(org.exist.dom.persistent.BinaryDocument) FileInputSource(org.exist.util.FileInputSource)

Example 5 with FileInputSource

use of org.exist.util.FileInputSource in project exist by eXist-db.

the class FileSystemBackupDescriptor method getInputSource.

@Override
public EXistInputSource getInputSource(final String describedItem) {
    final Path child = descriptor.getParent().resolve(describedItem);
    EXistInputSource is = null;
    if ((!Files.isDirectory(child)) && Files.isReadable(child)) {
        is = new FileInputSource(child);
    }
    return is;
}
Also used : Path(java.nio.file.Path) FileInputSource(org.exist.util.FileInputSource) EXistInputSource(org.exist.util.EXistInputSource)

Aggregations

FileInputSource (org.exist.util.FileInputSource)6 Path (java.nio.file.Path)4 BinaryDocument (org.exist.dom.persistent.BinaryDocument)3 EXistInputSource (org.exist.util.EXistInputSource)2 URL (java.net.URL)1 CountingInputStream (org.apache.commons.io.input.CountingInputStream)1 Collection (org.exist.collections.Collection)1 CollectionConfigurationManager (org.exist.collections.CollectionConfigurationManager)1 BrokerPool (org.exist.storage.BrokerPool)1 DBBroker (org.exist.storage.DBBroker)1 Txn (org.exist.storage.txn.Txn)1