@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; }
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()); log.debug("Attempting download of " + dFile.getRelativeFilename() + " from contentSourceId " + contentSourceId); String remoteFetchLoc = distSource.getDistFileRemoteLocation(repo.getName(), dist.getLabel(), dFile.getRelativeFilename()); InputStream bitsStream = pc.getAdapterManager().loadDistributionFileBits(contentSourceId, remoteFetchLoc);
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); } }