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
This commit is contained in:
Mark Rogers
2011-08-09 11:44:34 +00:00
parent 6dbe542032
commit 44065362f3
4 changed files with 353 additions and 313 deletions

View File

@@ -114,7 +114,7 @@
<!-- Buffered Content Disk Driver - adds performance buffering --> <!-- Buffered Content Disk Driver - adds performance buffering -->
<bean id="contentDiskDriver" class="org.alfresco.filesys.repo.BufferedContentDiskDriver" <bean id="contentDiskDriver" class="org.alfresco.filesys.repo.BufferedContentDiskDriver"
init-method="init"> init-method="init">
<property name="diskInterface"><ref bean="ruleDriver" /></property> <property name="diskInterface"><ref bean="fileStateDriver" /></property>
<property name="diskSizeInterface"><ref bean="transactionalContentDiskDriver" /></property> <property name="diskSizeInterface"><ref bean="transactionalContentDiskDriver" /></property>
<property name="ioctlInterface"><ref bean="transactionalContentDiskDriver" /></property> <property name="ioctlInterface"><ref bean="transactionalContentDiskDriver" /></property>
<property name="fileInfoCache"> <ref bean="contentDiskDriver.fileInfoCache" /></property> <property name="fileInfoCache"> <ref bean="contentDiskDriver.fileInfoCache" /></property>
@@ -158,9 +158,12 @@
</bean> </bean>
<!-- File State Driver - adds JLAN'S file state stuff -->
<bean name="fileStateDriver" class="org.alfresco.filesys.repo.LegacyFileStateDriver" <bean name="fileStateDriver" class="org.alfresco.filesys.repo.LegacyFileStateDriver"
init-method="init"> init-method="init">
</bean> <property name="diskInterface"><ref bean="ruleDriver" /></property>
</bean>
<!-- Shuffle Disk Driver - adds rule evaluation to the disk driver --> <!-- Shuffle Disk Driver - adds rule evaluation to the disk driver -->
<bean id="ruleDriver" class="org.alfresco.filesys.repo.NonTransactionalRuleContentDiskDriver" <bean id="ruleDriver" class="org.alfresco.filesys.repo.NonTransactionalRuleContentDiskDriver"
@@ -169,7 +172,6 @@
<property name="ruleEvaluator"><ref bean="ruleEvaluator" /></property> <property name="ruleEvaluator"><ref bean="ruleEvaluator" /></property>
<property name="repositoryDiskInterface"><ref bean="transactionalContentDiskDriver" /></property> <property name="repositoryDiskInterface"><ref bean="transactionalContentDiskDriver" /></property>
<property name="commandExecutor"><ref bean="filesystemCommandExecutor" /></property> <property name="commandExecutor"><ref bean="filesystemCommandExecutor" /></property>
<property name="callbackInterface"><ref bean="fileStateDriver" /></property>
</bean> </bean>
<!-- Content Disk Driver transaction bean --> <!-- Content Disk Driver transaction bean -->

View File

