本文整理汇总了Java中org.apache.commons.httpclient.URIException类的典型用法代码示例。如果您正苦于以下问题:Java URIException类的具体用法?Java URIException怎么用?Java URIException使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
URIException类属于org.apache.commons.httpclient包,在下文中一共展示了URIException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: postSolrQuery
import org.apache.commons.httpclient.URIException; //导入依赖的package包/类
protected JSONResult postSolrQuery(HttpClient httpClient, String url, JSONObject body, SolrJsonProcessor<?> jsonProcessor, String spellCheckParams)
throws UnsupportedEncodingException, IOException, HttpException, URIException,
JSONException
{
JSONObject json = postQuery(httpClient, url, body);
if (spellCheckParams != null)
{
SpellCheckDecisionManager manager = new SpellCheckDecisionManager(json, url, body, spellCheckParams);
if (manager.isCollate())
{
json = postQuery(httpClient, manager.getUrl(), body);
}
json.put("spellcheck", manager.getSpellCheckJsonValue());
}
JSONResult results = jsonProcessor.getResult(json);
if (s_logger.isDebugEnabled())
{
s_logger.debug("Sent :" + url);
s_logger.debug(" with: " + body.toString());
s_logger.debug("Got: " + results.getNumberFound() + " in " + results.getQueryTime() + " ms");
}
return results;
}
示例2: toPostMethod
import org.apache.commons.httpclient.URIException; //导入依赖的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;
}
示例3: getPackageZipFileUrl
import org.apache.commons.httpclient.URIException; //导入依赖的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);
}
}
示例4: getContainerReference
import org.apache.commons.httpclient.URIException; //导入依赖的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;
}
示例5: fullUriString
import org.apache.commons.httpclient.URIException; //导入依赖的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;
}
示例6: getDecodedPath
import org.apache.commons.httpclient.URIException; //导入依赖的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!
}
}
示例7: debugHttpMethod
import org.apache.commons.httpclient.URIException; //导入依赖的package包/类
public static String debugHttpMethod(HttpMethod method) {
StringBuffer stringBuffer = new StringBuffer();
stringBuffer.append("\nName:");
stringBuffer.append(method.getName());
stringBuffer.append("\n");
stringBuffer.append("\nPath:");
stringBuffer.append(method.getPath());
stringBuffer.append("\n");
stringBuffer.append("\nQueryString:");
stringBuffer.append(method.getQueryString());
stringBuffer.append("\n");
stringBuffer.append("\nUri:");
try {
stringBuffer.append(method.getURI().toString());
} catch (URIException e) {
// Do nothing
}
stringBuffer.append("\n");
HttpMethodParams httpMethodParams = method.getParams();
stringBuffer.append("\nHttpMethodParams:");
stringBuffer.append(httpMethodParams.toString());
return stringBuffer.toString();
}
示例8: prepare
import org.apache.commons.httpclient.URIException; //导入依赖的package包/类
public String prepare() {
final StringBuilder urlBuilder = new StringBuilder(RESOURCE_URL);
urlBuilder.append("/");
urlBuilder.append(this.system_id);
urlBuilder.append("/summary");
urlBuilder.append("?key=");
urlBuilder.append(this.key);
urlBuilder.append("&user_id=");
urlBuilder.append(this.user_id);
try {
return encodeQuery(urlBuilder.toString());
} catch (final URIException e) {
throw new EnphaseenergyException("Could not prepare systems request!", e);
}
}
示例9: buildQueryString
import org.apache.commons.httpclient.URIException; //导入依赖的package包/类
private String buildQueryString() {
final StringBuilder urlBuilder = new StringBuilder(RESOURCE_URL);
urlBuilder.append("?access_token=");
urlBuilder.append(this.accessToken);
urlBuilder.append("&scale=max");
urlBuilder.append("&date_end=last");
urlBuilder.append("&device_id=");
urlBuilder.append(this.deviceId);
if (this.moduleId != null) {
urlBuilder.append("&module_id=");
urlBuilder.append(this.moduleId);
}
urlBuilder.append("&type=");
for (final Iterator<String> i = this.measures.iterator(); i.hasNext();) {
urlBuilder.append(i.next());
if (i.hasNext()) {
urlBuilder.append(",");
}
}
try {
return URIUtil.encodeQuery(urlBuilder.toString());
} catch (final URIException e) {
throw new NetatmoException(e);
}
}
示例10: createRequest
import org.apache.commons.httpclient.URIException; //导入依赖的package包/类
/**
* Creates the request URL for the specified time span.
*
* @param begin the exclusive lower bound of the time span
* @param end the exclusive upper bound of the time span
*
* @return the request URL
*
* @throws MalformedURLException if the URL generation fails
* @throws URIException if the URL generation fails
*/
private URL createRequest(DateTime begin, DateTime end)
throws MalformedURLException, URIException {
Objects.requireNonNull(begin);
Objects.requireNonNull(end);
StringBuilder builder = new StringBuilder();
builder.append(this.requestTemplate.toString());
builder.append("&namespaces=").append(URIUtil.encodeQuery("xmlns(om,http://www.opengis.net/om/2.0)"));
builder.append("&temporalFilter=");
String temporalFilter = "om:phenomenonTime," +
ISODateTimeFormat.dateTime().print(begin) +
"/" +
ISODateTimeFormat.dateTime().print(end);
builder.append(URIUtil.encodeQuery(temporalFilter));
URL url = new URL(builder.toString());
return url;
}
示例11: setUp
import org.apache.commons.httpclient.URIException; //导入依赖的package包/类
@Before
public void setUp() throws URIException, URISyntaxException {
GripServer.JettyServerFactory f = new GripServerTest.TestServerFactory();
ContextStore contextStore = new ContextStore();
server = GripServerTest.makeServer(contextStore, f, new Pipeline());
server.start();
EventBus eventBus = new EventBus();
OutputSocket.Factory osf = new MockOutputSocketFactory(eventBus);
source = new HttpSource(
origin -> new MockExceptionWitness(eventBus, origin),
eventBus,
osf,
server,
contextStore,
GripServer.IMAGE_UPLOAD_PATH);
logoFile = new File(Files.class.getResource("/edu/wpi/grip/images/GRIP_Logo.png").toURI());
postClient = HttpClients.createDefault();
}
示例12: getAbsoluteFilename
import org.apache.commons.httpclient.URIException; //导入依赖的package包/类
/**
* Gets the absolute URL of the {@link MediaItem}. This is
* dynamically calculated based on the {@link MediaRepository} associated
* with the {@link MediaItem}.
*
* @return Absolute URL of the {@link MediaItem}
*/
public String getAbsoluteFilename() {
if (mediaItem == null || mediaItem.getCatalogue() == null
|| getFilename() == null) {
return "#";
}
StringBuilder absoluteFilename = new StringBuilder(mediaItem.
getCatalogue().getWebAccess());
absoluteFilename.append("/");
if (!StringUtils.isBlank(getPath())) {
absoluteFilename.append(FilenameUtils.separatorsToUnix(getPath()));
absoluteFilename.append("/");
}
if (!StringUtils.isBlank(getFilename())) {
try {
absoluteFilename.append(URIUtil.encodePath(getFilename(),
"UTF-8"));
} catch (URIException ex) {
absoluteFilename.append(getFilename());
}
}
return absoluteFilename.toString();
}
示例13: checkHttpSchemeSpecificPartSlashPrefix
import org.apache.commons.httpclient.URIException; //导入依赖的package包/类
/**
* If http(s) scheme, check scheme specific part begins '//'.
* @throws URIException
* @see <A href="http://www.faqs.org/rfcs/rfc1738.html">Section 3.1.
* Common Internet Scheme Syntax</A>
*/
protected void checkHttpSchemeSpecificPartSlashPrefix(final URI base,
final String scheme, final String schemeSpecificPart)
throws URIException {
if (scheme == null || scheme.length() <= 0) {
return;
}
if (!scheme.equals("http") && !scheme.equals("https")) {
return;
}
if (schemeSpecificPart == null
|| !schemeSpecificPart.startsWith("//")) {
// only acceptable if schemes match
if (base == null || !scheme.equals(base.getScheme())) {
throw new URIException(
"relative URI with scheme only allowed for "
+ "scheme matching base");
}
return;
}
if (schemeSpecificPart.length() <= 2) {
throw new URIException("http scheme specific part is "
+ "too short: " + schemeSpecificPart);
}
}
开发者ID:netarchivesuite,项目名称:netarchivesuite-svngit-migration,代码行数:31,代码来源:NetarchiveSuiteUURIFactory.java
示例14: constructEncodedURI
import org.apache.commons.httpclient.URIException; //导入依赖的package包/类
/**
* Generate a correctly encoded URI string from the given components.
*
* @param path The unencoded path. Will be encoded according to RFC3986.
* @param query The unencoded query. May be null. Will be x-www-form-urlencoded.
* @param fragment The unencoded fragment. May be null. Will be encoded according to RFC3986.
* @param extraPath The <strong>encoded</strong> extra part to append to the path.
* @return
*/
public static String constructEncodedURI(final String path, final String query, final String fragment, final String extraPath) {
try {
StringBuilder sb = new StringBuilder();
sb.append(URIUtil.encodeWithinPath(path, "UTF-8"));
if (extraPath != null) {
sb.append(extraPath);
}
if (query != null) {
sb.append("?");
sb.append(URIUtil.encodeQuery(query, "UTF-8"));
}
if (fragment != null) {
sb.append("#");
sb.append(URIUtil.encodeWithinPath(fragment, "UTF-8"));
}
return sb.toString();
}
catch(URIException ex) {
throw new Error("Java supports UTF-8!", ex);
}
}
示例15: pagesRoot
import org.apache.commons.httpclient.URIException; //导入依赖的package包/类
public String pagesRoot(final String wikiName) {
final String givenWikiName = wikiName == null ? _wiki.getWikiName() : wikiName;
String fixedBaseUrl = _wiki.getFixedBaseUrl(givenWikiName);
if (fixedBaseUrl != null) {
if (!fixedBaseUrl.endsWith("/")) {
fixedBaseUrl += "/";
}
return fixedBaseUrl;
}
String relative = "/pages/";
if (givenWikiName != null) {
try {
relative += URIUtil.encodeWithinPath(givenWikiName) + "/";
}
catch (URIException e) {
throw new RuntimeException(e);
}
}
return _applicationUrls.url(relative);
}