com.perforce.maven.scm.provider.p4.command
Class P4Executor

java.lang.Object
  extended by com.perforce.maven.scm.provider.p4.command.P4Executor
Direct Known Subclasses:
P4ServerExecutor

public abstract class P4Executor
extends Object

Base class for Perforce server and client commands. It defines some common properties and methods shared by most Perforce commands. This class is further extended by a base server and a base client classes.


Field Summary
protected  com.perforce.p4java.client.IClient client
          Perforce client.
protected  org.apache.maven.scm.ScmFileSet fileSet
          SCM file set.
protected  org.apache.maven.scm.log.ScmLogger logger
          SCM logger.
static String P4_CHANGELIST_DESCRIPTION_PROPERTY
          The Constant P4_CHANGELIST_PROPERTY.
static String P4_CHANGELIST_PROPERTY
          The Constant P4_CHANGELIST_PROPERTY.
static String P4_CHARSET_PROPERTY
          The Constant P4_CHARSET_PROPERTY.
static String P4_CLIENT_PROPERTY
          The Constant P4_CLIENT_PROPERTY.
static String P4_FROM_CHANGELIST_PROPERTY
          The Constant P4_FROM_CHANGELIST_PROPERTY.
static String P4_JOBS_PROPERTY
          The Constant P4_JOBS_PROPERTY.
static String P4_LOCK_TAG_PROPERTY
          The Constant P4_LOCK_TAG_PROPERTY.
static String P4_PASSWD_PROPERTY
          The Constant P4_PASSWD_PROPERTY.
static String P4_PORT_PROPERTY
          The Constant P4_PORT_PROPERTY.
static String P4_TO_CHANGELIST_PROPERTY
          The Constant P4_TO_CHANGELIST_PROPERTY.
static String P4_USER_PROPERTY
          The Constant P4_USER_PROPERTY.
protected  String p4Charset
          Character set used for translation of unicode files.
protected  String p4Client
          Perforce client.
protected  boolean p4ClientCreated
          Perforce client created.
protected  com.perforce.p4java.option.server.LoginOptions p4LoginOptions
          The p4 login options.
protected  String p4Passwd
          Perforce password.
protected  String p4Port
          Perforce port.
protected  com.perforce.p4java.option.UsageOptions p4ServerOptions
          Perforce server options.
protected  Properties p4ServerProperties
          Perforce server properties.
protected  String p4User
          Perforce user.
protected  P4ScmProviderRepository repository
          P4 SCM provider repository.
protected  com.perforce.p4java.server.IOptionsServer server
          Perforce server.
 
Constructor Summary
P4Executor(P4ScmProviderRepository repository, org.apache.maven.scm.ScmFileSet fileSet, org.apache.maven.scm.log.ScmLogger logger)
          Instantiates a new p4 command helper.
 
Method Summary
protected abstract  void cleanP4()
          Cleanup Perforce server and client instances; logout, disconnect, etc.
protected  com.perforce.p4java.impl.generic.client.ClientView.ClientViewMapping createClientViewMapping(P4ScmProviderRepository repo, File basedir)
          Creates the client view mapping.
static String encodeWildcards(String filePath)
          Perforce wildcards expansion.
protected  String generateClientName()
          Generate a Perforce client workspace name.
static String getCanonicalRepoPath(String repoPath)
          Gets the canonical repo path.
 com.perforce.p4java.client.IClient getClient()
          Gets the client.
 org.apache.maven.scm.ScmFileSet getFileSet()
          Gets the file set.
 org.apache.maven.scm.log.ScmLogger getLogger()
          Gets the logger.
 String getP4Charset()
          Gets the p4 charset.
 String getP4Client()
          Gets the p4 client.
 com.perforce.p4java.option.server.LoginOptions getP4LoginOptions()
          Gets the p4 login options.
 String getP4Passwd()
          Gets the p4 passwd.
 String getP4Port()
          Gets the p4 port.
 com.perforce.p4java.option.UsageOptions getP4ServerOptions()
          Gets the p4 server options.
 Properties getP4ServerProperties()
          Gets the p4 server properties.
 String getP4User()
          Gets the p4 user.
 String getRepoLocation(String path)
          Gets the repo location.
 String getRepoPath(P4ScmProviderRepository repo, File basedir)
          Gets the repo path.
 P4ScmProviderRepository getRepository()
          Gets the repository.
 com.perforce.p4java.server.IOptionsServer getServer()
          Gets the server.
