Search code examples
javanuxeo

Rename document in nuxeo


I've a document (folderish) in nuxeo I want to rename. I get the DocumentModel by uid using the API, and I'm trying to chenge the actual nuxeo name so that his path changes (not just like renaming a blob attachment name, the whole folderish should change name)

I tried changing the properties:

DocumentModel cf = this.getCampaignFolder();
cf.setProperty("dublincore", "title", newShortName);

This does seems to change the title, but leaves the nuxeo name unchanged.

I tried changing the path:

cf.setPathInfo(cf.getPathAsString().replaceAll("/[^/]*$", "), newShortName);

but when I save that it says the document doesn't exist.

Can't find a rename or move API either.

How do you rename stuff?

Currently, as a workaround, I am deleting the folder and recreating it.


Solution

  • What is your Nuxeo version?

    There are:

    You could do something like:

    session.move(doc.getRef(), null, newShortName);