public static boolean parseBooleanWithDefault(String booleanValue, boolean defaultValue) { if (StringUtilities.isBlank(booleanValue)) { return defaultValue; } else { return Boolean.valueOf(booleanValue); } }
@NotNull public static Proxy getProxy(@NotNull final String proxyHost, final int proxyPort, @NotNull final String proxyUser, @NotNull final String proxyPassword) { if (StringUtilities.isBlank(proxyHost)) { return Proxy.NO_PROXY; } if (StringUtilities.isNotEmpty(proxyUser)) { Authenticator.setDefault(new Authenticator() { @Override public PasswordAuthentication getPasswordAuthentication() { return new PasswordAuthentication(proxyUser, proxyPassword.toCharArray()); } }); } return new Proxy(HTTP, InetSocketAddress.createUnresolved(proxyHost, proxyPort)); }
@NotNull public static Proxy getProxy(@NotNull final String proxyHost, final int proxyPort, @NotNull final String proxyUser, @NotNull final String proxyPassword) { if (StringUtilities.isBlank(proxyHost)) { return Proxy.NO_PROXY; } if (StringUtilities.isNotEmpty(proxyUser)) { Authenticator.setDefault(new Authenticator() { @Override public PasswordAuthentication getPasswordAuthentication() { return new PasswordAuthentication(proxyUser, proxyPassword.toCharArray()); } }); } return new Proxy(HTTP, InetSocketAddress.createUnresolved(proxyHost, proxyPort)); } }
public static void validateEditJsonInputs(String jsonObject, String jsonPath, String action, String name, String value) throws Exception { if (StringUtilities.isBlank(jsonObject)) { throw new Exception("Empty jsonObject provided!"); } if (StringUtilities.isBlank(jsonPath)) { throw new Exception("Empty jsonPath provided!"); } if (StringUtilities.isBlank(action)) { throw new Exception("Empty action provided!"); } final String actionString = action.toLowerCase().trim(); boolean exists = false; String actionEnumValues = ""; for (ActionsEnum actionsEnum : ActionsEnum.values()) { final String actionEnumValue = actionsEnum.getValue(); actionEnumValues += actionEnumValue + " "; if (actionString.equals(actionEnumValue)) { exists = true; } } if (!exists) { throw new Exception("Invalid action provided! Action should be one of the values: " + actionEnumValues); } if (actionString.equals(insert.getValue())) { if (StringUtilities.isBlank(name)) { throw new Exception("Empty name provided for insert action!"); } } checkForNullValue(actionString, value); }
if (StringUtilities.isBlank(array)) { return populateResult(returnResult, new Exception(NOT_A_VALID_JSON_ARRAY_MESSAGE));
if (StringUtilities.isBlank(array1)) { final String exceptionValue = NOT_A_VALID_JSON_ARRAY_MESSAGE + ARRAY1_MESSAGE.replaceFirst("=", EMPTY_STRING); return populateResult(returnResult, exceptionValue, new Exception(exceptionValue)); if (StringUtilities.isBlank(array2)) { final String exceptionValue = NOT_A_VALID_JSON_ARRAY_MESSAGE + ARRAY2_MESSAGE.replaceFirst("=", EMPTY_STRING); return populateResult(returnResult, new Exception(exceptionValue));
final boolean validateValueBoolean = JsonUtils.parseBooleanWithDefault(validateValue, true); if (StringUtilities.isBlank(newPropertyValue)) { final String exceptionValue = "The value for the property " + newPropertyName + " it is not a valid JSON object!"; return populateResult(returnResult, new Exception(exceptionValue));
if (StringUtilities.isBlank(object)) { return populateResult(returnResult, new Exception("Empty object provided!"));