001package org.apache.maven.scm.provider.synergy.command.status;
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.ScmFile;
024import org.apache.maven.scm.ScmFileSet;
025import org.apache.maven.scm.ScmFileStatus;
026import org.apache.maven.scm.command.status.AbstractStatusCommand;
027import org.apache.maven.scm.command.status.StatusScmResult;
028import org.apache.maven.scm.provider.ScmProviderRepository;
029import org.apache.maven.scm.provider.synergy.command.SynergyCommand;
030import org.apache.maven.scm.provider.synergy.repository.SynergyScmProviderRepository;
031import org.apache.maven.scm.provider.synergy.util.SynergyUtil;
032
033import java.util.LinkedList;
034import java.util.List;
035
036/**
037 * @author <a href="mailto:julien.henry@capgemini.com">Julien Henry</a>
038 *
039 */
040public class SynergyStatusCommand
041    extends AbstractStatusCommand
042    implements SynergyCommand
043{
044    /** {@inheritDoc} */
045    protected StatusScmResult executeStatusCommand( ScmProviderRepository repository, ScmFileSet fileSet )
046        throws ScmException
047    {
048        if ( getLogger().isDebugEnabled() )
049        {
050            getLogger().debug( "executing status command..." );
051        }
052
053        SynergyScmProviderRepository repo = (SynergyScmProviderRepository) repository;
054
055        if ( getLogger().isDebugEnabled() )
056        {
057            getLogger().debug( "basedir: " + fileSet.getBasedir() );
058        }
059
060        String ccmAddr = SynergyUtil.start( getLogger(), repo.getUser(), repo.getPassword(), null );
061
062        List<String> l;
063        try
064        {
065            l = SynergyUtil.getWorkingFiles( getLogger(), repo.getProjectSpec(), repo.getProjectRelease(), ccmAddr );
066        }
067        finally
068        {
069            SynergyUtil.stop( getLogger(), ccmAddr );
070        }
071
072        List<ScmFile> result = new LinkedList<ScmFile>();
073        for ( String filename : l )
074        {
075            ScmFile f = new ScmFile( filename, ScmFileStatus.MODIFIED );
076            result.add( f );
077        }
078
079        return new StatusScmResult( "ccm dir", result );
080    }
081
082}