Search in sources :

Example 81 with DataStoreException

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

the class FSBackend method init.

@Override
public void init() throws DataStoreException {
    fsPath = properties.getProperty(FS_BACKEND_PATH);
    if (this.fsPath == null || "".equals(this.fsPath)) {
        throw new DataStoreException("Could not initialize FSBackend from " + properties + ". [" + FS_BACKEND_PATH + "] property not found.");
    }
    this.fsPath = normalizeNoEndSeparator(fsPath);
    fsPathDir = new File(this.fsPath);
    if (fsPathDir.exists() && fsPathDir.isFile()) {
        throw new DataStoreException("Can not create a directory " + "because a file exists with the same name: " + this.fsPath);
    }
    if (!fsPathDir.exists()) {
        boolean created = fsPathDir.mkdirs();
        if (!created) {
            throw new DataStoreException("Could not create directory: " + fsPathDir.getAbsolutePath());
        }
    }
}
Also used : DataStoreException(org.apache.jackrabbit.core.data.DataStoreException) RandomAccessFile(java.io.RandomAccessFile) File(java.io.File)

Example 82 with DataStoreException

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

the class FSBackend method getOrCreateReferenceKey.

@Override
public byte[] getOrCreateReferenceKey() throws DataStoreException {
    File file = new File(fsPathDir, "reference.key");
    try {
        if (file.exists()) {
            return FileUtils.readFileToByteArray(file);
        } else {
            byte[] key = super.getOrCreateReferenceKey();
            FileUtils.writeByteArrayToFile(file, key);
            return key;
        }
    } catch (IOException e) {
        throw new DataStoreException("Unable to access reference key file " + file.getPath(), e);
    }
}
Also used : DataStoreException(org.apache.jackrabbit.core.data.DataStoreException) IOException(java.io.IOException) RandomAccessFile(java.io.RandomAccessFile) File(java.io.File)

Example 83 with DataStoreException

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

the class OakCachingFDS method getOrCreateReferenceKey.

@Override
protected byte[] getOrCreateReferenceKey() throws DataStoreException {
    File file = new File(fsBackendPath, "reference.key");
    try {
        if (file.exists()) {
            return FileUtils.readFileToByteArray(file);
        } else {
            byte[] key = new byte[256];
            new SecureRandom().nextBytes(key);
            FileUtils.writeByteArrayToFile(file, key);
            return key;
        }
    } catch (IOException e) {
        throw new DataStoreException("Unable to access reference key file " + file.getPath(), e);
    }
}
Also used : DataStoreException(org.apache.jackrabbit.core.data.DataStoreException) SecureRandom(java.security.SecureRandom) IOException(java.io.IOException) File(java.io.File)

Example 84 with DataStoreException

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

the class S3DataStoreFactory method asCloseable.

private static Closeable asCloseable(final CachingDataStore store, final File tempHomeDir) {
    return new Closeable() {

        @Override
        public void close() throws IOException {
            try {
                while (!store.getPendingUploads().isEmpty()) {
                    log.info("Waiting for following uploads to finish: " + store.getPendingUploads());
                    Thread.sleep(1000);
                }
                store.close();
                FileUtils.deleteDirectory(tempHomeDir);
            } catch (DataStoreException e) {
                throw new IOException(e);
            } catch (InterruptedException e) {
                throw new IOException(e);
            }
        }
    };
}
Also used : DataStoreException(org.apache.jackrabbit.core.data.DataStoreException) Closeable(java.io.Closeable) IOException(java.io.IOException)

Example 85 with DataStoreException

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

the class SafeDataStoreBlobStore method getStream.

@Override
protected InputStream getStream(String blobId) throws IOException {
    try {
        DataRecord record = getDataRecord(blobId);
        if (record == null) {
            log.warn("No blob found for id [{}]", blobId);
            return new ByteArrayInputStream(new byte[0]);
        }
        InputStream in = getDataRecord(blobId).getStream();
        if (!(in instanceof BufferedInputStream)) {
            in = new BufferedInputStream(in);
        }
        return StatsCollectingStreams.wrap(stats, blobId, in);
    } catch (DataStoreException e) {
        throw new IOException(e);
    }
}
Also used : DataStoreException(org.apache.jackrabbit.core.data.DataStoreException) ByteArrayInputStream(java.io.ByteArrayInputStream) BufferedInputStream(java.io.BufferedInputStream) BufferedInputStream(java.io.BufferedInputStream) ByteArrayInputStream(java.io.ByteArrayInputStream) InputStream(java.io.InputStream) InMemoryDataRecord(org.apache.jackrabbit.oak.plugins.blob.datastore.InMemoryDataRecord) DataRecord(org.apache.jackrabbit.core.data.DataRecord) 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