Permalink
Browse files

Try to do a quick fix of issue #13.

  • Loading branch information...
1 parent 0663b46 commit 65637be5bcde455ab82c244ace5a93b461b970b1 @MoriTanosuke committed Aug 31, 2012
Showing with 73 additions and 63 deletions.
  1. +1 −1 pom.xml
  2. +72 −62 src/main/java/de/kopis/glacier/GlacierArchiveDownloader.java
View
@@ -3,7 +3,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>de.kopis.glacier</groupId>
<artifactId>uploader</artifactId>
- <version>0.0.4-SNAPSHOT</version>
+ <version>0.0.4.1-SNAPSHOT</version>
<inceptionYear>2012</inceptionYear>
<organization>
@@ -1,62 +1,72 @@
-package de.kopis.glacier;
-
-/*
- * #%L
- * uploader
- * $Id:$
- * $HeadURL:$
- * %%
- * Copyright (C) 2012 Carsten Ringe
- * %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/gpl-3.0.html>.
- * #L%
- */
-
-import java.io.File;
-import java.io.IOException;
-import java.net.URL;
-
-import com.amazonaws.services.glacier.model.DeleteArchiveRequest;
-import com.amazonaws.services.glacier.transfer.ArchiveTransferManager;
-
-public class GlacierArchiveDownloader extends AbstractGlacierCommand {
-
- public GlacierArchiveDownloader(final File credentials) throws IOException {
- super(credentials);
- }
-
- public void download(final URL endpointUrl, final String vaultName, final String archiveId) {
- System.out.println("Downloading archive " + archiveId + " from vault " + vaultName + "...");
- client.setEndpoint(endpointUrl.toExternalForm());
-
- try {
- final File downloadFile = File.createTempFile("glacier-", ".dl");
- final ArchiveTransferManager atm = new ArchiveTransferManager(client, credentials);
- atm.download(vaultName, archiveId, downloadFile);
- System.out.println("Archive downloaded to " + downloadFile);
- } catch (final IOException e) {
- System.err.println("Can not download archive " + archiveId + " from vault " + vaultName + ".");
- e.printStackTrace();
- }
- }
-
- public void delete(final URL endpointUrl, final String vaultName, final String archiveId) {
- System.out.println("Deleting archive " + archiveId + " from vault " + vaultName + "...");
- final DeleteArchiveRequest deleteArchiveRequest = new DeleteArchiveRequest(vaultName, archiveId);
- client.deleteArchive(deleteArchiveRequest);
- System.out.println("Archive " + archiveId + " deleted from vault " + vaultName + ".");
- }
-
-}
+package de.kopis.glacier;
+
+/*
+ * #%L
+ * uploader
+ * $Id:$
+ * $HeadURL:$
+ * %%
+ * Copyright (C) 2012 Carsten Ringe
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+import java.io.File;
+import java.io.IOException;
+import java.net.URL;
+
+import com.amazonaws.services.glacier.model.DeleteArchiveRequest;
+import com.amazonaws.services.glacier.transfer.ArchiveTransferManager;
+import com.amazonaws.services.sns.AmazonSNSClient;
+import com.amazonaws.services.sqs.AmazonSQSClient;
+
+public class GlacierArchiveDownloader extends AbstractGlacierCommand {
+
+ public GlacierArchiveDownloader(final File credentials) throws IOException {
+ super(credentials);
+ }
+
+ public void download(final URL endpointUrl, final String vaultName, final String archiveId) {
+ System.out.println("Downloading archive " + archiveId + " from vault " + vaultName + "...");
+ client.setEndpoint(endpointUrl.toExternalForm());
+
+ // TODO is this fixing issue #13?
+ final AmazonSQSClient sqs = new AmazonSQSClient(credentials);
+ final AmazonSNSClient sns = new AmazonSNSClient(credentials);
+ sqs.setEndpoint(endpointUrl.toExternalForm().replaceAll("glacier", "sqs"));
+ sns.setEndpoint(endpointUrl.toExternalForm().replaceAll("glacier", "sns"));
+
+ try {
+ final File downloadFile = File.createTempFile("glacier-", ".dl");
+
+ ArchiveTransferManager atm = new ArchiveTransferManager(client, sqs, sns);
+
+ atm.download(vaultName, archiveId, downloadFile);
+ System.out.println("Archive downloaded to " + downloadFile);
+ } catch (final IOException e) {
+ System.err.println("Can not download archive " + archiveId + " from vault " + vaultName + ".");
+ e.printStackTrace();
+ }
+ }
+
+ public void delete(final URL endpointUrl, final String vaultName, final String archiveId) {
+ System.out.println("Deleting archive " + archiveId + " from vault " + vaultName + "...");
+ final DeleteArchiveRequest deleteArchiveRequest = new DeleteArchiveRequest(vaultName, archiveId);
+ client.deleteArchive(deleteArchiveRequest);
+ System.out.println("Archive " + archiveId + " deleted from vault " + vaultName + ".");
+ }
+
+}

0 comments on commit 65637be

Please sign in to comment.