Search in sources :

Example 1 with NotFoundException

use of org.plos.crepo.exceptions.NotFoundException in project rhino by PLOS.

the class AssetCrudServiceImpl method getArticleItemFile.

@Override
public RepoObjectMetadata getArticleItemFile(ArticleFileIdentifier fileId) {
    ArticleItem work = articleCrudService.getArticleItem(fileId.getItemIdentifier());
    String fileType = fileId.getFileType();
    ArticleFile articleFile = work.getFile(fileType).orElseThrow(() -> new RestClientException("Unrecognized type: " + fileType, HttpStatus.NOT_FOUND));
    try {
        return contentRepoService.getRepoObjectMetadata(articleFile.getCrepoVersion());
    } catch (NotFoundException e) {
        throw new RestClientException("Object not found: " + fileId + ". File info: " + articleFile, HttpStatus.NOT_FOUND);
    }
}
Also used : ArticleItem(org.ambraproject.rhino.model.ArticleItem) RestClientException(org.ambraproject.rhino.rest.RestClientException) NotFoundException(org.plos.crepo.exceptions.NotFoundException) ArticleFile(org.ambraproject.rhino.model.ArticleFile)

Aggregations

ArticleFile (org.ambraproject.rhino.model.ArticleFile)1 ArticleItem (org.ambraproject.rhino.model.ArticleItem)1 RestClientException (org.ambraproject.rhino.rest.RestClientException)1 NotFoundException (org.plos.crepo.exceptions.NotFoundException)1