1 package org.apache.maven.scm.provider.jazz.command.list;
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.ScmFileSet;
24 import org.apache.maven.scm.ScmVersion;
25 import org.apache.maven.scm.command.list.AbstractListCommand;
26 import org.apache.maven.scm.command.list.ListScmResult;
27 import org.apache.maven.scm.provider.ScmProviderRepository;
28 import org.apache.maven.scm.provider.jazz.command.JazzConstants;
29 import org.apache.maven.scm.provider.jazz.command.JazzScmCommand;
30 import org.apache.maven.scm.provider.jazz.command.consumer.ErrorConsumer;
31 import org.apache.maven.scm.provider.jazz.repository.JazzScmProviderRepository;
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46 public class JazzListCommand
47 extends AbstractListCommand
48 {
49
50
51
52 protected ListScmResult executeListCommand( ScmProviderRepository repo, ScmFileSet fileSet, boolean recursive,
53 ScmVersion version )
54 throws ScmException
55 {
56 if ( getLogger().isDebugEnabled() )
57 {
58 getLogger().debug( "Executing list command..." );
59 }
60
61 JazzScmProviderRepository jazzRepo = (JazzScmProviderRepository) repo;
62
63 JazzListConsumer listConsumer = new JazzListConsumer( repo, getLogger() );
64 ErrorConsumer errConsumer = new ErrorConsumer( getLogger() );
65
66 JazzScmCommand listCmd = createListCommand( jazzRepo, fileSet, recursive, version );
67 int status = listCmd.execute( listConsumer, errConsumer );
68 if ( status != 0 )
69 {
70 return new ListScmResult( listCmd.getCommandString(), "Error code for Jazz SCM list command - " + status,
71 errConsumer.getOutput(), false );
72 }
73
74 return new ListScmResult( listCmd.getCommandString(), listConsumer.getFiles() );
75 }
76
77 public JazzScmCommand createListCommand( JazzScmProviderRepository repo, ScmFileSet fileSet, boolean recursive,
78 ScmVersion version )
79 {
80
81
82 JazzScmCommand command =
83 new JazzScmCommand( JazzConstants.CMD_LIST, JazzConstants.CMD_SUB_REMOTEFILES, repo, fileSet, getLogger() );
84 if ( recursive )
85 {
86 command.addArgument( JazzConstants.ARG_DEPTH );
87 command.addArgument( JazzConstants.ARG_DEPTH_INFINTE );
88 }
89 command.addArgument( repo.getRepositoryWorkspace() );
90 command.addArgument( repo.getComponent() );
91 return command;
92 }
93
94 }