Examples of DocumentModel


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

            session.save();
        }
    }

    protected DocumentModel createDoc(String title) throws ClientException {
        DocumentModel doc = session.createDocumentModel("File");
        doc.setProperty("dublincore", "title", title);
        try {
            return session.createDocument(doc);
        } finally {
            session.save();
        }
View Full Code Here

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

    public static SocialWorkspace toSocialWorkspace(DocumentModel doc) {
        return SocialWorkspaceHelper.toSocialWorkspace(doc);
    }

    public boolean isCurrentUserAdministratorOrMemberOfCurrentSocialWorkspace() {
        DocumentModel doc = navigationContext.getCurrentDocument();
        SocialWorkspace socialWorkspace = socialWorkspaceService.getDetachedSocialWorkspace(doc);
        return socialWorkspace != null
                && socialWorkspace.isAdministratorOrMember(currentUser);
    }
View Full Code Here

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

        return socialWorkspace != null
                && socialWorkspace.isAdministratorOrMember(currentUser);
    }

    public boolean isCurrentUserAdministratorOfCurrentSocialWorkspace() {
        DocumentModel doc = navigationContext.getCurrentDocument();
        SocialWorkspace socialWorkspace = socialWorkspaceService.getDetachedSocialWorkspace(doc);
        return socialWorkspace != null
                && socialWorkspace.isAdministrator(currentUser);
    }
View Full Code Here

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

    public SocialWorkspace getSocialWorkspace(DocumentModel doc) {
        return socialWorkspaceService.getDetachedSocialWorkspace(doc);
    }

    public SocialWorkspace getSocialWorkspace() {
        DocumentModel doc = navigationContext.getCurrentDocument();
        return getSocialWorkspace(doc);
    }
View Full Code Here

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

    public void handleEvent(Event event) throws ClientException {
        EventContext ctx = event.getContext();
        if (!(ctx instanceof DocumentEventContext)) {
            return;
        }
        DocumentModel document = ((DocumentEventContext) ctx).getSourceDocument();
        if (!SocialWorkspaceHelper.isSocialDocument(document)) {
            return;
        }

        if (!ctx.hasProperty(TRANSTION_EVENT_OPTION_TRANSITION)) {
View Full Code Here

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

    /**
     * Remove social document publication into social workspace if needed.
     */
    public static void cleanProxy(CoreSession session,
            SocialDocument socialDocument) throws ClientException {
        DocumentModel publicProxy = socialDocument.getPublicDocument();
        if (publicProxy != null) {
            session.removeDocument(publicProxy.getRef());
        } else {
            if (!ARTICLE_TYPE.equals(socialDocument.getType())) {
                // if not public then automatically private !!
                session.removeDocument(socialDocument.getRestrictedDocument().getRef());
            }
View Full Code Here

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

        EventContext ctx = event.getContext();
        if (!(ctx instanceof DocumentEventContext)) {
            return;
        }
        DocumentModel document = ((DocumentEventContext) ctx).getSourceDocument();
        if (document instanceof DeletedDocumentModel) {
            return;
        }

        if (ctx.hasProperty(ALREADY_PROCESSED)) {
            return;
        }

        if (!SocialWorkspaceHelper.isSocialDocument(document)) {
            return;
        }

        SocialWorkspace socialWorkspace = getSocialWorkspaceService().getDetachedSocialWorkspace(
                document);
        if (socialWorkspace == null) {
            // not in a social workspace
            return;
        }

        document.putContextData(ALREADY_PROCESSED, true);

        Boolean isPublic = (Boolean) document.getPropertyValue(SOCIAL_DOCUMENT_IS_PUBLIC_PROPERTY);
        updateSocialDocumentVisibility(document, isPublic == null ? false
                : isPublic);
    }
View Full Code Here

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

        return docView;
    }

    protected DocumentView computeDocumentView(CoreSession session,
            DocumentView docView) throws ClientException {
        DocumentModel doc = session.getDocument(docView.getDocumentLocation().getDocRef());
        // do nothing for the 'public' dashboard (sw/social document)
        if (DASHBOARD_SPACES_CONTAINER_TYPE.equals(doc.getType())) {
            return null;
        }

        if (doc.hasFacet(SOCIAL_WORKSPACE_FACET)) {
            docView.setDocumentLocation(new DocumentLocationImpl(
                    session.getChild(doc.getRef(), "social")));
            docView.setViewId("dashboard");
        } else {
            TypeManager typeService = Framework.getLocalService(TypeManager.class);
            Type type = typeService.getType(doc.getType());
            if (doc.hasFacet(FacetNames.FOLDERISH)
                    || (!typeService.getAllowedSubTypes(SOCIAL_WORKSPACE_TYPE).contains(
                            type) && !typeService.getAllowedSubTypes(
                            NEWS_ITEM_ROOT_TYPE).contains(type))) {
                docView.setViewId(type.getDefaultView());
                docView.addParameter("tabIds", "MAIN_TAB:documents");
View Full Code Here

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

        if (!(event.getContext() instanceof DocumentEventContext)) {
            return;
        }

        DocumentEventContext ctx = (DocumentEventContext) event.getContext();
        DocumentModel doc = ctx.getSourceDocument();

        if (!ARTICLE_TYPE.equals(doc.getType())) {
            return;
        }

        Blob image = (Blob) doc.getPropertyValue(CONTENT_PICTURE_PICTURE_PROPERTY);
        if (image == null) {
            return;
        }

        ImagingService service;
        try {
            service = Framework.getService(ImagingService.class);
        } catch (Exception e) {
            throw new ClientException("Failed to get ImagingService", e);
        }

        ImageInfo info = service.getImageInfo(image);
        int width = info.getWidth();
        int height = info.getHeight();
        float wScale = (float) RESIZED_IMAGE_WIDTH / width;
        float hscale = (float) RESIZED_IMAGE_HEIGHT / height;
        float scale = Math.min(wScale, hscale);

        if (scale < 1) {
            image = service.resize(image, "jpg", (int) (width * scale),
                    (int) (height * scale), info.getDepth());
            image.setMimeType("image/jpeg"); // XXX : Should be automatic
            doc.setPropertyValue(CONTENT_PICTURE_PICTURE_PROPERTY,
                    (Serializable) image);
        }
    }
View Full Code Here

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

        if (!(ctx instanceof DocumentEventContext)) {
            return;
        }

        List<String> allowedTypes = getSocialWorkspaceAllowedSubTypes();
        DocumentModel document = ((DocumentEventContext) ctx).getSourceDocument();
        if (document.hasFacet(FacetNames.FOLDERISH)
                || !allowedTypes.contains(document.getType())) {
            return;
        }

        if (document.getParentRef() == null) {
            return;
        }

        CoreSession session = ctx.getCoreSession();
        DocumentModel documentParent = session.getDocument(document.getParentRef());
        SocialWorkspace sws = getSocialWorkspaceService().getSocialWorkspace(
                documentParent);

        if (sws == null) {
            return;
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.