private synchronized void fixMediaTypes(DeploymentConfiguration config) {
if (fixed) {
return;
}
// FIXME: A hacky workaround for https://issues.apache.org/jira/browse/TUSCANY-3572
ResourceRecord record = config.getResourceRegistry().getRecord(resourceClass);
for (MethodMetadata methodMetadata : record.getMetadata().getResourceMethods()) {
String method = methodMetadata.getHttpMethod();
if (HttpMethod.GET.equals(method) || HttpMethod.HEAD.equals(method) || HttpMethod.DELETE.equals(method)) {
methodMetadata.addConsumes(MediaType.APPLICATION_OCTET_STREAM_TYPE);
methodMetadata.addConsumes(MediaType.WILDCARD_TYPE);
}
if (HttpMethod.HEAD.equals(method) || HttpMethod.DELETE.equals(method)) {
methodMetadata.addProduces(MediaType.APPLICATION_OCTET_STREAM_TYPE);
methodMetadata.addConsumes(MediaType.WILDCARD_TYPE);
}
}
for (MethodMetadata methodMetadata : record.getMetadata().getSubResourceMethods()) {
String method = methodMetadata.getHttpMethod();
if (HttpMethod.GET.equals(method) || HttpMethod.HEAD.equals(method) || HttpMethod.DELETE.equals(method)) {
methodMetadata.addConsumes(MediaType.APPLICATION_OCTET_STREAM_TYPE);
methodMetadata.addConsumes(MediaType.WILDCARD_TYPE);
}