Example usage for com.amazonaws.services.sns AmazonSNSClient AmazonSNSClient

List of usage examples for com.amazonaws.services.sns AmazonSNSClient AmazonSNSClient

Introduction

In this page you can find the example usage for com.amazonaws.services.sns AmazonSNSClient AmazonSNSClient.

Prototype

AmazonSNSClient(AwsSyncClientParams clientParams) 

Source Link

Document

Constructs a new client to invoke service methods on Amazon SNS using the specified parameters.

Usage

From source file:SNSMobilePush.java

License:Open Source License

public static void main(String[] args) throws IOException {
    /*/*from   www  .j  a  v  a  2 s .c  o  m*/
     * TODO: Be sure to fill in your AWS access credentials in the
     * AwsCredentials.properties file before you try to run this sample.
     * http://aws.amazon.com/security-credentials
     */
    AmazonSNS sns = new AmazonSNSClient(
            new PropertiesCredentials(SNSMobilePush.class.getResourceAsStream("AwsCredentials.properties")));

    sns.setEndpoint("https://sns.us-east-1.amazonaws.com");
    System.out.println("===========================================\n");
    System.out.println("Getting Started with Amazon SNS");
    System.out.println("===========================================\n");
    try {
        SNSMobilePush sample = new SNSMobilePush(sns);
        /* TODO: Uncomment the services you wish to use. */
        sample.demoAndroidAppNotification();
        // sample.demoKindleAppNotification();
        // sample.demoAppleAppNotification();
        // sample.demoAppleSandboxAppNotification();
        // sample.demoBaiduAppNotification();
        // sample.demoWNSAppNotification();
        // sample.demoMPNSAppNotification();
    } catch (AmazonServiceException ase) {
        System.out.println("Caught an AmazonServiceException, which means your request made it "
                + "to Amazon SNS, but was rejected with an error response for some reason.");
        System.out.println("Error Message:    " + ase.getMessage());
        System.out.println("HTTP Status Code: " + ase.getStatusCode());
        System.out.println("AWS Error Code:   " + ase.getErrorCode());
        System.out.println("Error Type:       " + ase.getErrorType());
        System.out.println("Request ID:       " + ase.getRequestId());
    } catch (AmazonClientException ace) {
        System.out.println("Caught an AmazonClientException, which means the client encountered "
                + "a serious internal problem while trying to communicate with SNS, such as not "
                + "being able to access the network.");
        System.out.println("Error Message: " + ace.getMessage());
    }
}

From source file:awslabs.lab31.Lab31.java

License:Open Source License

