Merged 5.0.N (5.0.3) to 5.1.N (5.1.1)

112930: Merged V4.2-BUG-FIX (4.2.6) to 5.0.N (5.0.3)
      112707 adavis: Merged V4.2.5 (4.2.5) to V4.2-BUG-FIX (4.2.6)
         112677 dvaserin: MNT-14780 (MNT-13871): Licence Error message when in overage
          - Place overage buffer information into License MBean and use it in admin license ftl.
         112634 adavis: MNT-13871: Merged DEV (V4.2.5-MNT-13871-LATEST) to V4.2.5 (4.2.5)
            111550: Merged DEV (4.1.11) to DEV (4.2.5)
               MNT-13871 : Count authorised users as those who've logged in, not total # of person objects
                  - Merged all made changes in core alfresco projects as single commit to fresh dev branch forked from V4.1-BUG-FIX.
               MNT-13871 : Count authorised users as those who've logged in, not total # of person objects
                  - added try/finally approach to reset show delete users flag to default value.,
            111574: MNT-13871: Count authorised users as those who've logged in, not total # of person objects
               - Added V4.2.5 specific changes.,
            111582: MNT-13871: Count authorised users as those who've logged in, not total # of person objects
               - Updated the jar to correspond with the latest changes in authorised-users/4.2,
            111751: MNT-13871: Count authorised users as those who've logged in, not total # of person objects
               - Removed unnecessary configuration.,
            111752: Merged DEV (V4.1.11) to DEV (V4.2.5)
               111632: MNT-13871 : Count authorised users as those who've logged in, not total # of person objects
                  - Fixed unit tests for build plan: https://bamboo.alfresco.com/bamboo/browse/DEV-ENT414-1,
            111753: Merged DEV (4.1.11) to DEV (V4.2.5)
               111719: MNT-13871 : Count authorised users as those who've logged in, not total # of person objects
                  - Updated authorization related icons with ones provided by Mark Howarth.
                  - Information message in Deauthorize Dialog was changed to the on provided by Mark Howarth.,
            111754: MNT-13871 : Count authorised users as those who've logged in, not total # of person objects
               - Updated to the latest authorised-users lib.,
            111761: MNT-13871: Count authorised users as those who've logged in, not total # of person objects
               - Fix for the SchemaReferenceFileTest.,
            111800: MNT-13871: Count authorised users as those who've logged in, not total # of person objects
               - Modified the test to create a tenant in a retrying transaction to solve the DataIntegrityViolationException.,
            111801: Megred DEV (4.1.11) to DEV (4.2.5)
               111795: MNT-13871 : Count authorised users as those who've logged in, not total # of person objects
                  - Updated Deleted column to display text instead of tick icon.
                  - Added name for actions column.,
            111813: MNT-13871: Count authorised users as those who've logged in, not total # of person objects
               - Updated to the latest authorisation jar to fix the Scema Reference test.,
            112020: MNT-14775: De-authorisation pop-up has similar title to first line of text
              - Remove the duplicated text from the pop-up body
              - Updated link to point the 4.2 documentation,
            112134: MNT-14763: [UserAuth] New entries are added in the authorization table for each different username case
             - Update authorization jar,
            112144: MNT-13871: Optimized strings in users.get.properties,
            112184: MNT-14762 : [UserAuth]Users from the ALFRESCO_ADMINISTRATORS LDAP group are not pre-authorized
               - Updated authorized-users jar with fix for ldap administrators pre-authorization.,
            112196: MNT-14729 : [UserAuth] The column header for the Deauthorize and Reauthorize button should have a name
               - Updated name for re/de-authorize actions column.,
            112202: MNT-14763: [UserAuth] New entries are added in the authorization table for each different username case
             - Add new authorization jar to fix null errors,
            112203: MNT-14779: System behaviour when system set read only due to licence exception
             - Force read-write transaction for LoginPost script.,
            112225: MNT-14763: [UserAuth] New entries are added in the authorization table for each different username case
             - Add new authorization jar after unit test fixing.,
            112226: MNT-14740 : [UserAuth] The message for the failed re authorization is not displayed onIE
               - Code for reloading page was wrapped with YAHOO.lang.later() function.,
            112247: MNT-14747 : [UserAuth]The Autorization State isn't change when the user logs via FTP.
               - Updated authorization jar with fix for kerberos unit test.,
            112259: MNT-14776: Heading banner text when using all allowed authorised users.
               - Changed the message.
               - Updated the authorised-users jar.,
            112269: MNT-13871: Count authorised users as those who've logged in, not total # of person objects
             - Wrap methods that uses 'authenticationComponent.setCurrentUser' into RetryingTransaction for retrying on DataIntegrityViolationException.,
            112285: MNT-14747 : [UserAuth]The Autorization State isn't change when the user logs via FTP.
               - Updated version for authorized-users jar.,
            112388: MNT-14809: [UserAuth] On a cluster setup after running the hourly job only one node goes into R/O mode
               - Updated the authorised-users.jar,
            112439: MNT-14815 : Wrong documentation link used in the deauthorize message window
               - Corrected link to documentation.,
            112445: MNT-14818 : [UserAuth] Missing quotation mark in the user reauthorization window message
               - Corrected message for reauthorization dialog.,
            112450: MNT-14802: [UserAuth] License warning message displayed for all the users
               - Updated the authorised-users jar.,
            112454: MNT-14780: Licence Error message when in overage
             - Make license warn messages on admin console the same as banner warn messages.,
            112471: MNT-14773 : Sort state not persisted after authorisation action
               - Sorting/paging state is now persists in sessionStorage.,
            112478: MNT-14773 : Sort state not persisted after authorisation action
               - Corrected previous fix.,
            112483: MNT-14814: [UserAuth] System goes into R/O mode after running the hourly job
               - Updated the authorised-users jar to the latest version.,
            112512: MNT-14833: [UserAuth] User cannot login on both nodes (cluster env.)
             - Update authorization jar.,
            112556: MNT-14787: [UserAuth] Login via NFS works when the license limit exceed
               - Modified the exception handling of setCurrentUser method. Now all the exceptions are rethrown.,
            112570: MNT-14838: Correct the Max Users string in the Admin Console License Screen
               - Corrected the string, remove the incorrect translations from the bundle.,
            112572: REVERSE MERGED  <<code is not worth to implement>>
               112471 : MNT-14773 : Sort state not persisted after authorisation action
                  - Sorting/paging state is now persists in sessionStorage. 
               112478 : MNT-14773 : Sort state not persisted after authorisation action
                  - Corrected previous fix. ,
            112610: MNT-14837 : Report license overage to the log files on authorization/deauthorization of users
               - Updated users authorization jar file.,
            112627: MNT-14839: [UserAuth]Alfresco goes in read -only after reauthorize a user from LDAP ALFESCO_ADMINISTRATORS group
               - Updated the authorised-users jar to the latest version.
   Merged DEV (V5.0.2-MNT-13871) to 5.0.N (5.0.3)
      111954: MNT-13871: Count authorised users as those who've logged in, not total # of person objects
         - Removed context reference to authorization.,
      112003: MNT-13871: Count authorised users as those who've logged in, not total # of person objects
         -  Added copying of sources and configuration from authorised-users to the output directory during build.,
      112014: MNT-13871: Count authorised users as those who've logged in, not total # of person objects
         - Modified the build configuration to unpack the resources to the test folders.,
      112027: MNT-13871: Count authorised users as those who've logged in, not total # of person objects
         - Added unpacking of authorisation resources to repoitory-crypto project.,
      112067: MNT-13871: Count authorised users as those who've logged in, not total # of person objects
         - Removed unpacking of resources, changed the context imports to point to authorization.,
   112952: Merged DEV (V5.0.2-MNT-13871) to 5.0.N (5.0.3)
      111887: MNT-13871: Count authorised users as those who've logged in, not total # of person objects
         - Corrected the authorised-users version to correspond to 5.0.,
   113060: Merged V4.2-BUG-FIX (4.2.6) to 5.0.N (5.0.3)
      113059 adavis: Merged V4.2.5 (4.2.5) to V4.2-BUG-FIX (4.2.6)
         113058 adavis: MNT-13871: Count authorised users as those who've logged in, not total # of person objects
            - Version dependency for alfresco-authorised-users moved to top level pom


