com.perforce.p4java.impl.mapbased.rpc
Class RpcServer

java.lang.Object
  extended by com.perforce.p4java.impl.mapbased.server.Server
      extended by com.perforce.p4java.impl.mapbased.rpc.RpcServer
All Implemented Interfaces:
IServerControl, IOptionsServer, IServer
Direct Known Subclasses:
NtsServerImpl, OneShotServerImpl

public abstract class RpcServer
extends Server

RPC-based Perforce server implementation superclass.


Field Summary
protected  String applicationName
           
protected  RpcUserAuthCounter authCounter
           
protected  int clientApiLevel
           
protected  ClientTrust clientTrust
           
protected  Map<String,Object> cmdMapArgs
          The RPC command args before the function name (i.e.
protected  long connectionStart
           
static int DEFAULT_CLIENT_API_LEVEL
          Default Perforce client API level; 78 represents 2015.1 capabilities.
static String DEFAULT_PROG_NAME
          The default string sent to the Perforce server in the protocol command defining the client's program name.
static String DEFAULT_PROG_VERSION
          The default string sent to the Perforce server in the protocol command defining the client's program version.
static int DEFAULT_SERVER_API_LEVEL
          Default Perforce server API level; 99999 apparently means "whatever...".
static IServerImplMetadata.ImplType IMPL_TYPE
          The implementation type of this implementation.
protected  String localHostName
           
protected  boolean relaxCmdNameValidationChecks
          If true, relax the command name validation checks done in the RPC layer.
static boolean RPC_ENABLE_STREAMS
          Signifies whether or not the client is capable of handling streams.
static String RPC_ENV_CWD_KEY
          The system properties key for the JVM's current directory.
static String RPC_ENV_NOCLIENT_SPEC
          What we use in the RPC environment packet to signal to the Perforce server that we don't have a client set yet or don't know what it is.
static String RPC_ENV_NOHOST_SPEC
          What we use in the RPC environment packet to signal to the Perforce server that we don't have a hostname set yet or don't know what it is.
static String RPC_ENV_NOUSER_SPEC
          What we use in the RPC environment packet to signal to the Perforce server that we don't have a client set yet or don't know what it is.
static String RPC_ENV_OS_NAME_KEY
          The system properties key for the OS name.
static String RPC_ENV_UNIX_SPEC
          What we use in the RPC environment packet to signal to the Perforce server that we're a NON-Windows box.
static String RPC_ENV_WINDOWS_PREFIX
          RPC_ENV_OS_NAME_KEY property value prefix for Windows systems.
static String RPC_ENV_WINDOWS_SPEC
          What we use in the RPC environment packet to signal to the Perforce server that we're a Windows box.
static boolean RPC_TAGS_USED
          Signifies whether or not we use tagged output.
static String RPC_TMP_CONVERTER_KEY
          Use to key converter to use out of state map
static String RPC_TMP_OUTFILE_STREAM_KEY
          Used to key temporary output streams in the command environment's state map for things like getFileContents(), etc., using the execStreamCmd method(s).
protected  IServerAddress rpcServerAddress
           
protected  Map<String,String> secretKeys
           
protected  int serverApiLevel
           
protected  String serverId
           
protected  Map<String,Object> serverProtocolMap
           
protected  ServerStats serverStats
           
protected  String ticketsFilePath
           
static String TRACE_PREFIX
          What we use as a P4JTracer trace prefix for methods here.
protected  String trustFilePath
           
 
Fields inherited from class com.perforce.p4java.impl.mapbased.server.Server
ATTRIBUTE_STREAM_MAP_KEY, authTickets, caseSensitive, charset, charsetName, client, clientName, clientUnsetName, commandCallback, connected, CORE_AUTH_FAIL_STRING_1, CORE_AUTH_FAIL_STRING_2, CORE_AUTH_FAIL_STRING_3, CORE_AUTH_FAIL_STRING_4, DEFAULT_STATUS_FIELD_NAME, enableProgress, enableTracking, ignoreFileName, IMPL_COMMENTS_FIELD_NAME, IMPL_TYPE_FIELD_NAME, IN_MAP_USE_TAGS_KEY, loginOnConnect, MINIMUM_SUPPORTED_SERVER_LEVEL_FIELD_NAME, minumumSupportedServerVersion, nextCmdCallBackKey, nextProgressCallbackKey, nonCheckedSyncs, P4IGNORE_ENV_VAR, P4TICKETS_DEFAULT_OTHER, P4TICKETS_DEFAULT_WINDOWS, P4TICKETS_ENV_VAR, P4TRUST_DEFAULT_OTHER, P4TRUST_DEFAULT_WINDOWS, P4TRUST_ENV_VAR, password, progressCallback, props, PROTOCOL_NAME_FIELD_NAME, quietMode, rand, rsh, runningOnWindows, SCREEN_NAME_FIELD_NAME, secure, serverAddress, serverHost, serverInfo, serverPort, serverVersion, setupOnConnect, ssoCallback, ssoKey, status, tmpDirName, UNKNOWN_SERVER_HOST, UNKNOWN_SERVER_PORT, UNKNOWN_SERVER_VERSION, usageOptions, useAuthMemoryStore, userName
 
Constructor Summary
RpcServer()
           
 
Method Summary
 String addTrust(String fingerprintValue)
          Approve and add the specified fingerprint for the Perforce SSL connection.
 String addTrust(String fingerprintValue, TrustOptions opts)
          Approve and add the specified fingerprint or replacement for the Perforce SSL connection.
 String addTrust(TrustOptions opts)
          Approve and add the fingerprint for the Perforce SSL connection.
protected  void checkFingerprint(RpcConnection rpcConnection)
          Check the fingerprint of the Perforce server SSL connection
protected  String composeAuthTicketEntryKey(String userName, String serverAddress)
          Compose the key for an auth ticket entry
 void connect()
          Try to establish an actual RPC connection to the target Perforce server.
 void disconnect()
          Try to cleanly disconnect from the Perforce server at the other end of the current connection (with the emphasis on "cleanly").
 String getApplicationName()
           
 RpcUserAuthCounter getAuthCounter()
          Get the RPC user authentication counter.
 String getAuthTicket(String userName)
          Return the Perforce authentication ticket for specified user.
 int getClientApiLevel()
           
protected  String getClientNameForEnv()
           
 String getErrorOrInfoStr(Map<String,Object> map)
          Gets the info/warning/error/fatal message from the passed-in Perforce command results map.
 String getErrorStr(Map<String,Object> map)
          RPC impl errors come across the wire as a map in the form usually like this:
protected  int getGenericCode(Map<String,Object> map)
           
protected  String getHostForEnv()
           
 String getInfoStr(Map<String,Object> map)
          Gets the info message from the passed-in Perforce command results map.
protected  String getLanguageForEnv()
           
protected  String getOsTypeForEnv()
           
 PerformanceMonitor getPerfMonitor()
           
protected  RpcPacketFieldRule getRpcPacketFieldRule(Map<String,Object> inMap, CmdSpec cmdSpec)
          Get the RPC packet field rule for skipping the charset conversion of a range of RPC packet fields; leave the values as bytes.
 IServerAddress getRpcServerAddress()
          Get the server's address for the RPC connection.
 String getSecretKey()
           
 String getSecretKey(String userName)
           
 String getServerAddress()
          Get the server's address field used for storing authentication tickets.
 String getServerHostPort()
          Get the server's host and port used for the RPC connection.
 String getServerId()
          Get the server's id field used for storing authentication tickets.
 int getSeverityCode(Map<String,Object> map)
           
 String getTicketsFilePath()
          Return the Perforce authentication tickets file path.
 String getTrust()
          Return the fingerprint for the Perforce SSL connection.
 String getTrustFilePath()
          Return the Perforce trust file path.
 List<Fingerprint> getTrusts()
          List all fingerprints in the trust file.
 List<Fingerprint> getTrusts(TrustOptions opts)
          List all fingerprints or replacements in the trust file.
protected  String getUserForEnv()
           
 ServerStatus init(String host, int port, Properties props)
          The default init sets up things like host names, etc., and fails if we can't establish some pretty basic things at connect time.
 ServerStatus init(String host, int port, Properties props, UsageOptions opts)
          Convenience method for init(host, port, props, opts, secure).
 ServerStatus init(String host, int port, Properties props, UsageOptions opts, boolean secure)
          Convenience method for init(host, port, props, opts, secure, null).
 boolean isAuthFail(String errStr)
           
 boolean isInfoMessage(Map<String,Object> map)
           
 boolean isLoginNotRequired(String msgStr)
           
protected  boolean isRelaxCmdNameValidationChecks()
           
 Fingerprint loadFingerprint(String serverIpPort, String fingerprintUser)
          Get the p4trust entry value for the server IP and port based upon a search of either the file found at PropertyDefs.TRUST_PATH_KEY_SHORT_FORM, PropertyDefs.TRUST_PATH_KEY, the P4TRUST environment variable or the standard p4trust file location for the current OS.
 Fingerprint[] loadFingerprints()
          Get the p4trust entries from the file found at PropertyDefs.TRUST_PATH_KEY_SHORT_FORM, PropertyDefs.TRUST_PATH_KEY, the P4TRUST environment variable or the standard p4trust file location for the current OS.
 String loadTicket(String serverId)
          Get the p4tickets entry value for the current user returned from Server.getUserName() and server address based upon a search of either the file found at PropertyDefs.TICKET_PATH_KEY_SHORT_FORM, PropertyDefs.TICKET_PATH_KEY, the P4TICKETS environment variable or the standard p4tickets file location for the current OS.
protected  void processCmdCallbacks(int cmdCallBackKey, long timeTaken, List<Map<String,Object>> resultMaps)
           
 String removeTrust()
          Remove the fingerprint for the Perforce SSL connection.
 String removeTrust(TrustOptions opts)
          Remove the fingerprint or replacement for the Perforce SSL connection.
 void saveCurrentTicket()
          Save current ticket returned from Server.getAuthTicket().
 void saveFingerprint(String serverIpPort, String fingerprintUser, String fingerprintValue)
          Save specified fingerprint value as associate with this server's address.
 void saveTicket(String ticketValue)
          Save specified auth ticket value as associate with this server's address and configured user returned from Server.getUserName().
 void saveTicket(String userName, String ticketValue)
          Save specified auth ticket value as associate with this server's address and user name from the userName parameter.
 void setApplicationName(String applicationName)
           
 void setAuthTicket(String userName, String authTicket)
          Set the server's Perforce authentication ticket for the specified user to the passed-in string.
 void setClientApiLevel(int clientApiLevel)
           
 void setPerfMonitor(PerformanceMonitor perfMonitor)
           
protected  void setRelaxCmdNameValidationChecks(boolean relaxCmdNameValidationChecks)
           
 void setRpcServerAddress(IServerAddress rpcServerAddress)
          Set the server's address for the RPC connection.
 void setSecretKey(String secretKey)
           
 void setSecretKey(String userName, String secretKey)
           
 void setServerId(String serverId)
          Set the server's id field used for storing authentication tickets.
 void setTicketsFilePath(String ticketsFilePath)
          Set the Perforce authentication tickets file path.
 void setTrustFilePath(String trustFilePath)
          Set the Perforce trust file path.
 boolean supportsSmartMove()
          Return true IFF the underlying Perforce server supports the new 2009.1 and later "smart move" command.
protected  boolean useTags(String cmdName, String[] cmdArgs, Map<String,Object> inMap, boolean isStreamCmd)
          Allow for per-command use of tags or not.
protected  boolean writeInPlace(String cmdName)
          Return true iff we should be performing server -> client file write I/O operations in place for this command.
 
Methods inherited from class com.perforce.p4java.impl.mapbased.server.Server
changePassword, createBranchSpec, createClient, createDepot, createJob, createLabel, createProtectionEntries, createStream, createTriggerEntries, createUser, createUser, createUserGroup, createUserGroup, deleteBranchSpec, deleteBranchSpec, deleteClient, deleteClient, deleteCounter, deleteDepot, deleteJob, deleteKey, deleteLabel, deleteLabel, deletePendingChangelist, deletePendingChangelist, deleteProperty, deleteStream, deleteUser, deleteUser, deleteUserGroup, deleteUserGroup, duplicateRevisions, execInputStringMapCmd, execInputStringMapCmdList, execInputStringMapCmdList, execInputStringStreamCmd, execInputStringStreamingMapCmd, execInputStringStreamingMapComd, execMapCmd, execMapCmd, execMapCmdList, execMapCmdList, execMapCmdList, execQuietMapCmd, execQuietMapCmdList, execQuietStreamCmd, execStreamCmd, execStreamCmd, execStreamCmd, execStreamingMapCommand, fixJobs, fixJobs, getAuthTicket, getBranchSpec, getBranchSpec, getBranchSpecs, getBranchSpecs, getChangelist, getChangelist, getChangelistDiffs, getChangelistDiffs, getChangelistDiffsStream, getChangelistFiles, getChangelists, getChangelists, getChangelists, getCharsetName, getClient, getClient, getClientName, getClients, getClients, getClientTemplate, getClientTemplate, getClientTemplate, getCounter, getCounter, getCounters, getCounters, getCounters, getCurrentClient, getDbSchema, getDefaultP4TicketsFile, getDefaultP4TrustFile, getDepot, getDepotFiles, getDepotFiles, getDepots, getDirectories, getDirectories, getDiskSpace, getExportRecords, getExportRecords, getExtendedFiles, getExtendedFiles, getFileAnnotations, getFileAnnotations, getFileContents, getFileContents, getFileDiffs, getFileDiffs, getFileDiffsStream, getFileSizes, getFixes, getFixList, getIgnoreFileName, getInfoServerAddress, getInterchanges, getInterchanges, getInterchanges, getInterchanges, getJob, getJobs, getJobs, getJobSpec, getKey, getKeys, getKnownCharsets, getLabel, getLabels, getLabels, getLoginStatus, getLogTail, getMatchingLines, getMatchingLines, getOpenedFiles, getOpenedFiles, getPreferredPathArray, getPreferredPathArray, getProperties, getProperty, getProtectionEntries, getProtectionEntries, getProtectionsTable, getRandomInt, getReviewChangelists, getReviews, getReviews, getRevisionHistory, getRevisionHistory, getServerFileDiffs, getServerInfo, getServerProcesses, getServerProcesses, getServerVersion, getServerVersionNumber, getShelvedFiles, getSSOCallback, getSSOKey, getStatus, getStream, getStream, getStreamingExportRecords, getStreamIntegrationStatus, getStreams, getSubmittedIntegrations, getSubmittedIntegrations, getTriggerEntries, getTriggersTable, getUsageOptions, getUser, getUserGroup, getUserGroups, getUserGroups, getUserName, getUsers, getUsers, getWorkingDirectory, guardNull, handleErrorStr, handleFileErrorStr, handleFileReturn, handleFileReturn, handleIntegrationFileReturn, handleIntegrationFileReturn, isCaseSensitive, isConnected, isDontWriteTicket, isEnableProgress, isEnableTracking, isNonCheckedSyncs, isQuietMode, isRunningOnWindows, isSecure, isUnicode, journalWait, login, login, login, login, login, logout, logout, moveFile, moveFile, obliterateFiles, parseVersionString, populatePathArray, processInterchangeMaps, registerCallback, registerProgressCallback, registerSSOCallback, reload, renameUser, searchJobs, setAuthTicket, setCharsetName, setClientName, setCounter, setCounter, setCurrentClient, setEnableProgress, setEnableTracking, setFileAttributes, setFileAttributes, setIgnoreFileName, setKey, setNonCheckedSyncs, setProperty, setQuietMode, setSecure, setServerConfigurationValue, setUsageOptions, setUserName, setWorkingDirectory, showServerConfiguration, supportsUnicode, switchClientView, switchStreamView, tagFiles, tagFiles, unload, updateBranchSpec, updateClient, updateClient, updateClient, updateJob, updateLabel, updateProtectionEntries, updateStream, updateTriggerEntries, updateUser, updateUser, updateUserGroup, updateUserGroup, verifyFiles
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.perforce.p4java.impl.mapbased.server.IServerControl
init
 

Field Detail

IMPL_TYPE

public static final IServerImplMetadata.ImplType IMPL_TYPE
The implementation type of this implementation.


DEFAULT_PROG_NAME

public static final String DEFAULT_PROG_NAME
The default string sent to the Perforce server in the protocol command defining the client's program name. This can be set with the IServer interface.

See Also:
Constant Field Values

DEFAULT_PROG_VERSION

public static final String DEFAULT_PROG_VERSION
The default string sent to the Perforce server in the protocol command defining the client's program version. This can be set with the IServer interface.

See Also:
Constant Field Values

DEFAULT_CLIENT_API_LEVEL

public static final int DEFAULT_CLIENT_API_LEVEL
Default Perforce client API level; 78 represents 2015.1 capabilities. Don't change this unless you know what you're doing. Note that this is a default for most commands; some commands dynamically bump up the level for the command's duration.

See Also:
Constant Field Values

DEFAULT_SERVER_API_LEVEL

public static final int DEFAULT_SERVER_API_LEVEL
Default Perforce server API level; 99999 apparently means "whatever...". Don't change this unless you know what you're doing.

See Also:
Constant Field Values

RPC_TAGS_USED

public static final boolean RPC_TAGS_USED
Signifies whether or not we use tagged output. Don't change this unless you like weird incomprehensible errors and days of debugging.

See Also:
Constant Field Values

RPC_ENABLE_STREAMS

public static final boolean RPC_ENABLE_STREAMS
Signifies whether or not the client is capable of handling streams.

See Also:
Constant Field Values

RPC_ENV_CWD_KEY

public static final String RPC_ENV_CWD_KEY
The system properties key for the JVM's current directory.

See Also:
Constant Field Values

RPC_ENV_OS_NAME_KEY

public static final String RPC_ENV_OS_NAME_KEY
The system properties key for the OS name.

See Also:
Constant Field Values

RPC_ENV_WINDOWS_PREFIX

public static final String RPC_ENV_WINDOWS_PREFIX
RPC_ENV_OS_NAME_KEY property value prefix for Windows systems.

See Also:
Constant Field Values

RPC_ENV_WINDOWS_SPEC

public static final String RPC_ENV_WINDOWS_SPEC
What we use in the RPC environment packet to signal to the Perforce server that we're a Windows box.

See Also:
Constant Field Values

RPC_ENV_UNIX_SPEC

public static final String RPC_ENV_UNIX_SPEC
What we use in the RPC environment packet to signal to the Perforce server that we're a NON-Windows box.

See Also:
Constant Field Values

RPC_ENV_NOCLIENT_SPEC

public static final String RPC_ENV_NOCLIENT_SPEC
What we use in the RPC environment packet to signal to the Perforce server that we don't have a client set yet or don't know what it is.

See Also:
Constant Field Values

RPC_ENV_NOHOST_SPEC

public static final String RPC_ENV_NOHOST_SPEC
What we use in the RPC environment packet to signal to the Perforce server that we don't have a hostname set yet or don't know what it is.

See Also:
Constant Field Values

RPC_ENV_NOUSER_SPEC

public static final String RPC_ENV_NOUSER_SPEC
What we use in the RPC environment packet to signal to the Perforce server that we don't have a client set yet or don't know what it is.

See Also:
Constant Field Values

TRACE_PREFIX

public static final String TRACE_PREFIX
What we use as a P4JTracer trace prefix for methods here.

See Also:
Constant Field Values

RPC_TMP_OUTFILE_STREAM_KEY

public static final String RPC_TMP_OUTFILE_STREAM_KEY
Used to key temporary output streams in the command environment's state map for things like getFileContents(), etc., using the execStreamCmd method(s).

See Also:
Constant Field Values

RPC_TMP_CONVERTER_KEY

public static final String RPC_TMP_CONVERTER_KEY
Use to key converter to use out of state map

See Also:
Constant Field Values

localHostName

protected String localHostName

clientApiLevel

protected int clientApiLevel

serverApiLevel

protected int serverApiLevel

applicationName

protected String applicationName

connectionStart

protected long connectionStart

serverProtocolMap

protected Map<String,Object> serverProtocolMap

serverStats

protected ServerStats serverStats

serverId

protected String serverId

secretKeys

protected Map<String,String> secretKeys

clientTrust

protected ClientTrust clientTrust

ticketsFilePath

protected String ticketsFilePath

trustFilePath

protected String trustFilePath

authCounter

protected RpcUserAuthCounter authCounter

rpcServerAddress

protected IServerAddress rpcServerAddress

cmdMapArgs

protected Map<String,Object> cmdMapArgs
The RPC command args before the function name (i.e. "tag")


relaxCmdNameValidationChecks

protected boolean relaxCmdNameValidationChecks
If true, relax the command name validation checks done in the RPC layer. This is dangerous, and any use of this should only be done if you know what you're doing and you're able to deal with the consequences (which won't be spelled out here).

Constructor Detail

RpcServer

public RpcServer()
Method Detail

init

public ServerStatus init(String host,
                         int port,
                         Properties props)
                  throws ConfigException,
                         ConnectionException
The default init sets up things like host names, etc., and fails if we can't establish some pretty basic things at connect time. Does not attempt to actually connect to the target Perforce server -- this is left for the connect() call, below.

Specified by:
init in interface IServerControl
Overrides:
init in class Server
Parameters:
host - the Perforce server hostname or IP address as passed in to the factory method
port - the Perforce server port number as passed in to the factory method
Returns:
the resulting status; should be ACTIVE unless otherwise specified
Throws:
ConfigException - if there's something wrong with the specified configuration or associated config files, etc.
ConnectionException - if the server is unreachable on initialization, and that unreachability is serious and unrecoverable (there are implementations that don't really do connections per se, so they may not consider this an error or even try connecting during initialisation).
See Also:
Server.init(java.lang.String, int, java.util.Properties)

init

public ServerStatus init(String host,
                         int port,
                         Properties props,
                         UsageOptions opts)
                  throws ConfigException,
                         ConnectionException
Description copied from interface: IServerControl
Convenience method for init(host, port, props, opts, secure). See init's main Javadoc for full documentation.

Specified by:
init in interface IServerControl
Overrides:
init in class Server
Parameters:
host - the Perforce server hostname or IP address as passed in to the factory method
port - the Perforce server port number as passed in to the factory method
props - the properties passed in to the factory method
opts - the UsageOptions object to be associated with the server object; if null, the server should construct a new default UsageOptions object.
Returns:
the resulting status; should be ACTIVE unless otherwise specified
Throws:
ConfigException - if there's something wrong with the specified configuration or associated config files, etc.
ConnectionException - if the server is unreachable on initialization, and that unreachability is serious and unrecoverable (there are implementations that don't really do connections per se, so they may not consider this an error or even try connecting during initialisation).
See Also:
IServerControl.init(java.lang.String, int, java.util.Properties, com.perforce.p4java.option.UsageOptions)

init

public ServerStatus init(String host,
                         int port,
                         Properties props,
                         UsageOptions opts,
                         boolean secure)
                  throws ConfigException,
                         ConnectionException
Description copied from interface: IServerControl
Convenience method for init(host, port, props, opts, secure, null). See init's main Javadoc for full documentation.

Specified by:
init in interface IServerControl
Overrides:
init in class Server
Parameters:
host - the Perforce server hostname or IP address as passed in to the factory method
port - the Perforce server port number as passed in to the factory method
props - the properties passed in to the factory method
opts - the UsageOptions object to be associated with the server object; if null, the server should construct a new default UsageOptions object.
Returns:
the resulting status; should be ACTIVE unless otherwise specified
Throws:
ConfigException - if there's something wrong with the specified configuration or associated config files, etc.
ConnectionException - if the server is unreachable on initialization, and that unreachability is serious and unrecoverable (there are implementations that don't really do connections per se, so they may not consider this an error or even try connecting during initialisation).
See Also:
IServerControl.init(java.lang.String, int, java.util.Properties, com.perforce.p4java.option.UsageOptions, boolean)

checkFingerprint

protected void checkFingerprint(RpcConnection rpcConnection)
                         throws ConnectionException
Check the fingerprint of the Perforce server SSL connection

Throws:
ConnectionException

connect

public void connect()
             throws ConnectionException,
                    AccessException,
                    RequestException,
                    ConfigException
Try to establish an actual RPC connection to the target Perforce server. Most of the actual setup work is done in the RpcConnection and RpcPacketDispatcher constructors, but associated gubbins such as auto login, etc., are done in the superclass.

Specified by:
connect in interface IServer
Overrides:
connect in class Server
Throws:
ConnectionException - if the Perforce server is unreachable or is not connected.
AccessException - if the Perforce server denies access to the caller
RequestException - if the Perforce server encounters an error during its processing of the request
ConfigException - if local I/O exception occurs
See Also:
Server.connect()

disconnect

public void disconnect()
                throws ConnectionException,
                       AccessException
Try to cleanly disconnect from the Perforce server at the other end of the current connection (with the emphasis on "cleanly"). This should theoretically include sending a release2 message, but we don't always get the chance to do that.

Specified by:
disconnect in interface IServer
Overrides:
disconnect in class Server
Throws:
ConnectionException
AccessException
See Also:
Server.disconnect()

supportsSmartMove

public boolean supportsSmartMove()
                          throws ConnectionException,
                                 RequestException,
                                 AccessException
Description copied from interface: IServer
Return true IFF the underlying Perforce server supports the new 2009.1 and later "smart move" command. Note that this returns whether the server can support moves only at the time the server is first created; it's entirely possible for the underlying server to change versions, etc., under the user in the meanitme or over time. In any case, if you do try to run a move command on such a server, the results will be safe, if not entirely what you expected. As of 2010.2 it also possible for the server to be configured to disable the move command, in which case this function will return false.

Returns:
true iff the server supports the smart move command.
Throws:
ConnectionException - if the Perforce server is unreachable or is not connected.
RequestException - if the Perforce server encounters an error during its processing of the request
AccessException - if the Perforce server denies access to the caller
See Also:
IServer.supportsSmartMove()

getErrorOrInfoStr

public String getErrorOrInfoStr(Map<String,Object> map)
Description copied from interface: IOptionsServer
Gets the info/warning/error/fatal message from the passed-in Perforce command results map. If no info/warning/error/fatal message found in the results map it returns null.

Note that the minimum severity code is MessageSeverityCode.E_INFO. Therefore, only message with severity code >= MessageSeverityCode.E_INFO will be returned.

RPC impl errors come across the wire as a map in the form usually like this:

 fmt0=Access for user '%user%' has not been enabled by 'p4 protect'.,
 func=client-Message, user=nouser, code0=822483067
 
Note that the code0 entry will be used to get the severity level; the fmt0 entry contains the message.

Specified by:
getErrorOrInfoStr in interface IOptionsServer
Overrides:
getErrorOrInfoStr in class Server
Parameters:
map - Perforce command results map
Returns:
possibly-null info/warning/error/fatal string
See Also:
IOptionsServer.getErrorOrInfoStr(java.util.Map)

isInfoMessage

public boolean isInfoMessage(Map<String,Object> map)
Specified by:
isInfoMessage in class Server

getSeverityCode

public int getSeverityCode(Map<String,Object> map)
Specified by:
getSeverityCode in class Server

getGenericCode

protected int getGenericCode(Map<String,Object> map)
Specified by:
getGenericCode in class Server

getErrorStr

public String getErrorStr(Map<String,Object> map)
RPC impl errors come across the wire as a map in the form usually like this:
 fmt0=Access for user '%user%' has not been enabled by 'p4 protect'.,
 func=client-Message, user=nouser, code0=822483067
 
With tags being used for non-error payloads, we can just basically pick up the presence of the code0 entry; if it's there, use fmt0 as the format and the other args as appropriate...

FIXME: work with multiple code/fmt sets... -- HR.

Specified by:
getErrorStr in interface IOptionsServer
Overrides:
getErrorStr in class Server
Parameters:
map - Perforce command results map
Returns:
possibly-null error/fatal string
See Also:
IOptionsServer.getErrorStr(java.util.Map)

getInfoStr

public String getInfoStr(Map<String,Object> map)
Description copied from interface: IOptionsServer
Gets the info message from the passed-in Perforce command results map. If no info message found in the results map it returns null.

Note that the severity code is MessageSeverityCode.E_INFO. Therefore, only message with severity code = MessageSeverityCode.E_INFO will be returned.

RPC impl errors come across the wire as a map in the form usually like this:

 fmt0=Access for user '%user%' has not been enabled by 'p4 protect'.,
 func=client-Message, user=nouser, code0=822483067
 
Note that the code0 entry will be used to get the severity level; the fmt0 entry contains the message.

Specified by:
getInfoStr in interface IOptionsServer
Overrides:
getInfoStr in class Server
Parameters:
map - Perforce command results map
Returns:
possibly-null info string
See Also:
IOptionsServer.getInfoStr(java.util.Map)

isAuthFail

public boolean isAuthFail(String errStr)
Specified by:
isAuthFail in class Server
See Also:
Server.isAuthFail(java.lang.String)

isLoginNotRequired

public boolean isLoginNotRequired(String msgStr)
Specified by:
isLoginNotRequired in class Server
See Also:
Server.isLoginNotRequired(java.lang.String)

getClientApiLevel

public int getClientApiLevel()

setClientApiLevel

public void setClientApiLevel(int clientApiLevel)

getApplicationName

public String getApplicationName()

setApplicationName

public void setApplicationName(String applicationName)

getPerfMonitor

public PerformanceMonitor getPerfMonitor()

setPerfMonitor

public void setPerfMonitor(PerformanceMonitor perfMonitor)

getOsTypeForEnv

protected String getOsTypeForEnv()

getLanguageForEnv

protected String getLanguageForEnv()

getClientNameForEnv

protected String getClientNameForEnv()

getHostForEnv

protected String getHostForEnv()

getUserForEnv

protected String getUserForEnv()

processCmdCallbacks

protected void processCmdCallbacks(int cmdCallBackKey,
                                   long timeTaken,
                                   List<Map<String,Object>> resultMaps)

saveCurrentTicket

public void saveCurrentTicket()
                       throws P4JavaException
Save current ticket returned from Server.getAuthTicket().

Throws:
P4JavaException
See Also:
saveTicket(String)

saveTicket

public void saveTicket(String ticketValue)
                throws ConfigException
Save specified auth ticket value as associate with this server's address and configured user returned from Server.getUserName(). This will attempt to write an entry to the p4tickets file either specified as the P4TICKETS environment variable or at the OS specific default location. If the ticket value is null then the current entry in the will be cleared.

Parameters:
ticketValue -
Throws:
ConfigException

saveTicket

public void saveTicket(String userName,
                       String ticketValue)
                throws ConfigException
Save specified auth ticket value as associate with this server's address and user name from the userName parameter. This will attempt to write an entry to the p4tickets file either specified as the P4TICKETS environment variable or at the OS specific default location. If the ticket value is null then the current entry will be cleared.

Parameters:
userName -
ticketValue -
Throws:
ConfigException

loadTicket

public String loadTicket(String serverId)
Get the p4tickets entry value for the current user returned from Server.getUserName() and server address based upon a search of either the file found at PropertyDefs.TICKET_PATH_KEY_SHORT_FORM, PropertyDefs.TICKET_PATH_KEY, the P4TICKETS environment variable or the standard p4tickets file location for the current OS. Will return null if not found or if an error occurred attempt to lookup the value.

Parameters:
serverId -
Returns:
- ticket value to get used for Server.setAuthTicket(String) or null if not found.

saveFingerprint

public void saveFingerprint(String serverIpPort,
                            String fingerprintUser,
                            String fingerprintValue)
                     throws ConfigException
Save specified fingerprint value as associate with this server's address. This will attempt to write an entry to the p4trust file either specified as the P4TRUST environment variable or at the OS specific default location. If the fingerprint value is null then the current entry will be cleared.

Parameters:
rpcConnection -
fingerprintValue -
Throws:
ConfigException

loadFingerprint

public Fingerprint loadFingerprint(String serverIpPort,
                                   String fingerprintUser)
Get the p4trust entry value for the server IP and port based upon a search of either the file found at PropertyDefs.TRUST_PATH_KEY_SHORT_FORM, PropertyDefs.TRUST_PATH_KEY, the P4TRUST environment variable or the standard p4trust file location for the current OS. Will return null if not found or if an error occurred attempt to lookup the value.

Parameters:
serverIpPort -
Returns:
- fingerprint or null if not found.

loadFingerprints

public Fingerprint[] loadFingerprints()
Get the p4trust entries from the file found at PropertyDefs.TRUST_PATH_KEY_SHORT_FORM, PropertyDefs.TRUST_PATH_KEY, the P4TRUST environment variable or the standard p4trust file location for the current OS. Will return null if nothing found or if an error occurred attempt to lookup the entries.

Returns:
- list of fingerprints or null if nothing found.

getTrust

public String getTrust()
                throws P4JavaException
Description copied from interface: IOptionsServer
Return the fingerprint for the Perforce SSL connection.

Note that this fingerprint is generated from the connection, it may not be the same as the one (if any) stored in the trust file.

Specified by:
getTrust in interface IOptionsServer
Specified by:
getTrust in class Server
Returns:
possibly-null fingerprint for the Perforce SSL connection.
Throws:
P4JavaException - if an error occurs processing this method and its parameters.
See Also:
Server.getTrust()

addTrust

public String addTrust(TrustOptions opts)
                throws P4JavaException
Description copied from interface: IOptionsServer
Approve and add the fingerprint for the Perforce SSL connection. The fingerprint or replacement will be stored in the trust file. If the attribute TrustOptions.isReplacement() is true, then the replacement fingerprint will be stored. Otherwise, the normal fingerprint is stored.

Note that an exception would be thrown if there is an identity change detected. If you want to trust the new key use the 'force' option.

Specified by:
addTrust in interface IOptionsServer
Specified by:
addTrust in class Server
Parameters:
opts - TrustOptions object describing optional parameters; if null, no options are set.
Returns:
non-null result message string from the trust operation; this may include the fingerprint for the Perforce server public key.
Throws:
P4JavaException - if an error occurs processing this method and its parameters.
See Also:
Server.addTrust(com.perforce.p4java.option.server.TrustOptions)

addTrust

public String addTrust(String fingerprintValue)
                throws P4JavaException
Description copied from interface: IOptionsServer
Approve and add the specified fingerprint for the Perforce SSL connection. The fingerprint will be stored in the trust file.

Specified by:
addTrust in interface IOptionsServer
Specified by:
addTrust in class Server
Parameters:
fingerprintValue - non-null fingerprint value to be added.
Returns:
non-null result message string from the trust operation; this may include the fingerprint for the Perforce server public key.
Throws:
P4JavaException - if an error occurs processing this method and its parameters.
See Also:
Server.addTrust(java.lang.String)

addTrust

public String addTrust(String fingerprintValue,
                       TrustOptions opts)
                throws P4JavaException
Description copied from interface: IOptionsServer
Approve and add the specified fingerprint or replacement for the Perforce SSL connection. The fingerprint or replacement will be stored in the trust file. If the attribute TrustOptions.isReplacement() is true, then the replacement fingerprint will be stored. Otherwise, the normal fingerprint is stored.

Specified by:
addTrust in interface IOptionsServer
Specified by:
addTrust in class Server
Parameters:
fingerprintValue - non-null fingerprint value to be added.
opts - TrustOptions object describing optional parameters; if null, no options are set.
Returns:
non-null result message string from the trust operation; this may include the fingerprint for the Perforce server public key.
Throws:
P4JavaException - if an error occurs processing this method and its parameters.
See Also:
com.perforce.p4java.impl.mapbased.server.Server#addTrust(com.perforce.p4java.option.server.TrustOptions, java.lang.String)

removeTrust

public String removeTrust()
                   throws P4JavaException
Description copied from interface: IOptionsServer
Remove the fingerprint for the Perforce SSL connection. The fingerprint will removed from the trust file.

Specified by:
removeTrust in interface IOptionsServer
Specified by:
removeTrust in class Server
Returns:
non-null result message string from the trust operation; this may include the fingerprint for the Perforce server public key.
Throws:
P4JavaException - if an error occurs processing this method and its parameters.
See Also:
Server.removeTrust()

removeTrust

public String removeTrust(TrustOptions opts)
                   throws P4JavaException
Description copied from interface: IOptionsServer
Remove the fingerprint or replacement for the Perforce SSL connection. The fingerprint or replacement will removed from the trust file. If the attribute TrustOptions.isReplacement() is true, then the replacement fingerprint will be removed. Otherwise the normal fingerprint is removed.

Specified by:
removeTrust in interface IOptionsServer
Specified by:
removeTrust in class Server
Parameters:
opts - TrustOptions object describing optional parameters; if null, no options are set.
Returns:
non-null result message string from the trust operation; this may include the fingerprint for the Perforce server public key.
Throws:
P4JavaException - if an error occurs processing this method and its parameters.
See Also:
Server.removeTrust(com.perforce.p4java.option.server.TrustOptions)

getTrusts

public List<Fingerprint> getTrusts()
                            throws P4JavaException
Description copied from interface: IOptionsServer
List all fingerprints in the trust file.

Specified by:
getTrusts in interface IOptionsServer
Specified by:
getTrusts in class Server
Returns:
non-null list of known fingerprints in the trust file.
Throws:
P4JavaException - if an error occurs processing this method and its parameters.
See Also:
Server.getTrusts()

getTrusts

public List<Fingerprint> getTrusts(TrustOptions opts)
                            throws P4JavaException
Description copied from interface: IOptionsServer
List all fingerprints or replacements in the trust file. If the attribute TrustOptions.isReplacement() is true, then replacement fingerprints will be returned. Otherwise, normal fingerprints are returned.

Specified by:
getTrusts in interface IOptionsServer
Specified by:
getTrusts in class Server
Parameters:
opts - TrustOptions object describing optional parameters; if null, no options are set.
Returns:
non-null list of fingerprints in the trust file.
Throws:
P4JavaException - if an error occurs processing this method and its parameters.
See Also:
Server.getTrusts(com.perforce.p4java.option.server.TrustOptions)

setServerId

public void setServerId(String serverId)
Set the server's id field used for storing authentication tickets. The id specified here will be used when saving ticket values to a p4 tickets file. This field should only be set to the server id returned as part of a server message.

Parameters:
serverId -

getServerId

public String getServerId()
Get the server's id field used for storing authentication tickets. This id should only be used as a server address portion for entries in a p4 tickets file.

Returns:
- possibly null server id

writeInPlace

protected boolean writeInPlace(String cmdName)
Return true iff we should be performing server -> client file write I/O operations in place for this command.

See PropertyDefs.WRITE_IN_PLACE_KEY javadoc for the semantics of this.

Parameters:
cmdName - non-null command command name string
Returns:
true iff we should do a sync in place

getSecretKey

public String getSecretKey()

setSecretKey

public void setSecretKey(String secretKey)

getSecretKey

public String getSecretKey(String userName)

setSecretKey

public void setSecretKey(String userName,
                         String secretKey)

isRelaxCmdNameValidationChecks

protected boolean isRelaxCmdNameValidationChecks()

setRelaxCmdNameValidationChecks

protected void setRelaxCmdNameValidationChecks(boolean relaxCmdNameValidationChecks)

getRpcPacketFieldRule

protected RpcPacketFieldRule getRpcPacketFieldRule(Map<String,Object> inMap,
                                                   CmdSpec cmdSpec)
Get the RPC packet field rule for skipping the charset conversion of a range of RPC packet fields; leave the values as bytes.

Note: currently only supporting the "export" command.


setAuthTicket

public void setAuthTicket(String userName,
                          String authTicket)
Description copied from interface: IOptionsServer
Set the server's Perforce authentication ticket for the specified user to the passed-in string.

Specified by:
setAuthTicket in interface IOptionsServer
Specified by:
setAuthTicket in class Server
Parameters:
userName - non-null Perforce user name
authTicket - possibly-null Perforce authentication ticket
See Also:
Server.setAuthTicket(java.lang.String, java.lang.String)

getAuthTicket

public String getAuthTicket(String userName)
Description copied from interface: IOptionsServer
Return the Perforce authentication ticket for specified user.

Specified by:
getAuthTicket in interface IOptionsServer
Specified by:
getAuthTicket in class Server
Parameters:
userName - non-null Perforce user name
Returns:
possibly-null Perforce authentication ticket
See Also:
Server.getAuthTicket(java.lang.String)

setTicketsFilePath

public void setTicketsFilePath(String ticketsFilePath)
Description copied from interface: IOptionsServer
Set the Perforce authentication tickets file path.

Specified by:
setTicketsFilePath in interface IOptionsServer
Specified by:
setTicketsFilePath in class Server
Parameters:
ticketsFilePath - non-null Perforce auth tickets file path
See Also:
Server.setTicketsFilePath(java.lang.String)

getTicketsFilePath

public String getTicketsFilePath()
Description copied from interface: IOptionsServer
Return the Perforce authentication tickets file path.

Specified by:
getTicketsFilePath in interface IOptionsServer
Specified by:
getTicketsFilePath in class Server
Returns:
possibly-null Perforce auth tickets file path
See Also:
Server.getTicketsFilePath()

setTrustFilePath

public void setTrustFilePath(String trustFilePath)
Description copied from interface: IOptionsServer
Set the Perforce trust file path.

Specified by:
setTrustFilePath in interface IOptionsServer
Specified by:
setTrustFilePath in class Server
Parameters:
trustFilePath - non-null Perforce trust file path
See Also:
Server.setTrustFilePath(java.lang.String)

getTrustFilePath

public String getTrustFilePath()
Description copied from interface: IOptionsServer
Return the Perforce trust file path.

Specified by:
getTrustFilePath in interface IOptionsServer
Specified by:
getTrustFilePath in class Server
Returns:
possibly-null Perforce trust file path
See Also:
Server.getTrustFilePath()

composeAuthTicketEntryKey

protected String composeAuthTicketEntryKey(String userName,
                                           String serverAddress)
Compose the key for an auth ticket entry


getServerAddress

public String getServerAddress()
Get the server's address field used for storing authentication tickets.

Returns:
- possibly null server address

getServerHostPort

public String getServerHostPort()
Get the server's host and port used for the RPC connection.

Returns:
- possibly null server host and port

useTags

protected boolean useTags(String cmdName,
                          String[] cmdArgs,
                          Map<String,Object> inMap,
                          boolean isStreamCmd)
Allow for per-command use of tags or not. Currently has limited use (only a few commands are anomalous as far as we can tell), but may find more uses generally with experience.

. This is normally used on a per-command (OneShot RPC server) basis. In order to use this on a per-session (NTS RPC server) implementation you must resend the RPC protocol, if the 'useTags' state has changed, prior to sending the command.


getAuthCounter

public RpcUserAuthCounter getAuthCounter()
Get the RPC user authentication counter.

Returns:
RPC user authentication counter

getRpcServerAddress

public IServerAddress getRpcServerAddress()
Get the server's address for the RPC connection.

Returns:
possibly-null RPC server address

setRpcServerAddress

public void setRpcServerAddress(IServerAddress rpcServerAddress)
Set the server's address for the RPC connection.

Parameters:
rpcServerAddress - RPC server address


Copyright © 2015 Perforce Software. All Rights Reserved.