On 11 Jun 2008, at 13:15, [EMAIL PROTECTED] wrote:
> Hi,
>
> I want to move a document directly after its creation to another
> workspace and then create a proxy to the new location.
>
> Therefore i created a new event "DOCUMENT_WRITTEN",
> (DOCUMENT_CREATED can't be used since the doc is not written at that
> point) which is thrown after the document is completely created.
>
> My event listener is called and I can move the document to another
> workspace without problems. However if I try to get the last version
> of the document in order to create a proxy I'm getting an exception.
>
> I use the following code in the event listener:
>
> ------------------------------------------------------------------------
>
> +CoreSession documentManager =
> CoreInstance.getInstance().open(doc.getRepositoryName(), null);+
This is reopening a new connection (session) to the repository, so as
the original connection has not yet commited you won't see everything.
You should reuse the documentManager of the document. You can call
getClient() on a casted DocumentModelImpl for that.
Florent
>
>
> +DocumentModel source =
> documentManager.getDocument(doc.getParentRef());+
> +DocumentModel t1 =
> documentManager.getDocument(source.getParentRef());+
> +DocumentModel t2 = documentManager.getDocument(t1.getParentRef());+
> +DocumentModel destination = documentManager.getChild( t2.getRef() ,
> "data" );+
>
> +doc.setProperty("custom", "source", source.getRef().toString() );+
> +doc.setProperty("uid", "major_version", 1 );+
> +doc.setProperty("uid", "minor_version", 1 );+
>
> +doc = documentManager.move(doc.getRef(), destination.getRef(),
> null);+
>
>
> +DocumentRef docRef = doc.getRef();+
>
>
>
>
> +VersionModel versionModel = documentManager.getLastVersion(docRef);+
>
> +documentManager.createProxy(source.getRef(), doc.getRef(),
> versionModel , true);+
>
> +documentManager.save();+
>
> ------------------------------------------------------------------------
>
>
> If I break just before the call to getLastVersion() I can step until
>
> +checkPermission(doc, VERSION);+
>
> doc is not null
> VERSION obviously either
>
> If I choose step into a NullPointerException occurs even before I am
> in the method checkPermission.
>
> Anybody has a clue why? Is it some bug, or am I just using
> getLastVersion in a wrong way?
>
> Thanks.
> _______________________________________________
> ECM mailing list
> [email protected]
> http://lists.nuxeo.com/mailman/listinfo/ecm
--
Florent Guillaume, Director of R&D, Nuxeo
Open Source Enterprise Content Management (ECM)
http://www.nuxeo.com http://www.nuxeo.org +33 1 40 33 79 87
_______________________________________________
ECM mailing list
[email protected]
http://lists.nuxeo.com/mailman/listinfo/ecm