Deprecate Document#rename(*) in favor of Refactoring Script Service API

Hi devs,

We currently have 2 scripting APIs to rename a document:

  • Document#rename(*) (e.g. `$doc.rename() in velocity)
  • Refactoring Script Service API (e.g. $services.refactoring.rename() on velocity)

There are several problems:

  • It’s confusing for users
  • It’s harder to maintain 2 apis
  • Both apis are not doing exactly the same things (and the refactoring one is more advanced)

I’m thus proposing to deprecate (and later on legacify) all Document#rename(*) signatures.

Note that this could apply to other methods such as copyDocument() (in api.XWiki) or Document#delete(). However, we could also decide that it’s ok to keep these methods in api.XWiki and api.Document, provided there are no refactoring operations done in them (ie they only rename, copy, delete the doc and don’t modify other docs). If we agree about this, then we could want to keep a Document#rename() method but we’d need to change its implementation which would be a breaking change. So I’m still proposing that we deprecate it.

WDYT?

Thx

+1 for deprecating Document#rename, thanks

+1 for deprecating the current Document#rename

Same, +1.

Thanks,
Marius

Implemented in Loading...

Note that I’ve also marked com.xpn.xwiki.api.XWiki#renameDocument as deprecated, to follow the same logic. But I’ve NOT marked com.xpn.xwiki.XWiki#renameDocumentas deprecated since it’s currently used by the refactoring API (see xwiki-platform/xwiki-platform-core/xwiki-platform-refactoring/xwiki-platform-refactoring-default/src/main/java/org/xwiki/refactoring/internal/DefaultModelBridge.java at be3c1fd48e7c872b178e1eaa89e993b1bc7b7deb · xwiki/xwiki-platform · GitHub ).

Next step will be to move these methods to legacy.

Thanks