1 package org.apache.maven.scm.provider.accurev.command.add;
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.List;
24
25 import org.apache.maven.scm.CommandParameter;
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.add.AddScmResult;
33 import org.apache.maven.scm.log.ScmLogger;
34 import org.apache.maven.scm.provider.ScmProviderRepository;
35 import org.apache.maven.scm.provider.accurev.AccuRev;
36 import org.apache.maven.scm.provider.accurev.AccuRevException;
37 import org.apache.maven.scm.provider.accurev.AccuRevScmProviderRepository;
38 import org.apache.maven.scm.provider.accurev.command.AbstractAccuRevCommand;
39
40
41
42
43 public class AccuRevAddCommand
44 extends AbstractAccuRevCommand
45 {
46
47 public AccuRevAddCommand( ScmLogger logger )
48 {
49 super( logger );
50 }
51
52
53
54
55
56
57 protected ScmResult executeAccurevCommand( AccuRevScmProviderRepository repository, ScmFileSet fileSet,
58 CommandParameters parameters )
59 throws ScmException, AccuRevException
60 {
61
62 AccuRev accuRev = repository.getAccuRev();
63
64 String message = parameters.getString( CommandParameter.MESSAGE, "" );
65
66 File basedir = fileSet.getBasedir();
67
68 List<File> relativeFiles = fileSet.getFileList();
69
70 List<File> addedFiles = accuRev.add( basedir, relativeFiles, message );
71
72 if ( addedFiles != null )
73 {
74 List<ScmFile> resultFiles = getScmFiles( addedFiles, ScmFileStatus.ADDED );
75 return new AddScmResult( accuRev.getCommandLines(), resultFiles );
76 }
77 else
78 {
79 return new AddScmResult( accuRev.getCommandLines(), "AccuRev Error", accuRev.getErrorOutput(), false );
80 }
81 }
82
83 public AddScmResult add( ScmProviderRepository repo, ScmFileSet scmFileSet, CommandParameters commandParameters )
84 throws ScmException
85 {
86 return (AddScmResult) execute( repo, scmFileSet, commandParameters );
87 }
88
89 }