Package org.nuxeo.ecm.core.versioning
Class StandardVersioningService
java.lang.Object
org.nuxeo.ecm.core.versioning.StandardVersioningService
- All Implemented Interfaces:
VersioningService
,ExtendableVersioningService
Implementation of the versioning service that follows standard checkout / checkin semantics.
-
Field Summary
Modifier and TypeFieldDescriptionstatic final String
static final String
static final String
static final String
protected static final String
Key for major version in Document API.protected static final String
Key for minor version in Document API.static final String
Fields inherited from interface org.nuxeo.ecm.core.api.versioning.VersioningService
CHECKIN_COMMENT, DISABLE_AUTO_CHECKOUT, DISABLE_AUTOMATIC_VERSIONING, MAJOR_VERSION_PROP, MINOR_VERSION_PROP, SKIP_VERSIONING, VERSIONING_OPTION
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected List<VersioningOption>
computeRestrictionOptions
(String lifeCycleState, String type) void
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.protected void
followTransitionByOption
(CoreSession session, Document doc, Map<String, Serializable> options) protected long
getMajor
(DocumentModel docModel) protected long
protected long
getMinor
(DocumentModel docModel) protected long
protected List<VersioningOption>
getSaveOptions
(boolean versionable, String lifeCycleState, String type) getSaveOptions
(DocumentModel docModel) Checks what options are available on a document at save time.protected List<VersioningOption>
getSaveOptions
(Document doc) protected long
getVersion
(DocumentModel docModel, String prop) protected long
getVersion
(Document doc, String prop) getVersionLabel
(DocumentModel docModel) Gets the version label to display for a given document.protected void
incrementByOption
(Document doc, VersioningOption option) protected void
incrementMajor
(Document doc) protected void
incrementMinor
(Document doc) protected boolean
isPolicyMatch
(VersioningPolicyDescriptor policyDescriptor, DocumentModel previousDocument, DocumentModel currentDocument) boolean
isPostSaveDoingCheckIn
(Document doc, VersioningOption option, Map<String, Serializable> options) Checks ifVersioningService.doPostSave(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 ifVersioningService.doPreSave(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.protected VersioningPolicyDescriptor
retrieveMatchingVersioningPolicy
(DocumentModel previousDocument, DocumentModel currentDocument, boolean before) protected void
sendEvent
(CoreSession session, Document doc, String previousLifecycleState, Map<String, Serializable> options) protected void
Sets the initial version on a document.protected void
setVersion
(Document doc, long major, long minor) void
setVersioningFilters
(Map<String, VersioningFilterDescriptor> versioningFilters) Add versioning filtersvoid
setVersioningPolicies
(Map<String, VersioningPolicyDescriptor> versioningPolicies) Add versioning policiesvoid
setVersioningRestrictions
(Map<String, VersioningRestrictionDescriptor> versioningRestrictions) Add versioning filtersprotected VersioningOption
validateOption
(Document doc, VersioningOption option)
-
Field Details
-
APPROVED_STATE
- See Also:
-
OBSOLETE_STATE
- See Also:
-
BACK_TO_PROJECT_TRANSITION
- See Also:
-
MAJOR_VERSION
Key for major version in Document API.- See Also:
-
MINOR_VERSION
Key for minor version in Document API.- See Also:
-
CATEGORY
- Since:
- 9.3
- See Also:
-
COMMENT
- Since:
- 9.3
- See Also:
-
-
Constructor Details
-
StandardVersioningService
public StandardVersioningService()
-
-
Method Details
-
getVersionLabel
Description copied from interface:VersioningService
Gets the version label to display for a given document.- Specified by:
getVersionLabel
in interfaceVersioningService
- Parameters:
docModel
- the document- Returns:
- the version label, like
"2.1"
-
getMajor
-
getMinor
-
getVersion
-
getMajor
-
getMinor
-
getVersion
-
setVersion
-
incrementMajor
-
incrementMinor
-
incrementByOption
-
doPostCreate
Description copied from interface:VersioningService
Applies versioning after document creation.- Specified by:
doPostCreate
in interfaceVersioningService
- Parameters:
doc
- the documentoptions
- map event info
-
setInitialVersion
Sets the initial version on a document. Can be overridden. -
getSaveOptions
Description copied from interface:VersioningService
Checks what options are available on a document at save time.- Specified by:
getSaveOptions
in interfaceVersioningService
- Parameters:
docModel
- the document- Returns:
- the options, the first being the default
-
getSaveOptions
-
getSaveOptions
protected List<VersioningOption> getSaveOptions(boolean versionable, String lifeCycleState, String type) -
computeRestrictionOptions
-
validateOption
-
isPreSaveDoingCheckOut
public boolean isPreSaveDoingCheckOut(Document doc, boolean isDirty, VersioningOption option, Map<String, Serializable> options) Description copied from interface:VersioningService
Checks ifVersioningService.doPreSave(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.
- Specified by:
isPreSaveDoingCheckOut
in interfaceVersioningService
- 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
ifVersioningService.doPreSave(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
public VersioningOption doPreSave(CoreSession session, Document doc, boolean isDirty, VersioningOption option, String checkinComment, Map<String, Serializable> options) Description copied from interface:VersioningService
Applies versioning options before document save.- Specified by:
doPreSave
in interfaceVersioningService
- 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)
-
followTransitionByOption
protected void followTransitionByOption(CoreSession session, Document doc, Map<String, Serializable> options) -
isPostSaveDoingCheckIn
public boolean isPostSaveDoingCheckIn(Document doc, VersioningOption option, Map<String, Serializable> options) Description copied from interface:VersioningService
Checks ifVersioningService.doPostSave(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.- Specified by:
isPostSaveDoingCheckIn
in interfaceVersioningService
- Parameters:
doc
- the documentoption
- an option chosen by the user or frameworkoptions
- map event info- Returns:
true
ifVersioningService.doPostSave(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
public Document doPostSave(CoreSession session, Document doc, VersioningOption option, String checkinComment, Map<String, Serializable> options) Description copied from interface:VersioningService
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.- Specified by:
doPostSave
in interfaceVersioningService
- 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
-
doCheckIn
Description copied from interface:VersioningService
Applies version increment option and does a checkin.- Specified by:
doCheckIn
in interfaceVersioningService
- Parameters:
doc
- the documentoption
- an option chosen by the user or frameworkcheckinComment
- a checkin comment- Returns:
- the version
-
doCheckOut
Description copied from interface:VersioningService
Apply modifications after doing a checkout.- Specified by:
doCheckOut
in interfaceVersioningService
- Parameters:
doc
- the document
-
setVersioningPolicies
Description copied from interface:ExtendableVersioningService
Add versioning policies- Specified by:
setVersioningPolicies
in interfaceExtendableVersioningService
-
setVersioningFilters
Description copied from interface:ExtendableVersioningService
Add versioning filters- Specified by:
setVersioningFilters
in interfaceExtendableVersioningService
-
setVersioningRestrictions
public void setVersioningRestrictions(Map<String, VersioningRestrictionDescriptor> versioningRestrictions) Description copied from interface:ExtendableVersioningService
Add versioning filters- Specified by:
setVersioningRestrictions
in interfaceExtendableVersioningService
- Parameters:
versioningRestrictions
- the restrictions to apply in versioning system
-
doAutomaticVersioning
public void doAutomaticVersioning(DocumentModel previousDocument, DocumentModel currentDocument, boolean before) Description copied from interface:VersioningService
Does automatic versioning if a policy exists for the current input context. Currently automatic versioning is either before or after document update, never both.- Specified by:
doAutomaticVersioning
in interfaceVersioningService
before
- the flag to trigger a before or after automatic versioning (used to retrieve the right policy)
-
retrieveMatchingVersioningPolicy
protected VersioningPolicyDescriptor retrieveMatchingVersioningPolicy(DocumentModel previousDocument, DocumentModel currentDocument, boolean before) -
isPolicyMatch
protected boolean isPolicyMatch(VersioningPolicyDescriptor policyDescriptor, DocumentModel previousDocument, DocumentModel currentDocument) -
sendEvent
protected void sendEvent(CoreSession session, Document doc, String previousLifecycleState, Map<String, Serializable> options)
-