Interface VersioningService
- All Known Subinterfaces:
ExtendableVersioningService
- All Known Implementing Classes:
StandardVersioningService
,VersioningComponent
public interface VersioningService
The versioning service holds the versioning policy used to define what happens to a document's version when it is
created, saved, checked in, checked out or restored, and what version increment options (none, minor, major) are made
available to the user.
- Since:
- 5.4
-
Field Summary
Modifier and TypeFieldDescriptionstatic final String
Context data to provide a checkin comment for operations that potentially check in (save, publish, checkin).static final String
Context data to disable auto-checkout of checked-in documents at pre-save time.static final String
Context data to disable the automatic versioning engine.static final String
Document property in which the major version is stored.static final String
Document property in which the minor version is stored.static final String
Context data that can be used to skip versioning on document creation, in case the supplied version is enough.static final String
Context data to provide a user-level choice to the versioning policy. -
Method Summary
Modifier and TypeMethodDescriptionvoid
doAutomaticVersioning
(DocumentModel previousDocument, DocumentModel currentDocument, boolean before) Does automatic versioning if a policy exists for the current input context.doCheckIn
(Document doc, VersioningOption option, String checkinComment) Applies version increment option and does a checkin.void
doCheckOut
(Document doc) Apply modifications after doing a checkout.void
doPostCreate
(Document doc, Map<String, Serializable> options) Applies versioning after document creation.doPostSave
(CoreSession session, Document doc, VersioningOption option, String checkinComment, Map<String, Serializable> options) Applies versioning options after document save.doPreSave
(CoreSession session, Document doc, boolean isDirty, VersioningOption option, String checkinComment, Map<String, Serializable> options) Applies versioning options before document save.Checks what options are available on a document at save time.Gets the version label to display for a given document.boolean
isPostSaveDoingCheckIn
(Document doc, VersioningOption option, Map<String, Serializable> options) Checks ifdoPostSave(org.nuxeo.ecm.core.api.CoreSession, org.nuxeo.ecm.core.model.Document, org.nuxeo.ecm.core.api.VersioningOption, java.lang.String, java.util.Map<java.lang.String, java.io.Serializable>)
will do a checkin when called with the same arguments.boolean
isPreSaveDoingCheckOut
(Document doc, boolean isDirty, VersioningOption option, Map<String, Serializable> options) Checks ifdoPreSave(org.nuxeo.ecm.core.api.CoreSession, org.nuxeo.ecm.core.model.Document, boolean, org.nuxeo.ecm.core.api.VersioningOption, java.lang.String, java.util.Map<java.lang.String, java.io.Serializable>)
will do a checkout when called with the same arguments.
-
Field Details
-
MAJOR_VERSION_PROP
Document property in which the major version is stored.- See Also:
-
MINOR_VERSION_PROP
Document property in which the minor version is stored.- See Also:
-
SKIP_VERSIONING
Context data that can be used to skip versioning on document creation, in case the supplied version is enough.- See Also:
-
VERSIONING_OPTION
Context data to provide a user-level choice to the versioning policy. Value is aVersioningOption
.- See Also:
-
DISABLE_AUTO_CHECKOUT
Context data to disable auto-checkout of checked-in documents at pre-save time. This option should only be used when updating a facet that's considered pure metadata and holds information about the document but external to it. Value is aBoolean
.- Since:
- 5.7, 5.6.0-HF09
- See Also:
-
CHECKIN_COMMENT
Context data to provide a checkin comment for operations that potentially check in (save, publish, checkin).- See Also:
-
DISABLE_AUTOMATIC_VERSIONING
Context data to disable the automatic versioning engine.- Since:
- 2021.12
- See Also:
-
-
Method Details
-
getVersionLabel
Gets the version label to display for a given document.- Parameters:
doc
- the document- Returns:
- the version label, like
"2.1"
-
getSaveOptions
Checks what options are available on a document at save time.- Parameters:
doc
- the document- Returns:
- the options, the first being the default
-
doPostCreate
Applies versioning after document creation.- Parameters:
doc
- the documentoptions
- map event info
-
isPreSaveDoingCheckOut
boolean isPreSaveDoingCheckOut(Document doc, boolean isDirty, VersioningOption option, Map<String, Serializable> options) Checks ifdoPreSave(org.nuxeo.ecm.core.api.CoreSession, org.nuxeo.ecm.core.model.Document, boolean, org.nuxeo.ecm.core.api.VersioningOption, java.lang.String, java.util.Map<java.lang.String, java.io.Serializable>)
will do a checkout when called with the same arguments.Needed to be able to send "about to checkin" events.
- Parameters:
doc
- the documentisDirty
-true
if there is actual data to saveoption
- an option chosen by the user or frameworkoptions
- map event info and options- Returns:
true
ifdoPreSave(org.nuxeo.ecm.core.api.CoreSession, org.nuxeo.ecm.core.model.Document, boolean, org.nuxeo.ecm.core.api.VersioningOption, java.lang.String, java.util.Map<java.lang.String, java.io.Serializable>)
will do a checkout
-
doPreSave
VersioningOption doPreSave(CoreSession session, Document doc, boolean isDirty, VersioningOption option, String checkinComment, Map<String, Serializable> options) Applies versioning options before document save.- Parameters:
session
- the core sessiondoc
- the documentisDirty
-true
if there is actual data to saveoption
- an option chosen by the user or frameworkcheckinComment
- a checkin commentoptions
- map event info- Returns:
- the validated option (to use in doPostSave)
- Since:
- 9.3
-
isPostSaveDoingCheckIn
boolean isPostSaveDoingCheckIn(Document doc, VersioningOption option, Map<String, Serializable> options) Checks ifdoPostSave(org.nuxeo.ecm.core.api.CoreSession, org.nuxeo.ecm.core.model.Document, org.nuxeo.ecm.core.api.VersioningOption, java.lang.String, java.util.Map<java.lang.String, java.io.Serializable>)
will do a checkin when called with the same arguments.- Parameters:
doc
- the documentoption
- an option chosen by the user or frameworkoptions
- map event info- Returns:
true
ifdoPostSave(org.nuxeo.ecm.core.api.CoreSession, org.nuxeo.ecm.core.model.Document, org.nuxeo.ecm.core.api.VersioningOption, java.lang.String, java.util.Map<java.lang.String, java.io.Serializable>)
will do a checkin
-
doPostSave
Document doPostSave(CoreSession session, Document doc, VersioningOption option, String checkinComment, Map<String, Serializable> options) Applies versioning options after document save. If a new version is checked in during the operation, the document for this version is returned to the caller.- Parameters:
session
- the core sessiondoc
- the documentoption
- an option chosen by the user or frameworkcheckinComment
- a checkin commentoptions
- map event info- Returns:
- checkedInDocument or null
- Since:
- 9.3
-
doCheckIn
Applies version increment option and does a checkin.- Parameters:
doc
- the documentoption
- an option chosen by the user or frameworkcheckinComment
- a checkin comment- Returns:
- the version
-
doCheckOut
Apply modifications after doing a checkout.- Parameters:
doc
- the document
-
doAutomaticVersioning
void doAutomaticVersioning(DocumentModel previousDocument, DocumentModel currentDocument, boolean before) Does automatic versioning if a policy exists for the current input context. Currently automatic versioning is either before or after document update, never both.- Parameters:
before
- the flag to trigger a before or after automatic versioning (used to retrieve the right policy)- Since:
- 9.1
-