Skip to content

Commit c4379a0

Browse files
authored
Merge pull request #11496 from GlobalDataverseCommunityConsortium/missing-term-fix
Reduce useless warnings about missing vocab values
2 parents b881147 + 5f32458 commit c4379a0

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/main/java/edu/harvard/iq/dataverse/ControlledVocabularyValue.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,15 @@
88

99
import edu.harvard.iq.dataverse.util.BundleUtil;
1010
import org.apache.commons.lang3.StringUtils;
11+
import org.eclipse.persistence.logging.LogLevel;
1112

1213
import java.io.Serializable;
1314
import java.util.ArrayList;
1415
import java.util.Collection;
1516
import java.util.Comparator;
1617
import java.util.Locale;
1718
import java.util.Objects;
19+
import java.util.logging.Level;
1820
import java.util.logging.Logger;
1921
import java.util.MissingResourceException;
2022
import jakarta.persistence.CascadeType;
@@ -148,7 +150,11 @@ public static String getLocaleStrValue(String strValue, String fieldTypeName, St
148150
return sendDefault ? strValue : null;
149151
}
150152
} catch (MissingResourceException | NullPointerException e) {
151-
logger.warning("Error finding " + "controlledvocabulary." + fieldTypeName + "." + key + " in " + ((locale==null)? "defaultLang" : locale.getLanguage()) + " : " + e.getLocalizedMessage());
153+
//If we're using the default local and can return the default value, this shouldn't be a warning
154+
if (locale != null && !locale.equals(Locale.getDefault()) && sendDefault) {
155+
logger.log(((locale != null && !locale.equals(Locale.getDefault()) && ! sendDefault) ? Level.WARNING:Level.FINE),"Error finding " + "controlledvocabulary." + fieldTypeName + "." + key + " in "
156+
+ ((locale == null) ? "defaultLang" : locale.getLanguage()) + " : " + e.getLocalizedMessage());
157+
}
152158
return sendDefault ? strValue : null;
153159
}
154160
}

0 commit comments

Comments
 (0)