diff --git a/source/java/org/alfresco/filesys/avm/AVMContext.java b/source/java/org/alfresco/filesys/avm/AVMContext.java
index 80373f6f91..f26ec1edd9 100644
--- a/source/java/org/alfresco/filesys/avm/AVMContext.java
+++ b/source/java/org/alfresco/filesys/avm/AVMContext.java
@@ -17,6 +17,8 @@
package org.alfresco.filesys.avm;
+import java.util.Map;
+
import org.alfresco.filesys.alfresco.AlfrescoContext;
import org.alfresco.filesys.alfresco.IOControlHandler;
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.PurgeStoreCallback;
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.LogFactory;
@@ -52,7 +57,12 @@ public class AVMContext extends AlfrescoContext
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 int m_version = VERSION_HEAD;
@@ -64,6 +74,14 @@ public class AVMContext extends AlfrescoContext
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
*
@@ -94,14 +112,21 @@ public class AVMContext extends AlfrescoContext
*
Construct a context for a virtualization view onto all stores/versions within AVM.
*
* @param filesysName String
+ * @param showSandboxes boolean
+ * @param avmDriver AVMDiskDriver
*/
- public AVMContext( String filesysName)
+ public AVMContext( String filesysName, boolean showSandboxes, AVMDiskDriver avmDriver)
{
super( filesysName, "VirtualView");
// Enable the virtualization view
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;
}
+ /**
+ * Check if sandboxes should be shown in the virtualization view
+ *
+ * @return boolean
+ */
+ public final boolean showSandboxes()
+ {
+ return m_showSandboxes;
+ }
+
/**
* Close the filesystem context
*/
@@ -185,30 +220,43 @@ public class AVMContext extends AlfrescoContext
if ( rootState != null)
{
- // Add a pseudo folder for the new store
-
- rootState.addPseudoFile( new StorePseudoFile( storeName));
-
- // DEBUG
-
- if ( logger.isDebugEnabled())
- logger.debug( "Added pseudo folder for new store " + storeName);
-
- // Send a change notification for the new folder
-
- if ( hasChangeHandler())
- {
- // Build the filesystem relative path to the new store folder
+ // Get the properties for the new store
+
+ boolean sandbox = false;
+ Map props = m_avmDriver.getAVMStoreProperties( storeName);
+
+ if ( props.containsKey( PROP_WORKFLOWPREVIEW) || props.containsKey( PROP_AUTHORPREVIEW))
+ sandbox = true;
+
+ // Add a pseudo file for the current store
+
+ if ( sandbox == false || showSandboxes() == true)
+ {
+ // Add a pseudo folder for the new store
- StringBuilder str = new StringBuilder();
+ rootState.addPseudoFile( new StorePseudoFile( storeName));
- str.append( FileName.DOS_SEPERATOR);
- str.append( storeName);
+ // DEBUG
- // 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());
+ }
+ }
}
}
diff --git a/source/java/org/alfresco/filesys/avm/AVMDiskDriver.java b/source/java/org/alfresco/filesys/avm/AVMDiskDriver.java
index c30c61c899..b5a76db37d 100644
--- a/source/java/org/alfresco/filesys/avm/AVMDiskDriver.java
+++ b/source/java/org/alfresco/filesys/avm/AVMDiskDriver.java
@@ -20,6 +20,8 @@ package org.alfresco.filesys.avm;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.List;
+import java.util.Map;
+import java.util.Set;
import java.util.SortedMap;
import java.util.StringTokenizer;
@@ -27,7 +29,6 @@ import javax.transaction.UserTransaction;
import org.alfresco.config.ConfigElement;
import org.alfresco.filesys.alfresco.AlfrescoDiskDriver;
-import org.alfresco.filesys.avm.AVMPath.LevelId;
import org.alfresco.filesys.server.SrvSession;
import org.alfresco.filesys.server.core.DeviceContext;
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.PseudoFolderNetworkFile;
import org.alfresco.filesys.server.state.FileState;
-import org.alfresco.filesys.smb.FindFirstNext;
import org.alfresco.filesys.util.StringList;
import org.alfresco.filesys.util.WildCard;
import org.alfresco.repo.avm.CreateStoreTxnListener;
import org.alfresco.repo.avm.CreateVersionTxnListener;
import org.alfresco.repo.avm.PurgeStoreTxnListener;
import org.alfresco.repo.avm.PurgeVersionTxnListener;
+import org.alfresco.repo.domain.PropertyValue;
import org.alfresco.repo.security.authentication.AuthenticationComponent;
import org.alfresco.service.cmr.avm.AVMBadArgumentException;
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.repository.MimetypeService;
import org.alfresco.service.cmr.security.AuthenticationService;
+import org.alfresco.service.namespace.QName;
import org.alfresco.service.transaction.TransactionService;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -274,9 +276,13 @@ public class AVMDiskDriver extends AlfrescoDiskDriver implements DiskInterface {
ConfigElement virtElem = cfg.getChild( "virtualView");
if ( virtElem != null)
{
+ // Check if sandboxes should be shown in the virtualization view
+
+ boolean showSandboxes = cfg.getChild( "showAllSandboxes") != null ? true : false;
+
// Create the context
- context = new AVMContext( name);
+ context = new AVMContext( name, showSandboxes, this);
// Enable file state caching
@@ -523,7 +529,7 @@ public class AVMDiskDriver extends AlfrescoDiskDriver implements DiskInterface {
}
catch (Exception ex)
{
- logger.error("Error during create context", ex);
+ logger.error("Error getting store names", ex);
}
finally
{
@@ -547,6 +553,66 @@ public class AVMDiskDriver extends AlfrescoDiskDriver implements DiskInterface {
return storeNames;
}
+ /**
+ * Get the properties for a store
+ *
+ * @param storeName String
+ * @return Map
+ */
+ protected final Map 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 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
*
@@ -1890,11 +1956,26 @@ public class AVMDiskDriver extends AlfrescoDiskDriver implements DiskInterface {
{
// Add pseudo files for the stores
+ boolean sandbox = false;
+
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 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));
}
}
}