protected abstract  void initP4()
          Initialize Perforce server and client instances.
 boolean isClientNameGenerated()
          Checks if is client name generated.
static boolean isEmpty(String value)
          Checks if is empty.
 boolean isP4ClientCreated()
          Checks if is p4 client created.
static int parseChangelist(String changelist)
          Parse the changelist string to a changelist number.
 void setClient(com.perforce.p4java.client.IClient client)
          Sets the client.
 void setFileSet(org.apache.maven.scm.ScmFileSet fileSet)
          Sets the file set.
 void setLogger(org.apache.maven.scm.log.ScmLogger logger)
          Sets the logger.
 void setP4Charset(String p4Charset)
          Sets the p4 charset.
 void setP4Client(String p4Client)
          Sets the p4 client.
 void setP4ClientCreated(boolean p4ClientCreated)
          Sets the p4 client created.
 void setP4LoginOptions(com.perforce.p4java.option.server.LoginOptions p4LoginOptions)
          Sets the p4 login options.
 void setP4Passwd(String p4Passwd)
          Sets the p4 passwd.
 void setP4Port(String p4Port)
          Sets the p4 port.
 void setP4ServerOptions(com.perforce.p4java.option.UsageOptions p4ServerOptions)
          Sets the p4 server options.
 void setP4ServerProperties(Properties p4ServerProperties)
          Sets the p4 server properties.
 void setP4User(String p4User)
          Sets the p4 user.
 void setRepository(P4ScmProviderRepository repository)
          Sets the repository.
 void setServer(com.perforce.p4java.server.IOptionsServer server)
          Sets the server.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

P4_PORT_PROPERTY

public static final String P4_PORT_PROPERTY
The Constant P4_PORT_PROPERTY.

See Also:
Constant Field Values

P4_USER_PROPERTY

public static final String P4_USER_PROPERTY
The Constant P4_USER_PROPERTY.

See Also:
Constant Field Values

P4_PASSWD_PROPERTY

public static final String P4_PASSWD_PROPERTY
The Constant P4_PASSWD_PROPERTY.

See Also:
Constant Field Values

P4_CHARSET_PROPERTY

public static final String P4_CHARSET_PROPERTY
The Constant P4_CHARSET_PROPERTY.

See Also:
Constant Field Values

P4_CLIENT_PROPERTY

public static final String P4_CLIENT_PROPERTY
The Constant P4_CLIENT_PROPERTY.

See Also:
Constant Field Values

P4_JOBS_PROPERTY

public static final String P4_JOBS_PROPERTY
The Constant P4_JOBS_PROPERTY.

See Also:
Constant Field Values

P4_CHANGELIST_PROPERTY

public static final String P4_CHANGELIST_PROPERTY
The Constant P4_CHANGELIST_PROPERTY.

See Also:
Constant Field Values

P4_CHANGELIST_DESCRIPTION_PROPERTY

public static final String P4_CHANGELIST_DESCRIPTION_PROPERTY
The Constant P4_CHANGELIST_PROPERTY.

See Also:
Constant Field Values

P4_FROM_CHANGELIST_PROPERTY

public static final String P4_FROM_CHANGELIST_PROPERTY
The Constant P4_FROM_CHANGELIST_PROPERTY.

See Also:
Constant Field Values

P4_TO_CHANGELIST_PROPERTY

public static final String P4_TO_CHANGELIST_PROPERTY
The Constant P4_TO_CHANGELIST_PROPERTY.

See Also:
Constant Field Values

P4_LOCK_TAG_PROPERTY

public static final String P4_LOCK_TAG_PROPERTY
The Constant P4_LOCK_TAG_PROPERTY.

See Also:
Constant Field Values

server

protected com.perforce.p4java.server.IOptionsServer server
Perforce server.


client

protected com.perforce.p4java.client.IClient client
Perforce client.


p4ServerProperties

