diff --git a/src/main/java/org/gcube/data_catalogue/grsf_publish_ws/utils/CommonServiceUtils.java b/src/main/java/org/gcube/data_catalogue/grsf_publish_ws/utils/CommonServiceUtils.java index 2b8311f..69d951a 100644 --- a/src/main/java/org/gcube/data_catalogue/grsf_publish_ws/utils/CommonServiceUtils.java +++ b/src/main/java/org/gcube/data_catalogue/grsf_publish_ws/utils/CommonServiceUtils.java @@ -469,6 +469,8 @@ public class CommonServiceUtils { Map> customFields, Set groups, List resources, String username, String futureTitle) throws Exception { + Set sourcesList = new HashSet(); + // 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 sourcesList = new HashSet(); - 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> databaseSources = record.getDatabaseSources(); + for(Resource 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());