Package org.sonatype.sisu.goodies.common.io.FileReplacer

Examples of org.sonatype.sisu.goodies.common.io.FileReplacer.ContentWriter


      // perform the "safe save"
      getLogger().debug("Saving configuration: {}", file);
      final FileReplacer fileReplacer = new FileReplacer(file);
      fileReplacer.setDeleteBackupFile(true);

      fileReplacer.replace(new ContentWriter()
      {
        @Override
        public void write(final BufferedOutputStream output)
            throws IOException
        {
View Full Code Here


    log.info("Saving model {}", file.getAbsoluteFile());
    DirSupport.mkdir(file.getParentFile().toPath());
    final File backupFile = new File(file.getParentFile(), file.getName() + ".bak");
    final FileReplacer fileReplacer = new FileReplacer(file);
    fileReplacer.setDeleteBackupFile(false);
    fileReplacer.replace(new ContentWriter()
    {
      @Override
      public void write(final BufferedOutputStream output) throws IOException {
        writer.write(output, model);
        output.flush();
View Full Code Here

                    final Map<String, LoggerLevel> overrides)
  {
    try {
      final FileReplacer fileReplacer = new FileReplacer(overridesXml);
      fileReplacer.setDeleteBackupFile(true);
      fileReplacer.replace(new ContentWriter()
      {
        @Override
        public void write(final BufferedOutputStream output)
            throws IOException
        {
View Full Code Here

    final File configurationFile = new File(getLogConfigDir(), LOG_CONF_PROPS);
    logger.debug("Saving configuration: {}", configurationFile);
    final FileReplacer fileReplacer = new FileReplacer(configurationFile);
    // we save this file many times, don't litter backups
    fileReplacer.setDeleteBackupFile(true);
    fileReplacer.replace(new ContentWriter()
    {
      @Override
      public void write(final BufferedOutputStream output)
          throws IOException
      {
View Full Code Here

        if (participant instanceof LogConfigurationParticipant.NonEditable || !logConfigFile.exists()) {
          try {
            final FileReplacer fileReplacer = new FileReplacer(logConfigFile);
            // we save this file many times, don't litter backups
            fileReplacer.setDeleteBackupFile(true);
            fileReplacer.replace(new ContentWriter()
            {
              @Override
              public void write(final BufferedOutputStream output)
                  throws IOException
              {
                try (final InputStream in = participant.getConfiguration()) {
                  StreamSupport.copy(in, output, StreamSupport.BUFFER_SIZE);
                }
              }
            });
          }
          catch (IOException e) {
            throw new IllegalStateException(String.format("Could not create %s as %s", name,
                logConfigFile.getAbsolutePath()), e);
          }
        }
      }
    }
    final File logConfigFile = new File(logConfigDir, LOG_CONF);
    try {
      final FileReplacer fileReplacer = new FileReplacer(logConfigFile);
      // we save this file many times, don't litter backups
      fileReplacer.setDeleteBackupFile(true);
      fileReplacer.replace(new ContentWriter()
      {
        @Override
        public void write(final BufferedOutputStream output)
            throws IOException
        {
View Full Code Here

    final Configuration configuration = configHelper.encryptDecryptPasswords(getConfiguration(), true);
    log.debug("Saving configuration: {}", file);
    final FileReplacer fileReplacer = new FileReplacer(file);
    // we save this file many times, don't litter backups
    fileReplacer.setDeleteBackupFile(true);
    fileReplacer.replace(new ContentWriter()
    {
      @Override
      public void write(final BufferedOutputStream output)
          throws IOException
      {
View Full Code Here

    // perform the "safe save"
    getLogger().debug("Saving configuration: {}", file);
    final FileReplacer fileReplacer = new FileReplacer(file);
    fileReplacer.setDeleteBackupFile(true);

    fileReplacer.replace(new ContentWriter()
    {
      @Override
      public void write(final BufferedOutputStream output)
          throws IOException
      {
View Full Code Here

    log.debug("Saving configuration: {}", configurationFile);
    try {
      final FileReplacer fileReplacer = new FileReplacer(configurationFile);
      // we save this file many times, don't litter backups
      fileReplacer.setDeleteBackupFile(true);
      fileReplacer.replace(new ContentWriter()
      {
        @Override
        public void write(final BufferedOutputStream output)
            throws IOException
        {
View Full Code Here

TOP

Related Classes of org.sonatype.sisu.goodies.common.io.FileReplacer.ContentWriter

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.