mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
TenantService hooks for WebDAV - need to lookup tenant-specific company home
git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@6634 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -37,6 +37,7 @@ import javax.transaction.UserTransaction;
|
|||||||
|
|
||||||
import org.alfresco.filesys.server.config.ServerConfiguration;
|
import org.alfresco.filesys.server.config.ServerConfiguration;
|
||||||
import org.alfresco.repo.security.authentication.AuthenticationComponent;
|
import org.alfresco.repo.security.authentication.AuthenticationComponent;
|
||||||
|
import org.alfresco.repo.tenant.TenantService;
|
||||||
import org.alfresco.service.ServiceRegistry;
|
import org.alfresco.service.ServiceRegistry;
|
||||||
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;
|
||||||
@@ -78,6 +79,9 @@ public class WebDAVServlet extends HttpServlet
|
|||||||
// Transaction service, each request is wrapped in a transaction
|
// Transaction service, each request is wrapped in a transaction
|
||||||
private TransactionService m_transactionService;
|
private TransactionService m_transactionService;
|
||||||
|
|
||||||
|
// Tenant service
|
||||||
|
private TenantService m_tenantService;
|
||||||
|
|
||||||
// WebDAV method handlers
|
// WebDAV method handlers
|
||||||
private Hashtable<String,Class> m_davMethods;
|
private Hashtable<String,Class> m_davMethods;
|
||||||
|
|
||||||
@@ -87,6 +91,9 @@ public class WebDAVServlet extends HttpServlet
|
|||||||
// WebDAV helper class
|
// WebDAV helper class
|
||||||
private WebDAVHelper m_davHelper;
|
private WebDAVHelper m_davHelper;
|
||||||
|
|
||||||
|
// Root path
|
||||||
|
private String m_rootPath;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see javax.servlet.http.HttpServlet#service(javax.servlet.http.HttpServletRequest,
|
* @see javax.servlet.http.HttpServlet#service(javax.servlet.http.HttpServletRequest,
|
||||||
* javax.servlet.http.HttpServletResponse)
|
* javax.servlet.http.HttpServletResponse)
|
||||||
@@ -214,7 +221,22 @@ public class WebDAVServlet extends HttpServlet
|
|||||||
// Create the handler method
|
// Create the handler method
|
||||||
|
|
||||||
method = (WebDAVMethod) methodClass.newInstance();
|
method = (WebDAVMethod) methodClass.newInstance();
|
||||||
method.setDetails(request, response, m_davHelper, m_rootNodeRef);
|
NodeRef rootNodeRef = null;
|
||||||
|
if (m_tenantService.isEnabled())
|
||||||
|
{
|
||||||
|
WebApplicationContext context = WebApplicationContextUtils.getRequiredWebApplicationContext(getServletContext());
|
||||||
|
NodeService nodeService = (NodeService) context.getBean("NodeService");
|
||||||
|
SearchService searchService = (SearchService) context.getBean("SearchService");
|
||||||
|
NamespaceService namespaceService = (NamespaceService) context.getBean("NamespaceService");
|
||||||
|
|
||||||
|
rootNodeRef = m_tenantService.getRootNode(nodeService, searchService, namespaceService, m_rootPath, rootNodeRef);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
rootNodeRef = m_rootNodeRef;
|
||||||
|
}
|
||||||
|
|
||||||
|
method.setDetails(request, response, m_davHelper, rootNodeRef);
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
@@ -246,7 +268,7 @@ public class WebDAVServlet extends HttpServlet
|
|||||||
m_serviceRegistry = (ServiceRegistry)context.getBean(ServiceRegistry.SERVICE_REGISTRY);
|
m_serviceRegistry = (ServiceRegistry)context.getBean(ServiceRegistry.SERVICE_REGISTRY);
|
||||||
|
|
||||||
m_transactionService = m_serviceRegistry.getTransactionService();
|
m_transactionService = m_serviceRegistry.getTransactionService();
|
||||||
|
m_tenantService = (TenantService) context.getBean("tenantService");
|
||||||
AuthenticationService authService = (AuthenticationService) context.getBean("authenticationService");
|
AuthenticationService authService = (AuthenticationService) context.getBean("authenticationService");
|
||||||
NodeService nodeService = (NodeService) context.getBean("NodeService");
|
NodeService nodeService = (NodeService) context.getBean("NodeService");
|
||||||
SearchService searchService = (SearchService) context.getBean("SearchService");
|
SearchService searchService = (SearchService) context.getBean("SearchService");
|
||||||
@@ -297,27 +319,27 @@ public class WebDAVServlet extends HttpServlet
|
|||||||
|
|
||||||
// Get the root path
|
// Get the root path
|
||||||
|
|
||||||
String rootPath = config.getInitParameter(KEY_ROOT_PATH);
|
m_rootPath = config.getInitParameter(KEY_ROOT_PATH);
|
||||||
if (rootPath == null)
|
if (m_rootPath == null)
|
||||||
{
|
{
|
||||||
throw new ServletException("Device missing init value: " + KEY_ROOT_PATH);
|
throw new ServletException("Device missing init value: " + KEY_ROOT_PATH);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Find the root node for this device
|
// Find the root node for this device
|
||||||
|
|
||||||
List<NodeRef> nodeRefs = searchService.selectNodes(storeRootNodeRef, rootPath, null, namespaceService, false);
|
List<NodeRef> nodeRefs = searchService.selectNodes(storeRootNodeRef, m_rootPath, null, namespaceService, false);
|
||||||
|
|
||||||
if (nodeRefs.size() > 1)
|
if (nodeRefs.size() > 1)
|
||||||
{
|
{
|
||||||
throw new ServletException("Multiple possible roots for device: \n" +
|
throw new ServletException("Multiple possible roots for device: \n" +
|
||||||
" root path: " + rootPath + "\n" +
|
" root path: " + m_rootPath + "\n" +
|
||||||
" results: " + nodeRefs);
|
" results: " + nodeRefs);
|
||||||
}
|
}
|
||||||
else if (nodeRefs.size() == 0)
|
else if (nodeRefs.size() == 0)
|
||||||
{
|
{
|
||||||
// nothing found
|
// nothing found
|
||||||
throw new ServletException("No root found for device: \n" +
|
throw new ServletException("No root found for device: \n" +
|
||||||
" root path: " + rootPath);
|
" root path: " + m_rootPath);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user