Package org.nuxeo.ecm.core.api

Examples of org.nuxeo.ecm.core.api.DocumentModel


    /**
     * Creates document and wait for all post-commit listener execution
     */
    public DocumentModel createDocument(String pathAsString, String name,
            String type) throws Exception {
        DocumentModel doc = session.createDocumentModel(pathAsString, name,
                type);
        doc.setPropertyValue("dc:title", name);
        doc = session.createDocument(doc);
        session.save(); // fire post commit event listener
        Framework.getService(EventService.class).waitForAsyncCompletion();
        session.save(); // flush the session to retrieve document
        return doc;
View Full Code Here


    /**
     * Creates document and wait for all post-commit listener execution
     */
    public DocumentModel createSocialDocument(String pathAsString, String name,
            String type, boolean isPublic) throws Exception {
        DocumentModel doc = session.createDocumentModel(pathAsString, name,
                type);
        doc.setPropertyValue(
                SocialConstants.SOCIAL_DOCUMENT_IS_PUBLIC_PROPERTY, isPublic);
        doc = session.createDocument(doc);
        session.save(); // fire post commit event listener
        session.save(); // flush the session to retrieve document
        Framework.getService(EventService.class).waitForAsyncCompletion();
View Full Code Here

        return doc;
    }

    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) {
View Full Code Here

        session.removeChildren(session.getRootDocument().getRef());
        session.save();

        // create social workspaces
        DocumentModel sws1 = session.createDocumentModel("/", "sws1",
                "SocialWorkspace");
        sws1.setPropertyValue("dc:title", "Social Workspace 1");
        sws1 = session.createDocument(sws1);

        session.save();

        DocumentModel sws2 = session.createDocumentModel("/", "sws2",
                "SocialWorkspace");
        sws2.setPropertyValue("dc:title", "Social Workspace 2");
        sws2 = session.createDocument(sws2);
        session.save();

        // create two articles in 2nd social workspace
        DocumentModel article1 = session.createDocumentModel("/sws2",
                "article1", "Article");
        article1.setPropertyValue(SOCIAL_DOCUMENT_IS_PUBLIC_PROPERTY, true);
        article1.setPropertyValue("dc:title", "Public Article");
        article1 = session.createDocument(article1);
        session.save();
        Framework.getService(EventService.class).waitForAsyncCompletion();
        session.save();
        article1 = session.getDocument(article1.getRef());

        DocumentModel article2 = session.createDocumentModel("/sws2",
                "article2", "Article");
        article2.setPropertyValue("dc:title", "Non Public Article");
        article2 = session.createDocument(article2);

        session.save();
    }
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

        socialWorkspaceDocument = session.createDocument(socialWorkspaceDocument);
        socialWorkspace = socialWorkspaceDocument.getAdapter(SocialWorkspace.class);
        assertNotNull(socialWorkspace);

        // create a user
        DocumentModel testUser = userManager.getBareUserModel();
        String schemaName = userManager.getUserSchemaName();

        testUser.setPropertyValue(schemaName + ":username", "testUser");
        testUser.setPropertyValue(schemaName + ":firstName",
                "testUser_firstName");
        testUser.setPropertyValue(schemaName + ":lastName", "testUser_lastName");
        userManager.createUser(testUser);
        assertNotNull(userManager.getPrincipal("testUser"));

        // make the user member of SocialWorkspace
        socialWorkspace.addMember(userManager.getPrincipal("testUser"));
View Full Code Here

    }

    @Override
    public ActivitiesList query(ActivityStreamService activityStreamService,
            Map<String, Serializable> parameters, long offset, long limit) {
        DocumentModel doc = (DocumentModel) parameters.get(CONTEXT_DOCUMENT_PARAMETER);
        if (doc == null) {
            throw new IllegalArgumentException(CONTEXT_DOCUMENT_PARAMETER
                    + " is required");
        }
        String docActivityObject = ActivityHelper.createDocumentActivityObject(doc);
View Full Code Here

        return relationshipPage;
    }

    protected void addUsernameToRelationshipPage(String username) {
        try {
            DocumentModel userProfile = getUserProfileService().getUserProfile(
                    getUserManager().getUserModel(username), getCoreSession());
            relationshipPage.add(userProfile);
        } catch (ClientException e) {
            log.warn("Cannot get user model for:" + username, e);
        }
View Full Code Here

        activity.setPublishedDate(now.plusHours(4).toDate());
        activityStreamService.addActivity(activity);
    }

    protected void createDocumentsWithBender() throws ClientException {
        DocumentModel workspacesDocument = session.getDocument(new PathRef(
                "/default-domain/workspaces"));
        ACP acp = workspacesDocument.getACP();
        ACL acl = acp.getOrCreateACL();
        acl.add(new ACE("Bender", EVERYTHING, true));
        acl.add(new ACE("Leela", READ, true));
        workspacesDocument.setACP(acp, true);
        session.save();
        session.save();

        try (CoreSession newSession = openSessionAs("Bender")) {
            DocumentModel doc = newSession.createDocumentModel(
                    workspacesDocument.getPathAsString(), "file1", "File");
            doc = newSession.createDocument(doc);
            acp = doc.getACP();
            acl = acp.getOrCreateACL();
            acl.add(new ACE("Leela", READ, true));
            doc.setACP(acp, true);
            newSession.save();
            newSession.save();

            doc = newSession.createDocumentModel(
                    workspacesDocument.getPathAsString(), "file2", "File");
            doc = newSession.createDocument(doc);
            acp = doc.getACP();
            acl = acp.getOrCreateACL();
            acl.add(new ACE("Leela", READ, true));
            doc.setACP(acp, true);
            newSession.save();
            newSession.save();

            doc = newSession.createDocumentModel(
                    workspacesDocument.getPathAsString(), "file-without-right",
                    "File");
            doc = newSession.createDocument(doc);
            acp = doc.getACP();
            acl = acp.getOrCreateACL();
            acl.add(new ACE(SecurityConstants.ADMINISTRATOR, READ));
            acl.add(ACE.BLOCK);
            doc.setACP(acp, true);
            newSession.save();
            newSession.save();

            eventService.waitForAsyncCompletion();
        }
View Full Code Here

        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");
View Full Code Here

TOP

Related Classes of org.nuxeo.ecm.core.api.DocumentModel

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.