Package org.nuxeo.ecm.core.versioning
Class StandardVersioningService
- java.lang.Object
-
- org.nuxeo.ecm.core.versioning.StandardVersioningService
-
- All Implemented Interfaces:
VersioningService,ExtendableVersioningService,VersioningService
- Direct Known Subclasses:
CompatVersioningService
public class StandardVersioningService extends Object implements ExtendableVersioningService
Implementation of the versioning service that follows standard checkout / checkin semantics.
-
-
Field Summary
Fields Modifier and Type Field Description static StringAPPROVED_STATEprotected static StringAUTO_CHECKED_OUTDeprecated.since 9.1 seems unusedstatic StringBACK_TO_PROJECT_TRANSITIONstatic StringCATEGORYstatic StringCOMMENTprotected static StringCOMPAT_DEFAULT_IDprotected static StringCOMPAT_ID_PREFIXprotected static intDEFAULT_FORMER_RULE_ORDERstatic StringFILE_TYPEDeprecated.since 9.1 seems unusedprotected static StringMAJOR_VERSIONKey for major version in Document API.protected static StringMINOR_VERSIONKey for minor version in Document API.static StringNOTE_TYPEDeprecated.since 9.1 seems unusedstatic StringOBSOLETE_STATEstatic StringPROJECT_STATEDeprecated.since 9.1 seems unused-
Fields inherited from interface org.nuxeo.ecm.core.api.versioning.VersioningService
CHECKIN_COMMENT, DISABLE_AUTO_CHECKOUT, MAJOR_VERSION_PROP, MINOR_VERSION_PROP, SKIP_VERSIONING, VERSIONING_OPTION
-
-
Constructor Summary
Constructors Constructor Description StandardVersioningService()
-
Method Summary
-
-
-
Field Detail
-
DEFAULT_FORMER_RULE_ORDER
protected static final int DEFAULT_FORMER_RULE_ORDER
- See Also:
- Constant Field Values
-
COMPAT_ID_PREFIX
protected static final String COMPAT_ID_PREFIX
- See Also:
- Constant Field Values
-
COMPAT_DEFAULT_ID
protected static final String COMPAT_DEFAULT_ID
- See Also:
- Constant Field Values
-
FILE_TYPE
@Deprecated public static final String FILE_TYPE
Deprecated.since 9.1 seems unused- See Also:
- Constant Field Values
-
NOTE_TYPE
@Deprecated public static final String NOTE_TYPE
Deprecated.since 9.1 seems unused- See Also:
- Constant Field Values
-
PROJECT_STATE
@Deprecated public static final String PROJECT_STATE
Deprecated.since 9.1 seems unused- See Also:
- Constant Field Values
-
APPROVED_STATE
public static final String APPROVED_STATE
- See Also:
- Constant Field Values
-
OBSOLETE_STATE
public static final String OBSOLETE_STATE
- See Also:
- Constant Field Values
-
BACK_TO_PROJECT_TRANSITION
public static final String BACK_TO_PROJECT_TRANSITION
- See Also:
- Constant Field Values
-
AUTO_CHECKED_OUT
@Deprecated protected static final String AUTO_CHECKED_OUT
Deprecated.since 9.1 seems unused- See Also:
- Constant Field Values
-
MAJOR_VERSION
protected static final String MAJOR_VERSION
Key for major version in Document API.- See Also:
- Constant Field Values
-
MINOR_VERSION
protected static final String MINOR_VERSION
Key for minor version in Document API.- See Also:
- Constant Field Values
-
CATEGORY
public static final String CATEGORY
- Since:
- 9.3
- See Also:
- Constant Field Values
-
COMMENT
public static final String COMMENT
- Since:
- 9.3
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
StandardVersioningService
public StandardVersioningService()
-
-
Method Detail
-
getVersionLabel
public String getVersionLabel(DocumentModel docModel)
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
protected long getMajor(DocumentModel docModel)
-
getMinor
protected long getMinor(DocumentModel docModel)
-
getVersion
protected long getVersion(DocumentModel docModel, String prop)
-
getVersion
protected long getVersion(Document doc, String prop)
-
setVersion
protected void setVersion(Document doc, long major, long minor)
-
incrementMajor
protected void incrementMajor(Document doc)
-
incrementMinor
protected void incrementMinor(Document doc)
-
incrementByOption
protected void incrementByOption(Document doc, VersioningOption option)
-
doPostCreate
public void doPostCreate(Document doc, Map<String,Serializable> options)
Description copied from interface:VersioningServiceApplies versioning after document creation.- Specified by:
doPostCreatein interfaceVersioningService- Parameters:
doc- the documentoptions- map event info
-
setInitialVersion
protected void setInitialVersion(Document doc)
Sets the initial version on a document. Can be overridden.
-
getSaveOptions
public List<VersioningOption> getSaveOptions(DocumentModel docModel)
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
protected List<VersioningOption> getSaveOptions(Document doc)
-
getSaveOptions
protected List<VersioningOption> getSaveOptions(boolean versionable, String lifeCycleState, String type)
-
computeRestrictionOptions
protected List<VersioningOption> computeRestrictionOptions(String lifeCycleState, String type)
-
validateOption
protected VersioningOption validateOption(Document doc, VersioningOption option)
-
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
public Document doCheckIn(Document doc, VersioningOption option, String checkinComment)
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
public void doCheckOut(Document doc)
Description copied from interface:VersioningServiceApply modifications after doing a checkout.- Specified by:
doCheckOutin interfaceVersioningService- Parameters:
doc- the document
-
getVersioningRules
@Deprecated public Map<String,VersioningRuleDescriptor> getVersioningRules()
Deprecated.- Specified by:
getVersioningRulesin interfaceExtendableVersioningService- Returns:
- A Map containing the versioning rule for specific types.
-
setVersioningRules
@Deprecated public void setVersioningRules(Map<String,VersioningRuleDescriptor> versioningRules)
Deprecated.Description copied from interface:ExtendableVersioningServiceAdd versioning rules for specific types.- Specified by:
setVersioningRulesin interfaceExtendableVersioningService
-
setDefaultVersioningRule
@Deprecated public void setDefaultVersioningRule(DefaultVersioningRuleDescriptor defaultVersioningRule)
Deprecated.Description copied from interface:ExtendableVersioningServiceSet the default versioning rule for all document type.- Specified by:
setDefaultVersioningRulein interfaceExtendableVersioningService
-
setVersioningPolicies
public void setVersioningPolicies(Map<String,VersioningPolicyDescriptor> versioningPolicies)
Description copied from interface:ExtendableVersioningServiceAdd versioning policies- Specified by:
setVersioningPoliciesin interfaceExtendableVersioningService
-
setVersioningFilters
public void setVersioningFilters(Map<String,VersioningFilterDescriptor> versioningFilters)
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 interfaceVersioningServicebefore- 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)
-
-