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

Examples of org.sonatype.sisu.goodies.common.io.FileReplacer.replace()


      // 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


          // backup old version
          Files.copy(file.toPath(), new File(file.getParentFile(), file.getName() + ".old").toPath(),
              StandardCopyOption.REPLACE_EXISTING);
          while (upgrader != null && !Objects.equals(currentModelVersion, currentFileVersion)) {
            try {
              fileReplacer.replace(new ModelUpgraderAdapter(file, upgrader));
            }
            catch (CorruptModelException e) {
              final CorruptModelException ex = new CorruptModelException(String
                  .format("Model %s detected as corrupt during upgrade from version %s to version %s",
                      file.getAbsolutePath(), upgrader.fromVersion(),
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
              {
View Full Code Here

    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
Copyright © 2018 www.massapi.com. 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.