@Override
 public void getRevisionFile(File originalFile, File revisionFile) {
   assert originalFile != null;
   if (originalFile == null) {
     LocalHistory.LOG.log(
         Level.FINE, "revision {0} requested for null file", se.getDate().getTime()); // NOI18N
     return;
   }
   LocalHistory.LOG.log(
       Level.FINE,
       "revision {0} requested for file {1}",
       new Object[] {se.getDate().getTime(), originalFile.getAbsolutePath()}); // NOI18N
   try {
     // we won't use the member store entry as that might have been
     // set for e.g. a stored .form while this is the according .java
     // file beeing requested. In case the storage can't find a revision it
     // returns the next nearest in time
     long ts = se.getTimestamp();
     StoreEntry storeEntry =
         LocalHistory.getInstance().getLocalHistoryStore().getStoreEntry(originalFile, ts);
     if (storeEntry != null) {
       FileUtils.copy(storeEntry.getStoreFileInputStream(), revisionFile);
     } else {
       LocalHistory.LOG.log(
           Level.WARNING,
           "No entry in Local History for file {0} {1} {2}",
           new Object[] {originalFile, new Date(ts), ts}); // NOI18N
     }
   } catch (IOException e) {
     LocalHistory.LOG.log(
         Level.WARNING,
         "Error while retrieving history for file {0} stored as {1}",
         new Object[] {se.getFile(), se.getStoreFile()}); // NOI18N
   }
 }
 private void logFiles(File[] files) {
   if (LocalHistory.LOG.isLoggable(Level.FINE)) {
     StringBuilder sb = new StringBuilder();
     sb.append("LocalHistory requested for files: "); // NOI18N
     sb.append(toString(files));
     LocalHistory.LOG.fine(sb.toString());
   }
 }
 private void logEntries(Collection<HistoryEntry> entries) {
   LocalHistory.LOG.log(Level.FINE, "LocalHistory returns {0} entries", entries.size()); // NOI18N
   if (LocalHistory.LOG.isLoggable(Level.FINEST)) {
     StringBuilder sb = new StringBuilder();
     Iterator<HistoryEntry> it = entries.iterator();
     while (it.hasNext()) {
       HistoryEntry entry = it.next();
       sb.append("["); // NOI18N
       sb.append(DateFormat.getDateTimeInstance().format(entry.getDateTime()));
       sb.append(",["); // NOI18N
       sb.append(toString(entry.getFiles()));
       sb.append("]]"); // NOI18N
       if (it.hasNext()) sb.append(","); // NOI18N
     }
     LocalHistory.LOG.finest(sb.toString());
   }
 }
 public static void log(String msg) {
   if (!LOG.isLoggable(Level.FINE)) {
     return;
   }
   StringBuilder sb = new StringBuilder();
   SimpleDateFormat defaultFormat = new SimpleDateFormat("dd-MM-yyyy:HH-mm-ss.S");
   sb.append(defaultFormat.format(new Date(System.currentTimeMillis())));
   sb.append(":");
   sb.append(msg);
   sb.append('\t');
   sb.append(Thread.currentThread().getName());
   LocalHistory.LOG.fine(sb.toString()); // NOI18N
 }
  @Override
  public HistoryEntry[] getHistory(File[] files, Date fromDate) {
    if (files == null || files.length == 0) {
      LocalHistory.LOG.log(
          Level.FINE,
          "LocalHistory requested for no files {0}",
          files != null ? files.length : null);
      return new HistoryEntry[0];
    }
    logFiles(files);

    Map<Long, HistoryEntry> storeEntries = new HashMap<Long, HistoryEntry>();
    for (File f : files) {
      StoreEntry[] ses = LocalHistory.getInstance().getLocalHistoryStore().getStoreEntries(f);
      for (StoreEntry se : ses) {
        if (!storeEntries.keySet().contains(se.getTimestamp())) {
          HistoryEntry e =
              new HistoryEntry(
                  files,
                  se.getDate(),
                  se.getLabel(),
                  "", // username         NOI18N
                  "", // username short   NOI18N
                  NbBundle.getMessage(
                      LocalHistoryProvider.class, "LBL_Local"), // revision         NOI18N
                  NbBundle.getMessage(
                      LocalHistoryProvider.class, "LBL_Local"), // revision short   NOI18N
                  getActions(),
                  new RevisionProviderImpl(se),
                  new MessageEditImpl(se));
          storeEntries.put(se.getTimestamp(), e);
        }
      }
    }
    logEntries(storeEntries.values());
    return storeEntries.values().toArray(new HistoryEntry[storeEntries.size()]);
  }