use of org.apache.jackrabbit.core.data.DataStoreException in project jackrabbit-oak by apache.
the class AzureDataStoreTest method testBackendReadRecordInvalidIdentifier.
@Test
public void testBackendReadRecordInvalidIdentifier() {
DataIdentifier identifier = new DataIdentifier("fake");
try {
backend.read(identifier);
fail();
} catch (DataStoreException e) {
}
}
use of org.apache.jackrabbit.core.data.DataStoreException in project jackrabbit-oak by apache.
the class DataStoreBlobStore method getReference.
@Override
public String getReference(@Nonnull String encodedBlobId) {
checkNotNull(encodedBlobId);
String blobId = extractBlobId(encodedBlobId);
//Reference are not created for in memory record
if (InMemoryDataRecord.isInstance(blobId)) {
return null;
}
DataRecord record;
try {
record = delegate.getRecordIfStored(new DataIdentifier(blobId));
if (record != null) {
return record.getReference();
} else {
log.debug("No blob found for id [{}]", blobId);
}
} catch (DataStoreException e) {
log.warn("Unable to access the blobId for [{}]", blobId, e);
}
return null;
}
use of org.apache.jackrabbit.core.data.DataStoreException in project jackrabbit-oak by apache.
the class DataStoreBlobStore method writeBlob.
@Override
public String writeBlob(InputStream stream, BlobOptions options) throws IOException {
boolean threw = true;
try {
long start = System.nanoTime();
checkNotNull(stream);
DataRecord dr = writeStream(stream, options);
String id = getBlobId(dr);
if (tracker != null && !InMemoryDataRecord.isInstance(id)) {
try {
tracker.add(id);
log.trace("Tracked Id {}", id);
} catch (Exception e) {
log.warn("Could not add track id", e);
}
}
threw = false;
stats.uploaded(System.nanoTime() - start, TimeUnit.NANOSECONDS, dr.getLength());
stats.uploadCompleted(id);
return id;
} catch (DataStoreException e) {
throw new IOException(e);
} finally {
//DataStore does not closes the stream internally
//So close the stream explicitly
Closeables.close(stream, threw);
}
}
use of org.apache.jackrabbit.core.data.DataStoreException in project jackrabbit-oak by apache.
the class DataStoreBlobStore method getBlobId.
@Override
public String getBlobId(@Nonnull String reference) {
checkNotNull(reference);
DataRecord record;
try {
record = delegate.getRecordFromReference(reference);
if (record != null) {
return getBlobId(record);
}
} catch (DataStoreException e) {
log.warn("Unable to access the blobId for [{}]", reference, e);
}
return null;
}
use of org.apache.jackrabbit.core.data.DataStoreException in project jackrabbit-oak by apache.
the class DataStoreBlobStore method getBlobLength.
@Override
public long getBlobLength(String encodedBlobId) throws IOException {
try {
checkNotNull(encodedBlobId, "BlobId must be specified");
BlobId id = BlobId.of(encodedBlobId);
if (encodeLengthInId && id.hasLengthInfo()) {
return id.length;
}
return getDataRecord(id.blobId).getLength();
} catch (DataStoreException e) {
throw new IOException(e);
}
}
Aggregations