use of org.apache.qpid.server.model.CustomRestHeaders in project qpid-broker-j by apache.
the class AbstractServlet method getResponseHeaders.
private Map<String, Object> getResponseHeaders(final Object content) {
Map<String, Object> headers = Collections.emptyMap();
if (content instanceof CustomRestHeaders) {
CustomRestHeaders customRestHeaders = (CustomRestHeaders) content;
Map<RestContentHeader, Method> contentHeaderGetters = getContentHeaderMethods(customRestHeaders);
if (contentHeaderGetters != null) {
headers = new HashMap<>();
for (Map.Entry<RestContentHeader, Method> entry : contentHeaderGetters.entrySet()) {
final String headerName = entry.getKey().value();
try {
final Object headerValue = entry.getValue().invoke(customRestHeaders);
if (headerValue != null) {
headers.put(headerName.toUpperCase(), headerValue);
}
} catch (Exception e) {
LOGGER.warn("Unexpected exception whilst setting response header " + headerName, e);
}
}
}
}
return headers;
}
Aggregations