Package org.nuxeo.ecm.core.api

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


        // build freemarker arguments map
        Map<String, Object> args = new HashMap<String, Object>();

        CoreSession session = ctx.getCoreSession();

        DocumentModel doc = session.getDocument(docRef);
        args.put("currentDoc", doc);

        PaginableDocumentModelList docs;
        DocumentModel socialWorkspace = null;
        if (isSearch) {
            docs = search(doc, pageSize, page, queryText);
            socialWorkspace = doc;
            args.put("queryText", queryText);
        } else {
            docs = getChildren(doc, pageSize, page);
            List<DocumentModel> ancestors = getAncestors(doc);

            DocumentModel parent = null;
            if (ancestors.size() > 1) {
                parent = ancestors.get(ancestors.size() - 2);
            }
            args.put("parent", parent);
View Full Code Here


            throws Exception {
        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.");
        }
View Full Code Here

            @QueryParam("doctype") String docTypeId,
            @QueryParam("lang") String lang) throws Exception {
        setLanguage(lang);
        DocumentRef docRef = getDocumentRef(ref);
        CoreSession session = ctx.getCoreSession();
        DocumentModel currentDoc = session.getDocument(docRef);

        DocumentType coreType = TypeService.getSchemaManager().getDocumentType(
                docTypeId);

        return getView("create_document_form").arg("currentDoc", currentDoc).arg(
View Full Code Here

    public Object selectDocTypeToCreate(@QueryParam("docRef") String ref,
            @QueryParam("lang") String lang) throws ClientException {
        setLanguage(lang);
        DocumentRef docRef = getDocumentRef(ref);
        CoreSession session = ctx.getCoreSession();
        DocumentModel currentDoc = session.getDocument(docRef);
        TypeManager typeService = getTypeService();
        Map<String, List<Type>> types = typeService.getTypeMapForDocumentType(
                currentDoc.getType(), currentDoc);
        filterAllowedTypes(types);

        return getView("select_doc_type").arg("currentDoc", currentDoc).arg(
                "docTypes", types).arg("categories", types.keySet()).arg(
                "lang", lang);
View Full Code Here

        CoreSession session = ctx.getCoreSession();
        FormData formData = new FormData(request);
        String type = formData.getDocumentType();
        String title = formData.getDocumentTitle();
        DocumentRef docRef = getDocumentRef(formData.getString("docRef"));
        DocumentModel parent = session.getDocument(docRef);
        DocumentModel newDoc = session.createDocumentModel(
                parent.getPathAsString(), title, type);
        formData.fillDocument(newDoc);
        newDoc = session.createDocument(newDoc);
        session.save();
        if (newDoc.isFolder()) {
            return buildDocumentList(newDoc.getId(), 0, 0, null);
        } else {
            return buildDocumentList(parent.getId(), 0, 0, null);
        }
    }
View Full Code Here

            throws Exception {
        // build freemarker arguments map
        Map<String, Object> args = new HashMap<String, Object>();
        CoreSession session = ctx.getCoreSession();
        IdRef docRef = new IdRef(ref);
        DocumentModel doc = session.getDocument(docRef);
        args.put("doc", doc);
        return Response.ok(getView("document_comments_template").args(args)).header(
                "docRef", ref).build();
    }
View Full Code Here

    public Object addComment() throws ClientException {
        try {
            HttpServletRequest request = ctx.getRequest();
            CoreSession session = ctx.getCoreSession();
            // Create pending comment
            DocumentModel myComment = session.createDocumentModel("Comment");
            // Set comment properties
            myComment.setProperty("comment", "author",
                    ctx.getPrincipal().getName());
            myComment.setProperty("comment", "text",
                    request.getParameter("commentContent"));
            myComment.setProperty("comment", "creationDate",
                    Calendar.getInstance());
            // Retrieve document to comment
            String docToCommentRef = request.getParameter("docToCommentRef");
            DocumentModel docToComment = session.getDocument(new IdRef(
                    docToCommentRef));
            String commentParentRef = request.getParameter("commentParentRef");
            // Create comment
            CommentableDocument commentableDoc = null;
            if (docToComment != null) {
                commentableDoc = docToComment.getAdapter(CommentableDocument.class);
            }
            DocumentModel newComment;
            if (commentParentRef != null) {
                // if exists retrieve comment parent
                DocumentModel commentParent = session.getDocument(new IdRef(
                        commentParentRef));
                newComment = commentableDoc.addComment(commentParent, myComment);
            } else {
                newComment = commentableDoc.addComment(myComment);
            }
View Full Code Here

    @POST
    @Path("docLike")
    public Object docLike(@FormParam("docRef") String docRef) throws Exception {
        // Get document
        CoreSession session = ctx.getCoreSession();
        DocumentModel docToLike = session.getDocument(new IdRef(docRef));
        // Get Like Services
        LikeService likeService = Framework.getLocalService(LikeService.class);
        // Get user name
        String userName = ctx.getPrincipal().getName();
        if (likeService.hasUserLiked(userName, docToLike)) {
View Full Code Here

     */
    public String getAvatarURL(String commentUser) throws ClientException {
        String url = VirtualHostHelper.getContextPathProperty()
                + "/icons/missing_avatar.png";
        UserProfileService userProfileService = Framework.getLocalService(UserProfileService.class);
        DocumentModel userProfileDoc = userProfileService.getUserProfileDocument(
                commentUser, ctx.getCoreSession());
        if (userProfileDoc == null) {
            return url;
        }

        if (userProfileDoc.getPropertyValue(AVATAR_PROPERTY) != null) {
            url = VirtualHostHelper.getContextPathProperty()
                    + "/"
                    + DocumentModelFunctions.fileUrl("downloadFile",
                            userProfileDoc, AVATAR_PROPERTY, "avatar");
        }
View Full Code Here

                relationshipService.getTargetsWithFulltext(user1, read, pattern).size());

    }

    protected DocumentModel createUser(String username) throws ClientException {
        DocumentModel user = userManager.getBareUserModel();
        user.setPropertyValue("user:username", username);
        try {
            return userManager.createUser(user);
        } finally {
            session.save();
        }
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.