Return-Path: X-Original-To: apmail-activemq-commits-archive@www.apache.org Delivered-To: apmail-activemq-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id BCD7D9CEC for ; Wed, 25 Jan 2012 01:09:22 +0000 (UTC) Received: (qmail 72553 invoked by uid 500); 25 Jan 2012 01:09:22 -0000 Delivered-To: apmail-activemq-commits-archive@activemq.apache.org Received: (qmail 72499 invoked by uid 500); 25 Jan 2012 01:09:22 -0000 Mailing-List: contact commits-help@activemq.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@activemq.apache.org Delivered-To: mailing list commits@activemq.apache.org Received: (qmail 72492 invoked by uid 99); 25 Jan 2012 01:09:22 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 25 Jan 2012 01:09:22 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED,WEIRD_QUOTING X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 25 Jan 2012 01:09:20 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 9A9C12388900 for ; Wed, 25 Jan 2012 01:09:00 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1235585 - /activemq/activemq-apollo/trunk/apollo-cli/src/main/scala/org/apache/activemq/apollo/cli/commands/Create.scala Date: Wed, 25 Jan 2012 01:09:00 -0000 To: commits@activemq.apache.org From: chirino@apache.org X-Mailer: svnmailer-1.0.8-patched Message-Id: <20120125010900.9A9C12388900@eris.apache.org> Author: chirino Date: Wed Jan 25 01:09:00 2012 New Revision: 1235585 URL: http://svn.apache.org/viewvc?rev=1235585&view=rev Log: Fixed generated config files on windows so that they use windows line endings Modified: activemq/activemq-apollo/trunk/apollo-cli/src/main/scala/org/apache/activemq/apollo/cli/commands/Create.scala (contents, props changed) Modified: activemq/activemq-apollo/trunk/apollo-cli/src/main/scala/org/apache/activemq/apollo/cli/commands/Create.scala URL: http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-cli/src/main/scala/org/apache/activemq/apollo/cli/commands/Create.scala?rev=1235585&r1=1235584&r2=1235585&view=diff ============================================================================== --- activemq/activemq-apollo/trunk/apollo-cli/src/main/scala/org/apache/activemq/apollo/cli/commands/Create.scala (original) +++ activemq/activemq-apollo/trunk/apollo-cli/src/main/scala/org/apache/activemq/apollo/cli/commands/Create.scala Wed Jan 25 01:09:00 2012 @@ -52,7 +52,10 @@ class Create extends Action { @option(name = "--with-ssl", description = "Generate an SSL enabled configuraiton") val with_ssl = true - + + @option(name = "--encoding", description = "The encoding that text files should use") + val encoding = "UTF-8" + var broker_security_config = """ @@ -85,14 +88,14 @@ class Create extends Action { etc.mkdirs if (create_log_config) { - write("etc/log4j.properties", etc/"log4j.properties") + write("etc/log4j.properties", etc/"log4j.properties", false, true) } if ( create_login_config ) { - write("etc/users.properties", etc/"users.properties") - write("etc/groups.properties", etc/"groups.properties") - write("etc/login.config", etc/"login.config") - write("etc/black-list.txt", etc/"black-list.txt") + write("etc/users.properties", etc/"users.properties", false, true) + write("etc/groups.properties", etc/"groups.properties", false, true) + write("etc/login.config", etc/"login.config", false, true) + write("etc/black-list.txt", etc/"black-list.txt", false, true) } // Generate a keystore with a new key @@ -194,17 +197,11 @@ class Create extends Action { null } - def write(source:String, target:File, filter:Boolean=false, target_encoding:String=null) = { + def write(source:String, target:File, filter:Boolean=false, text:Boolean=false) = { if( target.exists && !force ) { error("The file '%s' already exists. Use --force to overwrite.".format(target)) } - if( filter || target_encoding!=null ) { - - val encoding = if( target_encoding!=null ) { - target_encoding - } else { - "UTF-8" - } + if( filter || text ) { val out = new ByteArrayOutputStream() using(getClass.getResourceAsStream(source)) { in=> @@ -233,8 +230,10 @@ class Create extends Action { replace("${broker_security_config}", broker_security_config) replace("${host_security_config}", host_security_config) } - // and then writing out in the new target encoding. - val in = new ByteArrayInputStream(content.getBytes(encoding)) + + // and then writing out in the new target encoding.. Let's also replace \n with the values + // that is correct for the current platform. + val in = new ByteArrayInputStream(content.replaceAll("""\r?\n""", Matcher.quoteReplacement(System.getProperty("line.separator"))).getBytes(encoding)) using(new FileOutputStream(target)) { out=> copy(in, out) Propchange: activemq/activemq-apollo/trunk/apollo-cli/src/main/scala/org/apache/activemq/apollo/cli/commands/Create.scala ------------------------------------------------------------------------------ svn:executable = *