1 package org.apache.maven.scm.provider.jazz.command.unedit;
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.unedit.AbstractUnEditCommand;
29 import org.apache.maven.scm.command.unedit.UnEditScmResult;
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 JazzUnEditCommand
62 extends AbstractUnEditCommand
63 {
64
65
66
67 protected ScmResult executeUnEditCommand( ScmProviderRepository repo, ScmFileSet fileSet )
68 throws ScmException
69 {
70 if ( getLogger().isDebugEnabled() )
71 {
72 getLogger().debug( "Executing unedit command..." );
73 }
74
75 DebugLoggerConsumer uneditConsumer = new DebugLoggerConsumer( getLogger() );
76 ErrorConsumer errConsumer = new ErrorConsumer( getLogger() );
77
78 JazzScmCommand uneditCmd = createUneditCommand( repo, fileSet );
79 int status = uneditCmd.execute( uneditConsumer, errConsumer );
80
81 if ( status != 0 || errConsumer.hasBeenFed() )
82 {
83 return new UnEditScmResult( uneditCmd.getCommandString(),
84 "Error code for Jazz SCM unedit command - " + status, errConsumer.getOutput(),
85 false );
86 }
87
88 return new UnEditScmResult( uneditCmd.getCommandString(), "Successfully Completed.", uneditConsumer.getOutput(),
89 true );
90 }
91
92 public JazzScmCommand createUneditCommand( ScmProviderRepository repo, ScmFileSet fileSet )
93 {
94 JazzScmCommand command =
95 new JazzScmCommand( JazzConstants.CMD_LOCK, JazzConstants.CMD_SUB_RELEASE, repo, fileSet, getLogger() );
96
97 List<File> files = fileSet.getFileList();
98 if ( files != null && !files.isEmpty() )
99 {
100 for ( File file : files )
101 {
102 command.addArgument( file.getPath() );
103 }
104 }
105 else
106 {
107 command.addArgument( "." );
108 }
109
110 return command;
111 }
112 }