Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -79,16 +79,28 @@ public List<MetadataResource> getResources(final ServiceContext context, final S
return getResources(context, metadataUuid, metadataResourceVisibility, filter, true);
}

@Override
public List<MetadataResource> getResources(ServiceContext context, String metadataUuid, MetadataResourceVisibility metadataResourceVisibility, String filter, Boolean approved)
throws Exception {
return getResources(context, metadataUuid, metadataResourceVisibility, filter, approved, false);
}

@Override
public List<MetadataResource> getResources(ServiceContext context, String metadataUuid, Sort sort, String filter, Boolean approved)
throws Exception {
return getResources(context, metadataUuid, sort, filter, approved, false);
}

@Override
public List<MetadataResource> getResources(ServiceContext context, String metadataUuid, Sort sort, String filter, Boolean approved, boolean includeAdditionalIndexedProperties)
throws Exception {
int metadataId = getAndCheckMetadataId(metadataUuid, approved);
boolean canEdit = getAccessManager(context).canEdit(context, String.valueOf(metadataId));

List<MetadataResource> resourceList = new ArrayList<>(
getResources(context, metadataUuid, MetadataResourceVisibility.PUBLIC, filter, approved));
getResources(context, metadataUuid, MetadataResourceVisibility.PUBLIC, filter, approved, includeAdditionalIndexedProperties));
if (canEdit) {
resourceList.addAll(getResources(context, metadataUuid, MetadataResourceVisibility.PRIVATE, filter, approved));
resourceList.addAll(getResources(context, metadataUuid, MetadataResourceVisibility.PRIVATE, filter, approved, includeAdditionalIndexedProperties));
}

if (sort == Sort.name) {
Expand Down Expand Up @@ -289,7 +301,7 @@ public MetadataResource patchResourceStatus(final ServiceContext context, final

@Override
public void copyResources(ServiceContext context, String sourceUuid, String targetUuid, MetadataResourceVisibility metadataResourceVisibility, boolean sourceApproved, boolean targetApproved) throws Exception {
final List<MetadataResource> resources = getResources(context, sourceUuid, metadataResourceVisibility, null, sourceApproved);
final List<MetadataResource> resources = getResources(context, sourceUuid, metadataResourceVisibility, null, sourceApproved, false);
for (MetadataResource resource: resources) {
try (Store.ResourceHolder holder = getResource(context, sourceUuid, metadataResourceVisibility, resource.getFilename(), sourceApproved)) {
putResource(context, targetUuid, holder.getResource(), metadataResourceVisibility, targetApproved);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ public FilesystemStore() {

@Override
public List<MetadataResource> getResources(ServiceContext context, String metadataUuid, MetadataResourceVisibility visibility,
String filter, Boolean approved) throws Exception {
String filter, Boolean approved, boolean includeAdditionalIndexedProperties) throws Exception {
int metadataId = canDownload(context, metadataUuid, visibility, approved);

Path metadataDir = Lib.resource.getMetadataDir(getDataDirectory(context), metadataId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,16 @@ public List<MetadataResource> getResources(ServiceContext context, String metada
return null;
}

@Override
public List<MetadataResource> getResources(ServiceContext context, String metadataUuid,
MetadataResourceVisibility metadataResourceVisibility, String filter, Boolean approved, boolean includeAdditionalIndexedProperties)
throws Exception {
if (decoratedStore != null) {
return decoratedStore.getResources(context, metadataUuid, metadataResourceVisibility, filter, approved, includeAdditionalIndexedProperties);
}
return null;
}

@Override
public ResourceHolder getResource(final ServiceContext context, final String metadataUuid, final MetadataResourceVisibility visibility,
final String resourceId, Boolean approved) throws Exception {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,57 @@ public interface Store {
*/
List<MetadataResource> getResources(ServiceContext context, String metadataUuid, MetadataResourceVisibility metadataResourceVisibility, String filter, Boolean approved) throws Exception;

/**
* Retrieve all resources for a metadata. The list of resources depends on current user
* privileges.
*
* <p>This overload allows callers to control whether additional indexed properties
* are populated on each returned {@link MetadataResource}. Callers should set
* {@code includeAdditionalIndexedProperties} to {@code true} only when they actually
* need those extra indexed values (for example, when preparing data for search or
* indexing purposes). For simple listing or download operations where these extra
* properties are not required, it is recommended to set this flag to {@code false}.</p>
*
* @param context the service context
* @param metadataUuid the metadata UUID
* @param sort sort by resource name or sharing policy {@link Sort}
* @param filter a {@link java.nio.file.Files#newDirectoryStream(Path) GLOB
* expression} to filter resources eg. *.{png|jpg}
* @param approved return the approved version or not
* @param includeAdditionalIndexedProperties whether to populate additional indexed
* properties on returned resources ({@code true}) or to skip them
* for better performance when they are not needed ({@code false})
* @return A list of resources
* @throws Exception if an error occurs while retrieving the resources
*/
List<MetadataResource> getResources(ServiceContext context, String metadataUuid, Sort sort, String filter, Boolean approved, boolean includeAdditionalIndexedProperties) throws Exception;

/**
* Retrieve all resources for a metadata having a specific sharing policy.
*
* <p>This overload allows callers to control whether additional indexed properties
* are populated on each returned {@link MetadataResource}. Callers should set
* {@code includeAdditionalIndexedProperties} to {@code true} only when they actually
* need those extra indexed values (for example, when preparing data for search or
* indexing purposes). For simple listing or download operations where these extra
* properties are not required, it is recommended to set this flag to {@code false}.</p>
*
* @param context the service context
* @param metadataUuid the metadata UUID
* @param metadataResourceVisibility the type of sharing policy
* {@link MetadataResourceVisibility}
* @param filter a {@link java.nio.file.Files#newDirectoryStream(Path) GLOB
* expression} to filter resources eg. *.{png|jpg}
* @param approved return the approved version or not
* @param includeAdditionalIndexedProperties whether to populate additional indexed
* properties on returned resources ({@code true})
* or to skip them for better performance when they
* are not needed ({@code false})
* @return A list of resources
* @throws Exception if an error occurs while retrieving the resources
*/
List<MetadataResource> getResources(ServiceContext context, String metadataUuid, MetadataResourceVisibility metadataResourceVisibility, String filter, Boolean approved, boolean includeAdditionalIndexedProperties) throws Exception;

/**
* Retrieve a resource.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -705,7 +705,8 @@ public Multimap<String, Object> indexMetadataFileStore(AbstractMetadata fullMd)
fullMd.getUuid(),
(org.fao.geonet.api.records.attachments.Sort) null,
null,
!(fullMd instanceof MetadataDraft));
!(fullMd instanceof MetadataDraft),
true);

if (metadataResources != null && !metadataResources.isEmpty()) {
JsonNode jsonNode = indexObjectMapper.valueToTree(metadataResources);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ public class CMISStore extends AbstractStore {

@Override
public List<MetadataResource> getResources(final ServiceContext context, final String metadataUuid,
final MetadataResourceVisibility visibility, String filter, Boolean approved) throws Exception {
final MetadataResourceVisibility visibility, String filter, Boolean approved, boolean includeAdditionalIndexedProperties) throws Exception {
final int metadataId = canDownload(context, metadataUuid, visibility, approved);

final String resourceTypeDir = getMetadataDir(context, metadataId) + cmisConfiguration.getFolderDelimiter() + visibility.toString();
Expand Down
Loading
Loading