mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
Merged V3.1 to HEAD
13077: Abstracted ContentStore MBean operations 13099: Merge V3.0 to V3.1 13096 Merged V2.2 to V3.0 13071: Fix ETWOTWO-1058: Hibernate exception while concurrently submitting from and updating same user sandbox. 13079: Fix ETWOTWO-1117: Misleading exceptions reported during AVM flatten and update 13102: [no comment] 13112: Merged V3.0 to V3.1 13111: Merged V2.2 to V3.0 13110: Fix 2.1 -> 2.2 upgrade on Postgres 13114: Build/test fix (Enterprise Remote API project does not yet have any Java files to generate Javadoc) 13117: DM Index Check - unit test improvements 13123: *RECORD ONLY* Removed svn:mergeinfo fluff 13124: Used newer, more efficient NodeService.addProperties method instead of many NodeService.setProperty calls 13125: Added M2Binding for 'child-association': propagateTimestamps' 13126: WCM unit tests - reduce build/test time to check (async) submits 13127: Minor test fix - to allow it to run locally (on Mac OS X) 13130: Support for 'maxRetries' of zero or less 13131: Merged V3.0 to V3.1 13025 *RECORD-ONLY*: Removed unnecessary svn:mergeinfo 13026: Merged V2.2 to V3.0 12964: Fixed ETWOTWO-968: Space rules are not run when saving from MS Word 12993 *RECORD-ONLY*: added openoffice bootstrap context to sample-extensions 13009 *RECORD-ONLY*: Avoid default OOo config from causing problems on zip/gz installs 13132: Updated svn:mergeinfo 13134: ETHREEOH-1202 - initial fix and unit tests ___________________________________________________________________ Modified: svn:mergeinfo Merged /alfresco/BRANCHES/V3.0:r13005,13025-13026,13030,13039,13042,13050,13053,13096,13098,13111 Merged /alfresco/BRANCHES/V2.2:r12964,12993,13009,13071,13079,13110 Merged /alfresco/BRANCHES/V3.1:r13077,13099,13102,13112,13114,13117,13123-13127,13130-13132,13134 git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@13564 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -325,6 +325,22 @@ public interface WebProjectService
|
||||
*/
|
||||
public String getWebUserRole(NodeRef wpNodeRef, String userName);
|
||||
|
||||
/**
|
||||
* Indicates whether current user is a web user of the web project or not
|
||||
*
|
||||
* @param store id web project store id
|
||||
* @return boolean <tt>true</tt> if the current user is a web user of the web project, <tt>false</tt> otherwise
|
||||
*/
|
||||
public boolean isWebUser(String wpStoreId);
|
||||
|
||||
/**
|
||||
* Indicates whether current user is a web user of the web project or not
|
||||
*
|
||||
* @param wpNodeRef web project node ref
|
||||
* @return boolean <tt>true</tt> if the current user is a web user of the web project, <tt>false</tt> otherwise
|
||||
*/
|
||||
public boolean isWebUser(NodeRef wpNodeRef);
|
||||
|
||||
/**
|
||||
* Indicates whether given user is a web user of the web project or not
|
||||
*
|
||||
|
@@ -642,7 +642,7 @@ public class WebProjectServiceImpl extends WCMUtil implements WebProjectService
|
||||
{
|
||||
public Object doWork() throws Exception
|
||||
{
|
||||
List<SandboxInfo> sbInfos = sandboxFactory.listSandboxes(wpStoreId, AuthenticationUtil.getSystemUserName());
|
||||
List<SandboxInfo> sbInfos = sandboxFactory.listAllSandboxes(wpStoreId);
|
||||
|
||||
for (SandboxInfo sbInfo : sbInfos)
|
||||
{
|
||||
@@ -699,24 +699,43 @@ public class WebProjectServiceImpl extends WCMUtil implements WebProjectService
|
||||
return WCMUtil.ROLE_CONTENT_MANAGER.equals(userRole);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.alfresco.wcm.webproject.WebProjectService#isWebUser(java.lang.String)
|
||||
*/
|
||||
public boolean isWebUser(String wpStoreId)
|
||||
{
|
||||
return isWebUser(getWebProjectNodeFromStore(wpStoreId));
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.alfresco.wcm.webproject.WebProjectService#isWebUser(org.alfresco.service.cmr.repository.NodeRef)
|
||||
*/
|
||||
public boolean isWebUser(NodeRef wpNodeRef)
|
||||
{
|
||||
// note: admin is an implied web user (content manager) although will not appear in listWebUsers unless explicitly invited
|
||||
return (permissionService.hasPermission(wpNodeRef, PermissionService.READ) == AccessStatus.ALLOWED);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.alfresco.wcm.webproject.WebProjectService#isWebUser(java.lang.String, java.lang.String)
|
||||
*/
|
||||
public boolean isWebUser(String wpStoreId, String username)
|
||||
{
|
||||
ParameterCheck.mandatoryString("username", username);
|
||||
|
||||
return isWebUser(getWebProjectNodeFromStore(wpStoreId), username);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.alfresco.wcm.webproject.WebProjectService#isWebUser(org.alfresco.service.cmr.repository.NodeRef, java.lang.String)
|
||||
*/
|
||||
public boolean isWebUser(NodeRef wpNodeRef, String userName)
|
||||
public boolean isWebUser(final NodeRef wpNodeRef, String userName)
|
||||
{
|
||||
ParameterCheck.mandatoryString("userName", userName);
|
||||
|
||||
return (getWebUserRoleImpl(wpNodeRef, userName) != null);
|
||||
return AuthenticationUtil.runAs(new RunAsWork<Boolean>()
|
||||
{
|
||||
public Boolean doWork() throws Exception
|
||||
{
|
||||
return isWebUser(wpNodeRef);
|
||||
}
|
||||
}, userName);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
|
@@ -853,7 +853,7 @@ public class WebProjectServiceImplTest extends AbstractWCMServiceImplTest
|
||||
}
|
||||
|
||||
/**
|
||||
* Test inviteWebUser - and listWebProjects / listWebUsers
|
||||
* Test inviteWebUser - and listWebProjects / listWebUsers / isWebUser
|
||||
*/
|
||||
public void testInviteAndListWebUsers()
|
||||
{
|
||||
@@ -871,6 +871,9 @@ public class WebProjectServiceImplTest extends AbstractWCMServiceImplTest
|
||||
WebProjectInfo wpInfo = wpService.createWebProject(TEST_WEBPROJ_DNS+"-inviteWebUser1", TEST_WEBPROJ_NAME+"-inviteWebUser1", TEST_TITLE, TEST_DESCRIPTION);
|
||||
NodeRef wpNodeRef = wpInfo.getNodeRef();
|
||||
|
||||
assertTrue(wpService.isWebUser(wpNodeRef, USER_ADMIN));
|
||||
assertFalse(wpService.isWebUser(wpNodeRef, USER_ONE));
|
||||
|
||||
assertEquals(1, wpService.listWebUsers(wpNodeRef).size());
|
||||
assertEquals(WCMUtil.ROLE_CONTENT_MANAGER, wpService.listWebUsers(wpNodeRef).get(USER_ADMIN));
|
||||
|
||||
@@ -883,6 +886,9 @@ public class WebProjectServiceImplTest extends AbstractWCMServiceImplTest
|
||||
assertEquals(3, wpService.listWebUsers(wpNodeRef).size());
|
||||
assertEquals(WCMUtil.ROLE_CONTENT_PUBLISHER, wpService.listWebUsers(wpNodeRef).get(USER_ONE));
|
||||
assertEquals(WCMUtil.ROLE_CONTENT_MANAGER, wpService.listWebUsers(wpNodeRef).get(USER_TWO));
|
||||
|
||||
assertTrue(wpService.isWebUser(wpInfo.getStoreId(), USER_ONE));
|
||||
assertTrue(wpService.isWebUser(wpNodeRef, USER_TWO));
|
||||
|
||||
// Create another web project
|
||||
wpInfo = wpService.createWebProject(TEST_WEBPROJ_DNS+"-inviteWebUser2", TEST_WEBPROJ_NAME+"-inviteWebUser2", TEST_TITLE, TEST_DESCRIPTION);
|
||||
@@ -891,6 +897,9 @@ public class WebProjectServiceImplTest extends AbstractWCMServiceImplTest
|
||||
assertEquals(1, wpService.listWebUsers(wpNodeRef2).size());
|
||||
assertEquals(WCMUtil.ROLE_CONTENT_MANAGER, wpService.listWebUsers(wpNodeRef2).get(USER_ADMIN));
|
||||
|
||||
assertFalse(wpService.isWebUser(wpInfo.getStoreId(), USER_ONE));
|
||||
assertFalse(wpService.isWebUser(wpNodeRef2, USER_TWO));
|
||||
|
||||
wpService.inviteWebUser(wpNodeRef2, USER_TWO, WCMUtil.ROLE_CONTENT_PUBLISHER, false);
|
||||
wpService.inviteWebUser(wpNodeRef2, USER_ONE, WCMUtil.ROLE_CONTENT_MANAGER, false);
|
||||
|
||||
@@ -898,6 +907,9 @@ public class WebProjectServiceImplTest extends AbstractWCMServiceImplTest
|
||||
assertEquals(WCMUtil.ROLE_CONTENT_PUBLISHER, wpService.listWebUsers(wpNodeRef2).get(USER_TWO));
|
||||
assertEquals(WCMUtil.ROLE_CONTENT_MANAGER, wpService.listWebUsers(wpNodeRef2).get(USER_ONE));
|
||||
|
||||
assertTrue(wpService.isWebUser(wpInfo.getStoreId(), USER_ONE));
|
||||
assertTrue(wpService.isWebUser(wpNodeRef2, USER_TWO));
|
||||
|
||||
// Switch to USER_ONE
|
||||
AuthenticationUtil.setFullyAuthenticatedUser(USER_ONE);
|
||||
|
||||
@@ -939,9 +951,13 @@ public class WebProjectServiceImplTest extends AbstractWCMServiceImplTest
|
||||
// Switch to USER_ONE
|
||||
AuthenticationUtil.setFullyAuthenticatedUser(USER_ONE);
|
||||
|
||||
assertFalse(wpService.isWebUser(wpNodeRef2, USER_THREE));
|
||||
|
||||
// Invite web user
|
||||
wpService.inviteWebUser(wpNodeRef2, USER_THREE, WCMUtil.ROLE_CONTENT_REVIEWER, false);
|
||||
|
||||
assertTrue(wpService.isWebUser(wpNodeRef2, USER_THREE));
|
||||
|
||||
// Switch back to admin
|
||||
AuthenticationUtil.setFullyAuthenticatedUser(USER_ADMIN);
|
||||
|
||||
@@ -950,16 +966,16 @@ public class WebProjectServiceImplTest extends AbstractWCMServiceImplTest
|
||||
}
|
||||
|
||||
/**
|
||||
* Test uninviteWebUser - and listWebProjects / listWebUsers
|
||||
* Test uninviteWebUser - and listWebProjects / listWebUsers / isWebUser
|
||||
*/
|
||||
public void testUninviteAndListWebUsers()
|
||||
{
|
||||
// Switch to USER_FOUR
|
||||
AuthenticationUtil.setFullyAuthenticatedUser(USER_FOUR);
|
||||
|
||||
|
||||
List<WebProjectInfo> webProjects = wpService.listWebProjects();
|
||||
assertNotNull(webProjects);
|
||||
assertEquals(0, webProjects.size());
|
||||
int userFourWebProjectCount = webProjects.size();
|
||||
|
||||
// Switch back to admin
|
||||
AuthenticationUtil.setFullyAuthenticatedUser(USER_ADMIN);
|
||||
@@ -971,21 +987,27 @@ public class WebProjectServiceImplTest extends AbstractWCMServiceImplTest
|
||||
assertEquals(1, wpService.listWebUsers(wpNodeRef).size());
|
||||
assertEquals(WCMUtil.ROLE_CONTENT_MANAGER, wpService.listWebUsers(wpNodeRef).get(USER_ADMIN));
|
||||
|
||||
assertTrue(wpService.isWebUser(wpNodeRef, USER_ADMIN));
|
||||
assertFalse(wpService.isWebUser(wpNodeRef, USER_FOUR));
|
||||
assertFalse(wpService.isWebUser(wpNodeRef, USER_ONE));
|
||||
|
||||
wpService.inviteWebUser(wpNodeRef, USER_FOUR, WCMUtil.ROLE_CONTENT_CONTRIBUTOR, false);
|
||||
|
||||
assertEquals(2, wpService.listWebUsers(wpNodeRef).size());
|
||||
assertEquals(WCMUtil.ROLE_CONTENT_CONTRIBUTOR, wpService.listWebUsers(wpNodeRef).get(USER_FOUR));
|
||||
assertTrue(wpService.isWebUser(wpNodeRef, USER_FOUR));
|
||||
|
||||
wpService.inviteWebUser(wpNodeRef, USER_ONE, WCMUtil.ROLE_CONTENT_MANAGER, false);
|
||||
|
||||
assertEquals(3, wpService.listWebUsers(wpNodeRef).size());
|
||||
assertEquals(WCMUtil.ROLE_CONTENT_MANAGER, wpService.listWebUsers(wpNodeRef).get(USER_ONE));
|
||||
assertTrue(wpService.isWebUser(wpNodeRef, USER_ONE));
|
||||
|
||||
// Switch to USER_FOUR
|
||||
AuthenticationUtil.setFullyAuthenticatedUser(USER_FOUR);
|
||||
|
||||
webProjects = wpService.listWebProjects();
|
||||
assertEquals(1, webProjects.size());
|
||||
assertEquals(userFourWebProjectCount+1, webProjects.size());
|
||||
|
||||
// Switch to USER_TWO
|
||||
AuthenticationUtil.setFullyAuthenticatedUser(USER_TWO);
|
||||
@@ -1023,12 +1045,13 @@ public class WebProjectServiceImplTest extends AbstractWCMServiceImplTest
|
||||
|
||||
assertEquals(2, wpService.listWebUsers(wpNodeRef).size());
|
||||
assertEquals(null, wpService.listWebUsers(wpNodeRef).get(USER_FOUR));
|
||||
assertFalse(wpService.isWebUser(wpNodeRef, USER_FOUR));
|
||||
|
||||
// Switch to USER_FOUR
|
||||
AuthenticationUtil.setFullyAuthenticatedUser(USER_FOUR);
|
||||
|
||||
webProjects = wpService.listWebProjects();
|
||||
assertEquals(0, webProjects.size());
|
||||
assertEquals(userFourWebProjectCount, webProjects.size());
|
||||
|
||||
// Switch back to admin
|
||||
AuthenticationUtil.setFullyAuthenticatedUser(USER_ADMIN);
|
||||
@@ -1036,9 +1059,12 @@ public class WebProjectServiceImplTest extends AbstractWCMServiceImplTest
|
||||
// Content manager can uninvite themself
|
||||
// Uninvite web user - test using wpNodeRef
|
||||
wpService.uninviteWebUser(wpNodeRef, USER_ADMIN, false);
|
||||
|
||||
|
||||
// Note: All admin authorities are implicitly a web user and content manager (across all web projects) even if not explicitly invited
|
||||
assertEquals(1, wpService.listWebUsers(wpNodeRef).size());
|
||||
assertEquals(null, wpService.listWebUsers(wpNodeRef).get(USER_ADMIN));
|
||||
assertEquals(null, wpService.listWebUsers(wpNodeRef).get(USER_ADMIN));
|
||||
assertTrue(wpService.isWebUser(wpNodeRef, USER_ADMIN));
|
||||
assertTrue(wpService.isContentManager(wpNodeRef, USER_ADMIN));
|
||||
|
||||
// Switch to USER_ONE
|
||||
AuthenticationUtil.setFullyAuthenticatedUser(USER_ONE);
|
||||
@@ -1048,6 +1074,7 @@ public class WebProjectServiceImplTest extends AbstractWCMServiceImplTest
|
||||
|
||||
// Delete user (in this case, last invited content manager)
|
||||
wpService.uninviteWebUser(wpNodeRef, USER_ONE, false);
|
||||
assertFalse(wpService.isWebUser(wpNodeRef, USER_ONE));
|
||||
|
||||
try
|
||||
{
|
||||
@@ -1063,10 +1090,10 @@ public class WebProjectServiceImplTest extends AbstractWCMServiceImplTest
|
||||
// Switch back to admin
|
||||
AuthenticationUtil.setFullyAuthenticatedUser(USER_ADMIN);
|
||||
|
||||
// Note: All admin authorities are implicitly content managers (across all web projects) even if not explicitly invited
|
||||
assertTrue(wpService.isContentManager(wpInfo.getStoreId(), USER_ADMIN));
|
||||
|
||||
// Note: All admin authorities are implicitly a web user and content manager (across all web projects) even if not explicitly invited
|
||||
assertEquals(0, wpService.listWebUsers(wpNodeRef).size());
|
||||
assertTrue(wpService.isWebUser(wpNodeRef, USER_ADMIN));
|
||||
assertTrue(wpService.isContentManager(wpInfo.getStoreId(), USER_ADMIN));
|
||||
|
||||
// delete web project
|
||||
wpService.deleteWebProject(wpNodeRef);
|
||||
|
Reference in New Issue
Block a user