in flex-maven-tools/flex-sdk-converter/retrievers/download/src/main/java/org/apache/flex/utilities/converter/retrievers/download/DownloadRetriever.java [83:186]
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)) {
confirmLicenseAcceptance(type);
}
if (type.equals(SdkType.FONTKIT)) {
File tmpTargetFile = File.createTempFile(UUID.randomUUID().toString(), "");
String tempSuffix = tmpTargetFile.getName().substring(tmpTargetFile.getName().lastIndexOf("-"));
if (!(tmpTargetFile.delete())) {
throw new IOException("Could not delete temp file: " + tmpTargetFile.getAbsolutePath());
}
File targetRootDir = new File(tmpTargetFile.getParentFile(), type.toString() + tempSuffix);
File targetDir = new File(targetRootDir, "/lib/external/optional");
if (!(targetDir.mkdirs())) {
throw new IOException("Could not create temp directory: " + targetDir.getAbsolutePath());
}
final URI afeUri = new URI("https://sourceforge.net/adobe/flexsdk/code/HEAD/tree/trunk/lib/afe.jar?format=raw");
final File afeFile = new File(targetDir, "afe.jar");
performSafeDownload(afeUri, afeFile);
final URI aglj40Uri = new URI("https://sourceforge.net/adobe/flexsdk/code/HEAD/tree/trunk/lib/aglj40.jar?format=raw");
final File aglj40File = new File(targetDir, "aglj40.jar");
performSafeDownload(aglj40Uri, aglj40File);
final URI rideauUri = new URI("https://sourceforge.net/adobe/flexsdk/code/HEAD/tree/trunk/lib/rideau.jar?format=raw");
final File rideauFile = new File(targetDir, "rideau.jar");
performSafeDownload(rideauUri, rideauFile);
final URI flexFontkitUri = new URI("https://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);
return targetRootDir;
} else {
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(".")));
performSafeDownload(new URI(getBinaryUrl(type, version, platformType)), targetFile);
////////////////////////////////////////////////////////////////////////////////
// Do the extracting.
////////////////////////////////////////////////////////////////////////////////
if (type.equals(SdkType.FLASH)) {
final File targetDirectory = new File(targetFile.getParent(),
targetFile.getName().substring(0, targetFile.getName().lastIndexOf(".") - 1));
final File libDestFile = new File(targetDirectory, "frameworks/libs/player/" + version +
"/playerglobal.swc");
if (!libDestFile.getParentFile().exists()) {
if (!libDestFile.getParentFile().mkdirs()) {
throw new RetrieverException("Error creating directory " + libDestFile.getParent());
}
}
FileUtils.moveFile(targetFile, libDestFile);
return targetDirectory;
} else {
LOG.info("Extracting archive to temp directory.");
File targetDirectory = new File(targetFile.getParent(),
targetFile.getName().substring(0, targetFile.getName().lastIndexOf(".") - 1));
if (type.equals(SdkType.SWFOBJECT)) {
unpack(targetFile, new File(targetDirectory, "templates"));
} else {
unpack(targetFile, targetDirectory);
}
LOG.info("");
LOG.info("Finished extracting.");
LOG.info("===========================================================");
// In case of the swfobject, delete some stuff we don't want in there.
if (type.equals(SdkType.SWFOBJECT)) {
File delFile = new File(targetDirectory, "templates/swfobject/index_dynamic.html");
FileUtils.deleteQuietly(delFile);
delFile = new File(targetDirectory, "templates/swfobject/index.html");
FileUtils.deleteQuietly(delFile);
delFile = new File(targetDirectory, "templates/swfobject/test.swf");
FileUtils.deleteQuietly(delFile);
delFile = new File(targetDirectory, "templates/swfobject/src");
FileUtils.deleteDirectory(delFile);
}
return targetDirectory;
}
}
} catch (MalformedURLException e) {
throw new RetrieverException("Error downloading archive.", e);
} catch (FileNotFoundException e) {
throw new RetrieverException("Error downloading archive.", e);
} catch (SSLHandshakeException e) {
throw new RetrieverException("Error downloading archive. There were problems in the SSL handshake. " +
"In case of Sourceforge this is probably related to Sourceforge using strong encryption for " +
"SSL and the default Oracle JDK not supporting this. If you are able to do so please install " +
"the Java Cryptography Extension (JCE) Unlimited Strength Jurisdiction Policy Files 8 available " +
"from http://www.oracle.com/technetwork/java/javase/downloads/jce8-download-2133166.html", e);
} catch (IOException e) {
throw new RetrieverException("Error downloading archive.", e);
} catch (URISyntaxException e) {
throw new RetrieverException("Error downloading archive.", e);
}
}