@Override public void createProjectSettingsFile() { getFileManager().createFile(getProjectSettingsLocation()); }
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 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 = fileManager.createFile(fileIdentifier).getOutputStream(); try { String contents = IOUtils.toString(inputStream);
if (entry.getName().equals(expectedEntryName)) { final MutableFile target = fileManager.createFile(pathResolver.getFocusedIdentifier(Path.SRC_MAIN_RESOURCES, packagePath + "/" + countryCode + ".png")); OutputStream outputStream = null;
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) {
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); } } }
/** * 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); }
try { outputStream = fileManager.createFile( pathResolver.getFocusedIdentifier(Path.SRC_MAIN_RESOURCES, packagePath + separatorChar + messageBundle.getName())).getOutputStream(); if (flagGraphic != null) { outputStream = fileManager.createFile( pathResolver.getFocusedIdentifier(Path.SRC_MAIN_RESOURCES, packagePath + separatorChar + flagGraphic.getName())).getOutputStream(); final MutableFile mutableFile = fileManager.createFile(destinationFile); outputStream = mutableFile.getOutputStream(); IOUtils.write(input, outputStream);
props.load(inputStream); } else { appDevMutableFile = fileManager.createFile(filePath);
} else { mutableFile = getFileManager().createFile(filePath);
LogicalPath rootPath = LogicalPath.getInstance(Path.ROOT, ""); mutableFile = fileManager.createFile(pathResolver.getIdentifier(rootPath, folder + "/" + destinationFile)); } else { LogicalPath rootPath = LogicalPath.getInstance(Path.ROOT, ""); mutableFile = fileManager.createFile(pathResolver.getIdentifier(rootPath, destinationFile));
fileManager.createFile(pathResolver.getIdentifier(rootPath, folder + "/" + "src/main/resources/obr.xml")); } else { LogicalPath rootPath = LogicalPath.getInstance(Path.ROOT, ""); fileManager.createFile(pathResolver.getIdentifier(rootPath, "src/main/resources/obr.xml"));
fileManager.createFile(pathResolver.getIdentifier(rootPath, "src/main/assembly/repo-assembly.xml"));
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) {
private void copyTemplate(final String templateFileName, final String resolvedTargetDirectoryPath) { InputStream inputStream = null; OutputStream outputStream = null; try { inputStream = FileUtils .getInputStream(getClass(), templateFileName); outputStream = fileManager.createFile( resolvedTargetDirectoryPath + "/" + templateFileName) .getOutputStream(); IOUtils.copy(inputStream, outputStream); } catch (final IOException e) { throw new IllegalStateException( "Encountered an error during copying of resources for Web Flow addon.", e); } finally { IOUtils.closeQuietly(inputStream); IOUtils.closeQuietly(outputStream); } }
private void installImage(final LogicalPath path, final String imagePath) { final PathResolver pathResolver = projectOperations.getPathResolver(); final String imageFile = pathResolver.getIdentifier(path, imagePath); if (!fileManager.exists(imageFile)) { InputStream inputStream = null; OutputStream outputStream = null; try { inputStream = FileUtils.getInputStream(getClass(), imagePath); outputStream = fileManager.createFile( pathResolver.getIdentifier(path, imagePath)) .getOutputStream(); IOUtils.copy(inputStream, outputStream); } catch (final Exception e) { throw new IllegalStateException( "Encountered an error during copying of resources for MVC JSP addon.", e); } finally { IOUtils.closeQuietly(inputStream); IOUtils.closeQuietly(outputStream); } } }
private void writeTemplateFile(String destination,String bundleName,Set<Dependency> dependencies) { try { ProjectMetadata project = (ProjectMetadata) metadataService.get(ProjectMetadata.getProjectIdentifier()); String mfFile = FileCopyUtils.copyToString(new InputStreamReader(TemplateUtils.getTemplate(getClass(), "template.mf"))); mfFile = mfFile.replaceAll("#topLevelPackage#", project.getTopLevelPackage().toString()); String bundleNameReplacement = project.getProjectName(); if (null != bundleName) { bundleNameReplacement = bundleName; } mfFile = mfFile.replaceAll("#bundleName#",bundleNameReplacement); for (Dependency d : dependencies) { String bundleImport = bundleImportFor(d); if (null != bundleImport) { mfFile += (bundleImport + "\n"); } } FileCopyUtils.copy(mfFile,new OutputStreamWriter(fileManager.createFile(destination).getOutputStream())); } catch (IOException ioe) { throw new IllegalStateException(ioe); } }