/** * Iterates through all of the entries in the JAR and determines which of them will * be included in the S-RAMP archive. Returns the collection of artifacts that should be * included. */ private DiscoveredArtifacts discoverArtifacts() { DiscoveredArtifacts artifacts = new DiscoveredArtifacts(); Collection<File> files = FileUtils.listFiles(jarWorkDir, null, true); for (File file : files) { CandidateArtifact candidate = new CandidateArtifact(file, jarWorkDir); if (this.artifactFilter.accepts(candidate)) { artifacts.add(file); } } return artifacts; }
/** * Creates an S-RAMP archive from this JAR. * @return an S-RAMP archive * @throws ZipToSrampArchiveException */ public SrampArchive createSrampArchive() throws ZipToSrampArchiveException { this.artifactFilter.setContext(this.context); this.metaDataFactory.setContext(this.context); DiscoveredArtifacts discoveredArtifacts = discoverArtifacts(); discoveredArtifacts.index(jarWorkDir); generateMetaData(discoveredArtifacts); try { SrampArchive archive = new SrampArchive(); for (DiscoveredArtifact artifact : discoveredArtifacts) { String path = artifact.getArchivePath(); archive.addEntry(path, artifact.getMetaData(), artifact.getContent()); } return archive; } catch (Exception e) { throw new ZipToSrampArchiveException(e); } }