Java Code Examples for org.alfresco.repo.site.SiteModel#SITE_COLLABORATOR
The following examples show how to use
org.alfresco.repo.site.SiteModel#SITE_COLLABORATOR .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ActivitiInvitationServiceImplTests.java From alfresco-repository with GNU Lesser General Public License v3.0 | 6 votes |
/** * Nominated invites workflows finish without waiting for user accept */ @Test public void testWorkflowTaskContainsProps() { Invitation.ResourceType resourceType = Invitation.ResourceType.WEB_SITE; String resourceName = SITE_SHORT_NAME_INVITE; String inviteeRole = SiteModel.SITE_COLLABORATOR; String serverPath = "wibble"; String acceptUrl = "froob"; String rejectUrl = "marshmallow"; NominatedInvitation nomInvite = invitationService.inviteNominated(USER_ONE, resourceType, resourceName, inviteeRole, serverPath, acceptUrl, rejectUrl); List<WorkflowPath> paths = workflowService.getWorkflowPaths(nomInvite.getInviteId()); assertEquals(0, paths.size()); }
Example 2
Source File: AbstractInvitationServiceImplTest.java From alfresco-repository with GNU Lesser General Public License v3.0 | 5 votes |
/** * MNT-9101 An internal user account (disabled) should not be deleted if an * associated nominated invitation is cancelled. * * @throws Exception */ public void testInternalUserNotDeletedAfterInviteCancelled() throws Exception { // Disable our existing User boolean enabled = authenticationService.getAuthenticationEnabled(USER_ONE); assertTrue("User One authentication disabled", enabled); authenticationService.setAuthenticationEnabled(USER_ONE, false); enabled = authenticationService.getAuthenticationEnabled(USER_ONE); assertTrue("User One authentication enabled", !enabled); String inviteeUserName = USER_ONE; Invitation.ResourceType resourceType = Invitation.ResourceType.WEB_SITE; String resourceName = SITE_SHORT_NAME_INVITE; String inviteeRole = SiteModel.SITE_COLLABORATOR; String acceptUrl = "froob"; String rejectUrl = "marshmallow"; this.authenticationComponent.setCurrentUser(USER_MANAGER); // Invite our existing user try { invitationService.inviteNominated(inviteeUserName, resourceType, resourceName, inviteeRole, acceptUrl, rejectUrl); fail("An exception of type " + InvitationExceptionUserError.class.getName() + " should be thrown"); } catch (Exception ex) { assertTrue("Incorrect exception was thrown", ex instanceof InvitationExceptionUserError); } // Our User and associated Authentication still exists assertNotNull("User Exists", personService.getPersonOrNull(USER_ONE)); assertTrue("Authentication Exists", authenticationService.authenticationExists(USER_ONE)); }
Example 3
Source File: AbstractInvitationServiceImplTest.java From alfresco-repository with GNU Lesser General Public License v3.0 | 5 votes |
/** * Ensure that an External user account is deleted when an invite is * cancelled * * @throws Exception */ public void testExternalUserDeletedAfterInviteCancelled() throws Exception { String inviteeFirstName = PERSON_FIRSTNAME; String inviteeLastName = PERSON_LASTNAME; String inviteeEmail = "[email protected]"; Invitation.ResourceType resourceType = Invitation.ResourceType.WEB_SITE; String resourceName = SITE_SHORT_NAME_INVITE; String inviteeRole = SiteModel.SITE_COLLABORATOR; String serverPath = "wibble"; String acceptUrl = "froob"; String rejectUrl = "marshmallow"; this.authenticationComponent.setCurrentUser(USER_MANAGER); NominatedInvitation nominatedInvitation = invitationService.inviteNominated( inviteeFirstName, inviteeLastName, inviteeEmail, resourceType, resourceName, inviteeRole, serverPath, acceptUrl, rejectUrl); String inviteeUsername = nominatedInvitation.getInviteeUserName(); invitationService.cancel(nominatedInvitation.getInviteId()); // Our User and Authentication has been removed assertNull("Person deleted", personService.getPersonOrNull(inviteeUsername)); assertFalse("Authentication deleted", authenticationService.authenticationExists(inviteeUsername)); }
Example 4
Source File: AbstractInvitationServiceImplTest.java From alfresco-repository with GNU Lesser General Public License v3.0 | 5 votes |
/** * MNT-15614 Site with name "IT" cannot be managed properly * * @throws Exception */ public void test_MNT15614() throws Exception { String[] siteNames = {"it", "site", "GROUP"}; String inviteeUserName = USER_ONE; Invitation.ResourceType resourceType = Invitation.ResourceType.WEB_SITE; String inviteeRole = SiteModel.SITE_COLLABORATOR; String acceptUrl = "froob"; String rejectUrl = "marshmallow"; this.authenticationComponent.setCurrentUser(AuthenticationUtil.getAdminUserName()); for (String siteName : siteNames) { SiteInfo siteInfoRed = siteService.getSite(siteName); if (siteInfoRed == null) { siteService.createSite("InviteSitePreset", siteName, "InviteSiteTitle", "InviteSiteDescription", SiteVisibility.MODERATED); } assertEquals( SiteModel.SITE_MANAGER, siteService.getMembersRole(siteName, AuthenticationUtil.getAdminUserName())); // Invite user NominatedInvitation nominatedInvitation = invitationService.inviteNominated( inviteeUserName, resourceType, siteName, inviteeRole, acceptUrl, rejectUrl); assertNotNull("nominated invitation is null", nominatedInvitation); } }
Example 5
Source File: AbstractInvitationServiceImplTest.java From alfresco-repository with GNU Lesser General Public License v3.0 | 5 votes |
/** * test that the search limiter works */ public void testSearchInvitationWithLimit() throws Exception { Invitation.ResourceType resourceType = Invitation.ResourceType.WEB_SITE; String resourceName = SITE_SHORT_NAME_INVITE; String inviteeRole = SiteModel.SITE_COLLABORATOR; String serverPath = "wibble"; String acceptUrl = "froob"; String rejectUrl = "marshmallow"; authenticationComponent.setCurrentUser(USER_MANAGER); // Create 10 invites for (int i = 0; i < 10; i++) { invitationService .inviteNominated(USER_ONE, resourceType, resourceName, inviteeRole, serverPath, acceptUrl, rejectUrl); } // Invite USER_TWO NominatedInvitation inviteForUserTwo = invitationService.inviteNominated(USER_TWO, resourceType, resourceName, inviteeRole, serverPath, acceptUrl, rejectUrl); InvitationSearchCriteriaImpl query = new InvitationSearchCriteriaImpl(); query.setInvitee(USER_TWO); // search all of them List<Invitation> results = invitationService.searchInvitation(query, 0); assertEquals(1, results.size()); assertEquals(inviteForUserTwo.getInviteId(), results.get(0).getInviteId()); query = new InvitationSearchCriteriaImpl(); query.setInvitee(USER_ONE); final int MAX_SEARCH = 3; // only search for the first MAX_SEARCH results = invitationService.searchInvitation(query, MAX_SEARCH); assertEquals(MAX_SEARCH, results.size()); }
Example 6
Source File: AbstractInvitationServiceImplTest.java From alfresco-repository with GNU Lesser General Public License v3.0 | 5 votes |
@Commit public void disabled_test100Invites() throws Exception { Invitation.ResourceType resourceType = Invitation.ResourceType.WEB_SITE; String resourceName = SITE_SHORT_NAME_INVITE; String inviteeRole = SiteModel.SITE_COLLABORATOR; String serverPath = "wibble"; String acceptUrl = "froob"; String rejectUrl = "marshmallow"; authenticationComponent.setCurrentUser(USER_MANAGER); // Create 1000 invites for (int i = 0; i < 1000; i++) { invitationService.inviteNominated(USER_ONE, resourceType, resourceName, inviteeRole, serverPath, acceptUrl, rejectUrl); } // Invite USER_TWO NominatedInvitation invite = invitationService.inviteNominated(USER_TWO, resourceType, resourceName, inviteeRole, serverPath, acceptUrl, rejectUrl); InvitationSearchCriteriaImpl query = new InvitationSearchCriteriaImpl(); query.setInvitee(USER_TWO); long start = System.currentTimeMillis(); List<Invitation> results = invitationService.searchInvitation(query); long end= System.currentTimeMillis(); System.out.println("Invitation Search took " + (end - start) + "ms."); assertEquals(1, results.size()); assertEquals(invite.getInviteId(), results.get(0).getInviteId()); }
Example 7
Source File: AbstractInvitationServiceImplTest.java From alfresco-repository with GNU Lesser General Public License v3.0 | 4 votes |
/** * Test nominated user - new user who rejects invitation * * @throws Exception */ public void testNominatedInvitationNewUserReject() throws Exception { Calendar calendar = Calendar.getInstance(); calendar.add(Calendar.SECOND, -1); Date startDate = calendar.getTime(); String inviteeFirstName = PERSON_FIRSTNAME; String inviteeLastName = PERSON_LASTNAME; String inviteeEmail = "[email protected]"; String inviteeUserName = null; Invitation.ResourceType resourceType = Invitation.ResourceType.WEB_SITE; String resourceName = SITE_SHORT_NAME_INVITE; String inviteeRole = SiteModel.SITE_COLLABORATOR; String serverPath = "wibble"; String acceptUrl = "froob"; String rejectUrl = "marshmallow"; this.authenticationComponent.setCurrentUser(USER_MANAGER); NominatedInvitation nominatedInvitation = invitationService.inviteNominated(inviteeFirstName, inviteeLastName, inviteeEmail, resourceType, resourceName, inviteeRole, serverPath, acceptUrl, rejectUrl); assertNotNull("nominated invitation is null", nominatedInvitation); assertEquals("first name wrong", inviteeFirstName, nominatedInvitation.getInviteeFirstName()); assertEquals("last name wrong", inviteeLastName, nominatedInvitation.getInviteeLastName()); assertEquals("email name wrong", inviteeEmail, nominatedInvitation.getInviteeEmail()); // Generated User Name should be returned inviteeUserName = nominatedInvitation.getInviteeUserName(); assertNotNull("generated user name is null", inviteeUserName); // sentInviteDate should be set to today { Date sentDate = nominatedInvitation.getSentInviteDate(); assertTrue("sentDate wrong - too earlyStart Date: " +startDate +"\nSent Date: "+sentDate, sentDate.after(startDate)); assertTrue("sentDate wrong - too lateStart Date: " +startDate +"\nSent Date: "+sentDate, sentDate.before(new Date(new Date().getTime() + 1))); } /** * Now reject the invitation */ NominatedInvitation rejectedInvitation = (NominatedInvitation) invitationService.reject(nominatedInvitation .getInviteId(), "dont want it"); assertEquals("invite id wrong", nominatedInvitation.getInviteId(), rejectedInvitation.getInviteId()); assertEquals("first name wrong", inviteeFirstName, rejectedInvitation.getInviteeFirstName()); assertEquals("last name wrong", inviteeLastName, rejectedInvitation.getInviteeLastName()); assertEquals("user name wrong", inviteeUserName, rejectedInvitation.getInviteeUserName()); List<Invitation> it4 = invitationService.listPendingInvitationsForResource(resourceType, resourceName); assertTrue("invitations is not empty", it4.isEmpty()); /** * Now verify access control list inviteeUserName should not exist */ String roleName = siteService.getMembersRole(resourceName, inviteeUserName); if (roleName != null) { fail("role has been set for a rejected user"); } /** * Now verify that the generated user has been removed */ if (personService.personExists(inviteeUserName)) { fail("generated user has not been cleaned up"); } }
Example 8
Source File: AbstractInvitationServiceImplTest.java From alfresco-repository with GNU Lesser General Public License v3.0 | 4 votes |
/** * Test nominated user - new user Creates two separate users with two the * same email address. * * @throws Exception */ public void testNominatedInvitationNewUserSameEmails() throws Exception { String inviteeAFirstName = "John"; String inviteeALastName = "Smith"; String inviteeBFirstName = "Jane"; String inviteeBLastName = "Smith"; String inviteeEmail = "[email protected]"; String inviteeAUserName = null; String inviteeBUserName = null; Invitation.ResourceType resourceType = Invitation.ResourceType.WEB_SITE; String resourceName = SITE_SHORT_NAME_INVITE; String inviteeRole = SiteModel.SITE_COLLABORATOR; String serverPath = "wibble"; String acceptUrl = "froob"; String rejectUrl = "marshmallow"; this.authenticationComponent.setCurrentUser(USER_MANAGER); NominatedInvitation nominatedInvitationA = invitationService.inviteNominated(inviteeAFirstName, inviteeALastName, inviteeEmail, resourceType, resourceName, inviteeRole, serverPath, acceptUrl, rejectUrl); assertNotNull("nominated invitation is null", nominatedInvitationA); String inviteAId = nominatedInvitationA.getInviteId(); assertEquals("first name wrong", inviteeAFirstName, nominatedInvitationA.getInviteeFirstName()); assertEquals("last name wrong", inviteeALastName, nominatedInvitationA.getInviteeLastName()); assertEquals("email name wrong", inviteeEmail, nominatedInvitationA.getInviteeEmail()); // Generated User Name should be returned inviteeAUserName = nominatedInvitationA.getInviteeUserName(); assertNotNull("generated user name is null", inviteeAUserName); NominatedInvitation nominatedInvitationB = invitationService.inviteNominated(inviteeBFirstName, inviteeBLastName, inviteeEmail, resourceType, resourceName, inviteeRole, serverPath, acceptUrl, rejectUrl); assertNotNull("nominated invitation is null", nominatedInvitationB); String inviteBId = nominatedInvitationB.getInviteId(); assertEquals("first name wrong", inviteeBFirstName, nominatedInvitationB.getInviteeFirstName()); assertEquals("last name wrong", inviteeBLastName, nominatedInvitationB.getInviteeLastName()); assertEquals("email name wrong", inviteeEmail, nominatedInvitationB.getInviteeEmail()); // Generated User Name should be returned inviteeBUserName = nominatedInvitationB.getInviteeUserName(); assertNotNull("generated user name is null", inviteeBUserName); assertFalse("generated user names are the same", inviteeAUserName.equals(inviteeBUserName)); /** * Now accept the invitation */ AuthenticationUtil.setFullyAuthenticatedUser(nominatedInvitationA.getInviteeUserName()); NominatedInvitation acceptedInvitationA = (NominatedInvitation) invitationService.accept(inviteAId, nominatedInvitationA.getTicket()); assertEquals("invite id wrong", inviteAId, acceptedInvitationA.getInviteId()); assertEquals("first name wrong", inviteeAFirstName, acceptedInvitationA.getInviteeFirstName()); assertEquals("last name wrong", inviteeALastName, acceptedInvitationA.getInviteeLastName()); assertEquals("user name wrong", inviteeAUserName, acceptedInvitationA.getInviteeUserName()); AuthenticationUtil.setFullyAuthenticatedUser(nominatedInvitationB.getInviteeUserName()); NominatedInvitation acceptedInvitationB = (NominatedInvitation) invitationService.accept(inviteBId, nominatedInvitationB.getTicket()); assertEquals("invite id wrong", inviteBId, acceptedInvitationB.getInviteId()); assertEquals("first name wrong", inviteeBFirstName, acceptedInvitationB.getInviteeFirstName()); assertEquals("last name wrong", inviteeBLastName, acceptedInvitationB.getInviteeLastName()); assertEquals("user name wrong", inviteeBUserName, acceptedInvitationB.getInviteeUserName()); /** * Now verify access control list */ AuthenticationUtil.setFullyAuthenticatedUser(USER_MANAGER); String roleNameA = siteService.getMembersRole(resourceName, inviteeAUserName); assertEquals("role name wrong", roleNameA, inviteeRole); String roleNameB = siteService.getMembersRole(resourceName, inviteeBUserName); assertEquals("role name wrong", roleNameB, inviteeRole); siteService.removeMembership(resourceName, inviteeAUserName); siteService.removeMembership(resourceName, inviteeBUserName); }
Example 9
Source File: AbstractInvitationServiceImplTest.java From alfresco-repository with GNU Lesser General Public License v3.0 | 4 votes |
public void testMNT11775() throws Exception { String inviteeUserName = USER_TWO; Invitation.ResourceType resourceType = Invitation.ResourceType.WEB_SITE; String resourceName = SITE_SHORT_NAME_INVITE; String inviteeRole = SiteModel.SITE_COLLABORATOR; String comments = "please sir, let me in!"; /** * New invitation from User TWO */ this.authenticationComponent.setCurrentUser(USER_TWO); ModeratedInvitation invitation = invitationService.inviteModerated(comments, inviteeUserName, resourceType, resourceName, inviteeRole); String invitationId = invitation.getInviteId(); /** * Reject the invitation */ this.authenticationComponent.setCurrentUser(USER_MANAGER); invitationService.reject(invitationId, "Go away!"); /** * Negative test attempt to approve an invitation that has been rejected */ try { invitationService.approve(invitationId, "Have I not rejected this?"); fail("rejected invitation not working"); } catch (Exception e) { // An exception should have been thrown e.printStackTrace(); System.out.println(e.toString()); } /** * process email message template */ try { // Build our model Map<String, Serializable> model = new HashMap<String, Serializable>(8, 1.0f); model.put("resourceName", resourceName); model.put("resourceType", resourceType); model.put("inviteeRole", inviteeRole); model.put("reviewComments", "Go away!"); model.put("inviteeUserName", inviteeUserName); // Process the template String emailMsg = templateService.processTemplate("freemarker", "/alfresco/bootstrap/invite/moderated-reject-email.ftl", model); assertNotNull("Email message is null", emailMsg); assertTrue("Email message doesn't contain review comment", emailMsg.contains("Go away!")); } catch (Exception ex) { ex.printStackTrace(); System.out.println(ex.toString()); fail("Process email message template exception"); } }
Example 10
Source File: AbstractInvitationServiceImplTest.java From alfresco-repository with GNU Lesser General Public License v3.0 | 4 votes |
/** * Test nominated user - new user with whitespace in name. Related to * ETHREEOH-3030. */ public void testNominatedInvitationNewUserWhitespace() throws Exception { String inviteeFirstName = PERSON_FIRSTNAME_SPACES; String inviteeLastName = PERSON_LASTNAME_SPACES; String resourceName = SITE_SHORT_NAME_INVITE; String inviteeEmail = "[email protected]"; Invitation.ResourceType resourceType = Invitation.ResourceType.WEB_SITE; String inviteeRole = SiteModel.SITE_COLLABORATOR; String serverPath = "wibble"; String acceptUrl = "froob"; String rejectUrl = "marshmallow"; String expectedUserName = (inviteeFirstName + "_" + inviteeLastName).toLowerCase(); expectedUserName = expectedUserName.replaceAll("\\s+", "_"); authenticationComponent.setCurrentUser(USER_MANAGER); NominatedInvitation nominatedInvitation = invitationService.inviteNominated(inviteeFirstName, inviteeLastName, inviteeEmail, resourceType, resourceName, inviteeRole, serverPath, acceptUrl, rejectUrl); assertNotNull("nominated invitation is null", nominatedInvitation); assertEquals("Wrong username!", expectedUserName, nominatedInvitation.getInviteeUserName()); String inviteId = nominatedInvitation.getInviteId(); // Now we have an invitation get it and check the details have been // returned correctly. NominatedInvitation invitation = (NominatedInvitation) invitationService.getInvitation(inviteId); assertNotNull("invitation is null", invitation); assertEquals("first name wrong", inviteeFirstName, invitation.getInviteeFirstName()); assertEquals("last name wrong", inviteeLastName, invitation.getInviteeLastName()); assertEquals("user name wrong", expectedUserName, invitation.getInviteeUserName()); // Now accept the invitation AuthenticationUtil.setFullyAuthenticatedUser(invitation.getInviteeUserName()); NominatedInvitation acceptedInvitation = (NominatedInvitation) invitationService.accept(invitation .getInviteId(), invitation.getTicket()); assertEquals("first name wrong", inviteeFirstName, acceptedInvitation.getInviteeFirstName()); assertEquals("last name wrong", inviteeLastName, acceptedInvitation.getInviteeLastName()); assertEquals("user name wrong", expectedUserName, acceptedInvitation.getInviteeUserName()); // Now verify access control list String roleName = siteService.getMembersRole(resourceName, expectedUserName); assertEquals("role name wrong", roleName, inviteeRole); siteService.removeMembership(resourceName, expectedUserName); }
Example 11
Source File: AbstractInvitationServiceImplTest.java From alfresco-repository with GNU Lesser General Public License v3.0 | 4 votes |
/** * Create a moderated invitation Get it Search for it Cancel it Create a * moderated invitation Reject the invitation Create a moderated invitation * Approve the invitation */ public void testModeratedInvitation() { String inviteeUserName = USER_TWO; Invitation.ResourceType resourceType = Invitation.ResourceType.WEB_SITE; String resourceName = SITE_SHORT_NAME_INVITE; String inviteeRole = SiteModel.SITE_COLLABORATOR; String comments = "please sir, let me in!"; this.authenticationComponent.setCurrentUser(USER_TWO); ModeratedInvitation invitation = invitationService.inviteModerated(comments, inviteeUserName, resourceType, resourceName, inviteeRole); assertNotNull("moderated invitation is null", invitation); String inviteId = invitation.getInviteId(); assertEquals("user name wrong", inviteeUserName, invitation.getInviteeUserName()); assertEquals("role name wrong", inviteeRole, invitation.getRoleName()); assertEquals("comments", comments, invitation.getInviteeComments()); assertEquals("resource type name wrong", resourceType, invitation.getResourceType()); assertEquals("resource name wrong", resourceName, invitation.getResourceName()); /** * Now we have an invitation get it and check the details have been * returned correctly. */ ModeratedInvitation mi2 = (ModeratedInvitation) invitationService.getInvitation(inviteId); assertEquals("invite id", inviteId, mi2.getInviteId()); assertEquals("user name wrong", inviteeUserName, mi2.getInviteeUserName()); assertEquals("role name wrong", inviteeRole, mi2.getRoleName()); assertEquals("comments", comments, mi2.getInviteeComments()); assertEquals("resource type name wrong", resourceType, mi2.getResourceType()); assertEquals("resource name wrong", resourceName, mi2.getResourceName()); /** * Search for the new invitation */ List<Invitation> invitations = invitationService.listPendingInvitationsForResource(resourceType, resourceName); assertTrue("invitations is empty", !invitations.isEmpty()); ModeratedInvitation firstInvite = (ModeratedInvitation) invitations.get(0); assertEquals("invite id wrong", inviteId, firstInvite.getInviteId()); /** * Cancel the invitation */ ModeratedInvitation canceledInvitation = (ModeratedInvitation) invitationService.cancel(inviteId); assertEquals("invite id wrong", inviteId, canceledInvitation.getInviteId()); assertEquals("comments wrong", comments, canceledInvitation.getInviteeComments()); /** * Should now be no invitation */ List<Invitation> inv2 = invitationService.listPendingInvitationsForResource(resourceType, resourceName); assertTrue("After cancel invitations is not empty", inv2.isEmpty()); /** * New invitation */ this.authenticationComponent.setCurrentUser(USER_TWO); ModeratedInvitation invite2 = invitationService.inviteModerated(comments, inviteeUserName, resourceType, resourceName, inviteeRole); String secondInvite = invite2.getInviteId(); this.authenticationComponent.setCurrentUser(USER_MANAGER); invitationService.reject(secondInvite, "This is a test reject"); /** * New invitation */ this.authenticationComponent.setCurrentUser(USER_TWO); ModeratedInvitation invite3 = invitationService.inviteModerated(comments, inviteeUserName, resourceType, resourceName, inviteeRole); String thirdInvite = invite3.getInviteId(); this.authenticationComponent.setCurrentUser(USER_MANAGER); invitationService.approve(thirdInvite, "Welcome in"); /** * Now verify access control list */ String roleName = siteService.getMembersRole(resourceName, inviteeUserName); assertEquals("role name wrong", inviteeRole, roleName); siteService.removeMembership(resourceName, inviteeUserName); }