public static void main(String[] args) {
    try {//from   w  ww .j a v  a 2  s  . c o  m
        // Create an SQS client
        AmazonSQSClient sqsClient = new AmazonSQSClient(new ClasspathPropertiesFileCredentialsProvider());
        sqsClient.setRegion(region);

        // Create an SNS client
        AmazonSNSClient snsClient = new AmazonSNSClient(new ClasspathPropertiesFileCredentialsProvider());
        snsClient.setRegion(region);

        String queueName = "Notifications";
        String topicName = "ClassroomEvent";

        // Creating the queue will fail if we've just deleted it and are recreating it
        // which is a possibility if you're tracking down a code error. If that happens,
        // pause and retry for up to a minute.
        System.out.println("Creating " + queueName + " queue.");

        Boolean retry = true, notified = false;
        // Create a timeout for 60-seconds from now.
        Date timeout = new Date(System.currentTimeMillis() + 60000L);
        String queueUrl = "";

        while (retry) {
            try {
                queueUrl = labCode.createQueue(sqsClient, queueName);
                retry = false;
            } catch (QueueDeletedRecentlyException ex) {
                if (new Date().before(timeout)) {
                    if (!notified) {
                        System.out.println(
                                "The attempt to recreate the queue failed because the queue was deleted too");
                        System.out.println("recently. Waiting and retrying for up to 1 minute.");
                        notified = true;
                    }
                    // Timeout hasn't expired yet, so wait and retry in 5 seconds.
                    System.out.print(".");
                    Thread.sleep(5000);
                } else {
                    System.out.println("Retry timeout expired. Aborting.");
                    throw ex;
                }
            }

        }
        if (notified) {
            System.out.println("Recovered.");
        }

        System.out.println("URL for new queue: " + queueUrl);

        // List SQS queues
        System.out.println("Getting ARN for " + queueName + " queue.");
        String queueArn = labCode.getQueueArn(sqsClient, queueUrl);
        System.out.println("ARN for queue: " + queueArn);

        // Create an SNS topic and get ARN
        System.out.println("Creating " + topicName + " topic.");
        String topicArn = labCode.createTopic(snsClient, topicName);
        System.out.println("New topic ARN: " + topicArn);

        System.out.println("Granting the notification topic permission to post in the queue.");
        optionalLabCode.grantNotificationPermission(sqsClient, queueArn, queueUrl, topicArn);
        System.out.println("Permission granted.");

        // Create an SNS subscription
        System.out.println("Creating SNS subscription.");
        labCode.createSubscription(snsClient, queueArn, topicArn);
        System.out.println("Subscription created.");

        // Publish message to topic
        String messageText = "This is the SNS topic notification body.";
        String messageSubject = "SNSTopicNotification";

        System.out.println("Publishing SNS topic notification.");
        labCode.publishTopicMessage(snsClient, topicArn, messageSubject, messageText);
        System.out.println("Notification published.");

        // Send a message to the "Notifications" queue
        messageText = "This is the message posted to the queue directly.";
        System.out.println("Posting message to queue directly.");
        labCode.postToQueue(sqsClient, queueUrl, messageText);
        System.out.println("Message posted.");

        // Read message from queue
        System.out.println("Reading messages from queue.");

        List<Message> messages = labCode.readMessages(sqsClient, queueUrl);
        // We expect two messages here
        if (messages.size() < 2) {
            // Try to read again and see if we've picked up the missing message(s).
            messages.addAll(labCode.readMessages(sqsClient, queueUrl));
            if (messages.size() < 2) {
                System.out
                        .println(">>WARNING<< We didn't receive the expected number of messages. Investigate.");
            } else {
                System.out.println();
                System.out.println(
                        "============================================================================");
                System.out
                        .println("PROBLEM: ReadMessages() had to be called twice to collect all the messages.");
                System.out.println("         Did you remember to set the MaxNumberOfMessages property in the ");
                System.out.println("         ReceiveMessageRequest object?");
                System.out.println(
                        "============================================================================");
                System.out.println();

            }
        }
        PrintAndRemoveMessagesInResponse(sqsClient, messages, queueUrl);

        // Locate and delete the SNS subscription
        System.out.println("Removing provisioned resources.");
        labCode.deleteSubscriptions(snsClient, topicArn);
        System.out.println("Subscriptions removed.");

        // Delete the SNS Topic
        labCode.deleteTopic(snsClient, topicArn);
        System.out.println("Topic deleted.");
        // Locate the previously created queue and delete
        labCode.deleteQueue(sqsClient, queueUrl);
        System.out.println("Queue deleted.");
    } catch (Exception ex) {
        LabUtility.dumpError(ex);
    }
}

From source file:awslabs.lab41.SolutionCode.java

License:Open Source License

@Override
public Boolean appMode_TestSnsAccess(Region region, BasicSessionCredentials credentials) {
    try {//from   w w  w. ja  v a2  s  .c o  m
        AmazonSNSClient snsClient = new AmazonSNSClient(credentials);
        snsClient.setRegion(region);
        snsClient.listTopics(new ListTopicsRequest());
        return true;
    } catch (Exception ex) {
        return false;
    }
}

From source file:com.aipo.aws.sns.SNS.java

License:Open Source License

public static AmazonSNS getClient() {
    AWSContext awsContext = AWSContext.get();
    if (awsContext == null) {
        throw new IllegalStateException("AWSContext is not initialized.");
    }//from  w  w w .  j  a v  a  2  s.com
    AmazonSNS client = new AmazonSNSClient(awsContext.getAwsCredentials());
    String endpoint = awsContext.getSnsEndpoint();
    if (endpoint != null && endpoint != "") {
        client.setEndpoint(endpoint);
    }
    return client;
}

From source file:com.amazon.aws.demo.anonymous.AmazonClientManager.java

License:Open Source License

