Java Code Examples for org.apache.cxf.jaxrs.utils.JAXRSUtils#logMessageHandlerProblem()
The following examples show how to use
org.apache.cxf.jaxrs.utils.JAXRSUtils#logMessageHandlerProblem() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ReaderInterceptorMBR.java From cxf with Apache License 2.0 | 6 votes |
@SuppressWarnings({ "unchecked", "rawtypes" }) @Override public Object aroundReadFrom(ReaderInterceptorContext c) throws IOException, WebApplicationException { Class entityCls = c.getType(); Type entityType = c.getGenericType(); MediaType entityMt = c.getMediaType(); Annotation[] entityAnns = c.getAnnotations(); if ((reader == null || m.get(ProviderFactory.PROVIDER_SELECTION_PROPERTY_CHANGED) == Boolean.TRUE && !reader.isReadable(entityCls, entityType, entityAnns, entityMt)) && entityStreamAvailable(c.getInputStream())) { reader = ProviderFactory.getInstance(m) .createMessageBodyReader(entityCls, entityType, entityAnns, entityMt, m); } if (reader == null) { String errorMessage = JAXRSUtils.logMessageHandlerProblem("NO_MSG_READER", entityCls, entityMt); throw new ProcessingException(errorMessage); } return reader.readFrom(entityCls, entityType, entityAnns, entityMt, new HttpHeadersImpl(m).getRequestHeaders(), c.getInputStream()); }
Example 2
Source File: JAXRSOutInterceptor.java From cxf with Apache License 2.0 | 5 votes |
private void writeResponseErrorMessage(Message message, OutputStream out, String name, Class<?> cls, MediaType ct) { message.put(Message.CONTENT_TYPE, "text/plain"); message.put(Message.RESPONSE_CODE, 500); try { String errorMessage = JAXRSUtils.logMessageHandlerProblem(name, cls, ct); if (out != null) { out.write(errorMessage.getBytes(StandardCharsets.UTF_8)); } } catch (IOException another) { // ignore } }
Example 3
Source File: WriterInterceptorMBW.java From cxf with Apache License 2.0 | 5 votes |
@SuppressWarnings("unchecked") @Override public void aroundWriteTo(WriterInterceptorContext c) throws IOException, WebApplicationException { MultivaluedMap<String, Object> headers = c.getHeaders(); Object mtObject = headers.getFirst(HttpHeaders.CONTENT_TYPE); MediaType entityMt = mtObject == null ? c.getMediaType() : JAXRSUtils.toMediaType(mtObject.toString()); m.put(Message.CONTENT_TYPE, entityMt.toString()); Class<?> entityCls = c.getType(); Type entityType = c.getGenericType(); Annotation[] entityAnns = c.getAnnotations(); if (writer == null || m.get(ProviderFactory.PROVIDER_SELECTION_PROPERTY_CHANGED) == Boolean.TRUE && !writer.isWriteable(entityCls, entityType, entityAnns, entityMt)) { writer = (MessageBodyWriter<Object>)ProviderFactory.getInstance(m) .createMessageBodyWriter(entityCls, entityType, entityAnns, entityMt, m); } if (writer == null) { String errorMessage = JAXRSUtils.logMessageHandlerProblem("NO_MSG_WRITER", entityCls, entityMt); throw new ProcessingException(errorMessage); } HttpUtils.convertHeaderValuesToString(headers, true); if (LOG.isLoggable(Level.FINE)) { LOG.fine("Response EntityProvider is: " + writer.getClass().getName()); } writer.writeTo(c.getEntity(), c.getType(), c.getGenericType(), c.getAnnotations(), entityMt, headers, c.getOutputStream()); }
Example 4
Source File: JAXRSOutInterceptor.java From cxf with Apache License 2.0 | 4 votes |
private void logWriteError(boolean firstTry, Class<?> cls, MediaType ct) { if (firstTry) { JAXRSUtils.logMessageHandlerProblem("MSG_WRITER_PROBLEM", cls, ct); } }
Example 5
Source File: ResponseImpl.java From cxf with Apache License 2.0 | 4 votes |
private void reportMessageHandlerProblem(String name, Class<?> cls, MediaType ct, Throwable cause) { String errorMessage = JAXRSUtils.logMessageHandlerProblem(name, cls, ct); throw new ResponseProcessingException(this, errorMessage, cause); }
Example 6
Source File: AbstractClient.java From cxf with Apache License 2.0 | 4 votes |
protected static void reportMessageHandlerProblem(String name, Class<?> cls, MediaType ct, Throwable ex) { String errorMessage = JAXRSUtils.logMessageHandlerProblem(name, cls, ct); Throwable actualEx = ex instanceof Fault ? ((Fault)ex).getCause() : ex; throw new ProcessingException(errorMessage, actualEx); }