@@ -18,12 +18,15 @@
*/ */
package org.alfresco.filesys.repo; package org.alfresco.filesys.repo;
import java.io.FileNotFoundException;
import java.io.IOException; import java.io.IOException;
import org.alfresco.filesys.alfresco.ExtendedDiskInterface;
import org.alfresco.filesys.config.ServerConfigurationBean; import org.alfresco.filesys.config.ServerConfigurationBean;
import org.alfresco.jlan.server.SrvSession; import org.alfresco.jlan.server.SrvSession;
import org.alfresco.jlan.server.core.DeviceContext; import org.alfresco.jlan.server.core.DeviceContext;
import org.alfresco.jlan.server.core.DeviceContextException; 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.FileInfo;
import org.alfresco.jlan.server.filesys.FileOpenParams; import org.alfresco.jlan.server.filesys.FileOpenParams;
import org.alfresco.jlan.server.filesys.FileStatus; 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.SearchContext;
import org.alfresco.jlan.server.filesys.TreeConnection; import org.alfresco.jlan.server.filesys.TreeConnection;
import org.alfresco.jlan.server.filesys.cache.FileState; 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.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. * The Legacy file state driver is used to update JLAN's file state cache.
* <p> * <p>
* This class contains odds and ends to keep JLan happy. In particular it * This class decorates an ExtendedDiskInterface with odds and ends to keep JLan happy.
* cannot contain any code that requires access to the alfresco repository. * <p>
* 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() public void init()
{ {
PropertyCheck.mandatory(this, "diskInterface", diskInterface);
} }
@Override private static final Log logger = LogFactory.getLog(NonTransactionalRuleContentDiskDriver.class);
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
}
@Override @Override
public void treeOpened(SrvSession sess, TreeConnection tree) public void treeOpened(SrvSession sess, TreeConnection tree)
{ {
// TODO Auto-generated method stub diskInterface.treeOpened(sess, tree);
} }
@Override @Override
public void treeClosed(SrvSession sess, TreeConnection tree) 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 @Override
public void closeFile(SrvSession sess, TreeConnection tree, public void closeFile(SrvSession sess, TreeConnection tree,
NetworkFile param) NetworkFile param) throws IOException
{
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)
{ {
ContentContext tctx = (ContentContext) tree.getContext(); ContentContext tctx = (ContentContext) tree.getContext();
// TODO temp code - not of interest to the repo try
if (newFile instanceof NodeRefNetworkFile)
{ {
NodeRefNetworkFile x = (NodeRefNetworkFile)newFile; diskInterface.closeFile(sess, tree, param);
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());
}
}
@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()) if(tctx.hasStateCache())
{ {
FileState fstate = tctx.getStateCache().findFileState( path, true); FileStateCache cache = tctx.getStateCache();
x.setFileState(fstate); FileState fstate = cache.findFileState( param.getFullName(), true);
fstate.incrementOpenCount(); if(fstate != null && param.getAccessToken() != null)
fstate.setProcessId(param.getProcessId()); {
FileAccessToken token = param.getAccessToken();
if(logger.isDebugEnabled() && token != null)
{
logger.debug("close file release lock token:" + token);
}
cache.releaseFileAccess(fstate, token);
}
} }
} }
catch(IOException ie)
if (openFile instanceof TempNetworkFile)
{ {
TempNetworkFile x = (TempNetworkFile)openFile; if(logger.isDebugEnabled())
//x.setProcessId( param.getProcessId());
if(tctx.hasStateCache())
{ {
FileState fstate = tctx.getStateCache().findFileState( path, true); logger.debug("close file exception caught", ie);
x.setFileState(fstate); }
} throw ie;
} }
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
} }
@Override @Override
public void registerContext(DeviceContext ctx, public void registerContext(DeviceContext ctx,
ServerConfigurationBean serverConfig) throws DeviceContextException 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);
}
} }

View File

