You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@archiva.apache.org by jo...@apache.org on 2007/09/21 23:23:49 UTC

svn commit: r578279 - in /maven/archiva/trunk/archiva-base: archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/metadata/RepositoryMetadataWriter.java archiva-xml-tools/src/main/java/org/apache/maven/archiva/xml/XMLWriter.java

Author: joakime
Date: Fri Sep 21 14:23:48 2007
New Revision: 578279

URL: http://svn.apache.org/viewvc?rev=578279&view=rev
Log:
Correcting test error with closed writer stream.


Modified:
    maven/archiva/trunk/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/metadata/RepositoryMetadataWriter.java
    maven/archiva/trunk/archiva-base/archiva-xml-tools/src/main/java/org/apache/maven/archiva/xml/XMLWriter.java

Modified: maven/archiva/trunk/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/metadata/RepositoryMetadataWriter.java
URL: http://svn.apache.org/viewvc/maven/archiva/trunk/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/metadata/RepositoryMetadataWriter.java?rev=578279&r1=578278&r2=578279&view=diff
==============================================================================
--- maven/archiva/trunk/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/metadata/RepositoryMetadataWriter.java (original)
+++ maven/archiva/trunk/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/metadata/RepositoryMetadataWriter.java Fri Sep 21 14:23:48 2007
@@ -97,7 +97,7 @@
             if ( CollectionUtils.isNotEmpty( metadata.getAvailableVersions() ) )
             {
                 Element versions = versioning.addElement( "versions" );
-                Iterator it = metadata.getAvailableVersions().iterator();
+                Iterator<String> it = metadata.getAvailableVersions().iterator();
                 while ( it.hasNext() )
                 {
                     String version = (String) it.next();

Modified: maven/archiva/trunk/archiva-base/archiva-xml-tools/src/main/java/org/apache/maven/archiva/xml/XMLWriter.java
URL: http://svn.apache.org/viewvc/maven/archiva/trunk/archiva-base/archiva-xml-tools/src/main/java/org/apache/maven/archiva/xml/XMLWriter.java?rev=578279&r1=578278&r2=578279&view=diff
==============================================================================
--- maven/archiva/trunk/archiva-base/archiva-xml-tools/src/main/java/org/apache/maven/archiva/xml/XMLWriter.java (original)
+++ maven/archiva/trunk/archiva-base/archiva-xml-tools/src/main/java/org/apache/maven/archiva/xml/XMLWriter.java Fri Sep 21 14:23:48 2007
@@ -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.Writer;
 
 /**
- * XMLWriter 
+ * XMLWriter - Making writing XML files easier. 
  *
  * @author <a href="mailto:joakime@apache.org">Joakim Erdfelt</a>
  * @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 @@
         }
         finally
         {
-            if( xmlwriter != null )
+            if ( close && ( xmlwriter != null ) )
             {
                 try
                 {