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 String
APPROVED_STATE
protected static String
AUTO_CHECKED_OUT
Deprecated.since 9.1 seems unusedstatic String
BACK_TO_PROJECT_TRANSITION
static String
CATEGORY
static String
COMMENT
protected static String
COMPAT_DEFAULT_ID
protected static String
COMPAT_ID_PREFIX
protected static int
DEFAULT_FORMER_RULE_ORDER
static String
FILE_TYPE
Deprecated.since 9.1 seems unusedprotected static String
MAJOR_VERSION
Key for major version in Document API.protected static String
MINOR_VERSION
Key for minor version in Document API.static String
NOTE_TYPE
Deprecated.since 9.1 seems unusedstatic String
OBSOLETE_STATE
static String
PROJECT_STATE
Deprecated.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: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
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:VersioningService
Applies versioning after document creation.- Specified by:
doPostCreate
in 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: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
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: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
public Document doCheckIn(Document doc, VersioningOption option, String checkinComment)
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
public void doCheckOut(Document doc)
Description copied from interface:VersioningService
Apply modifications after doing a checkout.- Specified by:
doCheckOut
in interfaceVersioningService
- Parameters:
doc
- the document
-
getVersioningRules
@Deprecated public Map<String,VersioningRuleDescriptor> getVersioningRules()
Deprecated.- Specified by:
getVersioningRules
in 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:ExtendableVersioningService
Add versioning rules for specific types.- Specified by:
setVersioningRules
in interfaceExtendableVersioningService
-
setDefaultVersioningRule
@Deprecated public void setDefaultVersioningRule(DefaultVersioningRuleDescriptor defaultVersioningRule)
Deprecated.Description copied from interface:ExtendableVersioningService
Set the default versioning rule for all document type.- Specified by:
setDefaultVersioningRule
in interfaceExtendableVersioningService
-
setVersioningPolicies
public void setVersioningPolicies(Map<String,VersioningPolicyDescriptor> versioningPolicies)
Description copied from interface:ExtendableVersioningService
Add versioning policies- Specified by:
setVersioningPolicies
in interfaceExtendableVersioningService
-
setVersioningFilters
public void setVersioningFilters(Map<String,VersioningFilterDescriptor> versioningFilters)
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)
-
-