mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-24 17:32:48 +00:00
Tenant Services hooks for FTP - for getting tenant-specific company home/root space
git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@6670 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -32,8 +32,17 @@
|
|||||||
<ref bean="authenticationComponent"/>
|
<ref bean="authenticationComponent"/>
|
||||||
</property>
|
</property>
|
||||||
<property name="nodeService">
|
<property name="nodeService">
|
||||||
<ref bean="nodeService"/>
|
<ref bean="NodeService"/>
|
||||||
|
</property>
|
||||||
|
<property name="tenantService">
|
||||||
|
<ref bean="tenantService" />
|
||||||
</property>
|
</property>
|
||||||
|
<property name="searchService">
|
||||||
|
<ref bean="SearchService" />
|
||||||
|
</property>
|
||||||
|
<property name="namespaceService">
|
||||||
|
<ref bean="namespaceService" />
|
||||||
|
</property>
|
||||||
<property name="personService">
|
<property name="personService">
|
||||||
<ref bean="personService"/>
|
<ref bean="personService"/>
|
||||||
</property>
|
</property>
|
||||||
|
@@ -42,10 +42,12 @@ import java.util.Vector;
|
|||||||
|
|
||||||
import javax.transaction.UserTransaction;
|
import javax.transaction.UserTransaction;
|
||||||
|
|
||||||
|
import org.alfresco.filesys.avm.AVMDiskDriver;
|
||||||
import org.alfresco.filesys.server.SrvSession;
|
import org.alfresco.filesys.server.SrvSession;
|
||||||
import org.alfresco.filesys.server.auth.ClientInfo;
|
import org.alfresco.filesys.server.auth.ClientInfo;
|
||||||
import org.alfresco.filesys.server.auth.acl.AccessControl;
|
import org.alfresco.filesys.server.auth.acl.AccessControl;
|
||||||
import org.alfresco.filesys.server.auth.acl.AccessControlManager;
|
import org.alfresco.filesys.server.auth.acl.AccessControlManager;
|
||||||
|
import org.alfresco.filesys.server.core.InvalidDeviceInterfaceException;
|
||||||
import org.alfresco.filesys.server.core.SharedDevice;
|
import org.alfresco.filesys.server.core.SharedDevice;
|
||||||
import org.alfresco.filesys.server.core.SharedDeviceList;
|
import org.alfresco.filesys.server.core.SharedDeviceList;
|
||||||
import org.alfresco.filesys.server.filesys.AccessDeniedException;
|
import org.alfresco.filesys.server.filesys.AccessDeniedException;
|
||||||
@@ -69,10 +71,15 @@ import org.alfresco.filesys.server.filesys.TreeConnectionHash;
|
|||||||
import org.alfresco.filesys.smb.server.repo.ContentContext;
|
import org.alfresco.filesys.smb.server.repo.ContentContext;
|
||||||
import org.alfresco.model.ContentModel;
|
import org.alfresco.model.ContentModel;
|
||||||
import org.alfresco.repo.security.authentication.AuthenticationComponent;
|
import org.alfresco.repo.security.authentication.AuthenticationComponent;
|
||||||
|
import org.alfresco.repo.security.authentication.AuthenticationException;
|
||||||
|
import org.alfresco.repo.tenant.TenantService;
|
||||||
import org.alfresco.service.cmr.repository.NodeRef;
|
import org.alfresco.service.cmr.repository.NodeRef;
|
||||||
import org.alfresco.service.cmr.repository.NodeService;
|
import org.alfresco.service.cmr.repository.NodeService;
|
||||||
|
import org.alfresco.service.cmr.repository.StoreRef;
|
||||||
|
import org.alfresco.service.cmr.search.SearchService;
|
||||||
import org.alfresco.service.cmr.security.AuthenticationService;
|
import org.alfresco.service.cmr.security.AuthenticationService;
|
||||||
import org.alfresco.service.cmr.security.PersonService;
|
import org.alfresco.service.cmr.security.PersonService;
|
||||||
|
import org.alfresco.service.namespace.NamespaceService;
|
||||||
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;
|
||||||
@@ -3931,6 +3938,8 @@ public class FTPSrvSession extends SrvSession implements Runnable
|
|||||||
|
|
||||||
// Search for disk shares
|
// Search for disk shares
|
||||||
|
|
||||||
|
TenantService tenantService = getServer().getConfiguration().getTenantService();
|
||||||
|
|
||||||
m_shares = new SharedDeviceList();
|
m_shares = new SharedDeviceList();
|
||||||
Enumeration enm = shares.enumerateShares();
|
Enumeration enm = shares.enumerateShares();
|
||||||
|
|
||||||
@@ -3944,7 +3953,36 @@ public class FTPSrvSession extends SrvSession implements Runnable
|
|||||||
// Check if the share is a disk share
|
// Check if the share is a disk share
|
||||||
|
|
||||||
if (shr instanceof DiskSharedDevice)
|
if (shr instanceof DiskSharedDevice)
|
||||||
m_shares.addShare(shr);
|
{
|
||||||
|
if ((tenantService.isEnabled()) && (tenantService.isTenantUser()))
|
||||||
|
{
|
||||||
|
DiskSharedDevice dsd = (DiskSharedDevice)shr;
|
||||||
|
DiskDeviceContext ddc = dsd.getDiskContext();
|
||||||
|
if (ddc instanceof ContentContext)
|
||||||
|
{
|
||||||
|
// TODO - consider fixed tenant-specific shares ?
|
||||||
|
ContentContext cc = (ContentContext)ddc;
|
||||||
|
|
||||||
|
DiskSharedDevice tenantCompanyHomeShare = createCompanyHomeDiskShare(cc.getFilesystemName(), cc.getStoreName(), cc.getRootPath());
|
||||||
|
m_shares.addShare(tenantCompanyHomeShare);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (shr.getInterface() instanceof AVMDiskDriver)
|
||||||
|
{
|
||||||
|
// skip
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (InvalidDeviceInterfaceException ex)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
m_shares.addShare(shr);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check if there is an access control manager available, if so then
|
// Check if there is an access control manager available, if so then
|
||||||
@@ -4082,6 +4120,34 @@ public class FTPSrvSession extends SrvSession implements Runnable
|
|||||||
|
|
||||||
return new DiskSharedDevice( client.getUserName(), diskDrv, diskCtx, SharedDevice.Temporary);
|
return new DiskSharedDevice( client.getUserName(), diskDrv, diskCtx, SharedDevice.Temporary);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private final DiskSharedDevice createCompanyHomeDiskShare(String filesysName, String storeName, String rootPath)
|
||||||
|
{
|
||||||
|
TenantService tenantService = getServer().getConfiguration().getTenantService();
|
||||||
|
NodeService nodeService = getServer().getConfiguration().getNodeService();
|
||||||
|
SearchService searchService = getServer().getConfiguration().getSearchService();
|
||||||
|
NamespaceService namespaceService = getServer().getConfiguration().getNamespaceService();
|
||||||
|
|
||||||
|
StoreRef storeRef = new StoreRef(storeName);
|
||||||
|
NodeRef rootNodeRef = new NodeRef(storeRef.getProtocol(), storeRef.getIdentifier(), "dummy");
|
||||||
|
|
||||||
|
// root nodeRef is required for storeRef part
|
||||||
|
rootNodeRef = tenantService.getRootNode(nodeService, searchService, namespaceService, rootPath, rootNodeRef);
|
||||||
|
|
||||||
|
// Create the disk driver and context
|
||||||
|
|
||||||
|
DiskInterface diskDrv = getServer().getConfiguration().getDiskInterface();
|
||||||
|
DiskDeviceContext diskCtx = new ContentContext(filesysName, "", rootPath, rootNodeRef);
|
||||||
|
|
||||||
|
// Default the filesystem to look like an 80Gb sized disk with 90% free space
|
||||||
|
|
||||||
|
diskCtx.setDiskInformation(new SrvDiskInfo(2560, 64, 512, 2304));
|
||||||
|
|
||||||
|
// Create a temporary shared device for the user to access the tenant company home directory
|
||||||
|
|
||||||
|
return new DiskSharedDevice(filesysName, diskDrv, diskCtx, SharedDevice.Temporary);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Start the FTP session in a seperate thread
|
* Start the FTP session in a seperate thread
|
||||||
|
@@ -97,9 +97,12 @@ import org.alfresco.filesys.util.StringList;
|
|||||||
import org.alfresco.filesys.util.X64;
|
import org.alfresco.filesys.util.X64;
|
||||||
import org.alfresco.repo.security.authentication.AuthenticationComponent;
|
import org.alfresco.repo.security.authentication.AuthenticationComponent;
|
||||||
import org.alfresco.repo.security.authentication.NTLMMode;
|
import org.alfresco.repo.security.authentication.NTLMMode;
|
||||||
|
import org.alfresco.repo.tenant.TenantService;
|
||||||
import org.alfresco.service.cmr.repository.NodeService;
|
import org.alfresco.service.cmr.repository.NodeService;
|
||||||
|
import org.alfresco.service.cmr.search.SearchService;
|
||||||
import org.alfresco.service.cmr.security.AuthenticationService;
|
import org.alfresco.service.cmr.security.AuthenticationService;
|
||||||
import org.alfresco.service.cmr.security.PersonService;
|
import org.alfresco.service.cmr.security.PersonService;
|
||||||
|
import org.alfresco.service.namespace.NamespaceService;
|
||||||
import org.alfresco.service.transaction.TransactionService;
|
import org.alfresco.service.transaction.TransactionService;
|
||||||
import org.alfresco.util.AbstractLifecycleBean;
|
import org.alfresco.util.AbstractLifecycleBean;
|
||||||
import org.apache.commons.logging.Log;
|
import org.apache.commons.logging.Log;
|
||||||
@@ -402,6 +405,9 @@ public class ServerConfiguration extends AbstractLifecycleBean
|
|||||||
// Various services
|
// Various services
|
||||||
|
|
||||||
private NodeService m_nodeService;
|
private NodeService m_nodeService;
|
||||||
|
private TenantService m_tenantService;
|
||||||
|
private SearchService m_searchService;
|
||||||
|
private NamespaceService m_namespaceService;
|
||||||
private PersonService m_personService;
|
private PersonService m_personService;
|
||||||
private TransactionService m_transactionService;
|
private TransactionService m_transactionService;
|
||||||
|
|
||||||
@@ -521,6 +527,36 @@ public class ServerConfiguration extends AbstractLifecycleBean
|
|||||||
m_nodeService = service;
|
m_nodeService = service;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the namespace service
|
||||||
|
*
|
||||||
|
* @param service NamespaceService
|
||||||
|
*/
|
||||||
|
public void setNamespaceService(NamespaceService service)
|
||||||
|
{
|
||||||
|
m_namespaceService = service;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the search service
|
||||||
|
*
|
||||||
|
* @param service SearchService
|
||||||
|
*/
|
||||||
|
public void setSearchService(SearchService service)
|
||||||
|
{
|
||||||
|
m_searchService = service;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the tenant service
|
||||||
|
*
|
||||||
|
* @param service TenantService
|
||||||
|
*/
|
||||||
|
public void setTenantService(TenantService service)
|
||||||
|
{
|
||||||
|
m_tenantService = service;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the person service
|
* Set the person service
|
||||||
*
|
*
|
||||||
@@ -573,6 +609,18 @@ public class ServerConfiguration extends AbstractLifecycleBean
|
|||||||
{
|
{
|
||||||
throw new AlfrescoRuntimeException("Property 'nodeService' not set");
|
throw new AlfrescoRuntimeException("Property 'nodeService' not set");
|
||||||
}
|
}
|
||||||
|
else if (m_tenantService == null)
|
||||||
|
{
|
||||||
|
throw new AlfrescoRuntimeException("Property 'tenantService' not set");
|
||||||
|
}
|
||||||
|
else if (m_searchService == null)
|
||||||
|
{
|
||||||
|
throw new AlfrescoRuntimeException("Property 'searchService' not set");
|
||||||
|
}
|
||||||
|
else if (m_namespaceService == null)
|
||||||
|
{
|
||||||
|
throw new AlfrescoRuntimeException("Property 'namespaceService' not set");
|
||||||
|
}
|
||||||
else if (m_personService == null)
|
else if (m_personService == null)
|
||||||
{
|
{
|
||||||
throw new AlfrescoRuntimeException("Property 'personService' not set");
|
throw new AlfrescoRuntimeException("Property 'personService' not set");
|
||||||
@@ -2791,6 +2839,36 @@ public class ServerConfiguration extends AbstractLifecycleBean
|
|||||||
return m_nodeService;
|
return m_nodeService;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return the tenant service
|
||||||
|
*
|
||||||
|
* @return TenantService
|
||||||
|
*/
|
||||||
|
public final TenantService getTenantService()
|
||||||
|
{
|
||||||
|
return m_tenantService;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return the namespace service
|
||||||
|
*
|
||||||
|
* @return NamespaceService
|
||||||
|
*/
|
||||||
|
public final NamespaceService getNamespaceService()
|
||||||
|
{
|
||||||
|
return m_namespaceService;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return the node service
|
||||||
|
*
|
||||||
|
* @return NodeService
|
||||||
|
*/
|
||||||
|
public final SearchService getSearchService()
|
||||||
|
{
|
||||||
|
return m_searchService;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the person service
|
* Return the person service
|
||||||
*
|
*
|
||||||
|
Reference in New Issue
Block a user