类org.apache.http.MethodNotSupportedException源码实例Demo

下面列出了怎么用org.apache.http.MethodNotSupportedException的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: v20-java   文件: Context.java
private HttpUriRequest newHttpRequest(String method, URI uri)
    throws MethodNotSupportedException
{
    if (method == "GET")
        return new HttpGet(uri);
    if (method == "POST")
        return new HttpPost(uri);
    if (method == "PUT")
        return new HttpPut(uri);
    if (method == "DELETE")
        return new HttpDelete(uri);
    if (method == "PATCH")
        return new HttpPatch(uri);

    throw new MethodNotSupportedException(
        "Invalid method \"" + method + "\""
    );
}
 
public void handle(
		final HttpRequest request, 
		final HttpResponse response,
		final HttpContext context) throws HttpException, IOException {

	final String method = request.getRequestLine().getMethod().toUpperCase(Locale.ENGLISH);
	if (!method.equals("GET") && !method.equals("HEAD")) {
		throw new MethodNotSupportedException(method + " method not supported"); 
	}

	final EntityTemplate body = new EntityTemplate(new ContentProducer() {
		public void writeTo(final OutputStream outstream) throws IOException {
			OutputStreamWriter writer = new OutputStreamWriter(outstream, "UTF-8"); 
			writer.write(mJSON);
			writer.flush();
		}
	});

	response.setStatusCode(HttpStatus.SC_OK);
	body.setContentType("text/json; charset=UTF-8");
	response.setEntity(body);

}
 
源代码3 项目: TVRemoteIME   文件: UpnpHttpRequestFactory.java
public HttpRequest newHttpRequest(final RequestLine requestline)
        throws MethodNotSupportedException {
    if (requestline == null) {
        throw new IllegalArgumentException("Request line may not be null");
    }
    String method = requestline.getMethod();
    String uri = requestline.getUri();
    return newHttpRequest(method, uri);
}
 
源代码4 项目: TVRemoteIME   文件: UpnpHttpRequestFactory.java
public HttpRequest newHttpRequest(final String method, final String uri) throws MethodNotSupportedException {
    if (isOneOf(BASIC, method)) {
        return new BasicHttpRequest(method, uri);
    } else if (isOneOf(WITH_ENTITY, method)) {
        return new BasicHttpEntityEnclosingRequest(method, uri);
    } else {
        return super.newHttpRequest(method, uri);
    }
}
 
源代码5 项目: DroidDLNA   文件: UpnpHttpRequestFactory.java
public HttpRequest newHttpRequest(final RequestLine requestline)
        throws MethodNotSupportedException {
    if (requestline == null) {
        throw new IllegalArgumentException("Request line may not be null");
    }
    String method = requestline.getMethod();
    String uri = requestline.getUri();
    return newHttpRequest(method, uri);
}
 
源代码6 项目: DroidDLNA   文件: UpnpHttpRequestFactory.java
public HttpRequest newHttpRequest(final String method, final String uri) throws MethodNotSupportedException {
    if (isOneOf(BASIC, method)) {
        return new BasicHttpRequest(method, uri);
    } else if (isOneOf(WITH_ENTITY, method)) {
        return new BasicHttpEntityEnclosingRequest(method, uri);
    } else {
        return super.newHttpRequest(method, uri);
    }
}
 
public void handle(HttpRequest request, HttpResponse response, HttpContext context) throws HttpException,
		IOException
{
	try
	{
		String method = request.getRequestLine().getMethod().toUpperCase(Locale.ENGLISH);
		if (METHOD_GET.equals(method) || METHOD_HEAD.equals(method))
		{
			handleRequest(request, response, METHOD_HEAD.equals(method));
		}
		else if (METHOD_POST.equals(method))
		{
			handleRequest(request, response, METHOD_HEAD.equals(method));
		}
		else
		{
			throw new MethodNotSupportedException(MessageFormat.format(
					Messages.LocalWebServerHttpRequestHandler_UNSUPPORTED_METHOD, method));
		}
	}
	catch (Exception e)
	{
		IdeLog.logError(WebServerCorePlugin.getDefault(), e);
		response.setStatusCode(HttpStatus.SC_INTERNAL_SERVER_ERROR);
		response.setEntity(createTextEntity(Messages.LocalWebServerHttpRequestHandler_INTERNAL_SERVER_ERROR));
	}
}
 
