From 44065362f329bc426fcef0ac5fd25ee33f3489dc Mon Sep 17 00:00:00 2001 From: Mark Rogers Date: Tue, 9 Aug 2011 11:44:34 +0000 Subject: [PATCH] Content Disk Driver 2 : Implementation of "Lock Tokens" git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@29629 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261 --- .../default/network-protocol-context.xml | 8 +- .../filesys/repo/LegacyFileStateDriver.java | 520 +++++++++++------- ...NonTransactionalRuleContentDiskDriver.java | 130 +---- .../filesys/repo/rules/ScenarioOpenFile.java | 8 +- 4 files changed, 353 insertions(+), 313 deletions(-) diff --git a/config/alfresco/subsystems/fileServers/default/network-protocol-context.xml b/config/alfresco/subsystems/fileServers/default/network-protocol-context.xml index 2ed23eb235..137def01b5 100644 --- a/config/alfresco/subsystems/fileServers/default/network-protocol-context.xml +++ b/config/alfresco/subsystems/fileServers/default/network-protocol-context.xml @@ -114,7 +114,7 @@ - + @@ -158,9 +158,12 @@ + + - + + - diff --git a/source/java/org/alfresco/filesys/repo/LegacyFileStateDriver.java b/source/java/org/alfresco/filesys/repo/LegacyFileStateDriver.java index 12e9d50acf..35b95a9951 100644 --- a/source/java/org/alfresco/filesys/repo/LegacyFileStateDriver.java +++ b/source/java/org/alfresco/filesys/repo/LegacyFileStateDriver.java @@ -18,12 +18,15 @@ */ package org.alfresco.filesys.repo; +import java.io.FileNotFoundException; import java.io.IOException; +import org.alfresco.filesys.alfresco.ExtendedDiskInterface; import org.alfresco.filesys.config.ServerConfigurationBean; import org.alfresco.jlan.server.SrvSession; import org.alfresco.jlan.server.core.DeviceContext; import org.alfresco.jlan.server.core.DeviceContextException; +import org.alfresco.jlan.server.filesys.FileAccessToken; import org.alfresco.jlan.server.filesys.FileInfo; import org.alfresco.jlan.server.filesys.FileOpenParams; import org.alfresco.jlan.server.filesys.FileStatus; @@ -31,249 +34,370 @@ import org.alfresco.jlan.server.filesys.NetworkFile; import org.alfresco.jlan.server.filesys.SearchContext; import org.alfresco.jlan.server.filesys.TreeConnection; import org.alfresco.jlan.server.filesys.cache.FileState; +import org.alfresco.jlan.server.filesys.cache.FileStateCache; import org.alfresco.jlan.smb.SharingMode; +import org.alfresco.util.PropertyCheck; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.springframework.extensions.config.ConfigElement; /** * The Legacy file state driver is used to update JLAN's file state cache. *

- * This class contains odds and ends to keep JLan happy. In particular it - * cannot contain any code that requires access to the alfresco repository. + * This class decorates an ExtendedDiskInterface with odds and ends to keep JLan happy. + *

+ * In particular this implementation cannot contain any code that requires access to the + * alfresco repository. * */ -public class LegacyFileStateDriver implements ContentDiskCallback +public class LegacyFileStateDriver implements ExtendedDiskInterface { + private ExtendedDiskInterface diskInterface; public void init() { + PropertyCheck.mandatory(this, "diskInterface", diskInterface); } - - @Override - public void getFileInformation(SrvSession sess, TreeConnection tree, - String path, FileInfo info) - { - // TODO Auto-generated method stub - - } - - @Override - public void fileExists(SrvSession sess, TreeConnection tree, String path, - int fileExists) - { - // TODO Auto-generated method stub - - } + + private static final Log logger = LogFactory.getLog(NonTransactionalRuleContentDiskDriver.class); @Override public void treeOpened(SrvSession sess, TreeConnection tree) { - // TODO Auto-generated method stub + diskInterface.treeOpened(sess, tree); } @Override public void treeClosed(SrvSession sess, TreeConnection tree) { - // TODO Auto-generated method stub - + diskInterface.treeClosed(sess, tree); } + @Override + public NetworkFile createFile(SrvSession sess, TreeConnection tree, + FileOpenParams params) throws IOException + { + ContentContext tctx = (ContentContext) tree.getContext(); + + FileAccessToken token = null; + + if(tctx.hasStateCache()) + { + FileStateCache cache = tctx.getStateCache(); + FileState fstate = tctx.getStateCache().findFileState( params.getPath(), true); + token = cache.grantFileAccess(params, fstate, FileStatus.NotExist); + if(logger.isDebugEnabled()) + { + logger.debug("create file created lock token:" + token); + } + } + + try + { + NetworkFile newFile = diskInterface.createFile(sess, tree, params); + + if (newFile instanceof NodeRefNetworkFile) + { + NodeRefNetworkFile x = (NodeRefNetworkFile)newFile; + x.setProcessId( params.getProcessId()); + x.setAccessToken(token); + } + + if (newFile instanceof TempNetworkFile) + { + TempNetworkFile x = (TempNetworkFile)newFile; + x.setAccessToken(token); + } + + if(tctx.hasStateCache()) + { + FileState fstate = tctx.getStateCache().findFileState( params.getPath(), true); + fstate.incrementOpenCount(); + fstate.setProcessId(params.getProcessId()); + fstate.setSharedAccess( params.getSharedAccess()); + fstate.setProcessId( params.getProcessId()); + + // Indicate that the file is open + fstate.setFileStatus(newFile.isDirectory()? FileStatus.DirectoryExists : FileStatus.FileExists); + fstate.setAllocationSize( params.getAllocationSize()); + } + + return newFile; + + } + catch(IOException ie) + { + if(logger.isDebugEnabled()) + { + logger.debug("create file exception caught", ie); + } + if(tctx.hasStateCache() && token != null) + { + FileStateCache cache = tctx.getStateCache(); + FileState fstate = tctx.getStateCache().findFileState( params.getPath(), false); + if(fstate != null && token != null) + { + if(logger.isDebugEnabled()) + { + logger.debug("create file release lock token:" + token); + } + cache.releaseFileAccess(fstate, token); + } + } + throw ie; + } + } + + @Override + public NetworkFile openFile(SrvSession sess, TreeConnection tree, + FileOpenParams params) throws IOException + { + ContentContext tctx = (ContentContext) tree.getContext(); + String path = params.getPath(); + + FileAccessToken token = null; + + if(tctx.hasStateCache()) + { + if(!params.isDirectory()) + { + FileStateCache cache = tctx.getStateCache(); + FileState fstate = tctx.getStateCache().findFileState( params.getPath(), true); + token = cache.grantFileAccess(params, fstate, FileStatus.Unknown); + if(logger.isDebugEnabled()) + { + logger.debug("open file created lock token:" + token); + } + } + } + + try + { + NetworkFile openFile = diskInterface.openFile(sess, tree, params); + + if (openFile instanceof ContentNetworkFile) + { + ContentNetworkFile x = (ContentNetworkFile)openFile; + x.setProcessId( params.getProcessId()); + x.setAccessToken(token); + if(tctx.hasStateCache()) + { + FileState fstate = tctx.getStateCache().findFileState( path, true); + x.setFileState(fstate); + fstate.setProcessId(params.getProcessId()); + fstate.setFileStatus(FileStatus.FileExists); + } + } + + if (openFile instanceof TempNetworkFile) + { + TempNetworkFile x = (TempNetworkFile)openFile; + x.setAccessToken(token); + // x.setProcessId( params.getProcessId()); + if(tctx.hasStateCache()) + { + FileState fstate = tctx.getStateCache().findFileState( path, true); + x.setFileState(fstate); + fstate.setFileStatus(FileStatus.FileExists); + } + } + + if (openFile instanceof AlfrescoFolder) + { + AlfrescoFolder x = (AlfrescoFolder)openFile; + //x.setProcessId( param.getProcessId()); + if(tctx.hasStateCache()) + { + FileState fstate = tctx.getStateCache().findFileState( path, true); + x.setFileState(fstate); + fstate.setFileStatus(FileStatus.DirectoryExists); + } + } + + return openFile; + } + catch(IOException ie) + { + if(logger.isDebugEnabled()) + { + logger.debug("open file exception caught", ie); + } + if(tctx.hasStateCache() && token != null) + { + FileStateCache cache = tctx.getStateCache(); + FileState fstate = tctx.getStateCache().findFileState( params.getPath(), false); + if(fstate != null) + { + if(logger.isDebugEnabled()) + { + logger.debug("open file release lock token:" + token); + } + cache.releaseFileAccess(fstate, token); + } + } + throw ie; + } + + } + @Override public void closeFile(SrvSession sess, TreeConnection tree, - NetworkFile param) - { - ContentContext tctx = (ContentContext) tree.getContext(); - - if(tctx.hasStateCache()) - { - FileState fstate = tctx.getStateCache().findFileState( param.getFullName(), true); - if ( fstate.decrementOpenCount() == 0) - { - fstate.setSharedAccess( SharingMode.READWRITE + SharingMode.DELETE); - } - } - - } - - @Override - public void createDirectory(SrvSession sess, TreeConnection tree, - FileOpenParams params) - { - // TODO Auto-generated method stub - - } - - @Override - public void createFile(SrvSession sess, TreeConnection tree, - FileOpenParams params, NetworkFile newFile) + NetworkFile param) throws IOException { ContentContext tctx = (ContentContext) tree.getContext(); - // TODO temp code - not of interest to the repo - if (newFile instanceof NodeRefNetworkFile) + try { - NodeRefNetworkFile x = (NodeRefNetworkFile)newFile; - x.setProcessId( params.getProcessId()); - } - - if(tctx.hasStateCache()) - { - FileState fstate = tctx.getStateCache().findFileState( params.getPath(), true); - fstate.incrementOpenCount(); - fstate.setProcessId(params.getProcessId()); - fstate.setSharedAccess( params.getSharedAccess()); - fstate.setProcessId( params.getProcessId()); - - // Indicate that the file is open - fstate.setFileStatus(FileStatus.FileExists); - fstate.incrementOpenCount(); - //fstate.setFilesystemObject(result.getSecond()); - fstate.setAllocationSize( params.getAllocationSize()); - } - } + diskInterface.closeFile(sess, tree, param); - @Override - public void deleteDirectory(SrvSession sess, TreeConnection tree, String dir) - { - // TODO Auto-generated method stub - - } - - @Override - public void deleteFile(SrvSession sess, TreeConnection tree, String name) - { - // TODO Auto-generated method stub - - } - - @Override - public void flushFile(SrvSession sess, TreeConnection tree, NetworkFile file) - { - // TODO Auto-generated method stub - - } - - @Override - public void isReadOnly(SrvSession sess, DeviceContext ctx, - boolean isReadOnly) - { - // TODO Auto-generated method stub - - } - - @Override - public void openFile(SrvSession sess, TreeConnection tree, - FileOpenParams param, NetworkFile openFile) - { - ContentContext tctx = (ContentContext) tree.getContext(); - String path = param.getPath(); - - // Stuff to keep JLAN working - of no interest to the repo. - if (openFile instanceof ContentNetworkFile) - { - ContentNetworkFile x = (ContentNetworkFile)openFile; - x.setProcessId( param.getProcessId()); if(tctx.hasStateCache()) { - FileState fstate = tctx.getStateCache().findFileState( path, true); - x.setFileState(fstate); - fstate.incrementOpenCount(); - fstate.setProcessId(param.getProcessId()); + FileStateCache cache = tctx.getStateCache(); + FileState fstate = cache.findFileState( param.getFullName(), true); + if(fstate != null && param.getAccessToken() != null) + { + FileAccessToken token = param.getAccessToken(); + if(logger.isDebugEnabled() && token != null) + { + logger.debug("close file release lock token:" + token); + } + cache.releaseFileAccess(fstate, token); + } } } - - if (openFile instanceof TempNetworkFile) + catch(IOException ie) { - TempNetworkFile x = (TempNetworkFile)openFile; - //x.setProcessId( param.getProcessId()); - if(tctx.hasStateCache()) + if(logger.isDebugEnabled()) { - FileState fstate = tctx.getStateCache().findFileState( path, true); - x.setFileState(fstate); - } - } - - if (openFile instanceof AlfrescoFolder) - { - AlfrescoFolder x = (AlfrescoFolder)openFile; - //x.setProcessId( param.getProcessId()); - if(tctx.hasStateCache()) - { - FileState fstate = tctx.getStateCache().findFileState( path, true); - x.setFileState(fstate); - fstate.setFileStatus(FileStatus.DirectoryExists); - } - } - } - - @Override - public void readFile(SrvSession sess, TreeConnection tree, - NetworkFile file, byte[] buf, int bufPos, int siz, long filePos, - int readSize) - { - // TODO Auto-generated method stub - - } - - @Override - public void renameFile(SrvSession sess, TreeConnection tree, - String oldPath, String newPath) - { - // TODO Auto-generated method stub - - } - - @Override - public void seekFile(SrvSession sess, TreeConnection tree, - NetworkFile file, long pos, int typ) throws IOException - { - // TODO Auto-generated method stub - - } - - @Override - public void setFileInformation(SrvSession sess, TreeConnection tree, - String name, FileInfo info) throws IOException - { - // TODO Auto-generated method stub - - } - - @Override - public void startSearch(SrvSession sess, TreeConnection tree, - String searchPath, int attrib, SearchContext context) - { - // TODO Auto-generated method stub - - } - - @Override - public void truncateFile(SrvSession sess, TreeConnection tree, - NetworkFile file, long siz) - { - // TODO Auto-generated method stub - - } - - @Override - public void writeFile(SrvSession sess, TreeConnection tree, - NetworkFile file, byte[] buf, int bufoff, int siz, long fileoff, - int writeSize) - { - // TODO Auto-generated method stub - + logger.debug("close file exception caught", ie); + } + throw ie; + } } @Override public void registerContext(DeviceContext ctx, ServerConfigurationBean serverConfig) throws DeviceContextException { - // TODO Auto-generated method stub - + diskInterface.registerContext(ctx, serverConfig); } - + public void setDiskInterface(ExtendedDiskInterface diskInterface) + { + this.diskInterface = diskInterface; + } - - + public ExtendedDiskInterface getDiskInterface() + { + return diskInterface; + } + + @Override + public void createDirectory(SrvSession sess, TreeConnection tree, + FileOpenParams params) throws IOException + { + diskInterface.createDirectory(sess, tree, params); + } + + @Override + public void deleteDirectory(SrvSession sess, TreeConnection tree, String dir) + throws IOException + { + diskInterface.deleteDirectory(sess, tree, dir); + } + + @Override + public void deleteFile(SrvSession sess, TreeConnection tree, String name) + throws IOException + { + diskInterface.deleteFile(sess, tree, name); + } + + @Override + public int fileExists(SrvSession sess, TreeConnection tree, String name) + { + return diskInterface.fileExists(sess, tree, name); + } + + @Override + public void flushFile(SrvSession sess, TreeConnection tree, NetworkFile file) + throws IOException + { + diskInterface.flushFile(sess, tree, file); + } + + @Override + public FileInfo getFileInformation(SrvSession sess, TreeConnection tree, + String name) throws IOException + { + return diskInterface.getFileInformation(sess, tree, name); + } + + @Override + public boolean isReadOnly(SrvSession sess, DeviceContext ctx) + throws IOException + { + return diskInterface.isReadOnly(sess, ctx); + } + + @Override + public int readFile(SrvSession sess, TreeConnection tree, NetworkFile file, + byte[] buf, int bufPos, int siz, long filePos) throws IOException + { + return diskInterface.readFile(sess, tree, file, buf, bufPos, siz, filePos); + } + + @Override + public void renameFile(SrvSession sess, TreeConnection tree, + String oldName, String newName) throws IOException + { + diskInterface.renameFile(sess, tree, oldName, newName); + } + + @Override + public long seekFile(SrvSession sess, TreeConnection tree, + NetworkFile file, long pos, int typ) throws IOException + { + return diskInterface.seekFile(sess, tree, file, pos, typ); + } + + @Override + public void setFileInformation(SrvSession sess, TreeConnection tree, + String name, FileInfo info) throws IOException + { + diskInterface.setFileInformation(sess, tree, name, info); + } + + @Override + public SearchContext startSearch(SrvSession sess, TreeConnection tree, + String searchPath, int attrib) throws FileNotFoundException + { + return diskInterface.startSearch(sess, tree, searchPath, attrib); + + } + + @Override + public void truncateFile(SrvSession sess, TreeConnection tree, + NetworkFile file, long siz) throws IOException + { + diskInterface.truncateFile(sess, tree, file, siz); + } + + @Override + public int writeFile(SrvSession sess, TreeConnection tree, + NetworkFile file, byte[] buf, int bufoff, int siz, long fileoff) + throws IOException + { + return diskInterface.writeFile(sess, tree, file, buf, bufoff, siz, fileoff); + } + + @Override + public DeviceContext createContext(String shareName, ConfigElement args) + throws DeviceContextException + { + + return diskInterface.createContext(shareName, args); + } } \ No newline at end of file diff --git a/source/java/org/alfresco/filesys/repo/NonTransactionalRuleContentDiskDriver.java b/source/java/org/alfresco/filesys/repo/NonTransactionalRuleContentDiskDriver.java index 1a460fb12b..a0d5311b46 100644 --- a/source/java/org/alfresco/filesys/repo/NonTransactionalRuleContentDiskDriver.java +++ b/source/java/org/alfresco/filesys/repo/NonTransactionalRuleContentDiskDriver.java @@ -27,38 +27,29 @@ import org.alfresco.filesys.alfresco.ExtendedDiskInterface; import org.alfresco.filesys.alfresco.RepositoryDiskInterface; import org.alfresco.filesys.config.ServerConfigurationBean; import org.alfresco.filesys.repo.rules.Command; +import org.alfresco.filesys.repo.rules.EvaluatorContext; import org.alfresco.filesys.repo.rules.Operation; import org.alfresco.filesys.repo.rules.RuleEvaluator; +import org.alfresco.filesys.repo.rules.operations.CloseFileOperation; +import org.alfresco.filesys.repo.rules.operations.CreateFileOperation; +import org.alfresco.filesys.repo.rules.operations.DeleteFileOperation; +import org.alfresco.filesys.repo.rules.operations.OpenFileOperation; +import org.alfresco.filesys.repo.rules.operations.RenameFileOperation; import org.alfresco.jlan.server.SrvSession; import org.alfresco.jlan.server.core.DeviceContext; import org.alfresco.jlan.server.core.DeviceContextException; -import org.alfresco.jlan.server.filesys.AccessMode; import org.alfresco.jlan.server.filesys.FileInfo; import org.alfresco.jlan.server.filesys.FileName; import org.alfresco.jlan.server.filesys.FileOpenParams; -import org.alfresco.jlan.server.filesys.FileStatus; import org.alfresco.jlan.server.filesys.NetworkFile; import org.alfresco.jlan.server.filesys.SearchContext; import org.alfresco.jlan.server.filesys.TreeConnection; -import org.alfresco.jlan.server.filesys.cache.FileState; -import org.alfresco.jlan.server.filesys.cache.NetworkFileStateInterface; import org.alfresco.jlan.smb.SharingMode; import org.alfresco.service.cmr.repository.NodeRef; import org.alfresco.util.PropertyCheck; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.apache.ibatis.annotations.Case; import org.springframework.extensions.config.ConfigElement; -import org.alfresco.filesys.repo.rules.EvaluatorContext; -import org.alfresco.filesys.repo.rules.commands.CompoundCommand; -import org.alfresco.filesys.repo.rules.commands.CopyContentCommand; -import org.alfresco.filesys.repo.rules.commands.RenameFileCommand; -import org.alfresco.filesys.repo.rules.operations.CloseFileOperation; -import org.alfresco.filesys.repo.rules.operations.CreateFileOperation; -import org.alfresco.filesys.repo.rules.operations.DeleteFileOperation; -import org.alfresco.filesys.repo.rules.operations.MoveFileOperation; -import org.alfresco.filesys.repo.rules.operations.OpenFileOperation; -import org.alfresco.filesys.repo.rules.operations.RenameFileOperation; /** * Non Transactional DiskDriver with rules engine. @@ -80,15 +71,13 @@ public class NonTransactionalRuleContentDiskDriver implements ExtendedDiskInterf */ Map contextMap = new ConcurrentHashMap(); } - - // Logging + private static final Log logger = LogFactory.getLog(NonTransactionalRuleContentDiskDriver.class); private ExtendedDiskInterface diskInterface; private RuleEvaluator ruleEvaluator; private RepositoryDiskInterface repositoryDiskInterface; private CommandExecutor commandExecutor; - private ContentDiskCallback callbackInterface; public void init() { @@ -102,12 +91,12 @@ public class NonTransactionalRuleContentDiskDriver implements ExtendedDiskInterf public FileInfo getFileInformation(SrvSession sess, TreeConnection tree, String path) throws IOException { + if(logger.isDebugEnabled()) + { + logger.debug("getFileInformation:" + path); + } FileInfo info = diskInterface.getFileInformation(sess, tree, path); - if(getCallbackInterface() != null) - { - getCallbackInterface().getFileInformation(sess, tree, path, info); - } return info; } @@ -115,10 +104,7 @@ public class NonTransactionalRuleContentDiskDriver implements ExtendedDiskInterf public int fileExists(SrvSession sess, TreeConnection tree, String path) { int fileExists = diskInterface.fileExists(sess, tree, path); - if(getCallbackInterface() != null) - { - getCallbackInterface().fileExists(sess, tree, path, fileExists); - } + return fileExists; } @@ -133,10 +119,6 @@ public class NonTransactionalRuleContentDiskDriver implements ExtendedDiskInterf public void treeOpened(SrvSession sess, TreeConnection tree) { diskInterface.treeOpened(sess, tree); - if(getCallbackInterface() != null) - { - getCallbackInterface().treeOpened(sess, tree); - } } @Override @@ -144,10 +126,6 @@ public class NonTransactionalRuleContentDiskDriver implements ExtendedDiskInterf { diskInterface.treeClosed(sess, tree); - if(getCallbackInterface() != null) - { - getCallbackInterface().treeClosed(sess, tree); - } } @Override @@ -184,10 +162,6 @@ public class NonTransactionalRuleContentDiskDriver implements ExtendedDiskInterf commandExecutor.execute(sess, tree, c); - if(getCallbackInterface() != null) - { - getCallbackInterface().closeFile(sess, tree, param); - } } @Override @@ -196,10 +170,6 @@ public class NonTransactionalRuleContentDiskDriver implements ExtendedDiskInterf { diskInterface.createDirectory(sess, tree, params); - if(getCallbackInterface() != null) - { - getCallbackInterface().createDirectory(sess, tree, params); - } } @Override @@ -249,6 +219,8 @@ public class NonTransactionalRuleContentDiskDriver implements ExtendedDiskInterf ContentContext tctx = (ContentContext) tree.getContext(); NodeRef rootNode = tctx.getRootNode(); + + String[] paths = FileName.splitPath(params.getPath()); String folder = paths[0]; String file = paths[1]; @@ -263,10 +235,6 @@ public class NonTransactionalRuleContentDiskDriver implements ExtendedDiskInterf if(ret != null && ret instanceof NetworkFile) { - if(getCallbackInterface() != null) - { - getCallbackInterface().createFile(sess, tree, params, (NetworkFile)ret); - } return (NetworkFile)ret; } @@ -284,11 +252,6 @@ public class NonTransactionalRuleContentDiskDriver implements ExtendedDiskInterf { diskInterface.deleteDirectory(sess, tree, dir); - - if(getCallbackInterface() != null) - { - getCallbackInterface().deleteDirectory(sess, tree, dir); - } } @@ -317,10 +280,6 @@ public class NonTransactionalRuleContentDiskDriver implements ExtendedDiskInterf Command c = ruleEvaluator.evaluate(ctx, o); commandExecutor.execute(sess, tree, c); - if(getCallbackInterface() != null) - { - getCallbackInterface().deleteFile(sess, tree, name); - } } // End of deleteFile @@ -329,10 +288,7 @@ public class NonTransactionalRuleContentDiskDriver implements ExtendedDiskInterf throws IOException { diskInterface.flushFile(sess, tree, file); - if(getCallbackInterface() != null) - { - getCallbackInterface().flushFile(sess, tree, file); - } + } @Override @@ -340,10 +296,6 @@ public class NonTransactionalRuleContentDiskDriver implements ExtendedDiskInterf throws IOException { boolean isReadOnly = diskInterface.isReadOnly(sess, ctx); - if(getCallbackInterface() != null) - { - getCallbackInterface().isReadOnly(sess, ctx, isReadOnly); - } return isReadOnly; } @@ -407,17 +359,13 @@ public class NonTransactionalRuleContentDiskDriver implements ExtendedDiskInterf boolean writeAccess = param.isReadWriteAccess(); boolean truncate = param.isOverwrite(); - + Operation o = new OpenFileOperation(file, writeAccess, truncate, rootNode, path); Command c = ruleEvaluator.evaluate(ctx, o); Object ret = commandExecutor.execute(sess, tree, c); if(ret != null && ret instanceof NetworkFile) { - if(getCallbackInterface() != null) - { - getCallbackInterface().openFile(sess, tree, param, (NetworkFile)ret); - } if(logger.isDebugEnabled()) { @@ -440,12 +388,6 @@ public class NonTransactionalRuleContentDiskDriver implements ExtendedDiskInterf byte[] buf, int bufPos, int siz, long filePos) throws IOException { int readSize = diskInterface.readFile(sess, tree, file, buf, bufPos, siz, filePos); - - if(getCallbackInterface() != null) - { - getCallbackInterface().readFile(sess, tree, file, buf, bufPos, siz, filePos, readSize); - } - return readSize; } @@ -498,10 +440,7 @@ public class NonTransactionalRuleContentDiskDriver implements ExtendedDiskInterf diskInterface.renameFile(sess, tree, oldPath, newPath); } - if(getCallbackInterface() != null) - { - getCallbackInterface().renameFile(sess, tree, oldPath, newPath); - } + } @Override @@ -509,10 +448,7 @@ public class NonTransactionalRuleContentDiskDriver implements ExtendedDiskInterf NetworkFile file, long pos, int typ) throws IOException { long ret = diskInterface.seekFile(sess, tree, file, pos, typ); - if(getCallbackInterface() != null) - { - getCallbackInterface().seekFile(sess, tree, file, pos, typ); - } + return ret; } @@ -522,10 +458,7 @@ public class NonTransactionalRuleContentDiskDriver implements ExtendedDiskInterf String name, FileInfo info) throws IOException { diskInterface.setFileInformation(sess, tree, name, info); - if(getCallbackInterface() != null) - { - getCallbackInterface().setFileInformation(sess, tree, name, info); - } + } @Override @@ -533,10 +466,7 @@ public class NonTransactionalRuleContentDiskDriver implements ExtendedDiskInterf String searchPath, int attrib) throws FileNotFoundException { SearchContext context = diskInterface.startSearch(sess, tree, searchPath, attrib); - if(getCallbackInterface() != null) - { - getCallbackInterface().startSearch(sess, tree, searchPath, attrib, context); - } + return context; } @@ -545,10 +475,7 @@ public class NonTransactionalRuleContentDiskDriver implements ExtendedDiskInterf NetworkFile file, long siz) throws IOException { diskInterface.truncateFile(sess, tree, file, siz); - if(getCallbackInterface() != null) - { - getCallbackInterface().truncateFile(sess, tree, file, siz); - } + } @Override @@ -557,10 +484,6 @@ public class NonTransactionalRuleContentDiskDriver implements ExtendedDiskInterf throws IOException { int writeSize = diskInterface.writeFile(sess, tree, file, buf, bufoff, siz, fileoff); - if(getCallbackInterface() != null) - { - getCallbackInterface().writeFile(sess, tree, file, buf, bufoff, siz, fileoff, writeSize); - } return writeSize; } @@ -620,7 +543,6 @@ public class NonTransactionalRuleContentDiskDriver implements ExtendedDiskInterf */ private DriverState getDriverState(SrvSession sess) { - synchronized (sess) { // Get the driver state @@ -664,16 +586,6 @@ public class NonTransactionalRuleContentDiskDriver implements ExtendedDiskInterf } } - public void setCallbackInterface(ContentDiskCallback callbackInterface) - { - this.callbackInterface = callbackInterface; - } - - public ContentDiskCallback getCallbackInterface() - { - return callbackInterface; - } - } \ No newline at end of file diff --git a/source/java/org/alfresco/filesys/repo/rules/ScenarioOpenFile.java b/source/java/org/alfresco/filesys/repo/rules/ScenarioOpenFile.java index ab871edf97..ce3e0bd571 100644 --- a/source/java/org/alfresco/filesys/repo/rules/ScenarioOpenFile.java +++ b/source/java/org/alfresco/filesys/repo/rules/ScenarioOpenFile.java @@ -167,11 +167,13 @@ public class ScenarioOpenFile implements Scenario if(instance instanceof ScenarioOpenFileInstance) { ScenarioOpenFileInstance i = (ScenarioOpenFileInstance)instance; - if(i.getName().equalsIgnoreCase(name)); + if(i.getName() != null && name != null) { - return true; + if(i.getName().equalsIgnoreCase(name)); + { + return true; + } } - } } return false;