List of usage examples for org.apache.commons.lang ObjectUtils toString
public static String toString(Object obj)
Gets the toString
of an Object
returning an empty string ("") if null
input.
ObjectUtils.toString(null) = "" ObjectUtils.toString("") = "" ObjectUtils.toString("bat") = "bat" ObjectUtils.toString(Boolean.TRUE) = "true"
From source file:org.wso2.carbon.apimgt.hostobjects.APIProviderHostObject.java
/** * Evaluate HTTP end-point URI to validate path parameter and query * parameter formats<br>// w w w. jav a 2s .co m * Sample URI format<br> * http[s]//[www.]anyhost[.com][:port]/{uri.var.param}?param1=value¶m2={uri.var.value} * * @param endpointConfig JSON representation of end-point configuration. * @return true if valid URI * @throws APIManagementException If the endpointConfig is invalid or URI is invalid */ private static boolean validateEndpointURI(String endpointConfig) throws APIManagementException { if (endpointConfig != null) { try { JSONParser parser = new JSONParser(); JSONObject jsonObject = (JSONObject) parser.parse(endpointConfig); Object epType = jsonObject.get("endpoint_type"); if (StringUtils.isEmpty(ObjectUtils.toString(epType))) { handleException("No endpoint type defined."); } else if (epType instanceof String && "http".equals(epType)) { // extract production uri from config Object prodEPs = jsonObject.get("production_endpoints"); Object sandEPs = jsonObject.get("sandbox_endpoints"); if (prodEPs == null && sandEPs == null) { handleException( "At least one endpoint from Production Endpoint or Sandbox Endpoint must be defined."); } if (prodEPs instanceof JSONObject) { Object url = ((JSONObject) prodEPs).get("url");//check whether the URL is null or not if (StringUtils.isBlank(ObjectUtils.toString(url))) { handleException("URL of production Endpoint is not defined."); } if (url instanceof String && !isValidURI(url.toString())) { handleException("Invalid Production Endpoint URI. Please refer HTTP Endpoint " + "documentation of the WSO2 ESB for details."); } } // extract sandbox uri from config if (sandEPs instanceof JSONObject) { Object url = ((JSONObject) sandEPs).get("url"); if (StringUtils.isBlank(ObjectUtils.toString(url))) { handleException("URL of sandbox Endpoint is not defined."); } if (url instanceof String && !isValidURI(url.toString())) { handleException("Invalid Sandbox Endpoint URI. Please refer HTTP Endpoint " + "documentation of the WSO2 ESB for details."); } } } } catch (ParseException e) { handleException("Invalid Endpoint config", e); } } return true; }
From source file:org.zaproxy.zap.extension.autoupdate.AutoUpdateAPI.java
private ApiResponseSet<String> addonToSet(AddOn ao) { Map<String, String> map = new HashMap<>(); map.put("id", ao.getId()); map.put("name", ao.getName()); map.put("author", ao.getAuthor()); map.put("changes", ao.getChanges()); map.put("description", ao.getDescription()); map.put("hash", ObjectUtils.toString(ao.getHash())); map.put("infoUrl", ObjectUtils.toString(ao.getInfo())); map.put("sizeInBytes", String.valueOf(ao.getSize())); map.put("status", ao.getStatus().toString()); map.put("url", ObjectUtils.toString(ao.getUrl())); map.put("version", ObjectUtils.toString(ao.getVersion())); return new ApiResponseSet<String>("addon", map); }