001package org.apache.maven.scm.provider.synergy.command.checkin; 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 java.io.File; 023import java.util.ArrayList; 024import java.util.List; 025 026import org.apache.maven.scm.ScmException; 027import org.apache.maven.scm.ScmFile; 028import org.apache.maven.scm.ScmFileSet; 029import org.apache.maven.scm.ScmFileStatus; 030import org.apache.maven.scm.ScmVersion; 031import org.apache.maven.scm.command.checkin.AbstractCheckInCommand; 032import org.apache.maven.scm.command.checkin.CheckInScmResult; 033import org.apache.maven.scm.provider.ScmProviderRepository; 034import org.apache.maven.scm.provider.synergy.command.SynergyCommand; 035import org.apache.maven.scm.provider.synergy.repository.SynergyScmProviderRepository; 036import org.apache.maven.scm.provider.synergy.util.SynergyTaskManager; 037import org.apache.maven.scm.provider.synergy.util.SynergyUtil; 038 039/** 040 * @author <a href="mailto:julien.henry@capgemini.com">Julien Henry</a> 041 * @author Olivier Lamy 042 * 043 */ 044public class SynergyCheckInCommand 045 extends AbstractCheckInCommand 046 implements SynergyCommand 047{ 048 049 /** {@inheritDoc} */ 050 protected CheckInScmResult executeCheckInCommand( ScmProviderRepository repository, ScmFileSet fileSet, 051 String message, ScmVersion version ) 052 throws ScmException 053 { 054 if ( getLogger().isDebugEnabled() ) 055 { 056 getLogger().debug( "executing checkin command..." ); 057 } 058 059 SynergyScmProviderRepository repo = (SynergyScmProviderRepository) repository; 060 061 if ( getLogger().isDebugEnabled() ) 062 { 063 getLogger().debug( fileSet.toString() ); 064 } 065 066 String ccmAddr = SynergyUtil.start( getLogger(), repo.getUser(), repo.getPassword(), null ); 067 068 try 069 { 070 SynergyTaskManager.getInstance().checkinDefaultTask( getLogger(), message, ccmAddr ); 071 } 072 finally 073 { 074 SynergyUtil.stop( getLogger(), ccmAddr ); 075 } 076 List<ScmFile> scmFiles = new ArrayList<ScmFile>( fileSet.getFileList().size() ); 077 for ( File f : fileSet.getFileList() ) 078 { 079 scmFiles.add( new ScmFile( f.getPath(), ScmFileStatus.CHECKED_IN ) ); 080 } 081 return new CheckInScmResult( "ccm checkin", scmFiles ); 082 } 083 084}