Coverage Report - org.apache.maven.scm.provider.jazz.command.status.JazzStatusCommand
 
Classes in this File Line Coverage Branch Coverage Complexity
JazzStatusCommand
18 %
4/22
0 %
0/12
4,5
 
 1  
 package org.apache.maven.scm.provider.jazz.command.status;
 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.ScmException;
 23  
 import org.apache.maven.scm.ScmFile;
 24  
 import org.apache.maven.scm.ScmFileSet;
 25  
 import org.apache.maven.scm.command.status.AbstractStatusCommand;
 26  
 import org.apache.maven.scm.command.status.StatusScmResult;
 27  
 import org.apache.maven.scm.provider.ScmProviderRepository;
 28  
 import org.apache.maven.scm.provider.jazz.command.JazzConstants;
 29  
 import org.apache.maven.scm.provider.jazz.command.JazzScmCommand;
 30  
 import org.apache.maven.scm.provider.jazz.command.consumer.ErrorConsumer;
 31  
 
 32  
 import java.util.Iterator;
 33  
 
 34  
 //
 35  
 // See the following links for additional information on the RTC "status" command:
 36  
 // RTC 2.0.0.2:
 37  
 // http://publib.boulder.ibm.com/infocenter/rtc/v2r0m0/topic/com.ibm.team.scm.doc/topics/r_scm_cli_status.html
 38  
 // RTC 3.0:
 39  
 // http://publib.boulder.ibm.com/infocenter/clmhelp/v3r0/topic/com.ibm.team.scm.doc/topics/r_scm_cli_status.html
 40  
 // RTC 3.0.1:
 41  
 // http://publib.boulder.ibm.com/infocenter/clmhelp/v3r0m1/topic/com.ibm.team.scm.doc/topics/r_scm_cli_status.html
 42  
 //
 43  
 
 44  
 /**
 45  
  * @author <a href="mailto:ChrisGWarp@gmail.com">Chris Graham</a>
 46  
  */
 47  1
 public class JazzStatusCommand
 48  
     extends AbstractStatusCommand
 49  
 {
 50  
     /**
 51  
      * {@inheritDoc}
 52  
      */
 53  
     public StatusScmResult executeStatusCommand( ScmProviderRepository repo, ScmFileSet fileSet )
 54  
         throws ScmException
 55  
     {
 56  0
         if ( getLogger().isDebugEnabled() )
 57  
         {
 58  0
             getLogger().debug( "Executing status command..." );
 59  
         }
 60  
 
 61  0
         JazzStatusConsumer statusConsumer = new JazzStatusConsumer( repo, getLogger() );
 62  0
         ErrorConsumer errConsumer = new ErrorConsumer( getLogger() );
 63  
 
 64  0
         JazzScmCommand statusCmd = createStatusCommand( repo, fileSet );
 65  0
         int status = statusCmd.execute( statusConsumer, errConsumer );
 66  0
         if ( status != 0 || errConsumer.hasBeenFed() )
 67  
         {
 68  0
             return new StatusScmResult( statusCmd.getCommandString(),
 69  
                                         "Error code for Jazz SCM status command - " + status, errConsumer.getOutput(),
 70  
                                         false );
 71  
         }
 72  
 
 73  0
         if ( getLogger().isDebugEnabled() )
 74  
         {
 75  0
             Iterator<ScmFile> iter = statusConsumer.getChangedFiles().iterator();
 76  0
             if ( iter.hasNext() )
 77  
             {
 78  0
                 getLogger().debug( "Iterating over \"Status\" results" );
 79  0
                 while ( iter.hasNext() )
 80  
                 {
 81  0
                     ScmFile file = (ScmFile) iter.next();
 82  0
                     getLogger().debug( file.getPath() + " : " + file.getStatus() );
 83  0
                 }
 84  
             }
 85  
             else
 86  
             {
 87  0
                 getLogger().debug( "There are no differences" );
 88  
             }
 89  
         }
 90  
 
 91  0
         return new StatusScmResult( statusCmd.getCommandString(), statusConsumer.getChangedFiles() );
 92  
     }
 93  
 
 94  
     public JazzScmCommand createStatusCommand( ScmProviderRepository repo, ScmFileSet fileSet )
 95  
     {
 96  1
         JazzScmCommand command =
 97  
             new JazzScmCommand( JazzConstants.CMD_STATUS, null, repo, false, fileSet, getLogger() );
 98  
 
 99  1
         command.addArgument( JazzConstants.ARG_STATUS_WIDE_PRINT_OUT );
 100  1
         return command;
 101  
     }
 102  
 }