當前位置: 首頁>>代碼示例>>Java>>正文


Java URIException類代碼示例

本文整理匯總了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;
}
 
開發者ID:Alfresco,項目名稱:alfresco-repository,代碼行數:27,代碼來源:SolrQueryHTTPClient.java

示例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;
}
 
開發者ID:jhkst,項目名稱:dlface,代碼行數:28,代碼來源:MethodBuilder.java

示例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);
	}
}
 
開發者ID:equella,項目名稱:Equella,代碼行數:17,代碼來源:AttachmentResourceServiceImpl.java

示例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;
}
 
開發者ID:naver,項目名稱:hadoop,代碼行數:26,代碼來源:MockStorageInterface.java

示例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;
}
 
開發者ID:naver,項目名稱:hadoop,代碼行數:21,代碼來源:MockStorageInterface.java

示例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!
  }
}
 
開發者ID:naver,項目名稱:hadoop,代碼行數:14,代碼來源:ServletUtil.java

示例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();

}
 
開發者ID:clstoulouse,項目名稱:motu,代碼行數:26,代碼來源:HttpClientCAS.java

示例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);
	}
}
 
開發者ID:andrey-desman,項目名稱:openhab-hdl,代碼行數:17,代碼來源:SystemsRequest.java

示例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);
	}
}
 
開發者ID:andrey-desman,項目名稱:openhab-hdl,代碼行數:27,代碼來源:MeasurementRequest.java

示例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;
}
 
開發者ID:52North,項目名稱:imis-iot-eventing-process,代碼行數:28,代碼來源:KvpSosClient.java

示例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();
}
 
開發者ID:WPIRoboticsProjects,項目名稱:GRIP,代碼行數:20,代碼來源:HttpSourceTest.java

示例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();
}
 
開發者ID:getconverge,項目名稱:converge-1.x,代碼行數:33,代碼來源:MediaItemRendition.java

示例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);
  }
}
 
開發者ID:CoreFiling,項目名稱:reviki,代碼行數:31,代碼來源:Escape.java

示例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);
}
 
開發者ID:CoreFiling,項目名稱:reviki,代碼行數:23,代碼來源:WikiUrlsImpl.java


注:本文中的org.apache.commons.httpclient.URIException類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。