Class ResultMapParser
- java.lang.Object
-
- com.perforce.p4java.impl.mapbased.server.cmd.ResultMapParser
-
public abstract class ResultMapParser extends java.lang.Object
Utility to parse a result map and test for info/error messages etc.
-
-
Field Summary
Fields Modifier and Type Field Description protected static java.lang.String
CORE_AUTH_FAIL_STRING_1
Signals access (login) needed.protected static java.lang.String
CORE_AUTH_FAIL_STRING_2
Signals access (login) needed.protected static java.lang.String
CORE_AUTH_FAIL_STRING_3
Signals ticket has expired.protected static java.lang.String
CORE_AUTH_FAIL_STRING_4
Signals ticket has expired.
-
Constructor Summary
Constructors Constructor Description ResultMapParser()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static java.lang.String
getErrorOrInfoStr(java.util.Map<java.lang.String,java.lang.Object> map)
Gets the info/warning/error/fatal message from the passed-in Perforce command results map.static java.lang.String
getErrorStr(java.util.Map<java.lang.String,java.lang.Object> map)
RPC impl errors come across the wire as a map in the form usually like this:static java.lang.String
getInfoStr(java.util.Map<java.lang.String,java.lang.Object> map)
Gets the info message from the passed-in Perforce command results map.static java.lang.String
getWarningStr(java.util.Map<java.lang.String,java.lang.Object> map)
static boolean
handleErrorOrInfoStr(java.util.Map<java.lang.String,java.lang.Object> map)
Handle error or info str.static boolean
handleErrorStr(java.util.Map<java.lang.String,java.lang.Object> map)
Tests the map for errors and throws an exception if found.static java.lang.String
handleFileErrorStr(java.util.Map<java.lang.String,java.lang.Object> map)
Handle file error str.static boolean
handleWarningStr(java.util.Map<java.lang.String,java.lang.Object> map)
Tests the map for warnings and throws an exception if found.static boolean
isAuthFail(java.lang.String errStr)
Checks to see if an error String is as a result of an auth fail.static boolean
isExistClientOrLabelOrUser(java.util.Map<java.lang.String,java.lang.Object> map)
Unfortunately, the p4 command version returns a valid map for non-existent clients/labels/users; the only way we can detect that the client/label/user doesn't exist is to see if the Update or Access map entries exist -- if they do, the client/label/user is (most likely) a valid client/label/user on this server.static boolean
isInfoMessage(java.util.Map<java.lang.String,java.lang.Object> map)
Checks for a info message.static boolean
isNonExistClientOrLabelOrUser(java.util.Map<java.lang.String,java.lang.Object> map)
Unfortunately, the p4 command version returns a valid map for non-existent clients/labels/users; the only way we can detect that the client/label/user doesn't exist is to see if the Update or Access map entries exist -- if they do, the client/label/user is (most likely) a valid client/label/user on this server.static boolean
isWarningMessage(java.util.Map<java.lang.String,java.lang.Object> map)
Checks for a warning message.static java.util.List<IExtendedFileSpec>
parseCommandResultMapAsExtendedFileSpecs(int id, IServer server, java.util.List<java.util.Map<java.lang.String,java.lang.Object>> resultMaps)
Parses the command result map as file specs.static java.util.List<IFileSpec>
parseCommandResultMapAsFileSpecs(int id, IServer server, java.util.List<java.util.Map<java.lang.String,java.lang.Object>> resultMaps)
Parses the command result map as file specs.static java.lang.String
parseCommandResultMapAsString(java.util.List<java.util.Map<java.lang.String,java.lang.Object>> resultMaps)
Parses the command result map as string.static java.lang.String
parseCommandResultMapIfIsInfoMessageAsString(java.util.List<java.util.Map<java.lang.String,java.lang.Object>> resultMaps)
Parses the command result map to return a String of info messages.static java.util.List<IFileSpec>
parseGraphCommandResultMapAsFileSpecs(IServer server, java.util.List<java.util.Map<java.lang.String,java.lang.Object>> resultMaps)
Parses the graph command result map as file specs.static void
throwRequestExceptionIfErrorMessageFound(java.util.Map<java.lang.String,java.lang.Object> map)
Throw request exception if error message found.
-
-
-
Field Detail
-
CORE_AUTH_FAIL_STRING_1
protected static final java.lang.String CORE_AUTH_FAIL_STRING_1
Signals access (login) needed.- See Also:
- Constant Field Values
-
CORE_AUTH_FAIL_STRING_2
protected static final java.lang.String CORE_AUTH_FAIL_STRING_2
Signals access (login) needed.- See Also:
- Constant Field Values
-
CORE_AUTH_FAIL_STRING_3
protected static final java.lang.String CORE_AUTH_FAIL_STRING_3
Signals ticket has expired.- See Also:
- Constant Field Values
-
CORE_AUTH_FAIL_STRING_4
protected static final java.lang.String CORE_AUTH_FAIL_STRING_4
Signals ticket has expired.- See Also:
- Constant Field Values
-
-
Method Detail
-
parseCommandResultMapIfIsInfoMessageAsString
public static java.lang.String parseCommandResultMapIfIsInfoMessageAsString(@Nonnull java.util.List<java.util.Map<java.lang.String,java.lang.Object>> resultMaps) throws AccessException, RequestException
Parses the command result map to return a String of info messages. The messages are expected to be info and if they are not (i.e. they are error messages) an exception is thrown.- Parameters:
resultMaps
- the result maps- Returns:
- the string
- Throws:
AccessException
- the access exceptionRequestException
- the request exception
-
isInfoMessage
public static boolean isInfoMessage(java.util.Map<java.lang.String,java.lang.Object> map)
Checks for a info message.- Parameters:
map
- the map- Returns:
- true, if info message
-
isWarningMessage
public static boolean isWarningMessage(java.util.Map<java.lang.String,java.lang.Object> map)
Checks for a warning message.- Parameters:
map
- the map- Returns:
- true, if warning message
-
handleErrorStr
public static boolean handleErrorStr(java.util.Map<java.lang.String,java.lang.Object> map) throws RequestException, AccessException
Tests the map for errors and throws an exception if found.- Parameters:
map
- the map- Returns:
- true, if successful
- Throws:
RequestException
- the request exceptionAccessException
- the access exception
-
handleWarningStr
public static boolean handleWarningStr(java.util.Map<java.lang.String,java.lang.Object> map) throws RequestException, AccessException
Tests the map for warnings and throws an exception if found.- Parameters:
map
- the map- Returns:
- true, if successful
- Throws:
RequestException
- the request exceptionAccessException
- the access exception
-
getErrorStr
public static java.lang.String getErrorStr(java.util.Map<java.lang.String,java.lang.Object> map)
RPC impl errors come across the wire as a map in the form usually like this:
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...fmt0=Access for user '%user%' has not been enabled by 'p4 protect'., func=client-Message, user=nouser, code0=822483067
FIXME: work with multiple code/fmt sets... -- HR.
- Parameters:
map
- the map- Returns:
- the error string if found.
-
getWarningStr
public static java.lang.String getWarningStr(java.util.Map<java.lang.String,java.lang.Object> map)
-
isAuthFail
public static boolean isAuthFail(java.lang.String errStr)
Checks to see if an error String is as a result of an auth fail.- Parameters:
errStr
- the err str- Returns:
- true, if is auth fail
-
getInfoStr
public static java.lang.String getInfoStr(java.util.Map<java.lang.String,java.lang.Object> map)
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:
Note that the code0 entry will be used to get the severity level; the fmt0 entry contains the message.fmt0=Access for user '%user%' has not been enabled by 'p4 protect'., func=client-Message, user=nouser, code0=822483067
- Parameters:
map
- Perforce command results map- Returns:
- possibly-null info string
- Since:
- 2011.2
-
getErrorOrInfoStr
public static java.lang.String getErrorOrInfoStr(java.util.Map<java.lang.String,java.lang.Object> map)
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:
Note that the code0 entry will be used to get the severity level; the fmt0 entry contains the message.fmt0=Access for user '%user%' has not been enabled by 'p4 protect'., func=client-Message, user=nouser, code0=822483067
- Parameters:
map
- Perforce command results map- Returns:
- possibly-null info/warning/error/fatal string
- Since:
- 2011.2
-
throwRequestExceptionIfErrorMessageFound
public static void throwRequestExceptionIfErrorMessageFound(java.util.Map<java.lang.String,java.lang.Object> map) throws RequestException
Throw request exception if error message found.- Parameters:
map
- the map- Throws:
RequestException
- the request exception
-
handleErrorOrInfoStr
public static boolean handleErrorOrInfoStr(java.util.Map<java.lang.String,java.lang.Object> map) throws RequestException, AccessException
Handle error or info str.- Parameters:
map
- the map- Returns:
- true, if successful
- Throws:
RequestException
- the request exceptionAccessException
- the access exception
-
parseCommandResultMapAsString
public static java.lang.String parseCommandResultMapAsString(@Nonnull java.util.List<java.util.Map<java.lang.String,java.lang.Object>> resultMaps) throws AccessException, RequestException
Parses the command result map as string.- Parameters:
resultMaps
- the result maps- Returns:
- the string
- Throws:
AccessException
- the access exceptionRequestException
- the request exception
-
parseCommandResultMapAsFileSpecs
public static java.util.List<IFileSpec> parseCommandResultMapAsFileSpecs(int id, IServer server, java.util.List<java.util.Map<java.lang.String,java.lang.Object>> resultMaps)
Parses the command result map as file specs.- Parameters:
id
- the idserver
- the serverresultMaps
- the result maps- Returns:
- the list
-
parseCommandResultMapAsExtendedFileSpecs
public static java.util.List<IExtendedFileSpec> parseCommandResultMapAsExtendedFileSpecs(int id, IServer server, java.util.List<java.util.Map<java.lang.String,java.lang.Object>> resultMaps)
Parses the command result map as file specs.- Parameters:
id
- the idserver
- the serverresultMaps
- the result maps- Returns:
- the list
-
parseGraphCommandResultMapAsFileSpecs
public static java.util.List<IFileSpec> parseGraphCommandResultMapAsFileSpecs(IServer server, java.util.List<java.util.Map<java.lang.String,java.lang.Object>> resultMaps)
Parses the graph command result map as file specs.- Parameters:
server
- the serverresultMaps
- the result maps- Returns:
- the list
-
handleFileErrorStr
public static java.lang.String handleFileErrorStr(java.util.Map<java.lang.String,java.lang.Object> map) throws ConnectionException, AccessException
Handle file error str.- Parameters:
map
- the map- Returns:
- the string
- Throws:
ConnectionException
- the connection exceptionAccessException
- the access exception
-
isExistClientOrLabelOrUser
public static boolean isExistClientOrLabelOrUser(java.util.Map<java.lang.String,java.lang.Object> map)
Unfortunately, the p4 command version returns a valid map for non-existent clients/labels/users; the only way we can detect that the client/label/user doesn't exist is to see if the Update or Access map entries exist -- if they do, the client/label/user is (most likely) a valid client/label/user on this server. This seems less than optimal to me... -- HR.- Parameters:
map
- the map- Returns:
- true, if is exist client or label or user
-
isNonExistClientOrLabelOrUser
public static boolean isNonExistClientOrLabelOrUser(java.util.Map<java.lang.String,java.lang.Object> map)
Unfortunately, the p4 command version returns a valid map for non-existent clients/labels/users; the only way we can detect that the client/label/user doesn't exist is to see if the Update or Access map entries exist -- if they do, the client/label/user is (most likely) a valid client/label/user on this server. This seems less than optimal to me... -- HR.- Parameters:
map
- the map- Returns:
- true, if is non exist client or label or user
-
-