private String generateCacheControl ( Map < MediaType , String > cacheControlMap , String contentType ) { ArrayList < MediaType > mediaTypesList = new ArrayList < MediaType > ( cacheControlMap . keySet ( ) ) ; Collections . sort ( mediaTypesList , MediaTypeHelper . MEDIA_TYPE_COMPARATOR ) ; String cacheControlValue = "no-cache" ; if ( contentType == null || contentType . equals ( "" ) ) { return cacheControlValue ; } for ( MediaType mediaType : mediaTypesList ) { if ( contentType . equals ( MediaType . WILDCARD ) ) { cacheControlValue = cacheControlMap . get ( MediaType . WILDCARD_TYPE ) ; break ; } else if ( mediaType . isCompatible ( new MediaType ( contentType . split ( "/" ) [ 0 ] , contentType . split ( "/" ) [ 1 ] ) ) ) { cacheControlValue = cacheControlMap . get ( mediaType ) ; break ; } } return cacheControlValue ; }
Generates the value of Cache - Control header according to the content type .