log.info("TODO: create index.html listing all the distribution labels for this repo: " + repo.getName());
renderDistributionLabels(request, response, repo);
return;
}
// Get Distribution
Distribution dist = distroMgr.getDistributionByLabel(distLabel);
if (dist == null) {
log.info("Unable to find Distribution by label '" + distLabel + "'");
renderErrorPage(request, response);
return;
}
String fileRequest = getDistFilePath(request.getRequestURI());
if (StringUtils.isEmpty(fileRequest)) {
log.info("no distribution file was found in request, so render list of all distribution files");
renderDistributionFileList(request, response, dist);
return;
}
log.debug("Parsed DistributionFile request is for: " + fileRequest);
// Looks like a request for a distribution file
List<DistributionFile> distFiles = distroMgr.getDistributionFilesByDistId(dist.getId());
if (distFiles.isEmpty()) {
log.info("Unable to find any distribution files for dist: " + dist.getLabel());
renderErrorPage(request, response);
return;
}
for (DistributionFile dFile : distFiles) {
//log.info("Compare: " + dFile.getRelativeFilename() + " to " + fileRequest);
if (StringUtils.equalsIgnoreCase(dFile.getRelativeFilename(), fileRequest)) {
log.info("Sending back package bytes for: " + dFile.getRelativeFilename());
writeDistributionFileBits(request, response, dFile);
return;
}
}
// This isn't a DistributionFile
// This could be a request for a package. Package requests will come in as:
// ..../distributions/{Server,Cluster,Packages,etc}/a2ps-XXXXX.rpm
String possiblePkgName = getLastPiece(request.getRequestURI());
log.debug("Looking up : " + possiblePkgName + ", it might be a package request");
PackageVersion pv = getPackageVersionFromFileName(repo, possiblePkgName);
if (pv != null) {
log.info(possiblePkgName + " resolved to a package, will send package bytes back as response");
//response.setContentType("application/octet-stream");
writePackageVersionBits(request, response, pv);
return;
}
log.info("Searched through DistributionFiles and Packages, unable to find: " + fileRequest
+ ", in Distribution: " + dist.getLabel());
renderErrorPage(request, response);
}