use of org.alfresco.jlan.server.filesys.cache.FileState in project alfresco-repository by Alfresco.
the class LegacyFileStateDriver method renameFile.
@Override
public void renameFile(SrvSession sess, TreeConnection tree, String oldName, String newName) throws IOException {
ContentContext tctx = (ContentContext) tree.getContext();
diskInterface.renameFile(sess, tree, oldName, newName);
if (tctx.hasStateCache()) {
FileStateCache cache = tctx.getStateCache();
FileState fstate = cache.findFileState(oldName, false);
if (fstate != null) {
if (logger.isDebugEnabled()) {
logger.debug("rename file state from:" + oldName + ", to:" + newName);
}
cache.renameFileState(newName, fstate, fstate.isDirectory());
}
}
}
use of org.alfresco.jlan.server.filesys.cache.FileState in project alfresco-repository by Alfresco.
the class LegacyFileStateDriver method deleteFile.
@Override
public void deleteFile(SrvSession sess, TreeConnection tree, String name) throws IOException {
ContentContext tctx = (ContentContext) tree.getContext();
diskInterface.deleteFile(sess, tree, name);
if (tctx.hasStateCache()) {
FileStateCache cache = tctx.getStateCache();
FileState fstate = cache.findFileState(name, false);
if (fstate != null) {
fstate.setFileStatus(FileStatus.NotExist);
fstate.setOpenCount(0);
}
}
}
use of org.alfresco.jlan.server.filesys.cache.FileState in project alfresco-repository by Alfresco.
the class NodeMonitor method processMoveNode.
/**
* Process a node move event
*
* @param moveEvent MoveNodeEvent
*/
private final void processMoveNode(MoveNodeEvent moveEvent) {
// Strip the root path
String fromPath = moveEvent.getFromPath().substring(m_rootPath.length()).replace('/', '\\');
String toPath = moveEvent.getToPath().substring(m_rootPath.length()).replace('/', '\\');
if (logger.isDebugEnabled())
logger.debug("MoveNode fromPath=" + fromPath + ", toPath=" + toPath);
if (m_stateTable != null) {
// Check if there is file state for the orginal file/folder
FileState fState = m_stateTable.findFileState(fromPath);
if (fState != null && fState.exists() == true) {
// Mark the file/folder as no longer existing
fState.setFileStatus(FileStatus.NotExist);
if (logger.isDebugEnabled())
logger.debug("MoveNode updated state for fromPath=" + fromPath);
}
// Check if there is a file state for the destination file/folder
fState = m_stateTable.findFileState(toPath);
if (fState != null && fState.exists() == false) {
if (moveEvent.getFileType() == FileFolderServiceType.FILE)
fState.setFileStatus(FileStatus.FileExists);
else
fState.setFileStatus(FileStatus.DirectoryExists);
if (logger.isDebugEnabled())
logger.debug("MoveNode updated state for toPath=" + toPath);
}
}
if (m_filesysCtx.hasChangeHandler()) {
if (m_filesysCtx.getChangeHandler().getGlobalNotifyMask() != 0) {
// Send a file renamed event to the change notification handler
m_filesysCtx.getChangeHandler().notifyRename(fromPath, toPath);
if (logger.isDebugEnabled())
logger.debug("MoveNode queued change notification");
}
}
}
use of org.alfresco.jlan.server.filesys.cache.FileState in project alfresco-repository by Alfresco.
the class NodeMonitor method processDeleteNode.
/**
* Process a node delete event
*
* @param deleteEvent DeleteNodeEvent
*/
private final void processDeleteNode(DeleteNodeEvent deleteEvent) {
// Check if the delete was confirmed
// if ( deleteEvent.hasDeleteConfirm() == false) {
//
// // DEBUG
//
// if ( logger.isDebugEnabled())
// logger.debug("DeleteNode not confirmed, nodeRef=" + deleteEvent.getNodeRef() + ", path=" + deleteEvent.getPath());
//
// return;
// }
// Strip the root path
String relPath = deleteEvent.getPath().substring(m_rootPath.length()).replace('/', '\\');
if (logger.isDebugEnabled())
logger.debug("DeleteNode nodeRef=" + deleteEvent.getNodeRef() + ", path=" + relPath);
if (m_stateTable != null) {
// Check if there is file state for this file
FileState fState = m_stateTable.findFileState(relPath);
if (fState != null && fState.exists() == true) {
// Mark the file/folder as no longer existing
fState.setFileStatus(FileStatus.NotExist);
fState.setAllocationSize(0);
fState.setOpenCount(0);
if (logger.isDebugEnabled())
logger.debug("DeleteNode updated file state - " + fState);
}
}
if (m_filesysCtx.hasChangeHandler()) {
if (m_filesysCtx.getChangeHandler().getGlobalNotifyMask() != 0) {
if (deleteEvent.getFileType() == FileFolderServiceType.FILE)
m_filesysCtx.getChangeHandler().notifyFileChanged(NotifyChange.ActionRemoved, relPath);
else
m_filesysCtx.getChangeHandler().notifyDirectoryChanged(NotifyChange.ActionRemoved, relPath);
if (logger.isDebugEnabled())
logger.debug("DeleteNode queued change notification");
}
}
}
use of org.alfresco.jlan.server.filesys.cache.FileState in project alfresco-repository by Alfresco.
the class NodeMonitor method processCreateNode.
/**
* Process a create node event
*
* @param createEvent CreateNodeEvent
*/
private final void processCreateNode(CreateNodeEvent createEvent) {
// Get the full path to the file/folder node
String relPath = createEvent.getRelPath();
String name = createEvent.getName();
if (relPath.startsWith(m_rootPath)) {
if (logger.isDebugEnabled())
logger.debug("CreateNode nodeRef=" + createEvent.getNodeRef() + ", fName=" + name + ", path=" + relPath);
// Build the full file path
StringBuilder fullPath = new StringBuilder();
fullPath.append(relPath.substring(m_rootPath.length()));
fullPath.append("/");
fullPath.append(name);
relPath = fullPath.toString();
if (m_stateTable != null) {
// Check if there is file state for this file
FileState fState = m_stateTable.findFileState(relPath);
if (fState != null && fState.exists() == false) {
if (createEvent.getFileType() == FileFolderServiceType.FILE)
fState.setFileStatus(FileStatus.FileExists);
else
fState.setFileStatus(FileStatus.DirectoryExists);
if (logger.isDebugEnabled())
logger.debug("CreateNode updated file state - " + fState);
}
}
if (m_filesysCtx.hasChangeHandler()) {
if (m_filesysCtx.getChangeHandler().getGlobalNotifyMask() != 0) {
if (createEvent.getFileType() == FileFolderServiceType.FILE)
m_filesysCtx.getChangeHandler().notifyFileChanged(NotifyChange.ActionAdded, relPath);
else
m_filesysCtx.getChangeHandler().notifyDirectoryChanged(NotifyChange.ActionAdded, relPath);
if (logger.isDebugEnabled())
logger.debug("CreateNode queued change notification");
}
}
} else {
if (logger.isDebugEnabled())
logger.debug("CreateNode ignored nodeRef=" + createEvent.getNodeRef() + ", path=" + relPath);
}
}
Aggregations