public synchronized Response validateCredentials() {
    Response ableToGetToken = Response.SUCCESSFUL;

    if (AmazonSharedPreferencesWrapper.areCredentialsExpired(this.sharedPreferences)) {
        Log.i(LOG_TAG, "Credentials were expired.");

        clearCredentials();//from   w  w w  .  ja  v  a2 s. co  m

        AmazonTVMClient tvm = new AmazonTVMClient(this.sharedPreferences,
                PropertyLoader.getInstance().getTokenVendingMachineURL(),
                PropertyLoader.getInstance().useSSL());
        ableToGetToken = tvm.anonymousRegister();
        if (ableToGetToken.requestWasSuccessful()) {
            ableToGetToken = tvm.getToken();
        }
    }

    if (ableToGetToken.requestWasSuccessful()
            && (s3Client == null || sqsClient == null || sdbClient == null || snsClient == null)) {
        Log.i(LOG_TAG, "Creating New Credentials.");

        AWSCredentials credentials = AmazonSharedPreferencesWrapper
                .getCredentialsFromSharedPreferences(this.sharedPreferences);

        s3Client = new AmazonS3Client(credentials);
        sqsClient = new AmazonSQSClient(credentials);
        sdbClient = new AmazonSimpleDBClient(credentials);
        snsClient = new AmazonSNSClient(credentials);
    }

    return ableToGetToken;
}

From source file:com.amazon.aws.demo.identity.AmazonClientManager.java

License:Open Source License

public synchronized Response validateCredentials() {
    Response ableToGetToken = Response.SUCCESSFUL;

    if (AmazonSharedPreferencesWrapper.areCredentialsExpired(this.sharedPreferences)) {
        Log.i(LOG_TAG, "Credentials were expired.");

        clearCredentials();/*from w w w. ja v a2s  .c  om*/

        AmazonTVMClient tvm = new AmazonTVMClient(this.sharedPreferences,
                PropertyLoader.getInstance().getTokenVendingMachineURL(),
                PropertyLoader.getInstance().getAppName(), PropertyLoader.getInstance().useSSL());
        if (ableToGetToken.requestWasSuccessful()) {
            ableToGetToken = tvm.getToken();
        }
    }

    if (ableToGetToken.requestWasSuccessful()
            && (s3Client == null || sqsClient == null || sdbClient == null || snsClient == null)) {
        Log.i(LOG_TAG, "Creating New Credentials.");

        AWSCredentials credentials = AmazonSharedPreferencesWrapper
                .getCredentialsFromSharedPreferences(this.sharedPreferences);
        s3Client = new AmazonS3Client(credentials);
        sqsClient = new AmazonSQSClient(credentials);
        sdbClient = new AmazonSimpleDBClient(credentials);
        snsClient = new AmazonSNSClient(credentials);
    }

    return ableToGetToken;
}

From source file:com.aws.sns.service.notifications.sns.SNSMobilePush.java

License:Open Source License

public static void main(String[] args) throws IOException {
    /*/* ww  w .j av  a  2 s .c  om*/
     * TODO: Be sure to fill in your AWS access credentials in the
     * AwsCredentials.properties file before you try to run this sample.
     * http://aws.amazon.com/security-credentials
     */
    AmazonSNS sns = new AmazonSNSClient(
            new PropertiesCredentials(SNSMobilePush.class.getResourceAsStream("AwsCredentials.properties")));

    sns.setEndpoint("https://sns.us-west-2.amazonaws.com");
    System.out.println("===========================================\n");
    System.out.println("Getting Started with Amazon SNS");
    System.out.println("===========================================\n");
    try {
        SNSMobilePush sample = new SNSMobilePush(sns);
        /* TODO: Uncomment the services you wish to use. */
        String registrationId = "APA91bEzO4gs7gqC0PPaw1RKzlDY5cEmRwGzV4k5DPzc_uxp8aLyNVGS3Wx7G6O3lj9v17aqUBtoTyg3JZvbsOVt81mdUDTDDiXoiWLJt9PtcWUUNKYyJsiaq1OlPnSNRx2djcfPS7Pp";
        sample.demoAndroidAppNotification(registrationId, "Test Message", "payload action", "Moonfrog");
        // sample.demoKindleAppNotification();
        //   sample.demoAppleAppNotification("c522823644bf4e799d94adc7bc4c1f1dd57066a38cc72b7d37cf48129379c13b", "APNS Welcome !!!", "apns", "Moonfrog");
        // sample.demoAppleSandboxAppNotification();
        // sample.demoBaiduAppNotification();
        // sample.demoWNSAppNotification();
        // sample.demoMPNSAppNotification();
    } catch (AmazonServiceException ase) {
        System.out.println("Caught an AmazonServiceException, which means your request made it "
                + "to Amazon SNS, but was rejected with an error response for some reason.");
        System.out.println("Error Message:    " + ase.getMessage());
        System.out.println("HTTP Status Code: " + ase.getStatusCode());
        System.out.println("AWS Error Code:   " + ase.getErrorCode());
        System.out.println("Error Type:       " + ase.getErrorType());
        System.out.println("Request ID:       " + ase.getRequestId());
    } catch (AmazonClientException ace) {
        System.out.println("Caught an AmazonClientException, which means the client encountered "
                + "a serious internal problem while trying to communicate with SNS, such as not "
                + "being able to access the network.");
        System.out.println("Error Message: " + ace.getMessage());
    }
}

