Coverage Report - org.apache.maven.wagon.WagonUtils
 
Classes in this File Line Coverage Branch Coverage Complexity
WagonUtils
0%
0/30
0%
0/14
3,667
 
 1  
 package org.apache.maven.wagon;
 2  
 
 3  
 /*
 4  
  * Licensed to the Apache Software Foundation (ASF) under one
 5  
  * or more contributor license agreements.  See the NOTICE file
 6  
  * distributed with this work for additional information
 7  
  * regarding copyright ownership.  The ASF licenses this file
 8  
  * to you under the Apache License, Version 2.0 (the
 9  
  * "License"); you may not use this file except in compliance
 10  
  * with the License.  You may obtain a copy of the License at
 11  
  *
 12  
  *   http://www.apache.org/licenses/LICENSE-2.0
 13  
  *
 14  
  * Unless required by applicable law or agreed to in writing,
 15  
  * software distributed under the License is distributed on an
 16  
  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 17  
  * KIND, either express or implied.  See the License for the
 18  
  * specific language governing permissions and limitations
 19  
  * under the License.
 20  
  */
 21  
 
 22  
 import java.io.File;
 23  
 import java.io.IOException;
 24  
 import java.util.LinkedList;
 25  
 
 26  
 import org.apache.maven.wagon.authorization.AuthorizationException;
 27  
 import org.codehaus.plexus.util.FileUtils;
 28  
 
 29  
 /**
 30  
  * @author <a href="mailto:mmaczka@interia.pl">Michal Maczka</a>
 31  
  * @version $Id: WagonUtils.java 680954 2008-07-30 09:54:09Z brett $
 32  
  * @deprecated
 33  
  */
 34  
 public final class WagonUtils
 35  
 {
 36  
     private WagonUtils()
 37  0
     {
 38  0
     }
 39  
 
 40  
     public static String toString( String resource, Wagon wagon )
 41  
         throws IOException, TransferFailedException, ResourceDoesNotExistException, AuthorizationException
 42  
     {
 43  
 
 44  0
         File file = null;
 45  
 
 46  
         try
 47  
         {
 48  0
             file = File.createTempFile( "wagon", "tmp" );
 49  
 
 50  0
             wagon.get( resource, file );
 51  
 
 52  0
             String retValue = FileUtils.fileRead( file );
 53  
 
 54  0
             return retValue;
 55  
         }
 56  
         finally
 57  
         {
 58  0
             if ( file != null )
 59  
             {
 60  0
                 boolean deleted = file.delete();
 61  
 
 62  0
                 if ( !deleted )
 63  
                 {
 64  0
                     file.deleteOnExit();
 65  
                 }
 66  0
             }
 67  
         }
 68  
 
 69  
     }
 70  
 
 71  
 
 72  
     public static void putDirectory( File dir, Wagon wagon, boolean includeBasdir )
 73  
         throws ResourceDoesNotExistException, TransferFailedException, AuthorizationException
 74  
     {
 75  
 
 76  0
         LinkedList queue = new LinkedList();
 77  
 
 78  0
         if ( includeBasdir )
 79  
         {
 80  0
             queue.add( dir.getName() );
 81  
         }
 82  
         else
 83  
         {
 84  0
             queue.add( "" );
 85  
         }
 86  
 
 87  0
         while ( !queue.isEmpty() )
 88  
         {
 89  0
             String path = (String) queue.removeFirst();
 90  
 
 91  0
             File currentDir = new File( dir, path );
 92  
 
 93  0
             File[] files = currentDir.listFiles();
 94  
 
 95  0
             for ( int i = 0; i < files.length; i++ )
 96  
             {
 97  0
                 File file = files[i];
 98  
 
 99  
                 String resource;
 100  
 
 101  0
                 if ( path.length() > 0 )
 102  
                 {
 103  0
                     resource = path + "/" + file.getName();
 104  
                 }
 105  
                 else
 106  
                 {
 107  0
                     resource = file.getName();
 108  
                 }
 109  
 
 110  0
                 if ( file.isDirectory() )
 111  
                 {
 112  0
                     queue.add( resource );
 113  
                 }
 114  
                 else
 115  
                 {
 116  0
                     wagon.put( file, resource );
 117  
                 }
 118  
 
 119  
             }
 120  
 
 121  0
         }
 122  
 
 123  0
     }
 124  
 }