001/* 002 * Licensed to the Apache Software Foundation (ASF) under one 003 * or more contributor license agreements. See the NOTICE file 004 * distributed with this work for additional information 005 * regarding copyright ownership. The ASF licenses this file 006 * to you under the Apache License, Version 2.0 (the 007 * "License"); you may not use this file except in compliance 008 * with the License. You may obtain a copy of the License at 009 * 010 * http://www.apache.org/licenses/LICENSE-2.0 011 * 012 * Unless required by applicable law or agreed to in writing, 013 * software distributed under the License is distributed on an 014 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 015 * KIND, either express or implied. See the License for the 016 * specific language governing permissions and limitations 017 * under the License. 018 */ 019package org.apache.maven.scm.provider.svn.svnexe; 020 021import javax.inject.Named; 022import javax.inject.Singleton; 023 024import java.io.File; 025 026import org.apache.maven.scm.CommandParameters; 027import org.apache.maven.scm.ScmException; 028import org.apache.maven.scm.ScmFileSet; 029import org.apache.maven.scm.command.info.InfoScmResult; 030import org.apache.maven.scm.command.remoteinfo.RemoteInfoScmResult; 031import org.apache.maven.scm.provider.ScmProviderRepository; 032import org.apache.maven.scm.provider.svn.AbstractSvnScmProvider; 033import org.apache.maven.scm.provider.svn.command.SvnCommand; 034import org.apache.maven.scm.provider.svn.svnexe.command.add.SvnAddCommand; 035import org.apache.maven.scm.provider.svn.svnexe.command.blame.SvnBlameCommand; 036import org.apache.maven.scm.provider.svn.svnexe.command.branch.SvnBranchCommand; 037import org.apache.maven.scm.provider.svn.svnexe.command.changelog.SvnChangeLogCommand; 038import org.apache.maven.scm.provider.svn.svnexe.command.checkin.SvnCheckInCommand; 039import org.apache.maven.scm.provider.svn.svnexe.command.checkout.SvnCheckOutCommand; 040import org.apache.maven.scm.provider.svn.svnexe.command.diff.SvnDiffCommand; 041import org.apache.maven.scm.provider.svn.svnexe.command.export.SvnExeExportCommand; 042import org.apache.maven.scm.provider.svn.svnexe.command.info.SvnInfoCommand; 043import org.apache.maven.scm.provider.svn.svnexe.command.list.SvnListCommand; 044import org.apache.maven.scm.provider.svn.svnexe.command.mkdir.SvnMkdirCommand; 045import org.apache.maven.scm.provider.svn.svnexe.command.remoteinfo.SvnRemoteInfoCommand; 046import org.apache.maven.scm.provider.svn.svnexe.command.remove.SvnRemoveCommand; 047import org.apache.maven.scm.provider.svn.svnexe.command.status.SvnStatusCommand; 048import org.apache.maven.scm.provider.svn.svnexe.command.tag.SvnTagCommand; 049import org.apache.maven.scm.provider.svn.svnexe.command.untag.SvnUntagCommand; 050import org.apache.maven.scm.provider.svn.svnexe.command.update.SvnUpdateCommand; 051import org.apache.maven.scm.repository.ScmRepositoryException; 052 053/** 054 * @author <a href="mailto:evenisse@apache.org">Emmanuel Venisse</a> 055 */ 056@Singleton 057@Named("svn") 058public class SvnExeScmProvider extends AbstractSvnScmProvider { 059 private boolean interactive = true; 060 061 @Override 062 public void setInteractive(boolean interactive) { 063 this.interactive = interactive; 064 } 065 066 /** 067 * {@inheritDoc} 068 */ 069 @Override 070 protected SvnCommand getAddCommand() { 071 return new SvnAddCommand(); 072 } 073 074 /** 075 * {@inheritDoc} 076 */ 077 @Override 078 protected SvnCommand getBranchCommand() { 079 return new SvnBranchCommand(interactive); 080 } 081 082 /** 083 * {@inheritDoc} 084 */ 085 @Override 086 protected SvnCommand getChangeLogCommand() { 087 return new SvnChangeLogCommand(interactive); 088 } 089 090 /** 091 * {@inheritDoc} 092 */ 093 @Override 094 protected SvnCommand getCheckInCommand() { 095 return new SvnCheckInCommand(interactive); 096 } 097 098 /** 099 * {@inheritDoc} 100 */ 101 @Override 102 protected SvnCommand getCheckOutCommand() { 103 return new SvnCheckOutCommand(interactive); 104 } 105 106 /** 107 * {@inheritDoc} 108 */ 109 @Override 110 protected SvnCommand getDiffCommand() { 111 return new SvnDiffCommand(interactive); 112 } 113 114 /** 115 * {@inheritDoc} 116 */ 117 @Override 118 protected SvnCommand getExportCommand() { 119 return new SvnExeExportCommand(interactive); 120 } 121 122 /** 123 * {@inheritDoc} 124 */ 125 @Override 126 protected SvnCommand getRemoveCommand() { 127 return new SvnRemoveCommand(); 128 } 129 130 /** 131 * {@inheritDoc} 132 */ 133 @Override 134 protected SvnCommand getStatusCommand() { 135 return new SvnStatusCommand(interactive); 136 } 137 138 /** 139 * {@inheritDoc} 140 */ 141 @Override 142 protected SvnCommand getTagCommand() { 143 return new SvnTagCommand(interactive); 144 } 145 146 /** 147 * {@inheritDoc} 148 */ 149 @Override 150 protected SvnCommand getUntagCommand() { 151 return new SvnUntagCommand(interactive); 152 } 153 154 /** 155 * {@inheritDoc} 156 */ 157 @Override 158 protected SvnCommand getUpdateCommand() { 159 return new SvnUpdateCommand(interactive); 160 } 161 162 /** 163 * {@inheritDoc} 164 */ 165 @Override 166 protected SvnCommand getListCommand() { 167 return new SvnListCommand(interactive); 168 } 169 170 @Override 171 public SvnCommand getInfoCommand() { 172 return new SvnInfoCommand(interactive); 173 } 174 175 /** 176 * {@inheritDoc} 177 */ 178 @Override 179 protected SvnCommand getBlameCommand() { 180 return new SvnBlameCommand(interactive); 181 } 182 183 /** 184 * {@inheritDoc} 185 */ 186 @Override 187 protected SvnCommand getMkdirCommand() { 188 return new SvnMkdirCommand(interactive); 189 } 190 191 /** 192 * {@inheritDoc} 193 */ 194 @Override 195 protected String getRepositoryURL(File path) throws ScmException { 196 // Note: I need to supply just 1 absolute path, but ScmFileSet won't let me without 197 // a basedir (which isn't used here anyway), so use a dummy file. 198 SvnInfoCommand infoCmd = (SvnInfoCommand) getInfoCommand(); 199 200 InfoScmResult result = infoCmd.executeInfoCommand(null, new ScmFileSet(new File(""), path), null, false, null); 201 202 if (result.getInfoItems().size() != 1) { 203 throw new ScmRepositoryException("Cannot find URL: " 204 + (result.getInfoItems().size() == 0 ? "no" : "multiple") + " items returned by the info command"); 205 } 206 207 return result.getInfoItems().get(0).getURL(); 208 } 209 210 @Override 211 public RemoteInfoScmResult remoteInfo( 212 ScmProviderRepository repository, ScmFileSet fileSet, CommandParameters parameters) throws ScmException { 213 SvnRemoteInfoCommand svnRemoteInfoCommand = new SvnRemoteInfoCommand(interactive); 214 return svnRemoteInfoCommand.executeRemoteInfoCommand(repository, fileSet, parameters); 215 } 216 217 @Override 218 public boolean remoteUrlExist(ScmProviderRepository repository, CommandParameters parameters) throws ScmException { 219 SvnRemoteInfoCommand svnRemoteInfoCommand = new SvnRemoteInfoCommand(interactive); 220 return svnRemoteInfoCommand.remoteUrlExist(repository, parameters); 221 } 222}