@Override
 public void removeLanguageKeys(String langCode, String countryCode) {
   DotCacheAdministrator cache = CacheLocator.getCacheAdministrator();
   String languageKey =
       getPrimaryGroup()
           + "_Keys_"
           + (countryCode != null ? langCode + "_" + countryCode : langCode);
   cache.remove(languageKey, getPrimaryGroup());
 }
 public void removeLanguage(Language l) {
   DotCacheAdministrator cache = CacheLocator.getCacheAdministrator();
   long id = l.getId();
   String idSt = String.valueOf(l.getId());
   String languageKey = l.getLanguageCode() + "-" + l.getCountryCode();
   cache.remove(getPrimaryGroup() + id, getPrimaryGroup());
   cache.remove(getPrimaryGroup() + idSt, getPrimaryGroup());
   cache.remove(getPrimaryGroup() + languageKey, getPrimaryGroup());
 }
 @Override
 public void setLanguageKeys(String langCode, String countryCode, List<LanguageKey> keys) {
   DotCacheAdministrator cache = CacheLocator.getCacheAdministrator();
   String languageKey =
       getPrimaryGroup()
           + "_Keys_"
           + (countryCode != null ? langCode + "_" + countryCode : langCode);
   cache.put(languageKey, keys, getPrimaryGroup());
 }
 public boolean hasLanguage(long id) {
   DotCacheAdministrator cache = CacheLocator.getCacheAdministrator();
   Language l = null;
   try {
     l = (Language) cache.get(getPrimaryGroup() + id, getPrimaryGroup());
   } catch (DotCacheException e) {
     Logger.debug(LanguageCacheImpl.class, "Cache Entry not found", e);
   }
   return l != null;
 }
 public Language getLanguageById(String id) {
   DotCacheAdministrator cache = CacheLocator.getCacheAdministrator();
   Language f = null;
   try {
     f = (Language) cache.get(getPrimaryGroup() + id, getPrimaryGroup());
   } catch (DotCacheException e) {
     Logger.debug(LanguageCacheImpl.class, "Cache Entry not found", e);
   }
   return f;
 }
 @Override
 public List<LanguageKey> getLanguageKeys(String langCode, String countryCode)
     throws DotCacheException {
   DotCacheAdministrator cache = CacheLocator.getCacheAdministrator();
   String languageKey =
       getPrimaryGroup()
           + "_Keys_"
           + (countryCode != null ? langCode + "_" + countryCode : langCode);
   return (List<LanguageKey>) cache.get(languageKey, getPrimaryGroup());
 }
 public boolean hasLanguage(String languageCode, String countryCode) {
   DotCacheAdministrator cache = CacheLocator.getCacheAdministrator();
   String languageKey = languageCode + "-" + countryCode;
   Language l = null;
   try {
     l = (Language) cache.get(getPrimaryGroup() + languageKey, getPrimaryGroup());
   } catch (DotCacheException e) {
     Logger.debug(LanguageCacheImpl.class, "Cache Entry not found", e);
   }
   return l != null;
 }
  public static int deleteOldAssetVersions(Date assetsOlderThan) {
    int counter = 0;
    int auxCount = 0;

    /*
     * Run the drop tasks interatively, moving forward in time
     * DROP_OLD_ASSET_ITERATE_BY_SECONDS controls how many seconds to
     * move forward in time for each iteration - default is to iterate by 30 days
     */
    Calendar runDate = Calendar.getInstance();
    runDate.setTime(assetsOlderThan);
    runDate.add(Calendar.YEAR, -2);

    try {
      DotConnect dc = new DotConnect();
      String minIdateSQL = "select idate from inode order by idate";

      dc.setSQL(minIdateSQL);
      dc.setMaxRows(1);
      List<Map<String, Object>> map = dc.loadObjectResults();
      Date d = (Date) map.get(0).get("idate");
      if (d != null) runDate.setTime(d);
    } catch (Exception e) {
      Logger.info(CMSMaintenanceFactory.class, "Can't get start date");
    }

    while (runDate.getTime().before(assetsOlderThan) || runDate.getTime().equals(assetsOlderThan)) {
      try {
        HibernateUtil.startTransaction();
        Logger.info(
            CMSMaintenanceFactory.class,
            "Starting deleteOldAssetVersions for date: "
                + UtilMethods.dateToHTMLDate(runDate.getTime(), "yyyy-MM-dd"));

        ContentletAPI conAPI = APILocator.getContentletAPI();

        Logger.info(CMSMaintenanceFactory.class, "Removing Contentlets");
        auxCount = conAPI.deleteOldContent(runDate.getTime());
        counter = auxCount;
        Logger.info(CMSMaintenanceFactory.class, "Removed " + auxCount + " Contentlets");

        Logger.info(CMSMaintenanceFactory.class, "Removing HTML Pages");
        auxCount = APILocator.getHTMLPageAPI().deleteOldVersions(runDate.getTime());
        counter += auxCount;
        Logger.info(CMSMaintenanceFactory.class, "Removed " + auxCount + " HTML Pages");

        Logger.info(CMSMaintenanceFactory.class, "Removing Containers");
        auxCount = APILocator.getContainerAPI().deleteOldVersions(runDate.getTime());
        counter += auxCount;
        Logger.info(CMSMaintenanceFactory.class, "Removed " + auxCount + " Containers");

        Logger.info(CMSMaintenanceFactory.class, "Removing Templates");
        auxCount = APILocator.getTemplateAPI().deleteOldVersions(runDate.getTime());
        counter += auxCount;
        Logger.info(CMSMaintenanceFactory.class, "Removed " + auxCount + " Templates");

        Logger.info(CMSMaintenanceFactory.class, "Removing Links");
        auxCount = APILocator.getMenuLinkAPI().deleteOldVersions(runDate.getTime());
        counter += auxCount;
        Logger.info(CMSMaintenanceFactory.class, "Removed " + auxCount + " Links");

        Logger.info(CMSMaintenanceFactory.class, "Removing File Assets");

        auxCount = APILocator.getFileAPI().deleteOldVersions(runDate.getTime());
        counter += auxCount;
        Logger.info(CMSMaintenanceFactory.class, "Removed " + auxCount + " File Assets");

        Logger.info(
            CMSMaintenanceFactory.class,
            "Finished removing old asset versions, removed " + counter + " assets");

        // This is the last run, break
        if (runDate.getTime().equals(assetsOlderThan)) {
          break;
        }
        runDate.add(
            Calendar.SECOND,
            Config.getIntProperty("DROP_OLD_ASSET_ITERATE_BY_SECONDS", 60 * 60 * 24 * 30));

        // we should never go past the date the user entered
        if (runDate.getTime().after(assetsOlderThan)) {
          runDate.setTime(assetsOlderThan);
        }

      } catch (Exception ex) {
        try {
          HibernateUtil.rollbackTransaction();
        } catch (DotHibernateException e) {
          Logger.error(CMSMaintenanceFactory.class, e.getMessage());
        }
        Logger.debug(
            CMSMaintenanceFactory.class, "There was a problem deleting old asset versions", ex);
        Logger.warn(
            CMSMaintenanceFactory.class, "There  was a problem deleting old asset versions", ex);
        Logger.error(ViewCMSMaintenanceAction.class, ex.toString(), ex);
        if (counter > 0) {
          CacheLocator.getCacheAdministrator().flushAll();
        }
        return -1;
      } finally {
        try {
          HibernateUtil.commitTransaction();
        } catch (DotHibernateException e) {
          Logger.error(CMSMaintenanceFactory.class, e.getMessage());
          try {
            HibernateUtil.rollbackTransaction();
          } catch (DotHibernateException ex) {
            Logger.error(CMSMaintenanceFactory.class, e.getMessage());
          }
          Logger.debug(
              CMSMaintenanceFactory.class, "There was a problem deleting old asset versions", e);
          Logger.warn(
              CMSMaintenanceFactory.class, "There  was a problem deleting old asset versions", e);
          Logger.error(ViewCMSMaintenanceAction.class, e.toString(), e);
          if (counter > 0) {
            CacheLocator.getCacheAdministrator().flushAll();
          }
          return -1;
        }
      }
    }
    if (counter > 0) {
      CacheLocator.getCacheAdministrator().flushAll();
    }
    return counter;
  }
 private PollsQuestionPool() {
   _cacheable = PollsQuestion.CACHEABLE;
   _cache = CacheLocator.getCacheAdministrator();
 }
