Patched code to use "database_sources" field as source of information for sources for GRSF VRE.

In GRSF_Admin the sources are calculated using the referTo field.
see #12861


git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/data-catalogue/grsf-publisher-ws@176223 82a268e6-3cf1-43bd-a215-b396298e98cf
feature/17695
Luca Frosini 5 years ago
parent 04c91b534d
commit a39731a785

@ -469,6 +469,8 @@ public class CommonServiceUtils {
Map<String,List<String>> customFields, Set<String> groups, List<ResourceBean> resources, String username,
String futureTitle) throws Exception {
Set<String> sourcesList = new HashSet<String>();
// validate the record if it is a GRSF one and set the record type and in manage context
// Status field is needed only in the Manage context for GRSF records
if(context.equals((String) contextServlet.getInitParameter(HelperMethods.MANAGE_CONTEX_KEY))) {
@ -478,8 +480,6 @@ public class CommonServiceUtils {
if(refersTo == null || refersTo.isEmpty())
throw new Exception("refers_to is empty for a GRSF record");
Set<String> sourcesList = new HashSet<String>();
String databaseSource = "";
// we have the id within the catalog of this record. This means that we can retrieve the record and its system:type
for(RefersToBean refersToBean : refersTo) {
@ -493,14 +493,23 @@ public class CommonServiceUtils {
// create the Database Source information
customFields.put(Constants.GRSF_DATABASE_SOURCE, Arrays.asList(databaseSource.trim()));
// append to groups: we need to add this record to the correspondent group of the sources
addRecordToGroupSources(groups, new ArrayList(sourcesList), productType, sourceInPath);
// validate
CommonServiceUtils.validateAggregatedRecord(record);
}
}else {
// I'm not in GRSF Admin so the groups must be added using databaseSources
List<Resource<Sources>> databaseSources = record.getDatabaseSources();
for(Resource<Sources> source : databaseSources) {
Sources sourceName = source.getName();
sourcesList.add(sourceName.getOrigName().toLowerCase());
}
}
// append to groups: we need to add this record to the correspondent group of the sources
addRecordToGroupSources(groups, new ArrayList(sourcesList), productType, sourceInPath);
// validate
CommonServiceUtils.validateAggregatedRecord(record);
// set the domain
record.setDomain(productType.getOrigName());

Loading…
Cancel
Save