use of org.apache.jackrabbit.core.fs.FileSystemException in project jackrabbit by apache.
the class ObjectPersistenceManager method loadReferencesTo.
/**
* {@inheritDoc}
*/
public synchronized NodeReferences loadReferencesTo(NodeId id) throws NoSuchItemStateException, ItemStateException {
if (!initialized) {
throw new IllegalStateException("not initialized");
}
String refsFilePath = buildNodeReferencesFilePath(id);
try {
if (!itemStateFS.isFile(refsFilePath)) {
throw new NoSuchItemStateException(id.toString());
}
} catch (FileSystemException fse) {
String msg = "failed to load references: " + id;
log.debug(msg);
throw new ItemStateException(msg, fse);
}
try {
BufferedInputStream in = new BufferedInputStream(itemStateFS.getInputStream(refsFilePath));
try {
NodeReferences refs = new NodeReferences(id);
Serializer.deserialize(refs, in);
return refs;
} finally {
in.close();
}
} catch (Exception e) {
String msg = "failed to load references: " + id;
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 destroy.
/**
* {@inheritDoc}
*/
protected void destroy(NodeReferences refs) throws ItemStateException {
if (!initialized) {
throw new IllegalStateException("not initialized");
}
String refsFilePath = buildNodeReferencesFilePath(refs.getTargetId());
FileSystemResource refsFile = new FileSystemResource(itemStateFS, refsFilePath);
try {
if (refsFile.exists()) {
// delete resource and prune empty parent folders
refsFile.delete(true);
}
} catch (FileSystemException fse) {
String msg = "failed to delete " + refs;
log.debug(msg);
throw new ItemStateException(msg, fse);
}
}
use of org.apache.jackrabbit.core.fs.FileSystemException in project jackrabbit by apache.
the class PrivilegeRegistry method registerCustomDefinitions.
//---------------------------------------------< privilege registration >---
/**
* Register the specified custom privilege definitions.
*
* @param stubs
* @throws RepositoryException If an error occurs.
*/
private void registerCustomDefinitions(Map<Name, PrivilegeDefinition> stubs) throws RepositoryException {
if (customPrivilegesStore == null) {
throw new UnsupportedOperationException("No privilege store defined.");
}
synchronized (registeredPrivileges) {
Map<Name, Definition> definitions = createCustomDefinitions(stubs);
try {
// write the new custom privilege to the store and upon successful
// update of the file system resource add finally it to the map of
// registered privileges.
customPrivilegesStore.append(definitions);
cacheDefinitions(definitions);
} catch (IOException e) {
throw new RepositoryException("Failed to register custom privilegess.", e);
} catch (FileSystemException e) {
throw new RepositoryException("Failed to register custom privileges.", e);
} catch (ParseException e) {
throw new RepositoryException("Failed to register custom privileges.", e);
}
}
for (Listener l : listeners.keySet()) {
l.privilegesRegistered(stubs.keySet());
}
}
use of org.apache.jackrabbit.core.fs.FileSystemException in project jackrabbit by apache.
the class LockManagerImpl method save.
/**
* Write locks to locks file
*/
private void save() {
if (savingDisabled) {
return;
}
final ArrayList<LockInfo> list = new ArrayList<LockInfo>();
lockMap.traverse(new PathMap.ElementVisitor<LockInfo>() {
public void elementVisited(PathMap.Element<LockInfo> element) {
LockInfo info = element.get();
if (!info.isSessionScoped()) {
list.add(info);
}
}
}, false);
BufferedWriter writer = null;
try {
writer = new BufferedWriter(new OutputStreamWriter(locksFile.getOutputStream()));
for (LockInfo info : list) {
writer.write(info.getLockToken());
// Store the timeout hint, if one is specified
if (info.getTimeoutHint() != Long.MAX_VALUE) {
writer.write(',');
writer.write(Long.toString(info.getTimeoutHint()));
}
writer.newLine();
}
} catch (FileSystemException fse) {
log.warn("I/O error while saving locks to '" + locksFile.getPath() + "': " + fse.getMessage());
log.debug("Root cause: ", fse);
} catch (IOException ioe) {
log.warn("I/O error while saving locks to '" + locksFile.getPath() + "': " + ioe.getMessage());
log.debug("Root cause: ", ioe);
} finally {
IOUtils.closeQuietly(writer);
}
}
Aggregations