Class ResultMapParser
java.lang.Object
com.perforce.p4java.impl.mapbased.server.cmd.ResultMapParser
Utility to parse a result map and test for info/error messages etc.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic StringgetErrorOrInfoStr(Map<String, Object> map) Gets the info/warning/error/fatal message from the passed-in Perforce command results map.static StringgetErrorStr(Map<String, Object> map) RPC impl errors come across the wire as a map in the form usually like this:static StringgetInfoStr(Map<String, Object> map) Gets the info message from the passed-in Perforce command results map.static StringgetWarningStr(Map<String, Object> map) static booleanhandleErrorOrInfoStr(Map<String, Object> map) Handle error or info str.static booleanhandleErrorStr(Map<String, Object> map) Tests the map for errors and throws an exception if found.static StringhandleFileErrorStr(Map<String, Object> map) Handle file error str.static booleanhandleWarningStr(Map<String, Object> map) Tests the map for warnings and throws an exception if found.static booleanisAuthFail(String errStr) Checks to see if an error String is as a result of an auth fail.static booleanUnfortunately, 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 booleanisInfoMessage(Map<String, Object> map) Checks for a info message.static booleanUnfortunately, 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 booleanisWarningMessage(Map<String, Object> map) Checks for a warning message.static List<IExtendedFileSpec>parseCommandResultMapAsExtendedFileSpecs(int id, IServer server, List<Map<String, Object>> resultMaps) Parses the command result map as file specs.Parses the command result map as file specs.static StringparseCommandResultMapAsString(List<Map<String, Object>> resultMaps) Parses the command result map as string.static StringparseCommandResultMapIfIsInfoMessageAsString(List<Map<String, Object>> resultMaps) Parses the command result map to return a String of info messages.Parses the graph command result map as file specs.static voidThrow request exception if error message found.
-
Field Details
-
CORE_AUTH_FAIL_STRING_1
Signals access (login) needed.- See Also:
-
CORE_AUTH_FAIL_STRING_2
Signals access (login) needed.- See Also:
-
CORE_AUTH_FAIL_STRING_3
Signals ticket has expired.- See Also:
-
CORE_AUTH_FAIL_STRING_4
Signals ticket has expired.- See Also:
-
-
Constructor Details
-
ResultMapParser
public ResultMapParser()
-
-
Method Details
-
parseCommandResultMapIfIsInfoMessageAsString
public static String parseCommandResultMapIfIsInfoMessageAsString(@Nonnull List<Map<String, Object>> resultMaps) throws AccessException, RequestExceptionParses 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
Checks for a info message.- Parameters:
map- the map- Returns:
- true, if info message
-
isWarningMessage
Checks for a warning message.- Parameters:
map- the map- Returns:
- true, if warning message
-
handleErrorStr
public static boolean handleErrorStr(Map<String, Object> map) throws RequestException, AccessExceptionTests 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(Map<String, Object> map) throws RequestException, AccessExceptionTests 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
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=822483067FIXME: work with multiple code/fmt sets... -- HR.
- Parameters:
map- the map- Returns:
- the error string if found.
-
getWarningStr
-
isAuthFail
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
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
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(Map<String, Object> map) throws RequestExceptionThrow request exception if error message found.- Parameters:
map- the map- Throws:
RequestException- the request exception
-
handleErrorOrInfoStr
public static boolean handleErrorOrInfoStr(Map<String, Object> map) throws RequestException, AccessExceptionHandle error or info str.- Parameters:
map- the map- Returns:
- true, if successful
- Throws:
RequestException- the request exceptionAccessException- the access exception
-
parseCommandResultMapAsString
public static String parseCommandResultMapAsString(@Nonnull List<Map<String, Object>> resultMaps) throws AccessException, RequestExceptionParses 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 List<IFileSpec> parseCommandResultMapAsFileSpecs(int id, IServer server, List<Map<String, 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 List<IExtendedFileSpec> parseCommandResultMapAsExtendedFileSpecs(int id, IServer server, List<Map<String, 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 List<IFileSpec> parseGraphCommandResultMapAsFileSpecs(IServer server, List<Map<String, Object>> resultMaps) Parses the graph command result map as file specs.- Parameters:
server- the serverresultMaps- the result maps- Returns:
- the list
-
handleFileErrorStr
public static String handleFileErrorStr(Map<String, Object> map) throws ConnectionException, AccessExceptionHandle file error str.- Parameters:
map- the map- Returns:
- the string
- Throws:
ConnectionException- the connection exceptionAccessException- the access exception
-
isExistClientOrLabelOrUser
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
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
-