Search in sources :

Example 21 with RestClientException

use of org.ambraproject.rhino.rest.RestClientException in project rhino by PLOS.

the class IngestionService method getManifestXml.

@VisibleForTesting
ManifestXml getManifestXml(Archive archive) throws IOException {
    String manifestEntry = null;
    for (String entryName : archive.getEntryNames()) {
        if (entryName.equalsIgnoreCase("manifest.xml")) {
            manifestEntry = entryName;
        }
    }
    if (manifestEntry == null) {
        throw new RestClientException("Archive has no manifest file", HttpStatus.BAD_REQUEST);
    }
    ManifestXml manifestXml;
    try (InputStream manifestStream = new BufferedInputStream(archive.openFile(manifestEntry))) {
        manifestXml = new ManifestXml(AmbraService.parseXml(manifestStream));
    }
    return manifestXml;
}
Also used : BufferedInputStream(java.io.BufferedInputStream) BufferedInputStream(java.io.BufferedInputStream) InputStream(java.io.InputStream) RestClientException(org.ambraproject.rhino.rest.RestClientException) ManifestXml(org.ambraproject.rhino.content.xml.ManifestXml) VisibleForTesting(com.google.common.annotations.VisibleForTesting)

Aggregations

RestClientException (org.ambraproject.rhino.rest.RestClientException)21 Transactional (org.springframework.transaction.annotation.Transactional)6 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)6 Volume (org.ambraproject.rhino.model.Volume)5 Issue (org.ambraproject.rhino.model.Issue)4 Journal (org.ambraproject.rhino.model.Journal)4 ApiImplicitParam (com.wordnik.swagger.annotations.ApiImplicitParam)3 ManifestXml (org.ambraproject.rhino.content.xml.ManifestXml)3 ArticleIdentifier (org.ambraproject.rhino.identity.ArticleIdentifier)3 Article (org.ambraproject.rhino.model.Article)3 Comment (org.ambraproject.rhino.model.Comment)3 Query (org.hibernate.Query)3 InputStream (java.io.InputStream)2 ArrayList (java.util.ArrayList)2 Doi (org.ambraproject.rhino.identity.Doi)2 VolumeIdentifier (org.ambraproject.rhino.identity.VolumeIdentifier)2 ArticleList (org.ambraproject.rhino.model.ArticleList)2 Session (org.hibernate.Session)2 VisibleForTesting (com.google.common.annotations.VisibleForTesting)1 ImmutableList (com.google.common.collect.ImmutableList)1