geonetwork / core-geonetwork

GeoNetwork is a catalog application to manage spatially referenced resources. It provides powerful metadata editing and search functions as well as an interactive web map viewer. It is currently used in numerous Spatial Data Infrastructure initiatives across the world.
http://geonetwork-opensource.org/
GNU General Public License v2.0
428 stars 489 forks source link

MD_BrowseGraphic without description not being converted. #6728

Closed ianwallen closed 1 year ago

ianwallen commented 1 year ago

Describe the bug When importing a metadata record from an MEF file, I expect all the attachments from the source site to be converted to the url of the server where it is being imported. But this is not happening due to missing gmd:fileDescription

To Reproduce Steps to reproduce the behavior:

  1. Create a metadata (on server one using port 8080) and export the record. Ensure that it has the following for the graphicOverview

<gmd:graphicOverview xlink:role="urn:xml:lang:eng-CAN">
    <gmd:MD_BrowseGraphic>
       <gmd:fileName>
          <gco:CharacterString>http://localhost:8080/geonetwork/srv/api/records/9d93095e-7c97-11ed-a1eb-0242ac120002/attachments/test.png</gco:CharacterString>
       </gmd:fileName>
    </gmd:MD_BrowseGraphic>
</gmd:graphicOverview>
  1. import the metadata (on server 2 using a different address - i.e. different port 8081)

Expected behavior Expected the url "http://localhost:8080/geonetwork/srv/api/records/9d93095e-7c97-11ed-a1eb-0242ac120002/attachments/test.png" to be changed to the address used by the server where it was imported. i.e. http://localhost:8081/geonetwork/srv/api/records/9d93095e-7c97-11ed-a1eb-0242ac120002/attachments/test.png

Additional context The issue seems to be related to the following

https://github.com/geonetwork/core-geonetwork/blob/6fae61a049e814614e785e3a5295f739e428ba54/core/src/main/java/org/fao/geonet/MetadataResourceDatabaseMigration.java#L150-L162

It is based on the following xpath https://github.com/geonetwork/core-geonetwork/blob/6fae61a049e814614e785e3a5295f739e428ba54/core/src/main/java/org/fao/geonet/MetadataResourceDatabaseMigration.java#L80-L81

It seems like the url is being skipped because the [gmd:fileDescription/gco:CharacterString] is required. Is there a reason why a gmd:fileDescription is required when the data is in gmd:fileName?

josegar74 commented 1 year ago

At least in old versions of GeoNetwork the file description was assigned to identify the type of thumbnail. I've tested in 3.12.x and that seems no longer the case, uploading a file:

<gmd:graphicOverview>
  <gmd:MD_BrowseGraphic>
    <gmd:fileName>
      <gco:CharacterString>https://vanilla.geocat.net/geonetwork/srv/api/records/d4c832cd-3277-4b22-82a1-e6704c87043c/attachments/thumbnail.png</gco:CharacterString>
    </gmd:fileName>
  </gmd:MD_BrowseGraphic>
</gmd:graphicOverview>

I think that check can be removed. @fxprunayre can you check if there might be a reason I'm missing?

fxprunayre commented 1 year ago

I think that check can be removed

Yes it is more historical reason. We used to create a small and large thumbnail with different fixed labels. Adding this in the XPath in that migration was mainly to focus on those type of thumbnail uploaded in GeoNetwork. We can probably remove it now indeed.