use of org.apache.jackrabbit.core.fs.FileSystemException in project jackrabbit by apache.
the class XMLPersistenceManager 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 RetentionRegistryImpl method writeRetentionFile.
/**
* Write back the file system resource containing the node ids of those
* nodes containing holds and/or retention policies. Each node id is
* present only once.
*/
private void writeRetentionFile() {
final Set<NodeId> nodeIds = new HashSet<NodeId>();
// first look for nodes containing holds
holdMap.traverse(new PathMap.ElementVisitor<List<HoldImpl>>() {
public void elementVisited(PathMap.Element<List<HoldImpl>> element) {
List<HoldImpl> holds = element.get();
if (!holds.isEmpty()) {
nodeIds.add(holds.get(0).getNodeId());
}
}
}, false);
// then collect ids of nodes having an retention policy
retentionMap.traverse(new PathMap.ElementVisitor<RetentionPolicyImpl>() {
public void elementVisited(PathMap.Element<RetentionPolicyImpl> element) {
nodeIds.add(element.get().getNodeId());
}
}, false);
if (!nodeIds.isEmpty()) {
BufferedWriter writer = null;
try {
writer = new BufferedWriter(new OutputStreamWriter(retentionFile.getOutputStream()));
for (Iterator<NodeId> it = nodeIds.iterator(); it.hasNext(); ) {
writer.write(it.next().toString());
if (it.hasNext()) {
writer.newLine();
}
}
} catch (FileSystemException fse) {
log.error("Error while saving locks to '" + retentionFile.getPath() + "': " + fse.getMessage());
} catch (IOException ioe) {
log.error("Error while saving locks to '" + retentionFile.getPath() + "': " + ioe.getMessage());
} finally {
IOUtils.closeQuietly(writer);
}
}
}
use of org.apache.jackrabbit.core.fs.FileSystemException in project jackrabbit by apache.
the class MultiDataStore method init.
/**
* {@inheritDoc}
*/
public void init(String homeDir) throws RepositoryException {
if (delayedDelete) {
// First initialize the identifiersToDeleteFile
LocalFileSystem fileSystem = new LocalFileSystem();
fileSystem.setRoot(new File(homeDir));
identifiersToDeleteFile = new FileSystemResource(fileSystem, FileSystem.SEPARATOR + IDENTIFIERS_TO_DELETE_FILE_KEY);
}
moveDataTaskThread = new Thread(new MoveDataTask(), "Jackrabbit-MulitDataStore-MoveDataTaskThread");
moveDataTaskThread.setDaemon(true);
moveDataTaskThread.start();
log.info("MultiDataStore-MoveDataTask thread started; first run scheduled at " + moveDataTaskNextRun.getTime());
if (delayedDelete) {
try {
// delayedDeleteSleep timeout ...
if (identifiersToDeleteFile != null && identifiersToDeleteFile.exists() && (identifiersToDeleteFile.lastModified() + (delayedDeleteSleep * 1000)) < System.currentTimeMillis()) {
deleteDelayedIdentifiersTaskThread = new Thread(//Start immediately ...
new DeleteDelayedIdentifiersTask(0L), "Jackrabbit-MultiDataStore-DeleteDelayedIdentifiersTaskThread");
deleteDelayedIdentifiersTaskThread.setDaemon(true);
deleteDelayedIdentifiersTaskThread.start();
log.info("Old entries in the " + IDENTIFIERS_TO_DELETE_FILE_KEY + " File found. DeleteDelayedIdentifiersTask-Thread started now.");
}
} catch (FileSystemException e) {
throw new RepositoryException("I/O error while reading from '" + identifiersToDeleteFile.getPath() + "'", e);
}
}
}
use of org.apache.jackrabbit.core.fs.FileSystemException in project jackrabbit by apache.
the class LocalFileSystem method createFolder.
/**
* {@inheritDoc}
*/
public void createFolder(String folderPath) throws FileSystemException {
File f = new File(root, osPath(folderPath));
if (f.exists()) {
String msg = f.getPath() + " already exists";
log.debug(msg);
throw new FileSystemException(msg);
}
if (!f.mkdirs()) {
String msg = "failed to create folder " + f.getPath();
log.debug(msg);
throw new FileSystemException(msg);
}
}
use of org.apache.jackrabbit.core.fs.FileSystemException in project jackrabbit by apache.
the class LocalFileSystem method list.
/**
* {@inheritDoc}
*/
public String[] list(String folderPath) throws FileSystemException {
File f = new File(root, osPath(folderPath));
String[] entries = f.list();
if (entries == null) {
String msg = folderPath + " does not denote a folder";
log.debug(msg);
throw new FileSystemException(msg);
}
return entries;
}
Aggregations