Examples of DownloadService


Examples of com.rackspacecloud.blueflood.CloudFilesBackfiller.download.DownloadService

        final File downloadDir = new File(config.getStringProperty(BackFillerConfig.DOWNLOAD_DIR));
        downloadDir.mkdirs();

        // connect the download service to the file manager.
        FileManager fileManager = new CloudFilesManager(USER, KEY, PROVIDER, ZONE, CONTAINER, config.getIntegerProperty(BackFillerConfig.BATCH_SIZE));
        DownloadService downloadService = new DownloadService(downloadDir);
        downloadService.setFileManager(fileManager);

        // delete any temp files before starting.
        for (File tmp : downloadDir.listFiles(new FilenameFilter() {
            public boolean accept(File dir, String name) {
                return name.endsWith(".json.gz.tmp");
            }
        })) {
            if (!tmp.delete()) {
                log.error("Could not delete a temp file %s", tmp.getName());
                System.exit(-1);
            }
        }

        try {
            downloadService.start();
        } catch (IOException ex) {
            ex.printStackTrace();
            System.exit(-1);
        }
    }
View Full Code Here

Examples of javax.jnlp.DownloadService

public class SweetHome3DJavaWebStartBootstrap {
  public static void main(String [] args) throws ClassNotFoundException,
        NoSuchMethodException, IllegalAccessException, InvocationTargetException {
    try {
      // Lookup the javax.jnlp.DownloadService object
      DownloadService service = (DownloadService)ServiceManager.lookup("javax.jnlp.DownloadService");
      DownloadServiceListener progressWindow = service.getDefaultProgressWindow();
      // Search jars lazily downloaded
      String lazyParts = System.getProperty("com.eteks.sweethome3d.lazyParts", "");
      List<String> lazyPartsToDownload = new ArrayList<String>();
      for (String lazyPart : lazyParts.split("\\s")) {
        if (!service.isPartCached(lazyPart)) {
          lazyPartsToDownload.add(lazyPart);
        }
      }     
      try {
        if (lazyPartsToDownload.size() > 0) {
          service.loadPart(lazyPartsToDownload.toArray(new String [lazyPartsToDownload.size()]), progressWindow);
        }
      } catch (IOException ex) {
        ex.printStackTrace();
        System.exit(1);
      }       
View Full Code Here

Examples of javax.jnlp.DownloadService

  return true;
    }
   
    /** Remove data component data JAR from cache */
    static public void removeInstallerComponent() {
  DownloadService downloadService = Config.getDownloadService();
  if (downloadService != null) {
      String component = Config.getInstallerLocation();
      String version   = Config.getInstallerVersion();
      try {
    URL codebase = Config.getBasicService().getCodeBase();
    URL url = new URL(codebase, component);
    component = url.toString();
    Config.trace("Removing: " + component + "/" + version);
    downloadService.removeResource(url, version);
      } catch(IOException ioe) {
    Config.trace("Unable to remove " + component + "/" + version);
      }
  } else {
      Config.trace("No download service found");
View Full Code Here

Examples of javax.jnlp.DownloadService

   * @throws ApplicationException if the download service is not available.
   */
  private void startDownload(boolean forceDownload)
      throws IOException, ApplicationException
  {
    DownloadService ds;
    try
    {
      ds =
          (DownloadService) ServiceManager.lookup(Utils.JNLP_SERVICE_NAME);
    } catch (UnavailableServiceException e)
    {
      LOG.log(Level.SEVERE, "Could not find service: "+
          Utils.JNLP_SERVICE_NAME, e);
      String setupFile;
      if (Utils.isWindows())
      {
        setupFile = Installation.WINDOWS_SETUP_FILE_NAME;
      }
      else
      {
        setupFile = Installation.UNIX_SETUP_FILE_NAME;
      }
      throw new ApplicationException(
        ReturnCode.DOWNLOAD_ERROR,
        getThrowableMsg(INFO_DOWNLOADING_ERROR_NO_SERVICE_FOUND.get(
            Utils.JNLP_SERVICE_NAME, setupFile),
            e), e);
    }

    String[] urls = getJarUrls();
    String[] versions = getJarVersions();

    /*
     * Calculate the percentages that correspond to each file.
     * TODO ideally this should be done dynamically, but as this is just
     * to provide progress, updating this information from time to time can
     * be enough and does not complexify the build process.
     */
    int[] percentageMax = new int[urls.length];
    int[] ratios = new int[urls.length];
    int totalRatios = 0;
    for (int i=0; i<percentageMax.length; i++)
    {
      int ratio;
      if (urls[i].endsWith("NasuTekDS.jar"))
      {
        ratio =  23;
      }
      else if (urls[i].endsWith("je.jar"))
      {
        ratio = 11;
      }
      else if (urls[i].endsWith("zipped.jar"))
      {
        ratio = 110;
      }
      else if (urls[i].endsWith("aspectjrt.jar"))
      {
        ratio = 10;
      }
      else
      {
        ratio = (100 / urls.length);
      }
      ratios[i] = ratio;
      totalRatios += ratio;
    }

    for (int i=0; i<percentageMax.length; i++)
    {
      int r = 0;
      for (int j=0; j<=i; j++)
      {
        r += ratios[j];
      }
      percentageMax[i] = (100 * r)/totalRatios;
    }


    for (int i = 0; i < urls.length && (getException() == null); i++)
    {
      if (i == 0)
      {
        currentPercMin = 0;
      }
      else {
        currentPercMin = percentageMax[i-1];
      }
      currentPercMax = percentageMax[i];

      // determine if a particular resource is cached
      String sUrl = urls[i];
      String version = versions[i];

      URL url = new URL(sUrl);
      boolean cached = ds.isResourceCached(url, version);

      if (cached && forceDownload)
      {
        try
        {
          ds.removeResource(url, version);
        } catch (IOException ioe)
        {
        }
        cached = false;
      }

      if (!cached)
      {
        // if not in the cache load the resource into the cache
        ds.loadResource(url, version, this);
      }
      downloadPercentage = currentPercMax;
    }
    isFinished = true;
  }
View Full Code Here

Examples of org.exoplatform.download.DownloadService

   {

      public void execute(Event<UISampleDownloadUpload> event) throws Exception
      {
         UISampleDownloadUpload uiForm = event.getSource();
         DownloadService dservice = uiForm.getApplicationComponent(DownloadService.class);
         String[] downloadLink = new String[3];
         String[] fileName = new String[3];
         String[] inputName = new String[3];
         for (int index = 0; index <= 2; index++)
         {
            UIFormUploadInput input = uiForm.getChildById("name" + index);
            UploadResource uploadResource = input.getUploadResource();
            if (uploadResource != null)
            {
               DownloadResource dresource =
                  new InputStreamDownloadResource(input.getUploadDataAsStream(), uploadResource.getMimeType());
               dresource.setDownloadName(uploadResource.getFileName());
               downloadLink[index] = dservice.getDownloadLink(dservice.addDownloadResource(dresource));
               fileName[index] = uploadResource.getFileName();
               inputName[index] = "name" + index;
            }
         }
View Full Code Here

Examples of org.exoplatform.download.DownloadService

    public static class SubmitActionListener extends EventListener<UISampleDownloadUpload> {

        public void execute(Event<UISampleDownloadUpload> event) throws Exception {
            UISampleDownloadUpload uiForm = event.getSource();
            DownloadService dservice = uiForm.getApplicationComponent(DownloadService.class);
            List<String> downloadLink = new ArrayList<String>();
            List<String> fileName = new ArrayList<String>();
            List<String> inputName = new ArrayList<String>();
            for (int index = 0; index <= 2; index++) {
                UIFormUploadInput input = uiForm.getChildById("name" + index);
                UploadResource uploadResource = input.getUploadResource();
                if (uploadResource != null) {
                    DownloadResource dresource = new InputStreamDownloadResource(input.getUploadDataAsStream(),
                            uploadResource.getMimeType());
                    dresource.setDownloadName(uploadResource.getFileName());
                    downloadLink.add(dservice.getDownloadLink(dservice.addDownloadResource(dresource)));
                    fileName.add(uploadResource.getFileName());
                    inputName.add("name" + index);
                }
            }

            for (int index = 3; index < 5; index++) {
                UIUploadInput input = uiForm.getChildById("name" + index);
                UploadResource[] uploadResources = input.getUploadResources();
                for (UploadResource uploadResource : uploadResources) {
                    DownloadResource dresource = new InputStreamDownloadResource(new FileInputStream(new File(
                            uploadResource.getStoreLocation())), uploadResource.getMimeType());
                    dresource.setDownloadName(uploadResource.getFileName());
                    downloadLink.add(dservice.getDownloadLink(dservice.addDownloadResource(dresource)));
                    fileName.add(uploadResource.getFileName());
                    inputName.add("name" + index);
                }
            }
View Full Code Here

Examples of org.exoplatform.download.DownloadService

    public void execute(WebAppController controller, HttpServletRequest req, HttpServletResponse res) throws Exception {
        String resourceId = req.getParameter("resourceId");
        res.setHeader("Cache-Control", "private max-age=600, s-maxage=120");
        ExoContainer container = ExoContainerContext.getCurrentContainer();
        DownloadService dservice = (DownloadService) container.getComponentInstanceOfType(DownloadService.class);
        DownloadResource dresource = dservice.getDownloadResource(resourceId);
        if (dresource == null) {
            res.setContentType("text/plain");
            res.getWriter().write("NO DOWNDLOAD RESOURCE CONTENT  OR YOU DO NOT HAVE THE RIGHT TO ACCESS THE CONTENT");
            return;
        }
View Full Code Here

Examples of org.exoplatform.download.DownloadService

   public void execute(WebAppController controller, HttpServletRequest req, HttpServletResponse res) throws Exception
   {
      String resourceId = req.getParameter("resourceId");
      res.setHeader("Cache-Control", "private max-age=600, s-maxage=120");
      ExoContainer container = ExoContainerContext.getCurrentContainer();
      DownloadService dservice = (DownloadService)container.getComponentInstanceOfType(DownloadService.class);
      DownloadResource dresource = dservice.getDownloadResource(resourceId);
      if (dresource == null)
      {
         res.setContentType("text/plain");
         res.getWriter().write("NO DOWNDLOAD RESOURCE CONTENT  OR YOU DO NOT HAVE THE RIGHT TO ACCESS THE CONTENT");
         return;
View Full Code Here

Examples of org.exoplatform.download.DownloadService

   @SuppressWarnings("unused")
   public void execute(WebAppController controller, HttpServletRequest req, HttpServletResponse res) throws Exception
   {
      res.setHeader("Cache-Control", "private max-age=600, s-maxage=120");
      ExoContainer container = ExoContainerContext.getCurrentContainer();
      DownloadService dservice = (DownloadService)container.getComponentInstanceOfType(DownloadService.class);
      DownloadResource dresource = dservice.getDownloadResource(resourceId);
      if (dresource == null)
      {
         res.setContentType("text/plain");
         res.getWriter().write("NO DOWNDLOAD RESOURCE CONTENT  OR YOU DO NOT HAVE THE RIGHT TO ACCESS THE CONTENT");
         return;
View Full Code Here

Examples of org.rssowl.ui.internal.services.DownloadService

    /* Create the Saved Search Service */
    fSavedSearchService = new SavedSearchService();

    /* Create the Download Service */
    fDownloadService = new DownloadService();

    /* Register Listeners */
    registerListeners();

    /* Load Contributed News Share Providers */
 
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.