Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[pull] main from geonetwork:main #92

Closed
wants to merge 50 commits into from
Closed
Changes from 1 commit
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
33d1fb9
Add German codelist translations for scope code (#7566)
josegar74 Dec 20, 2023
1f16287
fix for empty language leading to spurious comma
joachimnielandt Dec 20, 2023
68cb69a
Overview not shown in PDF export when the overview image is stored in…
josegar74 Dec 22, 2023
a54f3d5
Fix case of wrong use for HttpStatus.CREATED and HttpStatus.OK
ianwallen Dec 31, 2023
0223ed2
Fix duplicate spring doc tags.
ianwallen Dec 21, 2023
1068a6c
Fix initialization of SpringDoc so that it does not use null serverna…
ianwallen Jan 2, 2024
5fb3196
API should return a structured object instead of JSONObject (#7584)
ianwallen Jan 2, 2024
6376582
Add missing apiResponse for group and map api (#7590)
ianwallen Jan 2, 2024
9285136
Update SpringDoc json/yaml generator to make the results more determi…
ianwallen Jan 3, 2024
b892b26
Spring doc API for link api should accept a structured object instead…
ianwallen Jan 4, 2024
2af1efb
Metadata extents API / Make configurable to display the metadata bbox…
josegar74 Jan 4, 2024
3b3180d
Home page / sort topic categories and INSPIRE themes facets alphabeti…
josegar74 Jan 4, 2024
c67946d
Record view / Invalid timezone shift for years outside moment's 10 ye…
josegar74 Dec 14, 2023
14dbaac
fix duplicate check on uuid+initiative+association (#7567)
joachimnielandt Jan 4, 2024
ddd8be5
Fix add element attribute in the metadata editor, causing the element…
josegar74 Jan 2, 2024
361e9aa
INSPIRE Atom feeds / Fix link to atom search endpoint
josegar74 Dec 20, 2023
016399b
Github / PR template / Add funded by (#7554)
fxprunayre Jan 5, 2024
81efcfc
Harvesting / WFS feature / Add WFS2 support for MapServer
fxprunayre Oct 27, 2023
4a5a17f
Build info improvements. (#7400)
fxprunayre Jan 5, 2024
6c8c450
Fix duplicate operation id caused by use of 2 methods GET/POST metho…
ianwallen Jan 5, 2024
dc5df0c
Search results / Configure related records type depending on template…
fxprunayre Jan 5, 2024
802e098
Configuration to restrict the hosts and ports accessible by the http …
josegar74 Jan 5, 2024
e7aee71
feat: avoid race condition, resize map once target size ok (#7545)
f-necas Jan 6, 2024
a0bb664
using icon for call/phone
joachimnielandt Jan 8, 2024
523a8c7
Add missing swagger icons that were referenced in the index.html file…
ianwallen Jan 9, 2024
b300811
Spring doc - Set API enum as ref (#7595)
ianwallen Jan 9, 2024
6dacf28
Fix issue with @ResponseStatus and @ApiResponse being out of sync. (#…
ianwallen Jan 9, 2024
4b6b30c
Fix linux specific file separator used for harvester transform option…
CMath04 Jan 9, 2024
07349d6
Preventing indexing error by limiting selection amount
joachimnielandt Jan 10, 2024
161c1df
Update files with Prettier formatting
josegar74 Jan 10, 2024
63cd59f
Service context null pointer (#7593)
wangf1122 Jan 10, 2024
541b013
Fix duplicate API endpoint /feeds (#7581)
ianwallen Jan 10, 2024
c9738e2
Changed http to https for urls that appear in open api specification.…
ianwallen Jan 10, 2024
ca3513b
Add missing import from commit 63cd59fb38df389694566d69459bcfbedb7ca8…
ianwallen Jan 10, 2024
23140d5
CSW GetRecords doesn't escape query values when creating the Elastics…
josegar74 Jan 11, 2024
eaaa06d
Fix SpringDoc duplicate OperationId (#7580)
ianwallen Jan 15, 2024
aed448c
Add missing @ApiResponse status for successful api search response. (…
ianwallen Jan 15, 2024
e06fbdd
Cleanup consumes from metadata insert api. (#7616)
ianwallen Jan 15, 2024
5d85e8c
Remove default response from open api specification. (#7609)
ianwallen Jan 15, 2024
44105b5
Build / release module build workflow improvements / fixes (#7619)
jodygarnett Jan 16, 2024
e7f64b7
Use Java 21 for Sonarcloud plugin (#7622)
juanluisrp Jan 16, 2024
e1ac22b
Bump actions/setup-java from 3.12.0 to 4.0.0 (#7522)
dependabot[bot] Jan 16, 2024
e114588
build fix: do not remove api docs during clean:clean@reset
jodygarnett Jan 16, 2024
01c26ec
Do not clean api docs out of src/main/webapp
jodygarnett Jan 16, 2024
172bce2
Record view / Display WFS downloads for WFS online resources without …
josegar74 Jan 17, 2024
9837e31
Fix error on edit page elements with non-unique id #gnRemoteRecordUrl…
ianwallen Jan 17, 2024
89ff9ff
backport bot to respond to PR tags
jodygarnett Jan 17, 2024
0c0fd04
Fix the grid on the homepage of the documentation (#7559)
MichelGabriel Jan 17, 2024
a52109e
document `backport 4.2.x` label change required for bot
jodygarnett Jan 17, 2024
4dfbb33
Update CONTRIBUTING.md
ticheler Jan 17, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Overview not shown in PDF export when the overview image is stored in…
… GeoNetwork and requires authentication to access it. Fixes geonetwork#7540 (geonetwork#7556)
josegar74 authored Dec 22, 2023

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
commit 68cb69aaac8f394818323fb1144e2a7baf4e75f0
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2001-2016 Food and Agriculture Organization of the
* Copyright (C) 2001-2023 Food and Agriculture Organization of the
* United Nations (FAO-UN), United Nations World Food Programme (WFP)
* and United Nations Environment Programme (UNEP)
*
@@ -28,11 +28,14 @@
import com.lowagie.text.Image;
import org.apache.commons.io.IOUtils;
import org.apache.commons.lang.StringUtils;
import org.fao.geonet.ApplicationContextHolder;
import org.fao.geonet.api.ApiUtils;
import org.fao.geonet.api.records.attachments.Store;
import org.fao.geonet.api.records.extent.MapRenderer;
import org.fao.geonet.api.records.extent.MetadataExtentApi;
import org.fao.geonet.constants.Geonet;
import org.fao.geonet.constants.Params;
import org.fao.geonet.domain.MetadataResourceVisibility;
import org.fao.geonet.utils.Log;
import org.xhtmlrenderer.extend.FSImage;
import org.xhtmlrenderer.extend.ReplacedElement;
@@ -82,20 +85,23 @@ private static Set<String> getSupportedExts() {
if (imgFormatExts == null) {
synchronized (ImageReplacedElementFactory.class) {
if (imgFormatExts == null) {
imgFormatExts = Sets.newHashSet();
Set<String> tmpImgFormatExts = Sets.newHashSet();
for (String ext : ImageIO.getReaderFileSuffixes()) {
imgFormatExts.add(ext.toLowerCase());
tmpImgFormatExts.add(ext.toLowerCase());
}
imgFormatExts = tmpImgFormatExts;
}
}
}

return imgFormatExts;
}

static private Pattern ONE_EXTENT_API_REGEX = Pattern.compile(".*/(.*)/extents/([0-9]+)\\.png.*");
static private Pattern ALL_EXTENT_API_REGEX = Pattern.compile(".*/(.*)/extents\\.png.*");
static private final String EXTENT_XPATH = ".//*[local-name() ='extent']/*/*[local-name() = 'geographicElement']/*";
private static final Pattern ONE_EXTENT_API_REGEX = Pattern.compile(".*/(.*)/extents/(\\d+)\\.png.*");
private static final Pattern ALL_EXTENT_API_REGEX = Pattern.compile(".*/(.*)/extents\\.png.*");
private static final String EXTENT_XPATH = ".//*[local-name() ='extent']/*/*[local-name() = 'geographicElement']/*";

private static final String DEFAULT_SRS = "EPSG:4326";

@Override
public ReplacedElement createReplacedElement(LayoutContext layoutContext, BlockBox box,
@@ -109,15 +115,15 @@ public ReplacedElement createReplacedElement(LayoutContext layoutContext, BlockB
if (!"img".equals(nodeName)) {
try {
return superFactory.createReplacedElement(layoutContext, box, userAgentCallback, cssWidth, cssHeight);
} catch (Throwable e) {
} catch (Exception e) {
return new EmptyReplacedElement(cssWidth, cssHeight);
}
}


String src = element.getAttribute("src");
String baseUrlNoLang = baseURL.substring(0, baseURL.length() - 4);

boolean useExtentApi = src.startsWith(baseURL.substring(0, baseURL.length() - 4))
boolean useExtentApi = src.startsWith(baseUrlNoLang)
&& mapRenderer != null
&& (ALL_EXTENT_API_REGEX.matcher(src).matches()
|| ONE_EXTENT_API_REGEX.matcher(src).matches());
@@ -135,7 +141,7 @@ public ReplacedElement createReplacedElement(LayoutContext layoutContext, BlockB
regionId = String.format("metadata:@id%s:@xpath(%s)[%s]", ApiUtils.getInternalId(oneMatcher.group(1), true), EXTENT_XPATH, oneMatcher.group(2));
}
Map<String, String> parameters = getParams(src);
String srs = parameters.get(MetadataExtentApi.MAP_SRS_PARAM) != null ? parameters.get(MetadataExtentApi.MAP_SRS_PARAM) : "EPSG:4326";
String srs = parameters.get(MetadataExtentApi.MAP_SRS_PARAM) != null ? parameters.get(MetadataExtentApi.MAP_SRS_PARAM) : DEFAULT_SRS;
Integer width = parameters.get(MetadataExtentApi.WIDTH_PARAM) != null ? Integer.parseInt(parameters.get(MetadataExtentApi.WIDTH_PARAM)) : null;
Integer height = parameters.get(MetadataExtentApi.HEIGHT_PARAM) != null ? Integer.parseInt(parameters.get(MetadataExtentApi.HEIGHT_PARAM)) : null;
String background = parameters.get(MetadataExtentApi.BACKGROUND_PARAM);
@@ -145,20 +151,25 @@ public ReplacedElement createReplacedElement(LayoutContext layoutContext, BlockB
}
float factor = layoutContext.getDotsPerPixel();
return loadImage(layoutContext, box, userAgentCallback, cssWidth, cssHeight, new BufferedImageLoader(image), factor);
} else if (src.startsWith(baseURL + "region.getmap.png") | src.endsWith("/geom.png") && mapRenderer != null) {
} else if (src.startsWith(baseURL + "region.getmap.png") || src.endsWith("/geom.png") && mapRenderer != null) {
BufferedImage image = null;
try {
Map<String, String> parameters = getParams(src);

String id = parameters.get(Params.ID);
String srs = parameters.get(MetadataExtentApi.MAP_SRS_PARAM) != null ? parameters.get(MetadataExtentApi.MAP_SRS_PARAM) : "EPSG:4326";
String srs = parameters.get(MetadataExtentApi.MAP_SRS_PARAM) != null ? parameters.get(MetadataExtentApi.MAP_SRS_PARAM) : DEFAULT_SRS;
Integer width = parameters.get(MetadataExtentApi.WIDTH_PARAM) != null ? Integer.parseInt(parameters.get(MetadataExtentApi.WIDTH_PARAM)) : null;
Integer height = parameters.get(MetadataExtentApi.HEIGHT_PARAM) != null ? Integer.parseInt(parameters.get(MetadataExtentApi.HEIGHT_PARAM)) : null;
String background = parameters.get(MetadataExtentApi.BACKGROUND_PARAM);
String geomParam = parameters.get(MetadataExtentApi.GEOM_PARAM);
String geomType = parameters.get(MetadataExtentApi.GEOM_TYPE_PARAM) != null ? parameters.get(MetadataExtentApi.GEOM_TYPE_PARAM) : "WKT";
String geomSrs = parameters.get(MetadataExtentApi.GEOM_SRS_PARAM) != null ? parameters.get(MetadataExtentApi.GEOM_SRS_PARAM) : "EPSG:4326";
String geomSrs = parameters.get(MetadataExtentApi.GEOM_SRS_PARAM) != null ? parameters.get(MetadataExtentApi.GEOM_SRS_PARAM) : DEFAULT_SRS;

if ((width == null) && (height == null)) {
// Width or height are required. If not set the default width with the same value
// as defined in MetadataExtentApi.getOneRecordExtentAsImage
width = 300;
}
image = mapRenderer.render(
id, srs, width, height, background, geomParam, geomType, geomSrs, null, null);
} catch (Exception e) {
@@ -189,14 +200,29 @@ public ReplacedElement createReplacedElement(LayoutContext layoutContext, BlockB
}
float factor = layoutContext.getDotsPerPixel();
return loadImage(layoutContext, box, userAgentCallback, cssWidth, cssHeight, new UrlImageLoader(builder.toString()), factor);

} else if (src.startsWith(baseUrlNoLang) && src.contains("/attachments/")) {
// Process attachments urls to load the images from the data directory
Matcher m = Pattern.compile(baseUrlNoLang + "api/records/(.*)/attachments/(.*)$").matcher(src);
if (m.find()) {
String uuid = m.group(1);
String file = m.group(2);

float factor = layoutContext.getDotsPerPixel();
return loadImage(layoutContext, box, userAgentCallback, cssWidth, cssHeight, new DataDirectoryImageLoader(uuid, file), factor);
} else if (isSupportedImageFormat(src)) {
float factor = layoutContext.getDotsPerPixel();
return loadImage(layoutContext, box, userAgentCallback, cssWidth, cssHeight, new UrlImageLoader(src), factor);
}

} else if (isSupportedImageFormat(src)) {
float factor = layoutContext.getDotsPerPixel();
return loadImage(layoutContext, box, userAgentCallback, cssWidth, cssHeight, new UrlImageLoader(src), factor);
}

try {
return superFactory.createReplacedElement(layoutContext, box, userAgentCallback, cssWidth, cssHeight);
} catch (Throwable e) {
} catch (Exception e) {
return new EmptyReplacedElement(cssWidth, cssHeight);
}
}
@@ -247,7 +273,7 @@ private ReplacedElement loadImage(LayoutContext layoutContext, BlockBox box, Use

try {
return superFactory.createReplacedElement(layoutContext, box, userAgentCallback, cssWidth, cssHeight);
} catch (Throwable e2) {
} catch (Exception e2) {
return new EmptyReplacedElement(cssWidth, cssHeight);
}
}
@@ -296,6 +322,35 @@ public Image loadImage() throws Exception {
}
}


/**
* Class to load images from the metadata data directory.
*/
private class DataDirectoryImageLoader implements ImageLoader {
private final String uuid;
private final String file;
public DataDirectoryImageLoader(String uuid, String file) {
this.uuid = uuid;
this.file = file;
}

@Override
public Image loadImage() throws Exception {
Store store = ApplicationContextHolder.get().getBean("filesystemStore", Store.class);
BufferedImage bufferedImage;
try (Store.ResourceHolder imageFile = store.getResourceInternal(
this.uuid,
MetadataResourceVisibility.PUBLIC,
this.file, true)) {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
bufferedImage = ImageIO.read(imageFile.getPath().toFile());
ImageIO.write(bufferedImage, "png", baos);
return Image.getInstance(baos.toByteArray());
}
}
}


/* Define an AWT BufferedImage image loader */

private class BufferedImageLoader implements ImageLoader {