ArtificerArchive implements Serializable { public void addEntry(String path, BaseArtifactType metaData, InputStream content) throws ArtificerArchiveException { if (path == null) throw new ArtificerArchiveException(Messages.i18n.format("INVALID_ENTRY_PATH")); if (metaData == null) throw new ArtificerArchiveException(Messages.i18n.format("MISSING_META_DATA")); File metaDataFile = new File(this.workDir, path + ".atom"); File contentFile = new File(this.workDir, path); if (metaDataFile.exists()) throw new ArtificerArchiveException(Messages.i18n.format("ARCHIVE_ALREADY_EXISTS")); metaDataFile.getParentFile().mkdirs(); if (content != null) writeContent(contentFile, content); try { ArtificerArchiveJaxbUtils.writeMetaData(metaDataFile, metaData); } catch (JAXBException e) { throw new ArtificerArchiveException(e); } } ArtificerArchive();  ArtificerArchive(File file);  ArtificerArchive(InputStream input); void close(); static void closeQuietly(ArtificerArchive archive); Collection<ArtificerArchiveEntry> getEntries(); InputStream getInputStream(ArtificerArchiveEntry entry); void addEntry(String path, BaseArtifactType metaData, InputStream content); void updateEntry(ArtificerArchiveEntry entry, InputStream content); File pack(); ArtificerArchiveEntry getEntry(String archivePath); boolean containsEntry(String archivePath); boolean removeEntry(String archivePath);  }
@Test public void testAddEntry() throws Exception { InputStream artifactContentStream = ArtificerArchiveTest.class.getResourceAsStream("sample.xsd"); XsdDocument artifactMetaData = new XsdDocument(); setMetaData(artifactMetaData, "sample.xsd", "1.0.3", "Just a sample XML Schema."); ArtificerArchive archive = null; try { archive = new ArtificerArchive(); archive.addEntry("sample.xsd", artifactMetaData, artifactContentStream); File workDir = AtomTestUtils.getArchiveWorkDir(archive); Assert.assertNotNull(workDir); Assert.assertTrue(workDir.isDirectory()); Collection<File> files = FileUtils.listFiles(workDir, new String[] {"xsd", "atom"}, true); Assert.assertEquals(2, files.size()); Set<String> fnames = new HashSet<String>(); for (File f : files) { fnames.add(f.getName()); } Assert.assertTrue(fnames.contains("sample.xsd")); Assert.assertTrue(fnames.contains("sample.xsd.atom")); } finally { ArtificerArchive.closeQuietly(archive); } }