1 | |
package org.apache.maven.scm.provider.jazz.command.checkout; |
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.ScmBranch; |
23 | |
import org.apache.maven.scm.ScmException; |
24 | |
import org.apache.maven.scm.ScmFileSet; |
25 | |
import org.apache.maven.scm.ScmTag; |
26 | |
import org.apache.maven.scm.ScmVersion; |
27 | |
import org.apache.maven.scm.command.checkout.AbstractCheckOutCommand; |
28 | |
import org.apache.maven.scm.command.checkout.CheckOutScmResult; |
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.consumer.ErrorConsumer; |
33 | |
import org.apache.maven.scm.provider.jazz.repository.JazzScmProviderRepository; |
34 | |
import org.codehaus.plexus.util.StringUtils; |
35 | |
|
36 | |
|
37 | |
|
38 | |
|
39 | |
|
40 | |
|
41 | |
|
42 | |
|
43 | |
|
44 | |
|
45 | |
|
46 | |
|
47 | |
|
48 | |
|
49 | |
|
50 | |
|
51 | 1 | public class JazzCheckOutCommand |
52 | |
extends AbstractCheckOutCommand |
53 | |
{ |
54 | |
|
55 | |
|
56 | |
|
57 | |
protected CheckOutScmResult executeCheckOutCommand( ScmProviderRepository repo, ScmFileSet fileSet, |
58 | |
ScmVersion scmVersion, boolean recursive ) |
59 | |
throws ScmException |
60 | |
{ |
61 | |
|
62 | |
|
63 | 0 | if ( getLogger().isDebugEnabled() ) |
64 | |
{ |
65 | 0 | getLogger().debug( "Executing checkout command..." ); |
66 | |
} |
67 | |
|
68 | 0 | JazzScmProviderRepository jazzRepo = (JazzScmProviderRepository) repo; |
69 | |
|
70 | 0 | JazzScmCommand checkoutCmd = createJazzLoadCommand( jazzRepo, fileSet, scmVersion ); |
71 | 0 | JazzCheckOutConsumer checkoutConsumer = new JazzCheckOutConsumer( repo, getLogger() ); |
72 | 0 | ErrorConsumer errConsumer = new ErrorConsumer( getLogger() ); |
73 | |
|
74 | 0 | int status = checkoutCmd.execute( checkoutConsumer, errConsumer ); |
75 | 0 | if ( status != 0 || errConsumer.hasBeenFed() ) |
76 | |
{ |
77 | 0 | return new CheckOutScmResult( checkoutCmd.getCommandString(), |
78 | |
"Error code for Jazz SCM checkout (load) command - " + status, |
79 | |
errConsumer.getOutput(), false ); |
80 | |
} |
81 | |
|
82 | 0 | return new CheckOutScmResult( checkoutCmd.getCommandString(), checkoutConsumer.getCheckedOutFiles() ); |
83 | |
} |
84 | |
|
85 | |
public JazzScmCommand createJazzLoadCommand( JazzScmProviderRepository repo, ScmFileSet fileSet, |
86 | |
ScmVersion scmVersion ) |
87 | |
{ |
88 | 1 | JazzScmCommand command = |
89 | |
new JazzScmCommand( JazzConstants.CMD_LOAD, JazzConstants.ARG_FORCE, repo, fileSet, getLogger() ); |
90 | |
|
91 | 1 | if ( fileSet != null ) |
92 | |
{ |
93 | 1 | command.addArgument( JazzConstants.ARG_LOCAL_WORKSPACE_PATH ); |
94 | 1 | command.addArgument( fileSet.getBasedir().getAbsolutePath() ); |
95 | |
} |
96 | |
|
97 | |
|
98 | |
|
99 | |
|
100 | |
|
101 | |
|
102 | |
|
103 | 1 | String workspace = repo.getRepositoryWorkspace(); |
104 | 1 | if ( scmVersion != null && StringUtils.isNotEmpty( scmVersion.getName() ) ) |
105 | |
{ |
106 | |
|
107 | 1 | if ( scmVersion instanceof ScmTag ) |
108 | |
{ |
109 | 0 | workspace = scmVersion.getName(); |
110 | |
} |
111 | 1 | else if ( scmVersion instanceof ScmBranch ) |
112 | |
{ |
113 | 0 | workspace = scmVersion.getName(); |
114 | |
} |
115 | |
} |
116 | |
|
117 | 1 | command.addArgument( workspace ); |
118 | |
|
119 | 1 | return command; |
120 | |
} |
121 | |
} |