/** * Copyright (c) 2010 Perforce Software. All rights reserved. */ package com.perforce.maven.scm.provider.p4; import org.apache.maven.scm.CommandParameter; import org.apache.maven.scm.CommandParameters; import org.apache.maven.scm.ScmBranch; import org.apache.maven.scm.ScmException; import org.apache.maven.scm.ScmFileSet; import org.apache.maven.scm.ScmTag; import org.apache.maven.scm.ScmVersion; import org.apache.maven.scm.command.add.AddScmResult; import org.apache.maven.scm.command.blame.BlameScmResult; import org.apache.maven.scm.command.branch.BranchScmResult; import org.apache.maven.scm.command.changelog.ChangeLogScmResult; import org.apache.maven.scm.command.checkin.CheckInScmResult; import org.apache.maven.scm.command.checkout.CheckOutScmResult; import org.apache.maven.scm.command.diff.DiffScmResult; import org.apache.maven.scm.command.edit.EditScmResult; import org.apache.maven.scm.command.export.ExportScmResult; import org.apache.maven.scm.command.info.InfoScmResult; import org.apache.maven.scm.command.list.ListScmResult; import org.apache.maven.scm.command.login.LoginScmResult; import org.apache.maven.scm.command.remove.RemoveScmResult; import org.apache.maven.scm.command.status.StatusScmResult; import org.apache.maven.scm.command.tag.TagScmResult; import org.apache.maven.scm.command.unedit.UnEditScmResult; import org.apache.maven.scm.command.update.UpdateScmResult; import org.apache.maven.scm.provider.AbstractScmProvider; import org.apache.maven.scm.provider.ScmProviderRepository; import org.apache.maven.scm.repository.ScmRepositoryException; import com.perforce.maven.scm.provider.p4.command.add.P4AddCommand; import com.perforce.maven.scm.provider.p4.command.blame.P4BlameCommand; import com.perforce.maven.scm.provider.p4.command.branch.P4BranchCommand; import com.perforce.maven.scm.provider.p4.command.changelog.P4ChangeLogCommand; import com.perforce.maven.scm.provider.p4.command.checkin.P4CheckInCommand; import com.perforce.maven.scm.provider.p4.command.checkout.P4CheckOutCommand; import com.perforce.maven.scm.provider.p4.command.diff.P4DiffCommand; import com.perforce.maven.scm.provider.p4.command.edit.P4EditCommand; import com.perforce.maven.scm.provider.p4.command.export.P4ExportCommand; import com.perforce.maven.scm.provider.p4.command.info.P4InfoCommand; import com.perforce.maven.scm.provider.p4.command.list.P4ListCommand; import com.perforce.maven.scm.provider.p4.command.login.P4LoginCommand; import com.perforce.maven.scm.provider.p4.command.remove.P4RemoveCommand; import com.perforce.maven.scm.provider.p4.command.status.P4StatusCommand; import com.perforce.maven.scm.provider.p4.command.tag.P4TagCommand; import com.perforce.maven.scm.provider.p4.command.unedit.P4UnEditCommand; import com.perforce.maven.scm.provider.p4.command.update.P4UpdateCommand; import com.perforce.maven.scm.provider.p4.manager.P4ClientManager; import com.perforce.maven.scm.provider.p4.repository.P4ScmProviderRepository; import com.perforce.maven.scm.provider.p4.util.P4ScmUrl; import com.perforce.maven.scm.provider.p4.util.P4Utils; /** * This class validates the SCM URL, populate the ScmProviderRepository and provide all commands supported by the P4 * provider. * * @plexus.component role="org.apache.maven.scm.provider.ScmProvider" role-hint="p4" */ public class P4ScmProvider extends AbstractScmProvider { /** * @plexus.requirement role="com.perforce.maven.scm.provider.p4.manager.P4ClientManager" */ private P4ClientManager clientManager; /** * @see org.apache.maven.scm.provider.ScmProvider#makeProviderScmRepository */ public ScmProviderRepository makeProviderScmRepository( String scmSpecificUrl, char delimiter ) throws ScmRepositoryException { P4ScmUrl parser = null; try { parser = P4ScmUrl.parse( P4ScmUrl.P4MAVEN_URL_PREFIX + scmSpecificUrl ); } catch ( Exception e ) { throw new ScmRepositoryException( e.getMessage() ); } return new P4ScmProviderRepository( parser.getProtocol(), parser.getHost(), parser.getPort(), parser.getPath(), parser.getUsername(), parser.getPassword() ); } /** * @see org.apache.maven.scm.provider.AbstractScmProvider#requiresEditMode() */ public boolean requiresEditMode() { return true; } /** * @see org.apache.maven.scm.provider.ScmProvider#getScmType() */ public String getScmType() { return "p4"; } /** * @see org.apache.maven.scm.provider.AbstractScmProvider .scm.provider.ScmProviderRepository, * org.apache.maven.scm.ScmFileSet, org.apache.maven.scm.CommandParameters) */ public AddScmResult add( ScmProviderRepository repository, ScmFileSet fileSet, CommandParameters params ) throws ScmException { P4AddCommand command = new P4AddCommand(); command.setLogger( getLogger() ); command.setClient( clientManager.getClient( (P4ScmProviderRepository) repository, fileSet.getBasedir() ) ); return (AddScmResult) command.execute( repository, fileSet, params ); } /** * @see org.apache.maven.scm.provider.AbstractScmProvider#blame */ protected BlameScmResult blame( ScmProviderRepository repository, ScmFileSet fileSet, CommandParameters params ) throws ScmException { P4BlameCommand command = new P4BlameCommand(); command.setLogger( getLogger() ); command.setClient( clientManager.getClient( (P4ScmProviderRepository) repository, fileSet.getBasedir() ) ); return (BlameScmResult) command.execute( repository, fileSet, params ); } /** * @see org.apache.maven.scm.provider.AbstractScmProvider#branch */ protected BranchScmResult branch( ScmProviderRepository repository, ScmFileSet fileSet, CommandParameters params ) throws ScmException { P4BranchCommand command = new P4BranchCommand(); command.setLogger( getLogger() ); command.setClient( clientManager.getClient( (P4ScmProviderRepository) repository, fileSet.getBasedir() ) ); return (BranchScmResult) command.execute( repository, fileSet, params ); } /** * @see org.apache.maven.scm.provider.AbstractScmProvider#checkin */ protected CheckInScmResult checkin( ScmProviderRepository repository, ScmFileSet fileSet, CommandParameters params ) throws ScmException { P4CheckInCommand command = new P4CheckInCommand(); command.setLogger( getLogger() ); command.setClient( clientManager.getClient( (P4ScmProviderRepository) repository, fileSet.getBasedir() ) ); return (CheckInScmResult) command.execute( repository, fileSet, params ); } /** * @see org.apache.maven.scm.provider.AbstractScmProvider#checkout */ protected CheckOutScmResult checkout( ScmProviderRepository repository, ScmFileSet fileSet, CommandParameters params ) throws ScmException { ScmVersion scmVersion = params.getScmVersion( CommandParameter.SCM_VERSION, null ); P4ScmProviderRepository p4Repo = (P4ScmProviderRepository) repository; if ( scmVersion != null && !( scmVersion instanceof ScmTag ) && scmVersion instanceof ScmBranch ) { ScmBranch scmBranch = (ScmBranch) scmVersion; p4Repo.setPath( scmBranch.getName() ); } P4CheckOutCommand command = new P4CheckOutCommand(); command.setLogger( getLogger() ); // handle the case where user want to a brand new checkout with given client name to be created and persisted String clientName = clientManager.discoverClientName( p4Repo, fileSet.getBasedir() ); if ( null == clientName ) { clientName = P4Utils.getSettings().getClientName(); } command.setClient( clientManager.getClient( p4Repo, fileSet.getBasedir(), clientName ) ); return (CheckOutScmResult) command.execute( repository, fileSet, params ); } /** * @see org.apache.maven.scm.provider.AbstractScmProvider#export */ protected ExportScmResult export( ScmProviderRepository repository, ScmFileSet fileSet, CommandParameters params ) throws ScmException { // @TODO, use a random client name so that we can auto remove it P4ExportCommand command = new P4ExportCommand(); command.setLogger( getLogger() ); command.setClient( clientManager.getClient( (P4ScmProviderRepository) repository, fileSet.getBasedir() ) ); return (ExportScmResult) command.execute( repository, fileSet, params ); } /** * @see org.apache.maven.scm.provider.AbstractScmProvider#changelog */ protected ChangeLogScmResult changelog( ScmProviderRepository repository, ScmFileSet fileSet, CommandParameters parameters ) throws ScmException { P4ChangeLogCommand command = new P4ChangeLogCommand(); command.setLogger( getLogger() ); command.setClient( clientManager.getClient( (P4ScmProviderRepository) repository, fileSet.getBasedir() ) ); return (ChangeLogScmResult) command.execute( repository, fileSet, parameters ); } /** * @see org.apache.maven.scm.provider.AbstractScmProvider#diff */ protected DiffScmResult diff( ScmProviderRepository repository, ScmFileSet fileSet, CommandParameters params ) throws ScmException { P4DiffCommand command = new P4DiffCommand(); command.setLogger( getLogger() ); command.setClient( clientManager.getClient( (P4ScmProviderRepository) repository, fileSet.getBasedir() ) ); return (DiffScmResult) command.execute( repository, fileSet, params ); } /** * @see org.apache.maven.scm.provider.AbstractScmProvider#edit */ protected EditScmResult edit( ScmProviderRepository repository, ScmFileSet fileSet, CommandParameters params ) throws ScmException { P4EditCommand command = new P4EditCommand(); command.setLogger( getLogger() ); command.setClient( clientManager.getClient( (P4ScmProviderRepository) repository, fileSet.getBasedir() ) ); return (EditScmResult) command.execute( repository, fileSet, params ); } /** * @see org.apache.maven.scm.provider.AbstractScmProvider#list */ public ListScmResult list( ScmProviderRepository repository, ScmFileSet fileSet, CommandParameters params ) throws ScmException { P4ListCommand command = new P4ListCommand(); command.setLogger( getLogger() ); command.setClient( clientManager.getClient( (P4ScmProviderRepository) repository, fileSet.getBasedir() ) ); return (ListScmResult) command.execute( repository, fileSet, params ); } /** * @see org.apache.maven.scm.provider.AbstractScmProvider#login */ protected LoginScmResult login( ScmProviderRepository repository, ScmFileSet fileSet, CommandParameters params ) throws ScmException { P4LoginCommand command = new P4LoginCommand(); command.setLogger( getLogger() ); command.setClient( clientManager.getClient( (P4ScmProviderRepository) repository, fileSet.getBasedir() ) ); return (LoginScmResult) command.execute( repository, fileSet, params ); } /** * @see org.apache.maven.scm.provider.AbstractScmProvider#remove */ protected RemoveScmResult remove( ScmProviderRepository repository, ScmFileSet fileSet, CommandParameters params ) throws ScmException { P4RemoveCommand command = new P4RemoveCommand(); command.setLogger( getLogger() ); command.setClient( clientManager.getClient( (P4ScmProviderRepository) repository, fileSet.getBasedir() ) ); return (RemoveScmResult) command.execute( repository, fileSet, params ); } /** * @see org.apache.maven.scm.provider.AbstractScmProvider#status */ protected StatusScmResult status( ScmProviderRepository repository, ScmFileSet fileSet, CommandParameters params ) throws ScmException { P4StatusCommand command = new P4StatusCommand(); command.setLogger( getLogger() ); command.setClient( clientManager.getClient( (P4ScmProviderRepository) repository, fileSet.getBasedir() ) ); return (StatusScmResult) command.execute( repository, fileSet, params ); } /** * @see org.apache.maven.scm.provider.AbstractScmProvider#tag */ protected TagScmResult tag( ScmProviderRepository repository, ScmFileSet fileSet, CommandParameters params ) throws ScmException { P4TagCommand command = new P4TagCommand(); command.setLogger( getLogger() ); command.setClient( clientManager.getClient( (P4ScmProviderRepository) repository, fileSet.getBasedir() ) ); return (TagScmResult) command.execute( repository, fileSet, params ); } /** * @see org.apache.maven.scm.provider.AbstractScmProvider#unedit */ protected UnEditScmResult unedit( ScmProviderRepository repository, ScmFileSet fileSet, CommandParameters params ) throws ScmException { P4UnEditCommand command = new P4UnEditCommand(); command.setLogger( getLogger() ); command.setClient( clientManager.getClient( (P4ScmProviderRepository) repository, fileSet.getBasedir() ) ); return (UnEditScmResult) command.execute( repository, fileSet, params ); } /** * @see org.apache.maven.scm.provider.AbstractScmProvider#update */ protected UpdateScmResult update( ScmProviderRepository repository, ScmFileSet fileSet, CommandParameters params ) throws ScmException { P4UpdateCommand command = new P4UpdateCommand(); command.setLogger( getLogger() ); command.setClient( clientManager.getClient( (P4ScmProviderRepository) repository, fileSet.getBasedir() ) ); return (UpdateScmResult) command.execute( repository, fileSet, params ); } public InfoScmResult info( ScmProviderRepository repository, ScmFileSet fileSet, CommandParameters params ) throws ScmException { P4InfoCommand command = new P4InfoCommand(); command.setLogger( getLogger() ); command.setClient( clientManager.getClient( (P4ScmProviderRepository) repository, fileSet.getBasedir() ) ); return (InfoScmResult) command.execute( repository, fileSet, params ); } }
# | Change | User | Description | Committed | |
---|---|---|---|---|---|
#2 | 19967 | jkovisto | Pull over numerous changes from @dantran's branch from change 16716. | ||
#1 | 10055 | Matt Attaway | Pull over numerous changes from @dantran's branch. | ||
//guest/perforce_software/p4maven/main/com.perforce.maven/src/main/java/com/perforce/maven/scm/provider/p4/P4ScmProvider.java | |||||
#2 | 9014 | Matt Attaway |
Add SSL support to P4Maven (committed on behalf of Dan Tran) USer visible change |
||
#1 | 8496 | Matt Attaway | Move P4Ant and P4Maven into their proper homes | ||
//public/perforce/p4maven/main/com.perforce.maven/src/main/java/com/perforce/maven/scm/provider/p4/P4ScmProvider.java | |||||
#1 | 8270 | Matt Attaway | Initial add of P4Maven source code |