From 9516906ba50b6153d0687fc0cc4d3dac366b3a77 Mon Sep 17 00:00:00 2001 From: utas-raymondng Date: Wed, 2 Oct 2024 10:19:47 +1000 Subject: [PATCH 1/2] Update readme and add one more case for logo --- README.md | 15 +++++++++++ .../org/aodn/geonetwork4/controller/Api.java | 27 ++++++++++--------- 2 files changed, 30 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index 8b4f8ed..2826cf1 100644 --- a/README.md +++ b/README.md @@ -9,6 +9,21 @@ geonetwork4 base package (org.fao.geonet), so that the initial component-scan wi class. From there we add additional component-scan to our custom classes. This avoided the need to alter the xml like what we did before plus we are using a Docker base image of GeoNetwork4. +## Migration +When new docker image release, you will need to migrate to a new version of geonetwork. There are few places you +need to update, it would be easier to search the current version string and replace it: + +1. pom.xml +2. Dockerfile + +The two file MUST have the same version match, for example if we use 4.4.5-0 for pom.xml then you need to use +4.4.5 Docker image of geonetwork. + +> Note: +> >a. The path to store geonetwork in the Docker image may change, you may need to update "ENV GN_DIR /opt/geonetwork" + +> >b. If you see warning about running migration script, then check the path /opt/geonetwork/WEB-INF/classes/setup/sql/migrate/ inside docker image by login the shell of the image -> docker exec -it geonetwork4 bash. It contains the migration script + ## Run locally You need create a file call .env and put in the following attribute if you do not want the default startup parameters diff --git a/geonetwork-core/src/main/java/au/org/aodn/geonetwork4/controller/Api.java b/geonetwork-core/src/main/java/au/org/aodn/geonetwork4/controller/Api.java index 0180444..09d5c9d 100644 --- a/geonetwork-core/src/main/java/au/org/aodn/geonetwork4/controller/Api.java +++ b/geonetwork-core/src/main/java/au/org/aodn/geonetwork4/controller/Api.java @@ -80,9 +80,11 @@ protected RemoteConfig getRemoteConfig(String type) { * metadata object itself and then expose the additional values, this object contains the sourceId * which is the uuid of the record from the source system being harvested, it different from the * UUID use in this geonetwork, because harvested record get assign a new UUID locally. - * This source id can be useful because the geonetwork may download the logo, it all depends on which harvester - * you use, for GeonetHarvester, it will download but others don't, therefore the logo list will be different - * TODO: We should add suggestion based on group logo. + * The logos are prefer logo that order by prefence, that means we prefer + * 1. the logo from the metadata if downloaded + * 2. the logo from the metadata store remotely in source system (where this metadata harvested from) + * 3. the logo of the harvester + * 4. the logo of the group that the harvester belongs * * @param uuid - UUID of the record use by this geonetwork * @return - A data structure contains the UUID of the record in the source system as well as suggested logo in order of possibility @@ -93,6 +95,7 @@ protected RemoteConfig getRemoteConfig(String type) { * "suggest_logos": [ * "http://localhost:8080/geonetwork/images/logos/dbee258b-8730-4072-96d4-2818a69a4afd.png", <-- likely the icon store locally * "https://catalogue-imos.aodn.org.au/geonetwork/images/logos/dbee258b-8730-4072-96d4-2818a69a4afd.png" <-- the icon that store from metadata source server + * "https://localhost:8080/geonetwork/images/harvesting/... " <-- the icon from harvester * "https://localhost:8080/geonetwork/images/harvesting/... " <-- the icon use by the group and this metadata belongs to this group * ], * "isHarvested": true, @@ -106,16 +109,16 @@ public ResponseEntity> getRecordExtraInfo(@PathVariable("uui List logos = new ArrayList<>(); info.put(SUGGEST_LOGOS, logos); + final String host = setup.getSiteSetting(SiteHelper.HOST); + final String port = setup.getSiteSetting(SiteHelper.PORT); + final String protocol = setup.getSiteSetting(SiteHelper.PROTOCOL); + Metadata metadata = repository.findOneByUuid(uuid); if(metadata != null) { if(metadata.getSourceInfo() != null) { // Here we can get the source id, then we can create the first option for logo // which is extract logo from this host info.put("sourceId", metadata.getSourceInfo().getSourceId()); - - String host = setup.getSiteSetting(SiteHelper.HOST); - String port = setup.getSiteSetting(SiteHelper.PORT); - String protocol = setup.getSiteSetting(SiteHelper.PROTOCOL); // Default logo location of record logos.add(String.format("%s://%s:%s/geonetwork/images/logos/%s.png", protocol, host, port, info.get("sourceId"))); } @@ -155,17 +158,17 @@ else if (harvester instanceof Geonet20Harvester) { else { logger.error("Unknown instanceof type for harvester {}", harvester.getClass()); } - - // Get owner group and get the icon + // Get icon @SuppressWarnings("unchecked") AbstractHarvester h = (AbstractHarvester) harvester; + if(h.getParams().getIcon() != null) { + logos.add(String.format("%s://%s:%s/geonetwork/images/harvesting/%s", protocol, host, port, h.getParams().getIcon())); + } + // Get icon from group if(h.getParams().getOwnerIdGroup() != null) { try { Optional group = groupRepository.findById(Integer.parseInt(h.getParams().getOwnerIdGroup())); group.ifPresent(g -> { - String host = setup.getSiteSetting(SiteHelper.HOST); - String port = setup.getSiteSetting(SiteHelper.PORT); - String protocol = setup.getSiteSetting(SiteHelper.PROTOCOL); logos.add(String.format("%s://%s:%s/geonetwork/images/harvesting/%s", protocol, host, port, g.getLogo())); }); } From 1dcf9964b053e3b9e32bb1ae5d37616d3fb83d37 Mon Sep 17 00:00:00 2001 From: utas-raymondng Date: Wed, 2 Oct 2024 10:23:31 +1000 Subject: [PATCH 2/2] Fix format --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 2826cf1..afe0fc1 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ class. From there we add additional component-scan to our custom classes. This a to alter the xml like what we did before plus we are using a Docker base image of GeoNetwork4. ## Migration -When new docker image release, you will need to migrate to a new version of geonetwork. There are few places you +When new docker image release, you will need to migrate to a new version of geonetwork. There are few places you need to update, it would be easier to search the current version string and replace it: 1. pom.xml