Package org.ametys.cms.content.version
Class CompareVersionHelper
java.lang.Object
org.ametys.cms.content.version.CompareVersionHelper
- All Implemented Interfaces:
Component,Serviceable
Helper for retrieving some useful version informations about
VersionAwareAmetysObjects, and compare some versions.-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected AmetysObjectResolverThe ametys object resolverprotected ContentComparatorThe content comparatorstatic final StringAvalon Role -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription<C extends Content & VersionAwareAmetysObject>
ContentComparatorResultcompareVersions(String versionableContentId, String baseVersion, String version) Compare two versions of the same contentfilterChanges(List<ContentComparatorChange> changes) Gets theContentComparatorChanges, with some of them filtered (such assomeRichText/lastModified), because they can be considered as "false positive", from the givenContentComparatorChangesgetChangedModelItems(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 givenContentodgetCurrentVersion(VersionAwareAmetysObject versionable) Gets the current version of the givenVersionAwareAmetysObjectgetLastVersionWithLabel(VersionAwareAmetysObject versionable, String label) Gets the last version of the givenVersionAwareAmetysObjectwith the given labelgetNewestVersion(VersionAwareAmetysObject versionable) Gets the current version of the givenVersionAwareAmetysObjectgetPreviousVersion(VersionAwareAmetysObject versionable) Gets the previous version of the givenVersionAwareAmetysObjectvoidservice(ServiceManager manager)
-
Field Details
-
ROLE
Avalon Role -
_ametysObjectResolver
The ametys object resolver -
_contentComparator
The content comparator
-
-
Constructor Details
-
CompareVersionHelper
public CompareVersionHelper()
-
-
Method Details
-
service
- Specified by:
servicein interfaceServiceable- Throws:
ServiceException
-
getNewestVersion
Gets the current version of the givenVersionAwareAmetysObject- Parameters:
versionable- TheVersionAwareAmetysObject- Returns:
- The current version
-
getCurrentVersion
Gets the current version of the givenVersionAwareAmetysObject- Parameters:
versionable- TheVersionAwareAmetysObject- Returns:
- The current version
-
getPreviousVersion
Gets the previous version of the givenVersionAwareAmetysObject- Parameters:
versionable- TheVersionAwareAmetysObject- Returns:
- The previous version. Can be null.
-
getLastVersionWithLabel
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 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 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
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
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
-