URI uri;
try {
uri = new URI(uriString);
} catch (URISyntaxException e2) {
throw new ArchiveFetchException("Invalid module URI : [" + uriString + "]", e2);
}
File localModuleFileCopy;
try {
localModuleFileCopy = File.createTempFile("tmp", "module");
} catch (IOException e1) {
logger.error(
"Cannot deploy app [{}] because a local copy of the module file could not be initialized due to [{}]",
appName, e1.getClass().getName() + "->" + e1.getMessage());
throw new ArchiveFetchException("Cannot deploy application [" + appName + "]", e1);
}
localModuleFileCopy.deleteOnExit();
try {
if (ByteStreams.copy(fetcher.fetch(uri), Files.newOutputStreamSupplier(localModuleFileCopy)) == 0) {
throw new ArchiveFetchException("Cannot copy archive from [" + uri.toString() + "] to ["
+ localModuleFileCopy.getAbsolutePath() + "] (nothing was copied)");
}
} catch (Exception e) {
throw new ArchiveFetchException("Cannot deploy application [" + appName + "] from URI [" + uri.toString()
+ "] ", e);
}
return localModuleFileCopy;
}