当前位置: 首页>>代码示例>>Java>>正文


Java URIUtil类代码示例

本文整理汇总了Java中org.apache.commons.httpclient.util.URIUtil的典型用法代码示例。如果您正苦于以下问题:Java URIUtil类的具体用法?Java URIUtil怎么用?Java URIUtil使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


URIUtil类属于org.apache.commons.httpclient.util包,在下文中一共展示了URIUtil类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: toPostMethod

import org.apache.commons.httpclient.util.URIUtil; //导入依赖的package包/类
/**
 * Returns result POST method.<br/>
 * Result POST method is composed by baseURL + action (if baseURL is not null).<br/>
 * All parameters are set and encoded.
 * At least one of the parameter has to be not null and the string has to start with 'http'.
 *
 * @return new instance of HttpMethod with POST request
 * @throws BuildMethodException if something goes wrong
 */
public HttpMethod toPostMethod() throws BuildMethodException {
    if (referer != null)
        client.setReferer(referer);
    String s = generateURL();
    if (encodePathAndQuery)
        try {
            s = URIUtil.encodePathQuery(s, encoding);
        } catch (URIException e) {
            throw new BuildMethodException("Cannot create URI");
        }
    s = checkURI(s);
    final PostMethod postMethod = client.getPostMethod(s);
    for (Map.Entry<String, String> entry : parameters.entrySet()) {
        postMethod.addParameter(entry.getKey(), (encodeParameters) ? encode(entry.getValue()) : entry.getValue());
    }
    setAdditionalHeaders(postMethod);
    return postMethod;
}
 
开发者ID:jhkst,项目名称:dlface,代码行数:28,代码来源:MethodBuilder.java

示例2: getPackageZipFileUrl

import org.apache.commons.httpclient.util.URIUtil; //导入依赖的package包/类
@Override
public URI getPackageZipFileUrl(Item item, Attachment attachment)
{
	try
	{
		// Need the_IMS folder, not the _SCORM folder ...?
		String zipFileUrl = institutionService.institutionalise("file/" + item.getItemId() + '/')
			+ FileSystemConstants.IMS_FOLDER + '/'
			+ URIUtil.encodePath(attachment.getUrl(), Charsets.UTF_8.toString());
		return new URI(zipFileUrl);
	}
	catch( URISyntaxException | URIException e )
	{
		throw new RuntimeException(e);
	}
}
 
开发者ID:equella,项目名称:Equella,代码行数:17,代码来源:AttachmentResourceServiceImpl.java

示例3: getContainerReference

import org.apache.commons.httpclient.util.URIUtil; //导入依赖的package包/类
@Override
public CloudBlobContainerWrapper getContainerReference(String name)
    throws URISyntaxException, StorageException {
  String fullUri;
  try {
    fullUri = baseUriString + "/" + URIUtil.encodePath(name);
  } catch (URIException e) {
    throw new RuntimeException("problem encoding fullUri", e);
  }

  MockCloudBlobContainerWrapper container = new MockCloudBlobContainerWrapper(
      fullUri, name);
  // Check if we have a pre-existing container with that name, and prime
  // the wrapper with that knowledge if it's found.
  for (PreExistingContainer existing : preExistingContainers) {
    if (fullUri.equalsIgnoreCase(existing.containerUri)) {
      // We have a pre-existing container. Mark the wrapper as created and
      // make sure we use the metadata for it.
      container.created = true;
      backingStore.setContainerMetadata(existing.containerMetadata);
      break;
    }
  }
  return container;
}
 
开发者ID:naver,项目名称:hadoop,代码行数:26,代码来源:MockStorageInterface.java

示例4: fullUriString

import org.apache.commons.httpclient.util.URIUtil; //导入依赖的package包/类
private String fullUriString(String relativePath, boolean withTrailingSlash) {
  String fullUri;

  String baseUri = this.baseUri;
  if (!baseUri.endsWith("/")) {
    baseUri += "/";
  }
  if (withTrailingSlash && !relativePath.equals("")
      && !relativePath.endsWith("/")) {
    relativePath += "/";
  }

  try {
    fullUri = baseUri + URIUtil.encodePath(relativePath);
  } catch (URIException e) {
    throw new RuntimeException("problem encoding fullUri", e);
  }

  return fullUri;
}
 
开发者ID:naver,项目名称:hadoop,代码行数:21,代码来源:MockStorageInterface.java

示例5: getDecodedPath

import org.apache.commons.httpclient.util.URIUtil; //导入依赖的package包/类
/**
 * Parse and decode the path component from the given request.
 * @param request Http request to parse
 * @param servletName the name of servlet that precedes the path
 * @return decoded path component, null if UTF-8 is not supported
 */
