Package org.nuxeo.ecm.social.workspace.adapters

Examples of org.nuxeo.ecm.social.workspace.adapters.SocialWorkspace


        }
        return members;
    }

    public void updateGroups() throws ClientException {
        SocialWorkspace socialWorkspace = toSocialWorkspace(navigationContext.getCurrentDocument());
        for (String administrator : administrators) {
            if (!originalAdministrators.contains(administrator)) {
                socialWorkspace.addAdministrator(userManager.getPrincipal(administrator));
            }
        }
        for (String administrator : originalAdministrators) {
            if (!administrators.contains(administrator)) {
                Principal principal = userManager.getPrincipal(administrator);
                if (principal == null) {
                    // build a standard principal, only its name will be used
                    principal = new PrincipalImpl(administrator);
                }
                socialWorkspace.removeAdministrator(principal);
            }
        }
        for (String member : members) {
            if (!originalMembers.contains(member)) {
                socialWorkspace.addMember(userManager.getPrincipal(member));
            }
        }
        for (String member : originalMembers) {
            if (!members.contains(member)) {
                Principal principal = userManager.getPrincipal(member);
                if (principal == null) {
                    // build a standard principal, only its name will be used
                    principal = new PrincipalImpl(member);
                }
                socialWorkspace.removeMember(principal);
            }
        }

        facesMessages.add(
                StatusMessage.Severity.INFO,
View Full Code Here


        CoreSession session = socialWorkspace.getDocument().getCoreSession();
        try {
            new UnrestrictedSessionRunner(session) {
                @Override
                public void run() throws ClientException {
                    SocialWorkspace unrestrictedSocialWorkspace = toSocialWorkspace(session.getDocument(new IdRef(
                            socialWorkspace.getId())));
                    initializeSocialWorkspaceRights(unrestrictedSocialWorkspace);
                    initializeNewsItemsRootRights(unrestrictedSocialWorkspace);
                    if (unrestrictedSocialWorkspace.isPublic()) {
                        makeSocialWorkspacePublic(unrestrictedSocialWorkspace);
                    }
                }
            }.runUnrestricted();
        } catch (ClientException e) {
View Full Code Here

    protected Space doGetSpace(CoreSession session,
            DocumentModel contextDocument, String spaceName,
            Map<String, String> parameters) throws SpaceException {
        try {
            if (isSocialWorkspace(contextDocument)) {
                SocialWorkspace socialWorkspace = toSocialWorkspace(contextDocument);
                DocumentModel doc = session.getDocument(new PathRef(
                        socialWorkspace.getPrivateDashboardSpacePath()));
                return doc.getAdapter(Space.class);
            } else {
                // assume dashboard spaces root
                DocumentModel doc = session.getDocument(new PathRef(
                        contextDocument.getPathAsString() + "/"
View Full Code Here

    protected Space doGetSpace(CoreSession session,
            DocumentModel contextDocument, String spaceName,
            Map<String, String> parameters) throws SpaceException {
        try {
            if (isSocialWorkspace(contextDocument)) {
                SocialWorkspace socialWorkspace = toSocialWorkspace(contextDocument);
                DocumentModel doc = session.getDocument(new PathRef(
                        socialWorkspace.getPublicDashboardSpacePath()));
                return doc.getAdapter(Space.class);
            } else {
                // assume dashboard spaces root
                DocumentModel doc = session.getDocument(new PathRef(
                        contextDocument.getPathAsString() + "/"
View Full Code Here

    protected SocialWorkspace createSocialWorkspace(String socialWorkspaceName,
            boolean isPublic) throws Exception {
        DocumentModel doc = createDocument(
                session.getRootDocument().getPathAsString(),
                socialWorkspaceName, SOCIAL_WORKSPACE_TYPE);
        SocialWorkspace sw = toSocialWorkspace(doc);

        if (isPublic) {
            sw.makePublic();
        }
        return sw;
    }
View Full Code Here

        DocumentModelList result = (DocumentModelList) service.run(ctx, chain);
        assertEquals(2, result.size());

        // remove current user from admins of sws2
        DocumentModel sws = session.getDocument(new PathRef("/sws2"));
        SocialWorkspace socialWorkspace = toSocialWorkspace(sws);

        oParams.set("query", "select * from Article where ecm:isProxy = 1");
        result = (DocumentModelList) service.run(ctx, chain);
        assertEquals(1, result.size()); // return only the public article
    }
View Full Code Here

    @Test
    public void testSocialWorkspaceComputer() throws Exception {
        SocialWorkspaceGroupComputer computer = new SocialWorkspaceGroupComputer();

        SocialWorkspace sw = createSocialWorkspace("mySocialWorkspace", true);
        assertNotNull(sw);
        SocialWorkspace sw2 = createSocialWorkspace("mySocialWorkspace2", true);
        assertNotNull(sw);

        // Rights for SocialWorkspace: 1 admin and 2 members
        assertTrue(addBidirectionalRelation(
                ActivityHelper.createUserActivityObject("userComputer"),
                ActivityHelper.createDocumentActivityObject(sw.getDocument()),
                buildRelationAdministratorKind()));
        assertTrue(addBidirectionalRelation(
                ActivityHelper.createUserActivityObject("userComputer2"),
                ActivityHelper.createDocumentActivityObject(sw.getDocument()),
                buildRelationMemberKind()));
        assertTrue(addBidirectionalRelation(
                ActivityHelper.createUserActivityObject("userComputer3"),
                ActivityHelper.createDocumentActivityObject(sw.getDocument()),
                buildRelationMemberKind()));

        assertEquals(
                3,
                computer.getGroupMembers(
                        getSocialWorkspaceMembersGroupName(sw.getDocument())).size());

        // There is the creator and a freshly added one.
        assertEquals(
                2,
                computer.getGroupMembers(
                        getSocialWorkspaceAdministratorsGroupName(sw.getDocument())).size());

        // Right for SocialWorkspace 2: 1 admin and 0 member
        assertTrue(addBidirectionalRelation(
                ActivityHelper.createUserActivityObject("userComputer2"),
                ActivityHelper.createDocumentActivityObject(sw2.getDocument()),
                buildRelationAdministratorKind()));

        assertEquals(
                2,
                computer.getGroupMembers(
                        getSocialWorkspaceAdministratorsGroupName(sw2.getDocument())).size());
        assertEquals(
                1,
                computer.getGroupMembers(
                        getSocialWorkspaceMembersGroupName(sw2.getDocument())).size());

        DocumentModel user1 = userManager.getBareUserModel();
        user1.setProperty(userManager.getUserSchemaName(),
                userManager.getUserIdField(), "userComputer2");
        userManager.createUser(user1);
        session.save();

        NuxeoPrincipal principal = userManager.getPrincipal("userComputer2");

        List<String> groups = computer.getGroupsForUser((NuxeoPrincipalImpl) principal);

        assertEquals(2, groups.size());
        assertTrue(groups.contains(getSocialWorkspaceAdministratorsGroupName(sw2.getDocument())));
        assertTrue(groups.contains(getSocialWorkspaceMembersGroupName(sw.getDocument())));

        assertEquals(2, principal.getAllGroups().size());
    }
View Full Code Here

    }

    @Test
    public void testAddSeveralSocialWorkspaceMembers() throws Exception {
        assertEquals(0, ImportEventListener.getMemberAddedCount());
        SocialWorkspace socialWorkspace = createSocialWorkspace("Social workspace for test");
        assertTrue(socialWorkspace.isMembersNotificationEnabled());

        String userAlreadyMember1Email = "userAlreadyMember1@mail.net";
        DocumentModel userAlreadyMember1 = createUserForTest(
                userAlreadyMember1Email, "userAlreadyMember1");
        socialWorkspace.addMember(userManager.getPrincipal(userAlreadyMember1.getId()));
        assertEquals(2, ImportEventListener.getMemberAddedCount());

        socialWorkspace.getDocument().putContextData(ScopeType.REQUEST,
                "memberNotificationDisabled", true);
        assertFalse(socialWorkspace.isMembersNotificationEnabled());

        DocumentModel userAlreadyMember2 = createUserForTest(
                "userAlreadyMember2@mail.net", "userAlreadyMember2");
        socialWorkspace.addMember(userManager.getPrincipal(userAlreadyMember2.getId()));

        assertEquals(2, ImportEventListener.getMemberAddedCount());
        socialWorkspace.getDocument().putContextData(ScopeType.REQUEST,
                "memberNotificationDisabled", false);

        DocumentModel fulltextEmailUser1 = createUserForTest(
                "fulltextEmailUser1@mail.net", "fulltextEmailUser1");

        String userNewMember1Email = "userNewMember1@mail.net";
        createUserForTest(userNewMember1Email, "userNewMember1");
        createUserForTest("userNewMember2@mail.net", "userNewMember2");

        String nonExsitingUser1Email = "nonExistingUser1@mail.net";
        List<String> emails = Arrays.asList(userAlreadyMember1Email,
                "userAlreadyMember2@mail.net", "userNewMember1@mail.net",
                "userNewMember2@mail.net", nonExsitingUser1Email,
                "nonExistingUser2@mail.net", fulltextEmailUser1.getId());

        Framework.getLocalService(EventService.class).waitForAsyncCompletion();

        List<String> addedUsers = socialWorkspaceService.addSocialWorkspaceMembers(
                socialWorkspace, emails);
        assertEquals(3, socialWorkspace.getMembers().size());
        assertTrue(socialWorkspace.isAdministratorOrMember(userManager.getPrincipal("userAlreadyMember1")));
        assertEquals(3, addedUsers.size());
        assertEquals(5, ImportEventListener.getMemberAddedCount());
        assertEquals(3, ImportEventListener.getLastPrincipalsCount());
        assertFalse(addedUsers.contains(userAlreadyMember1Email));
        assertFalse(addedUsers.contains(nonExsitingUser1Email));
View Full Code Here

        group1 = userManager.createGroup(group1);
        members = (List<String>) group1.getPropertyValue(userManager.getGroupSchemaName()
                + ":" + userManager.getGroupMembersField());
        assertEquals(4, members.size());

        SocialWorkspace sw = createSocialWorkspace("SocialWorkspaceWithGroup");
        assertEquals(1, sw.getMembers().size());

        int beforeImportCount = ImportEventListener.getMemberAddedCount();
        sw.getDocument().putContextData("allowMemberNotification", false);
        List<String> imported = socialWorkspaceService.addSocialWorkspaceMembers(
                sw, group1.getName());
        assertEquals(2, imported.size());
        assertEquals(beforeImportCount,
                ImportEventListener.getMemberAddedCount());
        assertTrue(imported.contains(existingUser1));
        assertTrue(imported.contains(existingUser2));
        assertFalse(imported.contains("Administrator"));

        assertEquals(3, sw.getMembers().size());

        // Will throw a ClientException
        socialWorkspaceService.addSocialWorkspaceMembers(sw, "john_doe_group");
    }
View Full Code Here

TOP

Related Classes of org.nuxeo.ecm.social.workspace.adapters.SocialWorkspace

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.