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:
@@ -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