Class ParametersChecker
java.lang.Object
io.clonecloudstore.common.standard.system.ParametersChecker
Checker for Parameters
Can be used for String (testing also emptiness) and for general Object.
For null String only, use the special method.
Can be used for String (testing also emptiness) and for general Object.
For null String only, use the special method.
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionstatic void
checkParameter
(String errorMessage, Object... parameters) Check if any parameter are null or empty and if so, throw an CcsInvalidArgumentRuntimeExceptionstatic void
checkParameterNullOnly
(String errorMessage, Object... parameters) Check if any parameter are null and if so, throw an CcsInvalidArgumentRuntimeExceptionstatic void
checkSanity
(Object... objects) Check external argument (null is considered as correct)static void
checkSanityBucketName
(String bucketName) Check external argument to avoid Path Traversal attackstatic void
checkSanityMap
(Map<String, String> map) Check external argument to avoid Path Traversal attackstatic void
checkSanityMapKey
(String mapKey) Check external argument to avoid Path Traversal attackstatic void
checkSanityObjectName
(String objectName) Check external argument to avoid Path Traversal attackstatic void
checkSanityString
(String value) Check external argument to avoid Path Traversal attackstatic void
checkSanityString
(String... strings) Check external argument (null is considered as correct)static void
checkSanityUri
(String uri) Check external argument to avoid Path Traversal attackstatic void
checkValue
(String name, long variable, long minValue) Check if an integer parameter is greater or equals to minValuestatic String
getSanitizedBucketName
(String bucketName) Check external argument to avoid Path Traversal attackstatic String
getSanitizedName
(String objectName) static String
getSanitizedObjectName
(String objectName) Check external argument to avoid Path Traversal attackstatic boolean
hasNotEmpty
(Object... parameters) Check if at least one parameter is not null and not empty and if so, return truestatic boolean
Check if any parameter are null or empty and if so, return truestatic boolean
isNotEmpty
(Object... parameters) Check if any parameter are null or empty and if so, return falsestatic String
urlDecodePathParam
(String path)
-
Field Details
-
BUCKET_LENGTH
public static final int BUCKET_LENGTH- See Also:
-
OBJECT_LENGTH
public static final int OBJECT_LENGTH- See Also:
-
SITE_LENGTH
public static final int SITE_LENGTH- See Also:
-
INVALID_INPUT
- See Also:
-
INVALID_URI
- See Also:
-
-
Method Details
-
checkParameter
public static void checkParameter(String errorMessage, Object... parameters) throws CcsInvalidArgumentRuntimeException Check if any parameter are null or empty and if so, throw an CcsInvalidArgumentRuntimeException- Parameters:
errorMessage
- the error messageparameters
- parameters to be checked- Throws:
CcsInvalidArgumentRuntimeException
- if null or empty
-
checkParameterNullOnly
public static void checkParameterNullOnly(String errorMessage, Object... parameters) throws CcsInvalidArgumentRuntimeException Check if any parameter are null and if so, throw an CcsInvalidArgumentRuntimeException- Parameters:
errorMessage
- the error messageparameters
- parameters to be checked- Throws:
CcsInvalidArgumentRuntimeException
- if null
-
checkValue
public static void checkValue(String name, long variable, long minValue) throws CcsInvalidArgumentRuntimeException Check if an integer parameter is greater or equals to minValue- Parameters:
name
- name of the variablevariable
- the value of variable to checkminValue
- the min value- Throws:
CcsInvalidArgumentRuntimeException
- if invalid
-
checkSanityString
Check external argument to avoid Path Traversal attack- Parameters:
value
- to check- Throws:
CcsInvalidArgumentRuntimeException
- if invalid
-
checkSanity
Check external argument (null is considered as correct)- Parameters:
objects
- the array to check (toString)- Throws:
CcsInvalidArgumentRuntimeException
- if invalid
-
checkSanityString
Check external argument (null is considered as correct)- Parameters:
strings
- the String array to check- Throws:
CcsInvalidArgumentRuntimeException
- if invalid
-
checkSanityBucketName
public static void checkSanityBucketName(String bucketName) throws CcsInvalidArgumentRuntimeException Check external argument to avoid Path Traversal attack- Parameters:
bucketName
- to check- Throws:
CcsInvalidArgumentRuntimeException
- if invalid
-
checkSanityObjectName
public static void checkSanityObjectName(String objectName) throws CcsInvalidArgumentRuntimeException Check external argument to avoid Path Traversal attack- Parameters:
objectName
- to check- Throws:
CcsInvalidArgumentRuntimeException
- if invalid
-
checkSanityMapKey
Check external argument to avoid Path Traversal attack- Parameters:
mapKey
- for Map key check- Throws:
CcsInvalidArgumentRuntimeException
- if invalid
-
checkSanityMap
Check external argument to avoid Path Traversal attack- Parameters:
map
- where key and value are to be checked- Throws:
CcsInvalidArgumentRuntimeException
- if invalid
-
isEmpty
Check if any parameter are null or empty and if so, return true- Parameters:
parameters
- set of parameters- Returns:
- True if any is null or empty or containing only spaces
-
isNotEmpty
Check if any parameter are null or empty and if so, return false- Parameters:
parameters
- set of parameters- Returns:
- True if not null and not empty neither containing only spaces
-
hasNotEmpty
Check if at least one parameter is not null and not empty and if so, return true- Parameters:
parameters
- set of parameters- Returns:
- True if at least one is not null and not empty neither containing only spaces
-
checkSanityUri
Check external argument to avoid Path Traversal attack- Parameters:
uri
- to check- Throws:
CcsInvalidArgumentRuntimeException
- if invalid
-
getSanitizedName
- Returns:
- the sanitized name
-
getSanitizedBucketName
public static String getSanitizedBucketName(String bucketName) throws CcsInvalidArgumentRuntimeException Check external argument to avoid Path Traversal attack- Parameters:
bucketName
- to check- Returns:
- the sanitized name
- Throws:
CcsInvalidArgumentRuntimeException
- if invalid
-
getSanitizedObjectName
public static String getSanitizedObjectName(String objectName) throws CcsInvalidArgumentRuntimeException Check external argument to avoid Path Traversal attack- Parameters:
objectName
- to check- Returns:
- the sanitized name
- Throws:
CcsInvalidArgumentRuntimeException
- if invalid
-
urlDecodePathParam
-