类javax.ws.rs.core.NoContentException源码实例Demo

下面列出了怎么用javax.ws.rs.core.NoContentException的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: quarkus   文件: JsonObjectReader.java
@Override
public JsonObject readFrom(Class<JsonObject> type, Type genericType, Annotation[] annotations, MediaType mediaType,
        MultivaluedMap<String, String> httpHeaders, InputStream entityStream) throws IOException, WebApplicationException {
    byte[] bytes = getBytes(entityStream);
    if (bytes.length == 0) {
        throw new NoContentException("Cannot create JsonObject");
    }
    return new JsonObject(Buffer.buffer(bytes));
}
 
源代码2 项目: quarkus   文件: JsonArrayReader.java
@Override
public JsonArray readFrom(Class<JsonArray> type, Type genericType, Annotation[] annotations, MediaType mediaType,
        MultivaluedMap<String, String> httpHeaders, InputStream entityStream) throws IOException, WebApplicationException {
    byte[] bytes = getBytes(entityStream);
    if (bytes.length == 0) {
        throw new NoContentException("Cannot create JsonArray");
    }
    return new JsonArray(Buffer.buffer(bytes));
}
 
源代码3 项目: jax-rs-moshi   文件: MoshiMessageBodyReader.java
@Override public Object readFrom(Class<Object> type, Type genericType, Annotation[] annotations,
    MediaType mediaType, MultivaluedMap<String, String> httpHeaders, InputStream entityStream)
    throws IOException, WebApplicationException {
  JsonAdapter<Object> adapter = moshi.adapter(genericType);
  BufferedSource source = Okio.buffer(Okio.source(entityStream));
  if (!source.request(1)) {
    throw new NoContentException("Stream is empty");
  }
  return adapter.fromJson(source);
  // Note: we do not close the InputStream per the interface documentation.
}
 
源代码4 项目: jax-rs-moshi   文件: MoshiMessageBodyReaderTest.java
@Test public void emptyReadThrows() throws IOException {
  Buffer data = new Buffer();
  Class<Object> type = (Class) String.class;
  try {
    reader.readFrom(type, type, new Annotation[0], APPLICATION_JSON_TYPE,
        new MultivaluedHashMap<>(),
        data.inputStream());
    fail();
  } catch (NoContentException ignored) {
  }
}
 
源代码5 项目: cxf   文件: PrimitiveTextProviderTest.java
@SuppressWarnings({
    "unchecked", "rawtypes"
})
@Test(expected = NoContentException.class)
public void testReadEmptyByte() throws Exception {
    MessageBodyReader<?> p = new PrimitiveTextProvider<>();

    p.readFrom((Class)Byte.TYPE, null, null,
                                      null,
                                      null,
                                      new ByteArrayInputStream("".getBytes()));


}
 
源代码6 项目: cxf   文件: AbstractConfigurableProvider.java
protected void reportEmptyContentLength() throws NoContentException {
    String message = new org.apache.cxf.common.i18n.Message("EMPTY_BODY", BUNDLE).toString();
    LOG.warning(message);
    throw new NoContentException(message);
}