@Override public int hashCode() { int result = 1; result = (31 * result) + ((repo == null) ? 0 : repo.hashCode()); result = (31 * result) + ((dist == null) ? 0 : dist.hashCode()); return result; }
public Distribution(String label, String basepathIn, DistributionType distributionType) { setLabel(label); setBasePath(basepathIn); setDistributionType(distributionType); }
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); } }
List<DistributionFile> distFiles = distManager.getDistributionFilesByDistId(dist.getId()); log.debug("Found " + distFiles.size() + " DistributionFiles"); 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,
@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; }
return false; } else if (!dist.equals(other.dist)) { return false;
@TransactionAttribute(TransactionAttributeType.REQUIRES_NEW) public RepoSyncResults _mergeDistributionSyncReportREMOVE(ContentSource contentSource, DistributionSyncReport report, RepoSyncResults syncResults, StringBuilder progress) { progress.append(new Date()).append(": ").append("Removing"); syncResults.setResults(progress.toString()); syncResults = repoManager.mergeRepoSyncResults(syncResults); DistributionManagerLocal distManager = LookupUtil.getDistributionManagerLocal(); Subject overlord = LookupUtil.getSubjectManager().getOverlord(); // remove all distributions that are no longer available on the remote repository for (DistributionDetails doomedDetails : report.getDeletedDistributions()) { Distribution doomedDist = distManager.getDistributionByLabel(doomedDetails.getLabel()); distManager.deleteDistributionByDistId(overlord, doomedDist.getId()); distManager.deleteDistributionFilesByDistId(overlord, doomedDist.getId()); progress.append("Removed distribution & distribution files for: " + doomedDetails.getLabel()); syncResults.setResults(progress.toString()); syncResults = repoManager.mergeRepoSyncResults(syncResults); } progress.append("Finished Distribution removal...").append('\n'); syncResults.setResults(progress.toString()); syncResults = repoManager.mergeRepoSyncResults(syncResults); return syncResults; }
@RequiredPermission(Permission.MANAGE_INVENTORY) public Distribution createDistribution(Subject user, String kslabel, String basepath, DistributionType disttype) throws DistributionException { DistributionType loaded = distributionManager.getDistributionTypeByName(disttype.getName()); if (loaded != null) { disttype = loaded; } Distribution kstree = new Distribution(kslabel, basepath, disttype); validateDistTree(kstree); entityManager.persist(kstree); return kstree; }
return false; } else if (!dist.equals(other.dist)) { return false;
RepoDistribution repoDist = new RepoDistribution(repo, newDist); log.debug("Created new mapping of RepoDistribution repoId = " + repo.getId() + ", distId = " + newDist.getId()); entityManager.persist(repoDist); List<DistributionFileDetails> files = detail.getFiles();
@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; }
@Override public int hashCode() { int result = 1; result = (31 * result) + ((repo == null) ? 0 : repo.hashCode()); result = (31 * result) + ((dist == null) ? 0 : dist.hashCode()); return result; }
@Override public boolean equals(Object obj) { if ((obj == null) || (!(obj instanceof DistributionFile))) { return false; } DistributionFile other = (DistributionFile) obj; if (getDistribution() == null) { if (other.getDistribution() != null) { return false; } } else if (!getDistribution().equals(other.getDistribution())) { 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() + "]"); } }
@Override public int hashCode() { int result = 1; result = (31 * result) + ((getDistribution() == null) ? 0 : getDistribution().hashCode()); return result; }
@Override public boolean equals(Object obj) { if (this == obj) { return true; } if ((obj == null) || (!(obj instanceof DistributionFilePK))) { return false; } final DistributionFilePK other = (DistributionFilePK) obj; if (getDistribution() == null) { if (other.getDistribution() != null) { return false; } } else if (!getDistribution().equals(other.getDistribution())) { return false; } return true; } }
@Override public int hashCode() { int result = 1; result = (31 * result) + ((getDistribution() == null) ? 0 : getDistribution().hashCode()); return result; }