Search in sources :

Example 16 with FileState

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());
        }
    }
}
Also used : FileStateCache(org.alfresco.jlan.server.filesys.cache.FileStateCache) FileState(org.alfresco.jlan.server.filesys.cache.FileState)

Example 17 with FileState

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);
        }
    }
}
Also used : FileStateCache(org.alfresco.jlan.server.filesys.cache.FileStateCache) FileState(org.alfresco.jlan.server.filesys.cache.FileState)

Example 18 with FileState

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");
        }
    }
}
Also used : FileState(org.alfresco.jlan.server.filesys.cache.FileState)

Example 19 with FileState

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");
        }
    }
}
Also used : FileState(org.alfresco.jlan.server.filesys.cache.FileState)

Example 20 with FileState

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);
    }
}
Also used : FileState(org.alfresco.jlan.server.filesys.cache.FileState)

Aggregations

FileState (org.alfresco.jlan.server.filesys.cache.FileState)28 IOException (java.io.IOException)14 ContentIOException (org.alfresco.service.cmr.repository.ContentIOException)12 NodeRef (org.alfresco.service.cmr.repository.NodeRef)12 AlfrescoRuntimeException (org.alfresco.error.AlfrescoRuntimeException)10 AccessDeniedException (org.alfresco.jlan.server.filesys.AccessDeniedException)9 FileNotFoundException (java.io.FileNotFoundException)8 FileStateCache (org.alfresco.jlan.server.filesys.cache.FileStateCache)8 FileInfo (org.alfresco.jlan.server.filesys.FileInfo)6 Date (java.util.Date)5 DirectoryNotEmptyException (org.alfresco.jlan.server.filesys.DirectoryNotEmptyException)4 QuotaManager (org.alfresco.jlan.server.filesys.quota.QuotaManager)4 Pair (org.alfresco.util.Pair)4 NetworkFileLegacyReferenceCount (org.alfresco.filesys.alfresco.NetworkFileLegacyReferenceCount)3 DiskFullException (org.alfresco.jlan.server.filesys.DiskFullException)3 FileAccessToken (org.alfresco.jlan.server.filesys.FileAccessToken)3 FileExistsException (org.alfresco.jlan.server.filesys.FileExistsException)3 FileSharingException (org.alfresco.jlan.server.filesys.FileSharingException)3 NetworkFile (org.alfresco.jlan.server.filesys.NetworkFile)3 NodeLockedException (org.alfresco.service.cmr.lock.NodeLockedException)3