Tenant Service hooks for LockService, FileFolderService and other MT fixes (DbNodeService & AuthorityService)

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@6437 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Jan Vonka
2007-08-07 08:40:25 +00:00
parent e0f2b295af
commit 9ed7b186f0
6 changed files with 50 additions and 4 deletions

View File

@@ -492,6 +492,9 @@
<property name="nodeService"> <property name="nodeService">
<ref bean="nodeService" /> <ref bean="nodeService" />
</property> </property>
<property name="tenantService">
<ref bean="tenantService" />
</property>
<property name="policyComponent"> <property name="policyComponent">
<ref bean="policyComponent" /> <ref bean="policyComponent" />
</property> </property>

View File

@@ -9,6 +9,7 @@
<property name="namespaceService"><ref bean="namespaceService" /></property> <property name="namespaceService"><ref bean="namespaceService" /></property>
<property name="dictionaryService"><ref bean="dictionaryService" /></property> <property name="dictionaryService"><ref bean="dictionaryService" /></property>
<property name="nodeService"><ref bean="nodeService" /></property> <property name="nodeService"><ref bean="nodeService" /></property>
<property name="tenantService"><ref bean="tenantService" /></property>
<property name="copyService"><ref bean="copyService" /></property> <property name="copyService"><ref bean="copyService" /></property>
<property name="searchService"><ref bean="admSearchService" /></property> <property name="searchService"><ref bean="admSearchService" /></property>
<property name="contentService"><ref bean="contentService" /></property> <property name="contentService"><ref bean="contentService" /></property>

View File

