OutputStream outputStream = fileManager.createFile(fileIdentifier).getOutputStream(); try { String contents = IOUtils.toString(inputStream);
private void setUpLog4jConfiguration() { final String log4jConfigFile = getPathResolver().getFocusedIdentifier(Path.SRC_MAIN_RESOURCES, "log4j.properties"); final InputStream templateInputStream = FileUtils.getInputStream(getClass(), "log4j.properties-template"); OutputStream outputStream = null; try { outputStream = getFileManager().createFile(log4jConfigFile).getOutputStream(); IOUtils.copy(templateInputStream, outputStream); } catch (final IOException e) { LOGGER.warning("Unable to install log4j logging configuration"); } finally { IOUtils.closeQuietly(templateInputStream); IOUtils.closeQuietly(outputStream); } }
OutputStream outputStream = null; try { outputStream = target.getOutputStream(); IOUtils.copy(zis, outputStream); success = true;
mutableFile.setDescriptionOfChange(descriptionOfChange); outputStream = mutableFile.getOutputStream(); IOUtils.write(newContents, outputStream); } catch (final IOException e) {
try { inputStream = url.openStream(); outputStream = fileManager.createFile(targetDirectory + fileName).getOutputStream(); IOUtils.copy(inputStream, outputStream); } catch (final Exception e) {
public String backup() { Validate.isTrue(isBackupPossible(), "Project metadata unavailable"); // For Windows, make a date format that can legally form part of a // filename (ROO-277) final String pattern = File.separatorChar == '\\' ? "yyyy-MM-dd_HH.mm.ss" : "yyyy-MM-dd_HH:mm:ss"; final DateFormat df = new SimpleDateFormat(pattern); final long start = System.nanoTime(); ZipOutputStream zos = null; try { final File projectDirectory = new File(getProjectOperations().getPathResolver().getFocusedIdentifier(Path.ROOT, ".")); final MutableFile file = getFileManager().createFile( FileUtils.getCanonicalPath(new File(projectDirectory, getProjectOperations() .getFocusedProjectName() + "_" + df.format(new Date()) + ".zip"))); zos = new ZipOutputStream(file.getOutputStream()); zip(projectDirectory, projectDirectory, zos); } catch (final FileNotFoundException e) { LOGGER.fine("Could not determine project directory"); } catch (final IOException e) { LOGGER.fine("Could not create backup archive"); } finally { IOUtils.closeQuietly(zos); } final long milliseconds = (System.nanoTime() - start) / 1000000; return "Backup completed in " + milliseconds + " ms"; }
try { inputStream = url.openStream(); outputStream = fileManager.createFile(targetDirectory + fileName).getOutputStream(); IOUtils.copy(inputStream, outputStream); } catch (final Exception e) {
@Override public void removeProperty(LogicalPath propertyFilePath, String propertyFilename, String prefix, String key) { Validate.notNull(prefix, "Prefix could be blank but not null"); Validate.notNull(propertyFilePath, "Property file path required"); Validate.notBlank(propertyFilename, "Property filename required"); Validate.notBlank(key, "Key required"); final String filePath = getProjectOperations().getPathResolver().getIdentifier(propertyFilePath, propertyFilename); MutableFile mutableFile = null; final Properties props = new Properties(); if (getFileManager().exists(filePath)) { mutableFile = getFileManager().updateFile(filePath); loadProperties(props, mutableFile.getInputStream()); } else { throw new IllegalStateException(String.format("ERROR: '%s' properties file doesn't exists.", filePath)); } // Including prefix if needed if (StringUtils.isNotBlank(prefix)) { key = prefix.concat(".").concat(key); } if (props.containsKey(key)) { props.remove(key); storeProps(props, mutableFile.getOutputStream(), "Updated at " + new Date()); } }
@Override public void removePropertiesByPrefix(LogicalPath propertyFilePath, String propertyFilename, String prefix) { Validate.notBlank(prefix, "Prefix required"); Validate.notNull(propertyFilePath, "Property file path required"); Validate.notBlank(propertyFilename, "Property filename required"); final String filePath = getProjectOperations().getPathResolver().getIdentifier(propertyFilePath, propertyFilename); MutableFile mutableFile = null; final Properties props = new Properties(); if (getFileManager().exists(filePath)) { mutableFile = getFileManager().updateFile(filePath); loadProperties(props, mutableFile.getInputStream()); } else { throw new IllegalStateException(String.format("ERROR: '%s' properties file doesn't exists.", filePath)); } for (Entry property : props.entrySet()) { String key = (String) property.getKey(); if (key != null && key.startsWith(prefix)) { props.remove(key); } } storeProps(props, mutableFile.getOutputStream(), "Updated at " + new Date()); }
private void writeTextFile(final String fullPathFromRoot, final String message, String folder) { Validate.notBlank(fullPathFromRoot, "Text file name to write is required"); Validate.notBlank(message, "Message required"); MutableFile mutableFile; if (folder != null) { LogicalPath rootPath = LogicalPath.getInstance(Path.ROOT, ""); mutableFile = fileManager.createFile(pathResolver.getIdentifier(rootPath, folder + "/" + fullPathFromRoot)); } else { LogicalPath rootPath = LogicalPath.getInstance(Path.ROOT, ""); mutableFile = fileManager.createFile(pathResolver.getIdentifier(rootPath, fullPathFromRoot)); } OutputStream outputStream = null; try { outputStream = mutableFile.getOutputStream(); IOUtils.write(message, outputStream); } catch (final IOException ioe) { throw new IllegalStateException(ioe); } finally { IOUtils.closeQuietly(outputStream); } }
private void copyFile(String fileName, String folder) { String file; LogicalPath rootPath = LogicalPath.getInstance(Path.ROOT, ""); if (folder != null) { file = pathResolver.getIdentifier(rootPath, folder + "/src/main/resources/" + fileName); } else { file = pathResolver.getIdentifier(rootPath, fileName); } InputStream inputStream = null; OutputStream outputStream = null; try { inputStream = FileUtils.getInputStream(getClass(), "resources/" + fileName); if (!fileManager.exists(file)) { outputStream = fileManager.createFile(file).getOutputStream(); } if (outputStream != null) { IOUtils.copy(inputStream, outputStream); } } catch (final IOException ioe) { throw new IllegalStateException(ioe); } finally { IOUtils.closeQuietly(inputStream); if (outputStream != null) { IOUtils.closeQuietly(outputStream); } } }
dependenciesElement.appendChild(dependencyAdvancedElement); XmlUtils.writeXml(fileManager.updateFile(pomRooAddonSuite).getOutputStream(), docXml);
fileManager.createFile( pathResolver.getFocusedIdentifier(Path.SRC_MAIN_RESOURCES, packagePath + separatorChar + messageBundle.getName())).getOutputStream(); org.apache.commons.io.FileUtils.copyFile(messageBundle, outputStream); if (flagGraphic != null) { fileManager.createFile( pathResolver.getFocusedIdentifier(Path.SRC_MAIN_RESOURCES, packagePath + separatorChar + flagGraphic.getName())).getOutputStream(); org.apache.commons.io.FileUtils.copyFile(flagGraphic, outputStream); } else { outputStream = mutableFile.getOutputStream(); IOUtils.write(input, outputStream); } catch (final IOException ioe) {
outputStream = appDevMutableFile.getOutputStream(); props.put("spring.messages.cache-seconds", "0"); props.put("logging.file", "");
storeProps(props, mutableFile.getOutputStream(), "Updated at " + new Date());
outputStream = mutableFile.getOutputStream(); IOUtils.write(input, outputStream); } catch (final IOException ioe) {
fileManager.updateFile( pathResolver.getIdentifier(rootPath, folder + "/" + "src/main/resources/obr.xml")) .getOutputStream(), docXml); fileManager.updateFile( pathResolver.getIdentifier(rootPath, "src/main/resources/obr.xml")) .getOutputStream(), docXml);
"src/main/assembly/repo-assembly.xml")); XmlUtils.writeXml(assemblyFile.getOutputStream(), assemblyDoc);
try { inputStream = language.getMessageBundle(); outputStream = getFileManager().createFile(messageBundle).getOutputStream(); IOUtils.copy(inputStream, outputStream); } catch (final Exception e) { try { inputStream = language.getFlagGraphic(); outputStream = getFileManager().createFile(flagGraphic).getOutputStream(); IOUtils.copy(inputStream, outputStream); } catch (final Exception e) {
/** * Writes the given Maven POM to disk * * @param pom the POM to write (required) */ private void writePomFile(final Document pom, String folder) { MutableFile pomFile; if (folder != null) { LogicalPath rootPath = LogicalPath.getInstance(Path.ROOT, ""); pomFile = fileManager.createFile(pathResolver.getIdentifier(rootPath, folder + "/" + POM_XML)); } else { LogicalPath rootPath = LogicalPath.getInstance(Path.ROOT, ""); pomFile = fileManager.createFile(pathResolver.getIdentifier(rootPath, POM_XML)); } XmlUtils.writeXml(pomFile.getOutputStream(), pom); }