public static TranslatedContentSpecWrapper getClosestTranslatedContentSpecById ( final DataProviderFactory providerFactory , final Integer id , final Integer rev ) { final CollectionWrapper < TranslatedContentSpecWrapper > translatedContentSpecs = providerFactory . getProvider ( ContentSpecProvider . class ) . getContentSpec ( id , rev ) . getTranslatedContentSpecs ( ) ; TranslatedContentSpecWrapper closestTranslation = null ; if ( translatedContentSpecs != null && translatedContentSpecs . getItems ( ) != null ) { final List < TranslatedContentSpecWrapper > entities = translatedContentSpecs . getItems ( ) ; for ( final TranslatedContentSpecWrapper translatedContentSpec : entities ) { if ( // Ensure that the translation is the newest translation possible ( closestTranslation == null || closestTranslation . getContentSpecRevision ( ) < translatedContentSpec . getContentSpecRevision ( ) ) // Ensure that the translation revision is less than or equal to the revision specified && ( rev == null || translatedContentSpec . getContentSpecRevision ( ) <= rev ) ) { closestTranslation = translatedContentSpec ; } } } return closestTranslation ; }
Gets a translated content spec based on a id and revision . The translated content spec that is returned will be less then or equal to the revision that is passed . If the revision is null then the latest translated content spec will be returned .