View Javadoc

1   package org.apache.maven.scm.provider.jazz.command.list;
2   
3   /*
4    * Licensed to the Apache Software Foundation (ASF) under one
5    * or more contributor license agreements.  See the NOTICE file
6    * distributed with this work for additional information
7    * regarding copyright ownership.  The ASF licenses this file
8    * to you under the Apache License, Version 2.0 (the
9    * "License"); you may not use this file except in compliance
10   * with the License.  You may obtain a copy of the License at
11   *
12   * http://www.apache.org/licenses/LICENSE-2.0
13   *
14   * Unless required by applicable law or agreed to in writing,
15   * software distributed under the License is distributed on an
16   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17   * KIND, either express or implied.  See the License for the
18   * specific language governing permissions and limitations
19   * under the License.
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  // See the following links for additional information on the RTC "list" command:
35  // RTC 2.0.0.2:
36  // http://publib.boulder.ibm.com/infocenter/rtc/v2r0m0/topic/com.ibm.team.scm.doc/topics/r_scm_cli_list.html
37  // RTC 3.0
38  // http://publib.boulder.ibm.com/infocenter/clmhelp/v3r0/topic/com.ibm.team.scm.doc/topics/r_scm_cli_list.html
39  // RTC 3.0.1:
40  // http://publib.boulder.ibm.com/infocenter/clmhelp/v3r0m1/topic/com.ibm.team.scm.doc/topics/r_scm_cli_list.html
41  //
42  
43  /**
44   * @author <a href="mailto:ChrisGWarp@gmail.com">Chris Graham</a>
45   */
46  public class JazzListCommand
47      extends AbstractListCommand
48  {
49      /**
50       * {@inheritDoc}
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 || errConsumer.hasBeenFed() )
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          // recursive is implicit in the command, so it is ignored.
81          // version is meaningless, so it is ignored.
82          JazzScmCommand command =
83              new JazzScmCommand( JazzConstants.CMD_LIST, JazzConstants.CMD_SUB_REMOTEFILES, repo, fileSet, getLogger() );
84          command.addArgument( repo.getRepositoryWorkspace() );
85          command.addArgument( repo.getComponent() );
86          return command;
87      }
88  
89  }