1 package org.apache.maven.scm.provider.jazz.command.edit;
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.ScmException;
26 import org.apache.maven.scm.ScmFileSet;
27 import org.apache.maven.scm.ScmResult;
28 import org.apache.maven.scm.command.edit.AbstractEditCommand;
29 import org.apache.maven.scm.command.edit.EditScmResult;
30 import org.apache.maven.scm.provider.ScmProviderRepository;
31 import org.apache.maven.scm.provider.jazz.command.JazzConstants;
32 import org.apache.maven.scm.provider.jazz.command.JazzScmCommand;
33 import org.apache.maven.scm.provider.jazz.command.consumer.DebugLoggerConsumer;
34 import org.apache.maven.scm.provider.jazz.command.consumer.ErrorConsumer;
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61 public class JazzEditCommand
62 extends AbstractEditCommand
63 {
64
65
66
67 protected ScmResult executeEditCommand( ScmProviderRepository repo, ScmFileSet fileSet )
68 throws ScmException
69 {
70 if ( getLogger().isDebugEnabled() )
71 {
72 getLogger().debug( "Executing edit command..." );
73 }
74
75 DebugLoggerConsumer editConsumer = new DebugLoggerConsumer( getLogger() );
76 ErrorConsumer errConsumer = new ErrorConsumer( getLogger() );
77
78 JazzScmCommand editCmd = createEditCommand( repo, fileSet );
79 int status = editCmd.execute( editConsumer, errConsumer );
80
81 if ( status != 0 || errConsumer.hasBeenFed() )
82 {
83 return new EditScmResult( editCmd.getCommandString(), "Error code for Jazz SCM edit command - " + status,
84 errConsumer.getOutput(), false );
85 }
86
87 return new EditScmResult( editCmd.getCommandString(), "Successfully Completed.", editConsumer.getOutput(),
88 true );
89 }
90
91 protected JazzScmCommand createEditCommand( ScmProviderRepository repo, ScmFileSet fileSet )
92 {
93 JazzScmCommand command =
94 new JazzScmCommand( JazzConstants.CMD_LOCK, JazzConstants.CMD_SUB_ACQUIRE, repo, fileSet, getLogger() );
95
96 List<File> files = fileSet.getFileList();
97 if ( files != null && !files.isEmpty() )
98 {
99 for ( File file : files )
100 {
101 command.addArgument( file.getPath() );
102 }
103 }
104 else
105 {
106 command.addArgument( "." );
107 }
108 return command;
109 }
110 }