From b4766468754679a4a1b85f9f3a9d26d41abb95ce Mon Sep 17 00:00:00 2001 From: Luca Frosini Date: Fri, 19 Jun 2020 09:50:46 +0200 Subject: [PATCH] Added some comments to have a better understanding of what the code does --- .../utils/CommonServiceUtils.java | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) 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 f58f154..3e695dc 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 @@ -482,24 +482,39 @@ public class CommonServiceUtils { // 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 + + // In web.xml a parameter indicates the Admin VRE as full path. if(context.equals((String) contextServlet.getInitParameter(HelperMethods.MANAGE_CONTEX_KEY))) { + + // If we are in Admin VRE and the source is GRSF if(sourceInPath.equals(Sources.GRSF)) { + // RefersTo cannot be empty or null in GRSF_Admin for a GRSF record List refersTo = record.getRefersTo(); if(refersTo == null || refersTo.isEmpty()) throw new Exception("refers_to is empty for a GRSF record"); + + // For each RefersTo a Resource is created in the record. The resource point to the referred record. + // We have also to set database sources + 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) { String sourceOrganization = ""; -// String sourceOrganization = getRecordOrganization(refersToBean.getId(), apiKey, context); + // Here there is a lookup to the referred records. + // getRecordOrganization read the record and get the organization +// String sourceOrganization = getRecordOrganization(refersToBean.getId(), apiKey, context); resources.add(new ResourceBean(refersToBean.getUrl(), sourceOrganization, "", null, username, null, null)); sourcesList.add(sourceOrganization.toLowerCase()); + + + // concatenating the organization in a string which provide the databaseSource value :O + // Better using a list databaseSource += sourceOrganization + " "; }