}
}
private void processRequest(Message message) {
ProviderFactory providerFactory = ProviderFactory.getInstance(message);
RequestPreprocessor rp = providerFactory.getRequestPreprocessor();
if (rp != null) {
rp.preprocess(message, new UriInfoImpl(message, null));
if (message.getExchange().get(Response.class) != null) {
return;
}
}
// Global pre-match request filters
if (JAXRSUtils.runContainerRequestFilters(providerFactory, message, true, null)) {
return;
}
// HTTP method
String httpMethod = HttpUtils.getProtocolHeader(message, Message.HTTP_REQUEST_METHOD,
HttpMethod.POST, true);
// Path to match
String rawPath = HttpUtils.getPathToMatch(message, true);
Map<String, List<String>> protocolHeaders = CastUtils.cast((Map<?, ?>)message.get(Message.PROTOCOL_HEADERS));
// Content-Type
String requestContentType = null;
List<String> ctHeaderValues = protocolHeaders.get(Message.CONTENT_TYPE);
if (ctHeaderValues != null) {
requestContentType = ctHeaderValues.get(0);
message.put(Message.CONTENT_TYPE, requestContentType);
}
if (requestContentType == null) {
requestContentType = (String)message.get(Message.CONTENT_TYPE);
if (requestContentType == null) {
requestContentType = MediaType.WILDCARD;
}
}
// Accept
String acceptTypes = null;
List<String> acceptHeaderValues = protocolHeaders.get(Message.ACCEPT_CONTENT_TYPE);
if (acceptHeaderValues != null) {
acceptTypes = acceptHeaderValues.get(0);
message.put(Message.ACCEPT_CONTENT_TYPE, acceptTypes);
}
if (acceptTypes == null) {
acceptTypes = HttpUtils.getProtocolHeader(message, Message.ACCEPT_CONTENT_TYPE, null);
if (acceptTypes == null) {
acceptTypes = "*/*";
message.put(Message.ACCEPT_CONTENT_TYPE, acceptTypes);
}
}
List<MediaType> acceptContentTypes = null;
try {
acceptContentTypes = JAXRSUtils.sortMediaTypes(acceptTypes, JAXRSUtils.MEDIA_TYPE_Q_PARAM);
} catch (IllegalArgumentException ex) {
throw ExceptionUtils.toNotAcceptableException(null, null);
}
message.getExchange().put(Message.ACCEPT_CONTENT_TYPE, acceptContentTypes);
//1. Matching target resource class
Service service = message.getExchange().get(Service.class);
List<ClassResourceInfo> resources = ((JAXRSServiceImpl)service).getClassResourceInfos();
MultivaluedMap<String, String> values = new MetadataMap<String, String>();
ClassResourceInfo resource = JAXRSUtils.selectResourceClass(resources,
rawPath,
values,
message);
if (resource == null) {
org.apache.cxf.common.i18n.Message errorMsg =
new org.apache.cxf.common.i18n.Message("NO_ROOT_EXC",
BUNDLE,
message.get(Message.REQUEST_URI),
rawPath);
LOG.warning(errorMsg.toString());
Response resp = JAXRSUtils.createResponse(null, message, errorMsg.toString(),
Response.Status.NOT_FOUND.getStatusCode(), false);
throw ExceptionUtils.toNotFoundException(null, resp);
}
message.getExchange().put(JAXRSUtils.ROOT_RESOURCE_CLASS, resource);
OperationResourceInfo ori = null;
boolean operChecked = false;
List<ProviderInfo<RequestHandler>> shs = providerFactory.getRequestHandlers();
for (ProviderInfo<RequestHandler> sh : shs) {
if (ori == null && !operChecked) {
try {
ori = JAXRSUtils.findTargetMethod(resource,
message, httpMethod, values,