Package org.ametys.cms.content.version
Class CompareVersionHelper
- java.lang.Object
-
- org.ametys.cms.content.version.CompareVersionHelper
-
- All Implemented Interfaces:
Component
,Serviceable
public class CompareVersionHelper extends Object implements Component, Serviceable
Helper for retrieving some useful version informations aboutVersionAwareAmetysObject
s, and compare some versions.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static class
CompareVersionHelper.AttributeModelChange
-
Field Summary
Fields Modifier and Type Field Description protected AmetysObjectResolver
_ametysObjectResolver
The ametys object resolverprotected ContentComparator
_contentComparator
The content comparatorstatic String
ROLE
Avalon Role
-
Constructor Summary
Constructors Constructor Description CompareVersionHelper()
-
Method Summary
-
-
-
Field Detail
-
_ametysObjectResolver
protected AmetysObjectResolver _ametysObjectResolver
The ametys object resolver
-
_contentComparator
protected ContentComparator _contentComparator
The content comparator
-
-
Constructor Detail
-
CompareVersionHelper
public CompareVersionHelper()
-
-
Method Detail
-
service
public void service(ServiceManager manager) throws ServiceException
- Specified by:
service
in interfaceServiceable
- Throws:
ServiceException
-
getCurrentVersion
public String getCurrentVersion(VersionAwareAmetysObject versionable)
Gets the current version of the givenVersionAwareAmetysObject
- Parameters:
versionable
- TheVersionAwareAmetysObject
- Returns:
- The current version
-
getPreviousVersion
public Optional<String> getPreviousVersion(VersionAwareAmetysObject versionable)
Gets the previous version of the givenVersionAwareAmetysObject
- Parameters:
versionable
- TheVersionAwareAmetysObject
- Returns:
- The previous version
-
getLastVersionWithLabel
public Optional<String> getLastVersionWithLabel(VersionAwareAmetysObject versionable, String label)
Gets the last version of the givenVersionAwareAmetysObject
with the given label- Parameters:
versionable
- TheVersionAwareAmetysObject
label
- The label- Returns:
- the last version
-
compareVersions
public <C extends Content & VersionAwareAmetysObject> ContentComparatorResult compareVersions(String versionableContentId, String baseVersion, String version) throws AmetysRepositoryException, IOException
Compare two versions of the same content- Type Parameters:
C
- The type of theVersionAwareAmetysObject
Content
- Parameters:
versionableContentId
- TheContent
id to compare, which isVersionAwareAmetysObject
baseVersion
- The base versionversion
- The version to be compared- Returns:
- The
ContentComparatorResult
- Throws:
AmetysRepositoryException
- repository exceptionIOException
- IO exception
-
getContentVersion
public <C extends Content & VersionAwareAmetysObject> C getContentVersion(String contentId, String version)
Gets the given version of the givenContent
od- Type Parameters:
C
- The type of theVersionAwareAmetysObject
Content
- Parameters:
contentId
- TheContent
idversion
- The version. Can be null for current version- Returns:
- the given version of the given
Content
od
-
getChangedModelItems
public Stream<ModelItem> getChangedModelItems(List<ContentComparatorChange> changes)
Gets the attribute changes (asModelItem
s) from the givenContentComparatorChange
s (as aContentComparatorChange
path can be more detailed than amodel item path
)
The false positive changes are alsofiltered
- Parameters:
changes
- TheContentComparatorChange
s- Returns:
- The changed
ModelItem
s
-
filterChanges
public Stream<ContentComparatorChange> filterChanges(List<ContentComparatorChange> changes)
Gets theContentComparatorChange
s, with some of them filtered (such assomeRichText/lastModified
), because they can be considered as "false positive", from the givenContentComparatorChange
s- Parameters:
changes
- TheContentComparatorChange
s- Returns:
- The filtered changed
ContentComparatorChange
s
-
_filterChanges
private Stream<CompareVersionHelper.AttributeModelChange> _filterChanges(List<ContentComparatorChange> changes)
-
_getAttributeModelChange
private CompareVersionHelper.AttributeModelChange _getAttributeModelChange(ContentComparatorChange contentComparatorChange)
-
_attributeModelChangeFilters
private static Predicate<CompareVersionHelper.AttributeModelChange> _attributeModelChangeFilters()
-
_filterContentComparatorChange
private static boolean _filterContentComparatorChange(ContentComparatorChange contentComparatorChange)
-
_isLastModifiedOnRichText
private static boolean _isLastModifiedOnRichText(ContentComparatorChange contentComparatorChange)
-
-