From source file:com.brianmcmichael.sagu.AmazonDownloadRequest.java

License:Open Source License

@Override
public void actionPerformed(ActionEvent e) {

    if (e.getSource() == jbtDownload) {
        archiveId = jtfDownloadField.getText().trim();
        if ((archiveId.equals(""))) {
            JOptionPane.showMessageDialog(null, "Enter the Archive ID of the file to be requested.", "Error",
                    JOptionPane.ERROR_MESSAGE);
        } else {/*from  ww  w.j  a  va 2  s  .  c o  m*/
            SwingWorker downloadWorker = new SwingWorker() {

                private String archiveId = jtfDownloadField.getText().trim();

                @Override
                protected Object doInBackground() throws Exception {

                    // Create dumb progressbar
                    JFrame downloadFrame = new JFrame("Downloading");
                    {
                        downloadFrame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
                        final JProgressBar dumJProgressBar = new JProgressBar(JProgressBar.HORIZONTAL);
                        dumJProgressBar.setIndeterminate(true);
                        downloadFrame.add(dumJProgressBar, BorderLayout.NORTH);
                        downloadFrame.setSize(300, 60);
                    }
                    centerDefineFrame(downloadFrame, 300, 50);

                    String archiveId = jtfDownloadField.getText().trim();
                    try {
                        String vaultName = dlVault;

                        FileDialog fd = new FileDialog(new Frame(), "Save Archive As...", FileDialog.SAVE);
                        fd.setFile("Save Archive As...");
                        fd.setDirectory(System.getProperty("user.dir"));
                        fd.setLocation(50, 50);
                        fd.setVisible(true);

                        String filePath = "" + fd.getDirectory() + System.getProperty("file.separator")
                                + fd.getFile();

                        File outFile = new File(filePath);

                        if (outFile != null) {
                            downloadFrame.setTitle("Downloading " + outFile.toString());
                            downloadFrame.setVisible(true);

                            final Endpoint endpoint = Endpoint.getByIndex(locationChoice);

                            AmazonSQSClient dlSQS = new AmazonSQSClient(dlCredentials);
                            AmazonSNSClient dlSNS = new AmazonSNSClient(dlCredentials);

                            dlSQS.setEndpoint(endpoint.getSQSEndpoint());
                            dlSNS.setEndpoint(endpoint.getSNSEndpoint());

                            // ArchiveTransferManager atm = new
                            // ArchiveTransferManager(dlClient,
                            // dlCredentials);
                            ArchiveTransferManager atm = new ArchiveTransferManager(dlClient, dlSQS, dlSNS);

                            atm.download("-", vaultName, archiveId, outFile);

                            JOptionPane.showMessageDialog(null, "Sucessfully downloaded " + outFile.toString(),
                                    "Success", JOptionPane.INFORMATION_MESSAGE);
                            downloadFrame.setVisible(false);
                        }
                    } catch (AmazonServiceException k) {
                        JOptionPane.showMessageDialog(null,
                                "The server returned an error. Wait 24 hours after submitting an archive to attempt a download. Also check that correct location of archive has been set on the previous page.",
                                "Error", JOptionPane.ERROR_MESSAGE);
                        System.out.println("" + k);
                        downloadFrame.setVisible(false);
                    } catch (AmazonClientException i) {
                        JOptionPane.showMessageDialog(null,
                                "Client Error. Check that all fields are correct. Archive not downloaded.",
                                "Error", JOptionPane.ERROR_MESSAGE);
                        downloadFrame.setVisible(false);
                    } catch (Exception j) {
                        JOptionPane.showMessageDialog(null, "Archive not found. Unspecified Error.", "Error",
                                JOptionPane.ERROR_MESSAGE);
                        downloadFrame.setVisible(false);
                    }
                    return null;
                }
            };
            downloadWorker.execute();
            try {
                Thread.sleep(500);
            } catch (InterruptedException e1) {
                e1.printStackTrace();
            }

            this.setVisible(false);
            dispose();
        }

    } else if (e.getSource() == jbtBack) {
        this.setVisible(false);
        dispose();
    } else {
        JOptionPane.showMessageDialog(this, "Please choose a valid action.");
    }

}

