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