Java Code Examples for javax.ws.rs.ext.ReaderInterceptorContext#getProperty()

The following examples show how to use javax.ws.rs.ext.ReaderInterceptorContext#getProperty() . 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: EmptyPayloadInterceptor.java    From hawkular-metrics with Apache License 2.0 6 votes vote down vote up
@Override
public Object aroundReadFrom(ReaderInterceptorContext context) throws IOException, WebApplicationException {
    Object object = context.proceed();
    if (context.getProperty(EMPTY_PAYLOAD) != TRUE) {
        return object;
    }
    if (object instanceof Collection) {
        Collection<?> collection = (Collection<?>) object;
        if (collection.isEmpty()) {
            throw new EmptyPayloadException();
        }
    } else if (object instanceof Map) {
        Map<?, ?> map = (Map<?, ?>) object;
        if (map.isEmpty()) {
            throw new EmptyPayloadException();
        }
    } else if (object == null) {
        throw new EmptyPayloadException();
    }
    return object;
}
 
Example 2
Source File: CacheControlClientReaderInterceptor.java    From cxf with Apache License 2.0 5 votes vote down vote up
protected boolean isCacheControlValid(final ReaderInterceptorContext context,
                                      final CacheControl responseControl) {

    boolean valid =
        responseControl != null && !responseControl.isNoCache() && !responseControl.isNoStore();
    if (valid) {
        String clientHeader =
            (String)context.getProperty(CacheControlClientRequestFilter.CLIENT_CACHE_CONTROL);
        CacheControl clientControl = clientHeader == null ? null : CacheControl.valueOf(clientHeader);
        if (clientControl != null && clientControl.isPrivate() != responseControl.isPrivate()) {
            valid = false;
        }
    }
    return valid;
}