001 package org.apache.maven.scm.command.mkdir;
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
022 import org.apache.maven.scm.CommandParameter;
023 import org.apache.maven.scm.CommandParameters;
024 import org.apache.maven.scm.ScmException;
025 import org.apache.maven.scm.ScmFileSet;
026 import org.apache.maven.scm.ScmResult;
027 import org.apache.maven.scm.command.AbstractCommand;
028 import org.apache.maven.scm.provider.ScmProviderRepository;
029
030 /**
031 * @author <a href="mailto:oching@apache.org">Maria Odea Ching</a>
032 *
033 */
034 public abstract class AbstractMkdirCommand
035 extends AbstractCommand
036 {
037 /**
038 * Creates directories in the remote repository.
039 *
040 * @param repository
041 * @param fileSet
042 * @param createInLocal TODO
043 * @param scmVersion
044 * @return
045 * @throws ScmException
046 */
047 protected abstract MkdirScmResult executeMkdirCommand( ScmProviderRepository repository, ScmFileSet fileSet,
048 String message, boolean createInLocal )
049 throws ScmException;
050
051 /** {@inheritDoc} */
052 protected ScmResult executeCommand( ScmProviderRepository repository, ScmFileSet fileSet,
053 CommandParameters parameters )
054 throws ScmException
055 {
056 if ( fileSet.getFileList().isEmpty() )
057 {
058 throw new IllegalArgumentException( "fileSet can not be empty" );
059 }
060
061 return executeMkdirCommand( repository, fileSet, parameters.getString( CommandParameter.MESSAGE ),
062 parameters.getBoolean( CommandParameter.SCM_MKDIR_CREATE_IN_LOCAL ) );
063 }
064
065 }