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:
@@ -1371,10 +1371,11 @@ public class BrowseBean implements IContextListener
|
||||
Node node = getActionSpace();
|
||||
if (node != null)
|
||||
{
|
||||
NodeRef companyRootRef = new NodeRef(Repository.getStoreRef(), Application.getCompanyRootId());
|
||||
FacesContext fc = FacesContext.getCurrentInstance();
|
||||
NodeRef companyRootRef = new NodeRef(Repository.getStoreRef(), Application.getCompanyRootId(fc));
|
||||
if (node.getNodeRef().equals(companyRootRef))
|
||||
{
|
||||
message = Application.getMessage(FacesContext.getCurrentInstance(), MSG_DELETE_COMPANYROOT);
|
||||
message = Application.getMessage(fc, MSG_DELETE_COMPANYROOT);
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -574,10 +574,11 @@ public class NavigationBean
|
||||
}
|
||||
catch (InvalidNodeRefException refErr)
|
||||
{
|
||||
FacesContext fc = FacesContext.getCurrentInstance();
|
||||
Utils.addErrorMessage(MessageFormat.format(Application.getMessage(
|
||||
FacesContext.getCurrentInstance(), ERROR_DELETED_FOLDER), new Object[] {this.currentNodeId}) );
|
||||
fc, ERROR_DELETED_FOLDER), new Object[] {this.currentNodeId}) );
|
||||
|
||||
nodeRef = new NodeRef(Repository.getStoreRef(), Application.getCompanyRootId());
|
||||
nodeRef = new NodeRef(Repository.getStoreRef(), Application.getCompanyRootId(fc));
|
||||
node = new Node(nodeRef);
|
||||
props = node.getProperties();
|
||||
}
|
||||
@@ -679,8 +680,13 @@ public class NavigationBean
|
||||
{
|
||||
if (this.companyHomeNode == null)
|
||||
{
|
||||
NodeRef companyRootRef = new NodeRef(Repository.getStoreRef(), Application.getCompanyRootId());
|
||||
this.companyHomeNode = new Node(companyRootRef);
|
||||
FacesContext fc = FacesContext.getCurrentInstance();
|
||||
String companyRootId = Application.getCompanyRootId(fc);
|
||||
if (companyRootId != null)
|
||||
{
|
||||
NodeRef companyRootRef = new NodeRef(Repository.getStoreRef(), companyRootId);
|
||||
this.companyHomeNode = new Node(companyRootRef);
|
||||
}
|
||||
}
|
||||
return this.companyHomeNode;
|
||||
}
|
||||
@@ -721,7 +727,15 @@ public class NavigationBean
|
||||
*/
|
||||
public boolean getCompanyHomeVisible()
|
||||
{
|
||||
return getCompanyHomeNode().hasPermission(PermissionService.READ);
|
||||
Node companyHomeNode = getCompanyHomeNode();
|
||||
if (companyHomeNode != null)
|
||||
{
|
||||
return companyHomeNode.hasPermission(PermissionService.READ);
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -321,12 +321,12 @@ public class NavigatorPluginBean implements IContextListener
|
||||
UserTransaction tx = null;
|
||||
try
|
||||
{
|
||||
tx = Repository.getUserTransaction(FacesContext.getCurrentInstance(), true);
|
||||
FacesContext fc = FacesContext.getCurrentInstance();
|
||||
tx = Repository.getUserTransaction(fc, true);
|
||||
tx.begin();
|
||||
|
||||
// query for the child nodes of company home
|
||||
NodeRef root = new NodeRef(Repository.getStoreRef(),
|
||||
Application.getCompanyRootId());
|
||||
NodeRef root = new NodeRef(Repository.getStoreRef(), Application.getCompanyRootId(fc));
|
||||
List<ChildAssociationRef> childRefs = this.nodeService.getChildAssocs(root,
|
||||
ContentModel.ASSOC_CONTAINS, RegexQNamePattern.MATCH_ALL);
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
@@ -49,6 +49,7 @@ import org.alfresco.web.app.Application;
|
||||
*/
|
||||
public final class User
|
||||
{
|
||||
private String companyRootId;
|
||||
private String homeSpaceId;
|
||||
private String userName;
|
||||
private String ticket;
|
||||
@@ -128,6 +129,22 @@ public final class User
|
||||
this.homeSpaceId = homeSpaceId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Retrieves the company home space
|
||||
*/
|
||||
public String getCompanyRootId()
|
||||
{
|
||||
return this.companyRootId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param companyRootId Sets the id of the company home space
|
||||
*/
|
||||
public void setCompanyRootId(String companyRootId)
|
||||
{
|
||||
this.companyRootId = companyRootId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Returns the ticket.
|
||||
*/
|
||||
|
@@ -41,6 +41,8 @@ import javax.transaction.UserTransaction;
|
||||
import org.alfresco.error.AlfrescoRuntimeException;
|
||||
import org.alfresco.model.ApplicationModel;
|
||||
import org.alfresco.model.ContentModel;
|
||||
import org.alfresco.repo.security.authentication.AuthenticationException;
|
||||
import org.alfresco.repo.tenant.TenantService;
|
||||
import org.alfresco.service.cmr.repository.ChildAssociationRef;
|
||||
import org.alfresco.service.cmr.repository.InvalidNodeRefException;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
@@ -101,6 +103,9 @@ public class NewUserWizard extends AbstractWizardBean
|
||||
|
||||
/** PersonService bean reference */
|
||||
private PersonService personService;
|
||||
|
||||
/** TenantService bean reference */
|
||||
private TenantService tenantService;
|
||||
|
||||
/** OwnableService bean reference */
|
||||
private OwnableService ownableService;
|
||||
@@ -154,6 +159,14 @@ public class NewUserWizard extends AbstractWizardBean
|
||||
{
|
||||
this.ownableService = ownableService;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param tenantService The tenantService to set.
|
||||
*/
|
||||
public void setTenantService(TenantService tenantService)
|
||||
{
|
||||
this.tenantService = tenantService;
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialises the wizard
|
||||
@@ -474,6 +487,31 @@ public class NewUserWizard extends AbstractWizardBean
|
||||
}
|
||||
else
|
||||
{
|
||||
if (tenantService.isEnabled())
|
||||
{
|
||||
String currentDomain = tenantService.getCurrentUserDomain();
|
||||
if (currentDomain != null)
|
||||
{
|
||||
if (! tenantService.isTenantUser(this.userName))
|
||||
{
|
||||
// force domain onto the end of the username
|
||||
this.userName = tenantService.getDomainUser(this.userName, currentDomain);
|
||||
logger.warn("Added domain to username: " + this.userName);
|
||||
}
|
||||
else
|
||||
{
|
||||
try
|
||||
{
|
||||
tenantService.checkDomainUser(this.userName);
|
||||
}
|
||||
catch (RuntimeException re)
|
||||
{
|
||||
throw new AuthenticationException("User must belong to same domain as admin: " + currentDomain);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (this.password.equals(this.confirm))
|
||||
{
|
||||
// create properties for Person type from submitted Form data
|
||||
@@ -840,18 +878,7 @@ public class NewUserWizard extends AbstractWizardBean
|
||||
{
|
||||
if (this.companyHomeSpaceRef == null)
|
||||
{
|
||||
String companyXPath = Application.getRootPath(FacesContext.getCurrentInstance());
|
||||
|
||||
NodeRef rootNodeRef = this.nodeService.getRootNode(Repository.getStoreRef());
|
||||
List<NodeRef> nodes = this.searchService.selectNodes(rootNodeRef, companyXPath, null, this.namespaceService,
|
||||
false);
|
||||
|
||||
if (nodes.size() == 0)
|
||||
{
|
||||
throw new IllegalStateException("Unable to find company home space path: " + companyXPath);
|
||||
}
|
||||
|
||||
this.companyHomeSpaceRef = nodes.get(0);
|
||||
this.companyHomeSpaceRef = Repository.getCompanyRoot(FacesContext.getCurrentInstance());
|
||||
}
|
||||
|
||||
return this.companyHomeSpaceRef;
|
||||
|
Reference in New Issue
Block a user