001package org.apache.maven.scm.provider.integrity.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 org.apache.maven.scm.ScmException;
023import org.apache.maven.scm.ScmFile;
024import org.apache.maven.scm.ScmFileSet;
025import org.apache.maven.scm.ScmResult;
026import org.apache.maven.scm.ScmVersion;
027import org.apache.maven.scm.command.checkin.AbstractCheckInCommand;
028import org.apache.maven.scm.command.checkin.CheckInScmResult;
029import org.apache.maven.scm.provider.ScmProviderRepository;
030import org.apache.maven.scm.provider.integrity.Sandbox;
031import org.apache.maven.scm.provider.integrity.repository.IntegrityScmProviderRepository;
032
033import java.util.List;
034
035/**
036 * MKS Integrity implementation for Maven's AbstractCheckInCommand
037 * <br>The check-in command will also drop any files that are missing from the working directory
038 *
039 * @author <a href="mailto:cletus@mks.com">Cletus D'Souza</a>
040 * @version $Id: IntegrityCheckInCommand.java 1.3 2011/08/22 13:06:20EDT Cletus D'Souza (dsouza) Exp  $
041 * @since 1.6
042 */
043public class IntegrityCheckInCommand
044    extends AbstractCheckInCommand
045{
046    /**
047     * {@inheritDoc}
048     */
049    @Override
050    public CheckInScmResult executeCheckInCommand( ScmProviderRepository repository, ScmFileSet fileSet, String message,
051                                                   ScmVersion scmVersion )
052        throws ScmException
053    {
054        getLogger().info( "Attempting to check-in updates from sandbox " + fileSet.getBasedir().getAbsolutePath() );
055        IntegrityScmProviderRepository iRepo = (IntegrityScmProviderRepository) repository;
056        Sandbox siSandbox = iRepo.getSandbox();
057        List<ScmFile> changedFiles = siSandbox.checkInUpdates( message );
058        if ( siSandbox.getOverallCheckInSuccess() )
059        {
060            return new CheckInScmResult( "si ci/drop", changedFiles );
061        }
062        else
063        {
064            return new CheckInScmResult( changedFiles,
065                                         new ScmResult( "si ci/drop", "There was a problem updating the repository", "",
066                                                        false ) );
067        }
068    }
069}