mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
Tenant Services hooks for WebClient - for getting tenant-specific company home/root space [not guest*servlets yet]
git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@6645 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -49,6 +49,7 @@ import org.alfresco.web.bean.ErrorBean;
|
||||
import org.alfresco.web.bean.SidebarBean;
|
||||
import org.alfresco.web.bean.dashboard.DashboardManager;
|
||||
import org.alfresco.web.bean.dialog.DialogManager;
|
||||
import org.alfresco.web.bean.repository.Repository;
|
||||
import org.alfresco.web.bean.repository.User;
|
||||
import org.alfresco.web.bean.wizard.WizardManager;
|
||||
import org.alfresco.web.config.ClientConfigElement;
|
||||
@@ -312,7 +313,9 @@ public class Application
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Returns id of the company root
|
||||
* @return Returns id of the company root
|
||||
*
|
||||
* @deprecated Replace with user-context-specific getCompanyRootId (e.g. could be tenant-specific)
|
||||
*/
|
||||
public static String getCompanyRootId()
|
||||
{
|
||||
@@ -323,12 +326,37 @@ public class Application
|
||||
* Sets the company root id. This is setup by the ContextListener.
|
||||
*
|
||||
* @param id The company root id
|
||||
*
|
||||
* @deprecated Replace with user-context-specific getCompanyRootId (e.g. could be tenant-specific)
|
||||
*/
|
||||
public static void setCompanyRootId(String id)
|
||||
{
|
||||
companyRootId = id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Returns id of the company root
|
||||
*/
|
||||
public static String getCompanyRootId(FacesContext context)
|
||||
{
|
||||
User user = Application.getCurrentUser(context);
|
||||
if (user != null)
|
||||
{
|
||||
String userCompanyRootId = user.getCompanyRootId();
|
||||
if (userCompanyRootId == null)
|
||||
{
|
||||
userCompanyRootId = Repository.getCompanyRoot(context).getId();
|
||||
user.setCompanyRootId(userCompanyRootId);
|
||||
}
|
||||
|
||||
return userCompanyRootId;
|
||||
}
|
||||
else
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Returns the root path for the application
|
||||
*/
|
||||
|
@@ -25,7 +25,6 @@
|
||||
package org.alfresco.web.app;
|
||||
|
||||
import java.util.Enumeration;
|
||||
import java.util.List;
|
||||
|
||||
import javax.servlet.ServletContext;
|
||||
import javax.servlet.ServletContextEvent;
|
||||
@@ -49,8 +48,6 @@ import org.alfresco.web.bean.repository.Repository;
|
||||
import org.alfresco.web.bean.repository.User;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.quartz.Scheduler;
|
||||
import org.quartz.SchedulerException;
|
||||
import org.springframework.web.context.WebApplicationContext;
|
||||
import org.springframework.web.context.support.WebApplicationContextUtils;
|
||||
|
||||
@@ -93,33 +90,14 @@ public class ContextListener implements ServletContextListener, HttpSessionListe
|
||||
tx.begin();
|
||||
authenticationComponent.setCurrentUser(authenticationComponent.getSystemUserName());
|
||||
|
||||
// get and setup the initial store ref from config
|
||||
// get and setup the initial store ref and root path from config
|
||||
StoreRef storeRef = Repository.getStoreRef(servletContext);
|
||||
|
||||
// check the repository exists, create if it doesn't
|
||||
if (nodeService.exists(storeRef) == false)
|
||||
{
|
||||
throw new AlfrescoRuntimeException("Store not created prior to application startup: " + storeRef);
|
||||
}
|
||||
|
||||
// get hold of the root node
|
||||
NodeRef rootNodeRef = nodeService.getRootNode(storeRef);
|
||||
|
||||
// see if the company home space is present
|
||||
|
||||
// get root path
|
||||
String rootPath = Application.getRootPath(servletContext);
|
||||
if (rootPath == null)
|
||||
{
|
||||
throw new AlfrescoRuntimeException("Root path has not been configured");
|
||||
}
|
||||
|
||||
List<NodeRef> nodes = searchService.selectNodes(rootNodeRef, rootPath, null, namespaceService, false);
|
||||
if (nodes.size() == 0)
|
||||
{
|
||||
throw new AlfrescoRuntimeException("Root path not created prior to application startup: " + rootPath);
|
||||
}
|
||||
|
||||
// Extract company space id and store it in the Application object
|
||||
companySpaceNodeRef = nodes.get(0);
|
||||
companySpaceNodeRef = Repository.getCompanyRoot(nodeService, searchService, namespaceService, storeRef, rootPath);
|
||||
Application.setCompanyRootId(companySpaceNodeRef.getId());
|
||||
|
||||
// commit the transaction
|
||||
|
Reference in New Issue
Block a user