/** * Escape and encode a string regarded as the path and query components of * an URI with the default protocol charset. * * @param unescaped an unescaped string * @return the escaped string * * @throws URIException if the default protocol charset is not supported * * @see URI#getDefaultProtocolCharset * @see #encode */ public static String encodePathQuery(String unescaped) throws URIException { return encodePathQuery(unescaped, URI.getDefaultProtocolCharset()); }
/** * Splits the given string on the first '?' then encodes the first half as a path (ignoring slashes and colons) * and the second half as a query segment (ignoring questionmarks, equals signs, etc...). * * @deprecated Prefer to use {@link HttpEncodingTools#encode(String)} instead for encoding specific * pieces of the URI. This method does not escape certain reserved characters, like '/', ':', '=', and '?'. * As such, this is not safe to use on URIs that may contain these reserved characters in the wrong places. */ @Deprecated public static String encodeUri(String uri) { try { return URIUtil.encodePathQuery(uri); } catch (URIException ex) { throw new EsHadoopIllegalArgumentException("Cannot escape uri [" + uri + "]", ex); } }
public URL createJobUrl(String jobUrl) { try { return new URL(jobUrl + URIUtil.encodePathQuery(API_JSON + TREE_PARAM + BASIC_JOB_INFO)); } catch (Exception ex) { handleException(ex); } return null; }
public URL createBuildUrl(String buildUrl) { try { return new URL(buildUrl + URIUtil.encodePathQuery(API_JSON + TREE_PARAM + BASIC_BUILD_INFO)); } catch (Exception ex) { handleException(ex); } return null; }
public static String encodeUri(String uri) { try { return URIUtil.encodePathQuery(uri); } catch (URIException ex) { throw new EsHadoopIllegalArgumentException("Cannot escape uri" + uri); } }
public URL createBuildsUrl(String buildUrl) { try { return new URL(buildUrl + URIUtil.encodePathQuery(API_JSON + TREE_PARAM + BASIC_BUILDS_INFO)); } catch (Exception ex) { handleException(ex); } return null; }
public URL createRunParameterizedJobUrl(String jobUrl, JenkinsAppSettings configuration, Map<String, String> paramValueMap) { StringBuilder strBuilder = new StringBuilder(String.format("%s?delay=%dsec", PARAMETERIZED_BUILD, configuration.getBuildDelay())); for (Map.Entry<String, String> valueByName : paramValueMap.entrySet()) { strBuilder.append("&").append(valueByName.getKey()).append("=").append(valueByName.getValue()); } try { return new URL(jobUrl + URIUtil.encodePathQuery(strBuilder.toString())); } catch (Exception ex) { handleException(ex); } return null; }
/** * Escape and encode a string regarded as the path and query components of * an URI with the default protocol charset. * * @param unescaped an unescaped string * @return the escaped string * * @throws URIException if the default protocol charset is not supported * * @see URI#getDefaultProtocolCharset * @see #encode */ public static String encodePathQuery(String unescaped) throws URIException { return encodePathQuery(unescaped, URI.getDefaultProtocolCharset()); }
/** * Escape and encode a string regarded as the path and query components of * an URI with the default protocol charset. * * @param unescaped an unescaped string * @return the escaped string * * @throws URIException if the default protocol charset is not supported * * @see URI#getDefaultProtocolCharset * @see #encode */ public static String encodePathQuery(String unescaped) throws URIException { return encodePathQuery(unescaped, URI.getDefaultProtocolCharset()); }
/** * Escape and encode a string regarded as the path and query components of * an URI with the default protocol charset. * * @param unescaped an unescaped string * @return the escaped string * * @throws URIException if the default protocol charset is not supported * * @see URI#getDefaultProtocolCharset * @see #encode */ public static String encodePathQuery(String unescaped) throws URIException { return encodePathQuery(unescaped, URI.getDefaultProtocolCharset()); }
/** * Escape and encode a string regarded as the path and query components of * an URI with the default protocol charset. * * @param unescaped an unescaped string * @return the escaped string * * @throws URIException if the default protocol charset is not supported * * @see URI#getDefaultProtocolCharset * @see #encode */ public static String encodePathQuery(String unescaped) throws URIException { return encodePathQuery(unescaped, URI.getDefaultProtocolCharset()); }
/** * Splits the given string on the first '?' then encodes the first half as a path (ignoring slashes and colons) * and the second half as a query segment (ignoring questionmarks, equals signs, etc...). * * @deprecated Prefer to use {@link HttpEncodingTools#encode(String)} instead for encoding specific * pieces of the URI. This method does not escape certain reserved characters, like '/', ':', '=', and '?'. * As such, this is not safe to use on URIs that may contain these reserved characters in the wrong places. */ @Deprecated public static String encodeUri(String uri) { try { return URIUtil.encodePathQuery(uri); } catch (URIException ex) { throw new EsHadoopIllegalArgumentException("Cannot escape uri [" + uri + "]", ex); } }
/** * Splits the given string on the first '?' then encodes the first half as a path (ignoring slashes and colons) * and the second half as a query segment (ignoring questionmarks, equals signs, etc...). * * @deprecated Prefer to use {@link HttpEncodingTools#encode(String)} instead for encoding specific * pieces of the URI. This method does not escape certain reserved characters, like '/', ':', '=', and '?'. * As such, this is not safe to use on URIs that may contain these reserved characters in the wrong places. */ @Deprecated public static String encodeUri(String uri) { try { return URIUtil.encodePathQuery(uri); } catch (URIException ex) { throw new EsHadoopIllegalArgumentException("Cannot escape uri [" + uri + "]", ex); } }
/** * Splits the given string on the first '?' then encodes the first half as a path (ignoring slashes and colons) * and the second half as a query segment (ignoring questionmarks, equals signs, etc...). * * @deprecated Prefer to use {@link HttpEncodingTools#encode(String)} instead for encoding specific * pieces of the URI. This method does not escape certain reserved characters, like '/', ':', '=', and '?'. * As such, this is not safe to use on URIs that may contain these reserved characters in the wrong places. */ @Deprecated public static String encodeUri(String uri) { try { return URIUtil.encodePathQuery(uri); } catch (URIException ex) { throw new EsHadoopIllegalArgumentException("Cannot escape uri [" + uri + "]", ex); } }
public URL createRunJobUrl(String jobBuildUrl, JenkinsAppSettings configuration) { try { String s = jobBuildUrl + URIUtil.encodePathQuery(String.format("%s?delay=%dsec", BUILD, configuration.getBuildDelay())); return new URL(s); } catch (Exception ex) { handleException(ex); } return null; }
private Object encode(boolean debugOn, String encoding, String value) throws FunctionCallException { if (value == null || "".equals(value)) { if (debugOn) { log.debug("Non empty string value should be provided for encoding"); } return SynapseXPathConstants.NULL_STRING; } String encodedString; try { encodedString = URIUtil.encodePathQuery(value, encoding); } catch (URIException e) { String msg = "Unsupported charset encoding"; log.error(msg, e); throw new FunctionCallException(msg, e); } if (debugOn) { log.debug("Converted string: " + value + " with encoding: " + encoding + " to url encoded value: " + encodedString); } return encodedString; } }
public URL createJenkinsWorkspaceUrl(JenkinsAppSettings configuration) { try { return new URL(URIUtil.encodePathQuery(configuration.getServerUrl() + API_JSON + TREE_PARAM + BASIC_JENKINS_INFO)); } catch (Exception ex) { handleException(ex); } return null; }
public URL createViewUrl(JenkinsPlateform jenkinsPlateform, String viewUrl) { String basicViewInfo = BASIC_VIEW_INFO; if (JenkinsPlateform.CLOUDBEES.equals(jenkinsPlateform)) { basicViewInfo = CLOUDBEES_VIEW_INFO; } try { return new URL(viewUrl + URIUtil.encodePathQuery(API_JSON + TREE_PARAM + basicViewInfo)); } catch (Exception ex) { handleException(ex); } return null; }
/** * Get data as a String for the GET method for the given path. * * @param path the server relative path of the resource to get * @return the contents of the given resource as a string * @exception HttpException * @exception IOException */ public String getMethodDataAsString(String path) throws HttpException, IOException { setClient(); GetMethod method = new GetMethod(URIUtil.encodePathQuery(path)); generateTransactionHeader(method); int statusCode = client.executeMethod(method); setStatusCode(statusCode); return method.getResponseBodyAsString(); }
/** * Execute the HEAD method for the given path. * * @param path the server relative path of the resource to request * @return true if the method is succeeded. * @exception HttpException * @exception IOException */ public boolean headMethod(String path) throws HttpException, IOException { setClient(); HeadMethod method = new HeadMethod(URIUtil.encodePathQuery(path)); generateTransactionHeader(method); int statusCode = client.executeMethod(method); setStatusCode(statusCode); return (statusCode >= 200 && statusCode < 300) ? true : false; }