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

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


            return;
        }

        CoreSession session = ctx.getCoreSession();

        SocialDocument socialDocument = toSocialDocument(document);
        cleanProxy(session, socialDocument);
    }
View Full Code Here


        FormData formData = new FormData(request);
        CoreSession session = ctx.getCoreSession();
        DocumentRef docRef = getDocumentRef(formData.getString("targetRef"));

        DocumentModel target = session.getDocument(docRef);
        SocialDocument socialDocument = toSocialDocument(target);

        if (socialDocument == null) {
            throw new ClientException("Can't fetch social document.");
        }

        boolean isPublic = "true".equals(formData.getString("public"));
        if (isPublic) {
            socialDocument.makePublic();
        } else {
            socialDocument.restrictToMembers();
        }
        return documentList(request);
    }
View Full Code Here

        List<String> list = new ArrayList<String>();

        if (isPublicSocialWorkspace) {
            if (isPublic) { // is public publication
                for (DocumentModel doc : docs) {
                    SocialDocument socialDocument = toSocialDocument(doc);
                    if (socialDocument != null
                            && socialDocument.isRestrictedToMembers()) {
                        list.add(doc.getId());
                    }
                }
            } else { // is private publication
                for (DocumentModel doc : docs) {
                    SocialDocument socialDocument = toSocialDocument(doc);
                    if (socialDocument != null && socialDocument.isPublic()) {
                        list.add(doc.getId());
                    }
                }
            }
        }
View Full Code Here

    /**
     * create or update a proxy of the social document passed as an argument in
     * the public social section of the social workspace.
     */
    public void makePublic(DocumentModel document) throws ClientException {
        SocialDocument socialDocument = toSocialDocument(document);
        socialDocument.makePublic();
        Events.instance().raiseEvent(EventNames.DOCUMENT_CHANGED, document);
    }
View Full Code Here

     * Hide the social document passed as parameter to non members of the social
     * collaboration workspace
     */
    public void restrictToMembers(DocumentModel document)
            throws ClientException {
        SocialDocument socialDocument = toSocialDocument(document);
        socialDocument.restrictToMembers();
        Events.instance().raiseEvent(EventNames.DOCUMENT_CHANGED, document);
    }
View Full Code Here

     *
     * @return true if the current document is public, false otherwise.
     * @throws ClientException
     */
    public boolean isPublic(DocumentModel document) throws ClientException {
        SocialDocument socialDocument = toSocialDocument(document);
        return socialDocument.isPublic();
    }
View Full Code Here

     *
     * @return true if the current document is public, false otherwise.
     * @throws ClientException
     */
    public boolean isRestricted(DocumentModel document) throws ClientException {
        SocialDocument socialDocument = toSocialDocument(document);
        return socialDocument.isRestrictedToMembers();
    }
View Full Code Here

    public void shouldCreatePrivateProxyForSocialDocumentPrivate()
            throws Exception {
        DocumentModel privateNews = createSocialDocument(
                socialWorkspaceDoc.getPathAsString(), "private news",
                NEWS_ITEM_TYPE, false);
        SocialDocument socialDocument = toSocialDocument(privateNews);

        assertTrue(socialDocument.isDocumentInSocialWorkspace());
        assertTrue(socialDocument.isRestrictedToMembers());
        assertFalse(socialDocument.isPublic());
        assertNull(socialDocument.getPublicDocument());
        assertNotNull(socialDocument.getRestrictedDocument());
        assertTrue(socialDocument.getRestrictedDocument().isProxy());
        checkRestricted(socialDocument.getRestrictedDocument());

        socialDocument.makePublic();
        assertFalse(socialDocument.isRestrictedToMembers());
        assertTrue(socialDocument.isPublic());
        assertNotNull(socialDocument.getPublicDocument());
        assertNull(socialDocument.getRestrictedDocument());
        assertTrue(socialDocument.getPublicDocument().isProxy());
        checkPublic(socialDocument.getPublicDocument());

        socialDocument.restrictToMembers();
        assertTrue(socialDocument.isRestrictedToMembers());
        assertFalse(socialDocument.isPublic());
        assertNull(socialDocument.getPublicDocument());
        assertNotNull(socialDocument.getRestrictedDocument());
        assertTrue(socialDocument.getRestrictedDocument().isProxy());
        checkRestricted(socialDocument.getRestrictedDocument());
    }