public static String getDecodedPath(final HttpServletRequest request, String servletName) {
  try {
    return URIUtil.decode(getRawPath(request, servletName), "UTF-8");
  } catch (URIException e) {
    throw new AssertionError("JVM does not support UTF-8"); // should never happen!
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:14,代码来源:ServletUtil.java

示例6: testEncodeWithinQuery

import org.apache.commons.httpclient.util.URIUtil; //导入依赖的package包/类
public void testEncodeWithinQuery() {
    //TODO: There was an unmappable character for encoding UTF8. YAGNI?
    String unescaped1=  "abc123+ %_?=&#.";
    try {
        String stringRet = URIUtil.encodeWithinQuery(unescaped1);
        assertEquals("abc123%2B%20%25_%3F%3D%26%23.%C3%A4", stringRet);
        stringRet = URIUtil.decode(stringRet);
        assertEquals(unescaped1, stringRet);
    } catch(Exception e) {
        System.err.println("Exception thrown:  "+e);
    }
}
 
开发者ID:jenkinsci,项目名称:lib-commons-httpclient,代码行数:13,代码来源:TestURIUtil2.java

示例7: searchUser

import org.apache.commons.httpclient.util.URIUtil; //导入依赖的package包/类
/**
 * Search a user in Zendesk on the basis of the criterion.
 * 
 * @param httpClient
 * @param criterion
 * @param queryString
 * @return
 * @throws URIException
 */
private int searchUser(HttpClient httpClient, String criterion, String queryString) throws Exception {
  final GetMethod get = new GetMethod(cadURL + "/object/ANY/" + criterion);
  get.setQueryString(URIUtil.encodeQuery(queryString));
  get.addRequestHeader("Accept", "application/xml");
  int result = 0;
  try {
    /* Execute get method */
    result = httpClient.executeMethod(get);
    System.out.println("Response body: " + get.getResponseBodyAsString());
  } catch (Exception e) {
    throw e;
  } finally {
    if (get != null) {
      get.releaseConnection();
    }
  }
  return result;
}
 
开发者ID:inbravo,项目名称:scribe,代码行数:28,代码来源:ZenDeskTest.java

示例8: searchLead

import org.apache.commons.httpclient.util.URIUtil; //导入依赖的package包/类
/**
 * Search a Lead object in microsoft on the basis of the criterion.
 * 
 * @param httpClient
 * @param criterion
 * @param queryString
 * @return
 * @throws URIException
 */
private final int searchLead(HttpClient httpClient, String criterion, String queryString) throws Exception {
  final GetMethod get = new GetMethod(cadURL + "/object/lead/" + criterion);
  get.setQueryString(URIUtil.encodeQuery(queryString));
  get.addRequestHeader("Accept", "application/xml");
  int result = 0;
  try {
    /* Execute get method */
    result = httpClient.executeMethod(get);
  } catch (final Exception e) {
    throw e;
  } finally {
    if (get != null) {
      get.releaseConnection();
    }
  }
  return result;
}
 
开发者ID:inbravo,项目名称:scribe,代码行数:27,代码来源:MicroSoftLeadTest.java

示例9: searchOpportunity

import org.apache.commons.httpclient.util.URIUtil; //导入依赖的package包/类
/**
 * Search a opportunity in microsoft on the basis of the criterion.
 * 
 * @param httpClient
 * @param criterion
 * @param queryString
 * @return
 * @throws URIException
 */
private final int searchOpportunity(final HttpClient httpClient, final String criterion, final String queryString) throws Exception {
  final GetMethod get = new GetMethod(cadURL + "/object/opportunity/" + criterion);
  get.setQueryString(URIUtil.encodeQuery(queryString));
  get.addRequestHeader("Accept", "application/xml");
  int result = 0;
  try {
    /* Execute get method */
    result = httpClient.executeMethod(get);
  } catch (final Exception e) {
    throw e;
  } finally {
    if (get != null) {
      get.releaseConnection();
    }
  }
  return result;
}
 
开发者ID:inbravo,项目名称:scribe,代码行数:27,代码来源:MicroSoftOpportunityTest.java

示例10: searchTask

import org.apache.commons.httpclient.util.URIUtil; //导入依赖的package包/类
/**
 * Search a Task in microsoft on the basis of the criterion.
 * 
 * @param httpClient
 * @param criterion
 * @param queryString
 * @return
 * @throws URIException
 */
private final int searchTask(final HttpClient httpClient, final String criterion, final String queryString) throws Exception {
  final GetMethod get = new GetMethod(cadURL + "/object/task/" + criterion);
  get.setQueryString(URIUtil.encodeQuery(queryString));
  get.addRequestHeader("Accept", "application/xml");
  int result = 0;
  try {
    /* Execute get method */
    result = httpClient.executeMethod(get);
  } catch (final Exception e) {
    throw e;
  } finally {
    if (get != null) {
      get.releaseConnection();
    }
  }
  return result;
}
 
开发者ID:inbravo,项目名称:scribe,代码行数:27,代码来源:MicroSoftTaskTest.java

示例11: searchIncident

import org.apache.commons.httpclient.util.URIUtil; //导入依赖的package包/类
/**
 * Search an incident in microsoft on the basis of the criterion.
 * 
 * @param httpClient
 * @param criterion
 * @param queryString
 * @return
 * @throws URIException
 */
private final int searchIncident(final HttpClient httpClient, final String criterion, final String queryString) throws Exception {
  final GetMethod get = new GetMethod(cadURL + "/object/incident/" + criterion);
  get.setQueryString(URIUtil.encodeQuery(queryString));
  get.addRequestHeader("Accept", "application/xml");
  int result = 0;
  try {
    /* Execute get method */
    result = httpClient.executeMethod(get);
  } catch (Exception e) {
    throw e;
  } finally {
    if (get != null) {
      get.releaseConnection();
    }
  }
  return result;
}
 
开发者ID:inbravo,项目名称:scribe,代码行数:27,代码来源:MicroSoftIncidentTest.java

示例12: searchContact

import org.apache.commons.httpclient.util.URIUtil; //导入依赖的package包/类
/**
 * Search a Contact object in microsoft on the basis of the criterion.
 * 
 * @param httpClient
 * @param criterion
 * @param queryString
 * @return
 * @throws URIException
 */
private final int searchContact(HttpClient httpClient, String criterion, String queryString) throws Exception {
  final GetMethod get = new GetMethod(cadURL + "/object/contact/" + criterion);
  get.setQueryString(URIUtil.encodeQuery(queryString));
  get.addRequestHeader("Accept", "application/xml");
  int result = 0;
  try {
    /* Execute get method */
    result = httpClient.executeMethod(get);
  } catch (final Exception e) {
    throw e;
  } finally {
    if (get != null) {
      get.releaseConnection();
    }
  }
  return result;
}
 
开发者ID:inbravo,项目名称:scribe,代码行数:27,代码来源:MicroSoftContactTest.java

示例13: searchAccount

import org.apache.commons.httpclient.util.URIUtil; //导入依赖的package包/类
/**
 * Search an account in MS CRM on the basis of the criterion.
 * 
 * @param httpClient
 * @param criterion
 * @param queryString
 * @return
 * @throws Exception
 */
private final int searchAccount(final HttpClient httpClient, final String criterion, final String queryString) throws Exception {
  final GetMethod get = new GetMethod(cadURL + "/object/account/" + criterion);
  get.setQueryString(URIUtil.encodeQuery(queryString));
  get.addRequestHeader("Accept", "application/xml");
  int result = 0;
  try {
    /* Execute get method */
    result = httpClient.executeMethod(get);
  } catch (final Exception e) {
    throw e;
  } finally {
    if (get != null) {
      get.releaseConnection();
    }
  }
  return result;
}
 
开发者ID:inbravo,项目名称:scribe,代码行数:27,代码来源:MicroSoftAccountTest.java

示例14: searchObjectAtCAD

import org.apache.commons.httpclient.util.URIUtil; //导入依赖的package包/类
/**
 * Search a user in Zendesk on the basis of the criterion.
 * 
 * @param httpClient
 * @param criterion
 * @param queryString
 * @return
 * @throws URIException
 */
private final int searchObjectAtCAD(final String criterion, final String queryString) throws Exception {
  final HttpClient httpClient = new HttpClient();
  final GetMethod get = new GetMethod(this.cadUrl + "/object/ANY/" + criterion);
  get.setQueryString(URIUtil.encodeQuery(queryString));
  get.addRequestHeader("Accept", "application/xml");
  int result = 0;
  try {
    /* Execute get method */
    result = httpClient.executeMethod(get);
    System.out.println("----Inside searchObjectAtCAD URL : " + get.getURI() + " & response code: " + result + " & body: "
        + get.getResponseBodyAsString());
  } catch (final Exception e) {
    throw e;
  } finally {
    get.releaseConnection();
  }
  return result;
}
 
开发者ID:inbravo,项目名称:scribe,代码行数:28,代码来源:PerfTester.java

示例15: interactive

import org.apache.commons.httpclient.util.URIUtil; //导入依赖的package包/类
public static String interactive(String url, String queryString) throws Exception {
		String response = null;
		HttpClient client = new HttpClient();
		HttpMethod method = new GetMethod(url);
		try {
			// if (StringUtils.isNotBlank(queryString))
			if (queryString != null && !queryString.equals(""))
				method.setQueryString(URIUtil.encodeQuery(queryString,"GBK"));
			client.executeMethod(method);
			if (method.getStatusCode() == HttpStatus.SC_OK) {
//				response = method.getResponseBodyAsString();
				InputStream input = method.getResponseBodyAsStream();
				response = Ryt.readStream(input);
				response=transCharCode(response);//对响应xml转码
			}
		} catch (Exception e) {
			logger.error(e.getMessage());
			throw new Exception("请求银行接口异常!");
		} finally {
			method.releaseConnection();
		}
		throwRequestException(response);
		return response;
	}
 
开发者ID:wufeisoft,项目名称:ryf_mms2,代码行数:25,代码来源:BOCOMSettleCore.java


注:本文中的org.apache.commons.httpclient.util.URIUtil类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。