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