Beispiel #1
0
 public int compareTo(NameAndVersion oth) {
   if (!name.equals(oth.name)) return name.compareTo(oth.name);
   else {
     if (version == null) return 1;
     else if (oth.version == null) return -1;
     else return version.compareTo(oth.version);
   }
 }
Beispiel #2
0
  /**
   * Check the status of the named plugin - whether an older, the same or a newer version is already
   * installed.
   *
   * @param f The plugin file.
   * @return an integer indicating the status
   */
  public static int checkInstalledVersion(File f) {
    String[] nav = getNameAndVersion(f);
    if (nav == null) return UNKNOWN_VERSION;

    VersionNumber vn = new VersionNumber(nav[1]);
    Map<VersionNumber, File> versions = getInstalledVersions(nav[0]);

    if (versions.size() == 0) {
      return NO_VERSIONS_INSTALLED;
    }
    VersionNumber thenum = versions.keySet().iterator().next();
    boolean hasSame = vn.compareTo(thenum) == 0;
    boolean hasNewer = vn.compareTo(thenum) > 0;

    if (hasNewer) return NEWER_VERSION_INSTALLED;
    if (hasSame) return SAME_VERSION_INSTALLED;

    return OLDER_VERSION_INSTALLED;
  }
Beispiel #3
0
 public static boolean deleteOlderVersions(File f) {
   String[] nav = getNameAndVersion(f);
   if (nav == null) return false;
   boolean success = true;
   VersionNumber num = new VersionNumber(nav[1]);
   Map<VersionNumber, File> versions = getInstalledVersions(nav[0]);
   for (VersionNumber versionNumber : versions.keySet()) {
     if (num.compareTo(versionNumber) < 0) {
       String vnString =
           versionNumber.equals(VersionNumber.ZERO) ? null : versionNumber.toString();
       File file = versions.get(versionNumber); // buildFileName(nav[0], vnString);
       success = deletePluginFile(file); // file).delete() && success;
     }
   }
   return success;
 }