Example usage for org.apache.commons.httpclient URIException initCause

List of usage examples for org.apache.commons.httpclient URIException initCause

Introduction

In this page you can find the example usage for org.apache.commons.httpclient URIException initCause.

Prototype

public synchronized Throwable initCause(Throwable cause) 

Source Link

Document

Initializes the cause of this throwable to the specified value.

Usage

From source file:dk.netarkivet.wayback.batch.copycode.NetarchiveSuiteUURIFactory.java

/**
 * Fixup the domain label part of the authority.
 *
 * We're more lax than the spec. in that we allow underscores.
 *
 * @param label Domain label to fix./*  w ww . java 2  s .  c o  m*/
 * @return Return fixed domain label.
 * @throws URIException
 */
private String fixupDomainlabel(String label) throws URIException {

    // apply IDN-punycoding, as necessary
    try {
        // TODO optimize: only apply when necessary, or
        // keep cache of recent encodings
        label = IDNA.toASCII(label);
    } catch (IDNAException e) {
        if (TextUtils.matches(ACCEPTABLE_ASCII_DOMAIN, label)) {
            // domain name has ACE prefix, leading/trailing dash, or
            // underscore -- but is still a name we wish to tolerate;
            // simply continue
        } else {
            // problematic domain: neither ASCII acceptable characters
            // nor IDN-punycodable, so throw exception
            // TODO change to HeritrixURIException so distinguishable
            // from URIExceptions in library code
            URIException ue = new URIException(e + " " + label);
            ue.initCause(e);
            throw ue;
        }
    }
    label = label.toLowerCase();
    return label;
}

From source file:com.cyberway.issue.net.UURIFactory.java

/**
 * Fixup the domain label part of the authority.
 * // ww  w. jav a 2 s  .c o  m
 * We're more lax than the spec. in that we allow underscores.
 * 
 * @param label Domain label to fix.
 * @return Return fixed domain label.
 * @throws URIException
 */
private String fixupDomainlabel(String label) throws URIException {

    // apply IDN-punycoding, as necessary
    try {
        // TODO: optimize: only apply when necessary, or
        // keep cache of recent encodings
        label = IDNA.toASCII(label);
    } catch (IDNAException e) {
        if (TextUtils.matches(ACCEPTABLE_ASCII_DOMAIN, label)) {
            // domain name has ACE prefix, leading/trailing dash, or 
            // underscore -- but is still a name we wish to tolerate;
            // simply continue
        } else {
            // problematic domain: neither ASCII acceptable characters
            // nor IDN-punycodable, so throw exception 
            // TODO: change to HeritrixURIException so distinguishable
            // from URIExceptions in library code
            URIException ue = new URIException(e + " " + label);
            ue.initCause(e);
            throw ue;
        }
    }
    label = label.toLowerCase();
    return label;
}