private void cleanUpUris() {
   synchronized (uriUsages) {
     final List<Persistence.UriUsage> toBeDiscardedUriUsages = uriUsages.getUriUsages();
     Collections.sort(toBeDiscardedUriUsages);
     final int toBeDiscardedCount = toBeDiscardedUriUsages.size() / 2;
     for (int index = 0; index < toBeDiscardedCount; index++) {
       final Persistence.UriUsage discardedUriUsage =
           uriUsages.remove(toBeDiscardedUriUsages.get(index).uri);
       properties.remove(discardedUriUsage.uri);
       if (log.isDebugEnabled()) {
         log.debug(
             "Removed from the cache the URI "
                 + discardedUriUsage.uri
                 + "' accessed "
                 + discardedUriUsage.getAccessCount()
                 + " time(s), corresponding to the file '"
                 + discardedUriUsage.storageFilePath);
       }
     }
     // We reset the remaining usages
     uriUsages.resetAccessCount();
     if (log.isInfoEnabled()) {
       log.info(
           "The web cache has been cleaned-up and it now contains "
               + uriUsages.size()
               + " item(s)");
     }
   }
 }
 private void rememberUriUsed(String uri) {
   if (isStorageLimited() == true) {
     final Persistence.UriUsage uriUsage = uriUsages.get(uri);
     uriUsage.accessed();
     if (log.isDebugEnabled()) {
       log.debug(
           "The URI '" + uri + "' has been accessed " + uriUsage.getAccessCount() + " time(s)");
     }
   }
 }
 private void registerUri(String uri, String filePath) {
   Persistence.UriUsage uriUsage;
   synchronized (uriUsages) {
     uriUsage = uriUsages.get(uri);
     if (uriUsage == null) {
       uriUsage = new Persistence.UriUsage(filePath, uri);
       uriUsage.accessed();
       uriUsages.put(uri, uriUsage);
       properties.put(uri, filePath);
       fileIndexNeedsSaving = true;
       if (log.isDebugEnabled()) {
         log.debug("Registered the URI '" + uri + "' with the file '" + filePath + "'");
       }
     }
   }
 }