/** * Add an "empty" entry in the deployment. * <p/> * Equivalent to adding an empty folder. * * @param path The target path of the entry when added to the archive. * @return This archive instance. */ public Archive addEntry(String path) { AssertArgument.isNotNullAndNotEmpty(path, "path"); path = path.trim(); if(path.endsWith("/")) { entries.put(trimLeadingSlash(path), null); } else { entries.put(trimLeadingSlash(path) + "/", null); } return this; }
/** * Add an "empty" entry in the deployment. * <p/> * Equivalent to adding an empty folder. * * @param path The target path of the entry when added to the archive. * @return This archive instance. */ public Archive addEntry(String path) { AssertArgument.isNotNullAndNotEmpty(path, "path"); path = path.trim(); if(path.endsWith("/")) { entries.put(trimLeadingSlash(path), null); } else { entries.put(trimLeadingSlash(path) + "/", null); } return this; }
/** * Add an "empty" entry in the deployment. * <p/> * Equivalent to adding an empty folder. * * @param path The target path of the entry when added to the archive. * @return This archive instance. */ public Archive addEntry(String path) { AssertArgument.isNotNullAndNotEmpty(path, "path"); path = path.trim(); if(path.endsWith("/")) { entries.put(trimLeadingSlash(path), null); } else { entries.put(trimLeadingSlash(path) + "/", null); } return this; }
/** * Add the supplied data as an entry in the deployment. * * @param path The target path of the entry when added to the archive. * @param data The data. Pass null to create a directory. * @return This archive instance. */ public Archive addEntry(String path, byte[] data) { AssertArgument.isNotNullAndNotEmpty(path, "path"); File entryFile = new File(tmpDir, path); if (entryFile.exists()) { entryFile.delete(); } entryFile.getParentFile().mkdirs(); if (data == null) { entryFile.mkdir(); } else { try { FileUtils.writeFile(data, entryFile); } catch (IOException e) { throw new IllegalStateException("Unexpected error writing Archive file '" + entryFile.getAbsolutePath() + "'.", e); } } entries.put(trimLeadingSlash(path.trim()), entryFile); return this; }
/** * Add the supplied data as an entry in the deployment. * * @param path The target path of the entry when added to the archive. * @param data The data. Pass null to create a directory. * @return This archive instance. */ public Archive addEntry(String path, byte[] data) { AssertArgument.isNotNullAndNotEmpty(path, "path"); File entryFile = new File(tmpDir, path); if (entryFile.exists()) { entryFile.delete(); } entryFile.getParentFile().mkdirs(); if (data == null) { entryFile.mkdir(); } else { try { FileUtils.writeFile(data, entryFile); } catch (IOException e) { throw new IllegalStateException("Unexpected error writing Archive file '" + entryFile.getAbsolutePath() + "'.", e); } } entries.put(trimLeadingSlash(path.trim()), entryFile); return this; }
/** * Add the supplied data as an entry in the deployment. * * @param path The target path of the entry when added to the archive. * @param data The data. Pass null to create a directory. * @return This archive instance. */ public Archive addEntry(String path, byte[] data) { AssertArgument.isNotNullAndNotEmpty(path, "path"); File entryFile = new File(tmpDir, path); if (entryFile.exists()) { entryFile.delete(); } entryFile.getParentFile().mkdirs(); if (data == null) { entryFile.mkdir(); } else { try { FileUtils.writeFile(data, entryFile); } catch (IOException e) { throw new IllegalStateException("Unexpected error writing Archive file '" + entryFile.getAbsolutePath() + "'.", e); } } entries.put(trimLeadingSlash(path.trim()), entryFile); return this; }
/** * Add the supplied character data as an entry in the deployment. * * @param path The target path of the entry when added to the archive. * @param data The data. * @return This archive instance. */ public Archive addEntry(String path, String data) { AssertArgument.isNotNullAndNotEmpty(path, "path"); AssertArgument.isNotNull(data, "data"); try { addEntry(trimLeadingSlash(path.trim()), data.getBytes("UTF-8")); } catch (UnsupportedEncodingException e) { throw new RuntimeException("Unexpected UnsupportedEncodingException exception for encoding 'UTF-8' when writing Archive entry from a StringBuilder instance.", e); } return this; }
/** * Add the supplied character data as an entry in the deployment. * * @param path The target path of the entry when added to the archive. * @param data The data. * @return This archive instance. */ public Archive addEntry(String path, String data) { AssertArgument.isNotNullAndNotEmpty(path, "path"); AssertArgument.isNotNull(data, "data"); try { addEntry(trimLeadingSlash(path.trim()), data.getBytes("UTF-8")); } catch (UnsupportedEncodingException e) { throw new RuntimeException("Unexpected UnsupportedEncodingException exception for encoding 'UTF-8' when writing Archive entry from a StringBuilder instance.", e); } return this; }
/** * Add the supplied character data as an entry in the deployment. * * @param path The target path of the entry when added to the archive. * @param data The data. * @return This archive instance. */ public Archive addEntry(String path, String data) { AssertArgument.isNotNullAndNotEmpty(path, "path"); AssertArgument.isNotNull(data, "data"); try { addEntry(trimLeadingSlash(path.trim()), data.getBytes("UTF-8")); } catch (UnsupportedEncodingException e) { throw new RuntimeException("Unexpected UnsupportedEncodingException exception for encoding 'UTF-8' when writing Archive entry from a StringBuilder instance.", e); } return this; }
/** * Add the supplied data as an entry in the deployment. * * @param path The target path of the entry when added to the archive. * @param data The data. * @return This archive instance. * @throws IOException Error reading from data stream. */ public Archive addEntry(String path, InputStream data) throws IOException { AssertArgument.isNotNullAndNotEmpty(path, "path"); AssertArgument.isNotNull(data, "data"); try { byte[] dataBytes = StreamUtils.readStream(data); addEntry(trimLeadingSlash(path.trim()), dataBytes); } finally { try { data.close(); } catch (IOException e) { logger.warn("Unable to close input stream for archive entry '" + path + "'."); } } return this; }
/** * Add the supplied data as an entry in the deployment. * * @param path The target path of the entry when added to the archive. * @param data The data. * @return This archive instance. * @throws IOException Error reading from data stream. */ public Archive addEntry(String path, InputStream data) throws IOException { AssertArgument.isNotNullAndNotEmpty(path, "path"); AssertArgument.isNotNull(data, "data"); try { byte[] dataBytes = StreamUtils.readStream(data); addEntry(trimLeadingSlash(path.trim()), dataBytes); } finally { try { data.close(); } catch (IOException e) { logger.warn("Unable to close input stream for archive entry '" + path + "'."); } } return this; }
/** * Add the supplied data as an entry in the deployment. * * @param path The target path of the entry when added to the archive. * @param data The data. * @return This archive instance. * @throws IOException Error reading from data stream. */ public Archive addEntry(String path, InputStream data) throws IOException { AssertArgument.isNotNullAndNotEmpty(path, "path"); AssertArgument.isNotNull(data, "data"); try { byte[] dataBytes = StreamUtils.readStream(data); addEntry(trimLeadingSlash(path.trim()), dataBytes); } finally { try { data.close(); } catch (IOException e) { logger.warn("Unable to close input stream for archive entry '" + path + "'."); } } return this; }