Java 类org.apache.http.conn.UnsupportedSchemeException 实例源码

项目:remote-files-sync    文件:HttpClientConnectionOperator.java   
public void upgrade(
        final ManagedHttpClientConnection conn,
        final HttpHost host,
        final HttpContext context) throws IOException {
    final HttpClientContext clientContext = HttpClientContext.adapt(context);
    final Lookup<ConnectionSocketFactory> registry = getSocketFactoryRegistry(clientContext);
    final ConnectionSocketFactory sf = registry.lookup(host.getSchemeName());
    if (sf == null) {
        throw new UnsupportedSchemeException(host.getSchemeName() +
                " protocol is not supported");
    }
    if (!(sf instanceof LayeredConnectionSocketFactory)) {
        throw new UnsupportedSchemeException(host.getSchemeName() +
                " protocol does not support connection upgrade");
    }
    final LayeredConnectionSocketFactory lsf = (LayeredConnectionSocketFactory) sf;
    Socket sock = conn.getSocket();
    final int port = this.schemePortResolver.resolve(host);
    sock = lsf.createLayeredSocket(sock, host.getHostName(), port, context);
    conn.bind(sock);
}
项目:remote-files-sync    文件:DefaultRoutePlanner.java   
public HttpRoute determineRoute(
        final HttpHost host,
        final HttpRequest request,
        final HttpContext context) throws HttpException {
    Args.notNull(request, "Request");
    if (host == null) {
        throw new ProtocolException("Target host is not specified");
    }
    final HttpClientContext clientContext = HttpClientContext.adapt(context);
    final RequestConfig config = clientContext.getRequestConfig();
    final InetAddress local = config.getLocalAddress();
    HttpHost proxy = config.getProxy();
    if (proxy == null) {
        proxy = determineProxy(host, request, context);
    }

    final HttpHost target;
    if (host.getPort() <= 0) {
        try {
            target = new HttpHost(
                    host.getHostName(),
                    this.schemePortResolver.resolve(host),
                    host.getSchemeName());
        } catch (final UnsupportedSchemeException ex) {
            throw new HttpException(ex.getMessage());
        }
    } else {
        target = host;
    }
    final boolean secure = target.getSchemeName().equalsIgnoreCase("https");
    if (proxy == null) {
        return new HttpRoute(target, local, secure);
    } else {
        return new HttpRoute(target, local, proxy, secure);
    }
}
项目:purecloud-iot    文件:DefaultSchemePortResolver.java   
@Override
public int resolve(final HttpHost host) throws UnsupportedSchemeException {
    Args.notNull(host, "HTTP host");
    final int port = host.getPort();
    if (port > 0) {
        return port;
    }
    final String name = host.getSchemeName();
    if (name.equalsIgnoreCase("http")) {
        return 80;
    } else if (name.equalsIgnoreCase("https")) {
        return 443;
    } else {
        throw new UnsupportedSchemeException(name + " protocol is not supported");
    }
}
项目:purecloud-iot    文件:DefaultRoutePlanner.java   
@Override
public HttpRoute determineRoute(
        final HttpHost host,
        final HttpRequest request,
        final HttpContext context) throws HttpException {
    Args.notNull(request, "Request");
    if (host == null) {
        throw new ProtocolException("Target host is not specified");
    }
    final HttpClientContext clientContext = HttpClientContext.adapt(context);
    final RequestConfig config = clientContext.getRequestConfig();
    final InetAddress local = config.getLocalAddress();
    HttpHost proxy = config.getProxy();
    if (proxy == null) {
        proxy = determineProxy(host, request, context);
    }

    final HttpHost target;
    if (host.getPort() <= 0) {
        try {
            target = new HttpHost(
                    host.getHostName(),
                    this.schemePortResolver.resolve(host),
                    host.getSchemeName());
        } catch (final UnsupportedSchemeException ex) {
            throw new HttpException(ex.getMessage());
        }
    } else {
        target = host;
    }
    final boolean secure = target.getSchemeName().equalsIgnoreCase("https");
    if (proxy == null) {
        return new HttpRoute(target, local, secure);
    } else {
        return new HttpRoute(target, local, proxy, secure);
    }
}
项目:purecloud-iot    文件:DefaultHttpClientConnectionOperator.java   
@Override
public void upgrade(
        final ManagedHttpClientConnection conn,
        final HttpHost host,
        final HttpContext context) throws IOException {
    final HttpClientContext clientContext = HttpClientContext.adapt(context);
    final Lookup<ConnectionSocketFactory> registry = getSocketFactoryRegistry(clientContext);
    final ConnectionSocketFactory sf = registry.lookup(host.getSchemeName());
    if (sf == null) {
        throw new UnsupportedSchemeException(host.getSchemeName() +
                " protocol is not supported");
    }
    if (!(sf instanceof LayeredConnectionSocketFactory)) {
        throw new UnsupportedSchemeException(host.getSchemeName() +
                " protocol does not support connection upgrade");
    }
    final LayeredConnectionSocketFactory lsf = (LayeredConnectionSocketFactory) sf;
    Socket sock = conn.getSocket();
    final int port = this.schemePortResolver.resolve(host);
    sock = lsf.createLayeredSocket(sock, host.getHostName(), port, context);
    conn.bind(sock);
}
项目:Visit    文件:HttpClientConnectionOperator.java   
public void upgrade(
        final ManagedHttpClientConnection conn,
        final HttpHost host,
        final HttpContext context) throws IOException {
    final HttpClientContext clientContext = HttpClientContext.adapt(context);
    final Lookup<ConnectionSocketFactory> registry = getSocketFactoryRegistry(clientContext);
    final ConnectionSocketFactory sf = registry.lookup(host.getSchemeName());
    if (sf == null) {
        throw new UnsupportedSchemeException(host.getSchemeName() +
                " protocol is not supported");
    }
    if (!(sf instanceof LayeredConnectionSocketFactory)) {
        throw new UnsupportedSchemeException(host.getSchemeName() +
                " protocol does not support connection upgrade");
    }
    final LayeredConnectionSocketFactory lsf = (LayeredConnectionSocketFactory) sf;
    Socket sock = conn.getSocket();
    final int port = this.schemePortResolver.resolve(host);
    sock = lsf.createLayeredSocket(sock, host.getHostName(), port, context);
    conn.bind(sock);
}
项目:ZTLib    文件:HttpClientConnectionOperator.java   
public void upgrade(
        final ManagedHttpClientConnection conn,
        final HttpHost host,
        final HttpContext context) throws IOException {
    final HttpClientContext clientContext = HttpClientContext.adapt(context);
    final Lookup<ConnectionSocketFactory> registry = getSocketFactoryRegistry(clientContext);
    final ConnectionSocketFactory sf = registry.lookup(host.getSchemeName());
    if (sf == null) {
        throw new UnsupportedSchemeException(host.getSchemeName() +
                " protocol is not supported");
    }
    if (!(sf instanceof LayeredConnectionSocketFactory)) {
        throw new UnsupportedSchemeException(host.getSchemeName() +
                " protocol does not support connection upgrade");
    }
    final LayeredConnectionSocketFactory lsf = (LayeredConnectionSocketFactory) sf;
    Socket sock = conn.getSocket();
    final int port = this.schemePortResolver.resolve(host);
    sock = lsf.createLayeredSocket(sock, host.getHostName(), port, context);
    conn.bind(sock);
}
项目:remote-files-sync    文件:BasicAuthCache.java   
protected HttpHost getKey(final HttpHost host) {
    if (host.getPort() <= 0) {
        final int port;
        try {
            port = schemePortResolver.resolve(host);
        } catch (final UnsupportedSchemeException ignore) {
            return host;
        }
        return new HttpHost(host.getHostName(), port, host.getSchemeName());
    } else {
        return host;
    }
}
项目:remote-files-sync    文件:DefaultSchemePortResolver.java   
public int resolve(final HttpHost host) throws UnsupportedSchemeException {
    Args.notNull(host, "HTTP host");
    final int port = host.getPort();
    if (port > 0) {
        return port;
    }
    final String name = host.getSchemeName();
    if (name.equalsIgnoreCase("http")) {
        return 80;
    } else if (name.equalsIgnoreCase("https")) {
        return 443;
    } else {
        throw new UnsupportedSchemeException(name + " protocol is not supported");
    }
}
项目:igsn30    文件:OAIService.java   
public JAXBConverterInterface getSuitableConverter(String metadataPrefix) throws UnsupportedSchemeException{
    for(JAXBConverterInterface converter:this.jaxbConverterInterface){
        if(converter.supports(metadataPrefix)){
            return converter;
        }
    }

    throw new UnsupportedSchemeException("Unable to find a converter that supports this schema");
}
项目:Bastion    文件:TestWithProxiedEmbeddedServer.java   
private static DefaultSchemePortResolver prepareSchemePortResolver() {
    return new DefaultSchemePortResolver() {
        @Override
        public int resolve(HttpHost host) throws UnsupportedSchemeException {
            if (host.getHostName().equalsIgnoreCase("sushi-shop.test")) {
                return 9876;
            } else {
                return super.resolve(host);
            }
        }
    };
}
项目:purecloud-iot    文件:BasicAuthCache.java   
protected HttpHost getKey(final HttpHost host) {
    if (host.getPort() <= 0) {
        final int port;
        try {
            port = schemePortResolver.resolve(host);
        } catch (final UnsupportedSchemeException ignore) {
            return host;
        }
        return new HttpHost(host.getHostName(), port, host.getSchemeName());
    } else {
        return host;
    }
}
项目:purecloud-iot    文件:TestHttpClientConnectionOperator.java   
@Test(expected=UnsupportedSchemeException.class)
public void testUpgradeUpsupportedScheme() throws Exception {
    final HttpContext context = new BasicHttpContext();
    final HttpHost host = new HttpHost("somehost", -1, "httpsssss");
    Mockito.when(socketFactoryRegistry.lookup("http")).thenReturn(plainSocketFactory);

    connectionOperator.upgrade(conn, host, context);
}
项目:purecloud-iot    文件:TestHttpClientConnectionOperator.java   
@Test(expected=UnsupportedSchemeException.class)
public void testUpgradeNonLayeringScheme() throws Exception {
    final HttpContext context = new BasicHttpContext();
    final HttpHost host = new HttpHost("somehost", -1, "http");
    Mockito.when(socketFactoryRegistry.lookup("http")).thenReturn(plainSocketFactory);

    connectionOperator.upgrade(conn, host, context);
}
项目:Visit    文件:BasicAuthCache.java   
protected HttpHost getKey(final HttpHost host) {
    if (host.getPort() <= 0) {
        final int port;
        try {
            port = schemePortResolver.resolve(host);
        } catch (final UnsupportedSchemeException ignore) {
            return host;
        }
        return new HttpHost(host.getHostName(), port, host.getSchemeName());
    } else {
        return host;
    }
}
项目:Visit    文件:DefaultSchemePortResolver.java   
public int resolve(final HttpHost host) throws UnsupportedSchemeException {
    Args.notNull(host, "HTTP host");
    final int port = host.getPort();
    if (port > 0) {
        return port;
    }
    final String name = host.getSchemeName();
    if (name.equalsIgnoreCase("http")) {
        return 80;
    } else if (name.equalsIgnoreCase("https")) {
        return 443;
    } else {
        throw new UnsupportedSchemeException(name + " protocol is not supported");
    }
}
项目:Visit    文件:DefaultRoutePlanner.java   
public HttpRoute determineRoute(
        final HttpHost host,
        final HttpRequest request,
        final HttpContext context) throws HttpException {
    Args.notNull(request, "Request");
    if (host == null) {
        throw new ProtocolException("Target host is not specified");
    }
    final HttpClientContext clientContext = HttpClientContext.adapt(context);
    final RequestConfig config = clientContext.getRequestConfig();
    final InetAddress local = config.getLocalAddress();
    HttpHost proxy = config.getProxy();
    if (proxy == null) {
        proxy = determineProxy(host, request, context);
    }

    final HttpHost target;
    if (host.getPort() <= 0) {
        try {
            target = new HttpHost(
                    host.getHostName(),
                    this.schemePortResolver.resolve(host),
                    host.getSchemeName());
        } catch (final UnsupportedSchemeException ex) {
            throw new HttpException(ex.getMessage());
        }
    } else {
        target = host;
    }
    final boolean secure = target.getSchemeName().equalsIgnoreCase("https");
    if (proxy == null) {
        return new HttpRoute(target, local, secure);
    } else {
        return new HttpRoute(target, local, proxy, secure);
    }
}
项目:SolRDF    文件:IntegrationTestSupertypeLayer.java   
/**
 * Initilisation procedure for this test case.
 * 
 * @throws UnableToBuildSolRDFClientException in case the client cannot be built.
 * @throws Exception in case of Solr startup failure.
 */
