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);
}
}
use of org.apache.jackrabbit.core.fs.FileSystemException in project jackrabbit by apache.
the class XMLPersistenceManager method destroy.
/**
* {@inheritDoc}
*/
protected void destroy(PropertyState state) throws ItemStateException {
if (!initialized) {
throw new IllegalStateException("not initialized");
}
// delete binary values (stored as files)
InternalValue[] values = state.getValues();
if (values != null) {
for (int i = 0; i < values.length; i++) {
InternalValue val = values[i];
if (val != null) {
val.deleteBinaryResource();
}
}
}
// delete property file
String propFilePath = buildPropFilePath(state.getPropertyId());
FileSystemResource propFile = new FileSystemResource(itemStateFS, propFilePath);
try {
if (propFile.exists()) {
// delete resource and prune empty parent folders
propFile.delete(true);
}
} catch (FileSystemException fse) {
String msg = "failed to delete property state: " + state.getParentId() + "/" + state.getName();
log.debug(msg);
throw new ItemStateException(msg, fse);
}
}
use of org.apache.jackrabbit.core.fs.FileSystemException in project jackrabbit by apache.
the class XMLPersistenceManager method load.
/**
* {@inheritDoc}
*/
public synchronized PropertyState load(PropertyId id) throws NoSuchItemStateException, ItemStateException {
if (!initialized) {
throw new IllegalStateException("not initialized");
}
Exception e = null;
String propFilePath = buildPropFilePath(id);
try {
if (!itemStateFS.isFile(propFilePath)) {
throw new NoSuchItemStateException(id.toString());
}
InputStream in = itemStateFS.getInputStream(propFilePath);
try {
DOMWalker walker = new DOMWalker(in);
PropertyState state = createNew(id);
readState(walker, state);
return state;
} finally {
in.close();
}
} catch (IOException ioe) {
e = ioe;
// fall through
} catch (FileSystemException fse) {
e = fse;
// fall through
}
String msg = "failed to read property state: " + id.toString();
log.debug(msg);
throw new ItemStateException(msg, e);
}
use of org.apache.jackrabbit.core.fs.FileSystemException in project jackrabbit by apache.
the class XMLPersistenceManager method destroy.
/**
* {@inheritDoc}
*/
protected void destroy(NodeState state) throws ItemStateException {
if (!initialized) {
throw new IllegalStateException("not initialized");
}
NodeId id = state.getNodeId();
String nodeFilePath = buildNodeFilePath(id);
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: " + id;
log.debug(msg);
throw new ItemStateException(msg, fse);
}
}
Aggregations