Repository: flex-utilities
Updated Branches:
  refs/heads/mavenizer-refactoring b9ca520e4 -> f8468bad7


FLEX-34318 - [Mavenizer] Refactor the Mavenizer in preparation of future 
mavenized releases of Flex
- Added the functionality to ask for accepting the Adobe license before 
downloading AIR and Flash resources.


Project: http://git-wip-us.apache.org/repos/asf/flex-utilities/repo
Commit: http://git-wip-us.apache.org/repos/asf/flex-utilities/commit/f8468bad
Tree: http://git-wip-us.apache.org/repos/asf/flex-utilities/tree/f8468bad
Diff: http://git-wip-us.apache.org/repos/asf/flex-utilities/diff/f8468bad

Branch: refs/heads/mavenizer-refactoring
Commit: f8468bad7109f936ff3536ed65f949ed031c8f9a
Parents: b9ca520
Author: Christofer Dutz <christofer.d...@c-ware.de>
Authored: Sat May 24 12:34:13 2014 +0200
Committer: Christofer Dutz <christofer.d...@c-ware.de>
Committed: Sat May 24 12:34:13 2014 +0200

----------------------------------------------------------------------
 .../converter/retrievers/types/SdkType.java     | 16 +++++++
 .../retrievers/download/DownloadRetriever.java  | 49 +++++++++++++++++---
 .../src/main/resources/message.properties       | 21 +++++++++
 3 files changed, 80 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/f8468bad/mavenizer/retrievers/base/src/main/java/org/apache/flex/utilities/converter/retrievers/types/SdkType.java
----------------------------------------------------------------------
diff --git 
a/mavenizer/retrievers/base/src/main/java/org/apache/flex/utilities/converter/retrievers/types/SdkType.java
 
b/mavenizer/retrievers/base/src/main/java/org/apache/flex/utilities/converter/retrievers/types/SdkType.java
index b2ba4df..f551ab1 100644
--- 
a/mavenizer/retrievers/base/src/main/java/org/apache/flex/utilities/converter/retrievers/types/SdkType.java
+++ 
b/mavenizer/retrievers/base/src/main/java/org/apache/flex/utilities/converter/retrievers/types/SdkType.java
@@ -1,3 +1,19 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
 package org.apache.flex.utilities.converter.retrievers.types;
 
 /**

http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/f8468bad/mavenizer/retrievers/download/src/main/java/org/apache/flex/utilities/converter/retrievers/download/DownloadRetriever.java
----------------------------------------------------------------------
diff --git 
a/mavenizer/retrievers/download/src/main/java/org/apache/flex/utilities/converter/retrievers/download/DownloadRetriever.java
 
b/mavenizer/retrievers/download/src/main/java/org/apache/flex/utilities/converter/retrievers/download/DownloadRetriever.java
index 05a839d..0bf26b2 100644
--- 
a/mavenizer/retrievers/download/src/main/java/org/apache/flex/utilities/converter/retrievers/download/DownloadRetriever.java
+++ 
b/mavenizer/retrievers/download/src/main/java/org/apache/flex/utilities/converter/retrievers/download/DownloadRetriever.java
@@ -40,6 +40,7 @@ import java.net.URL;
 import java.net.URLConnection;
 import java.nio.channels.Channels;
 import java.nio.channels.ReadableByteChannel;
+import java.util.Properties;
 
 /**
  * Created by cdutz on 18.05.2014.
@@ -56,6 +57,10 @@ public class DownloadRetriever extends BaseRetriever {
     @Override
     public File retrieve(SDKType type, String version, PlatformType 
platformType) throws RetrieverException {
         try {
+            if (type.equals(SDKType.FLASH) || type.equals(SDKType.AIR)) {
+                confirmLicenseAcceptance(type);
+            }
+
             // Define the source.
             final URL sourceUrl = new URL(getBinaryUrl(type, version, 
platformType));
             final URLConnection connection = sourceUrl.openConnection();
@@ -183,19 +188,51 @@ public class DownloadRetriever extends BaseRetriever {
         return stringBuilder.toString();
     }
 
+    protected void confirmLicenseAcceptance(SDKType type) throws 
RetrieverException {
+        final Properties questionProps = new Properties();
+        try {
+            
questionProps.load(DownloadRetriever.class.getClassLoader().getResourceAsStream("message.properties"));
+        } catch (IOException e) {
+            throw new RetrieverException("Error reading message.properties 
file", e);
+        }
+
+        final String question;
+        if(type.equals(SDKType.FLASH)) {
+            question = 
questionProps.getProperty("ASK_ADOBE_FLASH_PLAYER_GLOBAL_SWC");
+        } else if(type.equals(SDKType.AIR)) {
+            question = 
questionProps.getProperty("ASK_ADOBE_FLASH_PLAYER_GLOBAL_SWC");
+        } else {
+            throw new RetrieverException("Unknown SDKType");
+        }
+        System.out.println(question);
+        System.out.print(questionProps.getProperty("DO_YOU_ACCEPT_QUESTION") + 
" ");
+        final BufferedReader reader = new BufferedReader(new 
InputStreamReader(System.in));
+        try {
+            final String answer = reader.readLine();
+            if (!"YES".equalsIgnoreCase(answer)) {
+                System.out.println("You have to accept the license agreement 
in order to proceed.");
+                throw new RetrieverException("You have to accept the license 
agreement in order to proceed.");
+            }
+        } catch(IOException e) {
+            throw new RetrieverException("Couldn't read from Stdin.");
+        }
+    }
+
+
+
     public static void main(String[] args) throws Exception {
         final DownloadRetriever retriever = new DownloadRetriever();
 
         // Test the retrieval of Flex SDKs
-        retriever.retrieve(SDKType.FLEX, "4.9.1");
+        /*retriever.retrieve(SDKType.FLEX, "4.9.1");
         retriever.retrieve(SDKType.FLEX, "4.10.0");
         retriever.retrieve(SDKType.FLEX, "4.11.0");
         retriever.retrieve(SDKType.FLEX, "4.12.0");
         retriever.retrieve(SDKType.FLEX, "4.12.1");
-        retriever.retrieve(SDKType.FLEX, "Nightly");
+        retriever.retrieve(SDKType.FLEX, "Nightly");*/
 
         // Test the retrieval of AIR SDKs