protected Properties p4ServerProperties
Perforce server properties.


p4ServerOptions

protected com.perforce.p4java.option.UsageOptions p4ServerOptions
Perforce server options.


p4LoginOptions

protected com.perforce.p4java.option.server.LoginOptions p4LoginOptions
The p4 login options.


logger

protected org.apache.maven.scm.log.ScmLogger logger
SCM logger.


repository

protected P4ScmProviderRepository repository
P4 SCM provider repository.


fileSet

protected org.apache.maven.scm.ScmFileSet fileSet
SCM file set.


p4Client

protected String p4Client
Perforce client.


p4Charset

protected String p4Charset
Character set used for translation of unicode files. P4CHARSET only affects files of type unicode and utf16; non-unicode files are never translated. For servers operating in the default (non-Unicode mode), P4CHARSET must be left unset on client machines. If P4CHARSET is set, but the server is not operating in internationalized mode, the server returns the following error message: "Unicode clients require a unicode enabled server". For servers operating in Unicode mode, P4CHARSET must be set on client machines. If P4CHARSET is unset, but the server is operating in Unicode mode, client programs return the following error message: "Unicode server permits only unicode enabled clients". Note that the names below are not actually the standard name for the charset in some cases: e.g. UTF-8 should be "utf-8" not "utf8", but we follow the Perforce server's rules here.

"none", "utf8", "iso8859-1", "shiftjis", "eucjp", "winansi", "cp949", "macosroman", "iso8859-15", "iso8859-5", "koi8-r", "cp1251", "utf16le", "utf16be", "utf16"


p4Port

protected String p4Port
Perforce port.


p4User

protected String p4User
Perforce user.


p4Passwd

protected String p4Passwd
Perforce password.


p4ClientCreated

protected boolean p4ClientCreated
Perforce client created.

Constructor Detail

P4Executor

public P4Executor(P4ScmProviderRepository repository,
                  org.apache.maven.scm.ScmFileSet fileSet,
                  org.apache.maven.scm.log.ScmLogger logger)
           throws org.apache.maven.scm.ScmException
Instantiates a new p4 command helper.

Parameters:
repository - the repository
fileSet - the file set
logger - the logger
Throws:
org.apache.maven.scm.ScmException - the scm exception
Method Detail

getServer

public com.perforce.p4java.server.IOptionsServer getServer()
Gets the server.

Returns:
the server

setServer

public void setServer(com.perforce.p4java.server.IOptionsServer server)
Sets the server.

Parameters:
server - the new server

getClient

public com.perforce.p4java.client.IClient getClient()
Gets the client.

Returns:
the client

setClient

public void setClient(com.perforce.p4java.client.IClient client)
Sets the client.

Parameters:
client - the new client

getP4ServerProperties

public Properties getP4ServerProperties()
Gets the p4 server properties.

Returns:
the p4 server properties

setP4ServerProperties

public void setP4ServerProperties(Properties p4ServerProperties)
Sets the p4 server properties.

Parameters:
p4ServerProperties - the new p4 server properties

getP4ServerOptions

public com.perforce.p4java.option.UsageOptions getP4ServerOptions()
Gets the p4 server options.

Returns:
the p4 server options

setP4ServerOptions

public void setP4ServerOptions(com.perforce.p4java.option.UsageOptions p4ServerOptions)
Sets the p4 server options.

Parameters:
p4ServerOptions - the new p4 server options

getP4LoginOptions

public com.perforce.p4java.option.server.LoginOptions getP4LoginOptions()
Gets the p4 login options.

Returns:
the p4 login options

setP4LoginOptions

public void setP4LoginOptions(com.perforce.p4java.option.server.LoginOptions p4LoginOptions)
Sets the p4 login options.

Parameters:
p4LoginOptions - the new p4 login options

getLogger

public org.apache.maven.scm.log.ScmLogger getLogger()
Gets the logger.

Returns:
the logger

setLogger

public void setLogger(org.apache.maven.scm.log.ScmLogger logger)
Sets the logger.

Parameters:
logger - the new logger

getRepository

public P4ScmProviderRepository getRepository()
Gets the repository.

Returns:
the repository

setRepository

