Search in sources :

Example 1 with ArticlePackage

use of org.ambraproject.rhino.model.ingest.ArticlePackage in project rhino by PLOS.

the class IngestionService method createIngestPackage.

private IngestPackage createIngestPackage(Archive archive, Optional<String> bucketName) throws IOException {
    ManifestXml manifestXml = getManifestXml(archive);
    ImmutableSet<String> entryNames = archive.getEntryNames();
    manifestXml.validateManifestCompleteness(entryNames);
    String manuscriptEntry = getManuscriptEntry(entryNames, manifestXml);
    Document document = getDocument(archive, manuscriptEntry);
    ArticleXml parsedArticle = new ArticleXml(document);
    ArticleCustomMetadata customMetadata = customMetadataExtractorFactory.parse(document).build();
    ArticlePackage articlePackage = new ArticlePackageBuilder(resolveBucketName(bucketName), archive, parsedArticle, manifestXml).build();
    articlePackage.validateAssetCompleteness(parsedArticle.findAllAssetNodes().getDois());
    ArticleMetadata articleMetadata = parsedArticle.build();
    return new IngestPackage(articlePackage, articleMetadata, customMetadata);
}
Also used : ArticlePackageBuilder(org.ambraproject.rhino.model.ingest.ArticlePackageBuilder) IngestPackage(org.ambraproject.rhino.model.ingest.IngestPackage) ArticleXml(org.ambraproject.rhino.content.xml.ArticleXml) ManifestXml(org.ambraproject.rhino.content.xml.ManifestXml) ArticleCustomMetadata(org.ambraproject.rhino.model.article.ArticleCustomMetadata) Document(org.w3c.dom.Document) ArticlePackage(org.ambraproject.rhino.model.ingest.ArticlePackage) ArticleMetadata(org.ambraproject.rhino.model.article.ArticleMetadata)

Example 2 with ArticlePackage

use of org.ambraproject.rhino.model.ingest.ArticlePackage in project rhino by PLOS.

the class IngestionService method processIngestPackage.

private ArticleIngestion processIngestPackage(IngestPackage ingestPackage) {
    Doi doi = ArticleIdentifier.create(ingestPackage.getArticleMetadata().getDoi()).getDoi();
    ArticlePackage articlePackage = ingestPackage.getArticlePackage();
    for (ManifestXml.Asset asset : articlePackage.getManifest().getAssets()) {
        Doi assetDoi = Doi.create(asset.getUri());
        validateAssetUniqueness(doi, articleCrudService.getAllArticleItems(assetDoi));
    }
    validateManuscript(doi, articlePackage.getManifest().getArticleAsset().getUri());
    return persistArticle(ingestPackage, doi, articlePackage);
}
Also used : ManifestXml(org.ambraproject.rhino.content.xml.ManifestXml) Doi(org.ambraproject.rhino.identity.Doi) ArticlePackage(org.ambraproject.rhino.model.ingest.ArticlePackage)

Aggregations

ManifestXml (org.ambraproject.rhino.content.xml.ManifestXml)2 ArticlePackage (org.ambraproject.rhino.model.ingest.ArticlePackage)2 ArticleXml (org.ambraproject.rhino.content.xml.ArticleXml)1 Doi (org.ambraproject.rhino.identity.Doi)1 ArticleCustomMetadata (org.ambraproject.rhino.model.article.ArticleCustomMetadata)1 ArticleMetadata (org.ambraproject.rhino.model.article.ArticleMetadata)1 ArticlePackageBuilder (org.ambraproject.rhino.model.ingest.ArticlePackageBuilder)1 IngestPackage (org.ambraproject.rhino.model.ingest.IngestPackage)1 Document (org.w3c.dom.Document)1