Search in sources :

Example 1 with BlobStoreException

use of com.enonic.xp.blob.BlobStoreException in project xp by enonic.

the class AbstractDumpBlobStore method addRecord.

@Override
public BlobKey addRecord(final Segment segment, final ByteSource in) throws BlobStoreException {
    try {
        final BlobKey blobKey = BlobKey.from(in);
        writeRecord(segment, blobKey, in);
        return blobKey;
    } catch (final IOException e) {
        throw new BlobStoreException("Failed to add blob", e);
    }
}
Also used : BlobKey(com.enonic.xp.blob.BlobKey) IOException(java.io.IOException) BlobStoreException(com.enonic.xp.blob.BlobStoreException)

Example 2 with BlobStoreException

use of com.enonic.xp.blob.BlobStoreException in project xp by enonic.

the class FileBlobStore method deleteSegment.

@Override
public void deleteSegment(final Segment segment) {
    try {
        final Path segmentParentDirectory = this.baseDir.resolve(segment.getLevel(0).getValue());
        final Path segmentDirectory = segmentParentDirectory.resolve(segment.getLevel(1).getValue());
        if (Files.exists(segmentDirectory)) {
            MoreFiles.deleteRecursively(segmentDirectory, RecursiveDeleteOption.ALLOW_INSECURE);
        }
        if (Files.exists(segmentParentDirectory) && nioFilesList(segmentParentDirectory).isEmpty()) {
            Files.delete(segmentParentDirectory);
        }
    } catch (IOException e) {
        throw new BlobStoreException("Failed to delete segment", e);
    }
}
Also used : Path(java.nio.file.Path) IOException(java.io.IOException) BlobStoreException(com.enonic.xp.blob.BlobStoreException)

Aggregations

BlobStoreException (com.enonic.xp.blob.BlobStoreException)2 IOException (java.io.IOException)2 BlobKey (com.enonic.xp.blob.BlobKey)1 Path (java.nio.file.Path)1