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
FieldsModifier and TypeFieldDescriptionstatic final Stringstatic final Stringstatic final Stringstatic final Stringprotected static final StringKey for major version in Document API.protected static final StringKey for minor version in Document API.static final StringFields 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
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected List<VersioningOption> computeRestrictionOptions(String lifeCycleState, String type) voiddoAutomaticVersioning(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.voiddoCheckOut(Document doc) Apply modifications after doing a checkout.voiddoPostCreate(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 voidfollowTransitionByOption(CoreSession session, Document doc, Map<String, Serializable> options) protected longgetMajor(DocumentModel docModel) protected longprotected longgetMinor(DocumentModel docModel) protected longprotected 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 longgetVersion(DocumentModel docModel, String prop) protected longgetVersion(Document doc, String prop) getVersionLabel(DocumentModel docModel) Gets the version label to display for a given document.protected voidincrementByOption(Document doc, VersioningOption option) protected voidincrementMajor(Document doc) protected voidincrementMinor(Document doc) protected booleanisPolicyMatch(VersioningPolicyDescriptor policyDescriptor, DocumentModel previousDocument, DocumentModel currentDocument) booleanisPostSaveDoingCheckIn(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.booleanisPreSaveDoingCheckOut(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 VersioningPolicyDescriptorretrieveMatchingVersioningPolicy(DocumentModel previousDocument, DocumentModel currentDocument, boolean before) protected voidsendEvent(CoreSession session, Document doc, String previousLifecycleState, Map<String, Serializable> options) protected voidSets the initial version on a document.protected voidsetVersion(Document doc, long major, long minor) voidsetVersioningFilters(Map<String, VersioningFilterDescriptor> versioningFilters) Add versioning filtersvoidsetVersioningPolicies(Map<String, VersioningPolicyDescriptor> versioningPolicies) Add versioning policiesvoidsetVersioningRestrictions(Map<String, VersioningRestrictionDescriptor> versioningRestrictions) Add versioning filtersprotected VersioningOptionvalidateOption(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:VersioningServiceGets the version label to display for a given document.- Specified by:
getVersionLabelin 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:VersioningServiceApplies versioning after document creation.- Specified by:
doPostCreatein interfaceVersioningService- Parameters:
doc- the documentoptions- map event info
-
setInitialVersion
Sets the initial version on a document. Can be overridden. -
getSaveOptions
Description copied from interface:VersioningServiceChecks what options are available on a document at save time.- Specified by:
getSaveOptionsin 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:VersioningServiceChecks 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:
isPreSaveDoingCheckOutin interfaceVersioningService- Parameters:
doc- the documentisDirty-trueif there is actual data to saveoption- an option chosen by the user or frameworkoptions- map event info and options- Returns:
trueifVersioningService.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:VersioningServiceApplies versioning options before document save.- Specified by:
doPreSavein interfaceVersioningService- Parameters:
session- the core sessiondoc- the documentisDirty-trueif 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:VersioningServiceChecks 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:
isPostSaveDoingCheckInin interfaceVersioningService- Parameters:
doc- the documentoption- an option chosen by the user or frameworkoptions- map event info- Returns:
trueifVersioningService.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:VersioningServiceApplies 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:
doPostSavein 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:VersioningServiceApplies version increment option and does a checkin.- Specified by:
doCheckInin interfaceVersioningService- Parameters:
doc- the documentoption- an option chosen by the user or frameworkcheckinComment- a checkin comment- Returns:
- the version
-
doCheckOut
Description copied from interface:VersioningServiceApply modifications after doing a checkout.- Specified by:
doCheckOutin interfaceVersioningService- Parameters:
doc- the document
-
setVersioningPolicies
Description copied from interface:ExtendableVersioningServiceAdd versioning policies- Specified by:
setVersioningPoliciesin interfaceExtendableVersioningService
-
setVersioningFilters
Description copied from interface:ExtendableVersioningServiceAdd versioning filters- Specified by:
setVersioningFiltersin interfaceExtendableVersioningService
-
setVersioningRestrictions
public void setVersioningRestrictions(Map<String, VersioningRestrictionDescriptor> versioningRestrictions) Description copied from interface:ExtendableVersioningServiceAdd versioning filters- Specified by:
setVersioningRestrictionsin interfaceExtendableVersioningService- Parameters:
versioningRestrictions- the restrictions to apply in versioning system
-
doAutomaticVersioning
public void doAutomaticVersioning(DocumentModel previousDocument, DocumentModel currentDocument, boolean before) Description copied from interface:VersioningServiceDoes 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:
doAutomaticVersioningin interfaceVersioningService- Parameters:
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)
-