Source:
<code>private DoiTypeInfo getTypeOf(RequestedDoiVersion id) throws IOException { <START> Map<String, ?> metadata = getMetadataForDoi(id); <END> String doiType = (String) metadata.get("type"); if (!metadata.containsKey("article")) { Map<String, ?> journal = (Map<String, ?>) metadata.get("journal"); String journalKey = (String) journal.get("journalKey"); return new DoiTypeInfo(doiType, journalKey); } Map<String, ?> articleMetadata = (Map<String, ?>) metadata.get("article"); Map<String, ?> revisionTable = (Map<String, ?>) articleMetadata.get("revisions"); Optional<Integer> ingestionNumber = revisionTable.entrySet().stream() .max(Comparator.comparing(entry -> Integer.valueOf(entry.getKey()))) .map(entry -> ((Number) entry.getValue()).intValue()); if (!ingestionNumber.isPresent()) { throw new NotFoundException(); } String articleDoi = (String) articleMetadata.get("doi"); Map<String, ?> ingestionMetadata = articleApi.requestObject( ApiAddress.builder("articles").embedDoi(articleDoi) .addToken("ingestions").addToken(ingestionNumber.get().toString()).build(), Map.class); Map<String, ?> journal = (Map<String, ?>) ingestionMetadata.get("journal"); String journalKey = (String) journal.get("journalKey"); if (!doiType.equals("asset")) { return new DoiTypeInfo(doiType, journalKey); } Map<String, ?> itemView = articleApi.requestObject( ApiAddress.builder("articles").embedDoi(articleDoi) .addToken("ingestions").addToken(ingestionNumber.get().toString()) .addToken("items").build(), Map.class); Map<String, ?> itemTable = (Map<String, ?>) itemView.get("items"); String canonicalDoi = (String) metadata.get("doi"); Map<String, ?> itemMetadata = (Map<String, ?>) itemTable.get(canonicalDoi); String itemType = (String) itemMetadata.get("itemType"); return new DoiTypeInfo(itemType, journalKey); }</code><technical_language>this renamed doiMetadata</technical_language>

Target:
private DoiTypeInfo getTypeOf(RequestedDoiVersion id) throws IOException { Map<String, ?> doiMetadata = getMetadataForDoi(id); String doiType = (String) doiMetadata.get("type"); if (!doiMetadata.containsKey("article")) { Map<String, ?> journal = (Map<String, ?>) doiMetadata.get("journal"); String journalKey = (String) journal.get("journalKey"); return new DoiTypeInfo(doiType, journalKey); } Map<String, ?> articleMetadata = (Map<String, ?>) doiMetadata.get("article"); Map<String, Number> revisionTable = (Map<String, Number>) articleMetadata.get("revisions"); Optional<Integer> ingestionNumber = ArticleResolutionService.findLatestRevision(revisionTable) .map(ArticleResolutionService.RevisionPointer::getIngestionNumber); if (!ingestionNumber.isPresent()) { throw new NotFoundException(); } String articleDoi = (String) articleMetadata.get("doi"); Map<String, ?> ingestionMetadata = articleApi.requestObject( ApiAddress.builder("articles").embedDoi(articleDoi) .addToken("ingestions").addToken(ingestionNumber.get().toString()).build(), Map.class); Map<String, ?> journal = (Map<String, ?>) ingestionMetadata.get("journal"); String journalKey = (String) journal.get("journalKey"); if (!doiType.equals("asset")) { return new DoiTypeInfo(doiType, journalKey); } Map<String, ?> itemView = articleApi.requestObject( ApiAddress.builder("articles").embedDoi(articleDoi) .addToken("ingestions").addToken(ingestionNumber.get().toString()) .addToken("items").build(), Map.class); Map<String, ?> itemTable = (Map<String, ?>) itemView.get("items"); String canonicalDoi = (String) doiMetadata.get("doi"); Map<String, ?> itemMetadata = (Map<String, ?>) itemTable.get(canonicalDoi); String itemType = (String) itemMetadata.get("itemType"); return new DoiTypeInfo(itemType, journalKey); }