Package org.nuxeo.ecm.core.api

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


        boolean isSearch = queryText != null && queryText.trim().length() > 0;

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


    @POST
    @Path("publishDocument")
    public Object publishDocument(@Context HttpServletRequest request)
            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

    public Object deleteDocument(@Context HttpServletRequest request)
            throws Exception {
        FormData formData = new FormData(request);
        String target = formData.getString("targetRef");
        DocumentRef docRef = getDocumentRef(target);
        CoreSession session = ctx.getCoreSession();

        if (session.getAllowedStateTransitions(docRef).contains(
                DELETE_TRANSITION)) {
            session.followTransition(docRef, DELETE_TRANSITION);
        } else {
            session.removeDocument(docRef);
        }
       
        // Must save session to ensure that currentLifeCycleState is updated
        session.save();
           
        return documentList(request);
    }
View Full Code Here

    public Object createDocumentForm(@QueryParam("docRef") String ref,
            @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

    @Path("selectDocTypeToCreate")
    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);
View Full Code Here

     */
    @POST
    @Path("createDocument")
    public Object createDocument(@Context HttpServletRequest request)
            throws Exception {
        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

        }
    }

    protected static PaginableDocumentModelList getChildren(DocumentModel doc,
            int pageSize, int page) throws Exception {
        CoreSession session = doc.getCoreSession();

        OperationContext ctx = new OperationContext(session);
        OperationChain chain = new OperationChain("getChildren");

        String query = "SELECT * FROM Document "
View Full Code Here

                chain);
    }

    protected static PaginableDocumentModelList search(DocumentModel doc,
            int pageSize, int page, String queryText) throws Exception {
        CoreSession session = doc.getCoreSession();

        OperationContext ctx = new OperationContext(session);
        OperationChain chain = new OperationChain("search");

        String escapedQueryText = NXQLQueryBuilder.prepareStringLiteral(
View Full Code Here

     * SocialWorkspace.
     */
    protected static List<DocumentModel> getAncestors(DocumentModel doc)
            throws ClientException {
        List<DocumentModel> list = new ArrayList<DocumentModel>();
        CoreSession session = doc.getCoreSession();
        list.add(doc);
        while (doc != null && !isSocialWorkspace(doc)) {
            doc = session.getParentDocument(doc.getRef());
            list.add(0, doc);
        }
        return list;
    }
View Full Code Here

        List<String> docsIdResult = new ArrayList<String>();
        if (docs.isEmpty()) {
            return docsIdResult;
        }

        CoreSession session = docs.get(0).getCoreSession();
        for (DocumentModel doc : docs) {
            if (session.hasPermission(doc.getRef(), REMOVE)
                    && session.hasPermission(
                            session.getParentDocumentRef(doc.getRef()),
                            REMOVE_CHILDREN)) {
                docsIdResult.add(doc.getId());
            }
        }
View Full Code Here

TOP

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

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.