1 | |
package org.apache.maven.scm.provider.jazz.command.update; |
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
|
17 | |
|
18 | |
|
19 | |
|
20 | |
|
21 | |
|
22 | |
import org.apache.maven.scm.ScmException; |
23 | |
import org.apache.maven.scm.ScmFile; |
24 | |
import org.apache.maven.scm.ScmFileSet; |
25 | |
import org.apache.maven.scm.ScmVersion; |
26 | |
import org.apache.maven.scm.command.changelog.ChangeLogCommand; |
27 | |
import org.apache.maven.scm.command.update.AbstractUpdateCommand; |
28 | |
import org.apache.maven.scm.command.update.UpdateScmResult; |
29 | |
import org.apache.maven.scm.provider.ScmProviderRepository; |
30 | |
import org.apache.maven.scm.provider.jazz.command.JazzConstants; |
31 | |
import org.apache.maven.scm.provider.jazz.command.JazzScmCommand; |
32 | |
import org.apache.maven.scm.provider.jazz.command.changelog.JazzChangeLogCommand; |
33 | |
import org.apache.maven.scm.provider.jazz.command.consumer.ErrorConsumer; |
34 | |
|
35 | |
import java.util.Iterator; |
36 | |
|
37 | |
|
38 | |
|
39 | |
|
40 | |
|
41 | |
|
42 | |
|
43 | |
|
44 | |
|
45 | |
|
46 | |
|
47 | |
|
48 | |
|
49 | |
|
50 | |
|
51 | |
|
52 | |
|
53 | |
|
54 | |
|
55 | |
|
56 | |
|
57 | |
|
58 | |
|
59 | 1 | public class JazzUpdateCommand |
60 | |
extends AbstractUpdateCommand |
61 | |
{ |
62 | |
|
63 | |
|
64 | |
|
65 | |
protected UpdateScmResult executeUpdateCommand( ScmProviderRepository repo, ScmFileSet fileSet, ScmVersion version ) |
66 | |
throws ScmException |
67 | |
{ |
68 | 0 | if ( getLogger().isDebugEnabled() ) |
69 | |
{ |
70 | 0 | getLogger().debug( "Executing update command..." ); |
71 | |
} |
72 | |
|
73 | 0 | JazzUpdateConsumer updateConsumer = new JazzUpdateConsumer( repo, getLogger() ); |
74 | 0 | ErrorConsumer err = new ErrorConsumer( getLogger() ); |
75 | |
|
76 | 0 | JazzScmCommand updateCmd = createAcceptCommand( repo, fileSet ); |
77 | 0 | int status = updateCmd.execute( updateConsumer, err ); |
78 | |
|
79 | 0 | if ( status != 0 || err.hasBeenFed() ) |
80 | |
{ |
81 | 0 | return new UpdateScmResult( updateCmd.getCommandString(), |
82 | |
"Error code for Jazz SCM update command - " + status, err.getOutput(), false ); |
83 | |
} |
84 | |
|
85 | 0 | if ( getLogger().isDebugEnabled() ) |
86 | |
{ |
87 | 0 | Iterator<ScmFile> iter = updateConsumer.getUpdatedFiles().iterator(); |
88 | 0 | if ( iter.hasNext() ) |
89 | |
{ |
90 | 0 | getLogger().debug( "Iterating over \"Update\" results" ); |
91 | 0 | while ( iter.hasNext() ) |
92 | |
{ |
93 | 0 | ScmFile file = (ScmFile) iter.next(); |
94 | 0 | getLogger().debug( file.getPath() + " : " + file.getStatus() ); |
95 | 0 | } |
96 | |
} |
97 | |
else |
98 | |
{ |
99 | 0 | getLogger().debug( "There are no updated files" ); |
100 | |
} |
101 | |
} |
102 | |
|
103 | |
|
104 | |
|
105 | 0 | return new UpdateScmResult( updateCmd.getCommandString(), updateConsumer.getUpdatedFiles() ); |
106 | |
} |
107 | |
|
108 | |
public JazzScmCommand createAcceptCommand( ScmProviderRepository repo, ScmFileSet fileSet ) |
109 | |
{ |
110 | 1 | JazzScmCommand command = new JazzScmCommand( JazzConstants.CMD_ACCEPT, repo, fileSet, getLogger() ); |
111 | |
|
112 | 1 | command.addArgument( JazzConstants.ARG_FLOW_COMPONENTS ); |
113 | |
|
114 | 1 | return command; |
115 | |
} |
116 | |
|
117 | |
|
118 | |
|
119 | |
|
120 | |
protected ChangeLogCommand getChangeLogCommand() |
121 | |
{ |
122 | 0 | JazzChangeLogCommand command = new JazzChangeLogCommand(); |
123 | |
|
124 | 0 | command.setLogger( getLogger() ); |
125 | |
|
126 | 0 | return command; |
127 | |
} |
128 | |
|
129 | |
} |