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;
}
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());
}
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();
}
}
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());
}
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;
}
Aggregations