1 package org.apache.maven.scm.provider.cvslib.command.mkdir;
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.CommandParameter;
27 import org.apache.maven.scm.CommandParameters;
28 import org.apache.maven.scm.ScmException;
29 import org.apache.maven.scm.ScmFile;
30 import org.apache.maven.scm.ScmFileSet;
31 import org.apache.maven.scm.ScmFileStatus;
32 import org.apache.maven.scm.ScmResult;
33 import org.apache.maven.scm.command.Command;
34 import org.apache.maven.scm.command.mkdir.AbstractMkdirCommand;
35 import org.apache.maven.scm.command.mkdir.MkdirScmResult;
36 import org.apache.maven.scm.provider.ScmProviderRepository;
37
38
39
40
41
42 public abstract class AbstractCvsMkdirCommand
43 extends AbstractMkdirCommand
44 {
45
46 protected MkdirScmResult executeMkdirCommand( ScmProviderRepository repository, ScmFileSet fileSet, String message,
47 boolean createInLocal )
48 throws ScmException
49 {
50 CommandParameters parameters = new CommandParameters();
51
52 parameters.setString( CommandParameter.MESSAGE, message == null ? "" : message );
53
54 parameters.setString( CommandParameter.BINARY, "false" );
55
56
57 Command cmd = getAddCommand();
58 cmd.setLogger( getLogger() );
59
60 ScmResult addResult = cmd.execute( repository, fileSet, parameters );
61
62 if ( !addResult.isSuccess() )
63 {
64 return new MkdirScmResult( addResult.getCommandLine().toString(), "The cvs command failed.",
65 addResult.getCommandOutput(), false );
66 }
67
68 List<ScmFile> addedFiles = new ArrayList<ScmFile>();
69
70 for ( File file : fileSet.getFileList() )
71 {
72 ScmFile scmFile = new ScmFile( file.getPath(), ScmFileStatus.ADDED );
73 addedFiles.add( scmFile );
74 }
75
76 return new MkdirScmResult( addResult.getCommandLine().toString(), addedFiles );
77 }
78
79 protected abstract Command getAddCommand();
80 }