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
VersionAwareAmetysObject
s, and compare some versions.-
Field Summary
Modifier and TypeFieldDescriptionprotected AmetysObjectResolver
The ametys object resolverprotected ContentComparator
The content comparatorstatic final String
Avalon Role -
Constructor Summary
-
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 theContentComparatorChange
s, with some of them filtered (such assomeRichText/lastModified
), because they can be considered as "false positive", from the givenContentComparatorChange
sgetChangedModelItems
(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
<C extends Content & VersionAwareAmetysObject>
CgetContentVersion
(String contentId, String version) Gets the given version of the givenContent
odgetCurrentVersion
(VersionAwareAmetysObject versionable) Gets the current version of the givenVersionAwareAmetysObject
getLastVersionWithLabel
(VersionAwareAmetysObject versionable, String label) Gets the last version of the givenVersionAwareAmetysObject
with the given labelgetNewestVersion
(VersionAwareAmetysObject versionable) Gets the current version of the givenVersionAwareAmetysObject
getPreviousVersion
(VersionAwareAmetysObject versionable) Gets the previous version of the givenVersionAwareAmetysObject
void
service
(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:
service
in 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 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
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
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
-