Coverage Report - org.apache.maven.artifact.ant.AntDownloadMonitor
 
Classes in this File Line Coverage Branch Coverage Complexity
AntDownloadMonitor
0%
0/18
0%
0/10
1.333
 
 1  
 package org.apache.maven.artifact.ant;
 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 org.apache.maven.wagon.events.TransferEvent;
 23  
 import org.apache.maven.wagon.events.TransferListener;
 24  
 import org.apache.tools.ant.Project;
 25  
 import org.apache.tools.ant.ProjectComponent;
 26  
 
 27  
 /**
 28  
  * Log wagon events in the ant tasks
 29  
  *
 30  
  * @author <a href="mailto:brett@apache.org">Brett Porter</a>
 31  
  * @version $Id: org.apache.maven.artifact.ant.AntDownloadMonitor.html 806929 2012-03-01 18:57:40Z hboutemy $
 32  
  */
 33  0
 public class AntDownloadMonitor
 34  
     extends ProjectComponent
 35  
     implements TransferListener
 36  
 {
 37  
     private static final int KILO = 1024;
 38  
 
 39  
     public void debug( String s )
 40  
     {
 41  0
         log( s, Project.MSG_DEBUG );
 42  0
     }
 43  
 
 44  
     public void transferCompleted( TransferEvent event )
 45  
     {
 46  0
         long contentLength = event.getResource().getContentLength();
 47  0
         if ( ( contentLength > 0 ) && ( event.getRequestType() == TransferEvent.REQUEST_PUT ) )
 48  
         {
 49  0
             log( "Uploaded " + ( ( contentLength + KILO / 2 ) / KILO ) + "K" );
 50  
         }
 51  0
     }
 52  
 
 53  
     public void transferError( TransferEvent event )
 54  
     {
 55  0
         log( event.getException().getMessage(), Project.MSG_ERR );
 56  0
     }
 57  
 
 58  
     public void transferInitiated( TransferEvent event )
 59  
     {
 60  0
         String message = event.getRequestType() == TransferEvent.REQUEST_PUT ? "Uploading" : "Downloading";
 61  0
         String dest = event.getRequestType() == TransferEvent.REQUEST_PUT ? " to " : " from ";
 62  
 
 63  0
         log( message + ": " + event.getResource().getName() + dest + "repository "
 64  
             + event.getWagon().getRepository().getId() + " at " + event.getWagon().getRepository().getUrl() );
 65  0
     }
 66  
 
 67  
     public void transferProgress( TransferEvent event, byte[] bytes, int i )
 68  
     {
 69  0
     }
 70  
 
 71  
     public void transferStarted( TransferEvent event )
 72  
     {
 73  0
         long contentLength = event.getResource().getContentLength();
 74  0
         if ( contentLength > 0 )
 75  
         {
 76  0
             log( "Transferring " + ( ( contentLength + KILO / 2 ) / KILO ) + "K from "
 77  
                             + event.getWagon().getRepository().getId() );
 78  
         }
 79  0
     }
 80  
 }