From source file:com.brianmcmichael.sagu.ui.AmazonDownloadRequest.java

License:Open Source License

@Override
public void actionPerformed(ActionEvent e) {

    if (e.getSource() == jbtDownload) {
        archiveId = jtfDownloadField.getText().trim();
        if ((archiveId.equals(""))) {
            JOptionPane.showMessageDialog(null, "Enter the Archive ID of the file to be requested.", "Error",
                    JOptionPane.ERROR_MESSAGE);
        } else {/*from w  w  w. jav a 2 s  .  com*/
            SwingWorker<Object, Void> downloadWorker = new SwingWorker<Object, Void>() {

                private String archiveId = jtfDownloadField.getText().trim();

                @Override
                protected Void doInBackground() throws Exception {

                    // Create dumb progressbar
                    JFrame downloadFrame = new JFrame("Downloading");
                    {
                        downloadFrame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
                        final JProgressBar dumJProgressBar = new JProgressBar(JProgressBar.HORIZONTAL);
                        dumJProgressBar.setIndeterminate(true);
                        downloadFrame.add(dumJProgressBar, BorderLayout.NORTH);
                        downloadFrame.setSize(300, 60);
                    }
                    centerDefineFrame(downloadFrame, 300, 50);

                    try {
                        String vaultName = dlVault;

                        FileDialog fd = new FileDialog(new Frame(), "Save Archive As...", FileDialog.SAVE);
                        fd.setFile("Save Archive As...");
                        fd.setDirectory(System.getProperty("user.dir"));
                        fd.setLocation(50, 50);
                        fd.setVisible(true);

                        String filePath = "" + fd.getDirectory() + System.getProperty("file.separator")
                                + fd.getFile();

                        File outFile = new File(filePath);

                        if (outFile != null) {
                            downloadFrame.setTitle("Downloading " + outFile.toString());
                            downloadFrame.setVisible(true);

                            final Endpoint endpoint = Endpoint.getByIndex(locationChoice);

                            AmazonSQSClient dlSQS = new AmazonSQSClient(dlCredentials);
                            AmazonSNSClient dlSNS = new AmazonSNSClient(dlCredentials);

                            dlSQS.setEndpoint(endpoint.getSQSEndpoint());
                            dlSNS.setEndpoint(endpoint.getSNSEndpoint());

                            // ArchiveTransferManager atm = new
                            // ArchiveTransferManager(dlClient,
                            // dlCredentials);
                            ArchiveTransferManager atm = new ArchiveTransferManager(dlClient, dlSQS, dlSNS);

                            atm.download("-", vaultName, archiveId, outFile);

                            JOptionPane.showMessageDialog(null, "Sucessfully downloaded " + outFile.toString(),
                                    "Success", JOptionPane.INFORMATION_MESSAGE);
                            downloadFrame.setVisible(false);
                        }
                    } catch (AmazonServiceException k) {
                        JOptionPane.showMessageDialog(null,
                                "The server returned an error. Wait 24 hours after submitting an archive to attempt a download. Also check that correct location of archive has been set on the previous page.",
                                "Error", JOptionPane.ERROR_MESSAGE);
                        System.out.println("" + k);
                        downloadFrame.setVisible(false);
                    } catch (AmazonClientException i) {
                        JOptionPane.showMessageDialog(null,
                                "Client Error. Check that all fields are correct. Archive not downloaded.",
                                "Error", JOptionPane.ERROR_MESSAGE);
                        downloadFrame.setVisible(false);
                    } catch (Exception j) {
                        JOptionPane.showMessageDialog(null, "Archive not found. Unspecified Error.", "Error",
                                JOptionPane.ERROR_MESSAGE);
                        downloadFrame.setVisible(false);
                    }
                    return null;
                }
            };
            downloadWorker.execute();
            try {
                Thread.sleep(500);
            } catch (InterruptedException e1) {
                e1.printStackTrace();
            }

            this.setVisible(false);
            dispose();
        }

    } else if (e.getSource() == jbtBack) {
        this.setVisible(false);
        dispose();
    } else {
        JOptionPane.showMessageDialog(this, "Please choose a valid action.");
    }

}

