Skip to content

Commit

Permalink
Create a metadata / Add dynamic and download privileges to the users …
Browse files Browse the repository at this point in the history
…in the same group (#7679)

* Create a metadata / Add dynamic and download privileges to the users in the same group

* Update core/src/main/java/org/fao/geonet/kernel/datamanager/base/BaseMetadataOperations.java

Co-authored-by: Ian <[email protected]>

---------

Co-authored-by: Ian <[email protected]>
  • Loading branch information
josegar74 and ianwallen authored Feb 13, 2024
1 parent a09a000 commit f92baa9
Showing 1 changed file with 8 additions and 10 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//=============================================================================
//=== Copyright (C) 2001-2011 Food and Agriculture Organization of the
//=== 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)
//===
Expand Down Expand Up @@ -167,7 +167,7 @@ public boolean setOperation(ServiceContext context, int mdId, int grpId, int opI
*/
@Override
public boolean forceSetOperation(ServiceContext context, int mdId, int grpId, int opId) throws Exception {
Optional<OperationAllowed> opAllowed = _getOperationAllowedToAdd(context, mdId, grpId, opId, false);
Optional<OperationAllowed> opAllowed = getOperationAllowedToAddInternal(context, mdId, grpId, opId, false);

if (opAllowed.isPresent()) {
Log.trace(Geonet.DATA_MANAGER, "Operation is allowed");
Expand Down Expand Up @@ -199,11 +199,11 @@ public boolean forceSetOperation(ServiceContext context, int mdId, int grpId, in
@Override
public Optional<OperationAllowed> getOperationAllowedToAdd(final ServiceContext context, final int mdId, final int grpId,
final int opId) {
return _getOperationAllowedToAdd(context, mdId, grpId, opId, true);
return getOperationAllowedToAddInternal(context, mdId, grpId, opId, true);
}

private Optional<OperationAllowed> _getOperationAllowedToAdd(final ServiceContext context, final int mdId, final int grpId,
final int opId, boolean shouldCheckPermission) {
private Optional<OperationAllowed> getOperationAllowedToAddInternal(final ServiceContext context, final int mdId, final int grpId,
final int opId, boolean shouldCheckPermission) {
Log.trace(Geonet.DATA_MANAGER, "_getOperationAllowedToAdd(" + mdId + ", "
+ grpId + ", " + opId + ", " + shouldCheckPermission + ")");
final OperationAllowed operationAllowed = opAllowedRepo.findOneById_GroupIdAndId_MetadataIdAndId_OperationId(grpId, mdId, opId);
Expand Down Expand Up @@ -340,14 +340,12 @@ public void copyDefaultPrivForGroup(ServiceContext context, String id, String gr

setOperation(context, id, groupId, ReservedOperation.view);
setOperation(context, id, groupId, ReservedOperation.notify);
setOperation(context, id, groupId, ReservedOperation.download);
setOperation(context, id, groupId, ReservedOperation.dynamic);
//
// Restrictive: new and inserted records should not be editable,
// their resources can't be downloaded and any interactive maps can't be
// displayed by users in the same group
// Restrictive: new and inserted records should not be editable by users in the same group,
if (fullRightsForGroup) {
setOperation(context, id, groupId, ReservedOperation.editing);
setOperation(context, id, groupId, ReservedOperation.download);
setOperation(context, id, groupId, ReservedOperation.dynamic);
}
// Ultimately this should be configurable elsewhere
}
Expand Down

0 comments on commit f92baa9

Please sign in to comment.