public AtomDocumentResponse getMediaEntry(String url)
throws DSpaceSWORDException, SWORDErrorException
{
SWORDUrlManager urlManager = swordService.getUrlManager();
AtomDocumentResponse response = new AtomDocumentResponse(200);
if (url == null || urlManager.isBaseMediaLinkUrl(url))
{
// we are dealing with a default media-link, indicating that something
// is wrong
// FIXME: what do we actually do about this situation?
// throwing an error for the time being
throw new SWORDErrorException(DSpaceSWORDErrorCodes.MEDIA_UNAVAILABLE, "The media link you requested is not available");
}
// extract the thing that we are trying to get a media entry on
DSpaceObject dso = urlManager.extractDSpaceObject(url);
// now, the media entry should always be to an actual file, so we only care that this is a bitstream
if (!(dso instanceof Bitstream))
{
throw new SWORDErrorException(DSpaceSWORDErrorCodes.BAD_URL, "The url you provided does not resolve to an appropriate object");
}
// now construct the atom entry for the bitstream
DSpaceATOMEntry dsatom = new BitstreamEntryGenerator(swordService);
SWORDEntry entry = dsatom.getSWORDEntry(dso);
response.setEntry(entry);
return response;
}