Skip to content

Commit

Permalink
Merge pull request OpenLiberty#12 from herman-kailey/mavenRepo
Browse files Browse the repository at this point in the history
fixing improper feature pathnames
  • Loading branch information
herman-kailey authored Oct 10, 2019
2 parents 305cc63 + f41648e commit 2ac4d5a
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,6 @@ private List<File> downloadFeaturesFrom(Collection<String> resolvedFeatures, Fil
private List<File> downloadFeatureEsas(Collection<String> resolvedFeatures) throws InstallException {
map.put("download.artifact.list", resolvedFeatures);
boolean singleArtifactInstall = false;

map.put("download.inidividual.artifact", singleArtifactInstall);
List<File> result = (List<File>) map.get("download.result");
if (map.get("action.error.message") != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ public void synthesizeAndDownload(String mavenCoords, String filetype, String dL
String groupId = ArtifactDownloaderUtils.getGroupId(mavenCoords).replace(".", "/") + "/";
String artifactId = ArtifactDownloaderUtils.getartifactId(mavenCoords);
String version = ArtifactDownloaderUtils.getVersion(mavenCoords);
new File(dLocation + groupId + version + "/").mkdirs();
new File(dLocation + groupId + artifactId + "/" + version + "/").mkdirs();

String filename = ArtifactDownloaderUtils.getfilename(mavenCoords, filetype);
String urlLocation = ArtifactDownloaderUtils.getUrlLocation(repo, groupId, artifactId, version, filename);
Expand All @@ -111,18 +111,19 @@ public void synthesizeAndDownload(String mavenCoords, String filetype, String dL
if (individualDownload && ArtifactDownloaderUtils.fileIsMissing(urlLocation)) {
throw ExceptionUtils.createByKey("ERROR_FAILED_TO_DOWNLOAD_ASSETS_FROM_REPO", ArtifactDownloaderUtils.getFileNameFromURL(urlLocation), filetype + " file", repo);
} else {
download(urlLocation, dLocation, groupId, version, filename, checksumFormats);
download(urlLocation, dLocation, groupId, artifactId, version, filename, checksumFormats);
}
} catch (IOException e) {
throw ExceptionUtils.createByKey(e, "ERROR_INVALID_ESA", filename);
}

}

private void download(String urlLocation, String dLocation, String groupId, String version, String filename, String[] checksumFormats) throws IOException, InstallException {
private void download(String urlLocation, String dLocation, String groupId, String artifactId, String version, String filename,
String[] checksumFormats) throws IOException, InstallException {
try {
URI uriLoc = new URI(urlLocation);
File fileLoc = new File(ArtifactDownloaderUtils.getFileLocation(dLocation, groupId, version, filename));
File fileLoc = new File(ArtifactDownloaderUtils.getFileLocation(dLocation, groupId, artifactId, version, filename));

downloadInternal(uriLoc, fileLoc);
downloadedFiles.add(fileLoc);
Expand All @@ -131,7 +132,7 @@ private void download(String urlLocation, String dLocation, String groupId, Stri
String checksumLocal = ArtifactDownloaderUtils.getChecksum(fileLoc.getAbsolutePath(), checksumFormat);
String checksumOrigin = ArtifactDownloaderUtils.getMasterChecksum(urlLocation, checksumFormat);
if (!checksumLocal.equals(checksumOrigin)) {
ArtifactDownloaderUtils.deleteFiles(downloadedFiles, dLocation, groupId, version, filename);
ArtifactDownloaderUtils.deleteFiles(downloadedFiles, dLocation, groupId, artifactId, version, filename);
downloadedFiles.clear();
throw ExceptionUtils.createByKey("ERROR_DOWNLOADED_ASSET_INVALID_CHECKSUM", filename, Messages.INSTALL_KERNEL_MESSAGES.getMessage("FEATURE_ASSET"));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,11 +124,11 @@ public static String getMasterChecksum(String url, String format) throws IOExcep
return getChecksumFromURL(urlLocation);
}

public static void deleteFiles(List<File> fileList, String dLocation, String groupId, String version, String filename) {
public static void deleteFiles(List<File> fileList, String dLocation, String groupId, String artifactId, String version, String filename) {
for (File f : fileList) {
f.delete();
}
File file = (new File(getFileLocation(dLocation, groupId, version, filename))).getParentFile();
File file = (new File(getFileLocation(dLocation, groupId, artifactId, version, filename))).getParentFile();
while (!(file.toString() + "/").equals(dLocation)) {
File[] files = file.listFiles(new FilenameFilter() {
@Override
Expand Down Expand Up @@ -164,8 +164,8 @@ public static String getUrlLocation(String repo, String groupId, String artifact
return repo + groupId + artifactId + "/" + version + "/" + filename;
}

public static String getFileLocation(String dLocation, String groupId, String version, String filename) {
return dLocation + groupId + version + "/" + filename;
public static String getFileLocation(String dLocation, String groupId, String artifactId, String version, String filename) {
return dLocation + groupId + artifactId + "/" + version + "/" + filename;
}

public static String getFileNameFromURL(String str) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -844,7 +844,7 @@ private String getDownloadDir(String fromDir) {
return result;
}

private String getM2Cache() {
private String getM2Cache() { //check for maven_home specified mirror stuff
File m2Folder = getM2Path().toFile();

if (m2Folder.exists() && m2Folder.isDirectory()) {
Expand Down Expand Up @@ -1048,36 +1048,35 @@ private File generateJsonFromIndividualESAs(Path jsonDirectory, Map<String, Stri
private Collection<File> DownloadEsas() {
File rootDir = (File) data.get(ROOT_DIR);
Collection<String> resolvedFeatures = (List<String>) data.get(DOWNLOAD_ARTIFACT_LIST);
String openLibertyVersion = null;
try {
openLibertyVersion = getLibertyVersion();
} catch (IOException e) {
data.put(ACTION_RESULT, ERROR);
data.put(ACTION_ERROR_MESSAGE, e.getMessage());
data.put(ACTION_EXCEPTION_STACKTRACE, ExceptionUtils.stacktraceToString(e));
} catch (InstallException e) {
data.put(ACTION_RESULT, ERROR);
data.put(ACTION_ERROR_MESSAGE, e.getMessage());
data.put(ACTION_EXCEPTION_STACKTRACE, ExceptionUtils.stacktraceToString(e));
}
List<File> foundEsas = new ArrayList<>();
List<String> featuresClone = new ArrayList<>(resolvedFeatures);
List<Integer> missingFeatureIndexes = new ArrayList<>();

int index = 0;
for (String feature : resolvedFeatures) {
//logger.log(Level.FINE, "Processing feature: " + feature);

String groupId = feature.split(":")[0];
String featureName = feature.split(":")[1];

File groupDir = new File(rootDir, groupId.replace(".", "/"));
if (!groupDir.exists()) {
missingFeatureIndexes.add(index);
continue;
}
String featureEsa = null;
Path featurePath = null;
try {
featureEsa = featureName + "-" + getLibertyVersion() + ".esa";
featurePath = Paths.get(groupDir.getAbsolutePath().toString(), featureName, getLibertyVersion(), featureEsa);

} catch (IOException e) {
data.put(ACTION_RESULT, ERROR);
data.put(ACTION_ERROR_MESSAGE, e.getMessage());
data.put(ACTION_EXCEPTION_STACKTRACE, ExceptionUtils.stacktraceToString(e));
} catch (InstallException e) {
data.put(ACTION_RESULT, ERROR);
data.put(ACTION_ERROR_MESSAGE, e.getMessage());
data.put(ACTION_EXCEPTION_STACKTRACE, ExceptionUtils.stacktraceToString(e));
}
String featureEsa = featureName + "-" + openLibertyVersion + ".esa";
Path featurePath = Paths.get(groupDir.getAbsolutePath().toString(), featureName, openLibertyVersion, featureEsa);

//logger.log(Level.FINE, "Found feature at path: " + featurePath.toString());
if (Files.isRegularFile(featurePath)) {
Expand Down

0 comments on commit 2ac4d5a

Please sign in to comment.