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 #105

Open
wants to merge 115 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
115 commits
Select commit Hold shift + click to select a range
bb9c861
Metadata editor / validation report improvements (#8395)
josegar74 Oct 8, 2024
d4d2a31
Fix the width of the projection switcher (#8399)
MichelGabriel Oct 8, 2024
51c0b01
Metadata editor / Add required indicator support to the keyword selec…
josegar74 Oct 3, 2024
f65ae30
Fixed spurious whitespace for gn-comma-list (#8398)
joachimnielandt Oct 8, 2024
78f8bfc
Metadata indexing / ISO19139 / ISO19115-3.2018 / Escape graphic overv…
josegar74 Oct 9, 2024
a0465e3
Harvester / ISO19115-3 / Better support missing metadata date info
fxprunayre Jun 6, 2024
3252d14
Update external management url
ianwallen Sep 8, 2024
b3f5000
Javascript / HTML formatting fixes related to Prettier
josegar74 Oct 1, 2024
1cc4e42
CSW / Fix parsing date values for filters. Fixes #8034
josegar74 Jun 25, 2024
8471646
Standard / ISO19115-3 / Only search for associated record with UUID
fxprunayre Jun 4, 2024
2df2bb1
Thesaurus / Add inScheme property in concept of local thesaurus
fxprunayre Jun 4, 2024
9228e4a
Editor / Table mode / Fix field using directive (#8261)
fxprunayre Oct 10, 2024
8f9cfa9
Map / Save your map improvements (#8155)
fxprunayre Oct 10, 2024
50cbfd0
Record view / Does not display thesaurus block if no keywords.
fxprunayre Oct 8, 2024
ffe8282
Thesaurus / OWL format / Mobility theme hierarchy (#8393)
fxprunayre Oct 10, 2024
c1564c0
Remove spaces from the list of schema list of metadata import restric…
ianwallen Oct 10, 2024
c7c9e97
Formatter / Datacite / Default resource type (#8407)
fxprunayre Oct 10, 2024
721cd4c
Fixed description for getIdentifiers in IdentifierApi (#8422)
SuperOctocat Oct 11, 2024
6d6eef1
Editor / Associated resource / Remote document / Add content type
fxprunayre Sep 3, 2024
58a713c
WebDav harvester / Add support for XSLT filter process (#8243)
josegar74 Oct 11, 2024
c7f8e8b
Editor / Geopublication / Misc fix. (#8092)
fxprunayre Oct 11, 2024
87a8e3d
Harvester / Simple URL / ODS improvement
fxprunayre Sep 9, 2024
9afd1bf
Improve administrator guide UI configuration documentation
michikommader Oct 11, 2024
eb1a2e9
Elasticsearch / API / Allow ndjson for _msearch endpoint
fxprunayre Oct 10, 2024
8c1636f
Remove empty filename condition (#8436)
tylerjmchugh Oct 16, 2024
7b9361a
Elasticsearch / Update to 8.14.3. (#8337)
fxprunayre Oct 16, 2024
5ef4f51
Harvester / Simple URL / Fix multiple URL alignement
fxprunayre Oct 15, 2024
4f1dc68
Fix saving UI settings without changes
josegar74 Oct 16, 2024
f64425c
Record view / More like this / Add filter option.
fxprunayre Oct 15, 2024
66d3a58
Add better logging when resources are deleted to make it clear what m…
ianwallen Oct 16, 2024
e20820a
Add bootstrap datepicker language files for supported UI languages
josegar74 Oct 16, 2024
82fda12
Avoid duplicate validation message when trying to register a user wit…
josegar74 Oct 17, 2024
7d97656
Update home page "browse by" to display facet as label if there is on…
tylerjmchugh Oct 17, 2024
5b01f64
Standard / DCAT (and profiles) export (#7600)
fxprunayre Oct 17, 2024
6cd9085
Delete date not being copied causing duplicate (#8454)
ianwallen Oct 22, 2024
cd72f8e
update PSC details in user guide
jodygarnett Oct 22, 2024
1a0c70e
Release / 4.4.6 / Changelog. (#8462)
fxprunayre Oct 24, 2024
a36ba67
Update version to 4.4.6-0
fxprunayre Oct 24, 2024
573d4be
Update version to 4.4.7-SNAPSHOT
fxprunayre Oct 24, 2024
43a57af
XSL utility / Add function to retrieve thesaurus URI
fxprunayre Oct 22, 2024
d8a5b72
Metadata status changes notification mails improvements: (#8453)
josegar74 Oct 28, 2024
ea92905
Documentation / Update managing privileges page:
josegar74 Oct 29, 2024
7500803
option to force xsd schema check for required field (#8294)
wangf1122 Oct 29, 2024
0de6cd4
Documentation / Metadata workflow improvements (#8473)
josegar74 Oct 29, 2024
b62e6c2
Add option to mock a dropdown for keywordPickers (#8401)
tylerjmchugh Oct 29, 2024
c93b5b1
getResourceInternal implementation for cmis and jcloud (#8466)
wangf1122 Nov 1, 2024
cd50ded
Configuration to display an application banner (#8416)
josegar74 Nov 4, 2024
62ec516
Configuration to display an application banner - fix database migrati…
josegar74 Nov 6, 2024
052be18
GeoTools 32.0 update and JTS 1.20.0 update
jodygarnett Nov 5, 2024
bedfe3d
Enhance static page with group user accessibility (#7707)
wangf1122 Nov 7, 2024
56a4069
Change icon for the layer tools in the layer manager panel on the map…
MichelGabriel Nov 8, 2024
6dbaa47
Metadata editor / Fix display of multiple choice elements with custom…
josegar74 Oct 30, 2024
d672a4c
Lib / Spring / Minor version update (#8498)
fxprunayre Nov 14, 2024
4cd0930
Admin / DOI server / Clarify labels for record group (#8496)
fxprunayre Nov 14, 2024
4fa388c
Metadata publication notifications / allow to configure the mail form…
josegar74 Nov 15, 2024
af0c541
Sort groups alphabetically on the new account and report pages
josegar74 Oct 29, 2024
97bdd7b
Metadata editor / Regions picker display empty entry form the metadat…
josegar74 Nov 22, 2024
7ba4d47
removing jena non-compliant attribute during harvesting
joachimnielandt Oct 9, 2024
c84ff3b
Update file upload so that it has better error support. (#8427)
ianwallen Nov 25, 2024
60014cd
Directory entries / Fix parsing of sorting configuration (#8482)
josegar74 Nov 26, 2024
6f3d10c
Component to allow checking duplicated metadata values for title, alt…
josegar74 Nov 26, 2024
92c20ba
Remove usage of ECMASCRIPT6 const keyword. (#8518)
josegar74 Nov 26, 2024
b125070
Add better Jcloud versioning supports (#8512)
ianwallen Nov 28, 2024
e8a46b4
Automatic formatting
juanluisrp Nov 28, 2024
908338e
Change ESAPI logger to SLF4J using log4j2 (#8522)
josegar74 Nov 28, 2024
0fc0447
Batch selection is not in sync between search results and record view.
josegar74 Nov 8, 2024
8ca1e5c
Use case insensitive username for login and reset password (#8523)
josegar74 Nov 29, 2024
5e6f08f
update PSC details in user guide
fxprunayre Nov 29, 2024
c5b3fa6
Use the copyBlob to copy the resource with updated metadata (#8530)
ianwallen Dec 4, 2024
1b6d0fb
Update index to use a key with translations defined for map resource …
tylerjmchugh Dec 5, 2024
df52e1f
fixed login url for missing records
joachimnielandt Dec 4, 2024
2471bd3
Update CONTRIBUTING.md to describe the CLA automation
ticheler Dec 8, 2024
85eb829
Update README.md
ticheler Dec 8, 2024
82cc425
ISO19115.3-2008 / Fix typo in facsimile codelist value (#8539)
josegar74 Dec 9, 2024
e5bf00d
Fix wrong HTML self-closed elements. (#8542)
josegar74 Dec 9, 2024
794db36
ISO19110 / ISO19115-3.2008 / Fix indexing of multiple feature type al…
josegar74 Dec 9, 2024
c2b4558
Formatters / DCAT-AP / Allow PO URI to be used for constraints.
fxprunayre Nov 21, 2024
cd74d3b
Update db search and replace to support working copies (#8514)
tylerjmchugh Dec 10, 2024
18b00b3
Restrict setting privileges on groups (#8511)
tylerjmchugh Dec 10, 2024
a9c2e05
Attachments API use filename from Content-Disposition before url (#8470)
tylerjmchugh Dec 10, 2024
d5dc0d6
Editor / Add support for conditional default view
fxprunayre Dec 10, 2024
3389c9e
Standard / ISO19115-3 / Process / encode all keywords using anchor (#…
GeryNi Dec 11, 2024
96869d8
Editor / Improve support of schema having sibling elements for transl…
fxprunayre Dec 11, 2024
795b153
Editor / Add keywords even if thesaurus not available in record langu…
fxprunayre Dec 11, 2024
31c641d
Formatter / DCAT / Service (#8526)
fxprunayre Dec 11, 2024
36ce40b
Restyled `default` address block (#8289)
MichelGabriel Dec 11, 2024
4fbdefd
JWT Headers security module (#7899)
davidblasby Dec 11, 2024
b6114ea
Update CONTRIBUTING.md
geonetworkbuild Dec 11, 2024
c16869d
Update README.md
ticheler Dec 11, 2024
6545aa0
Attachments API / Set content-length and close input stream when retr…
josegar74 Dec 12, 2024
c0a6baf
Formatter / DCAT / Improvements
fxprunayre Dec 9, 2024
5ec47b5
DCAT / GeoDCAT-AP / Update shacl rules to version 3.
fxprunayre Dec 10, 2024
20d67b4
GeoDCAT-AP / Extends DCAT-AP-HVD.
fxprunayre Dec 10, 2024
180e409
DCAT-AP-HVD / Update vocabulary for HVD category including now sub ca…
fxprunayre Dec 10, 2024
9e035a6
Documentation / DCAT / Improvement.
fxprunayre Dec 10, 2024
657e195
Formatter / DCAT / Fix test after rebase of https://github.com/geonet…
fxprunayre Dec 10, 2024
8a531d0
Formatter / DCAT / Add element in Resource (mandatory in HVD for ser…
fxprunayre Dec 10, 2024
0856a80
Fix eu-applicable-legislation.rdf
fxprunayre Dec 11, 2024
541bd22
Update schemas/iso19115-3.2018/src/main/plugin/iso19115-3.2018/format…
fxprunayre Dec 11, 2024
8e31a5f
Formatter / DCAT / Fix test after rebase.
fxprunayre Dec 11, 2024
80a0fee
Standard / ISO / Schematron for HVD
fxprunayre Dec 10, 2024
91b82fa
support section variable in manual url (#8494)
wangf1122 Dec 14, 2024
64f9efc
Doc / DCAT page / Fix formatting (#8563)
fxprunayre Dec 16, 2024
408dc79
Formatters / Properly detect URL ending in 1,2,3 or 5 (#8235)
fxprunayre Dec 16, 2024
2432dc9
Feature catalogue / Add table of content of feature types (#8041)
fxprunayre Dec 16, 2024
86242e8
Editor / Add unit attribute as main field (#8245)
fxprunayre Dec 16, 2024
d975d52
Admin / Schematron / Fix icon in rules (#8569)
fxprunayre Dec 17, 2024
b252795
API / Extents / Add option to generate square image
fxprunayre Dec 16, 2024
19d5b5c
Facet / Add meta property to customize label. (#8536)
fxprunayre Dec 19, 2024
39d9f66
remove outgoing headers for the proxy
david-blasby Dec 16, 2024
da294f7
ISO19115-3.2008 - Add URL check schematron (#8575)
josegar74 Dec 20, 2024
9d3e585
Return xml inside JSON status (#8579)
wangf1122 Dec 24, 2024
490e6b9
GN5 / Security configuration
fxprunayre Dec 12, 2024
eab5c1b
Url decode the resourceId supplied to store.getResourceInternal to fi…
ianwallen Jan 10, 2025
21f0dc8
Fix set site settings in swagger_ui so it function correctly. (#8582)
ianwallen Jan 10, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
6 changes: 5 additions & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,11 @@

Thank you for contributing to GeoNetwork!

* Free-software: GeoNetwork is free-software, using the [GNU GENERAL PUBLIC LICENSE](LICENSE.md). Contributions provided by you, or your employer, are required to be compatible with this free-software license.
* Free-software: GeoNetwork is free-software, using the [GNU GENERAL PUBLIC LICENSE](LICENSE.md).
* Contributions provided by you, or your employer, are required to be compatible with this free-software license. You will therefor be asked to sign the [Contributor License Agreement](https://cla-assistant.io/geonetwork/) when you are contributing to the repositories. This process is automatically enabled when you create your first pull request via https://cla-assistant.io/.

[![CLA assistant](https://cla-assistant.io/readme/badge/geonetwork/geonetwork)](https://cla-assistant.io/geonetwork/geonetwork)

* Pull-request: GeoNetwork uses a pull-request workflow to review and accept changes. Pull-requests must be submitted against the *main* branch first, and may be back ported as required.

# Pull requests
Expand Down
9 changes: 2 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
# GeoNetwork opensource

## Build Health

[![Build Status](https://github.com/geonetwork/core-geonetwork/actions/workflows/linux.yml/badge.svg?branch=main)](https://github.com/geonetwork/core-geonetwork/actions/workflows/linux.yml?query=branch%3Amain)
[![Build Status](https://github.com/geonetwork/core-geonetwork/actions/workflows/linux.yml/badge.svg?branch=main)](https://github.com/geonetwork/core-geonetwork/actions/workflows/linux.yml?query=branch%3Amain) [![OpenSSF Best Practices](https://www.bestpractices.dev/projects/8626/badge)](https://www.bestpractices.dev/projects/8626) [![CLA assistant](https://cla-assistant.io/readme/badge/geonetwork/geonetwork)](https://cla-assistant.io/geonetwork/geonetwork)

## Features

Expand All @@ -29,7 +27,4 @@ Developer documentation located in ``README.md`` files in the code-base:

* General documentation for the project as a whole is in this [README.md](README.md)
* [Software Development Documentation](/software_development/) provides instructions for setting up a development environment, building GeoNetwork, compiling user documentation, and making a releases.
* Module specific documentation can be found in each module:

## Open Source Security Foundation (OpenSSF) best practices status
[![OpenSSF Best Practices](https://www.bestpractices.dev/projects/8626/badge)](https://www.bestpractices.dev/projects/8626)
* Module specific documentation can be found in each module
2 changes: 1 addition & 1 deletion cachingxslt/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
<parent>
<groupId>org.geonetwork-opensource</groupId>
<artifactId>geonetwork</artifactId>
<version>4.4.6-SNAPSHOT</version>
<version>4.4.7-SNAPSHOT</version>
</parent>


Expand Down
2 changes: 1 addition & 1 deletion common/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
<parent>
<groupId>org.geonetwork-opensource</groupId>
<artifactId>geonetwork</artifactId>
<version>4.4.6-SNAPSHOT</version>
<version>4.4.7-SNAPSHOT</version>
</parent>


Expand Down
13 changes: 12 additions & 1 deletion core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,21 @@
<parent>
<artifactId>geonetwork</artifactId>
<groupId>org.geonetwork-opensource</groupId>
<version>4.4.6-SNAPSHOT</version>
<version>4.4.7-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

<artifactId>gn-core</artifactId>
<name>GeoNetwork core</name>

<dependencies>

<dependency>
<groupId>org.geoserver.community.jwt-headers</groupId>
<artifactId>jwt-headers-util</artifactId>
<version>2.27-SNAPSHOT</version>
</dependency>

<dependency>
<groupId>net.objecthunter</groupId>
<artifactId>exp4j</artifactId>
Expand Down Expand Up @@ -304,6 +311,10 @@
<groupId>org.geotools</groupId>
<artifactId>gt-geojson</artifactId>
</dependency>
<dependency>
<groupId>com.jayway.jsonpath</groupId>
<artifactId>json-path</artifactId>
</dependency>
<dependency>
<groupId>org.locationtech.jts</groupId>
<artifactId>jts-core</artifactId>
Expand Down
6 changes: 3 additions & 3 deletions core/src/main/java/jeeves/component/ProfileManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,11 @@ public class ProfileManager {
*/
public static Profile getLowestProfile(String[] profiles) {
Profile lowestProfile = null;
int numberOfProfilesExtended = Profile.Administrator.getAll().size();
int numberOfProfilesExtended = Profile.Administrator.getProfileAndAllChildren().size();

for (String profileName : profiles) {
Profile p = Profile.valueOf(profileName);
Set<Profile> currentProfileSet = p.getAll();
Set<Profile> currentProfileSet = p.getProfileAndAllChildren();
if (currentProfileSet.size() < numberOfProfilesExtended) {
lowestProfile = p;
numberOfProfilesExtended = currentProfileSet.size();
Expand All @@ -89,7 +89,7 @@ public static Profile getHighestProfile(Profile[] profiles) {
int numberOfProfilesExtended = 0;

for (Profile profile : profiles) {
Set<Profile> all = profile.getAll();
Set<Profile> all = profile.getProfileAndAllChildren();
if (all.size() > numberOfProfilesExtended) {
highestProfile = profile;
numberOfProfilesExtended = all.size();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
/*
* Copyright (C) 2001-2024 Food and Agriculture Organization of the
* United Nations (FAO-UN), United Nations World Food Programme (WFP)
* and United Nations Environment Programme (UNEP)
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or (at
* your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*
* Contact: Jeroen Ticheler - FAO - Viale delle Terme di Caracalla 2,
* Rome - Italy. email: [email protected]
*/

package org.fao.geonet.api.exception;

import java.util.Locale;

import org.fao.geonet.exceptions.LocalizedException;

public class GeonetMaxUploadSizeExceededException extends LocalizedException {

public GeonetMaxUploadSizeExceededException() {
super();
}

public GeonetMaxUploadSizeExceededException(String message) {
super(message);
}

public GeonetMaxUploadSizeExceededException(String message, Throwable cause) {
super(message, cause);
}

public GeonetMaxUploadSizeExceededException(Throwable cause) {
super(cause);
}

protected String getResourceBundleBeanQualifier() {
return "apiMessages";
}

@Override
public GeonetMaxUploadSizeExceededException withMessageKey(String messageKey) {
super.withMessageKey(messageKey);
return this;
}

@Override
public GeonetMaxUploadSizeExceededException withMessageKey(String messageKey, Object[] messageKeyArgs) {
super.withMessageKey(messageKey, messageKeyArgs);
return this;
}

@Override
public GeonetMaxUploadSizeExceededException withDescriptionKey(String descriptionKey) {
super.withDescriptionKey(descriptionKey);
return this;
}

@Override
public GeonetMaxUploadSizeExceededException withDescriptionKey(String descriptionKey, Object[] descriptionKeyArgs) {
super.withDescriptionKey(descriptionKey, descriptionKeyArgs);
return this;
}

@Override
public GeonetMaxUploadSizeExceededException withLocale(Locale locale) {
super.withLocale(locale);
return this;
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* =============================================================================
* === Copyright (C) 2019 Food and Agriculture Organization of the
* === Copyright (C) 2024 Food and Agriculture Organization of the
* === United Nations (FAO-UN), United Nations World Food Programme (WFP)
* === and United Nations Environment Programme (UNEP)
* ===
Expand Down Expand Up @@ -35,21 +35,30 @@
import org.fao.geonet.kernel.AccessManager;
import org.fao.geonet.kernel.datamanager.IMetadataUtils;
import org.fao.geonet.repository.MetadataRepository;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.ApplicationContext;
import org.springframework.web.multipart.MultipartFile;

import java.io.BufferedInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.HttpURLConnection;
import java.net.URL;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.Base64;
import java.util.List;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;

public abstract class AbstractStore implements Store {
protected static final String RESOURCE_MANAGEMENT_EXTERNAL_PROPERTIES_SEPARATOR = ":";
protected static final String RESOURCE_MANAGEMENT_EXTERNAL_PROPERTIES_ESCAPED_SEPARATOR = "\\:";
private static final Logger log = LoggerFactory.getLogger(AbstractStore.class);

@Override
public final List<MetadataResource> getResources(final ServiceContext context, final String metadataUuid, final Sort sort,
final String filter) throws Exception {
Expand Down Expand Up @@ -148,6 +157,29 @@ protected int canDownload(ServiceContext context, String metadataUuid, MetadataR
return metadataId;
}

protected String getFilenameFromHeader(final URL fileUrl) throws IOException {
HttpURLConnection connection = null;
try {
connection = (HttpURLConnection) fileUrl.openConnection();
connection.setRequestMethod("HEAD");
connection.connect();
String contentDisposition = connection.getHeaderField("Content-Disposition");

if (contentDisposition != null && contentDisposition.contains("filename=")) {
String filename = contentDisposition.split("filename=")[1].replace("\"", "").trim();
return filename.isEmpty() ? null : filename;
}
return null;
} catch (Exception e) {
log.error("Error retrieving resource filename from header", e);
return null;
} finally {
if (connection != null) {
connection.disconnect();
}
}
}

protected String getFilenameFromUrl(final URL fileUrl) {
String fileName = FilenameUtils.getName(fileUrl.getPath());
if (fileName.contains("?")) {
Expand Down Expand Up @@ -194,7 +226,11 @@ public final MetadataResource putResource(ServiceContext context, String metadat
@Override
public final MetadataResource putResource(ServiceContext context, String metadataUuid, URL fileUrl,
MetadataResourceVisibility visibility, Boolean approved) throws Exception {
return putResource(context, metadataUuid, getFilenameFromUrl(fileUrl), fileUrl.openStream(), null, visibility, approved);
String filename = getFilenameFromHeader(fileUrl);
if (filename == null) {
filename = getFilenameFromUrl(fileUrl);
}
return putResource(context, metadataUuid, filename, fileUrl.openStream(), null, visibility, approved);
}

@Override
Expand Down Expand Up @@ -279,4 +315,28 @@ public String toString() {
}
};
}

private String escapeResourceManagementExternalProperties(String value) {
return value.replace(RESOURCE_MANAGEMENT_EXTERNAL_PROPERTIES_SEPARATOR, RESOURCE_MANAGEMENT_EXTERNAL_PROPERTIES_ESCAPED_SEPARATOR);
}

/**
* Create an encoded base 64 object id contains the following fields to uniquely identify the resource
* The fields are separated by a colon ":"
* @param type to identify type of storage - document/folder
* @param visibility of the resource public/private
* @param metadataId internal metadata id
* @param version identifier which can be used to directly get this version.
* @param resourceId or filename of the resource
* @return based 64 object id
*/
protected String getResourceManagementExternalPropertiesObjectId(final String type, final MetadataResourceVisibility visibility, final Integer metadataId, final String version,
final String resourceId) {
return Base64.getEncoder().encodeToString(
((type + RESOURCE_MANAGEMENT_EXTERNAL_PROPERTIES_SEPARATOR +
escapeResourceManagementExternalProperties(visibility == null ? "" : visibility.toString().toLowerCase()) + RESOURCE_MANAGEMENT_EXTERNAL_PROPERTIES_SEPARATOR +
metadataId + RESOURCE_MANAGEMENT_EXTERNAL_PROPERTIES_SEPARATOR +
escapeResourceManagementExternalProperties(version == null ? "" : version) + RESOURCE_MANAGEMENT_EXTERNAL_PROPERTIES_SEPARATOR +
escapeResourceManagementExternalProperties(resourceId)).getBytes()));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -234,33 +234,43 @@ public String delResources(ServiceContext context, int metadataId) throws Except
try {
Log.info(Geonet.RESOURCES, String.format("Deleting all files from metadataId '%d'", metadataId));
IO.deleteFileOrDirectory(metadataDir, true);
return String.format("Metadata '%s' directory removed.", metadataId);
Log.info(Geonet.RESOURCES,
String.format("Metadata '%d' directory removed.", metadataId));
return String.format("Metadata '%d' directory removed.", metadataId);
} catch (Exception e) {
return String.format("Unable to remove metadata '%s' directory.", metadataId);
return String.format("Unable to remove metadata '%d' directory.", metadataId);
}
}

@Override
public String delResource(ServiceContext context, String metadataUuid, String resourceId, Boolean approved) throws Exception {
canEdit(context, metadataUuid, approved);
int metadataId = canEdit(context, metadataUuid, approved);

try (ResourceHolder filePath = getResource(context, metadataUuid, resourceId, approved)) {
Files.deleteIfExists(filePath.getPath());
return String.format("MetadataResource '%s' removed.", resourceId);
Log.info(Geonet.RESOURCES,
String.format("Resource '%s' removed for metadata %d (%s).", resourceId, metadataId, metadataUuid));
return String.format("Metadata resource '%s' removed.", resourceId);
} catch (IOException e) {
Log.warning(Geonet.RESOURCES,
String.format("Unable to remove resource '%s' for metadata %d (%s). %s", resourceId, metadataId, metadataUuid, e.getMessage()));
return String.format("Unable to remove resource '%s'.", resourceId);
}
}

@Override
public String delResource(final ServiceContext context, final String metadataUuid, final MetadataResourceVisibility visibility,
final String resourceId, Boolean approved) throws Exception {
canEdit(context, metadataUuid, approved);
int metadataId = canEdit(context, metadataUuid, approved);

try (ResourceHolder filePath = getResource(context, metadataUuid, visibility, resourceId, approved)) {
Files.deleteIfExists(filePath.getPath());
return String.format("MetadataResource '%s' removed.", resourceId);
Log.info(Geonet.RESOURCES,
String.format("Resource '%s' removed for metadata %d (%s).", resourceId, metadataId, metadataUuid));
return String.format("Metadata resource '%s' removed.", resourceId);
} catch (IOException e) {
Log.warning(Geonet.RESOURCES,
String.format("Unable to remove resource '%s' for metadata %d (%s). %s", resourceId, metadataId, metadataUuid, e.getMessage()));
return String.format("Unable to remove resource '%s'.", resourceId);
}
}
Expand Down
31 changes: 31 additions & 0 deletions core/src/main/java/org/fao/geonet/kernel/AccessManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -509,6 +509,37 @@ private boolean hasEditingPermissionWithProfile(final ServiceContext context, fi

}

/**
* Checks if the user has the specified profile or any profile with greater permissions within the group.
*
* @param context The service context containing the user's session.
* @param profile The profile to be verified.
* @param groupId The ID of the group in which the user's profile is to be verified.
* @return true if the user has the specified profile (or greater) within the group; false otherwise.
*/
public boolean isProfileOrMoreOnGroup(final ServiceContext context, Profile profile, final int groupId) {
UserSession us = context.getUserSession();
if (!isUserAuthenticated(us)) {
return false;
}

// Grant access if the user is a global administrator
if (Profile.Administrator == us.getProfile()) {
return true;
}

// Get the profile and all its parent profiles to consider higher-level permissions
Set<Profile> acceptedProfiles = profile.getProfileAndAllParents();

// Build a specification to fetch any accepted profiles for the user in the specified group
Specification<UserGroup> spec = Specification.where(UserGroupSpecs.hasUserId(us.getUserIdAsInt()))
.and(UserGroupSpecs.hasGroupId(groupId))
.and(UserGroupSpecs.hasProfileIn(acceptedProfiles));
List<UserGroup> userGroups = userGroupRepository.findAll(spec);

return !userGroups.isEmpty();
}

public int getPrivilegeId(final String name) {
final Operation op = operationRepository.findByName(name);
if (op == null) {
Expand Down
Loading