List of usage examples for org.apache.commons.httpclient.util URIUtil encode
public static String encode(String unescaped, BitSet allowed) throws URIException
From source file:com.assemblade.client.Views.java
public View getViewByName(String name) throws ClientException { try {/*from ww w .ja v a 2 s .c o m*/ return get("/views/name/" + URIUtil.encode(name, URI.allowed_fragment), new TypeReference<View>() { }); } catch (URIException e) { throw new CallFailedException("Failed to encode request path", e); } }
From source file:org.apache.airavata.gfac.bes.utils.URIUtils.java
public static String encodeAuthority(String uri) throws URIException { int start = uri.indexOf("//"); if (start == -1) return uri; start++;/*ww w . ja v a 2 s . c o m*/ int end = uri.indexOf("/", start + 1); if (end == -1) end = uri.indexOf("?", start + 1); if (end == -1) end = uri.indexOf("#", start + 1); if (end == -1) end = uri.length(); String before = uri.substring(0, start + 1); String authority = uri.substring(start + 1, end); String after = uri.substring(end); authority = URIUtil.encode(authority, URI.allowed_authority); return before + authority + after; }
From source file:org.apache.airavata.gfac.bes.utils.URIUtils.java
public static String encodePath(String uri) throws URIException { int doubleSlashIndex = uri.indexOf("//"); boolean hasAuthority = doubleSlashIndex >= 0; int start = -1; if (hasAuthority) { start = uri.indexOf("/", doubleSlashIndex + 2); } else {//w w w. j ava 2s.c om start = uri.indexOf(":"); } if (start == -1) return uri; int end = uri.indexOf("?", start + 1); if (end == -1) end = uri.indexOf("#", start + 1); if (end == -1) end = uri.length(); String before = uri.substring(0, start + 1); String path = uri.substring(start + 1, end); String after = uri.substring(end); path = URIUtil.encode(path, URI.allowed_abs_path); return before + path + after; }
From source file:org.apache.airavata.gfac.bes.utils.URIUtils.java
public static String encodeQuery(String uri) throws URIException { int queryStart = uri.indexOf("?"); if (queryStart == -1) return uri; int queryEnd = uri.indexOf("#"); if (queryEnd == -1) queryEnd = uri.length();// www . ja va2s . c o m String beforeQuery = uri.substring(0, queryStart + 1); String query = uri.substring(queryStart + 1, queryEnd); String afterQuery = uri.substring(queryEnd); query = URIUtil.encode(query, URI.allowed_query); return beforeQuery + query + afterQuery; }
From source file:org.apache.airavata.gfac.bes.utils.URIUtils.java
public static String encodeFragment(String uri) throws URIException { int fragmentStart = uri.indexOf("#"); if (fragmentStart == -1) return uri; String beforeFragment = uri.substring(0, fragmentStart + 1); String fragment = uri.substring(fragmentStart + 1); fragment = URIUtil.encode(fragment, URI.allowed_fragment); return beforeFragment + fragment; }
From source file:org.glite.authz.pep.obligation.dfpmap.GridMapDirPoolAccountManager.java
/** * Encodes the unescaped subject identifier, typically the user DN. * <p>/*from www .java 2 s . com*/ * Implements the legacy string encoding used by gLExec LCAS/LCMAP for the * lease file names: * <ul> * <li>URL encode all no alpha-numeric characters <code>[0-9a-zA-Z]</code> * <li>apply lower case * </ul> * * @param unescaped * The unescaped user DN * @return encoded, escaped, user DN, compatible with gLExec * @throws URIException */ protected String encodeSubjectIdentifier(String unescaped) throws URIException { String encoded = URIUtil.encode(unescaped, ALPHANUM); return encoded.toLowerCase(); }
From source file:pl.nask.hsn2.service.urlfollower.WebClientWorker.java
/** * Check if provided URL is valid./*from w w w .ja v a2s . c o m*/ * * @param url URL to check. * @return True if URL is valid, false otherwise. */ private boolean properUrl(String url) { try { String encoded = URIUtil.encode(url, Link.PROPER_URL_BITSET); new URL(encoded); return true; } catch (Exception e) { return false; } }