org.alfresco.repo.site.SiteModel Java Examples
The following examples show how to use
org.alfresco.repo.site.SiteModel.
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: SiteRoutingFileContentStore.java From alfresco-simple-content-stores with Apache License 2.0 | 6 votes |
/** * This internal method only exists to avoid the circular dependency we would create when requiring the {@link SiteService} as a * dependency for {@link SiteService#getSite(NodeRef) resolving the site of a node}. * * @param node * the node for which to resolve the site * @return the node reference for the site, or {@code null} if the node is not contained in a site via a graph of primary parent * associations */ protected NodeRef resolveSiteForNode(final NodeRef node) { NodeRef site = null; NodeRef curParent = node; while (curParent != null) { final QName curParentType = this.nodeService.getType(curParent); if (this.dictionaryService.isSubClass(curParentType, SiteModel.TYPE_SITE)) { site = curParent; break; } curParent = this.nodeService.getPrimaryParent(curParent).getParentRef(); } return site; }
Example #2
Source File: ImapServiceImpl.java From alfresco-repository with GNU Lesser General Public License v3.0 | 6 votes |
@Override public String getPathFromSites(final NodeRef ref) { return doAsSystem(new RunAsWork<String>() { @Override public String doWork() throws Exception { String name = ((String) nodeService.getProperty(ref, ContentModel.PROP_NAME)).toLowerCase(); if (nodeService.getType(ref).equals(SiteModel.TYPE_SITE)) { return name; } else { NodeRef parent = nodeService.getPrimaryParent(ref).getParentRef(); return getPathFromSites(parent) + "/" + name; } } }); }
Example #3
Source File: SurfConfigFolderPatch.java From alfresco-repository with GNU Lesser General Public License v3.0 | 6 votes |
@Override public synchronized int getTotalEstimatedWorkSize() { if (maxId == Long.MAX_VALUE) { maxId = patchDAO.getMaxAdmNodeID(); if (logger.isDebugEnabled()) { logger.debug("\tQ: Max node id: " + maxId); } } if (workCount == Long.MAX_VALUE) { // get the sites count workCount = patchDAO.getCountNodesWithTypId(SiteModel.TYPE_SITE); // Each site has 12 children (we care only about surf-config // itself and its children) workCount *= 12; if (logger.isDebugEnabled()) { logger.debug("\tQ: Work count: " + workCount); } } return (int) workCount; }
Example #4
Source File: InvitationServiceImpl.java From alfresco-repository with GNU Lesser General Public License v3.0 | 6 votes |
/** * Checks that all necessary properties and services have been provided. */ public void init() { PropertyCheck.mandatory(this, "nodeService", nodeService); PropertyCheck.mandatory(this, "WorkflowService", workflowService); PropertyCheck.mandatory(this, "ActionService", actionService); PropertyCheck.mandatory(this, "PersonService", personService); PropertyCheck.mandatory(this, "SiteService", siteService); PropertyCheck.mandatory(this, "AuthenticationService", authenticationService); PropertyCheck.mandatory(this, "PermissionService", permissionService); PropertyCheck.mandatory(this, "NamespaceService", namespaceService); PropertyCheck.mandatory(this, "NodeService", nodeService); PropertyCheck.mandatory(this, "UserNameGenerator", usernameGenerator); PropertyCheck.mandatory(this, "PasswordGenerator", passwordGenerator); PropertyCheck.mandatory(this, "PolicyComponent", policyComponent); PropertyCheck.mandatory(this, "templateService", templateService); this.inviteNominatedSender = new InviteNominatedSender(serviceRegistry, repositoryHelper, messageService); this.inviteModeratedSender = new InviteModeratedSender(serviceRegistry, repositoryHelper, messageService); // this.policyComponent.bindClassBehaviour(QName.createQName(NamespaceService.ALFRESCO_URI, "beforeDeleteNode"), SiteModel.TYPE_SITE, new JavaBehaviour(this, "beforeDeleteNode")); this.policyComponent.bindClassBehaviour(BeforeDeleteNodePolicy.QNAME, ContentModel.TYPE_PERSON, new JavaBehaviour(this, "beforeDeleteNode")); }
Example #5
Source File: SiteRoutingContentStore.java From alfresco-simple-content-stores with Apache License 2.0 | 6 votes |
/** * This internal method only exists to avoid the circular dependency we would create when requiring the {@link SiteService} as a * dependency for {@link SiteService#getSite(NodeRef) resolving the site of a node}. * * @param node * the node for which to resolve the site * @return the node reference for the site, or {@code null} if the node is not contained in a site via a graph of primary parent * associations */ protected NodeRef resolveSiteForNode(final NodeRef node) { NodeRef site = null; NodeRef curParent = node; while (curParent != null) { final QName curParentType = this.nodeService.getType(curParent); if (this.dictionaryService.isSubClass(curParentType, SiteModel.TYPE_SITE)) { site = curParent; break; } curParent = this.nodeService.getPrimaryParent(curParent).getParentRef(); } return site; }
Example #6
Source File: InvitationServiceImpl.java From alfresco-repository with GNU Lesser General Public License v3.0 | 6 votes |
@Override public void cancelInvitation(String siteName, String invitee, String inviteId, String currentInviteId) { if (!AuthenticationUtil.isRunAsUserTheSystemUser()) { String currentUserName = authenticationService.getCurrentUserName(); String currentUserSiteRole = siteService.getMembersRole(siteName, currentUserName); if (SiteModel.SITE_MANAGER.equals(currentUserSiteRole)== false) { // The current user is not the site manager Object[] args = {currentUserName, inviteId, siteName}; throw new InvitationExceptionForbidden(MSG_NOT_SITE_MANAGER, args); } } // Clean up invitee's user account and person node if they are not in use i.e. // account is still disabled and there are no pending invites outstanding for the // invitee deleteAuthenticationIfUnused(invitee, currentInviteId); }
Example #7
Source File: AbstractSiteActivityTest.java From alfresco-repository with GNU Lesser General Public License v3.0 | 6 votes |
protected void addAndUpdateMemberships(String siteId, boolean includeUser4) throws Exception { // add member -> join site addMembership(siteId, user1, SiteModel.SITE_CONSUMER); addMembership(siteId, user2, SiteModel.SITE_MANAGER); addMembership(siteId, user3, SiteModel.SITE_COLLABORATOR); if (includeUser4) { addMembership(siteId, user4, SiteModel.SITE_CONSUMER); } // update member -> change role updateMembership(siteId, user1, SiteModel.SITE_MANAGER); updateMembership(siteId, user2, SiteModel.SITE_COLLABORATOR); updateMembership(siteId, user3, SiteModel.SITE_CONSUMER); if (includeUser4) { updateMembership(siteId, user4, SiteModel.SITE_COLLABORATOR); } }
Example #8
Source File: ImapServiceImplTest.java From alfresco-repository with GNU Lesser General Public License v3.0 | 6 votes |
public void testExcludeFoldersByComponentIt() { NodeRef imapFolderA = imapService.getOrCreateMailbox(user, MAILBOX_NAME_A, false, true).getFolderInfo().getNodeRef(); NodeRef imapFolderB = imapService.getOrCreateMailbox(user, MAILBOX_NAME_B, false, true).getFolderInfo().getNodeRef(); NodeRef imapFolderC = imapService.getOrCreateMailbox(user, "mailboxCalendarFolder", false, true).getFolderInfo().getNodeRef(); NodeRef imapFolderD = imapService.getOrCreateMailbox(user, "mailboxDataListsFolder", false, true).getFolderInfo().getNodeRef(); NodeRef imapFolderE = imapService.getOrCreateMailbox(user, "mailboxDocumentLibraryFolder", false, true).getFolderInfo().getNodeRef(); List<AlfrescoImapFolder> mf = imapService.listMailboxes(user, MAILBOX_PATTERN, false); assertEquals(5, mf.size()); nodeService.setProperty(imapFolderC, SiteModel.PROP_COMPONENT_ID, "calendar"); nodeService.setProperty(imapFolderD, SiteModel.PROP_COMPONENT_ID, "dataLists"); nodeService.setProperty(imapFolderE, SiteModel.PROP_COMPONENT_ID, "documentLibrary"); mf = imapService.listMailboxes(user, MAILBOX_PATTERN, false); assertEquals("Imap folders with component IDs 'calendar' or 'dataLists' were not excluded.", 3, mf.size()); }
Example #9
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 #10
Source File: SiteActivitySystemTest.java From alfresco-remote-api with GNU Lesser General Public License v3.0 | 6 votes |
public void testMNT13234() throws Exception { // as admin String ticket = callLoginWebScript(WEBSCRIPT_ENDPOINT, ADMIN_USER, ADMIN_PW); assertNotNull(ticket); // create users (should contain uppercase letter) String testid = ""+System.currentTimeMillis(); String user1 = "User1_" + testid; String user2 = "User2_" + testid; createUser(ticket, user1, USER_PW); createUser(ticket, user2, USER_PW); addFollower(user1, user2, ticket); // create site and add memberships String site1 = "test_site1_" + testid; createSite(site1, true, ticket); addMembership(site1, user1, ticket, SiteModel.SITE_CONSUMER); addMembership(site1, user2, ticket, SiteModel.SITE_CONSUMER); Thread.sleep(DELAY_MSECS); addFeedControl(user1, site1, null, ticket); getUserFeed(user1, ticket, true, 2); }
Example #11
Source File: SiteActivitySystemTest.java From alfresco-remote-api with GNU Lesser General Public License v3.0 | 6 votes |
protected void addAndUpdateMemberships(String siteId, String ticket, boolean includeUser4) throws Exception { // add member -> join site addMembership(siteId, user1, ticket, SiteModel.SITE_CONSUMER); addMembership(siteId, user2, ticket, SiteModel.SITE_MANAGER); addMembership(siteId, user3, ticket, SiteModel.SITE_COLLABORATOR); if (includeUser4) { addMembership(siteId, user4, ticket, SiteModel.SITE_CONSUMER); } // update member -> change role updateMembership(siteId, user1, ticket, SiteModel.SITE_MANAGER); updateMembership(siteId, user2, ticket, SiteModel.SITE_COLLABORATOR); updateMembership(siteId, user3, ticket, SiteModel.SITE_CONSUMER); if (includeUser4) { updateMembership(siteId, user4, ticket, SiteModel.SITE_COLLABORATOR); } }
Example #12
Source File: SiteServiceTest.java From alfresco-remote-api with GNU Lesser General Public License v3.0 | 6 votes |
public void testMultipleInviteRequests() throws Exception { String shortName = GUID.generate(); createSite("myPreset", shortName, "myTitle", "myDescription", SiteVisibility.MODERATED, 200); String userName = USER_TWO; String roleName = SiteModel.SITE_CONSUMER; String inviteComments = "Request to join"; try { //Create a new moderated invitation String moderatedInvitationId = createModeratedInvitation(shortName, inviteComments, userName, roleName); //Create another invitation String newModeratedInvitationId = createModeratedInvitation(shortName, inviteComments, userName, roleName); fail("A request to join this site is already in pending"); } catch (AssertionFailedError e) { // Ignore since we where expecting this } }
Example #13
Source File: TemporarySitesTest.java From alfresco-repository with GNU Lesser General Public License v3.0 | 6 votes |
@Test public void ensureUsersWithShareRolesArePresentAndCorrect() throws Exception { TRANSACTION_HELPER.doInTransaction(new RetryingTransactionCallback<Void>() { public Void execute() throws Throwable { final String shortName = testSiteWithMembers.siteInfo.getShortName(); final SiteInfo recoveredSite = SITE_SERVICE.getSite(shortName); assertNotNull("Test site does not exist", recoveredSite); assertEquals(SiteModel.SITE_MANAGER, SITE_SERVICE.getMembersRole(shortName, testSiteWithMembers.siteManager)); assertEquals(SiteModel.SITE_COLLABORATOR, SITE_SERVICE.getMembersRole(shortName, testSiteWithMembers.siteCollaborator)); assertEquals(SiteModel.SITE_CONTRIBUTOR, SITE_SERVICE.getMembersRole(shortName, testSiteWithMembers.siteContributor)); assertEquals(SiteModel.SITE_CONSUMER, SITE_SERVICE.getMembersRole(shortName, testSiteWithMembers.siteConsumer)); assertNotNull(testSiteWithMembers.doclib); assertTrue("Site doclib was not pre-created.", NODE_SERVICE.exists(testSiteWithMembers.doclib)); assertEquals("Site doclib was in wrong place.", testSiteWithMembers.siteInfo.getNodeRef(), NODE_SERVICE.getPrimaryParent(testSiteWithMembers.doclib).getParentRef()); return null; } }); }
Example #14
Source File: SitesImpl.java From alfresco-remote-api with GNU Lesser General Public License v3.0 | 6 votes |
private List<FilterProp> getFilterPropListOfSites(final Parameters parameters) { List<FilterProp> filterProps = new ArrayList<FilterProp>(); Query q = parameters.getQuery(); if (q != null) { MapBasedQueryWalkerOrSupported propertyWalker = new MapBasedQueryWalkerOrSupported(LIST_SITES_EQUALS_QUERY_PROPERTIES, null); QueryHelper.walk(q, propertyWalker); String siteVisibilityStr = propertyWalker.getProperty(PARAM_VISIBILITY, WhereClauseParser.EQUALS, String.class); if (siteVisibilityStr != null && !siteVisibilityStr.isEmpty()) { SiteVisibility siteVisibility = getSiteVisibilityFromParam(siteVisibilityStr); filterProps.add(new FilterPropString(SiteModel.PROP_SITE_VISIBILITY, siteVisibility.name(), FilterPropString.FilterTypeString.EQUALS)); } String sitePreset = propertyWalker.getProperty(PARAM_PRESET, WhereClauseParser.EQUALS, String.class); if (sitePreset != null && !sitePreset.isEmpty()) { filterProps.add(new FilterPropString(SiteModel.PROP_SITE_PRESET, sitePreset, FilterPropString.FilterTypeString.EQUALS)); } } // expected null or non-empty list return filterProps.isEmpty() ? null : filterProps; }
Example #15
Source File: SiteServiceTest.java From alfresco-remote-api with GNU Lesser General Public License v3.0 | 6 votes |
public void testDeleteMembership() throws Exception { // Create a site String shortName = GUID.generate(); createSite("myPreset", shortName, "myTitle", "myDescription", SiteVisibility.PUBLIC, 200); // Build the JSON membership object JSONObject membership = new JSONObject(); membership.put("role", SiteModel.SITE_CONSUMER); JSONObject person = new JSONObject(); person.put("userName", USER_TWO); membership.put("person", person); // Post the membership sendRequest(new PostRequest(URL_SITES + "/" + shortName + URL_MEMBERSHIPS, membership.toString(), "application/json"), 200); // Delete the membership sendRequest(new DeleteRequest(URL_SITES + "/" + shortName + URL_MEMBERSHIPS + "/" + USER_TWO), 200); // Check that the membership has been deleted sendRequest(new GetRequest(URL_SITES + "/" + shortName + URL_MEMBERSHIPS + "/" + USER_TWO), 404); }
Example #16
Source File: SitesImpl.java From alfresco-remote-api with GNU Lesser General Public License v3.0 | 5 votes |
private boolean includeFilter(SiteMembership siteMembership, List<FilterProp> filterProps) { Map<QName, Serializable> propVals = new HashMap<>(); propVals.put(SiteModel.PROP_SITE_VISIBILITY, siteMembership.getSiteInfo().getVisibility().name()); propVals.put(SiteModel.PROP_SITE_PRESET, siteMembership.getSiteInfo().getSitePreset()); return includeFilter(propVals, filterProps); }
Example #17
Source File: CommentServiceImpl.java From alfresco-repository with GNU Lesser General Public License v3.0 | 5 votes |
private boolean canEditPermission(NodeRef commentNodeRef) { String creator = (String)nodeService.getProperty(commentNodeRef, ContentModel.PROP_CREATOR); Serializable owner = nodeService.getProperty(commentNodeRef, ContentModel.PROP_OWNER); String currentUser = AuthenticationUtil.getFullyAuthenticatedUser(); boolean isSiteManager = permissionService.hasPermission(commentNodeRef, SiteModel.SITE_MANAGER) == (AccessStatus.ALLOWED); boolean isCoordinator = permissionService.hasPermission(commentNodeRef, PermissionService.COORDINATOR) == (AccessStatus.ALLOWED); return (isSiteManager || isCoordinator || currentUser.equals(creator) || currentUser.equals(owner)); }
Example #18
Source File: AbstractSiteServiceTest.java From alfresco-remote-api with GNU Lesser General Public License v3.0 | 5 votes |
protected void addSiteMember(String userName, String site) throws Exception { JSONObject membership = new JSONObject(); membership.put("role", SiteModel.SITE_CONSUMER); JSONObject person = new JSONObject(); person.put("userName", userName); membership.put("person", person); sendRequest(new PostRequest(URL_SITES + "/" + site + URL_MEMBERSHIPS, membership.toString(), "application/json"), 200); }
Example #19
Source File: SitesImpl.java From alfresco-remote-api with GNU Lesser General Public License v3.0 | 5 votes |
public SiteContainer getSiteContainer(String siteId, String containerId) { // check site and container node validity SiteInfo siteInfo = validateSite(siteId); if(siteInfo == null) { // site does not exist throw new RelationshipResourceNotFoundException(siteId, containerId); } // set the site id to the short name (to deal with case sensitivity issues with using the siteId from the url) siteId = siteInfo.getShortName(); NodeRef containerNodeRef = siteService.getContainer(siteId, containerId); if(containerNodeRef == null) { throw new RelationshipResourceNotFoundException(siteId, containerId); } // check that the containerId is actually a container for the specified site SiteInfo testSiteInfo = siteService.getSite(containerNodeRef); if(testSiteInfo == null) { throw new RelationshipResourceNotFoundException(siteId, containerId); } else { if(!testSiteInfo.getShortName().equals(siteId)) { throw new RelationshipResourceNotFoundException(siteId, containerId); } } String folderId = (String)nodeService.getProperty(containerNodeRef, SiteModel.PROP_COMPONENT_ID); SiteContainer siteContainer = new SiteContainer(folderId, containerNodeRef); return siteContainer; }
Example #20
Source File: SiteServiceTest.java From alfresco-remote-api with GNU Lesser General Public License v3.0 | 5 votes |
public void testCheckPermissionsAfterCopy() throws Exception { AuthenticationUtil.pushAuthentication(); AuthenticationUtil.setAdminUserAsFullyAuthenticatedUser(); String groupName = AuthorityType.GROUP.getPrefixString() + "_" + GUID.generate().substring(0, 5).trim(); String createdAuth = authorityService.createAuthority(AuthorityType.GROUP, groupName); NodeRef fileNode = null, siteDocLib = null, copiedNode = null, movedNode = null; try { fileNode = createRepoFile(); siteDocLib = createTestSite(); addPermissionsToFile(fileNode, createdAuth, SiteModel.SITE_CONTRIBUTOR, true); checkPermissions(fileNode, createdAuth, SiteModel.SITE_CONTRIBUTOR, "before copy"); copiedNode = copyToSite(fileNode, siteDocLib); checkPermissions(copiedNode, createdAuth, SiteModel.SITE_CONTRIBUTOR, "after copy"); nodeService.deleteNode(copiedNode); copiedNode = null; checkPermissions(fileNode, createdAuth, SiteModel.SITE_CONTRIBUTOR, "before move"); movedNode = moveToSite(fileNode, siteDocLib); checkPermissions(movedNode, createdAuth, SiteModel.SITE_CONTRIBUTOR, "after move"); } finally { if (fileNode != null) { nodeService.deleteNode(fileNode); } if (siteDocLib != null) { nodeService.deleteNode(siteDocLib); } AuthenticationUtil.popAuthentication(); } }
Example #21
Source File: SiteRoutingFileContentStore.java From alfresco-simple-content-stores with Apache License 2.0 | 5 votes |
/** * Resolves the content store to use for a particular site. * * @param siteNode * the node representing the site - may be {@code null} * @return the content store to use for the site - never {@code null} */ protected SiteAwareFileContentStore resolveStoreForSite(final NodeRef siteNode) { String site = null; String sitePreset = null; if (siteNode != null) { final Map<QName, Serializable> properties = this.nodeService.getProperties(siteNode); site = DefaultTypeConverter.INSTANCE.convert(String.class, properties.get(ContentModel.PROP_NAME)); sitePreset = DefaultTypeConverter.INSTANCE.convert(String.class, properties.get(SiteModel.PROP_SITE_PRESET)); } return this.resolveStoreForSite(site, sitePreset); }
Example #22
Source File: SiteServiceTest.java From alfresco-remote-api with GNU Lesser General Public License v3.0 | 5 votes |
/** * End to end sanity check of web site invitation. * * Nominated and Moderated invitations. * * @throws Exception */ public void testInvitationSanityCheck() throws Exception { String shortName = GUID.generate(); String secondShortName = GUID.generate(); createSite("myPreset", shortName, "myTitle", "myDescription", SiteVisibility.PUBLIC, 200); createSite("myPreset", secondShortName, "myTitle", "myDescription", SiteVisibility.PUBLIC, 200); String inviteComments = "Please sir, let me in"; String userName = USER_TWO; String roleName = SiteModel.SITE_CONSUMER; String inviteeFirstName = "Buffy"; String inviteeLastName = "Summers"; String inviteeEmail = "buffy@sunnydale"; String inviteeUserName = userName; String serverPath = "http://localhost:8081/share/"; String acceptURL = "page/accept-invite"; String rejectURL = "page/reject-invite"; //Create a new moderated invitation String moderatedId = createModeratedInvitation(secondShortName, inviteComments, userName, roleName); // Get the moderated invitation sendRequest(new GetRequest(URL_SITES + "/" + secondShortName + "/invitations/" + moderatedId), 200); // search for the moderated invitation sendRequest(new GetRequest(URL_SITES + "/" + shortName + "/invitations?inviteeUserName=" + userName), 200); // Create a nominated invitation String nominatedId = createNominatedInvitation(shortName, inviteeFirstName, inviteeLastName, inviteeEmail, inviteeUserName, roleName, serverPath, acceptURL, rejectURL, 201); // Search for all invitations on this site sendRequest(new GetRequest(URL_SITES + "/" + shortName + "/invitations"), 200); // cancel the moderated invitation sendRequest(new DeleteRequest(URL_SITES + "/" + secondShortName + "/invitations/" + moderatedId), 200); }
Example #23
Source File: FeedCleaner.java From alfresco-repository with GNU Lesser General Public License v3.0 | 5 votes |
public void init() { policyComponent.bindClassBehaviour(BeforeDeleteNodePolicy.QNAME, ContentModel.TYPE_PERSON, new JavaBehaviour(this, "beforeDeleteNodePerson")); deletePersonTransactionListener = new FeedCleanerDeletePersonTransactionListener(); policyComponent.bindClassBehaviour(BeforeDeleteNodePolicy.QNAME, SiteModel.TYPE_SITE, new JavaBehaviour(this, "beforeDeleteNodeSite")); deleteSiteTransactionListener = new FeedCleanerDeleteSiteTransactionListener(); }
Example #24
Source File: SiteServiceTest.java From alfresco-remote-api with GNU Lesser General Public License v3.0 | 5 votes |
public void testInviteDisabledUser() throws Exception { AuthenticationUtil.pushAuthentication(); AuthenticationUtil.setFullyAuthenticatedUser(AuthenticationUtil.getAdminUserName()); String username = "testUser" + System.nanoTime(); String siteShortName = GUID.generate(); try { createUser(username); createSite("myPreset", siteShortName, "myTitle", "myDescription", SiteVisibility.PUBLIC, 200); NodeRef personNodeRef = personService.getPerson(username); String firstName = (String) nodeService.getProperty(personNodeRef, ContentModel.PROP_FIRSTNAME); String lastName = (String) nodeService.getProperty(personNodeRef, ContentModel.PROP_LASTNAME); String email = (String) nodeService.getProperty(personNodeRef, ContentModel.PROP_EMAIL); String serverPath = "http://localhost:8081/share/"; String acceptURL = "page/accept-invite"; String rejectURL = "page/reject-invite"; authenticationService.setAuthenticationEnabled(username, false); createNominatedInvitation(siteShortName, firstName, lastName, email, username, SiteModel.SITE_CONSUMER, serverPath, acceptURL, rejectURL, 409); fail("The user " + username + " is disabled and cannot be invited"); } catch (JSONException e) { // expected } finally { siteService.deleteSite(siteShortName); deleteUser(username); AuthenticationUtil.popAuthentication(); } }
Example #25
Source File: SiteServiceTest.java From alfresco-remote-api with GNU Lesser General Public License v3.0 | 5 votes |
public void testDeleteMembershipAsSiteAdmin() throws Exception { // Create a site String shortName = GUID.generate(); createSite("myPreset", shortName, "myTitle", "myDescription", SiteVisibility.PUBLIC, 200); // Build the JSON membership object JSONObject membership = new JSONObject(); membership.put("role", SiteModel.SITE_CONSUMER); JSONObject person = new JSONObject(); person.put("userName", USER_TWO); membership.put("person", person); // Post the membership Response response = sendRequest(new PostRequest(URL_SITES + "/" + shortName + URL_MEMBERSHIPS, membership.toString(), "application/json"), 200); JSONObject jsonObj = new JSONObject(response.getContentAsString()); // Check the result assertEquals(SiteModel.SITE_CONSUMER, jsonObj.get("role")); assertEquals(USER_TWO, jsonObj.getJSONObject("authority").get("userName")); // try to delete user2 from the site this.authenticationComponent.setCurrentUser(USER_THREE); sendRequest(new DeleteRequest(URL_SITES + "/" + shortName + URL_MEMBERSHIPS + "/" + USER_TWO), 500); assertTrue(USER_THREE + " doesn’t have permission to delete users from the site", siteService.isMember(shortName, USER_TWO)); // set the current user as site-admin this.authenticationComponent.setCurrentUser(USER_FOUR_AS_SITE_ADMIN); sendRequest(new DeleteRequest(URL_SITES + "/" + shortName + URL_MEMBERSHIPS + "/" + USER_TWO), 200); assertFalse(siteService.isMember(shortName, USER_TWO)); }
Example #26
Source File: DiscussionServiceImplTest.java From alfresco-repository with GNU Lesser General Public License v3.0 | 5 votes |
/** * Deletes the specified NodeRefs, if they exist. * @param nodesToDelete List<NodeRef> */ private static void performDeletionOfNodes(final List<NodeRef> nodesToDelete) { TRANSACTION_HELPER.doInTransaction(new RetryingTransactionHelper.RetryingTransactionCallback<Void>() { @Override public Void execute() throws Throwable { AuthenticationUtil.setFullyAuthenticatedUser(ADMIN_USER); for (NodeRef node : nodesToDelete) { if (NODE_SERVICE.exists(node)) { // st:site nodes can only be deleted via the SiteService if (NODE_SERVICE.getType(node).equals(SiteModel.TYPE_SITE)) { SiteInfo siteInfo = SITE_SERVICE.getSite(node); SITE_SERVICE.deleteSite(siteInfo.getShortName()); } else { NODE_SERVICE.deleteNode(node); } } } return null; } }); }
Example #27
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 #28
Source File: SiteRoutingContentStore.java From alfresco-simple-content-stores with Apache License 2.0 | 5 votes |
/** * Resolves the content store to use for a particular site. * * @param siteNode * the node representing the site - may be {@code null} * @return the content store to use for the site - can be {@code null} if this implementation layer cannot determine the store on its * own, and selection of the {@code fallbackStore} by the super implementation has to be presumed */ protected ContentStore resolveStoreForSite(final NodeRef siteNode) { String site = null; String sitePreset = null; if (siteNode != null) { final Map<QName, Serializable> properties = this.nodeService.getProperties(siteNode); site = DefaultTypeConverter.INSTANCE.convert(String.class, properties.get(ContentModel.PROP_NAME)); sitePreset = DefaultTypeConverter.INSTANCE.convert(String.class, properties.get(SiteModel.PROP_SITE_PRESET)); } return this.resolveStoreForSite(site, sitePreset); }
Example #29
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 #30
Source File: CommentsPost.java From alfresco-remote-api with GNU Lesser General Public License v3.0 | 5 votes |
/** * generates an comment item value * * @param commentNodeRef * @return */ private Map<String, Object> generateItemValue(NodeRef commentNodeRef) { Map<String, Object> result = new HashMap<String, Object>(4, 1.0f); String creator = (String)this.nodeService.getProperty(commentNodeRef, ContentModel.PROP_CREATOR); Serializable created = this.nodeService.getProperty(commentNodeRef, ContentModel.PROP_CREATED); Serializable modified = this.nodeService.getProperty(commentNodeRef, ContentModel.PROP_MODIFIED); boolean isUpdated = false; if (created instanceof Date && modified instanceof Date) { isUpdated = ((Date)modified).getTime() - ((Date)created).getTime() > 5000; } // TODO refactor v0 Comments API to use CommentService (see ACE-5437) Serializable owner = this.nodeService.getProperty(commentNodeRef, ContentModel.PROP_OWNER); String currentUser = this.serviceRegistry.getAuthenticationService().getCurrentUserName(); boolean isSiteManager = this.permissionService.hasPermission(commentNodeRef, SiteModel.SITE_MANAGER) == (AccessStatus.ALLOWED); boolean isCoordinator = this.permissionService.hasPermission(commentNodeRef, PermissionService.COORDINATOR) == (AccessStatus.ALLOWED); boolean canEditComment = isSiteManager || isCoordinator || currentUser.equals(creator) || currentUser.equals(owner); result.put("node", commentNodeRef); result.put("author", this.personService.getPerson(creator)); result.put("isUpdated", isUpdated); result.put("canEditComment", canEditComment); return result; }