You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@flex.apache.org by cd...@apache.org on 2015/09/03 12:41:11 UTC
git commit: [flex-utilities] [refs/heads/develop] - - Made the
converter use proxy settings too - Refactored the way the proxy settings are
handled (Now they are saved in a singleton instead of piping them through the
method calls) - Made the BaseConvert
Repository: flex-utilities
Updated Branches:
refs/heads/develop bbb98e984 -> c69b8a609
- Made the converter use proxy settings too
- Refactored the way the proxy settings are handled (Now they are saved in a singleton instead of piping them through the method calls)
- Made the BaseConverter use the same client code to query for artifacts (Removed jersey client)
- Removed duplicated code
Project: http://git-wip-us.apache.org/repos/asf/flex-utilities/repo
Commit: http://git-wip-us.apache.org/repos/asf/flex-utilities/commit/c69b8a60
Tree: http://git-wip-us.apache.org/repos/asf/flex-utilities/tree/c69b8a60
Diff: http://git-wip-us.apache.org/repos/asf/flex-utilities/diff/c69b8a60
Branch: refs/heads/develop
Commit: c69b8a6093ee70ef0f92681824de9838b19f6cfd
Parents: bbb98e9
Author: Christofer Dutz <ch...@codecentric.de>
Authored: Thu Sep 3 12:41:00 2015 +0200
Committer: Christofer Dutz <ch...@codecentric.de>
Committed: Thu Sep 3 12:41:00 2015 +0200
----------------------------------------------------------------------
flex-maven-tools/flex-sdk-converter/api/pom.xml | 33 +++
.../utilities/converter/api/ProxySettings.java | 58 ++++++
flex-maven-tools/flex-sdk-converter/cli/pom.xml | 6 +
.../converter/core/SdkConverterCLI.java | 60 +++++-
.../flex-sdk-converter/converters/base/pom.xml | 7 +-
.../flex/utilities/converter/BaseConverter.java | 208 +++++++++++--------
.../utilities/converter/flex/FlexConverter.java | 72 -------
.../converter/wrapper/WrapperConverter.java | 42 ----
.../converter/mavenextension/FlexEventSpy.java | 41 ++--
flex-maven-tools/flex-sdk-converter/pom.xml | 1 +
.../flex-sdk-converter/retrievers/base/pom.xml | 6 +
.../converter/retrievers/Retriever.java | 4 -
.../retrievers/model/ProxySettings.java | 48 -----
.../retrievers/download/DownloadRetriever.java | 30 ++-
.../retrievers/download/ProxyTest.java | 14 +-
15 files changed, 334 insertions(+), 296 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/c69b8a60/flex-maven-tools/flex-sdk-converter/api/pom.xml
----------------------------------------------------------------------
diff --git a/flex-maven-tools/flex-sdk-converter/api/pom.xml b/flex-maven-tools/flex-sdk-converter/api/pom.xml
new file mode 100644
index 0000000..15e1a2a
--- /dev/null
+++ b/flex-maven-tools/flex-sdk-converter/api/pom.xml
@@ -0,0 +1,33 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ 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.
+
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.apache.flex.utilities.converter</groupId>
+ <artifactId>apache-flex-sdk-converter</artifactId>
+ <version>1.0.0-SNAPSHOT</version>
+ </parent>
+
+ <artifactId>api</artifactId>
+ <version>1.0.0-SNAPSHOT</version>
+ <packaging>jar</packaging>
+
+</project>
http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/c69b8a60/flex-maven-tools/flex-sdk-converter/api/src/main/java/org/apache/flex/utilities/converter/api/ProxySettings.java
----------------------------------------------------------------------
diff --git a/flex-maven-tools/flex-sdk-converter/api/src/main/java/org/apache/flex/utilities/converter/api/ProxySettings.java b/flex-maven-tools/flex-sdk-converter/api/src/main/java/org/apache/flex/utilities/converter/api/ProxySettings.java
new file mode 100644
index 0000000..5ed76da
--- /dev/null
+++ b/flex-maven-tools/flex-sdk-converter/api/src/main/java/org/apache/flex/utilities/converter/api/ProxySettings.java
@@ -0,0 +1,58 @@
+package org.apache.flex.utilities.converter.api;
+
+/**
+ * Created by christoferdutz on 01.07.15.
+ */
+public class ProxySettings {
+
+ private static ProxySettings proxySettings = null;
+
+ public static void setProxySettings(ProxySettings proxySettings) {
+ ProxySettings.proxySettings = proxySettings;
+ }
+
+ public static ProxySettings getProxySettings() {
+ return proxySettings;
+ }
+
+ private String protocol;
+ private String host;
+ private int port;
+ private String nonProxyHost;
+ private String username;
+ private String password;
+
+ public ProxySettings(String protocol, String host, int port, String nonProxyHost, String username, String password) {
+ this.protocol = protocol;
+ this.host = host;
+ this.port = port;
+ this.nonProxyHost = nonProxyHost;
+ this.username = username;
+ this.password = password;
+ }
+
+ public String getProtocol() {
+ return protocol;
+ }
+
+ public String getHost() {
+ return host;
+ }
+
+ public int getPort() {
+ return port;
+ }
+
+ public String getNonProxyHost() {
+ return nonProxyHost;
+ }
+
+ public String getUsername() {
+ return username;
+ }
+
+ public String getPassword() {
+ return password;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/c69b8a60/flex-maven-tools/flex-sdk-converter/cli/pom.xml
----------------------------------------------------------------------
diff --git a/flex-maven-tools/flex-sdk-converter/cli/pom.xml b/flex-maven-tools/flex-sdk-converter/cli/pom.xml
index 511ac31..7176ed1 100644
--- a/flex-maven-tools/flex-sdk-converter/cli/pom.xml
+++ b/flex-maven-tools/flex-sdk-converter/cli/pom.xml
@@ -67,6 +67,12 @@
<dependencies>
<dependency>
<groupId>org.apache.flex.utilities.converter</groupId>
+ <artifactId>api</artifactId>
+ <version>1.0.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.flex.utilities.converter</groupId>
<artifactId>download-retriever</artifactId>
<version>1.0.0-SNAPSHOT</version>
</dependency>
http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/c69b8a60/flex-maven-tools/flex-sdk-converter/cli/src/main/java/org/apache/flex/utilities/converter/core/SdkConverterCLI.java
----------------------------------------------------------------------
diff --git a/flex-maven-tools/flex-sdk-converter/cli/src/main/java/org/apache/flex/utilities/converter/core/SdkConverterCLI.java b/flex-maven-tools/flex-sdk-converter/cli/src/main/java/org/apache/flex/utilities/converter/core/SdkConverterCLI.java
index 918dd70..8cf0522 100644
--- a/flex-maven-tools/flex-sdk-converter/cli/src/main/java/org/apache/flex/utilities/converter/core/SdkConverterCLI.java
+++ b/flex-maven-tools/flex-sdk-converter/cli/src/main/java/org/apache/flex/utilities/converter/core/SdkConverterCLI.java
@@ -3,6 +3,7 @@ package org.apache.flex.utilities.converter.core;
import org.apache.commons.cli.*;
import org.apache.commons.io.FileUtils;
import org.apache.flex.utilities.converter.air.AirConverter;
+import org.apache.flex.utilities.converter.api.ProxySettings;
import org.apache.flex.utilities.converter.deployer.aether.AetherDeployer;
import org.apache.flex.utilities.converter.flash.FlashConverter;
import org.apache.flex.utilities.converter.flex.FlexConverter;
@@ -41,6 +42,13 @@ public class SdkConverterCLI {
public static final String OPTION_REPO_USERNAME = "repoUsername";
public static final String OPTION_REPO_PASSWORD = "repoPassword";
+ public static final String OPTION_PROXY_PROTOCOL = "proxyProtocol";
+ public static final String OPTION_PROXY_HOST = "proxyHost";
+ public static final String OPTION_PROXY_PORT = "proxyPort";
+ public static final String OPTION_PROXY_NON_PROXY_HOST = "proxyNonProxyHost";
+ public static final String OPTION_PROXY_USERNAME = "proxyUsername";
+ public static final String OPTION_PROXY_PASSWORD = "proxyPassword";
+
@SuppressWarnings("unchecked")
public static void main(String[] args) throws Exception {
@@ -103,6 +111,36 @@ public class SdkConverterCLI {
"deployed to.").
isRequired(false).
create(OPTION_REPO_PASSWORD));
+ options.addOption(OptionBuilder.withArgName("protocol").hasArg().
+ withDescription("(Optional and only valid when providing a proxy host and port) protocol " +
+ "to be used to communicate through a proxy server.").
+ isRequired(false).
+ create(OPTION_PROXY_PROTOCOL));
+ options.addOption(OptionBuilder.withArgName("host").hasArg().
+ withDescription("(Optional and only valid when providing a proxy host and port) host name " +
+ "of the proxy server.").
+ isRequired(false).
+ create(OPTION_PROXY_HOST));
+ options.addOption(OptionBuilder.withArgName("port").hasArg().
+ withDescription("(Optional and only valid when providing a proxy host and port) port " +
+ "of the proxy server.").
+ isRequired(false).
+ create(OPTION_PROXY_HOST));
+ options.addOption(OptionBuilder.withArgName("non-proxy-host(s)").hasArg().
+ withDescription("(Optional and only valid when providing a proxy host and port) list of " +
+ "hosts that should not use the proxy server.").
+ isRequired(false).
+ create(OPTION_PROXY_NON_PROXY_HOST));
+ options.addOption(OptionBuilder.withArgName("username").hasArg().
+ withDescription("(Optional and only valid when providing a proxy host and port) username " +
+ "used to authenticate at the proxy server.").
+ isRequired(false).
+ create(OPTION_PROXY_USERNAME));
+ options.addOption(OptionBuilder.withArgName("password").hasArg().
+ withDescription("(Optional and only valid when providing a proxy host and port) password " +
+ "used to authenticate at the proxy server.").
+ isRequired(false).
+ create(OPTION_PROXY_PASSWORD));
CommandLineParser parser = new BasicParser();
try {
@@ -189,6 +227,11 @@ public class SdkConverterCLI {
// Exectute operations
////////////////////////////////////////////////////////////////////////////
+ // Get proxy settings from the commandline and save them in the
+ // ProxySettings "singleton".
+ ProxySettings proxySettings = getProxySettings(cmd);
+ ProxySettings.setProxySettings(proxySettings);
+
// Output a list of all available downloads.
if(cmd.getArgList().contains(COMMAND_LIST)) {
System.out.println("-----------------------------------------------");
@@ -369,7 +412,9 @@ public class SdkConverterCLI {
"Options:";
HelpFormatter helpFormatter = new HelpFormatter();
- helpFormatter.printHelp("java -jar apache-flex-sdk-converter.jar [list] [-fdkDir <fdkDir>] " +
+ helpFormatter.printHelp("java -jar apache-flex-sdk-converter.jar [-proxyProtocol <http|https|socks> " +
+ "-proxyHost <host> -proxyPort <port> [-proxyNonProxyHost <non-proxy-host(s)>] " +
+ "[-proxyUser <username> -proxyPassword <password>]] [list] [-fdkDir <fdkDir>] " +
"[-mavenDir <mavenDir>] [[-flexVersion <version>] [-flashVersions <version(s)>] " +
"[-airVersion <version> [-platforms <platform(s)>]] [-fontkit] download] [convert] " +
"[-repoUrl <url> [-repoUsername <username> -repoPassword <password>] deploy]",
@@ -387,6 +432,19 @@ public class SdkConverterCLI {
return tempDir;
}
+ protected static ProxySettings getProxySettings(CommandLine cmd) {
+ if(cmd.hasOption(OPTION_PROXY_HOST)) {
+ String protocol = cmd.getOptionValue(OPTION_PROXY_PROTOCOL);
+ String host = cmd.getOptionValue(OPTION_PROXY_HOST);
+ String nonProxyHost = cmd.getOptionValue(OPTION_PROXY_NON_PROXY_HOST);
+ int port = cmd.hasOption(OPTION_PROXY_PORT) ? Integer.valueOf(cmd.getOptionValue(OPTION_PROXY_PORT)) : 0;
+ String username = cmd.getOptionValue(OPTION_PROXY_USERNAME);
+ String password = cmd.getOptionValue(OPTION_PROXY_PASSWORD);
+ return new ProxySettings(protocol, host, port, nonProxyHost, username, password);
+ }
+ return null;
+ }
+
protected static void mergeDirectories(File sourceDir, File targetDir) throws IOException {
FileUtils.copyDirectory(sourceDir, targetDir);
}
http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/c69b8a60/flex-maven-tools/flex-sdk-converter/converters/base/pom.xml
----------------------------------------------------------------------
diff --git a/flex-maven-tools/flex-sdk-converter/converters/base/pom.xml b/flex-maven-tools/flex-sdk-converter/converters/base/pom.xml
index 5a1b89c..71d9a92 100644
--- a/flex-maven-tools/flex-sdk-converter/converters/base/pom.xml
+++ b/flex-maven-tools/flex-sdk-converter/converters/base/pom.xml
@@ -32,10 +32,11 @@
<dependencies>
<dependency>
- <groupId>com.sun.jersey</groupId>
- <artifactId>jersey-client</artifactId>
- <version>1.12</version>
+ <groupId>org.apache.flex.utilities.converter</groupId>
+ <artifactId>api</artifactId>
+ <version>1.0.0-SNAPSHOT</version>
</dependency>
+
<dependency>
<groupId>org.codehaus.jettison</groupId>
<artifactId>jettison</artifactId>
http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/c69b8a60/flex-maven-tools/flex-sdk-converter/converters/base/src/main/java/org/apache/flex/utilities/converter/BaseConverter.java
----------------------------------------------------------------------
diff --git a/flex-maven-tools/flex-sdk-converter/converters/base/src/main/java/org/apache/flex/utilities/converter/BaseConverter.java b/flex-maven-tools/flex-sdk-converter/converters/base/src/main/java/org/apache/flex/utilities/converter/BaseConverter.java
index 65e5bd7..fce6ae1 100644
--- a/flex-maven-tools/flex-sdk-converter/converters/base/src/main/java/org/apache/flex/utilities/converter/BaseConverter.java
+++ b/flex-maven-tools/flex-sdk-converter/converters/base/src/main/java/org/apache/flex/utilities/converter/BaseConverter.java
@@ -16,22 +16,29 @@
*/
package org.apache.flex.utilities.converter;
-import com.sun.jersey.api.client.Client;
-import com.sun.jersey.api.client.ClientResponse;
-import com.sun.jersey.api.client.WebResource;
import freemarker.template.Configuration;
import freemarker.template.Template;
import freemarker.template.TemplateExceptionHandler;
+import org.apache.flex.utilities.converter.api.ProxySettings;
import org.apache.flex.utilities.converter.exceptions.ConverterException;
import org.apache.flex.utilities.converter.model.MavenArtifact;
import org.codehaus.jettison.json.JSONArray;
import org.codehaus.jettison.json.JSONException;
import org.codehaus.jettison.json.JSONObject;
import org.codehaus.jettison.json.JSONTokener;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.xml.sax.SAXException;
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
import java.io.*;
import java.math.BigInteger;
-import java.net.URL;
+import java.net.*;
+import java.nio.ByteBuffer;
+import java.nio.channels.Channels;
+import java.nio.channels.ReadableByteChannel;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.HashMap;
@@ -124,79 +131,93 @@ public abstract class BaseConverter {
}
protected MavenArtifact lookupMetadataForChecksum(String checksum) throws ConverterException {
- final String queryUrl = MAVEN_CENTRAL_SHA_1_QUERY_URL + checksum;
-
- final Client client = Client.create();
- final WebResource webResource = client.resource(queryUrl);
- final ClientResponse response = webResource.accept("application/json").get(ClientResponse.class);
-
- if (response.getStatus() != 200) {
- throw new RuntimeException("Failed : HTTP error code : " + response.getStatus());
- }
-
- final String output = response.getEntity(String.class);
-
- final BufferedReader reader = new BufferedReader(new StringReader(output));
- final StringBuilder builder = new StringBuilder();
+ String output = null;
try {
- for (String line; (line = reader.readLine()) != null; ) {
- builder.append(line).append("\n");
+ final URL queryUrl = new URL(MAVEN_CENTRAL_SHA_1_QUERY_URL + checksum);
+
+ URLConnection connection;
+ ProxySettings proxySettings = ProxySettings.getProxySettings();
+ if (proxySettings != null) {
+ SocketAddress socketAddress = new InetSocketAddress(proxySettings.getHost(), proxySettings.getPort());
+ Proxy proxy = new Proxy(Proxy.Type.valueOf(proxySettings.getProtocol().toUpperCase()), socketAddress);
+ connection = queryUrl.openConnection(proxy);
+ } else {
+ connection = queryUrl.openConnection();
}
- final JSONTokener tokener = new JSONTokener(builder.toString());
- final JSONObject rootObject = new JSONObject(tokener);
-
- final JSONObject responseObject = (JSONObject) rootObject.get("response");
- final int numFound = (Integer) responseObject.get("numFound");
- if(numFound == 0) {
- return null;
+ final ReadableByteChannel rbc = Channels.newChannel(connection.getInputStream());
+ final ByteBuffer byteBuffer = ByteBuffer.allocate(1024);
+ if(rbc.read(byteBuffer) > 0) {
+ output = new String (byteBuffer.array(), "UTF-8");
}
- else if(numFound == 1) {
- final JSONArray docs = (JSONArray) responseObject.get("docs");
- final JSONObject firstHit = (JSONObject) docs.get(0);
-
- final MavenArtifact artifactMetadata = new MavenArtifact();
- artifactMetadata.setGroupId((String) firstHit.get("g"));
- artifactMetadata.setArtifactId((String) firstHit.get("a"));
- artifactMetadata.setVersion((String) firstHit.get("v"));
- artifactMetadata.setPackaging((String) firstHit.get("p"));
+ } catch (MalformedURLException e) {
+ throw new ConverterException("Error querying maven central.", e);
+ } catch (IOException e) {
+ throw new ConverterException("Error querying maven central.", e);
+ }
- return artifactMetadata;
- } else {
- long newestTimestamp = 0;
- JSONObject newestVersion = null;
-
- JSONArray options = (JSONArray) responseObject.get("docs");
- // if the "groupId" is "batik" then use the newer version.
- for(int i = 0; i < numFound; i++) {
- final JSONObject option = (JSONObject) options.get(0);
- if("batik".equals(option.get("g")) && "batik-dom".equals(option.get("a")) && "jar".equals(option.get("p"))) {
- final long timestamp = (Long) option.get("timestamp");
- if(timestamp > newestTimestamp) {
- newestTimestamp = timestamp;
- newestVersion = option;
- }
- }
+ if(output != null) {
+ final BufferedReader reader = new BufferedReader(new StringReader(output));
+ final StringBuilder builder = new StringBuilder();
+ try {
+ for (String line; (line = reader.readLine()) != null; ) {
+ builder.append(line).append("\n");
}
+ final JSONTokener tokener = new JSONTokener(builder.toString());
+ final JSONObject rootObject = new JSONObject(tokener);
+
+ final JSONObject responseObject = (JSONObject) rootObject.get("response");
+ final int numFound = (Integer) responseObject.get("numFound");
+ if (numFound == 0) {
+ return null;
+ } else if (numFound == 1) {
+ final JSONArray docs = (JSONArray) responseObject.get("docs");
+ final JSONObject firstHit = (JSONObject) docs.get(0);
- if(newestVersion != null) {
final MavenArtifact artifactMetadata = new MavenArtifact();
- artifactMetadata.setGroupId((String) newestVersion.get("g"));
- artifactMetadata.setArtifactId((String) newestVersion.get("a"));
- artifactMetadata.setVersion((String) newestVersion.get("v"));
- artifactMetadata.setPackaging((String) newestVersion.get("p"));
+ artifactMetadata.setGroupId((String) firstHit.get("g"));
+ artifactMetadata.setArtifactId((String) firstHit.get("a"));
+ artifactMetadata.setVersion((String) firstHit.get("v"));
+ artifactMetadata.setPackaging((String) firstHit.get("p"));
return artifactMetadata;
} else {
- System.out.println("For jar-file with checksum: " + checksum +
- " more than one result was returned by query: " + queryUrl);
+ long newestTimestamp = 0;
+ JSONObject newestVersion = null;
+
+ JSONArray options = (JSONArray) responseObject.get("docs");
+ // if the "groupId" is "batik" then use the newer version.
+ for (int i = 0; i < numFound; i++) {
+ final JSONObject option = (JSONObject) options.get(0);
+ if ("batik".equals(option.get("g")) && "batik-dom".equals(option.get("a")) && "jar".equals(option.get("p"))) {
+ final long timestamp = (Long) option.get("timestamp");
+ if (timestamp > newestTimestamp) {
+ newestTimestamp = timestamp;
+ newestVersion = option;
+ }
+ }
+ }
+
+ if (newestVersion != null) {
+ final MavenArtifact artifactMetadata = new MavenArtifact();
+ artifactMetadata.setGroupId((String) newestVersion.get("g"));
+ artifactMetadata.setArtifactId((String) newestVersion.get("a"));
+ artifactMetadata.setVersion((String) newestVersion.get("v"));
+ artifactMetadata.setPackaging((String) newestVersion.get("p"));
+
+ return artifactMetadata;
+ } else {
+ System.out.println("For jar-file with checksum: " + checksum +
+ " more than one result was returned by query: " +
+ MAVEN_CENTRAL_SHA_1_QUERY_URL + checksum);
+ }
}
+ } catch (IOException e) {
+ throw new ConverterException("Error processing Metadata for checksum: '" + checksum + "'", e);
+ } catch (JSONException e) {
+ throw new ConverterException("Error processing Metadata for checksum: '" + checksum + "'", e);
}
- return null;
- } catch(IOException e) {
- throw new ConverterException("Error processing Metadata for checksum: '" + checksum + "'", e);
- } catch (JSONException e) {
- throw new ConverterException("Error processing Metadata for checksum: '" + checksum + "'", e);
}
+ return null;
}
protected void copyFile(File source, File target) throws ConverterException {
@@ -233,7 +254,7 @@ public abstract class BaseConverter {
protected void createPomDocument(final MavenArtifact metadata, File outputFile) throws ConverterException {
try {
// Build a context to hold the model
- Map freemarkerContext = new HashMap();
+ Map<String, Object> freemarkerContext = new HashMap<String, Object>();
freemarkerContext.put("artifact", metadata);
// Try to get a template "templates/{type}.vm".
@@ -279,27 +300,6 @@ public abstract class BaseConverter {
}
}
- protected static File findDirectory(File directory, String directoryToFind) {
- File[] entries = directory.listFiles();
- File founded = null;
-
- // Go over entries
- if(entries != null) {
- for (File entry : entries) {
- if (entry.isDirectory() && directoryToFind.equalsIgnoreCase(entry.getName())) {
- founded = entry;
- break;
- }
- if (entry.isDirectory()) {
- founded = findDirectory(entry, directoryToFind);
- if (founded != null)
- break;
- }
- }
- }
- return founded;
- }
-
protected MavenArtifact resolveArtifact(File sourceFile, String defaultGroupId, String defaultVersion)
throws ConverterException {
// Calculate a checksum for the current file. We will use this checksum to query maven central
@@ -423,4 +423,40 @@ public abstract class BaseConverter {
}
}
+ /**
+ * Get the version of an Flex SDK from the content of the SDK directory.
+ *
+ * @return version string for the current Flex SDK
+ */
+ protected String getFlexVersion(File rootDirectory) throws ConverterException {
+ final File sdkDescriptor = new File(rootDirectory, "flex-sdk-description.xml");
+
+ // If the descriptor is not present, return null as this FDK directory doesn't
+ // seem to contain a Flex SDK.
+ if(!sdkDescriptor.exists()) {
+ return null;
+ }
+
+ final DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
+ try {
+ // Parse the document
+ final DocumentBuilder db = dbf.newDocumentBuilder();
+ final Document dom = db.parse(sdkDescriptor);
+
+ // Get name, version and build nodes
+ final Element root = dom.getDocumentElement();
+ final String version = root.getElementsByTagName("version").item(0).getTextContent();
+ final String build = root.getElementsByTagName("build").item(0).getTextContent();
+
+ // In general the version consists of the content of the version element with an appended build-number.
+ return (build.equals("0")) ? version + "-SNAPSHOT" : version;
+ } catch (ParserConfigurationException pce) {
+ throw new RuntimeException(pce);
+ } catch (SAXException se) {
+ throw new RuntimeException(se);
+ } catch (IOException ioe) {
+ throw new RuntimeException(ioe);
+ }
+ }
+
}
http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/c69b8a60/flex-maven-tools/flex-sdk-converter/converters/flex/src/main/java/org/apache/flex/utilities/converter/flex/FlexConverter.java
----------------------------------------------------------------------
diff --git a/flex-maven-tools/flex-sdk-converter/converters/flex/src/main/java/org/apache/flex/utilities/converter/flex/FlexConverter.java b/flex-maven-tools/flex-sdk-converter/converters/flex/src/main/java/org/apache/flex/utilities/converter/flex/FlexConverter.java
index 9fda04f..e5a178a 100644
--- a/flex-maven-tools/flex-sdk-converter/converters/flex/src/main/java/org/apache/flex/utilities/converter/flex/FlexConverter.java
+++ b/flex-maven-tools/flex-sdk-converter/converters/flex/src/main/java/org/apache/flex/utilities/converter/flex/FlexConverter.java
@@ -32,7 +32,6 @@ import javax.xml.parsers.ParserConfigurationException;
import java.io.*;
import java.util.*;
import java.util.jar.JarOutputStream;
-import java.util.zip.ZipEntry;
import java.util.zip.ZipOutputStream;
/**
@@ -523,77 +522,6 @@ public class FlexConverter extends BaseConverter implements Converter {
return result;
}
- protected void addFileToZip(ZipOutputStream zipOutputStream, File inputFile, File rootDirectory)
- throws ConverterException {
- if (inputFile == null) {
- return;
- }
-
- // If this is a directory, add all it's children.
- if (inputFile.isDirectory()) {
- final File directoryContent[] = inputFile.listFiles();
- if (directoryContent != null) {
- for (final File file : directoryContent) {
- addFileToZip(zipOutputStream, file, rootDirectory);
- }
- }
- }
- // If this is a file, add it to the zips output.
- else {
- byte[] buf = new byte[1024];
- try {
- final FileInputStream in = new FileInputStream(inputFile);
- final String zipPath = inputFile.getAbsolutePath().substring(
- rootDirectory.getAbsolutePath().length() + 1).replace("\\", "/");
- zipOutputStream.putNextEntry(new ZipEntry(zipPath));
- int len;
- while ((len = in.read(buf)) > 0) {
- zipOutputStream.write(buf, 0, len);
- }
- zipOutputStream.closeEntry();
- in.close();
- } catch(IOException e) {
- throw new ConverterException("Error adding files to zip.", e);
- }
- }
- }
-
- /**
- * Get the version of an Flex SDK from the content of the SDK directory.
- *
- * @return version string for the current Flex SDK
- */
- protected String getFlexVersion(File rootDirectory) throws ConverterException {
- final File sdkDescriptor = new File(rootDirectory, "flex-sdk-description.xml");
-
- // If the descriptor is not present, return null as this FDK directory doesn't
- // seem to contain a Flex SDK.
- if(!sdkDescriptor.exists()) {
- return null;
- }
-
- final DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
- try {
- // Parse the document
- final DocumentBuilder db = dbf.newDocumentBuilder();
- final Document dom = db.parse(sdkDescriptor);
-
- // Get name, version and build nodes
- final Element root = dom.getDocumentElement();
- final String version = root.getElementsByTagName("version").item(0).getTextContent();
- final String build = root.getElementsByTagName("build").item(0).getTextContent();
-
- // In general the version consists of the content of the version element with an appended build-number.
- return (build.equals("0")) ? version + "-SNAPSHOT" : version;
- } catch (ParserConfigurationException pce) {
- throw new RuntimeException(pce);
- } catch (SAXException se) {
- throw new RuntimeException(se);
- } catch (IOException ioe) {
- throw new RuntimeException(ioe);
- }
- }
-
/**
* Get the version of an Flex SDK from the content of the SDK directory.
*
http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/c69b8a60/flex-maven-tools/flex-sdk-converter/converters/wrapper/src/main/java/org/apache/flex/utilities/converter/wrapper/WrapperConverter.java
----------------------------------------------------------------------
diff --git a/flex-maven-tools/flex-sdk-converter/converters/wrapper/src/main/java/org/apache/flex/utilities/converter/wrapper/WrapperConverter.java b/flex-maven-tools/flex-sdk-converter/converters/wrapper/src/main/java/org/apache/flex/utilities/converter/wrapper/WrapperConverter.java
index 7e4af4c..9425689 100644
--- a/flex-maven-tools/flex-sdk-converter/converters/wrapper/src/main/java/org/apache/flex/utilities/converter/wrapper/WrapperConverter.java
+++ b/flex-maven-tools/flex-sdk-converter/converters/wrapper/src/main/java/org/apache/flex/utilities/converter/wrapper/WrapperConverter.java
@@ -4,13 +4,7 @@ import org.apache.flex.utilities.converter.BaseConverter;
import org.apache.flex.utilities.converter.Converter;
import org.apache.flex.utilities.converter.exceptions.ConverterException;
import org.apache.flex.utilities.converter.model.MavenArtifact;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-import org.xml.sax.SAXException;
-import javax.xml.parsers.DocumentBuilder;
-import javax.xml.parsers.DocumentBuilderFactory;
-import javax.xml.parsers.ParserConfigurationException;
import java.io.File;
import java.io.IOException;
@@ -54,40 +48,4 @@ public class WrapperConverter extends BaseConverter implements Converter {
}
}
- /**
- * Get the version of an Flex SDK from the content of the SDK directory.
- *
- * @return version string for the current Flex SDK
- */
- protected String getFlexVersion(File rootDirectory) throws ConverterException {
- final File sdkDescriptor = new File(rootDirectory, "flex-sdk-description.xml");
-
- // If the descriptor is not present, return null as this FDK directory doesn't
- // seem to contain a Flex SDK.
- if(!sdkDescriptor.exists()) {
- return null;
- }
-
- final DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
- try {
- // Parse the document
- final DocumentBuilder db = dbf.newDocumentBuilder();
- final Document dom = db.parse(sdkDescriptor);
-
- // Get name, version and build nodes
- final Element root = dom.getDocumentElement();
- final String version = root.getElementsByTagName("version").item(0).getTextContent();
- final String build = root.getElementsByTagName("build").item(0).getTextContent();
-
- // In general the version consists of the content of the version element with an appended build-number.
- return (build.equals("0")) ? version + "-SNAPSHOT" : version;
- } catch (ParserConfigurationException pce) {
- throw new RuntimeException(pce);
- } catch (SAXException se) {
- throw new RuntimeException(se);
- } catch (IOException ioe) {
- throw new RuntimeException(ioe);
- }
- }
-
}
http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/c69b8a60/flex-maven-tools/flex-sdk-converter/maven-extension/src/main/java/org/apache/flex/utilities/converter/mavenextension/FlexEventSpy.java
----------------------------------------------------------------------
diff --git a/flex-maven-tools/flex-sdk-converter/maven-extension/src/main/java/org/apache/flex/utilities/converter/mavenextension/FlexEventSpy.java b/flex-maven-tools/flex-sdk-converter/maven-extension/src/main/java/org/apache/flex/utilities/converter/mavenextension/FlexEventSpy.java
index 8584634..dee94a0 100644
--- a/flex-maven-tools/flex-sdk-converter/maven-extension/src/main/java/org/apache/flex/utilities/converter/mavenextension/FlexEventSpy.java
+++ b/flex-maven-tools/flex-sdk-converter/maven-extension/src/main/java/org/apache/flex/utilities/converter/mavenextension/FlexEventSpy.java
@@ -7,7 +7,7 @@ import org.apache.flex.utilities.converter.flash.FlashConverter;
import org.apache.flex.utilities.converter.flex.FlexConverter;
import org.apache.flex.utilities.converter.fontkit.FontkitConverter;
import org.apache.flex.utilities.converter.retrievers.download.DownloadRetriever;
-import org.apache.flex.utilities.converter.retrievers.model.ProxySettings;
+import org.apache.flex.utilities.converter.api.ProxySettings;
import org.apache.flex.utilities.converter.retrievers.types.PlatformType;
import org.apache.flex.utilities.converter.retrievers.types.SdkType;
import org.apache.flex.utilities.converter.wrapper.WrapperConverter;
@@ -140,22 +140,36 @@ public class FlexEventSpy extends AbstractEventSpy {
logger.info("===========================================================");
logger.info(" - Installing Apache Flex SDK " + version);
try {
- ProxySettings proxySettings = getProxySettings();
+ // Get proxy settings from the maven settings and save them in the
+ // ProxySettings "singleton".
+ final ProxySettings proxySettings = getProxySettings();
+ ProxySettings.setProxySettings(proxySettings);
+ if ((proxySettings != null) && !StringUtils.isEmpty(proxySettings.getUsername()) &&
+ !StringUtils.isEmpty(proxySettings.getPassword())) {
+ Authenticator authenticator = new Authenticator() {
+ @Override
+ protected PasswordAuthentication getPasswordAuthentication() {
+ return new PasswordAuthentication(proxySettings.getUsername(),
+ proxySettings.getPassword().toCharArray());
+ }
+ };
+ Authenticator.setDefault(authenticator);
+ }
File localRepoBaseDir = new File(mavenSession.getLocalRepository().getBasedir());
DownloadRetriever downloadRetriever = new DownloadRetriever();
- File sdkRoot = downloadRetriever.retrieve(SdkType.FLEX, version, null, proxySettings);
+ File sdkRoot = downloadRetriever.retrieve(SdkType.FLEX, version, null);
// In order to create a fully functional wrapper we need to download
// SWFObject and merge that with the fdk first.
- File swfObjectRoot = downloadRetriever.retrieve(SdkType.SWFOBJECT, null, null, proxySettings);
+ File swfObjectRoot = downloadRetriever.retrieve(SdkType.SWFOBJECT, null, null);
FileUtils.copyDirectory(swfObjectRoot, sdkRoot);
// In order to compile some of the themes, we need to download a
// playerglobal version.
logger.info("In order to convert some of the skins in the Apache Flex SDK, " +
"a Flash SDK has to be downloaded.");
- File flashSdkRoot = downloadRetriever.retrieve(SdkType.FLASH, "10.2", null, proxySettings);
+ File flashSdkRoot = downloadRetriever.retrieve(SdkType.FLASH, "10.2", null);
FileUtils.copyDirectory(flashSdkRoot, sdkRoot);
// Convert the FDK itself.
@@ -178,7 +192,7 @@ public class FlexEventSpy extends AbstractEventSpy {
try {
File localRepoBaseDir = new File(mavenSession.getLocalRepository().getBasedir());
DownloadRetriever downloadRetriever = new DownloadRetriever();
- File sdkRoot = downloadRetriever.retrieve(SdkType.FLASH, version, null, getProxySettings());
+ File sdkRoot = downloadRetriever.retrieve(SdkType.FLASH, version);
FlashConverter converter = new FlashConverter(sdkRoot, localRepoBaseDir);
converter.convert();
} catch (Throwable ce) {
@@ -201,7 +215,7 @@ public class FlexEventSpy extends AbstractEventSpy {
} else {
platformType = PlatformType.valueOf(System.getProperty("platform-type"));
}
- File sdkRoot = downloadRetriever.retrieve(SdkType.AIR, version, platformType, getProxySettings());
+ File sdkRoot = downloadRetriever.retrieve(SdkType.AIR, version, platformType);
AirConverter converter = new AirConverter(sdkRoot, localRepoBaseDir);
converter.convert();
} catch (Throwable ce) {
@@ -217,7 +231,7 @@ public class FlexEventSpy extends AbstractEventSpy {
try {
File localRepoBaseDir = new File(mavenSession.getLocalRepository().getBasedir());
DownloadRetriever downloadRetriever = new DownloadRetriever();
- File sdkRoot = downloadRetriever.retrieve(SdkType.FONTKIT, null, null, getProxySettings());
+ File sdkRoot = downloadRetriever.retrieve(SdkType.FONTKIT);
FontkitConverter converter = new FontkitConverter(sdkRoot, localRepoBaseDir);
converter.convert();
} catch (Throwable ce) {
@@ -272,17 +286,6 @@ public class FlexEventSpy extends AbstractEventSpy {
String nonProxyHost = settingsProxy.getNonProxyHosts();
final String username = settingsProxy.getUsername();
final String password = settingsProxy.getPassword();
-
- if (!StringUtils.isEmpty(username) && !StringUtils.isEmpty(password)) {
- Authenticator authenticator = new Authenticator() {
- @Override
- protected PasswordAuthentication getPasswordAuthentication() {
- return new PasswordAuthentication(username, password.toCharArray());
- }
- };
- Authenticator.setDefault(authenticator);
- }
-
return new ProxySettings(protocol, host, port, nonProxyHost, username, password);
}
return null;
http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/c69b8a60/flex-maven-tools/flex-sdk-converter/pom.xml
----------------------------------------------------------------------
diff --git a/flex-maven-tools/flex-sdk-converter/pom.xml b/flex-maven-tools/flex-sdk-converter/pom.xml
index e5317f6..81109d9 100644
--- a/flex-maven-tools/flex-sdk-converter/pom.xml
+++ b/flex-maven-tools/flex-sdk-converter/pom.xml
@@ -57,6 +57,7 @@
</scm>
<modules>
+ <module>api</module>
<module>retrievers</module>
<module>converters</module>
<module>deployers</module>
http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/c69b8a60/flex-maven-tools/flex-sdk-converter/retrievers/base/pom.xml
----------------------------------------------------------------------
diff --git a/flex-maven-tools/flex-sdk-converter/retrievers/base/pom.xml b/flex-maven-tools/flex-sdk-converter/retrievers/base/pom.xml
index ace86c6..53db71c 100644
--- a/flex-maven-tools/flex-sdk-converter/retrievers/base/pom.xml
+++ b/flex-maven-tools/flex-sdk-converter/retrievers/base/pom.xml
@@ -37,6 +37,12 @@
<dependencies>
<dependency>
+ <groupId>org.apache.flex.utilities.converter</groupId>
+ <artifactId>api</artifactId>
+ <version>1.0.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.4</version>
http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/c69b8a60/flex-maven-tools/flex-sdk-converter/retrievers/base/src/main/java/org/apache/flex/utilities/converter/retrievers/Retriever.java
----------------------------------------------------------------------
diff --git a/flex-maven-tools/flex-sdk-converter/retrievers/base/src/main/java/org/apache/flex/utilities/converter/retrievers/Retriever.java b/flex-maven-tools/flex-sdk-converter/retrievers/base/src/main/java/org/apache/flex/utilities/converter/retrievers/Retriever.java
index c020378..ee863e3 100644
--- a/flex-maven-tools/flex-sdk-converter/retrievers/base/src/main/java/org/apache/flex/utilities/converter/retrievers/Retriever.java
+++ b/flex-maven-tools/flex-sdk-converter/retrievers/base/src/main/java/org/apache/flex/utilities/converter/retrievers/Retriever.java
@@ -18,7 +18,6 @@ package org.apache.flex.utilities.converter.retrievers;
import org.apache.flex.utilities.converter.retrievers.exceptions.RetrieverException;
import org.apache.flex.utilities.converter.retrievers.types.PlatformType;
-import org.apache.flex.utilities.converter.retrievers.model.ProxySettings;
import org.apache.flex.utilities.converter.retrievers.types.SdkType;
import java.io.File;
@@ -30,7 +29,4 @@ public interface Retriever {
File retrieve(SdkType sdkType, String version, PlatformType platformType) throws RetrieverException;
- File retrieve(SdkType sdkType, String version, PlatformType platformType, ProxySettings proxySettings)
- throws RetrieverException;
-
}
http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/c69b8a60/flex-maven-tools/flex-sdk-converter/retrievers/base/src/main/java/org/apache/flex/utilities/converter/retrievers/model/ProxySettings.java
----------------------------------------------------------------------
diff --git a/flex-maven-tools/flex-sdk-converter/retrievers/base/src/main/java/org/apache/flex/utilities/converter/retrievers/model/ProxySettings.java b/flex-maven-tools/flex-sdk-converter/retrievers/base/src/main/java/org/apache/flex/utilities/converter/retrievers/model/ProxySettings.java
deleted file mode 100644
index 22661a4..0000000
--- a/flex-maven-tools/flex-sdk-converter/retrievers/base/src/main/java/org/apache/flex/utilities/converter/retrievers/model/ProxySettings.java
+++ /dev/null
@@ -1,48 +0,0 @@
-package org.apache.flex.utilities.converter.retrievers.model;
-
-/**
- * Created by christoferdutz on 01.07.15.
- */
-public class ProxySettings {
-
- private String protocol;
- private String host;
- private int port;
- private String nonProxyHost;
- private String username;
- private String password;
-
- public ProxySettings(String protocol, String host, int port, String nonProxyHost, String username, String password) {
- this.protocol = protocol;
- this.host = host;
- this.port = port;
- this.nonProxyHost = nonProxyHost;
- this.username = username;
- this.password = password;
- }
-
- public String getProtocol() {
- return protocol;
- }
-
- public String getHost() {
- return host;
- }
-
- public int getPort() {
- return port;
- }
-
- public String getNonProxyHost() {
- return nonProxyHost;
- }
-
- public String getUsername() {
- return username;
- }
-
- public String getPassword() {
- return password;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/c69b8a60/flex-maven-tools/flex-sdk-converter/retrievers/download/src/main/java/org/apache/flex/utilities/converter/retrievers/download/DownloadRetriever.java
----------------------------------------------------------------------
diff --git a/flex-maven-tools/flex-sdk-converter/retrievers/download/src/main/java/org/apache/flex/utilities/converter/retrievers/download/DownloadRetriever.java b/flex-maven-tools/flex-sdk-converter/retrievers/download/src/main/java/org/apache/flex/utilities/converter/retrievers/download/DownloadRetriever.java
index 4b686d2..45682cb 100644
--- a/flex-maven-tools/flex-sdk-converter/retrievers/download/src/main/java/org/apache/flex/utilities/converter/retrievers/download/DownloadRetriever.java
+++ b/flex-maven-tools/flex-sdk-converter/retrievers/download/src/main/java/org/apache/flex/utilities/converter/retrievers/download/DownloadRetriever.java
@@ -18,9 +18,9 @@ package org.apache.flex.utilities.converter.retrievers.download;
import org.apache.commons.io.FileUtils;
import org.apache.commons.io.IOUtils;
+import org.apache.flex.utilities.converter.api.ProxySettings;
import org.apache.flex.utilities.converter.retrievers.BaseRetriever;
import org.apache.flex.utilities.converter.retrievers.exceptions.RetrieverException;
-import org.apache.flex.utilities.converter.retrievers.model.ProxySettings;
import org.apache.flex.utilities.converter.retrievers.types.PlatformType;
import org.apache.flex.utilities.converter.retrievers.types.SdkType;
import org.apache.flex.utilities.converter.retrievers.utils.ProgressBar;
@@ -76,11 +76,7 @@ public class DownloadRetriever extends BaseRetriever {
return retrieve(type, version, null);
}
- public File retrieve(SdkType type, String version, PlatformType platformType) throws RetrieverException {
- return retrieve(type, version, platformType, null);
- }
-
- public File retrieve(SdkType type, String version, PlatformType platformType, ProxySettings proxySettings)
+ public File retrieve(SdkType type, String version, PlatformType platformType)
throws RetrieverException {
try {
if (type.equals(SdkType.FLASH) || type.equals(SdkType.AIR) || type.equals(SdkType.FONTKIT)) {
@@ -104,27 +100,27 @@ public class DownloadRetriever extends BaseRetriever {
final URI afeUri = new URI("http://sourceforge.net/adobe/flexsdk/code/HEAD/tree/trunk/lib/afe.jar?format=raw");
final File afeFile = new File(targetDir, "afe.jar");
- performSafeDownload(afeUri, afeFile, proxySettings);
+ performSafeDownload(afeUri, afeFile);
final URI aglj40Uri = new URI("http://sourceforge.net/adobe/flexsdk/code/HEAD/tree/trunk/lib/aglj40.jar?format=raw");
final File aglj40File = new File(targetDir, "aglj40.jar");
- performSafeDownload(aglj40Uri, aglj40File, proxySettings);
+ performSafeDownload(aglj40Uri, aglj40File);
final URI rideauUri = new URI("http://sourceforge.net/adobe/flexsdk/code/HEAD/tree/trunk/lib/rideau.jar?format=raw");
final File rideauFile = new File(targetDir, "rideau.jar");
- performSafeDownload(rideauUri, rideauFile, proxySettings);
+ performSafeDownload(rideauUri, rideauFile);
final URI flexFontkitUri = new URI("http://sourceforge.net/adobe/flexsdk/code/HEAD/tree/trunk/lib/flex-fontkit.jar?format=raw");
final File flexFontkitFile = new File(targetDir, "flex-fontkit.jar");
- performSafeDownload(flexFontkitUri, flexFontkitFile, proxySettings);
+ performSafeDownload(flexFontkitUri, flexFontkitFile);
return targetRootDir;
} else {
- final URL sourceUrl = new URL(getBinaryUrl(type, version, platformType, proxySettings));
+ final URL sourceUrl = new URL(getBinaryUrl(type, version, platformType));
final File targetFile = File.createTempFile(type.toString() + "-" + version +
((platformType != null) ? "-" + platformType : "") + "-",
sourceUrl.getFile().substring(sourceUrl.getFile().lastIndexOf(".")));
- performFastDownload(sourceUrl, targetFile, proxySettings);
+ performFastDownload(sourceUrl, targetFile);
////////////////////////////////////////////////////////////////////////////////
// Do the extracting.
@@ -181,8 +177,9 @@ public class DownloadRetriever extends BaseRetriever {
}
}
- protected void performFastDownload(URL sourceUrl, File targetFile, ProxySettings proxySettings) throws IOException {
+ protected void performFastDownload(URL sourceUrl, File targetFile) throws IOException {
URLConnection connection;
+ ProxySettings proxySettings = ProxySettings.getProxySettings();
if(proxySettings != null) {
SocketAddress socketAddress = new InetSocketAddress(proxySettings.getHost(), proxySettings.getPort());
Proxy proxy = new Proxy(Proxy.Type.valueOf(proxySettings.getProtocol().toUpperCase()), socketAddress);
@@ -218,8 +215,9 @@ public class DownloadRetriever extends BaseRetriever {
System.out.println("===========================================================");
}
- protected void performSafeDownload(URI sourceUri, File targetFile, ProxySettings proxySettings) throws IOException {
+ protected void performSafeDownload(URI sourceUri, File targetFile) throws IOException {
RequestConfig config;
+ ProxySettings proxySettings = ProxySettings.getProxySettings();
if(proxySettings != null) {
HttpHost proxy = new HttpHost(proxySettings.getHost(), proxySettings.getPort());
config = RequestConfig.custom().setProxy(proxy).build();
@@ -277,14 +275,14 @@ public class DownloadRetriever extends BaseRetriever {
System.out.println("===========================================================");
}
- protected String getBinaryUrl(SdkType sdkType, String version, PlatformType platformType,
- ProxySettings proxySettings)
+ protected String getBinaryUrl(SdkType sdkType, String version, PlatformType platformType)
throws RetrieverException {
try {
final DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
final DocumentBuilder builder = factory.newDocumentBuilder();
final URL configUrl = new URL(getFlexInstallerConfigUrl());
URLConnection connection;
+ ProxySettings proxySettings = ProxySettings.getProxySettings();
if(proxySettings != null) {
SocketAddress socketAddress = new InetSocketAddress(proxySettings.getHost(), proxySettings.getPort());
Proxy proxy = new Proxy(Proxy.Type.valueOf(proxySettings.getProtocol().toUpperCase()), socketAddress);
http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/c69b8a60/flex-maven-tools/flex-sdk-converter/retrievers/download/src/test/java/org/apache/flex/utilities/converter/retrievers/download/ProxyTest.java
----------------------------------------------------------------------
diff --git a/flex-maven-tools/flex-sdk-converter/retrievers/download/src/test/java/org/apache/flex/utilities/converter/retrievers/download/ProxyTest.java b/flex-maven-tools/flex-sdk-converter/retrievers/download/src/test/java/org/apache/flex/utilities/converter/retrievers/download/ProxyTest.java
index e186e53..a5ac16f 100644
--- a/flex-maven-tools/flex-sdk-converter/retrievers/download/src/test/java/org/apache/flex/utilities/converter/retrievers/download/ProxyTest.java
+++ b/flex-maven-tools/flex-sdk-converter/retrievers/download/src/test/java/org/apache/flex/utilities/converter/retrievers/download/ProxyTest.java
@@ -16,7 +16,7 @@
*/
package org.apache.flex.utilities.converter.retrievers.download;
-import org.apache.flex.utilities.converter.retrievers.model.ProxySettings;
+import org.apache.flex.utilities.converter.api.ProxySettings;
import org.apache.flex.utilities.converter.retrievers.types.PlatformType;
import org.apache.flex.utilities.converter.retrievers.types.SdkType;
import org.mockserver.integration.ClientAndProxy;
@@ -51,8 +51,9 @@ public class ProxyTest {
@Test
public void simpleFastHttpNoAuthProxy() throws Exception {
ProxySettings proxySettings = new ProxySettings("HTTP", "localhost", 3456, null, null, null);
+ ProxySettings.setProxySettings(proxySettings);
DownloadRetriever downloadRetriever = new DownloadRetriever();
- downloadRetriever.retrieve(SdkType.FLASH, "17.0", PlatformType.WINDOWS, proxySettings);
+ downloadRetriever.retrieve(SdkType.FLASH, "17.0", PlatformType.WINDOWS);
}
/**
@@ -61,8 +62,9 @@ public class ProxyTest {
@Test
public void simpleSafeHttpNoAuthProxy() throws Exception {
ProxySettings proxySettings = new ProxySettings("HTTP", "localhost", 3456, null, null, null);
+ ProxySettings.setProxySettings(proxySettings);
DownloadRetriever downloadRetriever = new DownloadRetriever();
- downloadRetriever.retrieve(SdkType.FONTKIT, "1.0", PlatformType.WINDOWS, proxySettings);
+ downloadRetriever.retrieve(SdkType.FONTKIT, "1.0", PlatformType.WINDOWS);
}
/**
@@ -71,8 +73,9 @@ public class ProxyTest {
@Test(enabled = false)
public void simpleFastHttpWithAuthProxy() throws Exception {
ProxySettings proxySettings = new ProxySettings("HTTP", "localhost", 3456, "testuser", "testpass", null);
+ ProxySettings.setProxySettings(proxySettings);
DownloadRetriever downloadRetriever = new DownloadRetriever();
- downloadRetriever.retrieve(SdkType.FLASH, "17.0", PlatformType.WINDOWS, proxySettings);
+ downloadRetriever.retrieve(SdkType.FLASH, "17.0", PlatformType.WINDOWS);
}
/**
@@ -81,8 +84,9 @@ public class ProxyTest {
@Test(enabled = false)
public void simpleSafeHttpWithAuthProxy() throws Exception {
ProxySettings proxySettings = new ProxySettings("HTTP", "localhost", 3456, "testuser", "testpass", null);
+ ProxySettings.setProxySettings(proxySettings);
DownloadRetriever downloadRetriever = new DownloadRetriever();
- downloadRetriever.retrieve(SdkType.FONTKIT, "1.0", PlatformType.WINDOWS, proxySettings);
+ downloadRetriever.retrieve(SdkType.FONTKIT, "1.0", PlatformType.WINDOWS);
}
}