git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/BRANCHES/DEV/5.1.N/root@113101 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Alan Davis
2015-09-25 13:42:39 +00:00
parent dfe03d979b
commit be1414ecde
10 changed files with 1021 additions and 627 deletions

View File

@@ -49,4 +49,7 @@
<import resource="classpath:alfresco/invitation-service-context.xml"/> <import resource="classpath:alfresco/invitation-service-context.xml"/>
<import resource="classpath:alfresco/webdav-context.xml"/> <import resource="classpath:alfresco/webdav-context.xml"/>
<import resource="classpath*:alfresco/patch/*-context.xml" /> <import resource="classpath*:alfresco/patch/*-context.xml" />
<import resource="classpath*:alfresco/dbscripts/*-context.xml" />
<import resource="classpath*:alfresco/enterprise/authorization-context.xml" />
<import resource="classpath*:alfresco/enterprise/enterprise-usage-services-context.xml" />
</beans> </beans>

View File

@@ -84,6 +84,7 @@ system.usage.warn.limit_documents_approached=The allowable content limit of {0}
system.usage.warn.limit_documents_reached=The allowable content limit of {0} has been reached. There are {1} content objects in the system. system.usage.warn.limit_documents_reached=The allowable content limit of {0} has been reached. There are {1} content objects in the system.
system.usage.err.limit_users_exceeded=The allowable user limit of {0} as per your license agreement has been exceeded. There are currently {1} users in the system. Please contact your Alfresco sales representative to purchase additional user licenses. system.usage.err.limit_users_exceeded=The allowable user limit of {0} as per your license agreement has been exceeded. There are currently {1} users in the system. Please contact your Alfresco sales representative to purchase additional user licenses.
system.usage.err.limit_users_exceeded_verbose=The allowable user limit of {0} as per your license agreement has been exceeded. Users added: {1}. Please contact your Alfresco sales representative to purchase additional user licenses. system.usage.err.limit_users_exceeded_verbose=The allowable user limit of {0} as per your license agreement has been exceeded. Users added: {1}. Please contact your Alfresco sales representative to purchase additional user licenses.
system.usage.warn.limit_users_overage=The allowable user limit of {0} for your license agreement has been reached. There are {1} users in the system, {2} are allowed. Please contact your Alfresco sales representative to purchase additional user licenses.
system.usage.err.limit_documents_exceeded=The allowable content limit of {0} has been exceeded. There are currently {1} content objects in the system. system.usage.err.limit_documents_exceeded=The allowable content limit of {0} has been exceeded. There are currently {1} content objects in the system.
system.usage.err.limit_license_expiring=The Alfresco license will expire in {0} days. system.usage.err.limit_license_expiring=The Alfresco license will expire in {0} days.

View File

@@ -26,7 +26,7 @@
Import all modules and related components. Import all modules and related components.
--> -->
<import resource="classpath*:alfresco/module-context.xml" /> <import resource="classpath*:alfresco/module-context.xml" />
<!-- <!--
Import of the minimal extensions and bean overrides. Import of the minimal extensions and bean overrides.
--> -->

