View Javadoc
1   package org.apache.maven.scm.provider.synergy.command.checkin;
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 java.io.File;
23  import java.util.ArrayList;
24  import java.util.List;
25  
26  import org.apache.maven.scm.ScmException;
27  import org.apache.maven.scm.ScmFile;
28  import org.apache.maven.scm.ScmFileSet;
29  import org.apache.maven.scm.ScmFileStatus;
30  import org.apache.maven.scm.ScmVersion;
31  import org.apache.maven.scm.command.checkin.AbstractCheckInCommand;
32  import org.apache.maven.scm.command.checkin.CheckInScmResult;
33  import org.apache.maven.scm.provider.ScmProviderRepository;
34  import org.apache.maven.scm.provider.synergy.command.SynergyCommand;
35  import org.apache.maven.scm.provider.synergy.repository.SynergyScmProviderRepository;
36  import org.apache.maven.scm.provider.synergy.util.SynergyTaskManager;
37  import org.apache.maven.scm.provider.synergy.util.SynergyUtil;
38  
39  /**
40   * @author <a href="mailto:julien.henry@capgemini.com">Julien Henry</a>
41   * @author Olivier Lamy
42   *
43   */
44  public class SynergyCheckInCommand
45      extends AbstractCheckInCommand
46      implements SynergyCommand
47  {
48  
49      /** {@inheritDoc} */
50      protected CheckInScmResult executeCheckInCommand( ScmProviderRepository repository, ScmFileSet fileSet,
51                                                        String message, ScmVersion version )
52          throws ScmException
53      {
54          if ( getLogger().isDebugEnabled() )
55          {
56              getLogger().debug( "executing checkin command..." );
57          }
58  
59          SynergyScmProviderRepository repo = (SynergyScmProviderRepository) repository;
60  
61          if ( getLogger().isDebugEnabled() )
62          {
63              getLogger().debug( fileSet.toString() );
64          }
65  
66          String ccmAddr = SynergyUtil.start( getLogger(), repo.getUser(), repo.getPassword(), null );
67  
68          try
69          {
70              SynergyTaskManager.getInstance().checkinDefaultTask( getLogger(), message, ccmAddr );
71          }
72          finally
73          {
74              SynergyUtil.stop( getLogger(), ccmAddr );
75          }
76          List<ScmFile> scmFiles = new ArrayList<ScmFile>( fileSet.getFileList().size() );
77          for ( File f : fileSet.getFileList() )
78          {
79              scmFiles.add( new ScmFile( f.getPath(), ScmFileStatus.CHECKED_IN ) );
80          }
81          return new CheckInScmResult( "ccm checkin", scmFiles );
82      }
83  
84  }