// Path: desktop-reader/src/main/java/net/vhati/openuhs/desktopreader/downloader/FetchUnitException.java
// public class FetchUnitException extends Exception {
// 
// 
//     public FetchUnitException() {
// 	}
// 
// 	public FetchUnitException( String message ) {
// 		super(message);
// 	}
// 
// 	public FetchUnitException( Throwable cause ) {
// 		super( cause );
// 	}
// 
// 	public FetchUnitException( String message, Throwable cause ) {
// 		super( message, cause );
// 	}
// }


import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.IOException;
import java.net.HttpURLConnection;
import java.net.URL;
import javax.swing.SwingWorker;
import net.vhati.openuhs.desktopreader.downloader.FetchUnitException;

	/**
	 * Signals that the task should end gracefully.
	 * <p>
	 * SwingWorker's cancel() will cause get() to throw a CancellationException.
	 * Use this method instead.
	 * <p>
	 * This method is thread-safe.
	 */
	public void abortTask() {
		aborting = true;
	}


	@Override
	public StringFetchResult doInBackground() {
		HttpURLConnection con = null;
		InputStream downloadStream = null;
		BufferedReader r = null;
		StringBuilder contentString = null;

		StringFetchResult fetchResult = new StringFetchResult( urlString );
		Exception ex = null;

		try {
			con = (HttpURLConnection)(new URL( urlString ).openConnection());
			con.setRequestProperty( "User-Agent", userAgent );
			con.connect();

			if ( con.getResponseCode() != HttpURLConnection.HTTP_OK ) {
// Path: desktop-reader/src/main/java/net/vhati/openuhs/desktopreader/downloader/FetchUnitException.java
// public class FetchUnitException extends Exception {
// 
// 
//     public FetchUnitException() {
// 	}
// 
// 	public FetchUnitException( String message ) {
// 		super(message);
// 	}
// 
// 	public FetchUnitException( Throwable cause ) {
// 		super( cause );
// 	}
// 
// 	public FetchUnitException( String message, Throwable cause ) {
// 		super( message, cause );
// 	}
// }


// Path: desktop-reader/src/main/java/net/vhati/openuhs/desktopreader/downloader/StringFetchTask.java
import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.IOException;
import java.net.HttpURLConnection;
import java.net.URL;
import javax.swing.SwingWorker;
import net.vhati.openuhs.desktopreader.downloader.FetchUnitException;


	/**
	 * Signals that the task should end gracefully.
	 * <p>
	 * SwingWorker's cancel() will cause get() to throw a CancellationException.
	 * Use this method instead.
	 * <p>
	 * This method is thread-safe.
	 */
	public void abortTask() {
		aborting = true;
	}


	@Override
	public StringFetchResult doInBackground() {
		HttpURLConnection con = null;
		InputStream downloadStream = null;
		BufferedReader r = null;
		StringBuilder contentString = null;

		StringFetchResult fetchResult = new StringFetchResult( urlString );
		Exception ex = null;

		try {
			con = (HttpURLConnection)(new URL( urlString ).openConnection());
			con.setRequestProperty( "User-Agent", userAgent );
			con.connect();

			if ( con.getResponseCode() != HttpURLConnection.HTTP_OK ) {
				throw new FetchUnitException( "Server returned HTTP "+ con.getResponseCode() +" "+ con.getResponseMessage() );