Skip to content

Commit

Permalink
Merge pull request #62 from aodn/features/5862-logo-fix
Browse files Browse the repository at this point in the history
Update readme and add one more case for logo
  • Loading branch information
HavierD authored Oct 2, 2024
2 parents 505b1ce + 1dcf996 commit 18bb674
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 12 deletions.
15 changes: 15 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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,
Expand All @@ -106,16 +109,16 @@ public ResponseEntity<Map<String, Object>> getRecordExtraInfo(@PathVariable("uui
List<String> 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")));
}
Expand Down Expand Up @@ -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<HarvestResult, AbstractParams> h = (AbstractHarvester<HarvestResult, AbstractParams>) 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> 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()));
});
}
Expand Down

0 comments on commit 18bb674

Please sign in to comment.