View Full Code Here

        session.save();
        eventService.waitForAsyncCompletion();
        session.save();
        socialDocumentFacetedNotePrivate = session.getDocument(socialDocumentFacetedNotePrivate.getRef());

        SocialDocument socialDocument = toSocialDocument(socialDocumentFacetedNotePrivate);
        assertTrue(socialDocument.isRestrictedToMembers());
        assertFalse(socialDocument.isPublic());
        assertNull(socialDocument.getPublicDocument());
        assertNotNull(socialDocument.getRestrictedDocument());
        assertTrue(socialDocument.getRestrictedDocument().isProxy());
        checkRestricted(socialDocument.getRestrictedDocument());

        DocumentModel socialDocumentFacetedNotePublic = session.createDocumentModel(
                socialWorkspaceDoc.getPathAsString(), "Social Document Note2",
                "Note");
        socialDocumentFacetedNotePublic.addFacet(SOCIAL_DOCUMENT_FACET);
        socialDocumentFacetedNotePublic.setPropertyValue(
                SOCIAL_DOCUMENT_IS_PUBLIC_PROPERTY, true);
        socialDocumentFacetedNotePublic = session.createDocument(socialDocumentFacetedNotePublic);
        session.save();
        eventService.waitForAsyncCompletion();
        session.save();
        socialDocumentFacetedNotePublic = session.getDocument(socialDocumentFacetedNotePublic.getRef());

        socialDocument = toSocialDocument(socialDocumentFacetedNotePublic);
        assertFalse(socialDocument.isRestrictedToMembers());
        assertTrue(socialDocument.isPublic());
        assertNotNull(socialDocument.getPublicDocument());
        assertTrue(socialDocument.getPublicDocument().isProxy());
        assertNull(socialDocument.getRestrictedDocument());
        checkPublic(socialDocument.getPublicDocument());
    }
View Full Code Here

            throws Exception {
        DocumentModel privateNews = createSocialDocument(
                socialWorkspaceDoc.getPathAsString(), "private news",
                NEWS_ITEM_TYPE, true);

        SocialDocument socialDocument = toSocialDocument(privateNews);

        assertFalse(socialDocument.isRestrictedToMembers());
        assertTrue(socialDocument.isPublic());
        assertNotNull(socialDocument.getPublicDocument());
        assertNull(socialDocument.getRestrictedDocument());
        assertTrue(socialDocument.getPublicDocument().isProxy());
        checkPublic(socialDocument.getPublicDocument());

        socialDocument.restrictToMembers();
        assertTrue(socialDocument.isDocumentInSocialWorkspace());
        assertTrue(socialDocument.isRestrictedToMembers());
        assertFalse(socialDocument.isPublic());
        assertNull(socialDocument.getPublicDocument());
        assertNotNull(socialDocument.getRestrictedDocument());
        assertTrue(socialDocument.getRestrictedDocument().isProxy());
        checkRestricted(socialDocument.getRestrictedDocument());

        socialDocument.makePublic();
        assertFalse(socialDocument.isRestrictedToMembers());
        assertTrue(socialDocument.isPublic());
        assertNotNull(socialDocument.getPublicDocument());
        assertNull(socialDocument.getRestrictedDocument());
        assertTrue(socialDocument.getPublicDocument().isProxy());
        checkPublic(socialDocument.getPublicDocument());
    }
View Full Code Here

TOP

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

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.