diff --git a/source/java/org/alfresco/filesys/alfresco/AlfrescoContext.java b/source/java/org/alfresco/filesys/alfresco/AlfrescoContext.java index 90d78cd64a..7148e284cb 100644 --- a/source/java/org/alfresco/filesys/alfresco/AlfrescoContext.java +++ b/source/java/org/alfresco/filesys/alfresco/AlfrescoContext.java @@ -24,12 +24,21 @@ import java.util.StringTokenizer; import org.alfresco.error.AlfrescoRuntimeException; import org.alfresco.filesys.config.GlobalDesktopActionConfigBean; +import org.alfresco.filesys.config.ServerConfigurationBean; +import org.alfresco.jlan.server.config.CoreServerConfigSection; +import org.alfresco.jlan.server.config.InvalidConfigurationException; +import org.alfresco.jlan.server.core.DeviceContextException; import org.alfresco.jlan.server.filesys.DiskDeviceContext; import org.alfresco.jlan.server.filesys.DiskInterface; +import org.alfresco.jlan.server.filesys.DiskSharedDevice; import org.alfresco.jlan.server.filesys.FileSystem; +import org.alfresco.jlan.server.filesys.FilesystemsConfigSection; import org.alfresco.jlan.server.filesys.SrvDiskInfo; +import org.alfresco.jlan.server.filesys.cache.FileStateCache; +import org.alfresco.jlan.server.filesys.cache.StandaloneFileStateCache; import org.alfresco.jlan.server.filesys.pseudo.PseudoFileInterface; import org.alfresco.repo.admin.SysAdminParams; +import org.springframework.extensions.config.element.GenericConfigElement; /** * Alfresco Filesystem Context Class @@ -74,6 +83,10 @@ public abstract class AlfrescoContext extends DiskDeviceContext private IOControlHandler m_ioHandler; + // Server configuration + + private ServerConfigurationBean m_serverConfig; + // Debug flags // // Requires the logger to be enabled for debug output @@ -107,6 +120,15 @@ public abstract class AlfrescoContext extends DiskDeviceContext enableChangeHandler(!disableChangeNotification); } + /** + * Set the server configuration + * + * @param srvConfig ServerConfigurationBean + */ + public void setServerConfigurationBean( ServerConfigurationBean srvConfig) { + m_serverConfig = srvConfig; + } + /** * Complete initialization by registering with a disk driver */ @@ -424,4 +446,57 @@ public abstract class AlfrescoContext extends DiskDeviceContext { return (m_debug & flg) != 0 ? true : false; } + + /** + * Start the filesystem + * + * @param share DiskSharedDevice + * @exception DeviceContextException + */ + public void startFilesystem(DiskSharedDevice share) + throws DeviceContextException { + + // Call the base class + + super.startFilesystem(share); + } + + /** + * Enable the state cache + * + * @param ena boolean + */ + public void enableStateCache( boolean ena) { + + // Check if the server configuration has been set + + if ( m_serverConfig == null) + throw new AlfrescoRuntimeException( "Failed to set standalone file state cache for share " + getShareName()); + + // Check if we are enabling the state cache + + if ( ena == true && getStateCache() == null) { + + // Set the state cache, use a hard coded standalone cache for now + + FilesystemsConfigSection filesysConfig = (FilesystemsConfigSection) m_serverConfig.getConfigSection( FilesystemsConfigSection.SectionName); + + if ( filesysConfig != null) { + + try { + + // Create a standalone state cache + + StandaloneFileStateCache standaloneCache = new StandaloneFileStateCache(); + standaloneCache.initializeCache( new GenericConfigElement( ""), m_serverConfig); + + filesysConfig.addFileStateCache( getDeviceName(), standaloneCache); + setStateCache( standaloneCache); + } + catch ( InvalidConfigurationException ex) { + throw new AlfrescoRuntimeException( "Failed to initialize standalone state cache for " + getDeviceName()); + } + } + } + } } diff --git a/source/java/org/alfresco/filesys/alfresco/AlfrescoDiskDriver.java b/source/java/org/alfresco/filesys/alfresco/AlfrescoDiskDriver.java index 5376bfbcd3..b8959cd746 100644 --- a/source/java/org/alfresco/filesys/alfresco/AlfrescoDiskDriver.java +++ b/source/java/org/alfresco/filesys/alfresco/AlfrescoDiskDriver.java @@ -25,6 +25,7 @@ import javax.transaction.Status; import javax.transaction.UserTransaction; import org.alfresco.error.AlfrescoRuntimeException; +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; @@ -399,13 +400,25 @@ public abstract class AlfrescoDiskDriver implements IOCtlInterface, Transactiona * shares. In this base class, we initialize all desktop actions. * * @param ctx the context + * @param serverConfig ServerConfigurationBean * @exception DeviceContextException */ - public void registerContext(DeviceContext ctx) throws DeviceContextException + public void registerContext(DeviceContext ctx, ServerConfigurationBean serverConfig) throws DeviceContextException { if (ctx instanceof AlfrescoContext) { - ((AlfrescoContext) ctx).initialize(this); + // Enable a standalone state cache on the filesystem + + AlfrescoContext alfCtx = (AlfrescoContext) ctx; + + if ( serverConfig != null) { + alfCtx.setServerConfigurationBean( serverConfig); + alfCtx.enableStateCache( true); + } + + // Initialize the filesystem + + alfCtx.initialize(this); } } diff --git a/source/java/org/alfresco/filesys/alfresco/ExtendedDiskInterface.java b/source/java/org/alfresco/filesys/alfresco/ExtendedDiskInterface.java index d01f446985..e34530cf33 100644 --- a/source/java/org/alfresco/filesys/alfresco/ExtendedDiskInterface.java +++ b/source/java/org/alfresco/filesys/alfresco/ExtendedDiskInterface.java @@ -18,6 +18,7 @@ */ package org.alfresco.filesys.alfresco; +import org.alfresco.filesys.config.ServerConfigurationBean; import org.alfresco.jlan.server.core.DeviceContext; import org.alfresco.jlan.server.core.DeviceContextException; import org.alfresco.jlan.server.filesys.DiskInterface; @@ -33,7 +34,8 @@ public interface ExtendedDiskInterface extends DiskInterface * * @param context * the device context + * @param serverConfig ServerConfigurationBean * @exception DeviceContextException */ - public void registerContext(DeviceContext ctx) throws DeviceContextException; + public void registerContext(DeviceContext ctx, ServerConfigurationBean serverConfig) throws DeviceContextException; } diff --git a/source/java/org/alfresco/filesys/avm/AVMDiskDriver.java b/source/java/org/alfresco/filesys/avm/AVMDiskDriver.java index 3fb91f7c9f..fe1a835a62 100644 --- a/source/java/org/alfresco/filesys/avm/AVMDiskDriver.java +++ b/source/java/org/alfresco/filesys/avm/AVMDiskDriver.java @@ -28,6 +28,7 @@ import java.util.StringTokenizer; import javax.transaction.UserTransaction; import org.alfresco.filesys.alfresco.AlfrescoDiskDriver; +import org.alfresco.filesys.config.ServerConfigurationBean; import org.alfresco.jlan.server.SrvSession; import org.alfresco.jlan.server.auth.ClientInfo; import org.alfresco.jlan.server.core.DeviceContext; @@ -417,7 +418,7 @@ public class AVMDiskDriver extends AlfrescoDiskDriver implements DiskInterface } // Register the context bean - registerContext(context); + registerContext(context, null); // Return the context for this shared filesystem return context; @@ -428,13 +429,14 @@ public class AVMDiskDriver extends AlfrescoDiskDriver implements DiskInterface * device. * * @param context the device context + * @param serverConfig ServerConfigurationBean * @exception DeviceContextException */ @Override - public void registerContext(DeviceContext ctx) + public void registerContext(DeviceContext ctx, ServerConfigurationBean serverConfig) throws DeviceContextException { - super.registerContext(ctx); + super.registerContext(ctx, serverConfig); AVMContext context = (AVMContext)ctx; // Use the system user as the authenticated context for the filesystem initialization diff --git a/source/java/org/alfresco/filesys/config/ServerConfigurationBean.java b/source/java/org/alfresco/filesys/config/ServerConfigurationBean.java index 385850f565..d8eb596613 100644 --- a/source/java/org/alfresco/filesys/config/ServerConfigurationBean.java +++ b/source/java/org/alfresco/filesys/config/ServerConfigurationBean.java @@ -1627,7 +1627,7 @@ public class ServerConfigurationBean extends AbstractServerConfigurationBean // the new filesystem ExtendedDiskInterface filesysDriver = getAvmDiskInterface(); - filesysDriver.registerContext(filesystem); + filesysDriver.registerContext(filesystem, this); // Create the shared filesystem @@ -1656,7 +1656,7 @@ public class ServerConfigurationBean extends AbstractServerConfigurationBean ExtendedDiskInterface filesysDriver = getRepoDiskInterface(); ContentContext filesysContext = (ContentContext) filesystem; - filesysDriver.registerContext(filesystem); + filesysDriver.registerContext(filesystem, this); // Check if an access control list has been specified diff --git a/source/java/org/alfresco/filesys/repo/ContentContext.java b/source/java/org/alfresco/filesys/repo/ContentContext.java index 630dfd0969..3ece9b04cb 100644 --- a/source/java/org/alfresco/filesys/repo/ContentContext.java +++ b/source/java/org/alfresco/filesys/repo/ContentContext.java @@ -374,6 +374,9 @@ public class ContentContext extends AlfrescoContext // Call the base class super.startFilesystem(share); + + if ( getStateCache() != null) + getStateCache().setCaseSensitive( false); // Find the thread pool via the configuration diff --git a/source/java/org/alfresco/filesys/repo/ContentDiskDriver.java b/source/java/org/alfresco/filesys/repo/ContentDiskDriver.java index 24a29a59ce..17dcbd1709 100644 --- a/source/java/org/alfresco/filesys/repo/ContentDiskDriver.java +++ b/source/java/org/alfresco/filesys/repo/ContentDiskDriver.java @@ -39,6 +39,7 @@ import org.alfresco.error.AlfrescoRuntimeException; import org.alfresco.filesys.alfresco.AlfrescoContext; import org.alfresco.filesys.alfresco.AlfrescoDiskDriver; import org.alfresco.filesys.alfresco.AlfrescoNetworkFile; +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; @@ -590,7 +591,7 @@ public class ContentDiskDriver extends AlfrescoDiskDriver implements DiskInterfa // Register the device context - registerContext(context); + registerContext(context, null); // Return the context for this shared filesystem @@ -606,13 +607,14 @@ public class ContentDiskDriver extends AlfrescoDiskDriver implements DiskInterfa * WARNING: side effect, will commit or roll back current user transaction context. * * @param ctx the context + * @param serverConfig ServerConfigurationBean * @exception DeviceContextException */ // MER TODO - transaction handling in registerContext needs changing @Override - public void registerContext(DeviceContext ctx) throws DeviceContextException + public void registerContext(DeviceContext ctx, ServerConfigurationBean serverConfig) throws DeviceContextException { - super.registerContext(ctx); + super.registerContext(ctx, serverConfig); ContentContext context = (ContentContext)ctx; @@ -750,7 +752,6 @@ public class ContentDiskDriver extends AlfrescoDiskDriver implements DiskInterfa // Enable file state caching context.enableStateCache( true); - context.getStateCache().setCaseSensitive( false); // Initialize the I/O control handler diff --git a/source/java/org/alfresco/filesys/repo/LinkMemoryNetworkFile.java b/source/java/org/alfresco/filesys/repo/LinkMemoryNetworkFile.java index 3d1b1e78aa..50456190ef 100644 --- a/source/java/org/alfresco/filesys/repo/LinkMemoryNetworkFile.java +++ b/source/java/org/alfresco/filesys/repo/LinkMemoryNetworkFile.java @@ -23,6 +23,7 @@ import java.io.IOException; import org.alfresco.jlan.server.filesys.FileInfo; import org.alfresco.jlan.server.filesys.cache.FileState; +import org.alfresco.jlan.server.filesys.cache.LocalFileState; import org.alfresco.jlan.smb.SeekType; import org.alfresco.service.cmr.repository.NodeRef; @@ -261,7 +262,7 @@ public class LinkMemoryNetworkFile extends NodeRefNetworkFile // Create a dummy file state if ( super.getFileState() == null) - setFileState(new FileState(getFullName(), false)); + setFileState(new LocalFileState(getFullName(), false)); return super.getFileState(); } }