LinkedHashMap<String, ResourceMethodMediaType> supported = new LinkedHashMap<String, ResourceMethodMediaType>();
for (ResourceMethod resource : resourceList) {
for (ResourceMethodMediaType mediaType : resource.getApplicableMediaTypes()) {
for (String applicableType : findAllKnownTypesAcceptableTo(mediaType)) {
ResourceMethodMediaType type = supported.get(applicableType);
if (type == null) {
type = new ResourceMethodMediaType();
type.setType(applicableType);
supported.put(applicableType, type);
}
type.setProduceable(type.isProduceable() || mediaType.isProduceable());
type.setConsumable(type.isConsumable() || mediaType.isConsumable());
if (mediaType.isProduceable()) {
//if the media type is produceable, we want to add any subcontexts
//where the type might be mounted. This will only happen for
//the media types that have ids.
Map<String, Set<String>> subcontextMap = (Map<String, Set<String>>) resource.getMetaData().get("subcontexts");
if (subcontextMap != null) {
type.setSubcontexts(subcontextMap.get(applicableType));
}
}
}
}
}