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());
}
}
}
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);
}
}
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);
}
}
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);
}
}
};
}
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);
}
}
Aggregations