Package com.github.dandelion.core.asset

Examples of com.github.dandelion.core.asset.Asset


    }
  }
 
  public String getConfigurationFromPage(String page) {
    AssetCacheManager cacheManager = new AssetCacheManager(null);
    Asset asset = new Asset("dandelion-datatables", "0.10.0", AssetType.js);
    String cacheKey = cacheManager.generateCacheKey("http://" + SERVER_HOST + ":" + SERVER_PORT + "/thymeleaf/" + page, asset);
    String url = "http://" + SERVER_HOST + ":" + SERVER_PORT + DandelionServlet.DANDELION_ASSETS_URL + cacheKey;
    try {
      URL urlLocation = new URL(url);
      return ResourceUtils.getContentFromInputStream(urlLocation.openStream());
View Full Code Here


    }
  }
 
  public String getConfigurationFromPage(String page) {
    AssetCacheManager cacheManager = new AssetCacheManager(null);
    Asset asset = new Asset("dandelion-datatables", "0.10.0", AssetType.js);
    String cacheKey = cacheManager.generateCacheKey("http://" + SERVER_HOST + ":" + SERVER_PORT + "/" + page + ".jsp", asset);
    String url = "http://" + SERVER_HOST + ":" + SERVER_PORT + DandelionServlet.DANDELION_ASSETS_URL + cacheKey;
    try {
      URL urlLocation = new URL(url);
      return ResourceUtils.getContentFromInputStream(urlLocation.openStream());
View Full Code Here

    context = new Context(new MockFilterConfig());
   
    MockHttpServletRequest request = new MockHttpServletRequest();
    request.setContextPath("/context-path");
   
    Asset asset = new Asset();
    asset.setConfigLocation("//netdna.bootstrapcdn.com/twitter-bootstrap/2.3.2/css/bootstrap.css");
    asset.setFinalLocation("/context-path/dandelion-assets/sha1/bootstrap2-2.3.2.css");
    processingContext = new ProcessingContext(context, asset, request);
  }
View Full Code Here

  }
 
  @Test
  public void should_retrieve_content_from_cache() throws ServletException, IOException {

    Asset asset = new Asset();
    asset.setName("my-asset");
    asset.setVersion("1.0.0");
    asset.setType(AssetType.css);
    String content = "CONTENT" + Math.random();
   
    String cacheKey = context.getCacheManager().generateCacheKey("should_retrieve_content_from_cache", asset);
   
    context.getCacheManager().storeContent(cacheKey, content);
View Full Code Here

  /**
   * {@inheritDoc}
   */
  @Override
  protected void doProcess(Reader reader, Writer writer, ProcessingContext processingContext) throws Exception {
    Asset asset = processingContext.getAsset();
    String contextPath = processingContext.getRequest().getContextPath();
    LOG.debug("Processing {}", asset.toLog());
    urlRewriter.setContextPath(contextPath);

    StringBuilder assetContent = StringBuilderUtils.toStringBuilder(reader);

    BufferedWriter bufferedWriter = null;
    try {
      LOG.debug("  Old location: {}", asset.getConfigLocation());
      LOG.debug("  New location: {}", asset.getFinalLocation());

      bufferedWriter = new BufferedWriter(writer);
      bufferedWriter.write(urlRewriter.rewriteUrl("/" + contextPath + asset.getConfigLocation(),
          asset.getFinalLocation(), assetContent.toString()).toString());
    }
    catch (IOException e) {
      LOG.error("An error occurred when processing relative paths inside the asset " + asset.toLog());
      throw DandelionException.wrap(e);
    }
    finally {
      try {
        if (reader != null)
          reader.close();
      }
      catch (IOException e) {
        // Should never happen
        LOG.error("An error occurred when processing relative paths inside the asset " + asset.toLog());
        throw DandelionException.wrap(e);
      }

      // Flush and closes the stream
      bufferedWriter.close();
View Full Code Here

TOP

Related Classes of com.github.dandelion.core.asset.Asset

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.