/**
 * <a href="PollsQuestionPool.java.html"><b><i>View Source</i></b></a>
 *
 * @author Brian Wing Shun Chan
 * @version $Revision: 1.48 $
 */
public class PollsQuestionPool implements Cachable {
  public static void clear() {
    _getInstance()._clear();
  }

  public static PollsQuestion get(String questionId) {
    return _getInstance()._get(questionId);
  }

  public static PollsQuestion put(String questionId, PollsQuestion obj) {
    return _getInstance()._put(questionId, obj);
  }

  public static PollsQuestion remove(String questionId) {
    return _getInstance()._remove(questionId);
  }

  private static PollsQuestionPool _getInstance() {
    if (_instance == null) {
      synchronized (PollsQuestionPool.class) {
        if (_instance == null) {
          _instance = new PollsQuestionPool();
        }
      }
    }

    return _instance;
  }

  private PollsQuestionPool() {
    _cacheable = PollsQuestion.CACHEABLE;
    _cache = CacheLocator.getCacheAdministrator();
  }

  private void _clear() {
    _cache.flushGroup(primaryGroup);
  }

  private PollsQuestion _get(String questionId) {
    if (!_cacheable) {
      return null;
    } else if (questionId == null) {
      return null;
    } else {
      PollsQuestion obj = null;
      String key = questionId.toString();

      if (Validator.isNull(key)) {
        return null;
      }
      try {
        obj = (PollsQuestion) _cache.get(key, primaryGroup);
      } catch (DotCacheException e) {
        Logger.debug(this, "Cache Entry not found", e);
      }
      return obj;
    }
  }

