Java 类org.apache.commons.httpclient.URIException 实例源码

项目:alfresco-repository    文件:SolrQueryHTTPClient.java   
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;
}
项目: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!
  }
}
项目: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;
}
项目: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;
}
项目:motu    文件:HttpClientCAS.java   
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();

}
项目: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    文件:SystemsRequest.java   
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);
    }
}
项目: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;
}
项目:GRIP    文件:HttpSourceTest.java   
@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();
}
项目: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();
}
项目:community-edition-old    文件:SolrQueryHTTPClient.java   
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;
}
项目:netarchivesuite-svngit-migration    文件:NetarchiveSuiteUURIFactory.java   
/**
 * 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);
    }
}
项目: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    文件: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);
}
项目:pinpoint    文件:HttpMethodBaseExecuteMethodInterceptor.java   
private String getHost(HttpMethod httpMethod, Object[] args) {
    try {
        final URI url = httpMethod.getURI();
        if (url.isAbsoluteURI()) {
            return getEndpoint(url.getHost(), url.getPort());
        }

        if (isDebug) {
            logger.debug("URI is not absolute. {}", url.getURI());
        }

        // if not found schema, use httpConnection.
        final HttpConnection httpConnection = getHttpConnection(args);
        if (httpConnection != null) {
            final String host = httpConnection.getHost();
            final int port = getPort(httpConnection);
            return getEndpoint(host, port);
        }
    } catch (URIException e) {
        // unexpected error, perhaps of user fault.
        logger.error("[HttpClient3] Fail get URI", e);
    }

    return null;
}
项目:pinpoint    文件:HttpMethodBaseExecuteMethodInterceptor.java   
private String getHttpUrl(String host, int port, URI uri, HttpConnection httpConnection) throws URIException {
    final Protocol protocol = httpConnection.getProtocol();
    if (protocol == null) {
        return uri.getURI();
    }
    final StringBuilder sb = new StringBuilder();
    final String scheme = protocol.getScheme();
    sb.append(scheme).append("://");
    sb.append(host);
    // if port is default port number.
    if (port != SKIP_DEFAULT_PORT) {
        sb.append(':').append(port);
    }
    sb.append(uri.getURI());
    return sb.toString();
}
项目:airavata    文件:JSDLUtils.java   
public static void addDataStagingTargetElement(JobDefinitionType value, String fileSystem, String file, String uri, int flags) {
    JobDescriptionType jobDescr = getOrCreateJobDescription(value);
    DataStagingType newDS = jobDescr.addNewDataStaging();
    CreationFlagEnumeration.Enum creationFlag = CreationFlagEnumeration.DONT_OVERWRITE;
    if((flags & FLAG_OVERWRITE) != 0) creationFlag = CreationFlagEnumeration.OVERWRITE;
    if((flags & FLAG_APPEND) != 0) creationFlag = CreationFlagEnumeration.APPEND;
    boolean deleteOnTerminate = (flags & FLAG_DELETE_ON_TERMINATE) != 0;
    newDS.setCreationFlag(creationFlag);
    newDS.setDeleteOnTermination(deleteOnTerminate);
    SourceTargetType target = newDS.addNewTarget();

    try {
        if (uri != null) { 
            URIUtils.encodeAll(uri);
            target.setURI(uri);
        }
    } catch (URIException e) {
    }
    newDS.setFileName(file);
    if (fileSystem != null && !fileSystem.equals("Work")) {  //$NON-NLS-1$
        newDS.setFilesystemName(fileSystem);
    }
}
项目:airavata    文件:JSDLUtils.java   
public static void addDataStagingSourceElement(JobDefinitionType value, String uri, String fileSystem, String file, int flags) {
    JobDescriptionType jobDescr = getOrCreateJobDescription(value);

    try {
        uri = (uri == null) ? null : URIUtils.encodeAll(uri);
    } catch (URIException e) {
    }
    DataStagingType newDS = jobDescr.addNewDataStaging();
    CreationFlagEnumeration.Enum creationFlag = CreationFlagEnumeration.DONT_OVERWRITE;
    if((flags & FLAG_OVERWRITE) != 0) creationFlag = CreationFlagEnumeration.OVERWRITE;
    if((flags & FLAG_APPEND) != 0) creationFlag = CreationFlagEnumeration.APPEND;
    boolean deleteOnTerminate = (flags & FLAG_DELETE_ON_TERMINATE) != 0;
    newDS.setCreationFlag(creationFlag);
    newDS.setDeleteOnTermination(deleteOnTerminate);
    SourceTargetType source = newDS.addNewSource();
    source.setURI(uri);
    newDS.setFileName(file);
    if (fileSystem != null && !fileSystem.equals("Work")) {  //$NON-NLS-1$
        newDS.setFilesystemName(fileSystem);
    }
}
项目: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    文件:JSDLUtils.java   
public static void addDataStagingTargetElement(JobDefinitionType value, String fileSystem, String file, String uri, int flags) {
    JobDescriptionType jobDescr = getOrCreateJobDescription(value);
    DataStagingType newDS = jobDescr.addNewDataStaging();
    CreationFlagEnumeration.Enum creationFlag = CreationFlagEnumeration.DONT_OVERWRITE;
    if((flags & FLAG_OVERWRITE) != 0) creationFlag = CreationFlagEnumeration.OVERWRITE;
    if((flags & FLAG_APPEND) != 0) creationFlag = CreationFlagEnumeration.APPEND;
    boolean deleteOnTerminate = (flags & FLAG_DELETE_ON_TERMINATE) != 0;
    newDS.setCreationFlag(creationFlag);
    newDS.setDeleteOnTermination(deleteOnTerminate);
    SourceTargetType target = newDS.addNewTarget();

    try {
        if (uri != null) { 
            URIUtils.encodeAll(uri);
            target.setURI(uri);
        }
    } catch (URIException e) {
    }
    newDS.setFileName(file);
    if (fileSystem != null && !fileSystem.equals("Work")) {  //$NON-NLS-1$
        newDS.setFilesystemName(fileSystem);
    }
}
项目:airavata    文件:JSDLUtils.java   
public static void addDataStagingSourceElement(JobDefinitionType value, String uri, String fileSystem, String file, int flags) {
    JobDescriptionType jobDescr = getOrCreateJobDescription(value);

    try {
        uri = (uri == null) ? null : URIUtils.encodeAll(uri);
    } catch (URIException e) {
    }
    DataStagingType newDS = jobDescr.addNewDataStaging();
    CreationFlagEnumeration.Enum creationFlag = CreationFlagEnumeration.DONT_OVERWRITE;
    if((flags & FLAG_OVERWRITE) != 0) creationFlag = CreationFlagEnumeration.OVERWRITE;
    if((flags & FLAG_APPEND) != 0) creationFlag = CreationFlagEnumeration.APPEND;
    boolean deleteOnTerminate = (flags & FLAG_DELETE_ON_TERMINATE) != 0;
    newDS.setCreationFlag(creationFlag);
    newDS.setDeleteOnTermination(deleteOnTerminate);
    SourceTargetType source = newDS.addNewSource();
    source.setURI(uri);
    newDS.setFileName(file);
    if (fileSystem != null && !fileSystem.equals("Work")) {  //$NON-NLS-1$
        newDS.setFilesystemName(fileSystem);
    }
}
项目: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;
}
项目:DotCi    文件:HttpPoster.java   
private HttpHost getProxy(HttpUriRequest method) throws URIException {

        ProxyConfiguration proxy = Jenkins.getInstance().proxy;
        if (proxy == null) return null;

        Proxy p = proxy.createProxy(method.getURI().getHost());
        switch (p.type()) {
            case DIRECT:
                return null;
            case HTTP:
                InetSocketAddress sa = (InetSocketAddress) p.address();
                return new HttpHost(sa.getHostName(), sa.getPort());
            case SOCKS:
            default:
                return null;
        }
    }
项目:webarchive-commons    文件:SURTTokenizer.java   
private static String getKey(String url, boolean prefix)
throws URIException {

    String key = addImpliedHttpIfNecessary(url);
    UsableURI uuri = UsableURIFactory.getInstance(key);
    key = uuri.getScheme() + "://" + uuri.getAuthority() + 
        uuri.getEscapedPathQuery();

    key = SURT.fromURI(key);

    int hashPos = key.indexOf('#');
    if(hashPos != -1) {
        key = key.substring(0,hashPos);
    }

    if(key.startsWith("http://")) {
        key = key.substring(7);
    }
    if(prefix) {
        if(key.endsWith(",)/")) {
            key = key.substring(0,key.length()-3);
        }
    }
    return key;
}
项目:webarchive-commons    文件:UsableURIFactory.java   
/**
 * If http(s) scheme, check scheme specific part begins '//'.
 * @throws URIException 
 * @see http://www.faqs.org/rfcs/rfc1738.html Section 3.1. Common Internet
 * Scheme Syntax
 */
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);
    }
}
项目:jakarta-slide-webdavclient    文件:ResourceProperties.java   
public void storeProperties(PropFindMethod propFind)
   throws URIException
{
   // for each content element, check resource type and classify
   for (Enumeration e = propFind.getAllResponseURLs(); e.hasMoreElements(); ) 
   {
      String href = (String) e.nextElement();
      URI uri = new URI(propFind.getURI(), href);

      String key = uri.toString();
      List properties = (List)this.resourceMap.get(key);
      if (properties == null) {
         properties = new ArrayList();
         this.resourceMap.put(key, properties);
      }
      for(Enumeration f = propFind.getResponseProperties(href); 
          f.hasMoreElements();) 
      {
         properties.add((Property)f.nextElement());
      }
   }
}
项目:webarchive-commons    文件:SURT.java   
public static String toSURT(String input) {
        if(input.startsWith("(")) {
            return input;
        }
        try {
//          String tmp = input;
//          if(tmp == null) {
//              throw new URIException();
//          }
            String tmp = SURTTokenizer.prefixKey(input);
            if(tmp.contains("/")) {
                return tmp;
            }
            return tmp + ",";
        } catch (URIException e) {
            LOG.warning("URI Exception for(" + input + "):" + e.getLocalizedMessage());
//          e.printStackTrace();
            return input;
        }
    }
