001package org.apache.maven.scm.provider.jazz.command.list; 002 003/* 004 * Licensed to the Apache Software Foundation (ASF) under one 005 * or more contributor license agreements. See the NOTICE file 006 * distributed with this work for additional information 007 * regarding copyright ownership. The ASF licenses this file 008 * to you under the Apache License, Version 2.0 (the 009 * "License"); you may not use this file except in compliance 010 * with the License. You may obtain a copy of the License at 011 * 012 * http://www.apache.org/licenses/LICENSE-2.0 013 * 014 * Unless required by applicable law or agreed to in writing, 015 * software distributed under the License is distributed on an 016 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 017 * KIND, either express or implied. See the License for the 018 * specific language governing permissions and limitations 019 * under the License. 020 */ 021 022import org.apache.maven.scm.ScmException; 023import org.apache.maven.scm.ScmFileSet; 024import org.apache.maven.scm.ScmVersion; 025import org.apache.maven.scm.command.list.AbstractListCommand; 026import org.apache.maven.scm.command.list.ListScmResult; 027import org.apache.maven.scm.provider.ScmProviderRepository; 028import org.apache.maven.scm.provider.jazz.command.JazzConstants; 029import org.apache.maven.scm.provider.jazz.command.JazzScmCommand; 030import org.apache.maven.scm.provider.jazz.command.consumer.ErrorConsumer; 031import org.apache.maven.scm.provider.jazz.repository.JazzScmProviderRepository; 032 033// 034// See the following links for additional information on the RTC "list" command: 035// RTC 2.0.0.2: 036// http://publib.boulder.ibm.com/infocenter/rtc/v2r0m0/topic/com.ibm.team.scm.doc/topics/r_scm_cli_list.html 037// RTC 3.0 038// http://publib.boulder.ibm.com/infocenter/clmhelp/v3r0/topic/com.ibm.team.scm.doc/topics/r_scm_cli_list.html 039// RTC 3.0.1: 040// http://publib.boulder.ibm.com/infocenter/clmhelp/v3r0m1/topic/com.ibm.team.scm.doc/topics/r_scm_cli_list.html 041// 042 043/** 044 * @author <a href="mailto:ChrisGWarp@gmail.com">Chris Graham</a> 045 */ 046public class JazzListCommand 047 extends AbstractListCommand 048{ 049 /** 050 * {@inheritDoc} 051 */ 052 protected ListScmResult executeListCommand( ScmProviderRepository repo, ScmFileSet fileSet, boolean recursive, 053 ScmVersion version ) 054 throws ScmException 055 { 056 if ( getLogger().isDebugEnabled() ) 057 { 058 getLogger().debug( "Executing list command..." ); 059 } 060 061 JazzScmProviderRepository jazzRepo = (JazzScmProviderRepository) repo; 062 063 JazzListConsumer listConsumer = new JazzListConsumer( repo, getLogger() ); 064 ErrorConsumer errConsumer = new ErrorConsumer( getLogger() ); 065 066 JazzScmCommand listCmd = createListCommand( jazzRepo, fileSet, recursive, version ); 067 int status = listCmd.execute( listConsumer, errConsumer ); 068 if ( status != 0 ) 069 { 070 return new ListScmResult( listCmd.getCommandString(), "Error code for Jazz SCM list command - " + status, 071 errConsumer.getOutput(), false ); 072 } 073 074 return new ListScmResult( listCmd.getCommandString(), listConsumer.getFiles() ); 075 } 076 077 public JazzScmCommand createListCommand( JazzScmProviderRepository repo, ScmFileSet fileSet, boolean recursive, 078 ScmVersion version ) 079 { 080 // recursive is implicit in the command, so it is ignored. NOTE: V4 appears to have changed this. 081 // version is meaningless, so it is ignored. 082 JazzScmCommand command = 083 new JazzScmCommand( JazzConstants.CMD_LIST, JazzConstants.CMD_SUB_REMOTEFILES, repo, fileSet, getLogger() ); 084 if ( recursive ) 085 { 086 command.addArgument( JazzConstants.ARG_DEPTH ); 087 command.addArgument( JazzConstants.ARG_DEPTH_INFINTE ); 088 } 089 command.addArgument( repo.getRepositoryWorkspace() ); 090 command.addArgument( repo.getComponent() ); 091 return command; 092 } 093 094}