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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57 public class JazzUpdateCommand
58 extends AbstractUpdateCommand
59 {
60
61
62
63 protected UpdateScmResult executeUpdateCommand( ScmProviderRepository repo, ScmFileSet fileSet, ScmVersion version )
64 throws ScmException
65 {
66 if ( getLogger().isDebugEnabled() )
67 {
68 getLogger().debug( "Executing update command..." );
69 }
70
71 JazzUpdateConsumer updateConsumer = new JazzUpdateConsumer( repo, getLogger() );
72 ErrorConsumer err = new ErrorConsumer( getLogger() );
73
74 JazzScmCommand updateCmd = createAcceptCommand( repo, fileSet );
75 int status = updateCmd.execute( updateConsumer, err );
76
77 if ( status != 0 || err.hasBeenFed() )
78 {
79 return new UpdateScmResult( updateCmd.getCommandString(),
80 "Error code for Jazz SCM update command - " + status, err.getOutput(), false );
81 }
82
83 if ( getLogger().isDebugEnabled() )
84 {
85 if ( !updateConsumer.getUpdatedFiles().isEmpty() )
86 {
87 getLogger().debug( "Iterating over \"Update\" results" );
88 for ( ScmFile file : updateConsumer.getUpdatedFiles() )
89 {
90 getLogger().debug( file.getPath() + " : " + file.getStatus() );
91 }
92 }
93 else
94 {
95 getLogger().debug( "There are no updated files" );
96 }
97 }
98
99
100
101 return new UpdateScmResult( updateCmd.getCommandString(), updateConsumer.getUpdatedFiles() );
102 }
103
104 public JazzScmCommand createAcceptCommand( ScmProviderRepository repo, ScmFileSet fileSet )
105 {
106 JazzScmCommand command = new JazzScmCommand( JazzConstants.CMD_ACCEPT, repo, fileSet, getLogger() );
107
108 command.addArgument( JazzConstants.ARG_FLOW_COMPONENTS );
109
110 return command;
111 }
112
113
114
115
116 protected ChangeLogCommand getChangeLogCommand()
117 {
118 JazzChangeLogCommand command = new JazzChangeLogCommand();
119
120 command.setLogger( getLogger() );
121
122 return command;
123 }
124
125 }