项目:webarchive-commons    文件:UsableURIFactoryTest.java   
public final void testTooLongAfterEscaping() {
    StringBuffer buffer = new StringBuffer("http://www.archive.org/a/");
    // Append bunch of spaces.  When escaped, they'll triple in size.
    for (int i = 0; i < 1024; i++) {
        buffer.append(" ");
    }
    buffer.append("/index.html");
    String message = null;
    try {
        UsableURIFactory.getInstance(buffer.toString());
    } catch (URIException e) {
        message = e.getMessage();
    }
    assertTrue("Wrong or no exception: " + message, (message != null) &&
        message.startsWith("Created (escaped) uuri >"));
}
项目:Tanaguru    文件:CrawlConfigurationUtils.java   
/**
 * 
 * @param document
 * @param parameters
 * @param urlList
 * @return
 * @throws URIException 
 */
public Document setUpDocument(
        Document document, 
        Set<Parameter> parameters, 
        Collection<String> urlList) throws URIException {
    document = modifyValue(
            getUrlModifier(), 
            document, 
            getUrlListAsUniqueString(urlList), 
            "");
    for (Parameter parameter : parameters) {
        document = modifyHeritrixParameter(document, parameter, urlList.iterator().next());
    }
    if (HttpRequestHandler.getInstance().isProxySet(urlList.iterator().next())) {
        for (HeritrixConfigurationModifier hcm : proxyModifierList) {
            // to respect the hcm interface, the method is called with 3 parameters
            // but the last 2 parameters are ignored (so set as empty strings). 
            // The modifier is already set  with the proxy parameters set 
            // by spring configuration on startup
            document = hcm.modifyDocument(document, "", "");
        }
    }
    return document;
}