mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
Merged V4.1-BUG-FIX to HEAD
41597: ALF-1907: Check out rule is active for spaces - Merged in fix from DEV - Changed List of applicable types to a Set - Added quick initial checks against the set before doing the subtype checks - Various typo fixes 41598: Add an additional line of INFO to log the database details 41599: Fix for ALF-8374 - Simple view: incorrect file type icon for *.page and *.eps files 41600: Merge DEV to V4.1-BUG-FIX 41478 : ALF-14078: CLONE - Saving files with apps on Mac OS X Lion in CIFS doesn't invoke rules 41605: Fix for ALF-14653 - Share - Page link created wrongly in wiki. Solution to split wiki page name and title from Alex Bykov. 41608: CIFS cluster saving of text file fails. ALF-14179 The client releases the oplock by closing the file, if a remote oplock break was used then a notification to the remote node was missing in this case. 41616: ALF-13577:modified the delete site REST API to set the status code to 409 if a node is locked. 41624: MT: ALF-14331 - UserUsageTrackingComponent fails if disabled (in MT config) - defensive fix (exact steps do not repeat) - may also fix ALF-15956 41652: more debug 41653: Fix for ALF-15965 - IE9 - Script error occurs when manage aspect for a document 41655: Merged BRANCHES/V4.1 to BRANCHES/DEV/V4.1-BUG-FIX (RECORD ONLY) 41654: Fix for ALF-15965 - hand merged back from rev 41653 41658: ALF-14967: Task operations through task-forms now audited 41664: Reverse-merging change 41616 out of the product due to file formatting irregularities. This checkin was a fix for ALF-13577. A subsequent check-in will add the same fix but without the formatting problems. 41665: ALF-11452: Disabling JBPM now prevents jobexecutor thread from starting and consuming unneeded resources 41671: Reimplementation of fix for ALF-13577. Slight edit on previous fix. It now lets the NodeLockedException out of the Java layer and 'catches' this exception in the JavaScript layer. The API returns a 409 (conflict) if a NodeLockedException makes it to the JavaScript - the previous fix was returning 409 for *any* AlfrescoRuntimeException thrown during a site delete. Also this checkin preserves the whitespace/file layout of the preceding version. 41688: ALF-15867 WikiServiceImplTest failing on SQL Server - Switched WikiService_transaction bean over to using RetryingTransactionInterceptor 41720: ALF-15967: Using START_USER_ID_ instead of "initiator" property to query process instances started by user X to prevent extra joins 41730: Fix for ALF-15995 NodeRef is missing in log on "Problem converting to Freemarker" error 41743: ALF-9779 REGRESSION: FTP - Failed to retrieve directory listing for tenant user 41745: Removed a HomeShareMapper - there were two 41747: Fix for ALF-15811 SOLR query increases DocBitSet inefficiently Part of ALF-14861 SOLR to scale for non-admin users in 100k sites and a subgroup of each of 1000 independent groupings with 1000 subgroups 41748: Fix for ALF-15950 Solr: throws NPE: org.alfresco.solr.SolrLuceneAnalyser.loadAnalyzer - return default analyzer 41752: Fix for ALF-13634 Re-created category won't show up again on a node in Document Library. 41779: ALF-11283 - Got the home share mapper up and working after some refactoring. 41795: Fix for ALF-14361 CMIS object type definition for Document and Folder not spec compliant 41796: ALF-16008: missing column on clean Alfresco and after upgrade from 3.4.10 (703) - Schema-Reference for DB2 referenced a non-existent column. 41802: Fixed ALF-16029: TransactionCleanupTest throws constraint violations - Fallout from ALF-12358; sys:deleted node types have a mandatory property - Before bulk-deleting nodes, we need to delete properties - Use overriding DAo for MySQL. Other DBs can use standard delete with joins - NB: Fixed TransactionalCleanupTest to double-check the purge job 41822: Refactor to both Share Mappers. 41838: BDE-85: Deploy alfresco-mmt with a proper pom.xml containing dependencies Also, refactor Maven deployment to use a macro 41858: ALF-14444 - CloudSync: Ensure unknown properties when synced to Cloud are ignored properly 41876: Fix ALF-16067 - Items with cm:versionable aspect [custom aspect added] throw errors in Share UI 41877: Updated Spring Surf libs (1148) - downgrades module deployment error messages 41878: ALF-16069 - RU: 'Web Deployed' folder is not localized if Alfresco is installed with Russian locale. 41879: Fix non-continuous build, trying to call continuous-init from maven-env-prerequisites 41918: Merged PATCHES/V4.1.1 to V4.1-BUG-FIX 41657: ALF-15965 - IE9 - Script error occurs when manage aspect for a document (correct 4.1.1 branch this time) 41834: Merged DEV to V4.1.1 (4.1.1) 41827: ALF-15983: SPP: Meeting space: all-day event is displayed on the day before specified during creation Removing of time zone has been modified to be sensitive to Outlook meeting events which are not requiring special conversion for the start and end dates 41835: Merged DEV to V4.1.1 (4.1.1) 41833: ALF-16038 : DB2: Upgrade script needed to remove ALFUSER.ACT_HI_ACTINST.OWNER_ The patch was created to remove an unnecessary column in DB2. 41845: Reverse merge: << In attempt to clear 12 new DB2 build errors - don't think it is going to work >> 41835: Merged DEV to V4.1.1 (4.1.1) 41833: ALF-16038 : DB2: Upgrade script needed to remove ALFUSER.ACT_HI_ACTINST.OWNER_ The patch was created to remove an unnecessary column in DB2. Merged V4.1-BUG-FIX (4.1.2) to V4.1.1 (4.1.1) 41337: Merged V3.4-BUG-FIX (3.4.11) to V4.1-BUG-FIX (4.1.2) 41336: TransformerDebug: Use debug rather than trace when there are transformers but they are all unavailable. 41868: Reverse the reverse merge (back to r41835 state used in build #33 given to QA) 41845: Reverse merge: << In attempt to clear 12 new DB2 build errors - don't think it is going to work >> 41835: Merged DEV to V4.1.1 (4.1.1) 41833: ALF-16038 : DB2: Upgrade script needed to remove ALFUSER.ACT_HI_ACTINST.OWNER_ The patch was created to remove an unnecessary column in DB2. Merged V4.1-BUG-FIX (4.1.2) to V4.1.1 (4.1.1) 41337: Merged V3.4-BUG-FIX (3.4.11) to V4.1-BUG-FIX (4.1.2) 41336: TransformerDebug: Use debug rather than trace when there are transformers but they are all unavailable. 41914: Merged DEV to PATCHES/V4.1.1 41909: ALF-16078 : DB2: it's impossible to upgrade Alfresco from 3.4.10 to 4.1.1 (build 33). The remove-column-activiti.sql was marked as optional. git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@41919 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -21,12 +21,8 @@ package org.alfresco.filesys.alfresco;
|
||||
|
||||
import java.util.Enumeration;
|
||||
|
||||
import org.springframework.extensions.config.ConfigElement;
|
||||
import org.alfresco.error.AlfrescoRuntimeException;
|
||||
import org.alfresco.filesys.AlfrescoConfigSection;
|
||||
import org.alfresco.filesys.config.ServerConfigurationBean;
|
||||
import org.alfresco.filesys.repo.ContentContext;
|
||||
import org.alfresco.filesys.repo.ContentDiskDriver;
|
||||
import org.alfresco.jlan.server.SrvSession;
|
||||
import org.alfresco.jlan.server.auth.InvalidUserException;
|
||||
import org.alfresco.jlan.server.config.InvalidConfigurationException;
|
||||
@@ -39,8 +35,15 @@ import org.alfresco.jlan.server.core.SharedDeviceList;
|
||||
import org.alfresco.jlan.server.filesys.DiskInterface;
|
||||
import org.alfresco.jlan.server.filesys.DiskSharedDevice;
|
||||
import org.alfresco.jlan.server.filesys.FilesystemsConfigSection;
|
||||
import org.alfresco.jlan.server.filesys.quota.QuotaManager;
|
||||
import org.alfresco.model.ContentModel;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.cmr.repository.NodeService;
|
||||
import org.alfresco.service.cmr.security.PersonService;
|
||||
import org.alfresco.util.PropertyCheck;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.springframework.extensions.config.ConfigElement;
|
||||
|
||||
/**
|
||||
* Home Share Mapper Class
|
||||
@@ -49,50 +52,47 @@ import org.apache.commons.logging.LogFactory;
|
||||
* configuration and provides a dynamic home share mapped to the users home node.
|
||||
*
|
||||
* @author GKSpencer
|
||||
* @author mrogers
|
||||
*/
|
||||
public class HomeShareMapper implements ShareMapper
|
||||
{
|
||||
// Logging
|
||||
|
||||
private static final Log logger = LogFactory.getLog("org.alfresco.smb.protocol");
|
||||
private static final Log logger = LogFactory.getLog("org.alfresco.filesys.alfresco.HomeShareMapper");
|
||||
|
||||
// Home folder share name
|
||||
|
||||
public static final String HOME_FOLDER_SHARE = "HOME";
|
||||
|
||||
// Server configuration
|
||||
|
||||
private ServerConfigurationAccessor m_config;
|
||||
|
||||
private DiskInterface m_repoDiskInterface;
|
||||
|
||||
|
||||
// Home folder share name
|
||||
private String homeShareName = HOME_FOLDER_SHARE;
|
||||
|
||||
private String m_homeShareName = HOME_FOLDER_SHARE;
|
||||
private PersonService personService;
|
||||
private NodeService nodeService;
|
||||
private DiskInterface repoDiskInterface;
|
||||
|
||||
// Debug enable flag
|
||||
|
||||
private boolean m_debug;
|
||||
|
||||
private QuotaManager quotaManager; // optional quota manager
|
||||
|
||||
public void setConfig(ServerConfiguration config)
|
||||
public void init()
|
||||
{
|
||||
PropertyCheck.mandatory(this, "ServerConfiguration", m_config);
|
||||
PropertyCheck.mandatory(this, "Home share name", homeShareName);
|
||||
PropertyCheck.mandatory(this, "personService", getPersonService());
|
||||
PropertyCheck.mandatory(this, "nodeService", getNodeService());
|
||||
PropertyCheck.mandatory(this, "repoDiskInterface", getRepoDiskInterface());
|
||||
|
||||
}
|
||||
|
||||
public void setServerConfiguration(ServerConfiguration config)
|
||||
{
|
||||
m_config = config;
|
||||
}
|
||||
|
||||
public void setRepoDiskInterface(DiskInterface diskInterface)
|
||||
{
|
||||
m_repoDiskInterface = diskInterface;
|
||||
}
|
||||
|
||||
public void setHomeShareName(String shareName)
|
||||
{
|
||||
m_homeShareName = shareName;
|
||||
}
|
||||
|
||||
public void setDebug(boolean m_debug)
|
||||
{
|
||||
this.m_debug = m_debug;
|
||||
homeShareName = shareName;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -112,31 +112,7 @@ public class HomeShareMapper implements ShareMapper
|
||||
public void initializeMapper(ServerConfiguration config, ConfigElement params) throws InvalidConfigurationException
|
||||
{
|
||||
// Save the server configuration
|
||||
|
||||
setConfig(config);
|
||||
|
||||
setRepoDiskInterface(((AlfrescoConfigSection) m_config.getConfigSection( AlfrescoConfigSection.SectionName)).getRepoDiskInterface());
|
||||
|
||||
// Check if the home share name has been specified
|
||||
|
||||
String homeName = params.getAttribute("name");
|
||||
if ( homeName != null && homeName.length() > 0)
|
||||
setHomeShareName(homeName);
|
||||
|
||||
// Check if debug is enabled
|
||||
|
||||
if (params != null && params.getChild("debug") != null)
|
||||
setDebug(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if debug output is enabled
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public final boolean hasDebug()
|
||||
{
|
||||
return m_debug;
|
||||
setServerConfiguration(config);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -146,7 +122,7 @@ public class HomeShareMapper implements ShareMapper
|
||||
*/
|
||||
public final String getHomeFolderName()
|
||||
{
|
||||
return m_homeShareName;
|
||||
return homeShareName;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -162,21 +138,31 @@ public class HomeShareMapper implements ShareMapper
|
||||
// Check if the user has a home folder, and the session does not currently have any
|
||||
// dynamic shares defined
|
||||
|
||||
if ( sess != null && sess.hasClientInformation() && sess.hasDynamicShares() == false &&
|
||||
if ( sess != null &&
|
||||
sess.hasClientInformation() &&
|
||||
sess.hasDynamicShares() == false &&
|
||||
sess.getClientInformation() instanceof AlfrescoClientInfo)
|
||||
{
|
||||
AlfrescoClientInfo client = (AlfrescoClientInfo) sess.getClientInformation();
|
||||
if ( client.hasHomeFolder())
|
||||
|
||||
NodeRef personNode = getPersonService().getPerson(client.getUserName());
|
||||
|
||||
if(personNode != null)
|
||||
{
|
||||
// Create the home folder share
|
||||
NodeRef homeSpaceRef = (NodeRef)getNodeService().getProperty(personNode, ContentModel.PROP_HOMEFOLDER);
|
||||
|
||||
if (homeSpaceRef != null)
|
||||
{
|
||||
// Create the home folder share
|
||||
DiskSharedDevice homeShare = createHomeDiskShare(homeSpaceRef, client.getUserName());
|
||||
sess.addDynamicShare(homeShare);
|
||||
|
||||
DiskSharedDevice homeShare = createHomeDiskShare(client);
|
||||
sess.addDynamicShare(homeShare);
|
||||
|
||||
// Debug
|
||||
|
||||
if ( logger.isDebugEnabled())
|
||||
logger.debug("Added " + getHomeFolderName() + " share to list of shares for " + client.getUserName());
|
||||
if ( logger.isDebugEnabled())
|
||||
{
|
||||
logger.debug("Added " + getHomeFolderName() + " share to list of shares for " + client.getUserName());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -194,7 +180,9 @@ public class HomeShareMapper implements ShareMapper
|
||||
// Remove unavailable shares from the list and return the list
|
||||
|
||||
if ( allShares == false)
|
||||
{
|
||||
shrList.removeUnavailableShares();
|
||||
}
|
||||
return shrList;
|
||||
}
|
||||
|
||||
@@ -231,7 +219,7 @@ public class HomeShareMapper implements ShareMapper
|
||||
|
||||
// Check if the user has a home folder node
|
||||
|
||||
if ( client != null && client.hasHomeFolder()) {
|
||||
if ( client != null ) {
|
||||
|
||||
// Check if the share has already been created for the session
|
||||
|
||||
@@ -253,23 +241,33 @@ public class HomeShareMapper implements ShareMapper
|
||||
|
||||
// Create the home share mapped to the users home folder
|
||||
|
||||
DiskSharedDevice diskShare = createHomeDiskShare(client);
|
||||
NodeRef personNode = getPersonService().getPerson(client.getUserName());
|
||||
|
||||
// Add the new share to the sessions dynamic share list
|
||||
if(personNode != null)
|
||||
{
|
||||
NodeRef homeSpaceRef = (NodeRef)getNodeService().getProperty(personNode, ContentModel.PROP_HOMEFOLDER);
|
||||
|
||||
DiskSharedDevice diskShare = createHomeDiskShare(client.getHomeFolder(), client.getUserName());
|
||||
|
||||
// Add the new share to the sessions dynamic share list
|
||||
|
||||
sess.addDynamicShare(diskShare);
|
||||
share = diskShare;
|
||||
sess.addDynamicShare(diskShare);
|
||||
share = diskShare;
|
||||
|
||||
// DEBUG
|
||||
|
||||
if (logger.isDebugEnabled())
|
||||
logger.debug(" Mapped share " + name + " to " + client.getHomeFolder());
|
||||
if (logger.isDebugEnabled())
|
||||
{
|
||||
logger.debug(" Mapped share " + name + " to " + client.getHomeFolder());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new InvalidUserException("No home directory");
|
||||
}
|
||||
}
|
||||
else {
|
||||
else
|
||||
{
|
||||
|
||||
// Find the required share by name/type. Use a case sensitive search first, if that fails use a case
|
||||
// insensitive search.
|
||||
@@ -287,7 +285,9 @@ public class HomeShareMapper implements ShareMapper
|
||||
// Check if the share is available
|
||||
|
||||
if ( share != null && share.getContext() != null && share.getContext().isAvailable() == false)
|
||||
{
|
||||
share = null;
|
||||
}
|
||||
|
||||
// Return the shared device, or null if no matching device was found
|
||||
|
||||
@@ -347,39 +347,69 @@ public class HomeShareMapper implements ShareMapper
|
||||
* @param client AlfrescoClientInfo
|
||||
* @return DiskSharedDevice
|
||||
*/
|
||||
private final DiskSharedDevice createHomeDiskShare(AlfrescoClientInfo client)
|
||||
private final DiskSharedDevice createHomeDiskShare(NodeRef homeFolderRef, String userName)
|
||||
{
|
||||
// Create the disk driver and context
|
||||
logger.debug("create home share for user " + userName);
|
||||
|
||||
ExtendedDiskInterface diskDrv = (ExtendedDiskInterface) getRepoDiskInterface();
|
||||
ContentContext diskCtx = new ContentContext( getHomeFolderName(), "", "", client.getHomeFolder());
|
||||
DiskInterface diskDrv = getRepoDiskInterface();
|
||||
|
||||
ContentContext diskCtx = new ContentContext( getHomeFolderName(), "", "", homeFolderRef);
|
||||
|
||||
if(m_config instanceof ServerConfigurationBean)
|
||||
if ( getQuotaManager() != null)
|
||||
{
|
||||
ServerConfigurationBean config = (ServerConfigurationBean)m_config;
|
||||
|
||||
config.initialiseRuntimeContext(diskCtx);
|
||||
|
||||
// Enable file state caching
|
||||
// diskCtx.enableStateCache(serverConfigurationBean, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new AlfrescoRuntimeException("configuration error, unknown configuration bean");
|
||||
diskCtx.setQuotaManager( getQuotaManager());
|
||||
}
|
||||
|
||||
ServerConfigurationBean config = (ServerConfigurationBean)m_config;
|
||||
config.initialiseRuntimeContext("cifs.home." + userName, diskCtx);
|
||||
|
||||
// Create a temporary shared device for the users home directory
|
||||
|
||||
return new DiskSharedDevice(getHomeFolderName(), diskDrv, diskCtx, SharedDevice.Temporary);
|
||||
}
|
||||
|
||||
protected DiskInterface getRepoDiskInterface()
|
||||
{
|
||||
return m_repoDiskInterface;
|
||||
}
|
||||
|
||||
protected FilesystemsConfigSection getFilesystemsConfigSection()
|
||||
{
|
||||
return (FilesystemsConfigSection)m_config.getConfigSection(FilesystemsConfigSection.SectionName);
|
||||
}
|
||||
|
||||
public void setPersonService(PersonService personService)
|
||||
{
|
||||
this.personService = personService;
|
||||
}
|
||||
|
||||
public PersonService getPersonService()
|
||||
{
|
||||
return personService;
|
||||
}
|
||||
|
||||
public void setNodeService(NodeService nodeService)
|
||||
{
|
||||
this.nodeService = nodeService;
|
||||
}
|
||||
|
||||
public NodeService getNodeService()
|
||||
{
|
||||
return nodeService;
|
||||
}
|
||||
|
||||
public void setRepoDiskInterface(DiskInterface repoDiskInterface)
|
||||
{
|
||||
this.repoDiskInterface = repoDiskInterface;
|
||||
}
|
||||
|
||||
public DiskInterface getRepoDiskInterface()
|
||||
{
|
||||
return repoDiskInterface;
|
||||
}
|
||||
|
||||
public void setQuotaManager(QuotaManager quotaManager)
|
||||
{
|
||||
this.quotaManager = quotaManager;
|
||||
}
|
||||
|
||||
public QuotaManager getQuotaManager()
|
||||
{
|
||||
return quotaManager;
|
||||
}
|
||||
}
|
||||
|
@@ -43,6 +43,7 @@ import org.alfresco.jlan.server.filesys.SrvDiskInfo;
|
||||
import org.alfresco.jlan.server.filesys.quota.QuotaManager;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.cmr.repository.StoreRef;
|
||||
import org.alfresco.util.PropertyCheck;
|
||||
import org.springframework.beans.factory.InitializingBean;
|
||||
import org.alfresco.filesys.config.ServerConfigurationBean;
|
||||
import org.apache.commons.logging.Log;
|
||||
@@ -67,7 +68,7 @@ public class MultiTenantShareMapper implements ShareMapper, ConfigurationListene
|
||||
|
||||
private String m_tenantShareName;
|
||||
|
||||
// Store name and root path from standard content filesystem share
|
||||
// Store name and root path
|
||||
|
||||
private String m_rootPath;
|
||||
private String m_storeName;
|
||||
@@ -79,6 +80,8 @@ public class MultiTenantShareMapper implements ShareMapper, ConfigurationListene
|
||||
// Quota manager to use when creating multi-tenant shares
|
||||
|
||||
private QuotaManager m_quotaManager;
|
||||
|
||||
private DiskInterface repoDiskInterface;
|
||||
|
||||
/**
|
||||
* Default constructor
|
||||
@@ -87,29 +90,14 @@ public class MultiTenantShareMapper implements ShareMapper, ConfigurationListene
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
public void setServerConfiguration(ServerConfiguration config)
|
||||
{
|
||||
this.m_config = config;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public void setTenantShareName(String shareName)
|
||||
{
|
||||
m_tenantShareName = shareName;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Set the quota manager to be used by multi-tenant shares
|
||||
*
|
||||
* @param quotaManager QuotaManager
|
||||
*/
|
||||
public void setQuotaManager( QuotaManager quotaManager) {
|
||||
m_quotaManager = quotaManager;
|
||||
}
|
||||
public void init()
|
||||
{
|
||||
PropertyCheck.mandatory(this, "ServerConfiguration", m_config);
|
||||
PropertyCheck.mandatory(this, "Tenant share name", m_tenantShareName);
|
||||
PropertyCheck.mandatory(this, "repoDiskInterface", getRepoDiskInterface());
|
||||
PropertyCheck.mandatory(this, "Store name", m_storeName);
|
||||
PropertyCheck.mandatory(this, "Root Path", m_rootPath);
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize the share mapper
|
||||
@@ -129,20 +117,6 @@ public class MultiTenantShareMapper implements ShareMapper, ConfigurationListene
|
||||
// Save the server configuration
|
||||
|
||||
setServerConfiguration(config);
|
||||
|
||||
// Check if a tenant share name has been specified
|
||||
|
||||
ConfigElement tenantShareName = params.getChild( "TenantShareName");
|
||||
|
||||
if ( tenantShareName != null)
|
||||
{
|
||||
// Validate the share name
|
||||
|
||||
if ( tenantShareName.getValue() != null && tenantShareName.getValue().length() > 0)
|
||||
setTenantShareName(tenantShareName.getValue());
|
||||
else
|
||||
throw new InvalidConfigurationException("Invalid tenant share name");
|
||||
}
|
||||
|
||||
// Complete initialization
|
||||
afterPropertiesSet();
|
||||
@@ -162,11 +136,6 @@ public class MultiTenantShareMapper implements ShareMapper, ConfigurationListene
|
||||
if ( m_filesysConfig == null || m_alfrescoConfig == null)
|
||||
m_config.addListener( this);
|
||||
|
||||
// Find the content filesystem details to be used for the tenant shares
|
||||
|
||||
if ( m_filesysConfig != null)
|
||||
findContentShareDetails();
|
||||
|
||||
// Create the tenant share lists table
|
||||
|
||||
m_tenantShareLists = new Hashtable<String, SharedDeviceList>();
|
||||
@@ -180,7 +149,7 @@ public class MultiTenantShareMapper implements ShareMapper, ConfigurationListene
|
||||
* @param typ int
|
||||
* @param sess SrvSession
|
||||
* @param create boolean
|
||||
* @return SharedDevice
|
||||
* @return SharedDevice or null if no matching device was found
|
||||
* @exception InvalidUserException
|
||||
*/
|
||||
public SharedDevice findShare(String host, String name, int typ, SrvSession sess, boolean create)
|
||||
@@ -188,9 +157,12 @@ public class MultiTenantShareMapper implements ShareMapper, ConfigurationListene
|
||||
|
||||
// Check if this is a tenant user
|
||||
|
||||
if ( m_alfrescoConfig.getTenantService().isEnabled() && m_alfrescoConfig.getTenantService().isTenantUser() &&
|
||||
if ( m_alfrescoConfig.getTenantService().isEnabled() &&
|
||||
m_alfrescoConfig.getTenantService().isTenantUser() &&
|
||||
typ != ShareType.ADMINPIPE)
|
||||
{
|
||||
return findTenantShare(host, name, typ, sess, create);
|
||||
}
|
||||
|
||||
// Find the required share by name/type. Use a case sensitive search first, if that fails use a case
|
||||
// insensitive search.
|
||||
@@ -261,23 +233,26 @@ public class MultiTenantShareMapper implements ShareMapper, ConfigurationListene
|
||||
// Check if this is a tenant user
|
||||
|
||||
if ( m_alfrescoConfig.getTenantService().isEnabled() && m_alfrescoConfig.getTenantService().isTenantUser())
|
||||
{
|
||||
return getTenantShareList(host, sess, allShares);
|
||||
}
|
||||
|
||||
// Make a copy of the global share list and add the per session dynamic shares
|
||||
|
||||
SharedDeviceList shrList = new SharedDeviceList( m_filesysConfig.getShares());
|
||||
|
||||
if ( sess != null && sess.hasDynamicShares()) {
|
||||
|
||||
// Add the per session dynamic shares
|
||||
|
||||
if ( sess != null && sess.hasDynamicShares())
|
||||
{
|
||||
// Add the per session dynamic shares
|
||||
shrList.addShares(sess.getDynamicShareList());
|
||||
}
|
||||
|
||||
// Remove unavailable shares from the list and return the list
|
||||
|
||||
if ( allShares == false)
|
||||
shrList.removeUnavailableShares();
|
||||
{
|
||||
shrList.removeUnavailableShares();
|
||||
}
|
||||
return shrList;
|
||||
}
|
||||
|
||||
@@ -322,10 +297,6 @@ public class MultiTenantShareMapper implements ShareMapper, ConfigurationListene
|
||||
return ConfigurationListener.StsAccepted;
|
||||
}
|
||||
|
||||
// Check if the tenant share template details have been set
|
||||
|
||||
if ( m_rootPath == null)
|
||||
findContentShareDetails();
|
||||
|
||||
// Return a dummy status
|
||||
|
||||
@@ -350,9 +321,11 @@ public class MultiTenantShareMapper implements ShareMapper, ConfigurationListene
|
||||
|
||||
SharedDeviceList shareList = getTenantShareList(host, sess, true);
|
||||
if ( shareList == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
// Search for the required share
|
||||
// Search for the required share in the list of shares for the tennant
|
||||
|
||||
return shareList.findShare( name, typ, true);
|
||||
}
|
||||
@@ -375,6 +348,11 @@ public class MultiTenantShareMapper implements ShareMapper, ConfigurationListene
|
||||
|
||||
SharedDeviceList shareList = null;
|
||||
|
||||
if(m_tenantShareLists.containsKey(tenantDomain))
|
||||
{
|
||||
shareList = m_tenantShareLists.get( tenantDomain);
|
||||
}
|
||||
|
||||
synchronized ( m_tenantShareLists)
|
||||
{
|
||||
// Get the tenant specific share list
|
||||
@@ -389,7 +367,7 @@ public class MultiTenantShareMapper implements ShareMapper, ConfigurationListene
|
||||
|
||||
// Create a tenant specific share for this domain
|
||||
|
||||
shareList.addShare( createTenantShare());
|
||||
shareList.addShare( createTenantShare(tenantDomain));
|
||||
|
||||
// Store the list for use by other members of this domain
|
||||
|
||||
@@ -405,20 +383,25 @@ public class MultiTenantShareMapper implements ShareMapper, ConfigurationListene
|
||||
/**
|
||||
* Create a tenant domain specific share
|
||||
*/
|
||||
private final DiskSharedDevice createTenantShare()
|
||||
private final DiskSharedDevice createTenantShare(String tenantDomain)
|
||||
{
|
||||
StoreRef storeRef = new StoreRef(m_storeName);
|
||||
logger.debug("create tenant share for domain " + tenantDomain);
|
||||
StoreRef storeRef = new StoreRef(getStoreName());
|
||||
NodeRef rootNodeRef = new NodeRef(storeRef.getProtocol(), storeRef.getIdentifier(), "dummy");
|
||||
|
||||
// Root nodeRef is required for storeRef part
|
||||
|
||||
rootNodeRef = m_alfrescoConfig.getTenantService().getRootNode(m_alfrescoConfig.getNodeService(), m_alfrescoConfig.getSearchService(),
|
||||
m_alfrescoConfig.getNamespaceService(), m_rootPath, rootNodeRef);
|
||||
rootNodeRef = m_alfrescoConfig.getTenantService().getRootNode(
|
||||
m_alfrescoConfig.getNodeService(),
|
||||
m_alfrescoConfig.getSearchService(),
|
||||
m_alfrescoConfig.getNamespaceService(),
|
||||
getRootPath(),
|
||||
rootNodeRef);
|
||||
|
||||
// Create the disk driver and context
|
||||
|
||||
DiskInterface diskDrv = m_alfrescoConfig.getRepoDiskInterface();
|
||||
ContentContext diskCtx = new ContentContext(m_tenantShareName, "", m_rootPath, rootNodeRef);
|
||||
DiskInterface diskDrv = getRepoDiskInterface();
|
||||
ContentContext diskCtx = new ContentContext(m_tenantShareName, getStoreName(), getRootPath(), rootNodeRef);
|
||||
|
||||
// Set a quota manager for the share, if enabled
|
||||
|
||||
@@ -431,10 +414,7 @@ public class MultiTenantShareMapper implements ShareMapper, ConfigurationListene
|
||||
{
|
||||
ServerConfigurationBean config = (ServerConfigurationBean)m_config;
|
||||
|
||||
config.initialiseRuntimeContext(diskCtx);
|
||||
|
||||
// Enable file state caching
|
||||
// diskCtx.enableStateCache(serverConfigurationBean, true);
|
||||
config.initialiseRuntimeContext("cifs.tenant." + tenantDomain, diskCtx);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -450,40 +430,53 @@ public class MultiTenantShareMapper implements ShareMapper, ConfigurationListene
|
||||
return new DiskSharedDevice(m_tenantShareName, diskDrv, diskCtx);
|
||||
}
|
||||
|
||||
/**
|
||||
* Find the content filesystem driver details used for the tenant shares
|
||||
*/
|
||||
private final void findContentShareDetails()
|
||||
public void setServerConfiguration(ServerConfiguration config)
|
||||
{
|
||||
// Need the file system configuration to do the lookup
|
||||
|
||||
if ( m_filesysConfig == null)
|
||||
return;
|
||||
|
||||
// Get the fixed share list
|
||||
|
||||
SharedDeviceList shareList = m_filesysConfig.getShares();
|
||||
Enumeration<SharedDevice> shareEnum = shareList.enumerateShares();
|
||||
|
||||
while ( shareEnum.hasMoreElements())
|
||||
{
|
||||
// Get the current shared device
|
||||
|
||||
SharedDevice share = shareEnum.nextElement();
|
||||
if ( share.getContext() instanceof ContentContext)
|
||||
{
|
||||
// Found a content filesystem share
|
||||
|
||||
ContentContext ctx = (ContentContext) share.getContext();
|
||||
|
||||
// Store the share details that are used for the tenant shares
|
||||
|
||||
m_rootPath = ctx.getRootPath();
|
||||
m_storeName = ctx.getStoreName();
|
||||
|
||||
if ( m_tenantShareName == null)
|
||||
m_tenantShareName = ctx.getDeviceName();
|
||||
}
|
||||
}
|
||||
this.m_config = config;
|
||||
}
|
||||
|
||||
public void setTenantShareName(String shareName)
|
||||
{
|
||||
m_tenantShareName = shareName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the quota manager to be used by multi-tenant shares
|
||||
*
|
||||
* @param quotaManager QuotaManager
|
||||
*/
|
||||
public void setQuotaManager( QuotaManager quotaManager)
|
||||
{
|
||||
m_quotaManager = quotaManager;
|
||||
}
|
||||
|
||||
public void setRootPath(String m_rootPath)
|
||||
{
|
||||
this.m_rootPath = m_rootPath;
|
||||
}
|
||||
|
||||
public String getRootPath()
|
||||
{
|
||||
return m_rootPath;
|
||||
}
|
||||
|
||||
public void setStoreName(String m_storeName)
|
||||
{
|
||||
this.m_storeName = m_storeName;
|
||||
}
|
||||
|
||||
public String getStoreName()
|
||||
{
|
||||
return m_storeName;
|
||||
}
|
||||
|
||||
public void setRepoDiskInterface(DiskInterface repoDiskInterface)
|
||||
{
|
||||
this.repoDiskInterface = repoDiskInterface;
|
||||
}
|
||||
|
||||
public DiskInterface getRepoDiskInterface()
|
||||
{
|
||||
return repoDiskInterface;
|
||||
}
|
||||
}
|
||||
|
@@ -291,7 +291,7 @@ public class AVMShareMapper implements ShareMapper, InitializingBean {
|
||||
{
|
||||
ServerConfigurationBean config = (ServerConfigurationBean)m_config;
|
||||
|
||||
config.initialiseRuntimeContext(avmCtx);
|
||||
config.initialiseRuntimeContext("cifs.avm" + name, avmCtx);
|
||||
|
||||
// Enable file state caching
|
||||
// diskCtx.enableStateCache(serverConfigurationBean, true);
|
||||
|
@@ -1704,7 +1704,7 @@ public class ServerConfigurationBean extends AbstractServerConfigurationBean imp
|
||||
{
|
||||
logger.debug("start hazelcast cache : " + clusterConfigBean.getClusterName() + ", shareName: "+ diskCtx.getShareName());
|
||||
}
|
||||
GenericConfigElement hazelConfig = createClusterConfig(diskCtx.getShareName());
|
||||
GenericConfigElement hazelConfig = createClusterConfig("cifs.avm."+diskCtx.getShareName());
|
||||
HazelCastClusterFileStateCache hazel = new HazelCastClusterFileStateCache();
|
||||
hazel.initializeCache(hazelConfig, this);
|
||||
diskCtx.setStateCache(hazel);
|
||||
@@ -1716,6 +1716,7 @@ public class ServerConfigurationBean extends AbstractServerConfigurationBean imp
|
||||
standaloneCache.initializeCache( new GenericConfigElement( ""), this);
|
||||
diskCtx.setStateCache(standaloneCache);
|
||||
}
|
||||
|
||||
if ( diskCtx.hasStateCache()) {
|
||||
|
||||
// Register the state cache with the reaper thread
|
||||
@@ -1747,7 +1748,7 @@ public class ServerConfigurationBean extends AbstractServerConfigurationBean imp
|
||||
{
|
||||
logger.debug("start hazelcast cache : " + clusterConfigBean.getClusterName() + ", shareName: "+ filesysContext.getShareName());
|
||||
}
|
||||
GenericConfigElement hazelConfig = createClusterConfig(filesysContext.getShareName());
|
||||
GenericConfigElement hazelConfig = createClusterConfig("cifs.filesys."+filesysContext.getShareName());
|
||||
HazelCastClusterFileStateCache hazel = new HazelCastClusterFileStateCache();
|
||||
hazel.initializeCache(hazelConfig, this);
|
||||
filesysContext.setStateCache(hazel);
|
||||
@@ -1763,7 +1764,7 @@ public class ServerConfigurationBean extends AbstractServerConfigurationBean imp
|
||||
if ( filesysContext.hasStateCache()) {
|
||||
|
||||
// Register the state cache with the reaper thread
|
||||
|
||||
// has many side effects including initialisation of the cache
|
||||
fsysConfig.addFileStateCache( filesystem.getDeviceName(), filesysContext.getStateCache());
|
||||
|
||||
// Create the lock manager for the context.
|
||||
@@ -1970,19 +1971,7 @@ public class ServerConfigurationBean extends AbstractServerConfigurationBean imp
|
||||
// Associate the share mapper
|
||||
secConfig.setShareMapper(shareMapper);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Check if the tenant service is enabled
|
||||
if (m_tenantService != null && m_tenantService.isEnabled())
|
||||
{
|
||||
// Initialize the multi-tenancy share mapper
|
||||
|
||||
secConfig.setShareMapper("org.alfresco.filesys.alfresco.MultiTenantShareMapper",
|
||||
new GenericConfigElement("shareMapper"));
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Check if any domain mappings have been specified
|
||||
|
||||
List<DomainMappingConfigBean> mappings = securityConfigBean.getDomainMappings();
|
||||
@@ -2256,8 +2245,10 @@ public class ServerConfigurationBean extends AbstractServerConfigurationBean imp
|
||||
*
|
||||
* @param diskCtx
|
||||
*/
|
||||
public void initialiseRuntimeContext(AlfrescoContext diskCtx)
|
||||
public void initialiseRuntimeContext(String uniqueName, AlfrescoContext diskCtx)
|
||||
{
|
||||
logger.debug("initialiseRuntimeContext" + diskCtx);
|
||||
|
||||
if (diskCtx.getStateCache() == null) {
|
||||
|
||||
// Set the state cache, use a hard coded standalone cache for now
|
||||
@@ -2272,9 +2263,9 @@ public class ServerConfigurationBean extends AbstractServerConfigurationBean imp
|
||||
{
|
||||
if(logger.isDebugEnabled())
|
||||
{
|
||||
logger.debug("start hazelcast cache : " + clusterConfigBean.getClusterName() + ", shareName: "+ diskCtx.getShareName());
|
||||
logger.debug("start hazelcast cache : " + clusterConfigBean.getClusterName() + ", uniqueName: "+ uniqueName);
|
||||
}
|
||||
GenericConfigElement hazelConfig = createClusterConfig(diskCtx.getShareName());
|
||||
GenericConfigElement hazelConfig = createClusterConfig(uniqueName);
|
||||
HazelCastClusterFileStateCache hazel = new HazelCastClusterFileStateCache();
|
||||
hazel.initializeCache(hazelConfig, this);
|
||||
diskCtx.setStateCache(hazel);
|
||||
@@ -2287,10 +2278,14 @@ public class ServerConfigurationBean extends AbstractServerConfigurationBean imp
|
||||
filesysConfig.addFileStateCache( diskCtx.getDeviceName(), standaloneCache);
|
||||
diskCtx.setStateCache( standaloneCache);
|
||||
}
|
||||
|
||||
FileStateLockManager lockMgr = new FileStateLockManager(diskCtx.getStateCache());
|
||||
diskCtx.setLockManager(lockMgr);
|
||||
diskCtx.setOpLockManager(lockMgr);
|
||||
|
||||
// Register the state cache with the reaper thread
|
||||
// has many side effects including initialisation of the cache
|
||||
filesysConfig.addFileStateCache( diskCtx.getShareName(), diskCtx.getStateCache());
|
||||
|
||||
FileStateLockManager lockMgr = new FileStateLockManager(diskCtx.getStateCache());
|
||||
diskCtx.setLockManager(lockMgr);
|
||||
diskCtx.setOpLockManager(lockMgr);
|
||||
}
|
||||
catch ( InvalidConfigurationException ex)
|
||||
{
|
||||
@@ -2333,7 +2328,7 @@ public class ServerConfigurationBean extends AbstractServerConfigurationBean imp
|
||||
}
|
||||
|
||||
|
||||
private GenericConfigElement createClusterConfig(String topicName) throws InvalidConfigurationException
|
||||
private GenericConfigElement createClusterConfig(String topicName) throws InvalidConfigurationException
|
||||
{
|
||||
GenericConfigElement config = new GenericConfigElement("hazelcastStateCache");
|
||||
GenericConfigElement clusterNameCfg = new GenericConfigElement("clusterName");
|
||||
|
@@ -101,7 +101,7 @@ public class ContentContext extends AlfrescoContext
|
||||
/**
|
||||
* Class constructor
|
||||
*
|
||||
*@param filesysName
|
||||
*@param deviceName
|
||||
* String
|
||||
* @param storeName
|
||||
* String
|
||||
@@ -110,9 +110,9 @@ public class ContentContext extends AlfrescoContext
|
||||
* @param rootNodeRef
|
||||
* NodeRef
|
||||
*/
|
||||
public ContentContext(String filesysName, String storeName, String rootPath, NodeRef rootNodeRef)
|
||||
public ContentContext(String deviceName, String storeName, String rootPath, NodeRef rootNodeRef)
|
||||
{
|
||||
setDeviceName(filesysName);
|
||||
setDeviceName(deviceName);
|
||||
setStoreName(storeName);
|
||||
setRootPath(rootPath);
|
||||
setRootNodeRef(rootNodeRef);
|
||||
|
@@ -1,420 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2010 Alfresco Software Limited.
|
||||
*
|
||||
* This file is part of Alfresco
|
||||
*
|
||||
* Alfresco is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Alfresco is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package org.alfresco.filesys.repo;
|
||||
|
||||
import java.util.Enumeration;
|
||||
|
||||
import org.alfresco.jlan.server.SrvSession;
|
||||
import org.alfresco.jlan.server.auth.ClientInfo;
|
||||
import org.alfresco.jlan.server.auth.InvalidUserException;
|
||||
import org.alfresco.jlan.server.config.InvalidConfigurationException;
|
||||
import org.alfresco.jlan.server.config.ServerConfiguration;
|
||||
import org.alfresco.jlan.server.core.InvalidDeviceInterfaceException;
|
||||
import org.alfresco.jlan.server.core.ShareMapper;
|
||||
import org.alfresco.jlan.server.core.ShareType;
|
||||
import org.alfresco.jlan.server.core.SharedDevice;
|
||||
import org.alfresco.jlan.server.core.SharedDeviceList;
|
||||
import org.alfresco.jlan.server.filesys.DiskSharedDevice;
|
||||
import org.alfresco.jlan.server.filesys.FilesystemsConfigSection;
|
||||
import org.springframework.extensions.config.ConfigElement;
|
||||
import org.alfresco.error.AlfrescoRuntimeException;
|
||||
import org.alfresco.filesys.alfresco.AlfrescoClientInfo;
|
||||
import org.alfresco.filesys.config.ServerConfigurationBean;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.springframework.beans.factory.InitializingBean;
|
||||
|
||||
/**
|
||||
* Home Share Mapper Class
|
||||
*
|
||||
* <p>Maps disk share lookup requests to the list of shares defined in the server
|
||||
* configuration and provides a dynamic home share mapped to the users home node.
|
||||
*
|
||||
* @author GKSpencer
|
||||
*/
|
||||
public class HomeShareMapper implements ShareMapper, InitializingBean
|
||||
{
|
||||
// Logging
|
||||
|
||||
private static final Log logger = LogFactory.getLog("org.alfresco.smb.protocol");
|
||||
|
||||
// Home folder share name
|
||||
|
||||
public static final String HOME_FOLDER_SHARE = "HOME";
|
||||
|
||||
// Server configuration and sections
|
||||
|
||||
private ServerConfiguration m_config;
|
||||
private FilesystemsConfigSection m_filesysConfig;
|
||||
|
||||
// Filesystem driver to be used to create home shares
|
||||
|
||||
private ContentDiskDriver m_driver;
|
||||
|
||||
// Home folder share name
|
||||
|
||||
private String m_homeShareName = HOME_FOLDER_SHARE;
|
||||
|
||||
// Debug enable flag
|
||||
|
||||
private boolean m_debug;
|
||||
|
||||
/**
|
||||
* Default constructor
|
||||
*/
|
||||
public HomeShareMapper()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
public void setServerConfiguration(ServerConfiguration config)
|
||||
{
|
||||
this.m_config = config;
|
||||
}
|
||||
|
||||
public void setName(String shareName)
|
||||
{
|
||||
m_homeShareName = shareName;
|
||||
}
|
||||
|
||||
public void setDebug(boolean debug)
|
||||
{
|
||||
this.m_debug = debug;
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize the share mapper
|
||||
*
|
||||
* @param config ServerConfiguration
|
||||
* @param params ConfigElement
|
||||
* @exception InvalidConfigurationException
|
||||
*/
|
||||
public void initializeMapper(ServerConfiguration config, ConfigElement params) throws InvalidConfigurationException
|
||||
{
|
||||
// Save the server configuration
|
||||
|
||||
setServerConfiguration(config);
|
||||
|
||||
// Check if the home share name has been specified
|
||||
|
||||
String homeName = params.getAttribute("name");
|
||||
if ( homeName != null && homeName.length() > 0)
|
||||
setName(homeName);
|
||||
|
||||
// Check if debug is enabled
|
||||
|
||||
if (params != null && params.getChild("debug") != null)
|
||||
setDebug(true);
|
||||
|
||||
// Complete initialization
|
||||
afterPropertiesSet();
|
||||
}
|
||||
|
||||
|
||||
public void afterPropertiesSet()
|
||||
{
|
||||
// Save the server configuration
|
||||
m_filesysConfig = (FilesystemsConfigSection) m_config.getConfigSection(FilesystemsConfigSection.SectionName);
|
||||
|
||||
// Search for a filesystem that uses the content driver to use the driver when creating the home shares
|
||||
|
||||
SharedDeviceList shares = m_filesysConfig.getShares();
|
||||
|
||||
if ( shares != null)
|
||||
{
|
||||
Enumeration<SharedDevice> shrEnum = shares.enumerateShares();
|
||||
|
||||
while ( shrEnum.hasMoreElements() && m_driver == null)
|
||||
{
|
||||
try
|
||||
{
|
||||
SharedDevice curShare = shrEnum.nextElement();
|
||||
if ( curShare.getInterface() instanceof ContentDiskDriver)
|
||||
m_driver = (ContentDiskDriver) curShare.getInterface();
|
||||
}
|
||||
catch (InvalidDeviceInterfaceException ex)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if debug output is enabled
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public final boolean hasDebug()
|
||||
{
|
||||
return m_debug;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the home folder share name
|
||||
*
|
||||
* @return String
|
||||
*/
|
||||
public final String getHomeFolderName()
|
||||
{
|
||||
return m_homeShareName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the list of available shares.
|
||||
*
|
||||
* @param host String
|
||||
* @param sess SrvSession
|
||||
* @param allShares boolean
|
||||
* @return SharedDeviceList
|
||||
*/
|
||||
public SharedDeviceList getShareList(String host, SrvSession sess, boolean allShares)
|
||||
{
|
||||
// Check if the user has a home folder, and the session does not currently have any
|
||||
// dynamic shares defined
|
||||
|
||||
if ( sess != null && sess.hasClientInformation() && sess.hasDynamicShares() == false &&
|
||||
sess.getClientInformation() instanceof AlfrescoClientInfo)
|
||||
{
|
||||
AlfrescoClientInfo alfClient = (AlfrescoClientInfo) sess.getClientInformation();
|
||||
if ( alfClient.hasHomeFolder())
|
||||
{
|
||||
// Create the home folder share
|
||||
|
||||
DiskSharedDevice homeShare = createHomeDiskShare( alfClient);
|
||||
sess.addDynamicShare(homeShare);
|
||||
|
||||
// Debug
|
||||
|
||||
if ( logger.isDebugEnabled())
|
||||
logger.debug("Added " + getHomeFolderName() + " share to list of shares for " + alfClient.getUserName());
|
||||
}
|
||||
}
|
||||
|
||||
// Make a copy of the global share list and add the per session dynamic shares
|
||||
|
||||
SharedDeviceList shrList = new SharedDeviceList(m_filesysConfig.getShares());
|
||||
|
||||
if ( sess != null && sess.hasDynamicShares()) {
|
||||
|
||||
// Add the per session dynamic shares
|
||||
|
||||
shrList.addShares(sess.getDynamicShareList());
|
||||
}
|
||||
|
||||
// Remove unavailable shares from the list and return the list
|
||||
|
||||
if ( allShares == false)
|
||||
shrList.removeUnavailableShares();
|
||||
return shrList;
|
||||
}
|
||||
|
||||
/**
|
||||
* Find a share using the name and type for the specified client.
|
||||
*
|
||||
* @param host String
|
||||
* @param name String
|
||||
* @param typ int
|
||||
* @param sess SrvSession
|
||||
* @param create boolean
|
||||
* @return SharedDevice
|
||||
* @exception InvalidUserException
|
||||
*/
|
||||
public SharedDevice findShare(String tohost, String name, int typ, SrvSession sess, boolean create)
|
||||
throws Exception
|
||||
{
|
||||
|
||||
// Check for the special HOME disk share
|
||||
|
||||
SharedDevice share = null;
|
||||
|
||||
if (( typ == ShareType.DISK || typ == ShareType.UNKNOWN) && name.equalsIgnoreCase(getHomeFolderName()) &&
|
||||
sess.getClientInformation() != null && m_driver != null) {
|
||||
|
||||
// Get the client details
|
||||
|
||||
ClientInfo client = sess.getClientInformation();
|
||||
|
||||
// DEBUG
|
||||
|
||||
if ( logger.isDebugEnabled())
|
||||
logger.debug("Map share " + name + ", type=" + ShareType.TypeAsString(typ) + ", client=" + client);
|
||||
|
||||
// Check if the user has a home folder node
|
||||
|
||||
if ( client != null && client instanceof AlfrescoClientInfo) {
|
||||
|
||||
// Access the extended client information
|
||||
|
||||
AlfrescoClientInfo alfClient = (AlfrescoClientInfo) client;
|
||||
|
||||
if ( alfClient.hasHomeFolder()) {
|
||||
|
||||
// Check if the share has already been created for the session
|
||||
|
||||
if ( sess.hasDynamicShares()) {
|
||||
|
||||
// Check if the required share exists in the sessions dynamic share list
|
||||
|
||||
share = sess.getDynamicShareList().findShare(name, typ, false);
|
||||
|
||||
// DEBUG
|
||||
|
||||
if ( logger.isDebugEnabled())
|
||||
logger.debug(" Reusing existing dynamic share for " + name);
|
||||
}
|
||||
|
||||
// Check if we found a share, if not then create a new dynamic share for the home directory
|
||||
|
||||
if ( share == null && create == true) {
|
||||
|
||||
// Create the home share mapped to the users home folder
|
||||
|
||||
DiskSharedDevice diskShare = createHomeDiskShare( alfClient);
|
||||
|
||||
// Add the new share to the sessions dynamic share list
|
||||
|
||||
sess.addDynamicShare(diskShare);
|
||||
share = diskShare;
|
||||
|
||||
// DEBUG
|
||||
|
||||
if (logger.isDebugEnabled())
|
||||
logger.debug(" Mapped share " + name + " to " + alfClient.getHomeFolder());
|
||||
}
|
||||
}
|
||||
else
|
||||
throw new InvalidUserException("No home directory");
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
||||
// Find the required share by name/type. Use a case sensitive search first, if that fails use a case
|
||||
// insensitive search.
|
||||
|
||||
share = m_filesysConfig.getShares().findShare(name, typ, false);
|
||||
|
||||
if ( share == null) {
|
||||
|
||||
// Try a case insensitive search for the required share
|
||||
|
||||
share = m_filesysConfig.getShares().findShare(name, typ, true);
|
||||
}
|
||||
}
|
||||
|
||||
// Check if the share is available
|
||||
|
||||
if ( share != null && share.getContext() != null && share.getContext().isAvailable() == false)
|
||||
share = null;
|
||||
|
||||
// Return the shared device, or null if no matching device was found
|
||||
|
||||
return share;
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete temporary shares for the specified session
|
||||
*
|
||||
* @param sess SrvSession
|
||||
*/
|
||||
public void deleteShares(SrvSession sess)
|
||||
{
|
||||
|
||||
// Check if the session has any dynamic shares
|
||||
|
||||
if ( sess.hasDynamicShares() == false)
|
||||
return;
|
||||
|
||||
// Delete the dynamic shares
|
||||
|
||||
SharedDeviceList shares = sess.getDynamicShareList();
|
||||
Enumeration<SharedDevice> enm = shares.enumerateShares();
|
||||
|
||||
while ( enm.hasMoreElements()) {
|
||||
|
||||
// Get the current share from the list
|
||||
|
||||
SharedDevice shr = enm.nextElement();
|
||||
|
||||
// Close the shared device
|
||||
|
||||
shr.getContext().CloseContext();
|
||||
|
||||
// DEBUG
|
||||
|
||||
if (logger.isDebugEnabled())
|
||||
logger.debug("Deleted dynamic share " + shr);
|
||||
}
|
||||
|
||||
// Clear the dynamic share list
|
||||
|
||||
shares.removeAllShares();
|
||||
}
|
||||
|
||||
/**
|
||||
* Close the share mapper, release any resources.
|
||||
*/
|
||||
public void closeMapper()
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a disk share for the home folder
|
||||
*
|
||||
* @param alfClient AlfrescoClientInfo
|
||||
* @return DiskSharedDevice
|
||||
*/
|
||||
private final DiskSharedDevice createHomeDiskShare(AlfrescoClientInfo alfClient)
|
||||
{
|
||||
// Make sure the client is an Alfresco client
|
||||
|
||||
if ( alfClient != null) {
|
||||
|
||||
// Create the disk driver and context
|
||||
|
||||
ContentContext diskCtx = new ContentContext( getHomeFolderName(), "", "", alfClient.getHomeFolder());
|
||||
|
||||
if(m_config instanceof ServerConfigurationBean)
|
||||
{
|
||||
ServerConfigurationBean config = (ServerConfigurationBean)m_config;
|
||||
|
||||
config.initialiseRuntimeContext(diskCtx);
|
||||
|
||||
// Enable file state caching
|
||||
// diskCtx.enableStateCache(serverConfigurationBean, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new AlfrescoRuntimeException("configuration error, unknown configuration bean");
|
||||
}
|
||||
|
||||
|
||||
// Create a temporary shared device for the users home directory
|
||||
|
||||
return new DiskSharedDevice(getHomeFolderName(), m_driver, diskCtx, SharedDevice.Temporary);
|
||||
}
|
||||
|
||||
// Invalid client type
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user