diff --git a/dspace-api/src/main/java/org/dspace/license/CCLicenseConnectorServiceImpl.java b/dspace-api/src/main/java/org/dspace/license/CCLicenseConnectorServiceImpl.java index 619227432d..cdecadba52 100644 --- a/dspace-api/src/main/java/org/dspace/license/CCLicenseConnectorServiceImpl.java +++ b/dspace-api/src/main/java/org/dspace/license/CCLicenseConnectorServiceImpl.java @@ -106,7 +106,7 @@ public class CCLicenseConnectorServiceImpl implements CCLicenseConnectorService, for (String license : licenses) { - String licenseUri = ccLicenseUrl + "/license/" + license; + String licenseUri = ccLicenseUrl + "/license/" + license + "?locale=" + language; HttpGet licenseHttpGet = new HttpGet(licenseUri); try (CloseableHttpResponse response = client.execute(licenseHttpGet)) { CCLicense ccLicense = retrieveLicenseObject(license, response); diff --git a/dspace-api/src/main/java/org/dspace/license/CreativeCommonsServiceImpl.java b/dspace-api/src/main/java/org/dspace/license/CreativeCommonsServiceImpl.java index 29ae952a19..c9c8127d18 100644 --- a/dspace-api/src/main/java/org/dspace/license/CreativeCommonsServiceImpl.java +++ b/dspace-api/src/main/java/org/dspace/license/CreativeCommonsServiceImpl.java @@ -430,9 +430,10 @@ public class CreativeCommonsServiceImpl implements CreativeCommonsService, Initi } - private void addLicenseField(Context context, Item item, String field, String value) throws SQLException { + private void addLicenseField(Context context, Item item, String field, String language, String value) + throws SQLException { String[] params = splitField(field); - itemService.addMetadata(context, item, params[0], params[1], params[2], params[3], value); + itemService.addMetadata(context, item, params[0], params[1], params[2], language, value); } @@ -691,12 +692,12 @@ public class CreativeCommonsServiceImpl implements CreativeCommonsService, Initi String uriField = getCCField("uri"); String nameField = getCCField("name"); - addLicenseField(context, item, uriField, licenseUri); + addLicenseField(context, item, uriField, null, licenseUri); if (configurationService.getBooleanProperty("cc.submit.addbitstream")) { setLicenseRDF(context, item, fetchLicenseRDF(doc)); } if (configurationService.getBooleanProperty("cc.submit.setname")) { - addLicenseField(context, item, nameField, licenseName); + addLicenseField(context, item, nameField, "en", licenseName); } } diff --git a/dspace-server-webapp/src/main/java/org/dspace/app/rest/repository/SubmissionCCLicenseRestRepository.java b/dspace-server-webapp/src/main/java/org/dspace/app/rest/repository/SubmissionCCLicenseRestRepository.java index 0dab42f9bd..356b3f22bf 100644 --- a/dspace-server-webapp/src/main/java/org/dspace/app/rest/repository/SubmissionCCLicenseRestRepository.java +++ b/dspace-server-webapp/src/main/java/org/dspace/app/rest/repository/SubmissionCCLicenseRestRepository.java @@ -8,11 +8,14 @@ package org.dspace.app.rest.repository; import java.util.List; +import java.util.Locale; +import org.apache.commons.lang3.StringUtils; import org.dspace.app.rest.model.SubmissionCCLicenseRest; import org.dspace.core.Context; import org.dspace.license.CCLicense; import org.dspace.license.service.CreativeCommonsService; +import org.dspace.services.ConfigurationService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; @@ -29,10 +32,23 @@ public class SubmissionCCLicenseRestRepository extends DSpaceRestRepository findAll(final Context context, final Pageable pageable) { - List allCCLicenses = creativeCommonsService.findAllCCLicenses(); + String defaultCCLocale = configurationService.getProperty("cc.license.locale"); + + Locale currentLocale = context.getCurrentLocale(); + List allCCLicenses; + // when no default CC locale is defined, current locale is used + if (currentLocale != null && StringUtils.isBlank(defaultCCLocale)) { + allCCLicenses = creativeCommonsService.findAllCCLicenses(currentLocale.toString()); + } else { + allCCLicenses = creativeCommonsService.findAllCCLicenses(); + } return converter.toRestPage(allCCLicenses, pageable, utils.obtainProjection()); } diff --git a/dspace/config/dspace.cfg b/dspace/config/dspace.cfg index 64097e9dff..404fd6b530 100644 --- a/dspace/config/dspace.cfg +++ b/dspace/config/dspace.cfg @@ -1015,7 +1015,7 @@ cc.license.jurisdiction = us # Locale for CC dialogs # A locale in the form language or language-country. -# If no default locale is defined the CC default locale will be used +# If no default locale is defined the current supported locale will be used cc.license.locale = en