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 aboutVersionAwareAmetysObjects, and compare some versions.
-
-
Field Summary
Fields Modifier and Type Field Description protected AmetysObjectResolver_ametysObjectResolverThe ametys object resolverprotected ContentComparator_contentComparatorThe content comparatorstatic StringROLEAvalon Role
-
Constructor Summary
Constructors Constructor Description CompareVersionHelper()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description <C extends Content & VersionAwareAmetysObject>
ContentComparatorResultcompareVersions(String versionableContentId, String baseVersion, String version)Compare two versions of the same contentStream<ContentComparatorChange>filterChanges(List<ContentComparatorChange> changes)Gets theContentComparatorChanges, with some of them filtered (such assomeRichText/lastModified), because they can be considered as "false positive", from the givenContentComparatorChangesStream<ModelItem>getChangedModelItems(List<ContentComparatorChange> changes)Gets the attribute changes (asModelItems) from the givenContentComparatorChanges (as aContentComparatorChangepath can be more detailed than amodel item path)
The false positive changes are alsofiltered<C extends Content & VersionAwareAmetysObject>
CgetContentVersion(String contentId, String version)Gets the given version of the givenContentodStringgetCurrentVersion(VersionAwareAmetysObject versionable)Gets the current version of the givenVersionAwareAmetysObjectOptional<String>getLastVersionWithLabel(VersionAwareAmetysObject versionable, String label)Gets the last version of the givenVersionAwareAmetysObjectwith the given labelOptional<String>getPreviousVersion(VersionAwareAmetysObject versionable)Gets the previous version of the givenVersionAwareAmetysObjectvoidservice(ServiceManager manager)
-
-
-
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:
servicein 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 givenVersionAwareAmetysObjectwith the given label- Parameters:
versionable- TheVersionAwareAmetysObjectlabel- 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 theVersionAwareAmetysObjectContent- Parameters:
versionableContentId- TheContentid to compare, which isVersionAwareAmetysObjectbaseVersion- 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 givenContentod- Type Parameters:
C- The type of theVersionAwareAmetysObjectContent- Parameters:
contentId- TheContentidversion- The version. Can be null for current version- Returns:
- the given version of the given
Contentod
-
getChangedModelItems
public Stream<ModelItem> getChangedModelItems(List<ContentComparatorChange> changes)
Gets the attribute changes (asModelItems) from the givenContentComparatorChanges (as aContentComparatorChangepath can be more detailed than amodel item path)
The false positive changes are alsofiltered- Parameters:
changes- TheContentComparatorChanges- Returns:
- The changed
ModelItems
-
filterChanges
public Stream<ContentComparatorChange> filterChanges(List<ContentComparatorChange> changes)
Gets theContentComparatorChanges, with some of them filtered (such assomeRichText/lastModified), because they can be considered as "false positive", from the givenContentComparatorChanges- Parameters:
changes- TheContentComparatorChanges- Returns:
- The filtered changed
ContentComparatorChanges
-
-