Coverage Report - org.apache.maven.scm.provider.synergy.command.remove.SynergyRemoveCommand
 
Classes in this File Line Coverage Branch Coverage Complexity
SynergyRemoveCommand
0 %
0/27
0 %
0/14
9
 
 1  
 package org.apache.maven.scm.provider.synergy.command.remove;
 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.util.ArrayList;
 24  
 import java.util.List;
 25  
 
 26  
 import org.apache.maven.scm.ScmException;
 27  
 import org.apache.maven.scm.ScmFile;
 28  
 import org.apache.maven.scm.ScmFileSet;
 29  
 import org.apache.maven.scm.ScmFileStatus;
 30  
 import org.apache.maven.scm.ScmResult;
 31  
 import org.apache.maven.scm.command.remove.AbstractRemoveCommand;
 32  
 import org.apache.maven.scm.command.status.StatusScmResult;
 33  
 import org.apache.maven.scm.provider.ScmProviderRepository;
 34  
 import org.apache.maven.scm.provider.synergy.command.SynergyCommand;
 35  
 import org.apache.maven.scm.provider.synergy.repository.SynergyScmProviderRepository;
 36  
 import org.apache.maven.scm.provider.synergy.util.SynergyUtil;
 37  
 
 38  
 /**
 39  
  * @author <a href="mailto:julien.henry@capgemini.com">Julien Henry</a>
 40  
  * @version $Id: SynergyRemoveCommand.java 1067549 2011-02-05 23:13:10Z olamy $
 41  
  */
 42  0
 public class SynergyRemoveCommand
 43  
     extends AbstractRemoveCommand
 44  
     implements SynergyCommand
 45  
 {
 46  
     /** {@inheritDoc} */
 47  
     protected ScmResult executeRemoveCommand( ScmProviderRepository repository, ScmFileSet fileSet, String message )
 48  
         throws ScmException
 49  
     {
 50  0
         if ( getLogger().isDebugEnabled() )
 51  
         {
 52  0
             getLogger().debug( "executing remove command..." );
 53  
         }
 54  
 
 55  0
         SynergyScmProviderRepository repo = (SynergyScmProviderRepository) repository;
 56  
 
 57  0
         if ( getLogger().isDebugEnabled() )
 58  
         {
 59  0
             getLogger().debug( "basedir: " + fileSet.getBasedir() );
 60  
         }
 61  
 
 62  0
         String ccmAddr = SynergyUtil.start( getLogger(), repo.getUser(), repo.getPassword(), null );
 63  
 
 64  
         try
 65  
         {
 66  0
             String projectSpec =
 67  
                 SynergyUtil.getWorkingProject( getLogger(), repo.getProjectSpec(), repo.getUser(), ccmAddr );
 68  0
             if ( projectSpec == null )
 69  
             {
 70  0
                 throw new ScmException( "You should checkout a working project first" );
 71  
             }
 72  0
             File waPath = SynergyUtil.getWorkArea( getLogger(), projectSpec, ccmAddr );
 73  0
             File destPath = new File( waPath, repo.getProjectName() );
 74  0
             for ( File f : fileSet.getFileList() )
 75  
             {
 76  0
                 File source = new File( fileSet.getBasedir(), f.getPath() );
 77  0
                 File dest = new File( destPath, f.getPath() );
 78  0
                 SynergyUtil.delete( getLogger(), dest, ccmAddr, false );
 79  0
                 if ( !source.equals( dest ) )
 80  
                 {
 81  0
                     if ( getLogger().isDebugEnabled() )
 82  
                     {
 83  0
                         getLogger().debug( "Delete file [" + source + "]." );
 84  
                     }
 85  0
                     dest.delete();
 86  
                 }
 87  0
             }
 88  
         }
 89  
         finally
 90  
         {
 91  0
             SynergyUtil.stop( getLogger(), ccmAddr );
 92  0
         }
 93  0
         List<ScmFile> scmFiles = new ArrayList<ScmFile>();
 94  0
         for (File file : fileSet.getFileList())
 95  
         {
 96  0
             scmFiles.add( new ScmFile( file.getPath(), ScmFileStatus.DELETED ) );
 97  
         }
 98  0
         return new StatusScmResult( "", scmFiles );
 99  
     }
 100  
 
 101  
 }