use of org.apache.jackrabbit.core.fs.FileSystemException in project jackrabbit by apache.
the class DatabaseFileSystem method listFolders.
/**
* {@inheritDoc}
*/
public String[] listFolders(String folderPath) throws FileSystemException {
if (!initialized) {
throw new IllegalStateException("not initialized");
}
FileSystemPathUtil.checkFormat(folderPath);
if (!isFolder(folderPath)) {
throw new FileSystemException("no such folder: " + folderPath);
}
synchronized (selectFolderNamesSQL) {
ResultSet rs = null;
try {
rs = conHelper.exec(selectFolderNamesSQL, new Object[] { folderPath }, false, 0);
ArrayList<String> names = new ArrayList<String>();
while (rs.next()) {
String name = rs.getString(1);
if (name.length() == 0 && FileSystemPathUtil.denotesRoot(folderPath)) {
// this is the file system root entry, skip...
continue;
}
names.add(name);
}
return (String[]) names.toArray(new String[names.size()]);
} catch (SQLException e) {
String msg = "failed to list folder entries of folder: " + folderPath;
log.error(msg, e);
throw new FileSystemException(msg, e);
} finally {
DbUtility.close(rs);
}
}
}
use of org.apache.jackrabbit.core.fs.FileSystemException in project jackrabbit by apache.
the class ObjectPersistenceManager method exists.
/**
* {@inheritDoc}
*/
public synchronized boolean exists(PropertyId id) throws ItemStateException {
if (!initialized) {
throw new IllegalStateException("not initialized");
}
try {
String propFilePath = buildPropFilePath(id);
FileSystemResource propFile = new FileSystemResource(itemStateFS, propFilePath);
return propFile.exists();
} catch (FileSystemException fse) {
String msg = "failed to check existence of item state: " + id;
log.debug(msg);
throw new ItemStateException(msg, fse);
}
}
use of org.apache.jackrabbit.core.fs.FileSystemException in project jackrabbit by apache.
the class ObjectPersistenceManager method load.
/**
* {@inheritDoc}
*/
public synchronized PropertyState load(PropertyId id) throws NoSuchItemStateException, ItemStateException {
if (!initialized) {
throw new IllegalStateException("not initialized");
}
String propFilePath = buildPropFilePath(id);
try {
if (!itemStateFS.isFile(propFilePath)) {
throw new NoSuchItemStateException(propFilePath);
}
} catch (FileSystemException fse) {
String msg = "failed to read property state: " + propFilePath;
log.debug(msg);
throw new ItemStateException(msg, fse);
}
try {
BufferedInputStream in = new BufferedInputStream(itemStateFS.getInputStream(propFilePath));
try {
PropertyState state = createNew(id);
Serializer.deserialize(state, in, blobStore);
return state;
} finally {
in.close();
}
} catch (Exception e) {
String msg = "failed to read property state: " + propFilePath;
log.debug(msg);
throw new ItemStateException(msg, e);
}
}
use of org.apache.jackrabbit.core.fs.FileSystemException in project jackrabbit by apache.
the class ObjectPersistenceManager method existsReferencesTo.
/**
* {@inheritDoc}
*/
public synchronized boolean existsReferencesTo(NodeId id) throws ItemStateException {
if (!initialized) {
throw new IllegalStateException("not initialized");
}
try {
String refsFilePath = buildNodeReferencesFilePath(id);
FileSystemResource refsFile = new FileSystemResource(itemStateFS, refsFilePath);
return refsFile.exists();
} catch (FileSystemException fse) {
String msg = "failed to check existence of references: " + id;
log.debug(msg);
throw new ItemStateException(msg, fse);
}
}
use of org.apache.jackrabbit.core.fs.FileSystemException in project jackrabbit by apache.
the class ObjectPersistenceManager method destroy.
/**
* {@inheritDoc}
*/
protected void destroy(NodeState state) throws ItemStateException {
if (!initialized) {
throw new IllegalStateException("not initialized");
}
String nodeFilePath = buildNodeFilePath(state.getNodeId());
FileSystemResource nodeFile = new FileSystemResource(itemStateFS, nodeFilePath);
try {
if (nodeFile.exists()) {
// delete resource and prune empty parent folders
nodeFile.delete(true);
}
} catch (FileSystemException fse) {
String msg = "failed to delete node state: " + state.getNodeId();
log.debug(msg);
throw new ItemStateException(msg, fse);
}
}
Aggregations