View File

@@ -77,6 +77,10 @@
<type>d:content</type> <type>d:content</type>
<multiple>false</multiple> <multiple>false</multiple>
</property> </property>
<property name="sys:keyStore">
<type>d:content</type>
<multiple>false</multiple>
</property>
</properties> </properties>
</type> </type>

View File

@@ -372,6 +372,7 @@ public class AlfrescoRpcAuthenticator implements RpcAuthenticator, InitializingB
{ {
if ( logger.isErrorEnabled()) if ( logger.isErrorEnabled())
logger.error( "Error in RPC authenticator setting current user", ex); logger.error( "Error in RPC authenticator setting current user", ex);
throw ex;
} }
} }

View File

@@ -165,11 +165,11 @@ public class People extends BaseScopableProcessorExtension implements Initializi
/** /**
* Set the service registry * Set the service registry
* *
* @param serviceRegistry the service registry * @param serviceRegistry the service registry
*/ */
public void setServiceRegistry(ServiceRegistry serviceRegistry) public void setServiceRegistry(ServiceRegistry serviceRegistry)
{ {
this.services = serviceRegistry; this.services = serviceRegistry;
} }
/** /**
@@ -311,8 +311,8 @@ public class People extends BaseScopableProcessorExtension implements Initializi
public ScriptNode createPerson(String userName, String firstName, String lastName, String emailAddress, public ScriptNode createPerson(String userName, String firstName, String lastName, String emailAddress,
String password, boolean setAccountEnabled, boolean notifyByEmail) String password, boolean setAccountEnabled, boolean notifyByEmail)
{ {
ParameterCheck.mandatory("firstName", firstName); ParameterCheck.mandatory("firstName", firstName);
ParameterCheck.mandatory("emailAddress", emailAddress); ParameterCheck.mandatory("emailAddress", emailAddress);
ScriptNode person = null; ScriptNode person = null;
@@ -321,13 +321,13 @@ public class People extends BaseScopableProcessorExtension implements Initializi
{ {
for (int i=0; i < numRetries; i++) for (int i=0; i < numRetries; i++)
{ {
userName = usernameGenerator.generateUserName(firstName, lastName, emailAddress, i); userName = usernameGenerator.generateUserName(firstName, lastName, emailAddress, i);
// create person if user name does not already exist // create person if user name does not already exist
if (!personService.personExists(userName)) if (!personService.personExists(userName))
{ {
break; break;
} }
} }
} }
@@ -344,19 +344,19 @@ public class People extends BaseScopableProcessorExtension implements Initializi
person = createPerson(userName, firstName, lastName, emailAddress); person = createPerson(userName, firstName, lastName, emailAddress);
if (person != null && password != null) if (person != null && password != null)
{ {
// create account for person with the userName and password // create account for person with the userName and password
authenticationService.createAuthentication(userName, password.toCharArray()); authenticationService.createAuthentication(userName, password.toCharArray());
authenticationService.setAuthenticationEnabled(userName, setAccountEnabled); authenticationService.setAuthenticationEnabled(userName, setAccountEnabled);
person.save(); person.save();
if(notifyByEmail) if(notifyByEmail)
{ {
personService.notifyPerson(userName, password); personService.notifyPerson(userName, password);
} }
} }
} }
return person; return person;
@@ -914,8 +914,8 @@ public class People extends BaseScopableProcessorExtension implements Initializi
if ("fullName".equalsIgnoreCase(sortBy)) if ("fullName".equalsIgnoreCase(sortBy))
{ {
String firstName = nodeService.getProperty(nodeRef, ContentModel.PROP_FIRSTNAME).toString(); String firstName = (String)nodeService.getProperty(nodeRef, ContentModel.PROP_FIRSTNAME);
String lastName = nodeService.getProperty(nodeRef, ContentModel.PROP_LASTNAME).toString(); String lastName = (String)nodeService.getProperty(nodeRef, ContentModel.PROP_LASTNAME);
String fullName = firstName; String fullName = firstName;
if (lastName != null && lastName.length() > 0) if (lastName != null && lastName.length() > 0)
{ {

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright (C) 2005-2013 Alfresco Software Limited. * Copyright (C) 2005-2015 Alfresco Software Limited.
* *
* This file is part of Alfresco * This file is part of Alfresco
* *

View File

@@ -24,12 +24,12 @@ import java.io.Serializable;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import javax.transaction.UserTransaction;
import org.alfresco.model.ContentModel; import org.alfresco.model.ContentModel;
import org.alfresco.repo.policy.BehaviourFilter;
import org.alfresco.repo.security.authentication.AuthenticationUtil; import org.alfresco.repo.security.authentication.AuthenticationUtil;
import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork; import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork;
import org.alfresco.repo.tenant.TenantUtil.TenantRunAsWork; import org.alfresco.repo.tenant.TenantUtil.TenantRunAsWork;
import org.alfresco.repo.transaction.RetryingTransactionHelper;
import org.alfresco.service.cmr.repository.AssociationRef; import org.alfresco.service.cmr.repository.AssociationRef;
import org.alfresco.service.cmr.repository.ChildAssociationRef; import org.alfresco.service.cmr.repository.ChildAssociationRef;
import org.alfresco.service.cmr.repository.NodeRef; import org.alfresco.service.cmr.repository.NodeRef;
@@ -42,6 +42,7 @@ import org.alfresco.service.namespace.NamespaceService;
import org.alfresco.service.namespace.QName; import org.alfresco.service.namespace.QName;
import org.alfresco.service.transaction.TransactionService; import org.alfresco.service.transaction.TransactionService;
import org.alfresco.util.ApplicationContextHelper; import org.alfresco.util.ApplicationContextHelper;
import org.alfresco.util.GUID;
import org.junit.After; import org.junit.After;
import org.junit.Before; import org.junit.Before;
import org.junit.Test; import org.junit.Test;
@@ -66,41 +67,40 @@ public class MultiTServiceImplTest
private SearchService searchService; private SearchService searchService;
private NamespaceService namespaceService; private NamespaceService namespaceService;
private UserTransaction txn;
private boolean mtEnabled; private boolean mtEnabled;
// Test variables // Test variables
private static final String DEFAULT_ADMIN_PW = "admin"; private static final String DEFAULT_ADMIN_PW = "admin";
private static final String PASS = "password"; private static final String PASS = "password";
private static final String DOMAIN = MultiTServiceImplTest.class.getName().toLowerCase();
private static final String USER1 = "USER1";
private static final String USER2 = "USER2";
private static final String USER3 = "USER3";
private static final String USER2_WITH_DOMAIN = USER2 + TenantService.SEPARATOR + DOMAIN;
private static final String STRING = "stringwithouttenant";
private static final String TENANT_STRING = addDomainToId(STRING, DOMAIN);
private static final String STRING_WITH_EXISTENT_DOMAIN = TenantService.SEPARATOR + DOMAIN + TenantService.SEPARATOR;
private static final String STRING_WITH_NONEXITENT_DOMAIN = TenantService.SEPARATOR + STRING + TenantService.SEPARATOR;
private static final String PROTOCOL = "testprotocol"; private static final String PROTOCOL = "testprotocol";
private static final String IDENTIFIER = "testidentifier"; private static final String IDENTIFIER = "testidentifier";
private static final String ID = "id"; private static final String ID = "id";
private static final String ROOT_PATH = "/"; private static final String ROOT_PATH = "/";
private static final StoreRef DEFAULT_STORE = StoreRef.STORE_REF_WORKSPACE_SPACESSTORE; private static final StoreRef DEFAULT_STORE = StoreRef.STORE_REF_WORKSPACE_SPACESSTORE;
private static final StoreRef TENANT_STORE = new StoreRef(StoreRef.PROTOCOL_WORKSPACE, addDomainToId("SpacesStore", DOMAIN));
private static final NodeRef NODE_REF = new NodeRef(PROTOCOL, IDENTIFIER, ID); private static final NodeRef NODE_REF = new NodeRef(PROTOCOL, IDENTIFIER, ID);
private static final NodeRef TENANT_NODE_REF = new NodeRef(PROTOCOL, addDomainToId(IDENTIFIER, DOMAIN), ID);
private static final StoreRef STORE_REF = new StoreRef(PROTOCOL, IDENTIFIER); private static final StoreRef STORE_REF = new StoreRef(PROTOCOL, IDENTIFIER);
private static final StoreRef TENANT_STORE_REF = new StoreRef(PROTOCOL, addDomainToId(IDENTIFIER, DOMAIN));
private static final String NAMESPACE_URI = "testassoctypenamespace"; private static final String NAMESPACE_URI = "testassoctypenamespace";
private static final String LOCAL_NAME = "testassoctypelocalname"; private static final String LOCAL_NAME = "testassoctypelocalname";
private static final QName QNAME = QName.createQName(NAMESPACE_URI, LOCAL_NAME); private static final QName QNAME = QName.createQName(NAMESPACE_URI, LOCAL_NAME);
private static final QName TENANT_QNAME = QName.createQName(addDomainToId(NAMESPACE_URI, DOMAIN), LOCAL_NAME);
private static final AssociationRef assocRef = new AssociationRef(NODE_REF, QNAME, NODE_REF); private static final AssociationRef assocRef = new AssociationRef(NODE_REF, QNAME, NODE_REF);
private static final AssociationRef tenantAssocRef = new AssociationRef(TENANT_NODE_REF, QNAME, TENANT_NODE_REF);
private static final ChildAssociationRef childAssocRef = new ChildAssociationRef(QNAME, NODE_REF, QNAME, NODE_REF); private static String DOMAIN = null;
private static final ChildAssociationRef tenantChildAssocRef = new ChildAssociationRef(QNAME, TENANT_NODE_REF, QNAME, TENANT_NODE_REF); private static String USER1 = null;
private static String USER2 = null;
private static String USER3 = null;
private static String USER2_WITH_DOMAIN = null;
private static String STRING = null;
private static String TENANT_STRING = null;
private static String STRING_WITH_EXISTENT_DOMAIN = null;
private static String STRING_WITH_NONEXITENT_DOMAIN = null;
private static StoreRef TENANT_STORE = null;
private static NodeRef TENANT_NODE_REF = null;
private static StoreRef TENANT_STORE_REF = null;
private static QName TENANT_QNAME = null;
private static AssociationRef tenantAssocRef = null;
private static ChildAssociationRef childAssocRef = null;
private static ChildAssociationRef tenantChildAssocRef = null;
@Before @Before
public void setUp() throws Exception public void setUp() throws Exception
{ {
@@ -113,19 +113,34 @@ public class MultiTServiceImplTest
nodeService = ctx.getBean("NodeService", NodeService.class); nodeService = ctx.getBean("NodeService", NodeService.class);
searchService = ctx.getBean("SearchService", SearchService.class); searchService = ctx.getBean("SearchService", SearchService.class);
namespaceService = ctx.getBean("NamespaceService", NamespaceService.class); namespaceService = ctx.getBean("NamespaceService", NamespaceService.class);
DOMAIN = GUID.generate();
USER1 = GUID.generate();
USER2 = GUID.generate();
USER3 = GUID.generate();
USER2_WITH_DOMAIN = USER2 + TenantService.SEPARATOR + DOMAIN;
STRING = GUID.generate();
TENANT_STRING = addDomainToId(STRING, DOMAIN);
STRING_WITH_EXISTENT_DOMAIN = TenantService.SEPARATOR + DOMAIN + TenantService.SEPARATOR;
STRING_WITH_NONEXITENT_DOMAIN = TenantService.SEPARATOR + STRING + TenantService.SEPARATOR;
TENANT_STORE = new StoreRef(StoreRef.PROTOCOL_WORKSPACE, addDomainToId("SpacesStore", DOMAIN));
TENANT_NODE_REF = new NodeRef(PROTOCOL, addDomainToId(IDENTIFIER, DOMAIN), ID);
TENANT_STORE_REF = new StoreRef(PROTOCOL, addDomainToId(IDENTIFIER, DOMAIN));
TENANT_QNAME = QName.createQName(addDomainToId(NAMESPACE_URI, DOMAIN), LOCAL_NAME);
tenantAssocRef = new AssociationRef(TENANT_NODE_REF, QNAME, TENANT_NODE_REF);
childAssocRef = new ChildAssociationRef(QNAME, NODE_REF, QNAME, NODE_REF);
tenantChildAssocRef = new ChildAssociationRef(QNAME, TENANT_NODE_REF, QNAME, TENANT_NODE_REF);
AuthenticationUtil.setFullyAuthenticatedUser(AuthenticationUtil.getAdminUserName()); AuthenticationUtil.setFullyAuthenticatedUser(AuthenticationUtil.getAdminUserName());
mtEnabled = AuthenticationUtil.isMtEnabled(); mtEnabled = AuthenticationUtil.isMtEnabled();
txn = transactionService.getUserTransaction();
txn.begin();
AuthenticationUtil.setMtEnabled(false); AuthenticationUtil.setMtEnabled(false);
} }
@After @After
public void tearDown() throws Exception public void tearDown() throws Exception
{ {
txn.rollback(); deleteTenant(DOMAIN);
AuthenticationUtil.setMtEnabled(mtEnabled); AuthenticationUtil.setMtEnabled(mtEnabled);
AuthenticationUtil.clearCurrentSecurityContext(); AuthenticationUtil.clearCurrentSecurityContext();
} }
@@ -133,6 +148,13 @@ public class MultiTServiceImplTest
@Test @Test
public void testIsTenantUser() public void testIsTenantUser()
{ {
RetryingTransactionHelper.RetryingTransactionCallback<Void> work = new RetryingTransactionHelper.RetryingTransactionCallback<Void>()
{
@Override
public Void execute() throws Throwable
{
// Create a user with a plain user name without a domain // Create a user with a plain user name without a domain
NodeRef userNodeRef = createUser(USER1, TenantService.DEFAULT_DOMAIN, PASS); NodeRef userNodeRef = createUser(USER1, TenantService.DEFAULT_DOMAIN, PASS);
assertNotNull("The user was not created.", userNodeRef); assertNotNull("The user was not created.", userNodeRef);
@@ -148,11 +170,21 @@ public class MultiTServiceImplTest
userNodeRef = createUser(USER3, DOMAIN, PASS); userNodeRef = createUser(USER3, DOMAIN, PASS);
assertNotNull("The user was not created.", userNodeRef); assertNotNull("The user was not created.", userNodeRef);
assertTrue("The user is from a tenant, but was reported otherwise.", multiTServiceImpl.isTenantUser(USER3 + MultiTServiceImpl.SEPARATOR + DOMAIN)); assertTrue("The user is from a tenant, but was reported otherwise.", multiTServiceImpl.isTenantUser(USER3 + MultiTServiceImpl.SEPARATOR + DOMAIN));
return null;
}
};
transactionService.getRetryingTransactionHelper().doInTransaction(work);
} }
@Test @Test
public void testGetCurrentUserDomain() public void testGetCurrentUserDomain()
{ {
RetryingTransactionHelper.RetryingTransactionCallback<Void> work = new RetryingTransactionHelper.RetryingTransactionCallback<Void>()
{
@Override
public Void execute() throws Throwable
{
// Test a tenant user // Test a tenant user
createTenant(DOMAIN); createTenant(DOMAIN);
NodeRef userNodeRef = createUser(USER1, DOMAIN, PASS); NodeRef userNodeRef = createUser(USER1, DOMAIN, PASS);
@@ -185,11 +217,21 @@ public class MultiTServiceImplTest
result = TenantUtil.runAsUserTenant(work, USER2, TenantService.DEFAULT_DOMAIN); result = TenantUtil.runAsUserTenant(work, USER2, TenantService.DEFAULT_DOMAIN);
assertEquals("The domains do not match.", TenantService.DEFAULT_DOMAIN, result); assertEquals("The domains do not match.", TenantService.DEFAULT_DOMAIN, result);
return null;
}
};
transactionService.getRetryingTransactionHelper().doInTransaction(work);
} }
@Test @Test
public void testGetName() public void testGetName()
{ {
RetryingTransactionHelper.RetryingTransactionCallback<Void> work = new RetryingTransactionHelper.RetryingTransactionCallback<Void>()
{
@Override
public Void execute() throws Throwable
{
NodeRef userNodeRef = createUser(USER1, TenantService.DEFAULT_DOMAIN, PASS); NodeRef userNodeRef = createUser(USER1, TenantService.DEFAULT_DOMAIN, PASS);
assertNotNull("The user was not created.", userNodeRef); assertNotNull("The user was not created.", userNodeRef);
TenantRunAsWork<NodeRef> work1 = new TenantRunAsWork<NodeRef>() TenantRunAsWork<NodeRef> work1 = new TenantRunAsWork<NodeRef>()
@@ -288,7 +330,7 @@ public class MultiTServiceImplTest
@Override @Override
public QName doWork() throws Exception public QName doWork() throws Exception
{ {
return tenantService.getName(TENANT_NODE_REF ,QNAME); return tenantService.getName(TENANT_NODE_REF, QNAME);
} }
}; };
QName result7 = TenantUtil.runAsUserTenant(work7, USER2, DOMAIN); QName result7 = TenantUtil.runAsUserTenant(work7, USER2, DOMAIN);
@@ -304,11 +346,21 @@ public class MultiTServiceImplTest
}; };
String result8 = TenantUtil.runAsUserTenant(work8, USER2, DOMAIN); String result8 = TenantUtil.runAsUserTenant(work8, USER2, DOMAIN);
assertEquals("The String should contain domain.", TENANT_STRING, result8); assertEquals("The String should contain domain.", TENANT_STRING, result8);
return null;
}
};
transactionService.getRetryingTransactionHelper().doInTransaction(work);
} }
@Test @Test
public void testGetBaseName() public void testGetBaseName()
{ {
RetryingTransactionHelper.RetryingTransactionCallback<Void> work = new RetryingTransactionHelper.RetryingTransactionCallback<Void>()
{
@Override
public Void execute() throws Throwable
{
NodeRef userNodeRef = createUser(USER1, TenantService.DEFAULT_DOMAIN, PASS); NodeRef userNodeRef = createUser(USER1, TenantService.DEFAULT_DOMAIN, PASS);
assertNotNull("The user was not created.", userNodeRef); assertNotNull("The user was not created.", userNodeRef);
TenantRunAsWork<NodeRef> work1 = new TenantRunAsWork<NodeRef>() TenantRunAsWork<NodeRef> work1 = new TenantRunAsWork<NodeRef>()
@@ -412,11 +464,21 @@ public class MultiTServiceImplTest
}; };
String result6 = TenantUtil.runAsUserTenant(work6, USER2, DOMAIN); String result6 = TenantUtil.runAsUserTenant(work6, USER2, DOMAIN);
assertEquals("The String should not contain domain.", STRING, result6); assertEquals("The String should not contain domain.", STRING, result6);
return null;
}
};
transactionService.getRetryingTransactionHelper().doInTransaction(work);
} }
@Test @Test
public void testCheckDomainUser() public void testCheckDomainUser()
{ {
RetryingTransactionHelper.RetryingTransactionCallback<Void> work = new RetryingTransactionHelper.RetryingTransactionCallback<Void>()
{
@Override
public Void execute() throws Throwable
{
String nonExistentDomain = "nonExistentDomain"; String nonExistentDomain = "nonExistentDomain";
createUser(USER1, TenantService.DEFAULT_DOMAIN, PASS); createUser(USER1, TenantService.DEFAULT_DOMAIN, PASS);
createTenant(DOMAIN); createTenant(DOMAIN);
@@ -458,56 +520,75 @@ public class MultiTServiceImplTest
{ {
// Expected // Expected
} }
return null;
}
};
transactionService.getRetryingTransactionHelper().doInTransaction(work);
} }
@Test @Test
public void testCheckDomain() public void testCheckDomain()
{ {
createUser(USER1, TenantService.DEFAULT_DOMAIN, PASS); RetryingTransactionHelper.RetryingTransactionCallback<Void> work = new RetryingTransactionHelper.RetryingTransactionCallback<Void>()
createTenant(DOMAIN); {
createUser(USER2, DOMAIN, PASS); @Override
public Void execute() throws Throwable
{
createUser(USER1, TenantService.DEFAULT_DOMAIN, PASS);
createTenant(DOMAIN);
createUser(USER2, DOMAIN, PASS);
try try
{ {
createUser(USER3, STRING, PASS); createUser(USER3, STRING, PASS);
fail("The string has a domain, but there is no such tenant"); fail("The string has a domain, but there is no such tenant");
} }
catch (Exception e) catch (Exception e)
{ {
// Expected // Expected
} }
try try
{ {
checkDomainWork(STRING_WITH_EXISTENT_DOMAIN, TenantService.DEFAULT_DOMAIN, USER1); checkDomainWork(STRING_WITH_EXISTENT_DOMAIN, TenantService.DEFAULT_DOMAIN, USER1);
fail("The string has a domain, which should not match the default one."); fail("The string has a domain, which should not match the default one.");
} }
catch (Exception e) catch (Exception e)
{ {
// Expected // Expected
} }
try try
{ {
checkDomainWork(STRING_WITH_EXISTENT_DOMAIN, DOMAIN, USER2); checkDomainWork(STRING_WITH_EXISTENT_DOMAIN, DOMAIN, USER2);
} }
catch (Exception e) catch (Exception e)
{ {
fail("The string has a tenant domain and should match the execution context tenant."); fail("The string has a tenant domain and should match the execution context tenant.");
} }
try try
{ {
checkDomainWork(STRING_WITH_NONEXITENT_DOMAIN, DOMAIN, USER2); checkDomainWork(STRING_WITH_NONEXITENT_DOMAIN, DOMAIN, USER2);
fail("The string has a domain, which should not match the execution context tenant."); fail("The string has a domain, which should not match the execution context tenant.");
} }
catch (Exception e) catch (Exception e)
{ {
// Expected // Expected
} }
return null;
}
};
transactionService.getRetryingTransactionHelper().doInTransaction(work);
} }
@Test @Test
public void testGetRootNode() public void testGetRootNode()
{ {
RetryingTransactionHelper.RetryingTransactionCallback<Void> work = new RetryingTransactionHelper.RetryingTransactionCallback<Void>()
{
@Override
public Void execute() throws Throwable
{
NodeRef rootNodeRefDefault = nodeService.getRootNode(DEFAULT_STORE); NodeRef rootNodeRefDefault = nodeService.getRootNode(DEFAULT_STORE);
NodeRef rootNodeRef = new NodeRef(DEFAULT_STORE, IDENTIFIER); NodeRef rootNodeRef = new NodeRef(DEFAULT_STORE, IDENTIFIER);
NodeRef nodeRef = tenantService.getRootNode(nodeService, searchService, namespaceService, ROOT_PATH, rootNodeRef); NodeRef nodeRef = tenantService.getRootNode(nodeService, searchService, namespaceService, ROOT_PATH, rootNodeRef);
@@ -518,6 +599,10 @@ public class MultiTServiceImplTest
rootNodeRef = new NodeRef(TENANT_STORE, IDENTIFIER); rootNodeRef = new NodeRef(TENANT_STORE, IDENTIFIER);
nodeRef = tenantService.getRootNode(nodeService, searchService, namespaceService, ROOT_PATH, rootNodeRef); nodeRef = tenantService.getRootNode(nodeService, searchService, namespaceService, ROOT_PATH, rootNodeRef);
assertEquals("The reported rootNodeRef for the tenant domain is not correct.", rootNodeRefDefault, nodeRef); assertEquals("The reported rootNodeRef for the tenant domain is not correct.", rootNodeRefDefault, nodeRef);
return null;
}
};
transactionService.getRetryingTransactionHelper().doInTransaction(work);
} }
/** /**
@@ -526,33 +611,58 @@ public class MultiTServiceImplTest
@Test @Test
public void testIsTenantName() public void testIsTenantName()
{ {
RetryingTransactionHelper.RetryingTransactionCallback<Void> work = new RetryingTransactionHelper.RetryingTransactionCallback<Void>()
{
@Override
public Void execute() throws Throwable
{
boolean result = tenantService.isTenantName(STRING); boolean result = tenantService.isTenantName(STRING);
assertFalse("The string was reported as domain, but it is not", result); assertFalse("The string was reported as domain, but it is not", result);
result = tenantService.isTenantName(STRING_WITH_EXISTENT_DOMAIN); result = tenantService.isTenantName(STRING_WITH_EXISTENT_DOMAIN);
assertTrue("The string was not reported as domain.", result); assertTrue("The string was not reported as domain.", result);
return null;
}
};
transactionService.getRetryingTransactionHelper().doInTransaction(work);
} }
@Test @Test
public void testGetPrimaryDomain() public void testGetPrimaryDomain()
{ {
String result = tenantService.getPrimaryDomain(USER1); RetryingTransactionHelper.RetryingTransactionCallback<Void> work = new RetryingTransactionHelper.RetryingTransactionCallback<Void>()
assertNull("The primary domain should be null for a non tenant user without a tenant in name.", result); {
@Override
result = tenantService.getPrimaryDomain(USER2_WITH_DOMAIN); public Void execute() throws Throwable
assertNull("The primary domain should be null for a tenant user if multi tenancy is not enabled.", result); {
String result = tenantService.getPrimaryDomain(USER1);
createTenant(DOMAIN); assertNull("The primary domain should be null for a non tenant user without a tenant in name.", result);
result = tenantService.getPrimaryDomain(USER2_WITH_DOMAIN);
assertEquals("The primary domain should be of the USER2 is " + DOMAIN + ", but was reported as " + result, DOMAIN, result); result = tenantService.getPrimaryDomain(USER2_WITH_DOMAIN);
assertNull("The primary domain should be null for a tenant user if multi tenancy is not enabled.", result);
result = tenantService.getPrimaryDomain(USER1);
assertTrue("The primary domain should be the default one (empty string) for a non tenant user without a tenant in name.", result.equals(TenantService.DEFAULT_DOMAIN)); createTenant(DOMAIN);
result = tenantService.getPrimaryDomain(USER2_WITH_DOMAIN);
assertEquals("The primary domain of the USER2 should be " + DOMAIN + ", but was reported as " + result, DOMAIN, result);
result = tenantService.getPrimaryDomain(USER1);
assertTrue("The primary domain should be the default one (empty string) for a non tenant user without a tenant in name.", result.equals(TenantService.DEFAULT_DOMAIN));
return null;
}
};
transactionService.getRetryingTransactionHelper().doInTransaction(work);
} }
@Test @Test
public void testGetDomain() throws Exception public void testGetDomain() throws Exception
{ {
RetryingTransactionHelper.RetryingTransactionCallback<Void> work = new RetryingTransactionHelper.RetryingTransactionCallback<Void>()
{
@Override
public Void execute() throws Throwable
{
createUser(USER1, TenantService.DEFAULT_DOMAIN, PASS); createUser(USER1, TenantService.DEFAULT_DOMAIN, PASS);
String result = getDomainWork(STRING, TenantService.DEFAULT_DOMAIN, USER1, false); String result = getDomainWork(STRING, TenantService.DEFAULT_DOMAIN, USER1, false);
assertEquals("The domain should be reported as default.", TenantService.DEFAULT_DOMAIN, result); assertEquals("The domain should be reported as default.", TenantService.DEFAULT_DOMAIN, result);
@@ -584,24 +694,43 @@ public class MultiTServiceImplTest
{ {
// Expected // Expected
} }
return null;
}
};
transactionService.getRetryingTransactionHelper().doInTransaction(work);
} }
@Test @Test
public void testGetTenant() public void testGetTenant()
{ {
Tenant tenant = tenantService.getTenant(DOMAIN); RetryingTransactionHelper.RetryingTransactionCallback<Void> work = new RetryingTransactionHelper.RetryingTransactionCallback<Void>()
assertNull("The tenant should not exist.", tenant); {
@Override
createTenant(DOMAIN); public Void execute() throws Throwable
tenant = tenantService.getTenant(DOMAIN); {
assertNotNull("The tenant should exist.", tenant); Tenant tenant = tenantService.getTenant(DOMAIN);
assertTrue("The tenant should have the correct domain.", DOMAIN.equals(tenant.getTenantDomain())); assertNull("The tenant should not exist.", tenant);
assertTrue("The tenant should be enabled.", tenant.isEnabled());
createTenant(DOMAIN);
tenant = tenantService.getTenant(DOMAIN);
assertNotNull("The tenant should exist.", tenant);
assertTrue("The tenant should have the correct domain.", DOMAIN.equals(tenant.getTenantDomain()));
assertTrue("The tenant should be enabled.", tenant.isEnabled());
return null;
}
};
transactionService.getRetryingTransactionHelper().doInTransaction(work);
} }
@Test @Test
public void testGetUserDomain() public void testGetUserDomain()
{ {
RetryingTransactionHelper.RetryingTransactionCallback<Void> work = new RetryingTransactionHelper.RetryingTransactionCallback<Void>()
{
@Override
public Void execute() throws Throwable
{
String result = tenantService.getUserDomain(USER1); String result = tenantService.getUserDomain(USER1);
assertEquals("The user domain should be the default one for a non tenant user without a tenant in name.", TenantService.DEFAULT_DOMAIN, result); assertEquals("The user domain should be the default one for a non tenant user without a tenant in name.", TenantService.DEFAULT_DOMAIN, result);
@@ -614,6 +743,10 @@ public class MultiTServiceImplTest
result = tenantService.getUserDomain(USER1); result = tenantService.getUserDomain(USER1);
assertTrue("The user domain should be the default one (empty string) for a non tenant user without a tenant in name.", result.equals(TenantService.DEFAULT_DOMAIN)); assertTrue("The user domain should be the default one (empty string) for a non tenant user without a tenant in name.", result.equals(TenantService.DEFAULT_DOMAIN));
return null;
}
};
transactionService.getRetryingTransactionHelper().doInTransaction(work);
} }
/** /**
@@ -736,7 +869,38 @@ public class MultiTServiceImplTest
return personNodeRef; return personNodeRef;
} }
private void deleteTenant(final String tenantDomain)
{
AuthenticationUtil.runAs(new RunAsWork<Object>()
{
public Object doWork() throws Exception
{
RetryingTransactionHelper.RetryingTransactionCallback<Void> work = new RetryingTransactionHelper.RetryingTransactionCallback<Void>()
{
public Void execute() throws Throwable
{
// delete tenant (if it exists)
if (tenantAdminService.existsTenant(tenantDomain))
{
// TODO: WARNING: HACK for ALF-19155: MT deleteTenant does not work
// PersonService prevents 'guest' authorities from being deleted
{
BehaviourFilter behaviourFilter = (BehaviourFilter) ctx.getBean("policyBehaviourFilter");
behaviourFilter.disableBehaviour(ContentModel.TYPE_PERSON);
behaviourFilter.disableBehaviour(ContentModel.ASPECT_UNDELETABLE);
}
tenantAdminService.deleteTenant(tenantDomain);
}
return null;
}
};
transactionService.getRetryingTransactionHelper().doInTransaction(work);
return null;
}
}, AuthenticationUtil.getSystemUserName());
}
/** /**
* Utility method to add a domain to an string id * Utility method to add a domain to an string id
* @param id String * @param id String

View File

@@ -166,11 +166,14 @@ public class RepoUsageComponentTest extends TestCase
public void test4FullUse() throws Exception public void test4FullUse() throws Exception
{ {
// Set the restrictions // Update usage
updateUsage(UsageType.USAGE_ALL);
// Set the restrictions
RepoUsage restrictions = new RepoUsage( RepoUsage restrictions = new RepoUsage(
System.currentTimeMillis(), System.currentTimeMillis(),
7L, getUsage().getUsers(),
600L, 10000L,
LicenseMode.TEAM, LicenseMode.TEAM,
System.currentTimeMillis() + 24*3600000, System.currentTimeMillis() + 24*3600000,
false); false);
@@ -178,12 +181,13 @@ public class RepoUsageComponentTest extends TestCase
// Get the restrictions (should not need a txn for this) // Get the restrictions (should not need a txn for this)
RepoUsage restrictionsCheck = repoUsageComponent.getRestrictions(); RepoUsage restrictionsCheck = repoUsageComponent.getRestrictions();
assertEquals("Restrictions should return without change.", restrictions, restrictionsCheck); assertEquals("Restrictions should return without change.", restrictions, restrictionsCheck);
// Update use // Update use
updateUsage(UsageType.USAGE_ALL); updateUsage(UsageType.USAGE_ALL);
// Get the usage // Get the usage
RepoUsage usage = getUsage(); RepoUsage usage = getUsage();
// Check // Check
assertNotNull("Usage is null", usage); assertNotNull("Usage is null", usage);
assertNotNull("Invalid user count", usage.getUsers()); assertNotNull("Invalid user count", usage.getUsers());