Search in sources :

Example 6 with DataStoreException

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

the class OakFileDataStore method addMetadataRecord.

@Override
public void addMetadataRecord(File input, String name) throws DataStoreException {
    try {
        File file = new File(getPath(), name);
        FileUtils.copyFile(input, file);
    } catch (IOException e) {
        LOG.error("Exception while adding metadata record file {} with name {}, {}", new Object[] { 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) File(java.io.File)

Example 7 with DataStoreException

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

the class OakFileDataStore method addMetadataRecord.

@Override
public void addMetadataRecord(InputStream input, String name) throws DataStoreException {
    try {
        File file = new File(getPath(), name);
        FileOutputStream os = new FileOutputStream(file);
        try {
            IOUtils.copyLarge(input, os);
        } finally {
            Closeables.close(os, true);
            Closeables.close(input, true);
        }
    } catch (IOException e) {
        LOG.error("Exception while adding metadata record with name {}, {}", new Object[] { name, e });
        throw new DataStoreException("Could not add root record", e);
    }
}
Also used : DataStoreException(org.apache.jackrabbit.core.data.DataStoreException) FileOutputStream(java.io.FileOutputStream) IOException(java.io.IOException) File(java.io.File)

Example 8 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(InputStream input, String name) throws DataStoreException {
    try {
        File file = new File(fsPathDir, name);
        FileOutputStream os = new FileOutputStream(file);
        try {
            IOUtils.copyLarge(input, os);
        } finally {
            Closeables.close(os, true);
            Closeables.close(input, true);
        }
    } catch (IOException e) {
        LOG.error("Exception while adding metadata record with name {}, {}", new Object[] { name, e });
        throw new DataStoreException("Could not add root record", e);
    }
}
Also used : DataStoreException(org.apache.jackrabbit.core.data.DataStoreException) FileOutputStream(java.io.FileOutputStream) IOException(java.io.IOException) RandomAccessFile(java.io.RandomAccessFile) File(java.io.File)

Example 9 with DataStoreException

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

the class FSBackend method getRecord.

@Override
public DataRecord getRecord(DataIdentifier identifier) throws DataStoreException {
    long start = System.currentTimeMillis();
    File file = getFile(identifier, fsPathDir);
    if (!file.exists() || !file.isFile()) {
        LOG.info("getRecord:Identifier [{}] not found. Took [{}] ms.", identifier, (System.currentTimeMillis() - start));
        throw new DataStoreException("Identifier [" + identifier + "] not found.");
    }
    return new FSBackendDataRecord(this, identifier, file);
}
Also used : DataStoreException(org.apache.jackrabbit.core.data.DataStoreException) RandomAccessFile(java.io.RandomAccessFile) File(java.io.File)

Example 10 with DataStoreException

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

the class VFSBackend method getExistingFileObject.

/**
     * Returns the identified file object. If not existing, returns null.
     *
     * @param identifier data identifier
     * @return identified file object
     * @throws DataStoreException if any file system exception occurs
     */
protected FileObject getExistingFileObject(DataIdentifier identifier) throws DataStoreException {
    String relPath = resolveFileObjectRelPath(identifier);
    String[] segments = relPath.split("/");
    FileObject tempFileObject = getBaseFolderObject();
    try {
        for (int i = 0; i < segments.length; i++) {
            tempFileObject = tempFileObject.getChild(segments[i]);
            if (tempFileObject == null) {
                return null;
            }
        }
        return tempFileObject;
    } catch (FileSystemException e) {
        throw new DataStoreException("File object not resolved: " + identifier, e);
    }
}
Also used : FileSystemException(org.apache.commons.vfs2.FileSystemException) DataStoreException(org.apache.jackrabbit.core.data.DataStoreException) FileObject(org.apache.commons.vfs2.FileObject)

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