Search in sources :

Example 31 with DataStoreException

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) {
    }
}
Also used : DataStoreException(org.apache.jackrabbit.core.data.DataStoreException) DataIdentifier(org.apache.jackrabbit.core.data.DataIdentifier) Test(org.junit.Test)

Example 32 with DataStoreException

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;
}
Also used : DataStoreException(org.apache.jackrabbit.core.data.DataStoreException) DataIdentifier(org.apache.jackrabbit.core.data.DataIdentifier) DataRecord(org.apache.jackrabbit.core.data.DataRecord)

Example 33 with DataStoreException

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);
    }
}
Also used : DataStoreException(org.apache.jackrabbit.core.data.DataStoreException) DataRecord(org.apache.jackrabbit.core.data.DataRecord) IOException(java.io.IOException) RepositoryException(javax.jcr.RepositoryException) DataStoreException(org.apache.jackrabbit.core.data.DataStoreException) IOException(java.io.IOException) ExecutionException(java.util.concurrent.ExecutionException)

Example 34 with DataStoreException

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;
}
Also used : DataStoreException(org.apache.jackrabbit.core.data.DataStoreException) DataRecord(org.apache.jackrabbit.core.data.DataRecord)

Example 35 with DataStoreException

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);
    }
}
Also used : DataStoreException(org.apache.jackrabbit.core.data.DataStoreException) IOException(java.io.IOException)

Aggregations

DataStoreException (org.apache.jackrabbit.core.data.DataStoreException)85 IOException (java.io.IOException)35 AmazonServiceException (com.amazonaws.AmazonServiceException)28 ObjectMetadata (com.amazonaws.services.s3.model.ObjectMetadata)18 DataIdentifier (org.apache.jackrabbit.core.data.DataIdentifier)15 File (java.io.File)14 AmazonClientException (com.amazonaws.AmazonClientException)12 StorageException (com.microsoft.azure.storage.StorageException)11 InputStream (java.io.InputStream)9 URISyntaxException (java.net.URISyntaxException)9 RepositoryException (javax.jcr.RepositoryException)9 CopyObjectRequest (com.amazonaws.services.s3.model.CopyObjectRequest)7 PutObjectRequest (com.amazonaws.services.s3.model.PutObjectRequest)7 Copy (com.amazonaws.services.s3.transfer.Copy)7 Upload (com.amazonaws.services.s3.transfer.Upload)7 FileObject (org.apache.commons.vfs2.FileObject)7 FileSystemException (org.apache.commons.vfs2.FileSystemException)7 BufferedInputStream (java.io.BufferedInputStream)6 NoSuchAlgorithmException (java.security.NoSuchAlgorithmException)6 S3Object (com.amazonaws.services.s3.model.S3Object)5