From: Joakim Erdfelt Date: Fri, 21 Sep 2007 21:23:48 +0000 (+0000) Subject: Correcting test error with closed writer stream. X-Git-Tag: archiva-1.0-beta-3~163 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=af7ab9cdbb50a3fdc4bea4a77a8c2d4d19a899c7;p=archiva.git Correcting test error with closed writer stream. git-svn-id: https://svn.apache.org/repos/asf/maven/archiva/trunk@578279 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/metadata/RepositoryMetadataWriter.java b/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/metadata/RepositoryMetadataWriter.java index 606b35c2e..fb99fb235 100644 --- a/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/metadata/RepositoryMetadataWriter.java +++ b/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/metadata/RepositoryMetadataWriter.java @@ -97,7 +97,7 @@ public class RepositoryMetadataWriter if ( CollectionUtils.isNotEmpty( metadata.getAvailableVersions() ) ) { Element versions = versioning.addElement( "versions" ); - Iterator it = metadata.getAvailableVersions().iterator(); + Iterator it = metadata.getAvailableVersions().iterator(); while ( it.hasNext() ) { String version = (String) it.next(); diff --git a/archiva-base/archiva-xml-tools/src/main/java/org/apache/maven/archiva/xml/XMLWriter.java b/archiva-base/archiva-xml-tools/src/main/java/org/apache/maven/archiva/xml/XMLWriter.java index f8f4acb7c..1bdf003cd 100644 --- a/archiva-base/archiva-xml-tools/src/main/java/org/apache/maven/archiva/xml/XMLWriter.java +++ b/archiva-base/archiva-xml-tools/src/main/java/org/apache/maven/archiva/xml/XMLWriter.java @@ -1,22 +1,18 @@ package org.apache.maven.archiva.xml; /* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. + * Licensed to the Apache Software Foundation (ASF) under one or more contributor license + * agreements. See the NOTICE file distributed with this work for additional information regarding + * copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the License. You may obtain a + * copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License + * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express + * or implied. See the License for the specific language governing permissions and limitations under + * the License. */ import org.dom4j.Document; @@ -26,18 +22,39 @@ import java.io.IOException; import java.io.Writer; /** - * XMLWriter + * XMLWriter - Making writing XML files easier. * * @author Joakim Erdfelt * @version $Id$ */ public class XMLWriter { + /** + * Write the Document to the provided Writer, leaving the Writer open. + * + * @param doc the document to write. + * @param writer the writer to write to. + * @throws XMLException if there was a problem writing the xml to the writer. + */ public static void write( Document doc, Writer writer ) throws XMLException + { + write( doc, writer, false ); + } + + /** + * Write the Document to the provided Writer, with an option to close the writer upon completion. + * + * @param doc the document to write. + * @param writer the writer to write to. + * @param close true to close the writer on completion. + * @throws XMLException if there was a problem writing the xml to the writer. + */ + public static void write( Document doc, Writer writer, boolean close ) + throws XMLException { org.dom4j.io.XMLWriter xmlwriter = null; - + try { OutputFormat outputFormat = OutputFormat.createPrettyPrint(); @@ -51,7 +68,7 @@ public class XMLWriter } finally { - if( xmlwriter != null ) + if ( close && ( xmlwriter != null ) ) { try {