private String generateContent ( GeneratorContext context , ResourceBundlesHandler bundlesHandler , String bundlePath , Map < String , String > variants ) { // Here we create a new context where the bundle name is the Jawr // generator CSS path String cssGeneratorBundlePath = PathNormalizer . joinPaths ( context . getConfig ( ) . getServletMapping ( ) , ResourceGenerator . CSS_DEBUGPATH ) ; JoinableResourceBundle tempBundle = new JoinableResourceBundleImpl ( cssGeneratorBundlePath , null , null , "css" , null , null , context . getConfig ( ) . getGeneratorRegistry ( ) ) ; BundleProcessingStatus tempStatus = new BundleProcessingStatus ( BundleProcessingStatus . BUNDLE_PROCESSING_TYPE , tempBundle , context . getResourceReaderHandler ( ) , context . getConfig ( ) ) ; CSSURLPathRewriterPostProcessor postProcessor = new CSSURLPathRewriterPostProcessor ( ) ; ResourceBundlePathsIterator it = null ; StringWriter resultWriter = new StringWriter ( ) ; StringBuffer result = resultWriter . getBuffer ( ) ; ConditionalCommentCallbackHandler callbackHandler = new ConditionalCommentRenderer ( resultWriter ) ; if ( bundlesHandler . isGlobalResourceBundle ( bundlePath ) ) { it = bundlesHandler . getGlobalResourceBundlePaths ( bundlePath , callbackHandler , variants ) ; } else { it = bundlesHandler . getBundlePaths ( bundlePath , callbackHandler , variants ) ; } while ( it . hasNext ( ) ) { BundlePath resourcePath = it . nextPath ( ) ; if ( resourcePath != null ) { tempStatus . setLastPathAdded ( resourcePath . getPath ( ) ) ; Reader cssReader = null ; try { JoinableResourceBundle bundle = context . getBundle ( ) ; cssReader = context . getResourceReaderHandler ( ) . getResource ( bundle , resourcePath . getPath ( ) , true ) ; StringWriter writer = new StringWriter ( ) ; IOUtils . copy ( cssReader , writer , true ) ; StringBuffer resourceData = postProcessor . postProcessBundle ( tempStatus , writer . getBuffer ( ) ) ; result . append ( "/** CSS resource : " ) . append ( resourcePath . getPath ( ) ) . append ( " **/\n" ) ; result . append ( resourceData ) ; if ( it . hasNext ( ) ) { result . append ( "\n\n" ) ; } } catch ( ResourceNotFoundException e ) { LOGGER . debug ( "The resource '" + resourcePath . getPath ( ) + "' was not found" ) ; } catch ( IOException e ) { throw new BundlingProcessException ( e ) ; } finally { IOUtils . close ( cssReader ) ; } } } return result . toString ( ) ; }
Generates the Css content for the bundle path