@@ -41,6 +41,7 @@ import org.alfresco.repo.policy.JavaBehaviour;
import org.alfresco.repo.policy.PolicyComponent; import org.alfresco.repo.policy.PolicyComponent;
import org.alfresco.repo.policy.PolicyScope; import org.alfresco.repo.policy.PolicyScope;
import org.alfresco.repo.security.authentication.AuthenticationUtil; import org.alfresco.repo.security.authentication.AuthenticationUtil;
import org.alfresco.repo.tenant.TenantService;
import org.alfresco.repo.version.VersionServicePolicies; import org.alfresco.repo.version.VersionServicePolicies;
import org.alfresco.service.cmr.lock.LockService; import org.alfresco.service.cmr.lock.LockService;
import org.alfresco.service.cmr.lock.LockStatus; import org.alfresco.service.cmr.lock.LockStatus;
@@ -78,6 +79,11 @@ public class LockServiceImpl implements LockService,
*/ */
private NodeService nodeService; private NodeService nodeService;
/**
* The tenant service
*/
private TenantService tenantService;
/** /**
* The policy component * The policy component
*/ */
@@ -115,6 +121,17 @@ public class LockServiceImpl implements LockService,
this.nodeService = nodeService; this.nodeService = nodeService;
} }
/**
* Set the tenant service
*
* @param tenantService
* the tenant service
*/
public void setTenantService(TenantService tenantService)
{
this.tenantService = tenantService;
}
/** /**
* Sets the policy component * Sets the policy component
* *
@@ -208,6 +225,8 @@ public class LockServiceImpl implements LockService,
*/ */
public synchronized void lock(NodeRef nodeRef, LockType lockType, int timeToExpire) public synchronized void lock(NodeRef nodeRef, LockType lockType, int timeToExpire)
{ {
nodeRef = tenantService.getName(nodeRef);
// Check for lock aspect // Check for lock aspect
checkForLockApsect(nodeRef); checkForLockApsect(nodeRef);
@@ -303,6 +322,8 @@ public class LockServiceImpl implements LockService,
*/ */
public synchronized void unlock(NodeRef nodeRef) throws UnableToReleaseLockException public synchronized void unlock(NodeRef nodeRef) throws UnableToReleaseLockException
{ {
nodeRef = tenantService.getName(nodeRef);
// Check for lock aspect // Check for lock aspect
checkForLockApsect(nodeRef); checkForLockApsect(nodeRef);
@@ -357,6 +378,8 @@ public class LockServiceImpl implements LockService,
*/ */
public LockStatus getLockStatus(NodeRef nodeRef) public LockStatus getLockStatus(NodeRef nodeRef)
{ {
nodeRef = tenantService.getName(nodeRef);
return getLockStatus(nodeRef, getUserName()); return getLockStatus(nodeRef, getUserName());
} }
@@ -446,6 +469,8 @@ public class LockServiceImpl implements LockService,
{ {
String userName = getUserName(); String userName = getUserName();
nodeRef = tenantService.getName(nodeRef);
// Ensure we have found a node reference // Ensure we have found a node reference
if (nodeRef != null && userName != null) if (nodeRef != null && userName != null)
{ {

View File

@@ -35,6 +35,7 @@ import java.util.Map;
import org.alfresco.error.AlfrescoRuntimeException; import org.alfresco.error.AlfrescoRuntimeException;
import org.alfresco.model.ContentModel; import org.alfresco.model.ContentModel;
import org.alfresco.repo.search.QueryParameterDefImpl; import org.alfresco.repo.search.QueryParameterDefImpl;
import org.alfresco.repo.tenant.TenantService;
import org.alfresco.service.cmr.dictionary.DataTypeDefinition; import org.alfresco.service.cmr.dictionary.DataTypeDefinition;
import org.alfresco.service.cmr.dictionary.DictionaryService; import org.alfresco.service.cmr.dictionary.DictionaryService;
import org.alfresco.service.cmr.model.FileExistsException; import org.alfresco.service.cmr.model.FileExistsException;
@@ -118,6 +119,7 @@ public class FileFolderServiceImpl implements FileFolderService
private NamespaceService namespaceService; private NamespaceService namespaceService;
private DictionaryService dictionaryService; private DictionaryService dictionaryService;
private NodeService nodeService; private NodeService nodeService;
private TenantService tenantService;
private CopyService copyService; private CopyService copyService;
private SearchService searchService; private SearchService searchService;
private ContentService contentService; private ContentService contentService;
@@ -149,6 +151,11 @@ public class FileFolderServiceImpl implements FileFolderService
this.nodeService = nodeService; this.nodeService = nodeService;
} }
public void setTenantService(TenantService tenantService)
{
this.tenantService = tenantService;
}
public void setCopyService(CopyService copyService) public void setCopyService(CopyService copyService)
{ {
this.copyService = copyService; this.copyService = copyService;
@@ -469,6 +476,8 @@ public class FileFolderServiceImpl implements FileFolderService
private List<NodeRef> luceneSearch(NodeRef contextNodeRef, boolean folders, boolean files) private List<NodeRef> luceneSearch(NodeRef contextNodeRef, boolean folders, boolean files)
{ {
contextNodeRef = tenantService.getName(contextNodeRef);
SearchParameters params = new SearchParameters(); SearchParameters params = new SearchParameters();
params.setLanguage(SearchService.LANGUAGE_LUCENE); params.setLanguage(SearchService.LANGUAGE_LUCENE);
params.addStore(contextNodeRef.getStoreRef()); params.addStore(contextNodeRef.getStoreRef());

View File

@@ -1335,7 +1335,12 @@ public class DbNodeServiceImpl extends AbstractNodeServiceImpl
} }
else else
{ {
assocRef = assoc.getChildAssocRef(); assocRef = new ChildAssociationRef(assoc.getChildAssocRef().getTypeQName(),
tenantService.getBaseName(assoc.getChildAssocRef().getParentRef()),
assoc.getChildAssocRef().getQName(),
tenantService.getBaseName(assoc.getChildAssocRef().getChildRef()),
assoc.getChildAssocRef().isPrimary(),
assoc.getChildAssocRef().getNthSibling());
} }
return assocRef; return assocRef;
} }

View File

@@ -104,7 +104,9 @@ public class AuthorityServiceImpl implements AuthorityService
public boolean hasAdminAuthority() public boolean hasAdminAuthority()
{ {
String currentUserName = authenticationComponent.getCurrentUserName(); String currentUserName = authenticationComponent.getCurrentUserName();
return ((currentUserName != null) && adminUsers.contains(currentUserName));
// for MT, see note for getAuthoritiesForUser
return ((currentUserName != null) && (adminUsers.contains(currentUserName) || adminUsers.contains(tenantService.getBaseNameUser(currentUserName))));
} }
/* (non-Javadoc) /* (non-Javadoc)
@@ -117,7 +119,8 @@ public class AuthorityServiceImpl implements AuthorityService
{ {
canonicalName = authorityName; canonicalName = authorityName;
} }
return adminUsers.contains(canonicalName); // for MT, see note for getAuthoritiesForUser
return (adminUsers.contains(canonicalName) || adminUsers.contains(tenantService.getBaseNameUser(canonicalName)));
} }
// IOC // IOC