コード例 #1
0
 /* returns null if consistent, error string when not */
 public String checkConsistency() {
   final Collection<String> uploadSiteNames = getSiteNamesToUpload();
   final String uploadSiteName =
       uploadSiteNames.isEmpty() ? null : uploadSiteNames.iterator().next();
   final StringBuilder result = new StringBuilder();
   final Set<FileObject> circularChecked = new HashSet<FileObject>();
   for (final FileObject file : this) {
     if (uploadSiteName != null && !uploadSiteName.equals(file.updateSite)
         || file.getAction() == Action.REMOVE) {
       continue;
     }
     result.append(checkForCircularDependency(file, circularChecked, uploadSiteName));
     // only non-obsolete components can have dependencies
     final Set<String> deps = file.dependencies.keySet();
     if (deps.size() > 0 && file.isObsolete() && file.getAction() != Action.UPLOAD) {
       result.append(
           "Obsolete file " + file + " has dependencies: " + UpdaterUtil.join(", ", deps) + "!\n");
     }
     for (final String dependency : deps) {
       final FileObject dep = get(dependency);
       if (dep == null || dep.current == null)
         result.append(
             "The file "
                 + file
                 + " has the obsolete/local-only "
                 + "dependency "
                 + dependency
                 + "!\n");
     }
   }
   return result.length() > 0 ? result.toString() : null;
 }
コード例 #2
0
  public String downloadIndexAndChecksum(final Progress progress)
      throws ParserConfigurationException, SAXException {
    try {
      read();
    } catch (final FileNotFoundException e) {
      if (prefix("plugins/Fiji_Updater.jar").exists()) {
        // make sure that the Fiji update site is enabled
        UpdateSite fiji = getUpdateSite("Fiji", true);
        if (fiji == null) {
          addUpdateSite("Fiji", "http://fiji.sc/update/", null, null, 0);
        }
      }
    } catch (final IOException e) {
      /* ignore */
    }

    // clear the files
    clear();

    final XMLFileDownloader downloader = new XMLFileDownloader(this);
    downloader.addProgress(progress);
    try {
      downloader.start(false);
    } catch (final UpdateCanceledException e) {
      downloader.done();
      throw e;
    }
    new Checksummer(this, progress).updateFromLocal();

    // When upstream fixed dependencies, heed them
    for (final FileObject file : upToDate()) {
      for (final FileObject dependency : file.getFileDependencies(this, false)) {
        if (dependency.getAction() == Action.NOT_INSTALLED
            && dependency.isUpdateablePlatform(this)) {
          dependency.setAction(this, Action.INSTALL);
        }
      }
    }

    return downloader.getWarnings();
  }