Java 类org.apache.commons.httpclient.util.URIUtil 实例源码

项目:dlface    文件:MethodBuilder.java   
/**
 * 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;
}
项目:Equella    文件:AttachmentResourceServiceImpl.java   
@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);
    }
}
项目:hadoop    文件:MockStorageInterface.java   
@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;
}
项目:hadoop    文件:MockStorageInterface.java   
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;
}
项目:hadoop    文件:ServletUtil.java   
/**
 * 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!
  }
}
项目:lib-commons-httpclient    文件:TestURIUtil2.java   
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);
    }
}
项目:aliyun-oss-hadoop-fs    文件:MockStorageInterface.java   
@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;
}
项目:aliyun-oss-hadoop-fs    文件:MockStorageInterface.java   
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;
}
项目:scribe    文件:ZenDeskTest.java   
/**
 * 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;
}
项目:scribe    文件:MicroSoftLeadTest.java   
/**
 * 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;
}
项目:scribe    文件:MicroSoftOpportunityTest.java   
/**
 * 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;
}
项目:scribe    文件:MicroSoftTaskTest.java   
/**
 * 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;
}
项目:scribe    文件:MicroSoftIncidentTest.java   
/**
 * 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;
}
项目:scribe    文件:MicroSoftContactTest.java   
/**
 * 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;
}
项目:scribe    文件:MicroSoftAccountTest.java   
/**
 * 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;
}
项目:scribe    文件:PerfTester.java   
/**
 * 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;
}
项目:big-c    文件:MockStorageInterface.java   
@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;
}
项目:big-c    文件:MockStorageInterface.java   
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;
}
项目:ryf_mms2    文件:BOCOMSettleCore.java   
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;
    }
项目:ryf_mms2    文件:TestUtil.java   
private static String httpRequest(String reqDate, String ncURL, String encode) throws B2EException {
        String response = null;
        HttpClient client = new HttpClient();
        HttpMethod method = new GetMethod(ncURL);
        try {

            method.setRequestHeader("Content-Type", "application/xmlstream");
            method.setQueryString(URIUtil.encodeQuery(reqDate, encode));
            client.executeMethod(method);
            if (method.getStatusCode() == HttpStatus.SC_OK) {
//              response = method.getResponseBodyAsString();
                InputStream input=method.getResponseBodyAsStream();
                response=readStream(input);
                LogUtil.printInfoLog("TestUtil", "httpRequest", response);
            }
        } catch (Exception e) {
            LogUtil.printErrorLog("B2EProcess", "httpRequest", e.getMessage());
            throw new B2EException("请求银行接口异常:" + e.getMessage());

        } finally {
            method.releaseConnection();
        }
        return response;
    }
项目:hadoop-2.6.0-cdh5.4.3    文件:MockStorageInterface.java   
@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;
}
项目:hadoop-2.6.0-cdh5.4.3    文件:MockStorageInterface.java   
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;
}
项目:openhab-hdl    文件:AccessTokenRequest.java   
private String buildQueryString() {
    final StringBuilder urlBuilder = new StringBuilder(RESOURCE_URL);

    try {
        urlBuilder.append("?code=");
        urlBuilder.append(this.pinCode);
        urlBuilder.append("&client_id=");
        urlBuilder.append(this.clientId);
        urlBuilder.append("&client_secret=");
        urlBuilder.append(this.clientSecret);
        urlBuilder.append("&grant_type=authorization_code");
        return URIUtil.encodeQuery(urlBuilder.toString());
    } catch (final Exception e) {
        throw new NestException(e);
    }
}
项目:openhab-hdl    文件:MeasurementRequest.java   
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);
    }
}
项目:imis-iot-eventing-process    文件:KvpSosClient.java   
/**
 * 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;
}
项目:imis-iot-eventing-process    文件:RssFeederTest.java   
@Test
public void testPost()
        throws MalformedURLException, IOException, XMLStreamException {
    String guid = this.feeder.createGUID(event).toString();
    this.feeder.sendNotification(this.event);
    URL url = new URL(this.endpoint + "/GetRSS?id=" + URIUtil
                      .encodeWithinQuery(guid));
    String response;
    try (InputStream in = this.httpClient.get(url);
         Reader reader = new InputStreamReader(in, StandardCharsets.UTF_8)) {
        response = CharStreams.toString(reader);
    }
    assertThat(response, is(notNullValue()));
    errors.checkThat(response.length(), is(not(0)));
    errors.checkThat(response, is(not("guid " + guid +
                                      " does not exist in the data store.")));
}
项目:converge-1.x    文件:MediaItemRendition.java   
/**
 * 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();
}
项目:reviki    文件:Escape.java   
/**
 * 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);
  }
}
项目:reviki    文件:TextFormatSearchResults.java   
public void render(final HttpServletRequest request, final PrintWriter writer) throws Exception {
  String wiki;
  String page;
  for (SearchMatch matcher : _results) {
    wiki = matcher.getWiki();
    page = matcher.getPage();

    if (matcher.isSameWiki()) {
      writer.println(matcher.getPage());
    }
    else {
      StringBuilder s = new StringBuilder(wiki + ";" + page);
      try {
        s.append(";" + getUrlForPage(request, wiki, page));
      }
      catch (UnknownWikiException e) {
        // Do not respond with URL component
      }
      writer.println(s.toString());
    }
  }
  if (request.getHeader("Authorization") == null) {
    writer.println("Not logged in;Log in to see all results;" + getUrlForPage(request, null, "FindPage") + "?query=" + URIUtil.encodeWithinQuery(request.getParameter("query")));
  }
}
项目:reviki    文件:WikiUrlsImpl.java   
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);
}
项目:reviki    文件:LuceneSearcher.java   
public Set<String> incomingLinks(final String page) throws IOException, PageStoreException {
  if (_dir == null) {
    return Collections.emptySet();
  }
  try {
    return doReadOperation(new ReadOperation<Set<String>>() {
      public Set<String> execute(final IndexReader reader, final Searcher searcher, final Analyzer analyzer) throws IOException, ParseException {
        final String pageEscaped = escape(URIUtil.encodeWithinPath(page));
        Set<String> results = Sets.newLinkedHashSet(Iterables.transform(query(reader, createAnalyzer(), searcher, FIELD_OUTGOING_LINKS, pageEscaped, false), SearchMatch.TO_PAGE_NAME));
        results.remove(page);
        return results;
      }
    }, false);
  }
  catch (QuerySyntaxException ex) {
    throw new NoQueryPerformedException(ex);
  }
}
项目:Plugins    文件:FilesDownloadVaadinDialog.java   
@Override
protected void setConfiguration(FilesDownloadConfig_V1 config) throws DPUConfigException {
    if (isContainerValid(false)) {
        try {
            container.removeAllItems();

            for (VfsFile vfsFile : config.getVfsFiles()) {
                VfsFile vfsFileInContainer = new VfsFile(vfsFile);
                vfsFileInContainer.setUri(URIUtil.decode(vfsFile.getUri(), "utf8"));

                container.addItem(vfsFileInContainer);
            }
        } catch (Exception e) {
            throw new DPUConfigException(ctx.tr("FilesDownloadVaadinDialog.setConfiguration.exception"), e);
        }
    }
    defaultTimeout.setValue(config.getDefaultTimeout());
    ignoreTlsErrors.setValue(config.isIgnoreTlsErrors());
    chkSoftFail.setValue(config.isSoftFail());
    chkCheckDuplicates.setValue(config.isCheckForDuplicatedInputFiles());
    waitBeetweenCallsMs.setValue(config.getWaitBetweenCallsMs());
}
项目:incubator-gobblin    文件:HttpUtils.java   
/**
 * Convert D2 URL template into a string used for throttling limiter
 *
 * Valid:
 *    d2://host/${resource-id}
 *
 * Invalid:
 *    d2://host${resource-id}, because we cannot differentiate the host
 */