  private PollsQuestion _put(String questionId, PollsQuestion obj) {
    if (!_cacheable) {
      return obj;
    } else if (questionId == null) {
      return obj;
    } else {
      String key = questionId.toString();

      if (Validator.isNotNull(key)) {
        _cache.put(key, obj, primaryGroup);
      }

      return obj;
    }
  }

  private PollsQuestion _remove(String questionId) {
    if (!_cacheable) {
      return null;
    } else if (questionId == null) {
      return null;
    } else {
      PollsQuestion obj = null;
      String key = questionId.toString();

      if (Validator.isNull(key)) {
        return null;
      }
      try {
        obj = (PollsQuestion) _cache.get(key, primaryGroup);
      } catch (DotCacheException e) {
        Logger.debug(this, "Cache Entry not found", e);
      }
      _cache.remove(key, primaryGroup);
      return obj;
    }
  }

  private static String primaryGroup = "PollsQuestionPool";
  // region's name for the cache
  private static String[] groupNames = {primaryGroup};

  public String getPrimaryGroup() {
    return primaryGroup;
  }

  public String[] getGroups() {
    return groupNames;
  }

  private DotCacheAdministrator _cache = CacheLocator.getCacheAdministrator();

  private static PollsQuestionPool _instance;
  private boolean _cacheable;

  public void clearCache() {
    clear();
  }
}
 public MenuLinkCacheImpl() {
   cache = CacheLocator.getCacheAdministrator();
 }
 public void clearCache() {
   DotCacheAdministrator cache = CacheLocator.getCacheAdministrator();
   // clear the cache
   cache.flushGroup(getPrimaryGroup());
 }
Beispiel #13
0
 public static void flushCache() {
   DotCacheAdministrator cache = CacheLocator.getCacheAdministrator();
   cache.flushAll();
 }