public void setRepository(P4ScmProviderRepository repository)
Sets the repository.

Parameters:
repository - the new repository

getFileSet

public org.apache.maven.scm.ScmFileSet getFileSet()
Gets the file set.

Returns:
the file set

setFileSet

public void setFileSet(org.apache.maven.scm.ScmFileSet fileSet)
Sets the file set.

Parameters:
fileSet - the new file set

getP4Client

public String getP4Client()
Gets the p4 client.

Returns:
the p4 client

setP4Client

public void setP4Client(String p4Client)
Sets the p4 client.

Parameters:
p4Client - the new p4 client

getP4Charset

public String getP4Charset()
Gets the p4 charset.

Returns:
the p4 charset

setP4Charset

public void setP4Charset(String p4Charset)
Sets the p4 charset.

Parameters:
p4Charset - the new p4 charset

getP4Port

public String getP4Port()
Gets the p4 port.

Returns:
the p4 port

setP4Port

public void setP4Port(String p4Port)
Sets the p4 port.

Parameters:
p4Port - the new p4 port

getP4User

public String getP4User()
Gets the p4 user.

Returns:
the p4 user

setP4User

public void setP4User(String p4User)
Sets the p4 user.

Parameters:
p4User - the new p4 user

getP4Passwd

public String getP4Passwd()
Gets the p4 passwd.

Returns:
the p4 passwd

setP4Passwd

public void setP4Passwd(String p4Passwd)
Sets the p4 passwd.

Parameters:
p4Passwd - the new p4 passwd

isP4ClientCreated

public boolean isP4ClientCreated()
Checks if is p4 client created.

Returns:
true, if is p4 client created

setP4ClientCreated

public void setP4ClientCreated(boolean p4ClientCreated)
Sets the p4 client created.

Parameters:
p4ClientCreated - the new p4 client created

initP4

protected abstract void initP4()
                        throws org.apache.maven.scm.ScmException
Initialize Perforce server and client instances. This should be implemented in the Perforce server and client subclasses.

Throws:
org.apache.maven.scm.ScmException - the scm exception

cleanP4

protected abstract void cleanP4()
                         throws org.apache.maven.scm.ScmException
Cleanup Perforce server and client instances; logout, disconnect, etc. This should be implemented by the Perforce server and client subclasses.

Throws:
org.apache.maven.scm.ScmException - the scm exception

generateClientName

protected String generateClientName()
Generate a Perforce client workspace name.

Returns:
the string

isClientNameGenerated

public boolean isClientNameGenerated()
Checks if is client name generated.

Returns:
true, if is client name generated

createClientViewMapping

protected com.perforce.p4java.impl.generic.client.ClientView.ClientViewMapping createClientViewMapping(P4ScmProviderRepository repo,
                                                                                                       File basedir)
Creates the client view mapping.

Parameters:
repo - the repo
basedir - the basedir
Returns:
the client view mapping

getRepoLocation

public String getRepoLocation(String path)
Gets the repo location.

Parameters:
path - the path
Returns:
the repo location

getRepoPath

public String getRepoPath(P4ScmProviderRepository repo,
                          File basedir)
Gets the repo path. Handles cases where repo.getPath() is not a valid Perforce depot location. This might be an error due to branches and directory naming where dir name != artifactId.

Parameters:
repo - the repo
basedir - the basedir
Returns:
the repo path

getCanonicalRepoPath

public static String getCanonicalRepoPath(String repoPath)
Gets the canonical repo path.

Parameters:
repoPath - the repo path
Returns:
the canonical repo path

parseChangelist

public static int parseChangelist(String changelist)
Parse the changelist string to a changelist number. Convert the "default" changelist string to the default changelist number. If it is negative return unknown changelist. Otherwise, return the converted changelist number.

Parameters:
changelist - the changelist
Returns:
the int

encodeWildcards

public static String encodeWildcards(String filePath)
Perforce wildcards expansion.

Parameters:
filePath - the file path
Returns:
the string

isEmpty

public static boolean isEmpty(String value)
Checks if is empty.

Parameters:
value - the value
Returns:
true, if is empty


Copyright © 2003-2011 Perforce Software. All Rights Reserved.