mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
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:
@@ -114,7 +114,7 @@
|
||||
<!-- Buffered Content Disk Driver - adds performance buffering -->
|
||||
<bean id="contentDiskDriver" class="org.alfresco.filesys.repo.BufferedContentDiskDriver"
|
||||
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="ioctlInterface"><ref bean="transactionalContentDiskDriver" /></property>
|
||||
<property name="fileInfoCache"> <ref bean="contentDiskDriver.fileInfoCache" /></property>
|
||||
@@ -158,8 +158,11 @@
|
||||
|
||||
</bean>
|
||||
|
||||
|
||||
<!-- File State Driver - adds JLAN'S file state stuff -->
|
||||
<bean name="fileStateDriver" class="org.alfresco.filesys.repo.LegacyFileStateDriver"
|
||||
init-method="init">
|
||||
<property name="diskInterface"><ref bean="ruleDriver" /></property>
|
||||
</bean>
|
||||
|
||||
<!-- Shuffle Disk Driver - adds rule evaluation to the disk driver -->
|
||||
@@ -169,7 +172,6 @@
|
||||
<property name="ruleEvaluator"><ref bean="ruleEvaluator" /></property>
|
||||
<property name="repositoryDiskInterface"><ref bean="transactionalContentDiskDriver" /></property>
|
||||
<property name="commandExecutor"><ref bean="filesystemCommandExecutor" /></property>
|
||||
<property name="callbackInterface"><ref bean="fileStateDriver" /></property>
|
||||
</bean>
|
||||
|
||||
<!-- Content Disk Driver transaction bean -->
|
||||
|
@@ -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,88 +34,80 @@ 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.
|
||||
* <p>
|
||||
* 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.
|
||||
* <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()
|
||||
{
|
||||
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 void closeFile(SrvSession sess, TreeConnection tree,
|
||||
NetworkFile param)
|
||||
public NetworkFile createFile(SrvSession sess, TreeConnection tree,
|
||||
FileOpenParams params) throws IOException
|
||||
{
|
||||
ContentContext tctx = (ContentContext) tree.getContext();
|
||||
|
||||
FileAccessToken token = null;
|
||||
|
||||
if(tctx.hasStateCache())
|
||||
{
|
||||
FileState fstate = tctx.getStateCache().findFileState( param.getFullName(), true);
|
||||
if ( fstate.decrementOpenCount() == 0)
|
||||
FileStateCache cache = tctx.getStateCache();
|
||||
FileState fstate = tctx.getStateCache().findFileState( params.getPath(), true);
|
||||
token = cache.grantFileAccess(params, fstate, FileStatus.NotExist);
|
||||
if(logger.isDebugEnabled())
|
||||
{
|
||||
fstate.setSharedAccess( SharingMode.READWRITE + SharingMode.DELETE);
|
||||
logger.debug("create file created lock token:" + token);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void createDirectory(SrvSession sess, TreeConnection tree,
|
||||
FileOpenParams params)
|
||||
try
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
NetworkFile newFile = diskInterface.createFile(sess, tree, params);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void createFile(SrvSession sess, TreeConnection tree,
|
||||
FileOpenParams params, NetworkFile newFile)
|
||||
{
|
||||
ContentContext tctx = (ContentContext) tree.getContext();
|
||||
|
||||
// TODO temp code - not of interest to the repo
|
||||
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())
|
||||
@@ -124,71 +119,87 @@ public class LegacyFileStateDriver implements ContentDiskCallback
|
||||
fstate.setProcessId( params.getProcessId());
|
||||
|
||||
// Indicate that the file is open
|
||||
fstate.setFileStatus(FileStatus.FileExists);
|
||||
fstate.incrementOpenCount();
|
||||
//fstate.setFilesystemObject(result.getSecond());
|
||||
fstate.setFileStatus(newFile.isDirectory()? FileStatus.DirectoryExists : FileStatus.FileExists);
|
||||
fstate.setAllocationSize( params.getAllocationSize());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteDirectory(SrvSession sess, TreeConnection tree, String dir)
|
||||
return newFile;
|
||||
|
||||
}
|
||||
catch(IOException ie)
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteFile(SrvSession sess, TreeConnection tree, String name)
|
||||
if(logger.isDebugEnabled())
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
logger.debug("create file exception caught", ie);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void flushFile(SrvSession sess, TreeConnection tree, NetworkFile file)
|
||||
if(tctx.hasStateCache() && token != null)
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void isReadOnly(SrvSession sess, DeviceContext ctx,
|
||||
boolean isReadOnly)
|
||||
FileStateCache cache = tctx.getStateCache();
|
||||
FileState fstate = tctx.getStateCache().findFileState( params.getPath(), false);
|
||||
if(fstate != null && token != null)
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
if(logger.isDebugEnabled())
|
||||
{
|
||||
logger.debug("create file release lock token:" + token);
|
||||
}
|
||||
cache.releaseFileAccess(fstate, token);
|
||||
}
|
||||
}
|
||||
throw ie;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void openFile(SrvSession sess, TreeConnection tree,
|
||||
FileOpenParams param, NetworkFile openFile)
|
||||
public NetworkFile openFile(SrvSession sess, TreeConnection tree,
|
||||
FileOpenParams params) throws IOException
|
||||
{
|
||||
ContentContext tctx = (ContentContext) tree.getContext();
|
||||
String path = param.getPath();
|
||||
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);
|
||||
|
||||
// Stuff to keep JLAN working - of no interest to the repo.
|
||||
if (openFile instanceof ContentNetworkFile)
|
||||
{
|
||||
ContentNetworkFile x = (ContentNetworkFile)openFile;
|
||||
x.setProcessId( param.getProcessId());
|
||||
x.setProcessId( params.getProcessId());
|
||||
x.setAccessToken(token);
|
||||
if(tctx.hasStateCache())
|
||||
{
|
||||
FileState fstate = tctx.getStateCache().findFileState( path, true);
|
||||
x.setFileState(fstate);
|
||||
fstate.incrementOpenCount();
|
||||
fstate.setProcessId(param.getProcessId());
|
||||
fstate.setProcessId(params.getProcessId());
|
||||
fstate.setFileStatus(FileStatus.FileExists);
|
||||
}
|
||||
}
|
||||
|
||||
if (openFile instanceof TempNetworkFile)
|
||||
{
|
||||
TempNetworkFile x = (TempNetworkFile)openFile;
|
||||
//x.setProcessId( param.getProcessId());
|
||||
x.setAccessToken(token);
|
||||
// x.setProcessId( params.getProcessId());
|
||||
if(tctx.hasStateCache())
|
||||
{
|
||||
FileState fstate = tctx.getStateCache().findFileState( path, true);
|
||||
x.setFileState(fstate);
|
||||
fstate.setFileStatus(FileStatus.FileExists);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -203,77 +214,190 @@ public class LegacyFileStateDriver implements ContentDiskCallback
|
||||
fstate.setFileStatus(FileStatus.DirectoryExists);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFile(SrvSession sess, TreeConnection tree,
|
||||
NetworkFile file, byte[] buf, int bufPos, int siz, long filePos,
|
||||
int readSize)
|
||||
return openFile;
|
||||
}
|
||||
catch(IOException ie)
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
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 renameFile(SrvSession sess, TreeConnection tree,
|
||||
String oldPath, String newPath)
|
||||
public void closeFile(SrvSession sess, TreeConnection tree,
|
||||
NetworkFile param) throws IOException
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
ContentContext tctx = (ContentContext) tree.getContext();
|
||||
|
||||
try
|
||||
{
|
||||
diskInterface.closeFile(sess, tree, param);
|
||||
|
||||
if(tctx.hasStateCache())
|
||||
{
|
||||
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);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void seekFile(SrvSession sess, TreeConnection tree,
|
||||
NetworkFile file, long pos, int typ) throws IOException
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
cache.releaseFileAccess(fstate, token);
|
||||
}
|
||||
|
||||
@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)
|
||||
catch(IOException ie)
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
if(logger.isDebugEnabled())
|
||||
{
|
||||
logger.debug("close file exception caught", ie);
|
||||
}
|
||||
throw ie;
|
||||
}
|
||||
|
||||
@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
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
@@ -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.
|
||||
@@ -81,14 +72,12 @@ public class NonTransactionalRuleContentDiskDriver implements ExtendedDiskInterf
|
||||
Map<String, EvaluatorContext> contextMap = new ConcurrentHashMap<String, EvaluatorContext>();
|
||||
}
|
||||
|
||||
// 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;
|
||||
}
|
||||
@@ -285,11 +253,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;
|
||||
}
|
||||
@@ -414,10 +366,6 @@ public class NonTransactionalRuleContentDiskDriver implements ExtendedDiskInterf
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@@ -167,11 +167,13 @@ public class ScenarioOpenFile implements Scenario
|
||||
if(instance instanceof ScenarioOpenFileInstance)
|
||||
{
|
||||
ScenarioOpenFileInstance i = (ScenarioOpenFileInstance)instance;
|
||||
if(i.getName() != null && name != null)
|
||||
{
|
||||
if(i.getName().equalsIgnoreCase(name));
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
|
Reference in New Issue
Block a user