MT - fixes for version2Store + MT interceptor

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@11001 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Jan Vonka
2008-09-24 11:57:29 +00:00
parent 40e706f14f
commit 2f5abd7e0d
11 changed files with 278 additions and 52 deletions

View File

@@ -166,7 +166,7 @@
</props> </props>
<props> <props>
<prop key="storeRef">${version.store.version2Store}</prop> <prop key="storeRef">${version.store.version2Store}</prop>
<prop key="packageName">versions</prop> <prop key="packageName">versions2</prop>
</props> </props>
</list> </list>
</property> </property>

View File

@@ -126,6 +126,9 @@
<property name="nodeService"> <property name="nodeService">
<ref bean="nodeService" /> <ref bean="nodeService" />
</property> </property>
<property name="tenantService">
<ref bean="tenantService" />
</property>
<property name="enabled"> <property name="enabled">
<value>true</value> <!-- on/off switch --> <value>true</value> <!-- on/off switch -->
</property> </property>

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright (C) 2005-2007 Alfresco Software Limited. * Copyright (C) 2005-2008 Alfresco Software Limited.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
@@ -34,6 +34,7 @@ import java.util.Map;
import org.alfresco.repo.node.NodeServicePolicies; import org.alfresco.repo.node.NodeServicePolicies;
import org.alfresco.repo.policy.JavaBehaviour; import org.alfresco.repo.policy.JavaBehaviour;
import org.alfresco.repo.policy.PolicyComponent; import org.alfresco.repo.policy.PolicyComponent;
import org.alfresco.repo.tenant.TenantService;
import org.alfresco.repo.transaction.AlfrescoTransactionSupport; import org.alfresco.repo.transaction.AlfrescoTransactionSupport;
import org.alfresco.repo.transaction.RetryingTransactionHelper; import org.alfresco.repo.transaction.RetryingTransactionHelper;
import org.alfresco.service.cmr.dictionary.AspectDefinition; import org.alfresco.service.cmr.dictionary.AspectDefinition;
@@ -103,6 +104,7 @@ public class IntegrityChecker
private PolicyComponent policyComponent; private PolicyComponent policyComponent;
private DictionaryService dictionaryService; private DictionaryService dictionaryService;
private NodeService nodeService; private NodeService nodeService;
private TenantService tenantService;
private boolean enabled; private boolean enabled;
private boolean failOnViolation; private boolean failOnViolation;
private int maxErrorsPerTransaction; private int maxErrorsPerTransaction;
@@ -172,6 +174,11 @@ public class IntegrityChecker
{ {
this.nodeService = nodeService; this.nodeService = nodeService;
} }
public void setTenantService(TenantService tenantService)
{
this.tenantService = tenantService;
}
/** /**
* @param enabled set to false to disable integrity checking completely * @param enabled set to false to disable integrity checking completely
@@ -330,7 +337,7 @@ public class IntegrityChecker
public void onCreateNode(ChildAssociationRef childAssocRef) public void onCreateNode(ChildAssociationRef childAssocRef)
{ {
NodeRef childRef = childAssocRef.getChildRef(); NodeRef childRef = childAssocRef.getChildRef();
if (! storesToIgnore.contains(childRef.getStoreRef().toString())) if (! storesToIgnore.contains(tenantService.getBaseName(childRef.getStoreRef()).toString()))
{ {
IntegrityEvent event = null; IntegrityEvent event = null;
// check properties on child node // check properties on child node
@@ -380,7 +387,7 @@ public class IntegrityChecker
Map<QName, Serializable> before, Map<QName, Serializable> before,
Map<QName, Serializable> after) Map<QName, Serializable> after)
{ {
if (! storesToIgnore.contains(nodeRef.getStoreRef().toString())) if (! storesToIgnore.contains(tenantService.getBaseName(nodeRef.getStoreRef()).toString()))
{ {
IntegrityEvent event = null; IntegrityEvent event = null;
// check properties on node // check properties on node
@@ -402,7 +409,7 @@ public class IntegrityChecker
*/ */
public void onAddAspect(NodeRef nodeRef, QName aspectTypeQName) public void onAddAspect(NodeRef nodeRef, QName aspectTypeQName)
{ {
if (! storesToIgnore.contains(nodeRef.getStoreRef().toString())) if (! storesToIgnore.contains(tenantService.getBaseName(nodeRef.getStoreRef()).toString()))
{ {
IntegrityEvent event = null; IntegrityEvent event = null;
// check properties on node // check properties on node
@@ -438,7 +445,7 @@ public class IntegrityChecker
*/ */
public void onRemoveAspect(NodeRef nodeRef, QName aspectTypeQName) public void onRemoveAspect(NodeRef nodeRef, QName aspectTypeQName)
{ {
if (! storesToIgnore.contains(nodeRef.getStoreRef().toString())) if (! storesToIgnore.contains(tenantService.getBaseName(nodeRef.getStoreRef()).toString()))
{ {
IntegrityEvent event = null; IntegrityEvent event = null;
// check mandatory aspects // check mandatory aspects
@@ -463,7 +470,7 @@ public class IntegrityChecker
return; return;
} }
if (! storesToIgnore.contains(childAssocRef.getChildRef().getStoreRef().toString())) if (! storesToIgnore.contains(tenantService.getBaseName(childAssocRef.getChildRef().getStoreRef()).toString()))
{ {
IntegrityEvent event = null; IntegrityEvent event = null;
// check source type // check source type
@@ -513,7 +520,7 @@ public class IntegrityChecker
*/ */
public void onDeleteChildAssociation(ChildAssociationRef childAssocRef) public void onDeleteChildAssociation(ChildAssociationRef childAssocRef)
{ {
if (! storesToIgnore.contains(childAssocRef.getChildRef().getStoreRef().toString())) if (! storesToIgnore.contains(tenantService.getBaseName(childAssocRef.getChildRef().getStoreRef()).toString()))
{ {
IntegrityEvent event = null; IntegrityEvent event = null;
// check source multiplicity // check source multiplicity
@@ -543,7 +550,7 @@ public class IntegrityChecker
*/ */
public void onCreateAssociation(AssociationRef nodeAssocRef) public void onCreateAssociation(AssociationRef nodeAssocRef)
{ {
if (! storesToIgnore.contains(nodeAssocRef.getSourceRef().getStoreRef().toString())) if (! storesToIgnore.contains(tenantService.getBaseName(nodeAssocRef.getSourceRef().getStoreRef()).toString()))
{ {
IntegrityEvent event = null; IntegrityEvent event = null;
// check source type // check source type
@@ -585,7 +592,7 @@ public class IntegrityChecker
*/ */
public void onDeleteAssociation(AssociationRef nodeAssocRef) public void onDeleteAssociation(AssociationRef nodeAssocRef)
{ {
if (! storesToIgnore.contains(nodeAssocRef.getSourceRef().getStoreRef().toString())) if (! storesToIgnore.contains(tenantService.getBaseName(nodeAssocRef.getSourceRef().getStoreRef()).toString()))
{ {
IntegrityEvent event = null; IntegrityEvent event = null;
// check source multiplicity // check source multiplicity

View File

@@ -200,7 +200,8 @@ public class MultiTAdminServiceImpl implements TenantAdminService, ApplicationCo
public static final String PROTOCOL_STORE_ARCHIVE = "archive"; public static final String PROTOCOL_STORE_ARCHIVE = "archive";
public static final String STORE_BASE_ID_USER = "alfrescoUserStore"; public static final String STORE_BASE_ID_USER = "alfrescoUserStore";
public static final String STORE_BASE_ID_SYSTEM = "system"; public static final String STORE_BASE_ID_SYSTEM = "system";
public static final String STORE_BASE_ID_VERSION = "lightWeightVersionStore"; public static final String STORE_BASE_ID_VERSION1 = "lightWeightVersionStore"; // deprecated
public static final String STORE_BASE_ID_VERSION2 = "version2Store";
public static final String STORE_BASE_ID_SPACES = "SpacesStore"; public static final String STORE_BASE_ID_SPACES = "SpacesStore";
@@ -338,8 +339,12 @@ public class MultiTAdminServiceImpl implements TenantAdminService, ApplicationCo
ImporterBootstrap systemImporterBootstrap = (ImporterBootstrap)ctx.getBean("systemBootstrap"); ImporterBootstrap systemImporterBootstrap = (ImporterBootstrap)ctx.getBean("systemBootstrap");
bootstrapSystemTenantStore(systemImporterBootstrap, tenantDomain); bootstrapSystemTenantStore(systemImporterBootstrap, tenantDomain);
// deprecated
ImporterBootstrap versionImporterBootstrap = (ImporterBootstrap)ctx.getBean("versionBootstrap"); ImporterBootstrap versionImporterBootstrap = (ImporterBootstrap)ctx.getBean("versionBootstrap");
bootstrapVersionTenantStore(versionImporterBootstrap, tenantDomain); bootstrapVersionTenantStore(versionImporterBootstrap, tenantDomain);
ImporterBootstrap version2ImporterBootstrap = (ImporterBootstrap)ctx.getBean("version2Bootstrap");
bootstrapVersionTenantStore(version2ImporterBootstrap, tenantDomain);
ImporterBootstrap spacesArchiveImporterBootstrap = (ImporterBootstrap)ctx.getBean("spacesArchiveBootstrap"); ImporterBootstrap spacesArchiveImporterBootstrap = (ImporterBootstrap)ctx.getBean("spacesArchiveBootstrap");
bootstrapSpacesArchiveTenantStore(spacesArchiveImporterBootstrap, tenantDomain); bootstrapSpacesArchiveTenantStore(spacesArchiveImporterBootstrap, tenantDomain);
@@ -648,7 +653,8 @@ public class MultiTAdminServiceImpl implements TenantAdminService, ApplicationCo
// delete tenant-specific stores // delete tenant-specific stores
nodeService.deleteStore(tenantService.getName(tenantAdminUser, new StoreRef(PROTOCOL_STORE_WORKSPACE, STORE_BASE_ID_SPACES))); nodeService.deleteStore(tenantService.getName(tenantAdminUser, new StoreRef(PROTOCOL_STORE_WORKSPACE, STORE_BASE_ID_SPACES)));
nodeService.deleteStore(tenantService.getName(tenantAdminUser, new StoreRef(PROTOCOL_STORE_ARCHIVE, STORE_BASE_ID_SPACES))); nodeService.deleteStore(tenantService.getName(tenantAdminUser, new StoreRef(PROTOCOL_STORE_ARCHIVE, STORE_BASE_ID_SPACES)));
nodeService.deleteStore(tenantService.getName(tenantAdminUser, new StoreRef(PROTOCOL_STORE_WORKSPACE, STORE_BASE_ID_VERSION))); nodeService.deleteStore(tenantService.getName(tenantAdminUser, new StoreRef(PROTOCOL_STORE_WORKSPACE, STORE_BASE_ID_VERSION1)));
nodeService.deleteStore(tenantService.getName(tenantAdminUser, new StoreRef(PROTOCOL_STORE_WORKSPACE, STORE_BASE_ID_VERSION2)));
nodeService.deleteStore(tenantService.getName(tenantAdminUser, new StoreRef(PROTOCOL_STORE_SYSTEM, STORE_BASE_ID_SYSTEM))); nodeService.deleteStore(tenantService.getName(tenantAdminUser, new StoreRef(PROTOCOL_STORE_SYSTEM, STORE_BASE_ID_SYSTEM)));
nodeService.deleteStore(tenantService.getName(tenantAdminUser, new StoreRef(PROTOCOL_STORE_USER, STORE_BASE_ID_USER))); nodeService.deleteStore(tenantService.getName(tenantAdminUser, new StoreRef(PROTOCOL_STORE_USER, STORE_BASE_ID_USER)));
@@ -701,7 +707,7 @@ public class MultiTAdminServiceImpl implements TenantAdminService, ApplicationCo
} }
private void importBootstrapSystemTenantStore(String tenantDomain, File directorySource) private void importBootstrapSystemTenantStore(String tenantDomain, File directorySource)
{ {
// Import Bootstrap (restore) Tenant-Specific Version Store // Import Bootstrap (restore) Tenant-Specific Version Store
Properties bootstrapView = new Properties(); Properties bootstrapView = new Properties();
bootstrapView.put("path", "/"); bootstrapView.put("path", "/");
@@ -720,7 +726,8 @@ public class MultiTAdminServiceImpl implements TenantAdminService, ApplicationCo
private void bootstrapSystemTenantStore(ImporterBootstrap systemImporterBootstrap, String tenantDomain) private void bootstrapSystemTenantStore(ImporterBootstrap systemImporterBootstrap, String tenantDomain)
{ {
// Bootstrap Tenant-Specific System Store // Bootstrap Tenant-Specific System Store
StoreRef bootstrapStoreRef = new StoreRef(PROTOCOL_STORE_SYSTEM, tenantService.getName(STORE_BASE_ID_SYSTEM, tenantDomain)); StoreRef bootstrapStoreRef = systemImporterBootstrap.getStoreRef();
bootstrapStoreRef = new StoreRef(bootstrapStoreRef.getProtocol(), tenantService.getName(bootstrapStoreRef.getIdentifier(), tenantDomain));
systemImporterBootstrap.setStoreUrl(bootstrapStoreRef.toString()); systemImporterBootstrap.setStoreUrl(bootstrapStoreRef.toString());
// override default property (workspace://SpacesStore) // override default property (workspace://SpacesStore)
@@ -734,7 +741,7 @@ public class MultiTAdminServiceImpl implements TenantAdminService, ApplicationCo
} }
private void importBootstrapUserTenantStore(String tenantDomain, File directorySource) private void importBootstrapUserTenantStore(String tenantDomain, File directorySource)
{ {
// Import Bootstrap (restore) Tenant-Specific User Store // Import Bootstrap (restore) Tenant-Specific User Store
Properties bootstrapView = new Properties(); Properties bootstrapView = new Properties();
bootstrapView.put("path", "/"); bootstrapView.put("path", "/");
@@ -751,9 +758,10 @@ public class MultiTAdminServiceImpl implements TenantAdminService, ApplicationCo
} }
private void bootstrapUserTenantStore(ImporterBootstrap userImporterBootstrap, String tenantDomain, char[] tenantAdminRawPassword) private void bootstrapUserTenantStore(ImporterBootstrap userImporterBootstrap, String tenantDomain, char[] tenantAdminRawPassword)
{ {
// Bootstrap Tenant-Specific User Store // Bootstrap Tenant-Specific User Store
StoreRef bootstrapStoreRef = new StoreRef(PROTOCOL_STORE_USER, tenantService.getName(STORE_BASE_ID_USER, tenantDomain)); StoreRef bootstrapStoreRef = userImporterBootstrap.getStoreRef();
bootstrapStoreRef = new StoreRef(bootstrapStoreRef.getProtocol(), tenantService.getName(bootstrapStoreRef.getIdentifier(), tenantDomain));
userImporterBootstrap.setStoreUrl(bootstrapStoreRef.toString()); userImporterBootstrap.setStoreUrl(bootstrapStoreRef.toString());
// override admin username property // override admin username property
@@ -772,11 +780,11 @@ public class MultiTAdminServiceImpl implements TenantAdminService, ApplicationCo
} }
private void importBootstrapVersionTenantStore(String tenantDomain, File directorySource) private void importBootstrapVersionTenantStore(String tenantDomain, File directorySource)
{ {
// Import Bootstrap (restore) Tenant-Specific Version Store // Import Bootstrap (restore) Tenant-Specific Version Store
Properties bootstrapView = new Properties(); Properties bootstrapView = new Properties();
bootstrapView.put("path", "/"); bootstrapView.put("path", "/");
bootstrapView.put("location", directorySource.getPath()+"/"+tenantDomain+"_versions.acp"); bootstrapView.put("location", directorySource.getPath()+"/"+tenantDomain+"_versions2.acp");
List<Properties> bootstrapViews = new ArrayList<Properties>(1); List<Properties> bootstrapViews = new ArrayList<Properties>(1);
bootstrapViews.add(bootstrapView); bootstrapViews.add(bootstrapView);
@@ -791,7 +799,8 @@ public class MultiTAdminServiceImpl implements TenantAdminService, ApplicationCo
private void bootstrapVersionTenantStore(ImporterBootstrap versionImporterBootstrap, String tenantDomain) private void bootstrapVersionTenantStore(ImporterBootstrap versionImporterBootstrap, String tenantDomain)
{ {
// Bootstrap Tenant-Specific Version Store // Bootstrap Tenant-Specific Version Store
StoreRef bootstrapStoreRef = new StoreRef(PROTOCOL_STORE_WORKSPACE, tenantService.getName(STORE_BASE_ID_VERSION, tenantDomain)); StoreRef bootstrapStoreRef = versionImporterBootstrap.getStoreRef();
bootstrapStoreRef = new StoreRef(bootstrapStoreRef.getProtocol(), tenantService.getName(bootstrapStoreRef.getIdentifier(), tenantDomain));
versionImporterBootstrap.setStoreUrl(bootstrapStoreRef.toString()); versionImporterBootstrap.setStoreUrl(bootstrapStoreRef.toString());
versionImporterBootstrap.bootstrap(); versionImporterBootstrap.bootstrap();
@@ -800,7 +809,7 @@ public class MultiTAdminServiceImpl implements TenantAdminService, ApplicationCo
} }
private void importBootstrapSpacesArchiveTenantStore(String tenantDomain, File directorySource) private void importBootstrapSpacesArchiveTenantStore(String tenantDomain, File directorySource)
{ {
// Import Bootstrap (restore) Tenant-Specific Spaces Archive Store // Import Bootstrap (restore) Tenant-Specific Spaces Archive Store
Properties bootstrapView = new Properties(); Properties bootstrapView = new Properties();
bootstrapView.put("path", "/"); bootstrapView.put("path", "/");
@@ -818,13 +827,14 @@ public class MultiTAdminServiceImpl implements TenantAdminService, ApplicationCo
private void bootstrapSpacesArchiveTenantStore(ImporterBootstrap spacesArchiveImporterBootstrap, String tenantDomain) private void bootstrapSpacesArchiveTenantStore(ImporterBootstrap spacesArchiveImporterBootstrap, String tenantDomain)
{ {
// Bootstrap Tenant-Specific Spaces Archive Store // Bootstrap Tenant-Specific Spaces Archive Store
StoreRef bootstrapStoreRef = new StoreRef(PROTOCOL_STORE_ARCHIVE, tenantService.getName(STORE_BASE_ID_SPACES, tenantDomain)); StoreRef bootstrapStoreRef = spacesArchiveImporterBootstrap.getStoreRef();
bootstrapStoreRef = new StoreRef(bootstrapStoreRef.getProtocol(), tenantService.getName(bootstrapStoreRef.getIdentifier(), tenantDomain));
spacesArchiveImporterBootstrap.setStoreUrl(bootstrapStoreRef.toString()); spacesArchiveImporterBootstrap.setStoreUrl(bootstrapStoreRef.toString());
// override default property (archive://SpacesStore) // override default property (archive://SpacesStore)
List<String> mustNotExistStoreUrls = new ArrayList<String>(); List<String> mustNotExistStoreUrls = new ArrayList<String>();
mustNotExistStoreUrls.add(new StoreRef(PROTOCOL_STORE_ARCHIVE, tenantService.getName(STORE_BASE_ID_SPACES, tenantDomain)).toString()); mustNotExistStoreUrls.add(bootstrapStoreRef.toString());
spacesArchiveImporterBootstrap.setMustNotExistStoreUrls(mustNotExistStoreUrls); spacesArchiveImporterBootstrap.setMustNotExistStoreUrls(mustNotExistStoreUrls);
spacesArchiveImporterBootstrap.bootstrap(); spacesArchiveImporterBootstrap.bootstrap();
@@ -833,7 +843,7 @@ public class MultiTAdminServiceImpl implements TenantAdminService, ApplicationCo
} }
private void importBootstrapSpacesModelsTenantStore(String tenantDomain, File directorySource) private void importBootstrapSpacesModelsTenantStore(String tenantDomain, File directorySource)
{ {
// Import Bootstrap (restore) Tenant-Specific Spaces Store // Import Bootstrap (restore) Tenant-Specific Spaces Store
Properties bootstrapView = new Properties(); Properties bootstrapView = new Properties();
bootstrapView.put("path", "/"); bootstrapView.put("path", "/");
@@ -850,7 +860,7 @@ public class MultiTAdminServiceImpl implements TenantAdminService, ApplicationCo
} }
private void importBootstrapSpacesTenantStore(String tenantDomain, File directorySource) private void importBootstrapSpacesTenantStore(String tenantDomain, File directorySource)
{ {
// Import Bootstrap (restore) Tenant-Specific Spaces Store // Import Bootstrap (restore) Tenant-Specific Spaces Store
Properties bootstrapView = new Properties(); Properties bootstrapView = new Properties();
bootstrapView.put("path", "/"); bootstrapView.put("path", "/");
@@ -871,8 +881,9 @@ public class MultiTAdminServiceImpl implements TenantAdminService, ApplicationCo
private void bootstrapSpacesTenantStore(ImporterBootstrap spacesImporterBootstrap, String tenantDomain) private void bootstrapSpacesTenantStore(ImporterBootstrap spacesImporterBootstrap, String tenantDomain)
{ {
// Bootstrap Tenant-Specific Spaces Store // Bootstrap Tenant-Specific Spaces Store
StoreRef bootstrapStoreRef = new StoreRef(PROTOCOL_STORE_WORKSPACE, tenantService.getName(STORE_BASE_ID_SPACES, tenantDomain)); StoreRef bootstrapStoreRef = spacesImporterBootstrap.getStoreRef();
bootstrapStoreRef = new StoreRef(bootstrapStoreRef.getProtocol(), tenantService.getName(bootstrapStoreRef.getIdentifier(), tenantDomain));
spacesImporterBootstrap.setStoreUrl(bootstrapStoreRef.toString()); spacesImporterBootstrap.setStoreUrl(bootstrapStoreRef.toString());
// override admin username property // override admin username property
@@ -1156,6 +1167,11 @@ public class MultiTAdminServiceImpl implements TenantAdminService, ApplicationCo
return tenantService.getUserDomain(username); return tenantService.getUserDomain(username);
} }
public String getBaseNameUser(String username)
{
return tenantService.getBaseNameUser(username);
}
public String getDomainUser(String baseUsername, String tenantDomain) public String getDomainUser(String baseUsername, String tenantDomain)
{ {
return tenantService.getDomainUser(baseUsername, tenantDomain); return tenantService.getDomainUser(baseUsername, tenantDomain);

View File

@@ -105,6 +105,7 @@ public class MultiTDemoTest extends TestCase
public static final String TEST_USER2 = "bob"; public static final String TEST_USER2 = "bob";
public static final String TEST_USER3 = "eve"; public static final String TEST_USER3 = "eve";
private static final int DEFAULT_DM_STORE_COUNT = 6;
public static StoreRef SPACES_STORE = new StoreRef(StoreRef.PROTOCOL_WORKSPACE, "SpacesStore"); public static StoreRef SPACES_STORE = new StoreRef(StoreRef.PROTOCOL_WORKSPACE, "SpacesStore");
@@ -348,7 +349,7 @@ public class MultiTDemoTest extends TestCase
} }
} }
public void testCreateUserContent() public void testCreateVersionableUserContent()
{ {
logger.info("Create demo content"); logger.info("Create demo content");
@@ -370,11 +371,14 @@ public class MultiTDemoTest extends TestCase
public Object doWork() throws Exception public Object doWork() throws Exception
{ {
NodeRef homeSpaceRef = getHomeSpaceFolderNode(tenantUserName); NodeRef homeSpaceRef = getHomeSpaceFolderNode(tenantUserName);
addTextContent(homeSpaceRef, tenantUserName+" quick brown fox.txt", "The quick brown fox jumps over the lazy dog (tenant " + tenantDomain + ")");
NodeRef contentRef = addTextContent(homeSpaceRef, tenantUserName+" quick brown fox.txt", "The quick brown fox jumps over the lazy dog (tenant " + tenantDomain + ")");
nodeService.addAspect(contentRef, ContentModel.ASPECT_VERSIONABLE, null);
if (tenantDomain.equals(TEST_TENANT_DOMAIN2)) if (tenantDomain.equals(TEST_TENANT_DOMAIN2))
{ {
addTextContent(homeSpaceRef, tenantUserName+" quick brown fox ANO.txt", "The quick brown fox jumps over the lazy dog ANO (tenant " + tenantDomain + ")"); contentRef = addTextContent(homeSpaceRef, tenantUserName+" quick brown fox ANO.txt", "The quick brown fox jumps over the lazy dog ANO (tenant " + tenantDomain + ")");
nodeService.addAspect(contentRef, ContentModel.ASPECT_VERSIONABLE, null);
} }
return null; return null;
@@ -389,8 +393,27 @@ public class MultiTDemoTest extends TestCase
{ {
logger.info("Get tenant stores"); logger.info("Get tenant stores");
// super tenant // system
assertTrue("Super tenant: ", (nodeService.getStores().size() >= 5)); AuthenticationUtil.runAs(new RunAsWork<Object>()
{
public Object doWork() throws Exception
{
assertTrue("System: ", (nodeService.getStores().size() >= (DEFAULT_DM_STORE_COUNT * (tenants.size()+1))));
return null;
}
}, AuthenticationUtil.getSystemUserName());
// super admin
AuthenticationUtil.runAs(new RunAsWork<Object>()
{
public Object doWork() throws Exception
{
assertTrue("Super admin: ", (nodeService.getStores().size() >= DEFAULT_DM_STORE_COUNT));
return null;
}
}, TenantService.ADMIN_BASENAME);
assertTrue("Super tenant: ", (nodeService.getStores().size() >= DEFAULT_DM_STORE_COUNT));
for (final String tenantDomain : tenants) for (final String tenantDomain : tenants)
{ {
@@ -400,7 +423,7 @@ public class MultiTDemoTest extends TestCase
{ {
public Object doWork() throws Exception public Object doWork() throws Exception
{ {
assertEquals("Tenant: "+tenantDomain, 5, nodeService.getStores().size()); assertEquals("Tenant: "+tenantDomain, DEFAULT_DM_STORE_COUNT, nodeService.getStores().size());
return null; return null;
} }
@@ -602,7 +625,7 @@ public class MultiTDemoTest extends TestCase
return (NodeRef)this.nodeService.getProperty(personService.getPerson(userName), ContentModel.PROP_HOMEFOLDER); return (NodeRef)this.nodeService.getProperty(personService.getPerson(userName), ContentModel.PROP_HOMEFOLDER);
} }
private void addTextContent(NodeRef spaceRef, String name, String textData) private NodeRef addTextContent(NodeRef spaceRef, String name, String textData)
{ {
Map<QName, Serializable> contentProps = new HashMap<QName, Serializable>(); Map<QName, Serializable> contentProps = new HashMap<QName, Serializable>();
contentProps.put(ContentModel.PROP_NAME, name); contentProps.put(ContentModel.PROP_NAME, name);
@@ -627,6 +650,8 @@ public class MultiTDemoTest extends TestCase
writer.setEncoding("UTF-8"); writer.setEncoding("UTF-8");
writer.putContent(textData); writer.putContent(textData);
return content;
} }

View File

@@ -46,7 +46,7 @@ import org.springframework.aop.support.DelegatingIntroductionInterceptor;
* *
* @since 3.0 * @since 3.0
* @author Derek Hulley * @author Derek Hulley
* @author Jan Vonka * @author janv
*/ */
public class MultiTNodeServiceInterceptor extends DelegatingIntroductionInterceptor//implements NodeService public class MultiTNodeServiceInterceptor extends DelegatingIntroductionInterceptor//implements NodeService
{ {
@@ -253,6 +253,9 @@ public class MultiTNodeServiceInterceptor extends DelegatingIntroductionIntercep
{ {
return null; return null;
} }
// TODO use getBaseName ...
// Deal with collections // Deal with collections
Object value = rawValue; Object value = rawValue;
if (rawValue instanceof Collection) if (rawValue instanceof Collection)
@@ -267,7 +270,7 @@ public class MultiTNodeServiceInterceptor extends DelegatingIntroductionIntercep
else if (rawValue instanceof NodeRef) else if (rawValue instanceof NodeRef)
{ {
NodeRef ref = (NodeRef) rawValue; NodeRef ref = (NodeRef) rawValue;
value = tenantService.getName(ref); value = tenantService.getBaseName(ref);
} }
else if (rawValue instanceof ChildAssociationRef) else if (rawValue instanceof ChildAssociationRef)
{ {
@@ -279,6 +282,24 @@ public class MultiTNodeServiceInterceptor extends DelegatingIntroductionIntercep
AssociationRef ref = (AssociationRef) rawValue; AssociationRef ref = (AssociationRef) rawValue;
value = tenantService.getName(ref); value = tenantService.getName(ref);
} }
/* TODO
else if (rawValue instanceof Path)
{
Path ref = (Path)rawValue;
Path outboundPath = new Path();
Iterator<Path.Element> itr = ref.iterator();
while (itr.hasNext())
{
Path.Element pathElement = itr.next();
if (pathElement instanceof Path.ChildAssocElement)
{
pathElement = new Path.ChildAssocElement(tenantService.getBaseName(((Path.ChildAssocElement)pathElement).getRef()));
}
outboundPath.append(pathElement);
}
value = outboundPath;
}
*/
// Done // Done
return value; return value;
} }

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright (C) 2005-2007 Alfresco Software Limited. * Copyright (C) 2005-2008 Alfresco Software Limited.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
@@ -61,6 +61,9 @@ public class MultiTServiceImpl implements TenantService
this.tenantsCache = tenantsCache; this.tenantsCache = tenantsCache;
} }
/* (non-Javadoc)
* @see org.alfresco.repo.tenant.TenantService#getName(org.alfresco.service.cmr.repository.NodeRef)
*/
public NodeRef getName(NodeRef nodeRef) public NodeRef getName(NodeRef nodeRef)
{ {
if (nodeRef == null) { return null; } if (nodeRef == null) { return null; }
@@ -68,6 +71,9 @@ public class MultiTServiceImpl implements TenantService
return new NodeRef(nodeRef.getStoreRef().getProtocol(), getName(nodeRef.getStoreRef().getIdentifier()), nodeRef.getId()); return new NodeRef(nodeRef.getStoreRef().getProtocol(), getName(nodeRef.getStoreRef().getIdentifier()), nodeRef.getId());
} }
/* (non-Javadoc)
* @see org.alfresco.repo.tenant.TenantService#getName(org.alfresco.service.cmr.repository.NodeRef, org.alfresco.service.cmr.repository.NodeRef)
*/
public NodeRef getName(NodeRef inNodeRef, NodeRef nodeRef) public NodeRef getName(NodeRef inNodeRef, NodeRef nodeRef)
{ {
if (inNodeRef == null || nodeRef == null) { return null; } if (inNodeRef == null || nodeRef == null) { return null; }
@@ -82,6 +88,9 @@ public class MultiTServiceImpl implements TenantService
return nodeRef; return nodeRef;
} }
/* (non-Javadoc)
* @see org.alfresco.repo.tenant.TenantService#getName(org.alfresco.service.cmr.repository.StoreRef)
*/
public StoreRef getName(StoreRef storeRef) public StoreRef getName(StoreRef storeRef)
{ {
if (storeRef == null) { return null; } if (storeRef == null) { return null; }
@@ -89,6 +98,9 @@ public class MultiTServiceImpl implements TenantService
return new StoreRef(storeRef.getProtocol(), getName(storeRef.getIdentifier())); return new StoreRef(storeRef.getProtocol(), getName(storeRef.getIdentifier()));
} }
/* (non-Javadoc)
* @see org.alfresco.repo.tenant.TenantService#getName(org.alfresco.service.cmr.repository.ChildAssociationRef)
*/
public ChildAssociationRef getName(ChildAssociationRef childAssocRef) public ChildAssociationRef getName(ChildAssociationRef childAssocRef)
{ {
if (childAssocRef == null) { return null; } if (childAssocRef == null) { return null; }
@@ -102,6 +114,9 @@ public class MultiTServiceImpl implements TenantService
childAssocRef.getNthSibling()); childAssocRef.getNthSibling());
} }
/* (non-Javadoc)
* @see org.alfresco.repo.tenant.TenantService#getName(org.alfresco.service.cmr.repository.AssociationRef)
*/
public AssociationRef getName(AssociationRef assocRef) public AssociationRef getName(AssociationRef assocRef)
{ {
if (assocRef == null) { return null; } if (assocRef == null) { return null; }
@@ -109,10 +124,12 @@ public class MultiTServiceImpl implements TenantService
return new AssociationRef( return new AssociationRef(
getName(assocRef.getSourceRef()), getName(assocRef.getSourceRef()),
assocRef.getTypeQName(), assocRef.getTypeQName(),
getName(assocRef.getTargetRef()) getName(assocRef.getTargetRef()));
);
} }
/* (non-Javadoc)
* @see org.alfresco.repo.tenant.TenantService#getName(java.lang.String, org.alfresco.service.cmr.repository.StoreRef)
*/
public StoreRef getName(String username, StoreRef storeRef) public StoreRef getName(String username, StoreRef storeRef)
{ {
if (storeRef == null) { return null; } if (storeRef == null) { return null; }
@@ -157,6 +174,9 @@ public class MultiTServiceImpl implements TenantService
return name; return name;
} }
/* (non-Javadoc)
* @see org.alfresco.repo.tenant.TenantService#getName(org.alfresco.service.cmr.repository.NodeRef, org.alfresco.service.namespace.QName)
*/
public QName getName(NodeRef inNodeRef, QName name) public QName getName(NodeRef inNodeRef, QName name)
{ {
// Check that all the passed values are not null // Check that all the passed values are not null
@@ -198,6 +218,9 @@ public class MultiTServiceImpl implements TenantService
return name; return name;
} }
/* (non-Javadoc)
* @see org.alfresco.repo.tenant.TenantService#getName(java.lang.String)
*/
public String getName(String name) public String getName(String name)
{ {
// Check that all the passed values are not null // Check that all the passed values are not null
@@ -227,12 +250,18 @@ public class MultiTServiceImpl implements TenantService
return name; return name;
} }
/* (non-Javadoc)
* @see org.alfresco.repo.tenant.TenantService#getBaseName(org.alfresco.service.namespace.QName, boolean)
*/
public QName getBaseName(QName name, boolean forceForNonTenant) public QName getBaseName(QName name, boolean forceForNonTenant)
{ {
String baseNamespaceURI = getBaseName(name.getNamespaceURI(), forceForNonTenant); String baseNamespaceURI = getBaseName(name.getNamespaceURI(), forceForNonTenant);
return QName.createQName(baseNamespaceURI, name.getLocalName()); return QName.createQName(baseNamespaceURI, name.getLocalName());
} }
/* (non-Javadoc)
* @see org.alfresco.repo.tenant.TenantService#getBaseName(org.alfresco.service.cmr.repository.NodeRef)
*/
public NodeRef getBaseName(NodeRef nodeRef) public NodeRef getBaseName(NodeRef nodeRef)
{ {
if (nodeRef == null) { return null; } if (nodeRef == null) { return null; }
@@ -240,6 +269,9 @@ public class MultiTServiceImpl implements TenantService
return new NodeRef(nodeRef.getStoreRef().getProtocol(), getBaseName(nodeRef.getStoreRef().getIdentifier()), nodeRef.getId()); return new NodeRef(nodeRef.getStoreRef().getProtocol(), getBaseName(nodeRef.getStoreRef().getIdentifier()), nodeRef.getId());
} }
/* (non-Javadoc)
* @see org.alfresco.repo.tenant.TenantService#getBaseName(org.alfresco.service.cmr.repository.StoreRef)
*/
public StoreRef getBaseName(StoreRef storeRef) public StoreRef getBaseName(StoreRef storeRef)
{ {
if (storeRef == null) { return null; } if (storeRef == null) { return null; }
@@ -247,11 +279,15 @@ public class MultiTServiceImpl implements TenantService
return new StoreRef(storeRef.getProtocol(), getBaseName(storeRef.getIdentifier())); return new StoreRef(storeRef.getProtocol(), getBaseName(storeRef.getIdentifier()));
} }
/* (non-Javadoc)
* @see org.alfresco.repo.tenant.TenantService#getBaseName(org.alfresco.service.cmr.repository.ChildAssociationRef)
*/
public ChildAssociationRef getBaseName(ChildAssociationRef childAssocRef) public ChildAssociationRef getBaseName(ChildAssociationRef childAssocRef)
{ {
if (childAssocRef == null) { return null; } if (childAssocRef == null) { return null; }
return new ChildAssociationRef(childAssocRef.getTypeQName(), return new ChildAssociationRef(
childAssocRef.getTypeQName(),
getBaseName(childAssocRef.getParentRef()), getBaseName(childAssocRef.getParentRef()),
childAssocRef.getQName(), childAssocRef.getQName(),
getBaseName(childAssocRef.getChildRef()), getBaseName(childAssocRef.getChildRef()),
@@ -259,12 +295,31 @@ public class MultiTServiceImpl implements TenantService
childAssocRef.getNthSibling()); childAssocRef.getNthSibling());
} }
/* (non-Javadoc)
* @see org.alfresco.repo.tenant.TenantService#getBaseName(org.alfresco.service.cmr.repository.AssociationRef)
*/
public AssociationRef getBaseName(AssociationRef assocRef)
{
if (assocRef == null) { return null; }
return new AssociationRef(
getBaseName(assocRef.getSourceRef()),
assocRef.getTypeQName(),
getBaseName(assocRef.getTargetRef()));
}
/* (non-Javadoc)
* @see org.alfresco.repo.tenant.TenantService#getBaseName(java.lang.String)
*/
public String getBaseName(String name) public String getBaseName(String name)
{ {
// get base name, but don't force for non-tenant user (e.g. super admin) // get base name, but don't force for non-tenant user (e.g. super admin)
return getBaseName(name, false); return getBaseName(name, false);
} }
/* (non-Javadoc)
* @see org.alfresco.repo.tenant.TenantService#getBaseName(java.lang.String, boolean)
*/
public String getBaseName(String name, boolean forceForNonTenant) public String getBaseName(String name, boolean forceForNonTenant)
{ {
// Check that all the passed values are not null // Check that all the passed values are not null
@@ -293,6 +348,9 @@ public class MultiTServiceImpl implements TenantService
return name; return name;
} }
/* (non-Javadoc)
* @see org.alfresco.repo.tenant.TenantService#getBaseNameUser(java.lang.String)
*/
public String getBaseNameUser(String name) public String getBaseNameUser(String name)
{ {
// can be null (e.g. for System user / during app ctx init) // can be null (e.g. for System user / during app ctx init)
@@ -307,6 +365,9 @@ public class MultiTServiceImpl implements TenantService
return name; return name;
} }
/* (non-Javadoc)
* @see org.alfresco.repo.tenant.TenantService#checkDomainUser(java.lang.String)
*/
public void checkDomainUser(String username) public void checkDomainUser(String username)
{ {
// Check that all the passed values are not null // Check that all the passed values are not null
@@ -333,6 +394,9 @@ public class MultiTServiceImpl implements TenantService
} }
} }
/* (non-Javadoc)
* @see org.alfresco.repo.tenant.TenantService#checkDomain(java.lang.String)
*/
public void checkDomain(String name) public void checkDomain(String name)
{ {
// Check that all the passed values are not null // Check that all the passed values are not null
@@ -356,6 +420,9 @@ public class MultiTServiceImpl implements TenantService
} }
} }
/* (non-Javadoc)
* @see org.alfresco.repo.tenant.TenantService#getRootNode(org.alfresco.service.cmr.repository.NodeService, org.alfresco.service.cmr.search.SearchService, org.alfresco.service.namespace.NamespaceService, java.lang.String, org.alfresco.service.cmr.repository.NodeRef)
*/
public NodeRef getRootNode(NodeService nodeService, SearchService searchService, NamespaceService namespaceService, String rootPath, NodeRef rootNodeRef) public NodeRef getRootNode(NodeService nodeService, SearchService searchService, NamespaceService namespaceService, String rootPath, NodeRef rootNodeRef)
{ {
// Check that all the passed values are not null // Check that all the passed values are not null
@@ -428,11 +495,17 @@ public class MultiTServiceImpl implements TenantService
} }
} }
/* (non-Javadoc)
* @see org.alfresco.repo.tenant.TenantService#isTenantUser()
*/
public boolean isTenantUser() public boolean isTenantUser()
{ {
return isTenantUser(AuthenticationUtil.getCurrentUserName()); return isTenantUser(AuthenticationUtil.getCurrentUserName());
} }
/* (non-Javadoc)
* @see org.alfresco.repo.tenant.TenantService#isTenantUser(java.lang.String)
*/
public boolean isTenantUser(String username) public boolean isTenantUser(String username)
{ {
// can be null (e.g. for System user / during app ctx init) // can be null (e.g. for System user / during app ctx init)
@@ -446,6 +519,9 @@ public class MultiTServiceImpl implements TenantService
return false; return false;
} }
/* (non-Javadoc)
* @see org.alfresco.repo.tenant.TenantService#isTenantName(java.lang.String)
*/
public boolean isTenantName(String name) public boolean isTenantName(String name)
{ {
// Check that all the passed values are not null // Check that all the passed values are not null
@@ -464,6 +540,9 @@ public class MultiTServiceImpl implements TenantService
return false; return false;
} }
/* (non-Javadoc)
* @see org.alfresco.repo.tenant.TenantService#getUserDomain(java.lang.String)
*/
public String getUserDomain(String username) public String getUserDomain(String username)
{ {
// can be null (e.g. for System user / during app ctx init) // can be null (e.g. for System user / during app ctx init)
@@ -483,12 +562,18 @@ public class MultiTServiceImpl implements TenantService
return DEFAULT_DOMAIN; // default domain - non-tenant user return DEFAULT_DOMAIN; // default domain - non-tenant user
} }
/* (non-Javadoc)
* @see org.alfresco.repo.tenant.TenantUserService#getCurrentUserDomain()
*/
public String getCurrentUserDomain() public String getCurrentUserDomain()
{ {
String user = AuthenticationUtil.getCurrentUserName(); String user = AuthenticationUtil.getCurrentUserName();
return getUserDomain(user); return getUserDomain(user);
} }
/* (non-Javadoc)
* @see org.alfresco.repo.tenant.TenantUserService#getDomain(java.lang.String)
*/
public String getDomain(String name) public String getDomain(String name)
{ {
// Check that all the passed values are not null // Check that all the passed values are not null
@@ -513,6 +598,9 @@ public class MultiTServiceImpl implements TenantService
return nameDomain; return nameDomain;
} }
/* (non-Javadoc)
* @see org.alfresco.repo.tenant.TenantUserService#getDomainUser(java.lang.String, java.lang.String)
*/
public String getDomainUser(String baseUsername, String tenantDomain) public String getDomainUser(String baseUsername, String tenantDomain)
{ {
// Check that all the passed values are not null // Check that all the passed values are not null
@@ -550,6 +638,9 @@ public class MultiTServiceImpl implements TenantService
} }
} }
/* (non-Javadoc)
* @see org.alfresco.repo.tenant.TenantService#getTenant(java.lang.String)
*/
public Tenant getTenant(String tenantDomain) public Tenant getTenant(String tenantDomain)
{ {
Tenant tenant = tenantsCache.get(tenantDomain); Tenant tenant = tenantsCache.get(tenantDomain);
@@ -573,6 +664,9 @@ public class MultiTServiceImpl implements TenantService
return tenant; return tenant;
} }
/* (non-Javadoc)
* @see org.alfresco.repo.tenant.TenantUserService#isEnabled()
*/
public boolean isEnabled() public boolean isEnabled()
{ {
return true; return true;

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright (C) 2005-2007 Alfresco Software Limited. * Copyright (C) 2005-2008 Alfresco Software Limited.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
@@ -117,6 +117,14 @@ public class SingleTAdminServiceImpl implements TenantAdminService
return TenantService.DEFAULT_DOMAIN; return TenantService.DEFAULT_DOMAIN;
} }
/**
* @return Returns the given <tt>username</tt> always
*/
public String getBaseNameUser(String username)
{
return username;
}
/** /**
* @return Returns the given <tt>baseUserName</tt> always * @return Returns the given <tt>baseUserName</tt> always
*/ */

View File

@@ -99,6 +99,11 @@ public class SingleTServiceImpl implements TenantService
return childAssocRef; return childAssocRef;
} }
public AssociationRef getBaseName(AssociationRef assocRef)
{
return assocRef;
}
public String getBaseName(String name) public String getBaseName(String name)
{ {
return name; return name;

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright (C) 2005-2007 Alfresco Software Limited. * Copyright (C) 2005-2008 Alfresco Software Limited.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
@@ -108,6 +108,11 @@ public interface TenantService extends TenantUserService
*/ */
public ChildAssociationRef getBaseName(ChildAssociationRef childAssocRef); public ChildAssociationRef getBaseName(ChildAssociationRef childAssocRef);
/**
* @return the reference <b>without</b> the tenant-specific ID attached
*/
public AssociationRef getBaseName(AssociationRef assocRef);
/** /**
* @return the reference <b>without</b> the tenant-specific ID attached * @return the reference <b>without</b> the tenant-specific ID attached
*/ */
@@ -118,8 +123,6 @@ public interface TenantService extends TenantUserService
*/ */
public String getBaseName(String name, boolean forceIfNonTenant); public String getBaseName(String name, boolean forceIfNonTenant);
public String getBaseNameUser(String name);
public void checkDomainUser(String username); public void checkDomainUser(String username);
public void checkDomain(String name); public void checkDomain(String name);

View File

@@ -1,3 +1,27 @@
/*
* Copyright (C) 2005-2008 Alfresco Software Limited.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
* As a special exception to the terms and conditions of version 2.0 of
* the GPL, you may redistribute this Program in connection with Free/Libre
* and Open Source Software ("FLOSS") applications as described in Alfresco's
* FLOSS exception. You should have recieved a copy of the text describing
* the FLOSS exception, and it is also available here:
* http://www.alfresco.com/legal/licensing"
*/
package org.alfresco.repo.tenant; package org.alfresco.repo.tenant;
/** /**
@@ -9,13 +33,33 @@ package org.alfresco.repo.tenant;
*/ */
public interface TenantUserService public interface TenantUserService
{ {
public String getCurrentUserDomain(); /**
* @return the username <b>with</b> the tenant-specific ID attached
public String getDomain(String name); */
public String getUserDomain(String username);
public String getDomainUser(String baseUsername, String tenantDomain); public String getDomainUser(String baseUsername, String tenantDomain);
/**
* @return the username <b>without</b> the tenant-specific ID attached
*/
public String getBaseNameUser(String name);
/**
* @return the tenant-specific ID for current user
*/
public String getCurrentUserDomain();
/**
* @return the tenant-specific ID for specified username
*/
public String getUserDomain(String username);
/**
* @return the tenant-specific ID for specified identifier
*/
public String getDomain(String name);
/**
* @return true if the system is configured to be MT-enabled
*/
public boolean isEnabled(); public boolean isEnabled();
} }