diff --git a/dspace-api/src/main/java/org/dspace/orcid/model/factory/impl/AbstractOrcidProfileSectionFactory.java b/dspace-api/src/main/java/org/dspace/orcid/model/factory/impl/AbstractOrcidProfileSectionFactory.java index 2c272e620cca..98f63193a964 100644 --- a/dspace-api/src/main/java/org/dspace/orcid/model/factory/impl/AbstractOrcidProfileSectionFactory.java +++ b/dspace-api/src/main/java/org/dspace/orcid/model/factory/impl/AbstractOrcidProfileSectionFactory.java @@ -34,6 +34,8 @@ public abstract class AbstractOrcidProfileSectionFactory implements OrcidProfile protected final OrcidProfileSyncPreference preference; + protected Integer maxAllowedMetadataVisibility = 0; + @Autowired protected ItemService itemService; @@ -70,4 +72,17 @@ protected List getMetadataValues(Item item, String metadataField) return itemService.getMetadataByMetadataString(item, metadataField); } + protected boolean isAllowedMetadataByVisibility(MetadataValue metadataValue) { + return metadataValue.getSecurityLevel() == null + || metadataValue.getSecurityLevel() <= getMaxAllowedMetadataVisibility(); + } + + public Integer getMaxAllowedMetadataVisibility() { + return maxAllowedMetadataVisibility; + } + + public void setMaxAllowedMetadataVisibility(Integer maxAllowedMetadataVisibility) { + this.maxAllowedMetadataVisibility = maxAllowedMetadataVisibility; + } + } diff --git a/dspace-api/src/main/java/org/dspace/orcid/model/factory/impl/OrcidAffiliationFactory.java b/dspace-api/src/main/java/org/dspace/orcid/model/factory/impl/OrcidAffiliationFactory.java index 89a1ca3d83e4..d74f05bcaf50 100644 --- a/dspace-api/src/main/java/org/dspace/orcid/model/factory/impl/OrcidAffiliationFactory.java +++ b/dspace-api/src/main/java/org/dspace/orcid/model/factory/impl/OrcidAffiliationFactory.java @@ -93,7 +93,13 @@ public List getMetadataSignatures(Context context, Item item) { int groupSize = metadataGroups.getOrDefault(organizationField, Collections.emptyList()).size(); for (int currentGroupIndex = 0; currentGroupIndex < groupSize; currentGroupIndex++) { List metadataValues = getMetadataValueByPlace(metadataGroups, currentGroupIndex); - signatures.add(metadataSignatureGenerator.generate(context, metadataValues)); + //only "visible" metadatavalues within this group + metadataValues = metadataValues.stream() + .filter(metadataValue -> isAllowedMetadataByVisibility(metadataValue)) + .collect(Collectors.toList()); + if (!metadataValues.isEmpty()) { + signatures.add(metadataSignatureGenerator.generate(context, metadataValues)); + } } return signatures; diff --git a/dspace-api/src/main/java/org/dspace/orcid/model/factory/impl/OrcidSimpleValueObjectFactory.java b/dspace-api/src/main/java/org/dspace/orcid/model/factory/impl/OrcidSimpleValueObjectFactory.java index 4ddfbe47a328..28113e958332 100644 --- a/dspace-api/src/main/java/org/dspace/orcid/model/factory/impl/OrcidSimpleValueObjectFactory.java +++ b/dspace-api/src/main/java/org/dspace/orcid/model/factory/impl/OrcidSimpleValueObjectFactory.java @@ -76,6 +76,7 @@ public Object create(Context context, List metadataValues) { public List getMetadataSignatures(Context context, Item item) { return metadataFields.stream() .flatMap(metadataField -> getMetadataValues(item, metadataField).stream()) + .filter(metadataValue -> isAllowedMetadataByVisibility(metadataValue)) .map(metadataValue -> metadataSignatureGenerator.generate(context, List.of(metadataValue))) .collect(Collectors.toList()); }