Hello all,
I've hitting a weird problem with my plugin code. I am sometimes finding that a
document's parent doesn't exist when accessed by its IdRef but exists when
accessed by its PathRef. I say that it happens sometimes because if I debug
slow enough, I eventually find no such consistency problem. This points to a
race condition problem.
Here is some code snippets which illustrate my problem. The following code
doesn't work.
protected NuxeoMessageManager getMessageManager(DocumentModel targetDoc) {
DocumentRef parentRef;
parentRef = targetDoc.getParentRef();
try {
if (sysSession.getCoreSession().exists(parentRef) {
// Won't enter the if clause.
...
The following works:
protected NuxeoMessageManager getMessageManager(DocumentModel targetDoc) {
DocumentRef parentRef;
String docPathStr = targetDoc.getPathAsString();
Path docPath = Path.createFromAbsolutePath(docPathStr)
Path parentPath = docPath.removeLastSegments(1);
PathRef parentPathRef = new PathRef(parentPath.toString());
try {
if (sysSession.getCoreSession().exists(parentPathRef) {
// This will work.
...
I can live with the second technique but until I understand what is going on, I
can only consider this to be a workaround. I'm using the
DocumentModel.getParentRef() at some other place so understanding this problem
is important to me.
--
François-Denis Gonthier
Programmeur/analyste
819-780-8955 #1128 http://www.revolutionlinux.com/
_______________________________________________
ECM mailing list
[email protected]
http://lists.nuxeo.com/mailman/listinfo/ecm
To unsubscribe, go to http://lists.nuxeo.com/mailman/options/ecm