cancel
Showing results for 
Search instead for 
Did you mean: 

Creating a shortcut (live proxy)?

nerff_
Champ in-the-making
Champ in-the-making

I'd like to create a proxy that always points to the live representation of a document, so that the proxy always reflects the changes to its target (and so edits to the proxy apply to the target).

I see that the javadoc for CoreSession says this for the createProxy() method:

Creates a generic proxy to the given document inside the given folder. The document may be a version, or a working copy (live document) in which case the proxy will be a "shortcut".

My code to create a shortcut does the following:

DocumentModel childWorkingCopyDoc = coreSession.getWorkingCopy(sourceDoc.getRef());
childDoc = coreSession.createProxy(childWorkingCopyDoc.getRef(), destinationDir.getRef());
childDoc = coreSession.createDocument(childDoc);

I use this code in the following way:

  1. Call coreSession.createDocumentModel(), set the dc:title property, and then call coreSession.createDocument(doc) to set up the original document.
  2. Create a shortcut to the document using the above code.
  3. Set additional property values on the original document.
  4. Save the original document.

What I see when viewing the doc and its shortcut in Nuxeo DM after all of this is that the original document has the properties set in step 3, but the shortcut does not.

Am I interpreting "shortcut" in the javadoc incorrectly (does a shortcut always point to the live document or not?) If a shortcut does indeed do what I'd like it to, can you provide a code snippet that illustrates how to create it correctly?

1 REPLY 1

nerff_
Champ in-the-making
Champ in-the-making

I had copied/pasted my code for creating a new document (step 1 above) to use as the base for my proxy creation code. I changed the above code to:

	DocumentModel childWorkingCopyDoc = coreSession.getWorkingCopy(sourceDoc.getRef());
childDoc = coreSession.createProxy(childWorkingCopyDoc.getRef(), destinationDir.getRef());
coreSession.saveDocument(childDoc);

And now my live proxies work as expected. I can edit the proxy target and see the change reflected in the proxy, and can also edit the proxy and see the change in the target.

Getting started

Find what you came for

We want to make your experience in Hyland Connect as valuable as possible, so we put together some helpful links.