mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-24 17:32:48 +00:00
Added filtering out of workflow and author sandboxes from the CIFS virtualization view. Added the <showAllSandboxes/> config
item to switch off filtering. WCM-273. git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@4992 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -17,6 +17,8 @@
|
|||||||
|
|
||||||
package org.alfresco.filesys.avm;
|
package org.alfresco.filesys.avm;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
import org.alfresco.filesys.alfresco.AlfrescoContext;
|
import org.alfresco.filesys.alfresco.AlfrescoContext;
|
||||||
import org.alfresco.filesys.alfresco.IOControlHandler;
|
import org.alfresco.filesys.alfresco.IOControlHandler;
|
||||||
import org.alfresco.filesys.server.filesys.DiskInterface;
|
import org.alfresco.filesys.server.filesys.DiskInterface;
|
||||||
@@ -29,6 +31,9 @@ import org.alfresco.repo.avm.CreateStoreCallback;
|
|||||||
import org.alfresco.repo.avm.CreateVersionCallback;
|
import org.alfresco.repo.avm.CreateVersionCallback;
|
||||||
import org.alfresco.repo.avm.PurgeStoreCallback;
|
import org.alfresco.repo.avm.PurgeStoreCallback;
|
||||||
import org.alfresco.repo.avm.PurgeVersionCallback;
|
import org.alfresco.repo.avm.PurgeVersionCallback;
|
||||||
|
import org.alfresco.repo.domain.PropertyValue;
|
||||||
|
import org.alfresco.service.namespace.NamespaceService;
|
||||||
|
import org.alfresco.service.namespace.QName;
|
||||||
import org.apache.commons.logging.Log;
|
import org.apache.commons.logging.Log;
|
||||||
import org.apache.commons.logging.LogFactory;
|
import org.apache.commons.logging.LogFactory;
|
||||||
|
|
||||||
@@ -52,7 +57,12 @@ public class AVMContext extends AlfrescoContext
|
|||||||
|
|
||||||
public static final int VERSION_HEAD = -1;
|
public static final int VERSION_HEAD = -1;
|
||||||
|
|
||||||
// Store, root path and version
|
// Store properties
|
||||||
|
|
||||||
|
public static QName PROP_WORKFLOWPREVIEW = QName.createQName(NamespaceService.DEFAULT_URI, ".sandbox.workflow.preview");
|
||||||
|
public static QName PROP_AUTHORPREVIEW = QName.createQName(NamespaceService.DEFAULT_URI, ".sandbox.author.preview");
|
||||||
|
|
||||||
|
// Store, root path and version
|
||||||
|
|
||||||
private String m_storePath;
|
private String m_storePath;
|
||||||
private int m_version = VERSION_HEAD;
|
private int m_version = VERSION_HEAD;
|
||||||
@@ -64,6 +74,14 @@ public class AVMContext extends AlfrescoContext
|
|||||||
|
|
||||||
private boolean m_virtualView;
|
private boolean m_virtualView;
|
||||||
|
|
||||||
|
// Show sandboxes in the virtualization view
|
||||||
|
|
||||||
|
private boolean m_showSandboxes = false;
|
||||||
|
|
||||||
|
// associated AVM filesystem driver
|
||||||
|
|
||||||
|
private AVMDiskDriver m_avmDriver;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class constructor
|
* Class constructor
|
||||||
*
|
*
|
||||||
@@ -94,14 +112,21 @@ public class AVMContext extends AlfrescoContext
|
|||||||
* <p>Construct a context for a virtualization view onto all stores/versions within AVM.
|
* <p>Construct a context for a virtualization view onto all stores/versions within AVM.
|
||||||
*
|
*
|
||||||
* @param filesysName String
|
* @param filesysName String
|
||||||
|
* @param showSandboxes boolean
|
||||||
|
* @param avmDriver AVMDiskDriver
|
||||||
*/
|
*/
|
||||||
public AVMContext( String filesysName)
|
public AVMContext( String filesysName, boolean showSandboxes, AVMDiskDriver avmDriver)
|
||||||
{
|
{
|
||||||
super( filesysName, "VirtualView");
|
super( filesysName, "VirtualView");
|
||||||
|
|
||||||
// Enable the virtualization view
|
// Enable the virtualization view
|
||||||
|
|
||||||
m_virtualView = true;
|
m_virtualView = true;
|
||||||
|
m_showSandboxes = showSandboxes;
|
||||||
|
|
||||||
|
// Save the associated filesystem driver
|
||||||
|
|
||||||
|
m_avmDriver = avmDriver;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -144,6 +169,16 @@ public class AVMContext extends AlfrescoContext
|
|||||||
return m_virtualView;
|
return m_virtualView;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if sandboxes should be shown in the virtualization view
|
||||||
|
*
|
||||||
|
* @return boolean
|
||||||
|
*/
|
||||||
|
public final boolean showSandboxes()
|
||||||
|
{
|
||||||
|
return m_showSandboxes;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Close the filesystem context
|
* Close the filesystem context
|
||||||
*/
|
*/
|
||||||
@@ -185,30 +220,43 @@ public class AVMContext extends AlfrescoContext
|
|||||||
|
|
||||||
if ( rootState != null)
|
if ( rootState != null)
|
||||||
{
|
{
|
||||||
// Add a pseudo folder for the new store
|
// Get the properties for the new store
|
||||||
|
|
||||||
rootState.addPseudoFile( new StorePseudoFile( storeName));
|
boolean sandbox = false;
|
||||||
|
Map<QName, PropertyValue> props = m_avmDriver.getAVMStoreProperties( storeName);
|
||||||
// DEBUG
|
|
||||||
|
if ( props.containsKey( PROP_WORKFLOWPREVIEW) || props.containsKey( PROP_AUTHORPREVIEW))
|
||||||
if ( logger.isDebugEnabled())
|
sandbox = true;
|
||||||
logger.debug( "Added pseudo folder for new store " + storeName);
|
|
||||||
|
// Add a pseudo file for the current store
|
||||||
// Send a change notification for the new folder
|
|
||||||
|
if ( sandbox == false || showSandboxes() == true)
|
||||||
if ( hasChangeHandler())
|
{
|
||||||
{
|
// Add a pseudo folder for the new store
|
||||||
// Build the filesystem relative path to the new store folder
|
|
||||||
|
|
||||||
StringBuilder str = new StringBuilder();
|
rootState.addPseudoFile( new StorePseudoFile( storeName));
|
||||||
|
|
||||||
str.append( FileName.DOS_SEPERATOR);
|
// DEBUG
|
||||||
str.append( storeName);
|
|
||||||
|
|
||||||
// Send the change notification
|
if ( logger.isDebugEnabled())
|
||||||
|
logger.debug( "Added pseudo folder for new store " + storeName);
|
||||||
|
|
||||||
getChangeHandler().notifyDirectoryChanged(NotifyChange.ActionAdded, str.toString());
|
// Send a change notification for the new folder
|
||||||
}
|
|
||||||
|
if ( hasChangeHandler())
|
||||||
|
{
|
||||||
|
// Build the filesystem relative path to the new store folder
|
||||||
|
|
||||||
|
StringBuilder str = new StringBuilder();
|
||||||
|
|
||||||
|
str.append( FileName.DOS_SEPERATOR);
|
||||||
|
str.append( storeName);
|
||||||
|
|
||||||
|
// Send the change notification
|
||||||
|
|
||||||
|
getChangeHandler().notifyDirectoryChanged(NotifyChange.ActionAdded, str.toString());
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -20,6 +20,8 @@ package org.alfresco.filesys.avm;
|
|||||||
import java.io.FileNotFoundException;
|
import java.io.FileNotFoundException;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Set;
|
||||||
import java.util.SortedMap;
|
import java.util.SortedMap;
|
||||||
import java.util.StringTokenizer;
|
import java.util.StringTokenizer;
|
||||||
|
|
||||||
@@ -27,7 +29,6 @@ import javax.transaction.UserTransaction;
|
|||||||
|
|
||||||
import org.alfresco.config.ConfigElement;
|
import org.alfresco.config.ConfigElement;
|
||||||
import org.alfresco.filesys.alfresco.AlfrescoDiskDriver;
|
import org.alfresco.filesys.alfresco.AlfrescoDiskDriver;
|
||||||
import org.alfresco.filesys.avm.AVMPath.LevelId;
|
|
||||||
import org.alfresco.filesys.server.SrvSession;
|
import org.alfresco.filesys.server.SrvSession;
|
||||||
import org.alfresco.filesys.server.core.DeviceContext;
|
import org.alfresco.filesys.server.core.DeviceContext;
|
||||||
import org.alfresco.filesys.server.core.DeviceContextException;
|
import org.alfresco.filesys.server.core.DeviceContextException;
|
||||||
@@ -49,13 +50,13 @@ import org.alfresco.filesys.server.pseudo.PseudoFile;
|
|||||||
import org.alfresco.filesys.server.pseudo.PseudoFileList;
|
import org.alfresco.filesys.server.pseudo.PseudoFileList;
|
||||||
import org.alfresco.filesys.server.pseudo.PseudoFolderNetworkFile;
|
import org.alfresco.filesys.server.pseudo.PseudoFolderNetworkFile;
|
||||||
import org.alfresco.filesys.server.state.FileState;
|
import org.alfresco.filesys.server.state.FileState;
|
||||||
import org.alfresco.filesys.smb.FindFirstNext;
|
|
||||||
import org.alfresco.filesys.util.StringList;
|
import org.alfresco.filesys.util.StringList;
|
||||||
import org.alfresco.filesys.util.WildCard;
|
import org.alfresco.filesys.util.WildCard;
|
||||||
import org.alfresco.repo.avm.CreateStoreTxnListener;
|
import org.alfresco.repo.avm.CreateStoreTxnListener;
|
||||||
import org.alfresco.repo.avm.CreateVersionTxnListener;
|
import org.alfresco.repo.avm.CreateVersionTxnListener;
|
||||||
import org.alfresco.repo.avm.PurgeStoreTxnListener;
|
import org.alfresco.repo.avm.PurgeStoreTxnListener;
|
||||||
import org.alfresco.repo.avm.PurgeVersionTxnListener;
|
import org.alfresco.repo.avm.PurgeVersionTxnListener;
|
||||||
|
import org.alfresco.repo.domain.PropertyValue;
|
||||||
import org.alfresco.repo.security.authentication.AuthenticationComponent;
|
import org.alfresco.repo.security.authentication.AuthenticationComponent;
|
||||||
import org.alfresco.service.cmr.avm.AVMBadArgumentException;
|
import org.alfresco.service.cmr.avm.AVMBadArgumentException;
|
||||||
import org.alfresco.service.cmr.avm.AVMExistsException;
|
import org.alfresco.service.cmr.avm.AVMExistsException;
|
||||||
@@ -67,6 +68,7 @@ import org.alfresco.service.cmr.avm.AVMWrongTypeException;
|
|||||||
import org.alfresco.service.cmr.avm.VersionDescriptor;
|
import org.alfresco.service.cmr.avm.VersionDescriptor;
|
||||||
import org.alfresco.service.cmr.repository.MimetypeService;
|
import org.alfresco.service.cmr.repository.MimetypeService;
|
||||||
import org.alfresco.service.cmr.security.AuthenticationService;
|
import org.alfresco.service.cmr.security.AuthenticationService;
|
||||||
|
import org.alfresco.service.namespace.QName;
|
||||||
import org.alfresco.service.transaction.TransactionService;
|
import org.alfresco.service.transaction.TransactionService;
|
||||||
import org.apache.commons.logging.Log;
|
import org.apache.commons.logging.Log;
|
||||||
import org.apache.commons.logging.LogFactory;
|
import org.apache.commons.logging.LogFactory;
|
||||||
@@ -274,9 +276,13 @@ public class AVMDiskDriver extends AlfrescoDiskDriver implements DiskInterface {
|
|||||||
ConfigElement virtElem = cfg.getChild( "virtualView");
|
ConfigElement virtElem = cfg.getChild( "virtualView");
|
||||||
if ( virtElem != null)
|
if ( virtElem != null)
|
||||||
{
|
{
|
||||||
|
// Check if sandboxes should be shown in the virtualization view
|
||||||
|
|
||||||
|
boolean showSandboxes = cfg.getChild( "showAllSandboxes") != null ? true : false;
|
||||||
|
|
||||||
// Create the context
|
// Create the context
|
||||||
|
|
||||||
context = new AVMContext( name);
|
context = new AVMContext( name, showSandboxes, this);
|
||||||
|
|
||||||
// Enable file state caching
|
// Enable file state caching
|
||||||
|
|
||||||
@@ -523,7 +529,7 @@ public class AVMDiskDriver extends AlfrescoDiskDriver implements DiskInterface {
|
|||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
logger.error("Error during create context", ex);
|
logger.error("Error getting store names", ex);
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
@@ -547,6 +553,66 @@ public class AVMDiskDriver extends AlfrescoDiskDriver implements DiskInterface {
|
|||||||
return storeNames;
|
return storeNames;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the properties for a store
|
||||||
|
*
|
||||||
|
* @param storeName String
|
||||||
|
* @return Map<QName, PropertyValue>
|
||||||
|
*/
|
||||||
|
protected final Map<QName, PropertyValue> getAVMStoreProperties( String storeName)
|
||||||
|
{
|
||||||
|
// Use the system user as the authenticated context to get the AVM store properties
|
||||||
|
|
||||||
|
m_authComponent.setCurrentUser( m_authComponent.getSystemUserName());
|
||||||
|
|
||||||
|
// Wrap the service request in a transaction
|
||||||
|
|
||||||
|
UserTransaction tx = m_transactionService.getUserTransaction(false);
|
||||||
|
|
||||||
|
Map<QName, PropertyValue> properties = null;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
// Start the transaction
|
||||||
|
|
||||||
|
if ( tx != null)
|
||||||
|
tx.begin();
|
||||||
|
|
||||||
|
// Get the list of properties for AVM store
|
||||||
|
|
||||||
|
properties = m_avmService.getStoreProperties( storeName);
|
||||||
|
|
||||||
|
// Commit the transaction
|
||||||
|
|
||||||
|
tx.commit();
|
||||||
|
tx = null;
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
logger.error("Error getting store properties", ex);
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
// If there is an active transaction then roll it back
|
||||||
|
|
||||||
|
if ( tx != null)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
tx.rollback();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
logger.warn("Failed to rollback transaction", ex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Return the list of AVM store properties
|
||||||
|
|
||||||
|
return properties;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Build the full store path for a file/folder using the share relative path
|
* Build the full store path for a file/folder using the share relative path
|
||||||
*
|
*
|
||||||
@@ -1890,11 +1956,26 @@ public class AVMDiskDriver extends AlfrescoDiskDriver implements DiskInterface {
|
|||||||
{
|
{
|
||||||
// Add pseudo files for the stores
|
// Add pseudo files for the stores
|
||||||
|
|
||||||
|
boolean sandbox = false;
|
||||||
|
|
||||||
for ( AVMStoreDescriptor storeDesc : storeList)
|
for ( AVMStoreDescriptor storeDesc : storeList)
|
||||||
{
|
{
|
||||||
// Add a pseudo file for the current store
|
// Get the properties for the current store
|
||||||
|
|
||||||
fstate.addPseudoFile( new StorePseudoFile( storeDesc));
|
Map<QName, PropertyValue> props = m_avmService.getStoreProperties( storeDesc.getName());
|
||||||
|
|
||||||
|
if ( props.containsKey( AVMContext.PROP_WORKFLOWPREVIEW) || props.containsKey( AVMContext.PROP_AUTHORPREVIEW))
|
||||||
|
sandbox = true;
|
||||||
|
|
||||||
|
// DEBUG
|
||||||
|
|
||||||
|
if ( logger.isDebugEnabled())
|
||||||
|
logger.debug( "Store " + storeDesc.getName() + ", sandbox=" + sandbox);
|
||||||
|
|
||||||
|
// Add a pseudo file for the current store
|
||||||
|
|
||||||
|
if ( sandbox == false || avmCtx.showSandboxes() == true)
|
||||||
|
fstate.addPseudoFile( new StorePseudoFile( storeDesc));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user