-        retriever.retrieve(SDKType.AIR, "2.6", PlatformType.WINDOWS);
+        /*retriever.retrieve(SDKType.AIR, "2.6", PlatformType.WINDOWS);
         retriever.retrieve(SDKType.AIR, "2.6", PlatformType.MAC);
         retriever.retrieve(SDKType.AIR, "2.6", PlatformType.LINUX);
         retriever.retrieve(SDKType.AIR, "2.7", PlatformType.WINDOWS);
@@ -225,11 +262,11 @@ public class DownloadRetriever extends BaseRetriever {
         retriever.retrieve(SDKType.AIR, "13.0", PlatformType.WINDOWS);
         retriever.retrieve(SDKType.AIR, "13.0", PlatformType.MAC);
         retriever.retrieve(SDKType.AIR, "14.0", PlatformType.WINDOWS);
-        retriever.retrieve(SDKType.AIR, "14.0", PlatformType.MAC);
+        retriever.retrieve(SDKType.AIR, "14.0", PlatformType.MAC);*/
 
         // Test the retrieval of Flash SDKs
         retriever.retrieve(SDKType.FLASH, "10.2");
-        retriever.retrieve(SDKType.FLASH, "10.3");
+        /*retriever.retrieve(SDKType.FLASH, "10.3");
         retriever.retrieve(SDKType.FLASH, "11.0");
         retriever.retrieve(SDKType.FLASH, "11.1");
         retriever.retrieve(SDKType.FLASH, "11.2");
@@ -242,7 +279,7 @@ public class DownloadRetriever extends BaseRetriever {
         retriever.retrieve(SDKType.FLASH, "11.9");
         retriever.retrieve(SDKType.FLASH, "12.0");
         retriever.retrieve(SDKType.FLASH, "13.0");
-        retriever.retrieve(SDKType.FLASH, "14.0");
+        retriever.retrieve(SDKType.FLASH, "14.0");*/
 
     }
 

http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/f8468bad/mavenizer/retrievers/download/src/main/resources/message.properties
----------------------------------------------------------------------
diff --git 
a/mavenizer/retrievers/download/src/main/resources/message.properties 
b/mavenizer/retrievers/download/src/main/resources/message.properties
new file mode 100644
index 0000000..b799623
--- /dev/null
+++ b/mavenizer/retrievers/download/src/main/resources/message.properties
@@ -0,0 +1,21 @@
+################################################################################
+##
+##  Licensed to the Apache Software Foundation (ASF) under one or more
+##  contributor license agreements.  See the NOTICE file distributed with
+##  this work for additional information regarding copyright ownership.
+##  The ASF licenses this file to You under the Apache License, Version 2.0
+##  (the "License"); you may not use this file except in compliance with
+##  the License.  You may obtain a copy of the License at
+##
+##      http://www.apache.org/licenses/LICENSE-2.0
+##
+##  Unless required by applicable law or agreed to in writing, software
+##  distributed under the License is distributed on an "AS IS" BASIS,
+##  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+##  See the License for the specific language governing permissions and
+##  limitations under the License.
+##
+################################################################################
+ASK_ADOBE_AIR_SDK=The Adobe SDK license agreement applies to the Adobe AIR 
SDK. Do you want to install the Adobe AIR SDK? Adobe AIR SDK License: 
http://www.adobe.com/products/air/sdk-eula.html
+ASK_ADOBE_FLASH_PLAYER_GLOBAL_SWC=The Adobe SDK license agreement applies to 
the Adobe Flash Player playerglobal.swc. Do you want to install the Adobe Flash 
Player playerglobal.swc?
+DO_YOU_ACCEPT_QUESTION=Do you accept (Yes/No)?
\ No newline at end of file

Reply via email to