use of org.apache.jackrabbit.core.data.DataRecord in project jackrabbit-oak by apache.
the class CachingDataStoreTest method syncAddGetDelete.
/**
* Add, get, delete with synchronous option.
* @throws Exception
*/
@Test
public void syncAddGetDelete() throws Exception {
LOG.info("Starting syncAddGetDelete");
File f = copyToFile(randomStream(0, 4 * 1024), folder.newFile());
String id = getIdForInputStream(f);
FileInputStream fin = new FileInputStream(f);
closer.register(fin);
DataRecord rec = dataStore.addRecord(fin, new BlobOptions().setUpload(SYNCHRONOUS));
assertEquals(id, rec.getIdentifier().toString());
assertFile(rec.getStream(), f, folder);
rec = dataStore.getRecordIfStored(new DataIdentifier(id));
assertEquals(id, rec.getIdentifier().toString());
assertFile(rec.getStream(), f, folder);
assertEquals(1, Iterators.size(dataStore.getAllIdentifiers()));
dataStore.deleteRecord(new DataIdentifier(id));
rec = dataStore.getRecordIfStored(new DataIdentifier(id));
assertNull(rec);
LOG.info("Finished syncAddGetDelete");
}
use of org.apache.jackrabbit.core.data.DataRecord in project jackrabbit-oak by apache.
the class OakFileDataStore method getAllMetadataRecords.
@Override
public List<DataRecord> getAllMetadataRecords(String prefix) {
File root = new File(getPath());
List<DataRecord> rootRecords = new ArrayList<DataRecord>();
for (File file : FileFilterUtils.filterList(FileFilterUtils.prefixFileFilter(prefix), root.listFiles())) {
if (!file.isDirectory()) {
// skip directories which are actual data store files
rootRecords.add(new FileDataRecord(this, new DataIdentifier(file.getName()), file));
}
}
return rootRecords;
}
use of org.apache.jackrabbit.core.data.DataRecord in project jackrabbit-oak by apache.
the class CachingDataStoreTest method addDelete.
/**
* Add in datastore.
*/
@Test
public void addDelete() throws Exception {
LOG.info("Starting addDelete");
File f = copyToFile(randomStream(0, 4 * 1024), folder.newFile());
String id = getIdForInputStream(f);
FileInputStream fin = new FileInputStream(f);
closer.register(fin);
DataRecord rec = dataStore.addRecord(fin);
assertEquals(id, rec.getIdentifier().toString());
//start & finish
taskLatch.countDown();
callbackLatch.countDown();
waitFinish();
rec = dataStore.getRecordIfStored(new DataIdentifier(id));
assertNotNull(rec);
assertFile(rec.getStream(), f, folder);
dataStore.deleteRecord(new DataIdentifier(id));
rec = dataStore.getRecordIfStored(new DataIdentifier(id));
assertNull(rec);
LOG.info("Finished addDelete");
}
use of org.apache.jackrabbit.core.data.DataRecord in project jackrabbit-oak by apache.
the class CachingDataStoreTest method referenceNoCache.
@Test
public void referenceNoCache() throws Exception {
LOG.info("Starting referenceNoCache");
dataStore.close();
init(1, 0, 0);
File f = copyToFile(randomStream(0, 4 * 1024), folder.newFile());
String id = getIdForInputStream(f);
FileInputStream fin = new FileInputStream(f);
closer.register(fin);
// Record still in staging
DataRecord rec = dataStore.addRecord(fin);
assertEquals(id, rec.getIdentifier().toString());
assertFile(rec.getStream(), f, folder);
assertEquals(backend.getReferenceFromIdentifier(rec.getIdentifier()), rec.getReference());
rec = dataStore.getRecordIfStored(new DataIdentifier(id));
assertNotNull(rec);
assertFile(rec.getStream(), f, folder);
assertEquals(backend.getReferenceFromIdentifier(rec.getIdentifier()), rec.getReference());
LOG.info("Finished referenceNoCache");
}
use of org.apache.jackrabbit.core.data.DataRecord in project jackrabbit-oak by apache.
the class DataStoreTextWriterTest method nonExistingEntry.
@Test
public void nonExistingEntry() throws Exception {
File fdsDir = temporaryFolder.newFolder();
FileDataStore fds = DataStoreUtils.createFDS(fdsDir, 0);
ByteArrayInputStream is = new ByteArrayInputStream("hello".getBytes());
DataRecord dr = fds.addRecord(is);
File writerDir = temporaryFolder.newFolder();
DataStoreTextWriter w = new DataStoreTextWriter(writerDir, false);
String id = dr.getIdentifier().toString();
assertFalse(w.isProcessed(id));
assertNull(w.getText("/a", new IdBlob("foo", id)));
w.write(id, "foo");
assertTrue(w.isProcessed(id));
ExtractedText et = w.getText("/a", new IdBlob("foo", id));
assertEquals("foo", et.getExtractedText());
assertEquals(ExtractionResult.SUCCESS, et.getExtractionResult());
w.markEmpty("a");
assertTrue(w.isProcessed("a"));
}
Aggregations