diff --git a/src/main/java/org/folio/linked/data/mapper/dto/monograph/TopResourceMapperUnit.java b/src/main/java/org/folio/linked/data/mapper/dto/monograph/TopResourceMapperUnit.java index 4bc32aa2..2795389f 100644 --- a/src/main/java/org/folio/linked/data/mapper/dto/monograph/TopResourceMapperUnit.java +++ b/src/main/java/org/folio/linked/data/mapper/dto/monograph/TopResourceMapperUnit.java @@ -34,6 +34,7 @@ protected List getPrimaryMainTitles(List ti .map(PrimaryTitleField.class::cast) .map(PrimaryTitleField::getPrimaryTitle) .map(pt -> join(" ", getFirstValue(pt::getMainTitle), getFirstValue(pt::getSubTitle))) + .map(String::trim) .toList(); } } diff --git a/src/main/java/org/folio/linked/data/mapper/dto/monograph/common/title/TitleMapperUnit.java b/src/main/java/org/folio/linked/data/mapper/dto/monograph/common/title/TitleMapperUnit.java index 00dfa4f9..646c6b83 100644 --- a/src/main/java/org/folio/linked/data/mapper/dto/monograph/common/title/TitleMapperUnit.java +++ b/src/main/java/org/folio/linked/data/mapper/dto/monograph/common/title/TitleMapperUnit.java @@ -1,5 +1,8 @@ package org.folio.linked.data.mapper.dto.monograph.common.title; +import static org.apache.commons.lang3.StringUtils.isBlank; +import static java.lang.String.join; + import java.util.Set; import org.folio.linked.data.domain.dto.InstanceRequest; import org.folio.linked.data.domain.dto.InstanceResponse; @@ -22,6 +25,6 @@ public Set> supportedParents() { } protected String getLabel(String mainTitle, String subTitle) { - return String.join(" ", mainTitle, subTitle); + return isBlank(subTitle) ? mainTitle : join(" ", mainTitle, subTitle); } }