Remove deprecated setMetadata of CommunityService, CollectionService #2956

This introduces a new class:  a holder for metadata field names.
This commit is contained in:
Mark H. Wood
2020-09-22 20:16:13 -04:00
parent f8221f54ce
commit 6569089228
15 changed files with 209 additions and 116 deletions

View File

@@ -175,10 +175,10 @@ public class CommunityServiceImpl extends DSpaceObjectServiceImpl<Community> imp
}
@Override
public void setMetadata(Context context, Community community, String field, String value)
throws MissingResourceException, SQLException {
if ((field.trim()).equals("name")
&& (value == null || value.trim().equals(""))) {
public void setMetadataSingleValue(Context context, Community community,
MetadataFieldName field, String language, String value)
throws MissingResourceException, SQLException {
if (field.equals(MD_NAME) && (value == null || value.trim().equals(""))) {
try {
value = I18nUtil.getMessage("org.dspace.workflow.WorkflowManager.untitled");
} catch (MissingResourceException e) {
@@ -186,19 +186,19 @@ public class CommunityServiceImpl extends DSpaceObjectServiceImpl<Community> imp
}
}
String[] MDValue = getMDValueByLegacyField(field);
/*
* Set metadata field to null if null
* and trim strings to eliminate excess
* whitespace.
*/
if (value == null) {
clearMetadata(context, community, MDValue[0], MDValue[1], MDValue[2], Item.ANY);
clearMetadata(context, community, field.SCHEMA, field.ELEMENT, field.QUALIFIER, Item.ANY);
community.setMetadataModified();
} else {
setMetadataSingleValue(context, community, MDValue[0], MDValue[1], MDValue[2], null, value);
super.setMetadataSingleValue(context, community, field, null, value);
}
community.addDetails(field);
community.addDetails(field.toString());
}
@Override