@BeforeClass
public static void initITTest() {
    System.setProperty("tests.asserts", "false");   
    System.setProperty("jetty.port", "8080");
    System.setProperty("solr.core.name", "store");
    System.setProperty("solr.data.dir", initCoreDataDir.getAbsolutePath());

    try {
        SOLR = createJetty(
                "target/solrdf-integration-tests-1.1-dev/solrdf",
                JettyConfig.builder()
                    .setPort(8080)
                    .setContext("/solr")
                    .stopAtShutdown(true)
                    .build());      

        final HttpClient httpClient = HttpClientBuilder.create()
                .setRoutePlanner(
                        new DefaultRoutePlanner(
                                new SchemePortResolver() {
                                    @Override
                                    public int resolve(final HttpHost host) throws UnsupportedSchemeException {
                                        return SOLR.getLocalPort();
                                    }
                                })).build();


        SOLRDF_CLIENT = SolRDF.newBuilder()
                  .withEndpoint("http://127.0.0.1:8080/solr/store")
                  .withGraphStoreProtocolEndpointPath("/rdf-graph-store")
                  .withHttpClient(httpClient)
                  .withSPARQLEndpointPath("/sparql")
                  .build();

        PLAIN_SOLR_CLIENT = new HttpSolrClient(SOLR_URI);
    } catch (final Exception exception) {
        throw new RuntimeException(exception);
    }
}
项目:ZTLib    文件:BasicAuthCache.java   
protected HttpHost getKey(final HttpHost host) {
    if (host.getPort() <= 0) {
        final int port;
        try {
            port = schemePortResolver.resolve(host);
        } catch (final UnsupportedSchemeException ignore) {
            return host;
        }
        return new HttpHost(host.getHostName(), port, host.getSchemeName());
    } else {
        return host;
    }
}
项目:ZTLib    文件:DefaultSchemePortResolver.java   
public int resolve(final HttpHost host) throws UnsupportedSchemeException {
    Args.notNull(host, "HTTP host");
    final int port = host.getPort();
    if (port > 0) {
        return port;
    }
    final String name = host.getSchemeName();
    if (name.equalsIgnoreCase("http")) {
        return 80;
    } else if (name.equalsIgnoreCase("https")) {
        return 443;
    } else {
        throw new UnsupportedSchemeException(name + " protocol is not supported");
    }
}
项目:ZTLib    文件:DefaultRoutePlanner.java   
public HttpRoute determineRoute(
        final HttpHost host,
        final HttpRequest request,
        final HttpContext context) throws HttpException {
    Args.notNull(request, "Request");
    if (host == null) {
        throw new ProtocolException("Target host is not specified");
    }
    final HttpClientContext clientContext = HttpClientContext.adapt(context);
    final RequestConfig config = clientContext.getRequestConfig();
    final InetAddress local = config.getLocalAddress();
    HttpHost proxy = config.getProxy();
    if (proxy == null) {
        proxy = determineProxy(host, request, context);
    }

    final HttpHost target;
    if (host.getPort() <= 0) {
        try {
            target = new HttpHost(
                    host.getHostName(),
                    this.schemePortResolver.resolve(host),
                    host.getSchemeName());
        } catch (final UnsupportedSchemeException ex) {
            throw new HttpException(ex.getMessage());
        }
    } else {
        target = host;
    }
    final boolean secure = target.getSchemeName().equalsIgnoreCase("https");
    if (proxy == null) {
        return new HttpRoute(target, local, secure);
    } else {
        return new HttpRoute(target, local, proxy, secure);
    }
}
项目:igsn30    文件:OAIService.java   
public JAXBElement<OAIPMHtype> getListIdentifier(List<Resources> resources, String metadataPrefix, String from, String until, Long totalCount, TokenResumption tokenResumption) throws DatatypeConfigurationException, JAXBException, UnsupportedSchemeException{

    if(resources.isEmpty()){
        return this.getNoRecordMatch(VerbType.LIST_RECORDS);
    }

    //VT: Find suitable converter
    JAXBConverterInterface converter = this.getSuitableConverter(metadataPrefix);
    if(converter==null){
        return this.getCannotDisseminateFormat(VerbType.LIST_IDENTIFIERS);
    }

    OAIPMHtype oaiType = oaiObjectFactory.createOAIPMHtype();

    //VT:Set response Date
    oaiType.setResponseDate(DatatypeFactory.newInstance().newXMLGregorianCalendar(dateFormatterLong.format(new Date())));

    //VT:Set Request Type
    RequestType requestType = new RequestType();
    requestType.setVerb(VerbType.LIST_IDENTIFIERS);
    if(tokenResumption == null){
        if(from != null && !from.isEmpty()){
            requestType.setFrom(from);
        }       
        if(until !=null && !until.isEmpty()){
            requestType.setUntil(until);
        }
        requestType.setMetadataPrefix(metadataPrefix);
    }else{
        requestType.setResumptionToken(tokenResumption.getKey());
    }
    requestType.setValue(OAI_BASEURL_VALUE);
    oaiType.setRequest(requestType);

    //VT:GetRecord
    ListIdentifiersType listIdentifiersType = new ListIdentifiersType();

    for(Resources resource : resources){            
        HeaderType headerType = new HeaderType();       

        //GetRecord header
        headerType.setIdentifier(OAI_IDENTIFIER_PREFIX + resource.getResourceIdentifier());
        headerType.setDatestamp(dateFormatterShort.format(resource.getModified()));
        if(resource.getLogDate()!=null && isDeleted(resource.getLogDate().getEventType())){
            headerType.setStatus(StatusType.DELETED);
        }               

        listIdentifiersType.getHeader().add(headerType);
    }


    listIdentifiersType.setResumptionToken(manageResumptionToken( metadataPrefix,  from,  until,  totalCount,  tokenResumption));
    oaiType.setListIdentifiers(listIdentifiersType);    

    JAXBElement<OAIPMHtype> oaipmh = oaiObjectFactory.createOAIPMH(oaiType);
    return oaipmh;
}