1 package org.apache.maven.scm.provider.accurev.command;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 import java.io.File;
23 import java.util.ArrayList;
24 import java.util.List;
25
26 import org.apache.maven.scm.CommandParameters;
27 import org.apache.maven.scm.ScmException;
28 import org.apache.maven.scm.ScmFile;
29 import org.apache.maven.scm.ScmFileSet;
30 import org.apache.maven.scm.ScmFileStatus;
31 import org.apache.maven.scm.ScmResult;
32 import org.apache.maven.scm.command.AbstractCommand;
33 import org.apache.maven.scm.log.ScmLogger;
34 import org.apache.maven.scm.provider.ScmProviderRepository;
35 import org.apache.maven.scm.provider.accurev.AccuRevException;
36 import org.apache.maven.scm.provider.accurev.AccuRevScmProviderRepository;
37
38
39
40
41 public abstract class AbstractAccuRevCommand
42 extends AbstractCommand
43 {
44
45 public AbstractAccuRevCommand( ScmLogger logger )
46 {
47 super();
48 setLogger( logger );
49 }
50
51 protected abstract ScmResult executeAccurevCommand( AccuRevScmProviderRepository repository, ScmFileSet fileSet,
52 CommandParameters parameters )
53 throws ScmException, AccuRevException;
54
55 protected final ScmResult executeCommand( ScmProviderRepository repository, ScmFileSet fileSet,
56 CommandParameters parameters )
57 throws ScmException
58 {
59
60 if ( !( repository instanceof AccuRevScmProviderRepository ) )
61 {
62 throw new ScmException( "Not an AccuRev repository " + repository );
63 }
64
65 AccuRevScmProviderRepository accuRevRepository = (AccuRevScmProviderRepository) repository;
66 accuRevRepository.getAccuRev().reset();
67 try
68 {
69 return executeAccurevCommand( accuRevRepository, fileSet, parameters );
70 }
71 catch ( AccuRevException e )
72 {
73 throw new ScmException( "Error invoking AccuRev command", e );
74 }
75 }
76
77 protected static List<ScmFile> getScmFiles( final List<File> files, ScmFileStatus status )
78 {
79 ArrayList<ScmFile> resultFiles = new ArrayList<ScmFile>( files.size() );
80 for ( File addedFile : files )
81 {
82
83 resultFiles.add( new ScmFile( addedFile.getPath(), status ) );
84 }
85 return resultFiles;
86 }
87
88 }