From source file:com.brianmcmichael.SimpleGlacierUploader.AmazonDownloadRequest.java

License:Open Source License

@Override
public void actionPerformed(ActionEvent e) {

    if (e.getSource() == jbtDownload) {
        archiveId = jtfDownloadField.getText().trim();
        if ((archiveId.equals(""))) {
            JOptionPane.showMessageDialog(null, "Enter the Archive ID of the file to be requested.", "Error",
                    JOptionPane.ERROR_MESSAGE);
        } else {//from w  ww . jav a 2s  . c o m
            SwingWorker downloadWorker = new SwingWorker() {

                private String archiveId = jtfDownloadField.getText().trim();

                @Override
                protected Object doInBackground() throws Exception {

                    // Create dumb progressbar
                    JFrame downloadFrame = new JFrame("Downloading");
                    {
                        downloadFrame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
                        final JProgressBar dumJProgressBar = new JProgressBar(JProgressBar.HORIZONTAL);
                        dumJProgressBar.setIndeterminate(true);
                        downloadFrame.add(dumJProgressBar, BorderLayout.NORTH);
                        downloadFrame.setSize(300, 60);
                    }
                    centerDefineFrame(downloadFrame, 300, 50);

                    String archiveId = jtfDownloadField.getText().trim();
                    try {
                        String vaultName = dlVault;

                        FileDialog fd = new FileDialog(new Frame(), "Save Archive As...", FileDialog.SAVE);
                        fd.setFile("Save Archive As...");
                        fd.setDirectory(System.getProperty("user.dir"));
                        fd.setLocation(50, 50);
                        fd.setVisible(true);

                        String filePath = "" + fd.getDirectory() + System.getProperty("file.separator")
                                + fd.getFile();

                        File outFile = new File(filePath);

                        if (outFile != null) {
                            downloadFrame.setTitle("Downloading " + outFile.toString());
                            downloadFrame.setVisible(true);

                            Endpoints notificationEP = new Endpoints(locationChoice);

                            AmazonSQSClient dlSQS = new AmazonSQSClient(dlCredentials);
                            AmazonSNSClient dlSNS = new AmazonSNSClient(dlCredentials);

                            dlSQS.setEndpoint(notificationEP.sqsEndpoint());
                            dlSNS.setEndpoint(notificationEP.snsEndpoint());

                            // ArchiveTransferManager atm = new
                            // ArchiveTransferManager(dlClient,
                            // dlCredentials);
                            ArchiveTransferManager atm = new ArchiveTransferManager(dlClient, dlSQS, dlSNS);

                            atm.download("-", vaultName, archiveId, outFile);

                            JOptionPane.showMessageDialog(null, "Sucessfully downloaded " + outFile.toString(),
                                    "Success", JOptionPane.INFORMATION_MESSAGE);
                            downloadFrame.setVisible(false);
                        }
                    } catch (AmazonServiceException k) {
                        JOptionPane.showMessageDialog(null,
                                "The server returned an error. Wait 24 hours after submitting an archive to attempt a download. Also check that correct location of archive has been set on the previous page.",
                                "Error", JOptionPane.ERROR_MESSAGE);
                        System.out.println("" + k);
                        downloadFrame.setVisible(false);
                    } catch (AmazonClientException i) {
                        JOptionPane.showMessageDialog(null,
                                "Client Error. Check that all fields are correct. Archive not downloaded.",
                                "Error", JOptionPane.ERROR_MESSAGE);
                        downloadFrame.setVisible(false);
                    } catch (Exception j) {
                        JOptionPane.showMessageDialog(null, "Archive not found. Unspecified Error.", "Error",
                                JOptionPane.ERROR_MESSAGE);
                        downloadFrame.setVisible(false);
                    }
                    return null;
                }
            };
            downloadWorker.execute();
            try {
                Thread.sleep(500);
            } catch (InterruptedException e1) {
                e1.printStackTrace();
            }

            this.setVisible(false);
            dispose();
        }

    } else if (e.getSource() == jbtBack) {
        this.setVisible(false);
        dispose();
    } else {
        JOptionPane.showMessageDialog(this, "Please choose a valid action.");
    }

}