diff --git a/src/main/java/org/gcube/data/transfer/model/plugins/thredds/ThreddsCatalog.java b/src/main/java/org/gcube/data/transfer/model/plugins/thredds/ThreddsCatalog.java index e297038..a592f03 100644 --- a/src/main/java/org/gcube/data/transfer/model/plugins/thredds/ThreddsCatalog.java +++ b/src/main/java/org/gcube/data/transfer/model/plugins/thredds/ThreddsCatalog.java @@ -31,11 +31,11 @@ public class ThreddsCatalog{ public String getPathFromLocation(String location) { - if(declaredDataSetRoot!=null&&declaredDataSetRoot.getLocation()!=null&& - ThreddsInfo.matchesPath(declaredDataSetRoot.getLocation(),location)) return declaredDataSetRoot.getPath(); for(DataSetScan scan : declaredDataSetScan) if(scan!=null&&scan.getLocation()!=null&&ThreddsInfo.matchesPath(scan.getLocation(), location)) return scan.getPath(); + if(declaredDataSetRoot!=null&&declaredDataSetRoot.getLocation()!=null&& + ThreddsInfo.matchesPath(declaredDataSetRoot.getLocation(),location)) return declaredDataSetRoot.getPath(); return null; } } \ No newline at end of file diff --git a/src/main/java/org/gcube/data/transfer/model/plugins/thredds/ThreddsInfo.java b/src/main/java/org/gcube/data/transfer/model/plugins/thredds/ThreddsInfo.java index e720ca9..7ec87b6 100644 --- a/src/main/java/org/gcube/data/transfer/model/plugins/thredds/ThreddsInfo.java +++ b/src/main/java/org/gcube/data/transfer/model/plugins/thredds/ThreddsInfo.java @@ -52,22 +52,26 @@ public class ThreddsInfo { if(catalog!=null) { if(catalog.getID()!=null&&catalog.getID().equals(id)) return catalog; if(catalog.getSubCatalogs()!=null&&catalog.getSubCatalogs().getLinkedCatalogs()!=null) - for(ThreddsCatalog cat : catalog.getSubCatalogs().getLinkedCatalogs()) - return findById(cat,id); + for(ThreddsCatalog cat : catalog.getSubCatalogs().getLinkedCatalogs()) { + ThreddsCatalog found=findById(cat,id); + if(found!=null) return found; + } } return null; } public static ThreddsCatalog getByFittingLocation(ThreddsCatalog catalog,String toMatchPath) { if(catalog!=null) { - if(catalog.getDeclaredDataSetRoot()!=null&&catalog.getDeclaredDataSetRoot().getLocation()!=null&& - matchesPath(catalog.getDeclaredDataSetRoot().getLocation(),toMatchPath)) return catalog; +// if(catalog.getDeclaredDataSetRoot()!=null&&catalog.getDeclaredDataSetRoot().getLocation()!=null&& +// matchesPath(catalog.getDeclaredDataSetRoot().getLocation(),toMatchPath)) return catalog; for(DataSetScan scan : catalog.getDeclaredDataSetScan()) if(scan!=null&&scan.getLocation()!=null&&matchesPath(scan.getLocation(), toMatchPath)) return catalog; if(catalog.getSubCatalogs()!=null&&catalog.getSubCatalogs().getLinkedCatalogs()!=null) - for(ThreddsCatalog cat:catalog.getSubCatalogs().getLinkedCatalogs()) - getByFittingLocation(cat, toMatchPath); + for(ThreddsCatalog cat:catalog.getSubCatalogs().getLinkedCatalogs()) { + ThreddsCatalog found=getByFittingLocation(cat, toMatchPath); + if(found!=null) return found; + } } return null; }