源代码8 项目: geoar-app   文件: NewGridFeature.java
@Override
public void setColor(float[] colorArray) {
	try {
		throw new MethodNotSupportedException(
				"Setting Color array is not supported atm");
	} catch (MethodNotSupportedException e) { // Lol...
		LOG.debug("setColor array is not supported atm");
		e.printStackTrace();
	}
}
 
源代码9 项目: sana.mobile   文件: DispatchRequestFactory.java
@Override
public HttpRequest newHttpRequest(RequestLine requestLine)
        throws MethodNotSupportedException {
    String method = requestLine.getMethod();
    String uri = requestLine.getUri();
    return this.newHttpRequest(method, uri);
}
 
源代码10 项目: openhab1-addons   文件: StreamClientImpl.java
protected HttpUriRequest createHttpRequest(UpnpMessage upnpMessage, UpnpRequest upnpRequestOperation)
        throws MethodNotSupportedException {

    switch (upnpRequestOperation.getMethod()) {
        case GET:
            return new HttpGet(upnpRequestOperation.getURI());
        case SUBSCRIBE:
            return new HttpGet(upnpRequestOperation.getURI()) {
                @Override
                public String getMethod() {
                    return UpnpRequest.Method.SUBSCRIBE.getHttpName();
                }
            };
        case UNSUBSCRIBE:
            return new HttpGet(upnpRequestOperation.getURI()) {
                @Override
                public String getMethod() {
                    return UpnpRequest.Method.UNSUBSCRIBE.getHttpName();
                }
            };
        case POST:
            HttpEntityEnclosingRequest post = new HttpPost(upnpRequestOperation.getURI());
            post.setEntity(createHttpRequestEntity(upnpMessage));
            return (HttpUriRequest) post; // Fantastic API
        case NOTIFY:
            HttpEntityEnclosingRequest notify = new HttpPost(upnpRequestOperation.getURI()) {
                @Override
                public String getMethod() {
                    return UpnpRequest.Method.NOTIFY.getHttpName();
                }
            };
            notify.setEntity(createHttpRequestEntity(upnpMessage));
            return (HttpUriRequest) notify; // Fantastic API
        default:
            throw new MethodNotSupportedException(upnpRequestOperation.getHttpMethodName());
    }

}
 
源代码11 项目: neo4jena   文件: NeoGraph.java
@Override
public void clear() {
	throw new RuntimeException(new MethodNotSupportedException("clear"));
}
 
源代码12 项目: neo4jena   文件: NeoGraph.java
@Override
public boolean dependsOn(Graph arg0) {
	throw new RuntimeException(new MethodNotSupportedException("dependsOn"));
}
 
源代码13 项目: neo4jena   文件: NeoGraph.java
@Override
public BulkUpdateHandler getBulkUpdateHandler() {
		throw new RuntimeException(new MethodNotSupportedException("getBulUpdate"));
}
 
源代码14 项目: neo4jena   文件: NeoGraph.java
@Override
public GraphStatisticsHandler getStatisticsHandler() {
	throw new RuntimeException(new MethodNotSupportedException("getStatsHandler"));
}
 
源代码15 项目: neo4jena   文件: NeoGraph.java
@Override
public TransactionHandler getTransactionHandler() {
	throw new RuntimeException(new MethodNotSupportedException("getTransactionHandler"));
}
 
源代码16 项目: neo4jena   文件: NeoGraph.java
@Override
public boolean isIsomorphicWith(Graph arg0) {
	throw new RuntimeException(new MethodNotSupportedException("isIsomorphic"));
}
 
源代码17 项目: neo4jena   文件: NeoGraph.java
@Override
public void remove(Node arg0, Node arg1, Node arg2) {
	throw new RuntimeException(new MethodNotSupportedException("remove"));
}
 
源代码18 项目: neo4jena   文件: NeoGraph.java
@Override
public int size() {
	throw new RuntimeException(new MethodNotSupportedException("size"));
}
 
源代码19 项目: sana.mobile   文件: HttpRequestBuilder.java
public HttpRequest newHttpRequest(RequestLine requestLine)
        throws MethodNotSupportedException {
    String method = requestLine.getMethod();
    String uri = requestLine.getUri();
    return newHttpRequest(method, uri);
}
 
 类所在包
 类方法
 同包方法