Esempio n. 1
0
 protected DownloadingPackage getDownloadingPackage(String pkgId) {
   ConnectDownloadManager cdm = Framework.getLocalService(ConnectDownloadManager.class);
   List<DownloadingPackage> pkgs = cdm.listDownloadingPackages();
   for (DownloadingPackage pkg : pkgs) {
     if (pkg.getId().equals(pkgId)) {
       return pkg;
     }
   }
   return null;
 }
Esempio n. 2
0
 @GET
 @Produces("application/json")
 @Path(value = "progressAsJSON")
 public String getDownloadsProgress() {
   ConnectDownloadManager cdm = Framework.getLocalService(ConnectDownloadManager.class);
   List<DownloadingPackage> pkgs = cdm.listDownloadingPackages();
   StringBuffer sb = new StringBuffer();
   sb.append("[");
   for (int i = 0; i < pkgs.size(); i++) {
     if (i > 0) {
       sb.append(",");
     }
     sb.append("{ \"pkgid\" : ");
     sb.append("\"" + pkgs.get(i).getId() + "\",");
     sb.append(" \"progress\" : ");
     sb.append(pkgs.get(i).getDownloadProgress() + "}");
   }
   sb.append("]");
   return sb.toString();
 }