Search in sources :

Example 76 with DataStoreException

use of org.apache.jackrabbit.core.data.DataStoreException in project jackrabbit-oak by apache.

the class AzureDataStoreTest method testBackendGetRecordInvalidIdentifierThrowsDataStoreException.

@Test
public void testBackendGetRecordInvalidIdentifierThrowsDataStoreException() {
    try {
        backend.getRecord(new DataIdentifier("invalid"));
        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 77 with DataStoreException

use of org.apache.jackrabbit.core.data.DataStoreException in project jackrabbit-oak by apache.

the class AzureBlobStoreBackend method addMetadataRecordImpl.

private void addMetadataRecordImpl(final InputStream input, String name, long recordLength) throws DataStoreException {
    try {
        CloudBlobDirectory metaDir = getAzureContainer().getDirectoryReference(META_DIR_NAME);
        CloudBlockBlob blob = metaDir.getBlockBlobReference(name);
        blob.upload(input, recordLength);
    } catch (StorageException e) {
        LOG.info("Error adding metadata record. metadataName={} length={}", name, recordLength, e);
        throw new DataStoreException(e);
    } catch (URISyntaxException | IOException e) {
        throw new DataStoreException(e);
    }
}
Also used : DataStoreException(org.apache.jackrabbit.core.data.DataStoreException) CloudBlobDirectory(com.microsoft.azure.storage.blob.CloudBlobDirectory) URISyntaxException(java.net.URISyntaxException) IOException(java.io.IOException) CloudBlockBlob(com.microsoft.azure.storage.blob.CloudBlockBlob) StorageException(com.microsoft.azure.storage.StorageException)

Example 78 with DataStoreException

use of org.apache.jackrabbit.core.data.DataStoreException in project jackrabbit-oak by apache.

the class AzureDataStoreTest method testBackendAddMetadataRecordFileNotFoundThrowsDataStoreException.

@Test
public void testBackendAddMetadataRecordFileNotFoundThrowsDataStoreException() throws IOException {
    File testFile = folder.newFile();
    copyInputStreamToFile(randomStream(0, 10), testFile);
    testFile.delete();
    try {
        backend.addMetadataRecord(testFile, "name");
        fail();
    } catch (DataStoreException e) {
        assertTrue(e.getCause() instanceof FileNotFoundException);
    }
}
Also used : DataStoreException(org.apache.jackrabbit.core.data.DataStoreException) FileNotFoundException(java.io.FileNotFoundException) FileUtils.copyInputStreamToFile(org.apache.commons.io.FileUtils.copyInputStreamToFile) File(java.io.File) Test(org.junit.Test)

Example 79 with DataStoreException

use of org.apache.jackrabbit.core.data.DataStoreException in project jackrabbit-oak by apache.

the class AzureDataStoreTest method testBackendWriteRecordFileNotFoundThrowsException.

@Test
public void testBackendWriteRecordFileNotFoundThrowsException() throws IOException, NoSuchAlgorithmException {
    File testFile = folder.newFile();
    copyInputStreamToFile(randomStream(0, 10), testFile);
    DataIdentifier identifier = new DataIdentifier(getIdForInputStream(new FileInputStream(testFile)));
    assertTrue(testFile.delete());
    try {
        backend.write(identifier, testFile);
        fail();
    } catch (DataStoreException e) {
        assertTrue(e.getCause() instanceof FileNotFoundException);
    }
}
Also used : DataStoreException(org.apache.jackrabbit.core.data.DataStoreException) DataIdentifier(org.apache.jackrabbit.core.data.DataIdentifier) FileNotFoundException(java.io.FileNotFoundException) FileUtils.copyInputStreamToFile(org.apache.commons.io.FileUtils.copyInputStreamToFile) File(java.io.File) FileInputStream(java.io.FileInputStream) Test(org.junit.Test)

Example 80 with DataStoreException

use of org.apache.jackrabbit.core.data.DataStoreException in project jackrabbit-oak by apache.

the class FSBackend method addMetadataRecord.

@Override
public void addMetadataRecord(File input, String name) throws DataStoreException {
    try {
        File file = new File(fsPathDir, name);
        FileUtils.copyFile(input, file);
    } catch (IOException e) {
        LOG.error("Exception while adding metadata record file {} with name {}, {}", input, name, e);
        throw new DataStoreException("Could not add root record", e);
    }
}
Also used : DataStoreException(org.apache.jackrabbit.core.data.DataStoreException) IOException(java.io.IOException) RandomAccessFile(java.io.RandomAccessFile) File(java.io.File)

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