private void verifyIfBundleIsModified ( JoinableResourceBundleImpl bundle , List < String > mappings , PropertiesConfigHelper props ) { // Retrieves current available variant Map < String , VariantSet > variants = new TreeMap <> ( ) ; for ( String mapping : mappings ) { variants = VariantUtils . concatVariants ( variants , generatorRegistry . getAvailableVariants ( mapping ) ) ; } // Checks if the current variant are the same as the stored one if ( ! variants . equals ( bundle . getVariants ( ) ) ) { bundle . setVariants ( variants ) ; bundle . setDirty ( true ) ; } else { String bundleName = bundle . getName ( ) ; List < String > fileMappings = props . getCustomBundlePropertyAsList ( bundleName , PropertiesBundleConstant . BUNDLE_FACTORY_CUSTOM_FILEPATH_MAPPINGS ) ; if ( fileMappings != null ) { List < FilePathMapping > bundleFileMappings = bundle . getFilePathMappings ( ) ; if ( bundleFileMappings . size ( ) != fileMappings . size ( ) ) { bundle . setDirty ( true ) ; } else { Set < FilePathMapping > storedFilePathMapping = new HashSet <> ( ) ; for ( String filePathWithTimeStamp : fileMappings ) { String [ ] tmp = filePathWithTimeStamp . split ( LAST_MODIFIED_SEPARATOR ) ; String filePath = tmp [ 0 ] ; long storedLastModified = Long . parseLong ( tmp [ 1 ] ) ; storedFilePathMapping . add ( new FilePathMapping ( bundle , filePath , storedLastModified ) ) ; } Set < FilePathMapping > bundleFilePathMappingSet = new HashSet <> ( bundleFileMappings ) ; if ( ! bundleFilePathMappingSet . equals ( storedFilePathMapping ) ) { bundle . setDirty ( true ) ; } } } // Checks if the linked resource has been modified fileMappings = props . getCustomBundlePropertyAsList ( bundleName , PropertiesBundleConstant . BUNDLE_FACTORY_CUSTOM_LINKED_FILEPATH_MAPPINGS ) ; for ( String filePathWithTimeStamp : fileMappings ) { int idx = filePathWithTimeStamp . lastIndexOf ( LAST_MODIFIED_SEPARATOR ) ; if ( idx != - 1 ) { String filePath = filePathWithTimeStamp . substring ( 0 , idx ) ; long storedLastModified = Long . parseLong ( filePathWithTimeStamp . substring ( idx + 1 ) ) ; long currentLastModified = rsReaderHandler . getLastModified ( filePath ) ; FilePathMapping fPathMapping = new FilePathMapping ( bundle , filePath , currentLastModified ) ; bundle . getLinkedFilePathMappings ( ) . add ( fPathMapping ) ; if ( storedLastModified != currentLastModified ) { bundle . setDirty ( true ) ; } } } } }
Verify f the bundle has been modified