@Override public boolean equals(Object o) { if (this == o) { return true; } if (o == null) { return false; } if (!(o instanceof Distribution)) { return false; } Distribution kstree = (Distribution) o; if ((getLabel() != null) ? (!getLabel().equals(kstree.getLabel())) : (kstree.getLabel() != null)) { return false; } return true; }
/** * validates a given kickstart tree object and throws a KickstartTreeException * @param kstree kickstart tree object * @throws DistributionException */ public void validateDistTree(Distribution kstree) throws DistributionException { if (kstree.getLabel() == null || kstree.getLabel().trim().equals("")) { throw new DistributionException("A valid Distribution tree is required"); } Distribution kstreeobj = getDistributionByLabel(kstree.getLabel()); if (kstreeobj != null) { throw new DistributionException("There is already a kstree with the name of [" + kstree.getLabel() + "]"); } }
@TransactionAttribute(TransactionAttributeType.REQUIRES_NEW) @TransactionTimeout(45 * 60) public long outputDistributionFileBits(DistributionFile distFile, OutputStream outputStream) { long numBytes = 0L; InputStream bitStream = null; try { Distribution dist = distFile.getDistribution(); log.info("Distribution has a basePath of " + dist.getBasePath()); String distFilePath = dist.getBasePath() + "/" + distFile.getRelativeFilename(); File f = getDistributionFileBitsLocalFilesystemFile(dist.getLabel(), distFilePath); log.info("Fetching: " + distFilePath + " on local file store from: " + f.getAbsolutePath()); bitStream = new FileInputStream(f); numBytes = StreamUtil.copy(bitStream, outputStream); } catch (Exception e) { log.info(e); } finally { // close our stream but leave the output stream open try { bitStream.close(); } catch (Exception closeError) { log.warn("Failed to close the bits stream", closeError); } } log.debug("Retrieved and sent [" + numBytes + "] bytes for [" + distFile.getRelativeFilename() + "]"); return numBytes; }
for (DistributionFile dFile : distFiles) { String relPath = dist.getBasePath() + "/" + dFile.getRelativeFilename(); File outputFile = getDistLocalFileAndCreateParentDir(dist.getLabel(), relPath); log.debug("Checking if file exists at: " + outputFile.getAbsolutePath()); if (outputFile.exists()) { String remoteFetchLoc = distSource.getDistFileRemoteLocation(repo.getName(), dist.getLabel(), dFile.getRelativeFilename()); InputStream bitsStream = pc.getAdapterManager().loadDistributionFileBits(contentSourceId,
private void translateDomainToDto(List<Distribution> dists, List<DistributionDetails> distDetails) { DistributionManagerLocal distManager = LookupUtil.getDistributionManagerLocal(); for (Distribution d : dists) { DistributionDetails detail = new DistributionDetails(d.getLabel(), d.getDistributionType().getName()); detail.setLabel(d.getLabel()); detail.setDistributionPath(d.getBasePath()); detail.setDescription(d.getDistributionType().getDescription()); List<DistributionFile> files = distManager.getDistributionFilesByDistId(d.getId()); for (DistributionFile f : files) { DistributionFileDetails dfd = new DistributionFileDetails(f.getRelativeFilename(), f.getLastModified(), f.getMd5sum()); detail.addFile(dfd); } distDetails.add(detail); } }