Coverage Report - org.apache.maven.scm.provider.cvslib.command.update.CvsUpdateConsumer
 
Classes in this File Line Coverage Branch Coverage Complexity
CvsUpdateConsumer
0 %
0/29
0 %
0/22
5
 
 1  
 package org.apache.maven.scm.provider.cvslib.command.update;
 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.scm.ScmFile;
 23  
 import org.apache.maven.scm.ScmFileStatus;
 24  
 import org.apache.maven.scm.log.ScmLogger;
 25  
 import org.codehaus.plexus.util.cli.StreamConsumer;
 26  
 import org.codehaus.plexus.util.StringUtils;
 27  
 
 28  
 import java.util.ArrayList;
 29  
 import java.util.List;
 30  
 
 31  
 /**
 32  
  * @author <a href="mailto:trygvis@inamo.no">Trygve Laugst&oslash;l</a>
 33  
  * @version $Id: CvsUpdateConsumer.java 1055643 2011-01-05 21:21:13Z olamy $
 34  
  */
 35  
 public class CvsUpdateConsumer
 36  
     implements StreamConsumer
 37  
 {
 38  
     private ScmLogger logger;
 39  
 
 40  0
     private List<ScmFile> files = new ArrayList<ScmFile>();
 41  
 
 42  
     public CvsUpdateConsumer( ScmLogger logger )
 43  0
     {
 44  0
         this.logger = logger;
 45  0
     }
 46  
 
 47  
     /** {@inheritDoc} */
 48  
     public void consumeLine( String line )
 49  
     {
 50  0
         if ( logger.isDebugEnabled() )
 51  
         {
 52  0
             logger.debug( line );
 53  
         }
 54  
 
 55  0
         if ( line.length() < 3 )
 56  
         {
 57  0
             if ( StringUtils.isNotEmpty( line ) )
 58  
             {
 59  0
                 if ( logger.isWarnEnabled() )
 60  
                 {
 61  0
                     logger.warn( "Unable to parse output from command: line length must be bigger than 3. ("
 62  
                         + line + ")." );
 63  
                 }
 64  
             }
 65  0
             return;
 66  
         }
 67  
 
 68  0
         String status = line.substring( 0, 2 );
 69  
 
 70  0
         String file = line.substring( 2 );
 71  
 
 72  0
         if ( status.equals( "U " ) )
 73  
         {
 74  0
             files.add( new ScmFile( file, ScmFileStatus.UPDATED ) );
 75  
         }
 76  0
         else if ( status.equals( "P " ) )
 77  
         {
 78  0
             files.add( new ScmFile( file, ScmFileStatus.PATCHED ) );
 79  
         }
 80  0
         else if ( status.equals( "A " ) )
 81  
         {
 82  0
             files.add( new ScmFile( file, ScmFileStatus.ADDED ) );
 83  
         }
 84  0
         else if ( status.equals( "C " ) )
 85  
         {
 86  0
             files.add( new ScmFile( file, ScmFileStatus.CONFLICT ) );
 87  
         }
 88  0
         else if ( status.equals( "M " ) )
 89  
         {
 90  0
             files.add( new ScmFile( file, ScmFileStatus.MODIFIED ) );
 91  
         }
 92  0
         else if ( status.equals( "? " ) )
 93  
         {
 94  0
             files.add( new ScmFile( file, ScmFileStatus.UNKNOWN ) );
 95  
         }
 96  
         else
 97  
         {
 98  0
             if ( logger.isDebugEnabled() )
 99  
             {
 100  0
                 logger.warn( "Unknown status: '" + status + "' for file '" + file + "'." );
 101  
             }
 102  
         }
 103  0
     }
 104  
 
 105  
     public List<ScmFile> getUpdatedFiles()
 106  
     {
 107  0
         return files;
 108  
     }
 109  
 }