Return-Path: Delivered-To: apmail-directory-commits-archive@www.apache.org Received: (qmail 8696 invoked from network); 13 Dec 2010 14:17:47 -0000 Received: from unknown (HELO mail.apache.org) (140.211.11.3) by 140.211.11.9 with SMTP; 13 Dec 2010 14:17:47 -0000 Received: (qmail 67780 invoked by uid 500); 13 Dec 2010 14:17:47 -0000 Delivered-To: apmail-directory-commits-archive@directory.apache.org Received: (qmail 67717 invoked by uid 500); 13 Dec 2010 14:17:46 -0000 Mailing-List: contact commits-help@directory.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@directory.apache.org Delivered-To: mailing list commits@directory.apache.org Received: (qmail 67710 invoked by uid 99); 13 Dec 2010 14:17:46 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 13 Dec 2010 14:17:46 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED 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; Mon, 13 Dec 2010 14:17:43 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id E091A2388A33; Mon, 13 Dec 2010 14:17:22 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1045127 - /directory/apacheds/trunk/server-config/src/main/java/org/apache/directory/server/config/ConfigWriter.java Date: Mon, 13 Dec 2010 14:17:22 -0000 To: commits@directory.apache.org From: pamarcelot@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20101213141722.E091A2388A33@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: pamarcelot Date: Mon Dec 13 14:17:22 2010 New Revision: 1045127 URL: http://svn.apache.org/viewvc?rev=1045127&view=rev Log: Renamed 'write...' methods. Added a new 'writeToString()' which convert the configuration to simple a string. Modified: directory/apacheds/trunk/server-config/src/main/java/org/apache/directory/server/config/ConfigWriter.java Modified: directory/apacheds/trunk/server-config/src/main/java/org/apache/directory/server/config/ConfigWriter.java URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/server-config/src/main/java/org/apache/directory/server/config/ConfigWriter.java?rev=1045127&r1=1045126&r2=1045127&view=diff ============================================================================== --- directory/apacheds/trunk/server-config/src/main/java/org/apache/directory/server/config/ConfigWriter.java (original) +++ directory/apacheds/trunk/server-config/src/main/java/org/apache/directory/server/config/ConfigWriter.java Mon Dec 13 14:17:22 2010 @@ -125,9 +125,9 @@ public class ConfigWriter * @throws IOException * if an error occurs when writing the file */ - public void write( String path ) throws ConfigurationException, IOException + public void writeToPath( String path ) throws ConfigurationException, IOException { - write( new File( path ) ); + writeToFile( new File( path ) ); } @@ -141,19 +141,38 @@ public class ConfigWriter * @throws IOException * if an error occurs when writing the file */ - public void write( File file ) throws ConfigurationException, IOException + public void writeToFile( File file ) throws ConfigurationException, IOException + { + // Writing the file to disk + FileWriter writer = new FileWriter( file ); + writer.append( writeToString() ); + writer.close(); + } + + + /** + * Writes the configuration to a String object. + * + * @return + * a String containing the LDIF + * representation of the configuration + * @throws ConfigurationException + * if an error occurs during the conversion to LDIF + */ + public String writeToString() throws ConfigurationException { // Converting the configuration bean to a list of LDIF entries convertConfigurationBeanToLdifEntries(); - // Writing the file to disk - FileWriter writer = new FileWriter( file ); - writer.append( "version: 1\n" ); + // Building the StringBuilder + StringBuilder sb = new StringBuilder(); + sb.append( "version: 1\n" ); for ( LdifEntry entry : entries ) { - writer.append( entry.toString() ); + sb.append( entry.toString() ); } - writer.close(); + + return sb.toString(); }