View Javadoc
1   package org.apache.maven.scm.provider.accurev.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  import java.io.File;
22  import java.util.List;
23  
24  import org.apache.maven.scm.CommandParameter;
25  import org.apache.maven.scm.CommandParameters;
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.RemoveScmResult;
32  import org.apache.maven.scm.log.ScmLogger;
33  import org.apache.maven.scm.provider.ScmProviderRepository;
34  import org.apache.maven.scm.provider.accurev.AccuRev;
35  import org.apache.maven.scm.provider.accurev.AccuRevException;
36  import org.apache.maven.scm.provider.accurev.AccuRevScmProviderRepository;
37  import org.apache.maven.scm.provider.accurev.command.AbstractAccuRevCommand;
38  
39  public class AccuRevRemoveCommand
40      extends AbstractAccuRevCommand
41  {
42  
43      public AccuRevRemoveCommand( ScmLogger logger )
44      {
45          super( logger );
46      }
47  
48      @Override
49      protected ScmResult executeAccurevCommand( AccuRevScmProviderRepository repository, ScmFileSet fileSet,
50                                                 CommandParameters parameters )
51          throws ScmException, AccuRevException
52      {
53  
54          AccuRev accuRev = repository.getAccuRev();
55  
56          String message = parameters.getString( CommandParameter.MESSAGE, "" );
57  
58          File basedir = fileSet.getBasedir();
59  
60          List<File> relativeFiles = fileSet.getFileList();
61  
62          final List<File> removedFiles = accuRev.defunct( basedir, relativeFiles, message );
63  
64          if ( removedFiles != null )
65          {
66              List<ScmFile> resultFiles = getScmFiles( removedFiles, ScmFileStatus.DELETED );
67              return new RemoveScmResult( accuRev.getCommandLines(), resultFiles );
68          }
69          else
70          {
71              return new RemoveScmResult( accuRev.getCommandLines(), "AccuRev Error", accuRev.getErrorOutput(), false );
72          }
73      }
74  
75      public RemoveScmResult remove( ScmProviderRepository repository, ScmFileSet fileSet, CommandParameters parameters )
76          throws ScmException
77      {
78          return (RemoveScmResult) execute( repository, fileSet, parameters );
79      }
80  
81  }