thanks, it works now.

Olivier Grisel wrote:
Vincent Dutat a écrit :
Hi,

I created a 2 document types with folderish facet and some other schemas
(let's call them doctypeA and doctypeB). I would like that a document of
doctypeB is automatically created in all documents of doctypeA when they
are created. I thought that a core event listener was a good way to
achieve this. This core event listener receives an event
'documentCreated' on a document of type doctypeA and create a document
of type doctypeB as a child of it. But I get exception saying that
document of typr doctypeA does not exist, strange. My listener's class
is AddMrLeadFoldersListener. Created document's title is 'lead 2'. Here
is the exception :

This might be because you are trying to create children in a new transaction
that is concurrent to the one that creates the folder. To reuse the same
CoreSession you can try to do something along the lines:

    public void notifyEvent(CoreEvent event) {

        String eventId = event.getEventId();
        Object ob = event.getSource();

        if (!(ob instanceof Document)) {
            return;
        }
        Document doc = (Document) ob;
        Session session = doc.getSession();
        String sid = session.getUserSessionId();

        CoreSession session = CoreInstance.getInstance().getSession(
                managedSessionId);
        // do the creation of your children here

        // do not close the session as it will be probably be used
        // by other core event listener afterward

    }

_______________________________________________
ECM mailing list
[email protected]
http://lists.nuxeo.com/mailman/listinfo/ecm

Reply via email to