@@ -27,38 +27,29 @@ import org.alfresco.filesys.alfresco.ExtendedDiskInterface;
import org.alfresco.filesys.alfresco.RepositoryDiskInterface; import org.alfresco.filesys.alfresco.RepositoryDiskInterface;
import org.alfresco.filesys.config.ServerConfigurationBean; import org.alfresco.filesys.config.ServerConfigurationBean;
import org.alfresco.filesys.repo.rules.Command; 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.Operation;
import org.alfresco.filesys.repo.rules.RuleEvaluator; 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.SrvSession;
import org.alfresco.jlan.server.core.DeviceContext; import org.alfresco.jlan.server.core.DeviceContext;
import org.alfresco.jlan.server.core.DeviceContextException; 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.FileInfo;
import org.alfresco.jlan.server.filesys.FileName; import org.alfresco.jlan.server.filesys.FileName;
import org.alfresco.jlan.server.filesys.FileOpenParams; 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.NetworkFile;
import org.alfresco.jlan.server.filesys.SearchContext; import org.alfresco.jlan.server.filesys.SearchContext;
import org.alfresco.jlan.server.filesys.TreeConnection; 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.jlan.smb.SharingMode;
import org.alfresco.service.cmr.repository.NodeRef; import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.util.PropertyCheck; import org.alfresco.util.PropertyCheck;
import org.apache.commons.logging.Log; import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory; import org.apache.commons.logging.LogFactory;
import org.apache.ibatis.annotations.Case;
import org.springframework.extensions.config.ConfigElement; 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. * Non Transactional DiskDriver with rules engine.
@@ -80,15 +71,13 @@ public class NonTransactionalRuleContentDiskDriver implements ExtendedDiskInterf
*/ */
Map<String, EvaluatorContext> contextMap = new ConcurrentHashMap<String, EvaluatorContext>(); Map<String, EvaluatorContext> contextMap = new ConcurrentHashMap<String, EvaluatorContext>();
} }
// Logging
private static final Log logger = LogFactory.getLog(NonTransactionalRuleContentDiskDriver.class); private static final Log logger = LogFactory.getLog(NonTransactionalRuleContentDiskDriver.class);
private ExtendedDiskInterface diskInterface; private ExtendedDiskInterface diskInterface;
private RuleEvaluator ruleEvaluator; private RuleEvaluator ruleEvaluator;
private RepositoryDiskInterface repositoryDiskInterface; private RepositoryDiskInterface repositoryDiskInterface;
private CommandExecutor commandExecutor; private CommandExecutor commandExecutor;
private ContentDiskCallback callbackInterface;
public void init() public void init()
{ {
@@ -102,12 +91,12 @@ public class NonTransactionalRuleContentDiskDriver implements ExtendedDiskInterf
public FileInfo getFileInformation(SrvSession sess, TreeConnection tree, public FileInfo getFileInformation(SrvSession sess, TreeConnection tree,
String path) throws IOException String path) throws IOException
{ {
if(logger.isDebugEnabled())
{
logger.debug("getFileInformation:" + path);
}
FileInfo info = diskInterface.getFileInformation(sess, tree, path); FileInfo info = diskInterface.getFileInformation(sess, tree, path);
if(getCallbackInterface() != null)
{
getCallbackInterface().getFileInformation(sess, tree, path, info);
}
return info; return info;
} }
@@ -115,10 +104,7 @@ public class NonTransactionalRuleContentDiskDriver implements ExtendedDiskInterf
public int fileExists(SrvSession sess, TreeConnection tree, String path) public int fileExists(SrvSession sess, TreeConnection tree, String path)
{ {
int fileExists = diskInterface.fileExists(sess, tree, path); int fileExists = diskInterface.fileExists(sess, tree, path);
if(getCallbackInterface() != null)
{
getCallbackInterface().fileExists(sess, tree, path, fileExists);
}
return fileExists; return fileExists;
} }
@@ -133,10 +119,6 @@ public class NonTransactionalRuleContentDiskDriver implements ExtendedDiskInterf
public void treeOpened(SrvSession sess, TreeConnection tree) public void treeOpened(SrvSession sess, TreeConnection tree)
{ {
diskInterface.treeOpened(sess, tree); diskInterface.treeOpened(sess, tree);
if(getCallbackInterface() != null)
{
getCallbackInterface().treeOpened(sess, tree);
}
} }
@Override @Override
@@ -144,10 +126,6 @@ public class NonTransactionalRuleContentDiskDriver implements ExtendedDiskInterf
{ {
diskInterface.treeClosed(sess, tree); diskInterface.treeClosed(sess, tree);
if(getCallbackInterface() != null)
{
getCallbackInterface().treeClosed(sess, tree);
}
} }
@Override @Override
@@ -184,10 +162,6 @@ public class NonTransactionalRuleContentDiskDriver implements ExtendedDiskInterf
commandExecutor.execute(sess, tree, c); commandExecutor.execute(sess, tree, c);
if(getCallbackInterface() != null)
{
getCallbackInterface().closeFile(sess, tree, param);
}
} }
@Override @Override
@@ -196,10 +170,6 @@ public class NonTransactionalRuleContentDiskDriver implements ExtendedDiskInterf
{ {
diskInterface.createDirectory(sess, tree, params); diskInterface.createDirectory(sess, tree, params);
if(getCallbackInterface() != null)
{
getCallbackInterface().createDirectory(sess, tree, params);
}
} }
@Override @Override
@@ -249,6 +219,8 @@ public class NonTransactionalRuleContentDiskDriver implements ExtendedDiskInterf
ContentContext tctx = (ContentContext) tree.getContext(); ContentContext tctx = (ContentContext) tree.getContext();
NodeRef rootNode = tctx.getRootNode(); NodeRef rootNode = tctx.getRootNode();
String[] paths = FileName.splitPath(params.getPath()); String[] paths = FileName.splitPath(params.getPath());
String folder = paths[0]; String folder = paths[0];
String file = paths[1]; String file = paths[1];
@@ -263,10 +235,6 @@ public class NonTransactionalRuleContentDiskDriver implements ExtendedDiskInterf
if(ret != null && ret instanceof NetworkFile) if(ret != null && ret instanceof NetworkFile)
{ {
if(getCallbackInterface() != null)
{
getCallbackInterface().createFile(sess, tree, params, (NetworkFile)ret);
}
return (NetworkFile)ret; return (NetworkFile)ret;
} }
@@ -284,11 +252,6 @@ public class NonTransactionalRuleContentDiskDriver implements ExtendedDiskInterf
{ {
diskInterface.deleteDirectory(sess, tree, dir); 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); Command c = ruleEvaluator.evaluate(ctx, o);
commandExecutor.execute(sess, tree, c); commandExecutor.execute(sess, tree, c);
if(getCallbackInterface() != null)
{
getCallbackInterface().deleteFile(sess, tree, name);
}
} // End of deleteFile } // End of deleteFile
@@ -329,10 +288,7 @@ public class NonTransactionalRuleContentDiskDriver implements ExtendedDiskInterf
throws IOException throws IOException
{ {
diskInterface.flushFile(sess, tree, file); diskInterface.flushFile(sess, tree, file);
if(getCallbackInterface() != null)
{
getCallbackInterface().flushFile(sess, tree, file);
}
} }
@Override @Override
@@ -340,10 +296,6 @@ public class NonTransactionalRuleContentDiskDriver implements ExtendedDiskInterf
throws IOException throws IOException
{ {
boolean isReadOnly = diskInterface.isReadOnly(sess, ctx); boolean isReadOnly = diskInterface.isReadOnly(sess, ctx);
if(getCallbackInterface() != null)
{
getCallbackInterface().isReadOnly(sess, ctx, isReadOnly);
}
return isReadOnly; return isReadOnly;
} }
@@ -407,17 +359,13 @@ public class NonTransactionalRuleContentDiskDriver implements ExtendedDiskInterf
boolean writeAccess = param.isReadWriteAccess(); boolean writeAccess = param.isReadWriteAccess();
boolean truncate = param.isOverwrite(); boolean truncate = param.isOverwrite();
Operation o = new OpenFileOperation(file, writeAccess, truncate, rootNode, path); Operation o = new OpenFileOperation(file, writeAccess, truncate, rootNode, path);
Command c = ruleEvaluator.evaluate(ctx, o); Command c = ruleEvaluator.evaluate(ctx, o);
Object ret = commandExecutor.execute(sess, tree, c); Object ret = commandExecutor.execute(sess, tree, c);
if(ret != null && ret instanceof NetworkFile) if(ret != null && ret instanceof NetworkFile)
{ {
if(getCallbackInterface() != null)
{
getCallbackInterface().openFile(sess, tree, param, (NetworkFile)ret);
}
if(logger.isDebugEnabled()) if(logger.isDebugEnabled())
{ {
@@ -440,12 +388,6 @@ public class NonTransactionalRuleContentDiskDriver implements ExtendedDiskInterf
byte[] buf, int bufPos, int siz, long filePos) throws IOException byte[] buf, int bufPos, int siz, long filePos) throws IOException
{ {
int readSize = diskInterface.readFile(sess, tree, file, buf, bufPos, siz, filePos); 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; return readSize;
} }
@@ -498,10 +440,7 @@ public class NonTransactionalRuleContentDiskDriver implements ExtendedDiskInterf
diskInterface.renameFile(sess, tree, oldPath, newPath); diskInterface.renameFile(sess, tree, oldPath, newPath);
} }
if(getCallbackInterface() != null)
{
getCallbackInterface().renameFile(sess, tree, oldPath, newPath);
}
} }
@Override @Override
@@ -509,10 +448,7 @@ public class NonTransactionalRuleContentDiskDriver implements ExtendedDiskInterf
NetworkFile file, long pos, int typ) throws IOException NetworkFile file, long pos, int typ) throws IOException
{ {
long ret = diskInterface.seekFile(sess, tree, file, pos, typ); long ret = diskInterface.seekFile(sess, tree, file, pos, typ);
if(getCallbackInterface() != null)
{
getCallbackInterface().seekFile(sess, tree, file, pos, typ);
}
return ret; return ret;
} }
@@ -522,10 +458,7 @@ public class NonTransactionalRuleContentDiskDriver implements ExtendedDiskInterf
String name, FileInfo info) throws IOException String name, FileInfo info) throws IOException
{ {
diskInterface.setFileInformation(sess, tree, name, info); diskInterface.setFileInformation(sess, tree, name, info);
if(getCallbackInterface() != null)
{
getCallbackInterface().setFileInformation(sess, tree, name, info);
}
} }
@Override @Override
@@ -533,10 +466,7 @@ public class NonTransactionalRuleContentDiskDriver implements ExtendedDiskInterf
String searchPath, int attrib) throws FileNotFoundException String searchPath, int attrib) throws FileNotFoundException
{ {
SearchContext context = diskInterface.startSearch(sess, tree, searchPath, attrib); SearchContext context = diskInterface.startSearch(sess, tree, searchPath, attrib);
if(getCallbackInterface() != null)
{
getCallbackInterface().startSearch(sess, tree, searchPath, attrib, context);
}
return context; return context;
} }
@@ -545,10 +475,7 @@ public class NonTransactionalRuleContentDiskDriver implements ExtendedDiskInterf
NetworkFile file, long siz) throws IOException NetworkFile file, long siz) throws IOException
{ {
diskInterface.truncateFile(sess, tree, file, siz); diskInterface.truncateFile(sess, tree, file, siz);
if(getCallbackInterface() != null)
{
getCallbackInterface().truncateFile(sess, tree, file, siz);
}
} }
@Override @Override
@@ -557,10 +484,6 @@ public class NonTransactionalRuleContentDiskDriver implements ExtendedDiskInterf
throws IOException throws IOException
{ {
int writeSize = diskInterface.writeFile(sess, tree, file, buf, bufoff, siz, fileoff); 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; return writeSize;
} }
@@ -620,7 +543,6 @@ public class NonTransactionalRuleContentDiskDriver implements ExtendedDiskInterf
*/ */
private DriverState getDriverState(SrvSession sess) private DriverState getDriverState(SrvSession sess)
{ {
synchronized (sess) synchronized (sess)
{ {
// Get the driver state // 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;
}
} }

View File

@@ -167,11 +167,13 @@ public class ScenarioOpenFile implements Scenario
if(instance instanceof ScenarioOpenFileInstance) if(instance instanceof ScenarioOpenFileInstance)
{ {
ScenarioOpenFileInstance i = (ScenarioOpenFileInstance)instance; 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; return false;