@Override
public int doEndTag() throws JspException {
final ServletRequest request = pageContext.getRequest();
MediaRating rating;
if (request.getAttribute("content") != null
&& request.getAttribute("content") instanceof MediaContent) {
rating = ((MediaContent) request.getAttribute("content")).addExtension(MediaConstants.RATING);
} else if (request.getAttribute("group") != null
&& request.getAttribute("group") instanceof MediaGroup) {
rating = ((MediaGroup) request.getAttribute("group")).addExtension(MediaConstants.RATING);
} else if (request.getAttribute("entry") != null
&& request.getAttribute("entry") instanceof Entry) {
rating = ((Entry) request.getAttribute("entry")).addExtension(MediaConstants.RATING);
} else {
rating = ((Feed) request.getAttribute("feed")).addExtension(MediaConstants.RATING);
}
// set the body content
rating.setText(getBodyContent().getString());
// set the scheme
if (scheme != null) rating.setScheme(scheme);
return super.doEndTag();
}