Interface IServer

    • Field Detail

      • ATTRIBUTE_STREAM_MAP_KEY

        static final java.lang.String ATTRIBUTE_STREAM_MAP_KEY
        See Also:
        Constant Field Values
      • IN_MAP_USE_TAGS_KEY

        static final java.lang.String IN_MAP_USE_TAGS_KEY
        Property key for overriding the default tagged/non-tagged behavior of a command. This is a per-command property, set on a command's "inMap".
        See Also:
        Constant Field Values
    • Method Detail

      • getServerVersion

        int getServerVersion()
                      throws ConnectionException
        Try to get the Perforce server version. This is likely to be the first time actual connectivity is tested for the server... Since this is called before we know much about the state or type of the Perforce server, we do virtually no real error checking or recovery -- we either get a suitable response and dig out the server version, or we just leave things alone.

        NOTE: has the side effect of setting the server impl's serverVersion field.

        Returns:
        version
        Throws:
        ConnectionException - on error
      • connect

        void connect()
              throws ConnectionException,
                     AccessException,
                     RequestException,
                     ConfigException
        Connect to the Perforce server associated with this server object.

        This method's detailed semantics depend on the underlying transport implementation, but in general, it's intended to be called before any attempt is made to issue a command to the associated Perforce server. It's also intended to be called after any (intentional or accidental) disconnect.

        Note that certain implementations may try to request a client, etc., on connection (in response to property values passed in through the URL, etc.), which may cause a RequestException to be generated.

        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
      • createUserGroup

        java.lang.String createUserGroup​(IUserGroup group)
                                  throws ConnectionException,
                                         RequestException,
                                         AccessException
        Create a new Perforce user group on the Perforce server.
        Parameters:
        group - non-null IUserGroup to be created.
        Returns:
        possibly-null status message string as returned from the server
        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.
      • deleteUserGroup

        java.lang.String deleteUserGroup​(IUserGroup group)
                                  throws ConnectionException,
                                         RequestException,
                                         AccessException
        Delete a Perforce user group from the Perforce server.
        Parameters:
        group - non-null group to be deleted.
        Returns:
        possibly-null status message string as returned from the server
        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.
      • disconnect

        void disconnect()
                 throws ConnectionException,
                        AccessException
        Disconnect from this Perforce server. Does not affect the current IServer's current user, password, or client settings, but if you later reconnect to the same Perforce server, you may also need to re-login.

        This command should be run at the point at which this server is not going to be used any more, and attempts to disconnect from the associated server. "Disconnect" here has different meanings according to the underlying transport mechanism, but in practice it will mean that attempting to use this server object to issue Perforce commands will fail, usually with a ConnectionException exception.

        Throws:
        ConnectionException - on error
        AccessException - on error
      • execInputStringMapCmd

        java.util.Map<java.lang.String,​java.lang.Object>[] execInputStringMapCmd​(java.lang.String cmdName,
                                                                                       java.lang.String[] cmdArgs,
                                                                                       java.lang.String inString)
                                                                                throws P4JavaException
        Issue an arbitrary P4Java command to the Perforce server and return the results as a map.

        This method is intended for low-level commands in the spirit and format of the p4 command line interpreter, and offers a simple way to issue commands to the associated Perforce server without the overhead of the more abstract Java interfaces and methods.

        No guidance is given here on the format of the returned map; however, it produces the same output as the p4 command line interpreter in -G (Python map) mode.

        Note that this method does not allow you to set "usage" options for the command; these may be added later. Note also that although option arguments passed to this method must be in a form recognized by the p4 command line interpreter, that does not mean the method is being implemented by the interpreter -- the actual implementation depends on the options used to get the server object in the first place from the server factory.

        Parameters:
        cmdName - the command to be issued; must be non-null, and correspond to a Perforce command recognized by P4Java and defined in CmdSpec.
        cmdArgs - the array of command arguments (options and file arguments, etc.) to be sent to the Perforce server. These must be in the form used by the corresponding p4 command line interpreter. Ignored if null.
        inString - an optional string to be sent to the server as standard input unchanged (this must be in the format expected by the server, typically as required when using the "-i" flag to the p4 command line app for the same command). You must remember to issue the relevant command-specific option to enable this if needed.
        Returns:
        a non-null Java Map of results; these results are as returned from issuing the command using the -G option with the p4 command line interpreter.
        Throws:
        P4JavaException - if an error occurs processing this method and its parameters
        Since:
        2011.1
      • execInputStringStreamingMapComd

        @Deprecated
        void execInputStringStreamingMapComd​(java.lang.String cmdName,
                                             java.lang.String[] cmdArgs,
                                             java.lang.String inString,
                                             IStreamingCallback callback,
                                             int key)
                                      throws P4JavaException
        Issue a streaming map command to the Perforce server, using an optional string for any input expected by the server (such as label or job specs, etc.).

        Streaming commands allow users to get each result from a suitably-issued command as it comes in from the server, rather than waiting for the entire command method to complete (and getting the results back as a completed List or Map or whatever).

        The results are sent to the user using the IStreamingCallback handleResult method; see the IStreamingCallback Javadoc for details. The payload passed to handleResult is usually the raw map gathered together deep in the RPC protocol layer, and the user is assumed to have the knowledge and technology to be able to parse it and use it suitably in much the same way as a user unpacks or processes the results from the other low-level exec methods like execMapCommand.

        NOTE: 'streaming' here has nothing at all to do with Perforce 'streams', which are (or will be) implemented elsewhere.

        Parameters:
        cmdName - the command to be issued; must be non-null, and correspond to a Perforce command recognized by P4Java and defined in CmdSpec.
        cmdArgs - the array of command arguments (options and file arguments, etc.) to be sent to the Perforce server. These must be in the form used by the corresponding p4 command line interpreter. Ignored if null.
        inString - an optional string to be sent to the server as standard input unchanged (this must be in the format expected by the server, typically as required when using the "-i" flag to the p4 command line app for the same command). You must remember to issue the relevant command-specific option to enable this if needed.
        callback - a non-null IStreamingCallback to be used to process the incoming results.
        key - an opaque integer key that is passed to the IStreamingCallback callback methods to identify the action as being associated with this specific call.
        Throws:
        P4JavaException - if an error occurs processing this method and its parameters.
        Since:
        2011.1
      • execMapCmd

        java.util.Map<java.lang.String,​java.lang.Object>[] execMapCmd​(java.lang.String cmdName,
                                                                            java.lang.String[] cmdArgs,
                                                                            java.util.Map<java.lang.String,​java.lang.Object> inMap)
                                                                     throws ConnectionException,
                                                                            RequestException,
                                                                            AccessException
        Issue an arbitrary P4Java command to the Perforce server and return the results as a map.

        This method is intended for low-level commands in the spirit and format of the p4 command line interpreter, and offers a simple way to issue commands to the associated Perforce server without the overhead of the more abstract Java interfaces and methods.

        No guidance is given here on the format of the returned map; however, it produces the same output as the p4 command line interpreter in -G (Python map) mode.

        Note that this method does not allow you to set "usage" options for the command; these may be added later. Note also that although option arguments passed to this method must be in a form recognized by the p4 command line interpreter, that does not mean the method is being implemented by the interpreter -- the actual implementation depends on the options used to get the server object in the first place from the server factory.

        Parameters:
        cmdName - the command to be issued; must be non-null, and correspond to a Perforce command recognized by P4Java and defined in CmdSpec.
        cmdArgs - the array of command arguments (options and file arguments, etc.) to be sent to the Perforce server. These must be in the form used by the corresponding p4 command line interpreter. Ignored if null.
        inMap - an optional map to be sent to the server as standard input, using the Python map format (-G) form. You must remember to issue the relevant command-specific option to enable this if needed.
        Returns:
        a non-null Java Map of results; these results are as returned from issuing the command using the -G option with the p4 command line interpreter.
        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
      • execQuietMapCmd

        java.util.Map<java.lang.String,​java.lang.Object>[] execQuietMapCmd​(java.lang.String cmdName,
                                                                                 java.lang.String[] cmdArgs,
                                                                                 java.util.Map<java.lang.String,​java.lang.Object> inMap)
                                                                          throws ConnectionException,
                                                                                 RequestException,
                                                                                 AccessException
        Issue an arbitrary P4Java command to the Perforce server and return the results as a map without invoking any command callbacks.

        Basically equivalent to execMapCmd with temporary disabling of any ICommandCallback calls and / or listeners; this turns out to be useful for various reasons we won't go into here...

        Parameters:
        cmdName - the command to be issued; must be non-null, and correspond to a Perforce command recognized by P4Java and defined in CmdSpec.
        cmdArgs - the array of command arguments (options and file arguments, etc.) to be sent to the Perforce server. These must be in the form used by the corresponding p4 command line interpreter. Ignored if null.
        inMap - an optional map to be sent to the server as standard input, using the Python map format (-G) form. You must remember to issue the relevant command-specific option to enable this if needed.
        Returns:
        a non-null Java Map of results; these results are as returned from issuing the command using the -G option with the p4 command line interpreter.
        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
      • execQuietStreamCmd

        java.io.InputStream execQuietStreamCmd​(java.lang.String cmdName,
                                               java.lang.String[] cmdArgs)
                                        throws ConnectionException,
                                               RequestException,
                                               AccessException
        Issue an arbitrary P4Java command to the Perforce server and get the results as a stream without invoking any command callbacks.

        Basically equivalent to execStreamCmd with temporary disabling of any ICommandCallback calls and / or listeners; this turns out to be useful for various reasons we won't go into here...

        Parameters:
        cmdName - the command to be issued; must be non-null, and correspond to a Perforce command recognized by P4Java and defined in CmdSpec.
        cmdArgs - the array of command arguments (options and file arguments, etc.) to be sent to the Perforce server. These must be in the form used by the corresponding p4 command line interpreter. Ignored if null.
        Returns:
        an InputStream on the command output. This will never be null, but it may be empty. You must properly close this stream after use or temporary files may be left lying around the VM's java.io.tmpdir area.
        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
      • execStreamingMapCommand

        void execStreamingMapCommand​(java.lang.String cmdName,
                                     java.lang.String[] cmdArgs,
                                     java.util.Map<java.lang.String,​java.lang.Object> inMap,
                                     IStreamingCallback callback,
                                     int key)
                              throws P4JavaException
        Issue a streaming map command to the Perforce server, using an optional map for any input expected by the server (such as label or job specs, etc.).

        Streaming commands allow users to get each result from a suitably-issued command as it comes in from the server, rather than waiting for the entire command method to complete (and getting the results back as a completed List or Map or whatever).

        The results are sent to the user using the IStreamingCallback handleResult method; see the IStreamingCallback Javadoc for details. The payload passed to handleResult is usually the raw map gathered together deep in the RPC protocol layer, and the user is assumed to have the knowledge and technology to be able to parse it and use it suitably in much the same way as a user unpacks or processes the results from the other low-level exec methods like execMapCommand.

        NOTE: 'streaming' here has nothing at all to do with Perforce 'streams', which are (or will be) implemented elsewhere.

        Parameters:
        cmdName - the command to be issued; must be non-null, and correspond to a Perforce command recognized by P4Java and defined in CmdSpec.
        cmdArgs - the array of command arguments (options and file arguments, etc.) to be sent to the Perforce server. These must be in the form used by the corresponding p4 command line interpreter. Ignored if null.
        inMap - an optional map to be sent to the server as standard input, using the Python map format (-G) form. You must remember to issue the relevant command-specific option to enable this if needed.
        callback - a non-null IStreamingCallback to be used to process the incoming results.
        key - an opaque integer key that is passed to the IStreamingCallback callback methods to identify the action as being associated with this specific call.
        Throws:
        P4JavaException - if an error occurs processing this method and its parameters.
        Since:
        2011.1
      • execStreamingMapCommand

        void execStreamingMapCommand​(java.lang.String cmdName,
                                     java.lang.String[] cmdArgs,
                                     java.util.Map<java.lang.String,​java.lang.Object> inMap,
                                     IStreamingCallback callback,
                                     int key,
                                     IParallelCallback parallelCallback)
                              throws P4JavaException
        Issue a parallelised streaming map command to the Perforce server, using an optional map for any input expected by the server (such as label or job specs, etc.).

        Streaming commands allow users to get each result from a suitably-issued command as it comes in from the server, rather than waiting for the entire command method to complete (and getting the results back as a completed List or Map or whatever).

        The results are sent to the user using the IStreamingCallback handleResult method; see the IStreamingCallback Javadoc for details. The payload passed to handleResult is usually the raw map gathered together deep in the RPC protocol layer, and the user is assumed to have the knowledge and technology to be able to parse it and use it suitably in much the same way as a user unpacks or processes the results from the other low-level exec methods like execMapCommand.

        NOTE: 'streaming' here has nothing at all to do with Perforce 'streams', which are (or will be) implemented elsewhere.

        Parameters:
        cmdName - the command to be issued; must be non-null, and correspond to a Perforce command recognized by P4Java and defined in CmdSpec.
        cmdArgs - the array of command arguments (options and file arguments, etc.) to be sent to the Perforce server. These must be in the form used by the corresponding p4 command line interpreter. Ignored if null.
        inMap - an optional map to be sent to the server as standard input, using the Python map format (-G) form. You must remember to issue the relevant command-specific option to enable this if needed.
        callback - a non-null IStreamingCallback to be used to process the incoming results.
        key - an opaque integer key that is passed to the IStreamingCallback callback methods to identify the action as being associated with this specific call.
        parallelCallback - IParallelCallback used to parallelise the task
        Throws:
        P4JavaException - on error
        Since:
        2017.1
      • getAuthTicket

        java.lang.String getAuthTicket()
        Return the current Perforce authentication ticket being used by this server, if any. This ticket is not always guaranteed to be currently valid, so reuse should be done carefully.
        Returns:
        possibly-null Perforce authentication ticket
      • getAuthTicket

        java.lang.String getAuthTicket​(java.lang.String userName)
        Return the Perforce authentication ticket for specified user.
        Parameters:
        userName - non-null Perforce user name
        Returns:
        possibly-null Perforce authentication ticket
        Since:
        2011.2
      • getAuthTicket

        java.lang.String getAuthTicket​(java.lang.String userName,
                                       java.lang.String serverId)
        Return the Perforce authentication ticket for specified user.
        Parameters:
        userName - non-null Perforce user name
        serverId - non-null Perforce server's auth.id/IP:port
        Returns:
        possibly-null Perforce authentication ticket
        Since:
        2021.2
      • isLoginNotRequired

        boolean isLoginNotRequired​(java.lang.String msgStr)
      • getChangelistDiffs

        java.io.InputStream getChangelistDiffs​(int id,
                                               DiffType diffType)
                                        throws ConnectionException,
                                               RequestException,
                                               AccessException
        Get an InputStream onto the file diffs associated with a specific submitted changelist. This method (like the similar "p4 describe" command) will not return diffs for pending changelists.

        This is one of the guaranteed "live" method on this interface, and will return the diff output as it exists when called (rather than when the underlying implementation object was created). This can be an expensive method to evaluate, and can generate reams and reams (and reams) of output, so don't use it willy-nilly.

        Note that unlike the corresponding command-line command, which keeps going in the face of errors by moving on to the next file (or whatever), any errors encountered in this method will cause an exception from this method at the first error, so plan accordingly....

        Parameters:
        id - the ID of the target changelist
        diffType - if non-null, describes which type of diff to perform.
        Returns:
        InputStream onto the diff stream. Note that while this stream will not be null, it may be empty
        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
      • getCommitFiles

        java.util.List<IFileSpec> getCommitFiles​(java.lang.String repo,
                                                 java.lang.String commit)
                                          throws ConnectionException,
                                                 RequestException,
                                                 AccessException
        Parameters:
        repo - the graph repo
        commit - the commit SHA
        Returns:
        non-null (but possibly empty) list of files associated with the commit.
        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
      • getCharsetName

        java.lang.String getCharsetName()
        Get the current charset name for the server connection. May be null, in which case there is no associated character set.
        Returns:
        charset name associated with this server; may be null.
      • getGenericCode

        int getGenericCode​(java.util.Map<java.lang.String,​java.lang.Object> map)
      • getInterchanges

        java.util.List<IChangelist> getInterchanges​(IFileSpec fromFile,
                                                    IFileSpec toFile,
                                                    boolean showFiles,
                                                    boolean longDesc,
                                                    int maxChangelistId)
                                             throws ConnectionException,
                                                    RequestException,
                                                    AccessException
        Get a list of changes and / or associated files not yet integrated (unsupported). Corresponds fairly closely to the p4 interchanges command for filespecs.

        Note that if showFiles is true, the returned files are attached to the associated changelist, and can be retrieved using the getFiles(false) method -- and note that if you call getFiles(true) you will get a refreshed list of all files associated with the changelist, which is probably different from the list associated with the integration.

        Note also that if there are no qualifying changes, this method will return an empty list rather than throw an exception; this behaviour is different to that seen with the p4 command line which will throw an exception.

        Parameters:
        fromFile - non-null from-file specification.
        toFile - non-null to-file specification.
        showFiles - if true, show the individual files that would require integration.
        longDesc - if true, return a long description in the changelist.
        maxChangelistId - if greater than zero, only consider integration history from changelists at or below the given number
        Returns:
        non-null (but possibly empty) list of qualifying changelists. Note that the changelists returned here may not have all fields set (only description, ID, date, user, and client are known to be properly set by the server for this 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
      • getInterchanges

        java.util.List<IChangelist> getInterchanges​(java.lang.String branchSpecName,
                                                    java.util.List<IFileSpec> fromFileList,
                                                    java.util.List<IFileSpec> toFileList,
                                                    boolean showFiles,
                                                    boolean longDesc,
                                                    int maxChangelistId,
                                                    boolean reverseMapping,
                                                    boolean biDirectional)
                                             throws ConnectionException,
                                                    RequestException,
                                                    AccessException
        Get a list of changes and / or associated files not yet integrated, based on branchspecs (unsupported). Corresponds fairly closely to the p4 interchanges command for branchspecs.

        Note that if showFiles is true, the returned files are attached to the associated changelist, and can be retrieved using the getFiles(false) method -- and note that if you call getFiles(true) you will get a refreshed list of all files associated with the changelist, which is probably different from the list associated with the integration.

        Note also that if there are no qualifying changes, this method will return an empty list rather than throw an exception; this behaviour is different to that seen with the p4 command line which will throw an exception.

        Parameters:
        branchSpecName - non-null, non-empty branch spec name.
        fromFileList - if non-null and not empty, and biDirectional is true, use this as the from file list.
        toFileList - if non-null and not empty, use this as the to file list.
        showFiles - if true, show the individual files that would require integration.
        longDesc - if true, return a long description in the changelist.
        maxChangelistId - if greater than zero, only consider integration
        reverseMapping - if true, reverse the mappings in the branch view, with the target files and source files exchanging place.
        biDirectional - if true, bi-directional option
        Returns:
        non-null (but possibly empty) list of qualifying changelists. Note that the changelists returned here may not have all fields set (only description, ID, date, user, and client are known to be properly set by the server for this 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
      • getKnownCharsets

        java.lang.String[] getKnownCharsets()
        Return an array of strings representing "known" charsets (e.g. "utf8" or "utf32le".

        Note that in this context, "known" simply means that Perforce servers supported by this API can potentially recognize the charset name and (hopefully) act accordingly.

        Charset support in Perforce is described in more detail in the main p4 command documentation; in summary, although the list returned here is comprehensive and quite impressive, unless the Perforce server is actually primed to cope with Unicode (which, by default, they're not), the only charset listed here that will work is "none"; furthermore, actual charset support is somewhat idiosyncratic -- please refer to specific documentation for guidance with this. You probably need to use this method in conjunction with the supportsUnicode() method above.

        Returns:
        a non-null array of strings representing lower-case charset names known to the server.
      • getProperties

        java.util.Properties getProperties()
        Return the Java properties associated with this server. The Properties returned here are the actual properties used in the server and can be updated through this method (i.e. the object is not just a copy). The interpretation of the individual Properties are implementation-specific and not discussed here.
        Returns:
        Properties object; may be empty but will not be null.
      • getServerVersionNumber

        int getServerVersionNumber()
        Get the Perforce version number of the Perforce server associated with this IServer object, if any. This will be in the form 20092 or 20073 (corresponding to 2009.2 and 2007.3 respectively), but the version number will not be available if you're not actually connected to a Perforce server.
        Returns:
        positive integer version number or -1 if not known or unavailable.
      • getSeverityCode

        int getSeverityCode​(java.util.Map<java.lang.String,​java.lang.Object> map)
      • getStatus

        ServerStatus getStatus()
        Return the current status of this server object.
        Returns:
        non-null ServerStatus representing the server status.
      • getUserGroups

        java.util.List<IUserGroup> getUserGroups​(java.lang.String userOrGroupName,
                                                 boolean indirect,
                                                 boolean displayValues,
                                                 int maxGroups)
                                          throws ConnectionException,
                                                 RequestException,
                                                 AccessException
        Get a list of Perforce user groups from the server.

        Note that the Perforce server considers it an error to have both indirect and displayValues parameters set true; this will cause the server to throw a RequestException with an appropriate usage message.

        Parameters:
        userOrGroupName - if non-null, restrict the list to the specified group or username.
        indirect - if true, also displays groups that the specified user or group belongs to indirectly via subgroups.
        displayValues - if true, display the MaxResults, MaxScanRows, MaxLockTime, and Timeout values for the named group.
        maxGroups - if > 0, display only the first m results.
        Returns:
        a non-zero but possibly-empty list of qualifying groups.
        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.
      • getUserName

        java.lang.String getUserName()
        Return the user name currently associated with this server, if any. User names are set using the setUserName method.
        Returns:
        the user name currently associated with this server, if any; null otherwise.
      • getWorkingDirectory

        java.lang.String getWorkingDirectory()
        Get the underlying server's notion of the current working directory. If this method returns null, the server is using the JVM's current working directory, typically available as the System user.dir property.
        Returns:
        current working directory path, or null if not set
      • getCurrentClient

        IClient getCurrentClient()
        Return the Perforce client currently associated with this Perforce server, if any.
        Returns:
        IClient representing the current client, or null if no client associated with this server.
      • isCaseSensitive

        boolean isCaseSensitive()
        Returns whether the Perforce server associated with this IServer object is case sensitive.
        Returns:
        - true if case sensitive, false if case insensitive.
      • isConnected

        boolean isConnected()
        Return true iff and the server object is connected to the associated Perforce server.

        The meaning of "connected" is generally dependent on the underlying transport layer, but in general, if the server is not connected, issuing server commands to the associated Perforce server will fail with a connection exception.

        Returns:
        - true iff connected, false otherwise
      • registerCallback

        ICommandCallback registerCallback​(ICommandCallback callback)
        Register a P4Java command callback with this Perforce server.

        See the ICommandCallback javadocs for callback semantics. Note that only one command callback can be active and registered for a given server at any one time.

        Parameters:
        callback - ICommandCallback object to be registered; if null, command callbacks are disabled.
        Returns:
        the previous command callback, if it existed; null otherwise
      • registerProgressCallback

        IProgressCallback registerProgressCallback​(IProgressCallback callback)
        Register a P4Java command progress callback with this Perforce server.

        See the IProgressCallback javadocs for callback semantics. Note that only one progress callback can be active and registered for a given server at any one time.

        Parameters:
        callback - IProgressCallback object to be registered; if null, progress callbacks are disabled.
        Returns:
        the previous progress callback, if it existed; null otherwise
      • registerSSOCallback

        void registerSSOCallback​(ISSOCallback callback,
                                 java.lang.String ssoKey)
        Register a Perforce Single Sign On (SSO) callback and key for this server.

        See the ISSOCallback Javadoc comments for an explanation of the SSO callback feature; note that only one SSO callback can be active and registered for a given P4Jserver object at any one time.

        Note that SSO callbacks work only with the (default) pure Java (RPC) protocol implementation.

        Parameters:
        callback - ISSOCallback object to be registered; if null, SSO callbacks are disabled.
        ssoKey - opaque string to be passed untouched to the callback; can be null, in which case null is passed in to the callback
      • registerBrowserCallback

        void registerBrowserCallback​(IBrowserCallback browserCallback)
        Register a Perforce browser callback to launch the browser for a given url for this server.

        See the IBrowserCallback Javadoc comments for an explanation of the browser callback feature; note that only one browser callback can be active and registered for a given P4server object at any one time.

        Parameters:
        browserCallback - BrowserCallback object to be registered; if null, browser callbacks are disabled.
      • setAuthTicket

        void setAuthTicket​(java.lang.String authTicket)
        Set the server's Perforce authentication ticket to the passed-in string. If the string is null, auth tickets won't be used when talking to the associated Perforce server; otherwise, the auth ticket will be used to authenticate against the Perforce server for each call to the server.

        No checking is performed on the passed-in ticket, and any changes to existing tickets can cause authentication failures, so you should ensure the passed-in ticket is valid and makes sense for the current context.

        Parameters:
        authTicket - possibly-null Perforce authentication ticket
      • setCurrentServerInfo

        void setCurrentServerInfo​(IServerInfo info)
        Set the server's Info object without calling `p4 info`. Intended to be used for initialising new server connections for parallel threads.
        Parameters:
        info - possibly-null Perforce server information
      • getCurrentServerInfo

        IServerInfo getCurrentServerInfo()
        Get the server's Info object without calling `p4 info`. Intended to be used for initialising new server connections for parallel threads.
        Returns:
        the current server's info (may be null)
      • setCharsetName

        boolean setCharsetName​(java.lang.String charsetName)
                        throws java.nio.charset.UnsupportedCharsetException
        Set the Perforce server's charset to the passed-in charset name. The semantics of this are described in the full Perforce documentation, but note that odd things will happen if the named charset isn't recognized by both the JVM and the Perforce server (i.e. "utf8" works fine, but bizarre variants may not). What constitutes a good charset name, and whether or not the server recognises it, is somewhat fraught and may involve retrieving the unicode counter and using the (printed) list of recognised charsets.
        Parameters:
        charsetName - charset name; if null, resets the charset to "no charset".
        Returns:
        true if the attempt to set the charset name succeeded; false otherwise. False will only be returned if the JVM doesn't support the charset. (an exception will be thrown if the server doesn't recognize it).
        Throws:
        java.nio.charset.UnsupportedCharsetException - if the Perforce server doesn't support or recognize the charset name.
      • setUserName

        void setUserName​(java.lang.String userName)
        Set the Perforce user name to be used with this server. This does not perform any login or checking, just associates a user name with this session. Once set, the user name is used with all commands where it makes sense.

        Note that the auth ticket (if available) for this user will also be set to this server instance.

        Parameters:
        userName - Perforce user name; can be null, which is interpreted as "don't associate a user name with this server".
      • setWorkingDirectory

        void setWorkingDirectory​(java.lang.String dirPath)
        Set the Perforce server's idea of each command's working directory. This affects all commands on this server from this point on, and the passed-in path should be both absolute and valid, otherwise strange errors may appear from the server. If dirPath is null, the Java VM's actual current working directory is used instead (which is almost always a safe option unless you're using Perforce alt roots).

        Note: no checking is done at call time for correctness (or otherwise) of the passed-in path.

        Parameters:
        dirPath - absolute path of directory to be used, or null
      • setClientPath

        void setClientPath​(java.lang.String clientPath)
        Set the Perforce P4CLIENTPATH - directories the client can access.

        A list of directories to which Perforce applications are permitted to write. Any attempt by a Perforce application to access or modify files outside these areas of the filesystem will result in an error message. To specify more than one directory, separate the directories with semicolons.

        Parameters:
        clientPath - client path
      • supportsSmartMove

        boolean supportsSmartMove()
                           throws ConnectionException,
                                  RequestException,
                                  AccessException
        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
      • supportsUnicode

        boolean supportsUnicode()
                         throws ConnectionException,
                                RequestException,
                                AccessException
        Return true if the underlying Perforce server supports Unicode (and is connected). In this context "supporting unicode" simply means that the method was able to contact the server and retrieve a "true" unicode-enabled status using the info command.

        Returns:
        true iff the underlying server supports Unicode.
        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
      • updateUserGroup

        java.lang.String updateUserGroup​(IUserGroup group,
                                         boolean updateIfOwner)
                                  throws ConnectionException,
                                         RequestException,
                                         AccessException
        Update a Perforce user group on the Perforce server.
        Parameters:
        group - non-null user group to be updated.
        updateIfOwner - if true, allows a user without 'super' access to modify the group only if that user is an 'owner' of that group.
        Returns:
        possibly-null status message string as returned from the server
        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.