Class DownloadNotesTask

    • Method Detail

      • download

        public java.util.concurrent.Future<?> download​(long id,
                                                       ProgressMonitor progressMonitor)
        Download a specific note by its id.
        Parameters:
        id - Note identifier
        progressMonitor - progress monitor
        Returns:
        the future representing the asynchronous task
      • download

        public java.util.concurrent.Future<?> download​(DownloadParams settings,
                                                       Bounds downloadArea,
                                                       ProgressMonitor progressMonitor)
        Description copied from interface: DownloadTask
        Asynchronously launches the download task for a given bounding box.

        Set progressMonitor to null, if the task should create, open, and close a progress monitor. Set progressMonitor to NullProgressMonitor.INSTANCE if progress information is to be discarded.

        You can wait for the asynchronous download task to finish by synchronizing on the returned Future, but make sure not to freeze up JOSM. Example:

            Future<?> future = task.download(...);
            // DON'T run this on the Swing EDT or JOSM will freeze
            future.get(); // waits for the dowload task to complete
         
        The following example uses a pattern which is better suited if a task is launched from the Swing EDT:
            final Future<?> future = task.download(...);
            Runnable runAfterTask = new Runnable() {
               public void run() {
                   // this is not strictly necessary because of the type of executor service
                   // Main.worker is initialized with, but it doesn't harm either
                   //
                   future.get(); // wait for the download task to complete
                   doSomethingAfterTheTaskCompleted();
               }
            }
            MainApplication.worker.submit(runAfterTask);
         
        Parameters:
        settings - download settings
        downloadArea - the area to download
        progressMonitor - the progressMonitor
        Returns:
        the future representing the asynchronous task
      • cancel

        public void cancel()
        Description copied from interface: DownloadTask
        Cancels the asynchronous download task.
      • getConfirmationMessage

        public java.lang.String getConfirmationMessage​(java.net.URL url)
        Description copied from interface: DownloadTask
        Replies the HTML-formatted confirmation message to be shown to user when the given URL needs to be confirmed before loading.
        Parameters:
        url - The URL to be confirmed
        Returns:
        The HTML-formatted confirmation message to be shown to user
      • isSafeForRemotecontrolRequests

        public boolean isSafeForRemotecontrolRequests()
        Description copied from class: AbstractDownloadTask
        Check / decide if the task is safe for remotecontrol.

        Keep in mind that a potential attacker has full control over the content of the file that will be downloaded. If it is possible to run arbitrary code or write to the local file system, then the task is (obviously) not save for remote execution.

        The default value is false = unsafe. Override in a subclass to allow running the task via remotecontol.

        Overrides:
        isSafeForRemotecontrolRequests in class AbstractDownloadTask<NoteData>
        Returns:
        true if it is safe to download and open any file of the corresponding format, false otherwise