Skip to content

Commit

Permalink
Merge pull request OpenLiberty#4 from herman-kailey/mavenRepo
Browse files Browse the repository at this point in the history
removing lambda in ArtifactDownloaderUtils
  • Loading branch information
TayyabDev authored Sep 25, 2019
2 parents f49fec8 + 200d2da commit 8df82c7
Showing 1 changed file with 18 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.FilenameFilter;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
Expand All @@ -24,15 +25,15 @@ public class ArtifactDownloaderUtils {

public static List<String> getMissingFiles(List<String> featureURLs) {
List<String> result = new ArrayList<String>();
for (String url: featureURLs) {
for (String url : featureURLs) {
if (!(exists(url) == HttpURLConnection.HTTP_OK)) {
result.add(url);
}
}
return result;
}

public static int exists(String URLName){
public static int exists(String URLName) {

try {
HttpURLConnection.setFollowRedirects(false);
Expand All @@ -59,8 +60,7 @@ public static int exists(String URLName){
return 0;
}


public static List<String> acquireFeatureURLs(List<String> mavenCoords, String repo){
public static List<String> acquireFeatureURLs(List<String> mavenCoords, String repo) {
List<String> result = new ArrayList<String>();
for (String coord : mavenCoords) {
String groupId = getGroupId(coord).replace(".", "/") + "/";
Expand All @@ -78,14 +78,14 @@ public static String getChecksum(String filename, String format) throws NoSuchAl
byte[] b = createChecksum(filename, format);
String result = "";

for (int i=0; i < b.length; i++) {
result += Integer.toString( ( b[i] & 0xff ) + 0x100, 16).substring( 1 );
for (int i = 0; i < b.length; i++) {
result += Integer.toString((b[i] & 0xff) + 0x100, 16).substring(1);
}
return result;
}

public static byte[] createChecksum(String filename, String format) throws IOException, NoSuchAlgorithmException {
InputStream fis = new FileInputStream(filename);
InputStream fis = new FileInputStream(filename);

byte[] buffer = new byte[1024];
MessageDigest complete = MessageDigest.getInstance(format);
Expand All @@ -112,7 +112,7 @@ public static String getChecksumFromURL(URL url) {
result += inputLine;
in.close();
} catch (IOException e) {
System.out.println("failed to download checksum file at " + url.toString() ); //TODO proper error message
System.out.println("failed to download checksum file at " + url.toString()); //TODO proper error message
e.printStackTrace();
return null;
}
Expand All @@ -125,16 +125,21 @@ public static String getMasterChecksum(String url, String format) throws Malform
}

public static void deleteFiles(List<File> fileList, String dLocation, String groupId, String version, String filename) {
for (File f: fileList) {
if(!f.delete()) {
for (File f : fileList) {
if (!f.delete()) {
System.out.println("failed to delete file");
}
}
File file = (new File (getFileLocation(dLocation, groupId, version, filename))).getParentFile();
File file = (new File(getFileLocation(dLocation, groupId, version, filename))).getParentFile();
while (!(file.toString() + "/").equals(dLocation)) {
File[] files = file.listFiles((dir, name) -> !name.equals(".DS_Store"));
File[] files = file.listFiles(new FilenameFilter() {
@Override
public boolean accept(File dir, String name) {
return !name.equals(".DS_Store");
}
});
File newFile = file.getParentFile();
if (files.length == 0 ) {
if (files.length == 0) {
file.delete();
}
file = newFile;
Expand Down

0 comments on commit 8df82c7

Please sign in to comment.