public static String createR2ClientLimiterKey(Config config) {

  String urlTemplate = config.getString(HttpConstants.URL_TEMPLATE);
  try {
    String escaped = URIUtil.encodeQuery(urlTemplate);
    URI uri = new URI(escaped);
    if (uri.getHost() == null)
      throw new RuntimeException("Cannot get host part from uri" + urlTemplate);

    String key = uri.getScheme() + "/" + uri.getHost();
    if (uri.getPort() > 0) {
      key = key + "/" + uri.getPort();
    }
    log.info("Get limiter key [" + key + "]");
    return key;
  } catch (Exception e) {
    throw new RuntimeException("Cannot create R2 limiter key", e);
  }
}
项目:IUSIS    文件:LocationLookupService.java   
public Location lookup(@Named("Description") String description) {

        final GetMethod get = new GetMethod(BASEURL + MODE);
        try {
            final String query = URIUtil.encodeQuery("?address=" + description + "&sensor=false");
            get.setQueryString(query);

            httpclient.executeMethod(get);

            final String xml = get.getResponseBodyAsString();
            final SAXBuilder builder = new SAXBuilder();
            Document doc = builder.build(new StringReader(xml));
            Element root = doc.getRootElement();
            String lat = root.getChild("result").getChild("geometry").getChild("location").getChildTextTrim("lat");
            String lon = root.getChild("result").getChild("geometry").getChild("location").getChildTextTrim("lng");
            return Location.fromString(lat + ";" + lon);
        } catch (Exception ex) {
            return null;
        }
    }
项目:airavata    文件:URIUtils.java   
public static String encodeAuthority(String uri) throws URIException
{
    int start = uri.indexOf("//");
    if(start == -1) return uri;
    start++;
    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;
}
项目:airavata    文件: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
    {
        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;
}
项目:airavata    文件:URIUtils.java   
public static String encodeAuthority(String uri) throws URIException
{
    int start = uri.indexOf("//");
    if(start == -1) return uri;
    start++;
    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;
}
项目:airavata    文件: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
    {
        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;
}
项目:openhab1-addons    文件:AccessTokenRequest.java   
private String buildQueryString() {
    final StringBuilder urlBuilder = new StringBuilder(RESOURCE_URL);

    try {
        urlBuilder.append("?code=");
        urlBuilder.append(this.pinCode);
        urlBuilder.append("&client_id=");
        urlBuilder.append(this.clientId);
        urlBuilder.append("&client_secret=");
        urlBuilder.append(this.clientSecret);
        urlBuilder.append("&grant_type=authorization_code");
        return URIUtil.encodeQuery(urlBuilder.toString());
    } catch (final Exception e) {
        throw new NestException(e);
    }
}
项目:jakarta-slide-webdavclient    文件:WebdavResource.java   
/**
 * Updates the resource with a new set of aces.
 *
 * @param path the server relative path of the resource to which the given
 *        ACEs shall be applied
 * @param aces the ACEs to apply
 * @return true if the method succeeded
 */
public boolean aclMethod(String path, Ace[] aces)
    throws HttpException, IOException {

    setClient();

    AclMethod method = new AclMethod(URIUtil.encodePath(path));
    method.setDebug(debug);
    method.setFollowRedirects(this.followRedirects);

    generateIfHeader(method);
    for (int i=0; i<aces.length ; i++) {
        Ace ace = aces[i];
        method.addAce(ace);
    }

    generateTransactionHeader(method);
    int statusCode = client.executeMethod(method);

    setStatusCode(statusCode);

    return (statusCode >= 200 && statusCode < 300) ? true : false;
}