Package com.google.code.greenwood.confluenceadvancedcodeblockplugin.cache

Examples of com.google.code.greenwood.confluenceadvancedcodeblockplugin.cache.AdvancedCodeBlockCache


  protected AdvancedCodeBlockCache getFromCache(String innerKeyCacheName) {
    if (innerKeyCacheName != null && ! innerKeyCacheName.isEmpty()) {
      Cache cache = cacheManager.getCache(MACRO_CACHE_KEY);   
 
      AdvancedCodeBlockCache cacheObj = null;
      try {
        cacheObj = (AdvancedCodeBlockCache) cache.get(innerKeyCacheName);
      } catch (Exception e) {
        // If Object of old version with different footprint is already there, discard the object.
        log.info("Cache gets renewed because of ClassCastException."+e.getMessage());
View Full Code Here


  protected void putToCache(List<Map<String,String>> codeblocks, String innerKeyCacheName) {
    if (innerKeyCacheName != null && ! innerKeyCacheName.isEmpty()) {
      Cache cache = cacheManager.getCache(MACRO_CACHE_KEY);   
     
      Date lastCacheUpdate = newDate();
      AdvancedCodeBlockCache cacheObj = new AdvancedCodeBlockCache();
      cacheObj.setCodeblocks(codeblocks);
      cacheObj.setCreated(lastCacheUpdate);
     
      cache.put(innerKeyCacheName, cacheObj);
    }
  }
View Full Code Here

      Map<String, Object>  context = getDefaultVelocityContext();

    String innerKeyCacheName = AdvancedCodeBlockCache.generateCacheKeyForRemoteMacro(remoteFileUrl, remoteFileHttpUser, remoteFileHttpPassword, macroid);

    try {
      AdvancedCodeBlockCache cacheObj = getFromCache(innerKeyCacheName);
      if (cacheObj == null) {
        String remoteFileContent = HttpDownloader.downloadFile(new URL(remoteFileUrl), remoteFileHttpUser, remoteFileHttpPassword);
        codeblocks = parseConfigWithContent(body, remoteFileContent, macroid, conversionContext.getEntity().getId(), context, true);
        // (re)create cache
        cacheObj = new AdvancedCodeBlockCache();
        cacheObj.setCreated(newDate());
        cacheObj.setCodeblocks(codeblocks);
        putToCache(codeblocks, innerKeyCacheName);
      } else {
        codeblocks = cacheObj.getCodeblocks();
      }
      context.put(VELOCITY_PLACEHOLDER_LAST_CACHE_UPDATE, cacheObj.getCreated());
     
      final String refreshActionPath = bootstrapManager.getWebAppContextPath() + "/"+MACRO_ACTION_PREFIX+"/actions/refreshcache.action?pageId=" + GeneralUtil.urlEncode(conversionContext.getEntity().getIdAsString())+"&cachekey="+GeneralUtil.urlEncode(innerKeyCacheName);
      context.put("refreshActionPath", refreshActionPath);
     
    } catch (MalformedURLException e) {
View Full Code Here

TOP

Related Classes of com.google.code.greenwood.confluenceadvancedcodeblockplugin.cache.AdvancedCodeBlockCache

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.