metadataRecord = new ArrayList<>(isUserHistoryEnabled ? 7 : 6);
metadataRecord.add(username);
metadataRecord.add(surname);
metadataRecord.add(name);
@@ -144,8 +148,8 @@ public void create(final ServiceContext context,
/**
* Creates a string with the list of groups / profiles of a user:
- *
- * group1/profileGroup1-group2/profileGroup2 ...
+ *
+ * group1/profileGroup1-group2/profileGroup2 ...
*
* @param context
* @param user
@@ -174,7 +178,7 @@ private String retrieveGroupsListInfo(final ServiceContext context, User user) {
if (i++ > 0) {
userGroupsList.append("-");
}
- userGroupsList.append(groupName + "/" + groupProfile);
+ userGroupsList.append(groupName).append("/").append(groupProfile);
}
return userGroupsList.toString();
diff --git a/services/src/main/java/org/fao/geonet/api/users/UsersApi.java b/services/src/main/java/org/fao/geonet/api/users/UsersApi.java
index eb27d0dd82f..c23134054ec 100644
--- a/services/src/main/java/org/fao/geonet/api/users/UsersApi.java
+++ b/services/src/main/java/org/fao/geonet/api/users/UsersApi.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2001-2021 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)
*
@@ -202,7 +202,7 @@ public User getUser(
myUserId.equals(Integer.toString(userIdentifier))) {
Optional user = userRepository.findById(userIdentifier);
- if (!user.isPresent()) {
+ if (user.isEmpty()) {
throw new UserNotFoundEx(Integer.toString(userIdentifier));
}
@@ -251,7 +251,7 @@ public void getUserIdenticon(
try {
Optional user = userRepository.findById(userIdentifier);
- if (!user.isPresent()) {
+ if (user.isEmpty()) {
throw new UserNotFoundEx(Integer.toString(userIdentifier));
}
@@ -350,7 +350,7 @@ public ResponseEntity deleteUser(
List userGroups = userGroupRepository.findAll(UserGroupSpecs.hasUserId(userIdentifier));
userGroupRepository.deleteAllByIdAttribute(UserGroupId_.userId,
- Arrays.asList(userIdentifier));
+ List.of(userIdentifier));
userSavedSelectionRepository.deleteAllByUser(userIdentifier);
@@ -409,7 +409,7 @@ public ResponseEntity checkUserPropertyExist(
return new ResponseEntity<>(HttpStatus.OK);
}
} else {
- throw new IllegalArgumentException(String.format("Property '%s' is not supported. You can only check username and email"));
+ throw new IllegalArgumentException("Property is not supported. You can only check username and email");
}
return new ResponseEntity<>(HttpStatus.NOT_FOUND);
}
@@ -557,16 +557,16 @@ public ResponseEntity updateUser(
// TODO: CheckAccessRights
- User user = userRepository.findById(userIdentifier).get();
- if (user == null) {
- throw new IllegalArgumentException("No user found with id: "
- + userDto.getId());
+ Optional userOptional = userRepository.findById(userIdentifier);
+ if (userOptional.isEmpty()) {
+ throw new IllegalArgumentException(String.format("No user found with id: %s", userDto.getId()));
}
+ User user = userOptional.get();
// Check no duplicated username and if we are adding a duplicate existing name with other case combination
List usersWithUsernameIgnoreCase = userRepository.findByUsernameIgnoreCase(userDto.getUsername());
- if (usersWithUsernameIgnoreCase.size() != 0 &&
- (!usersWithUsernameIgnoreCase.stream().anyMatch(u -> u.getId() == userIdentifier)
+ if (!usersWithUsernameIgnoreCase.isEmpty() &&
+ (usersWithUsernameIgnoreCase.stream().noneMatch(u -> u.getId() == userIdentifier)
|| usersWithUsernameIgnoreCase.stream().anyMatch(u ->
u.getUsername().equals(userDto.getUsername()) && u.getId() != userIdentifier)
)) {
@@ -588,7 +588,7 @@ public ResponseEntity updateUser(
groups.addAll(processGroups(userDto.getGroupsReviewer(), Profile.Reviewer));
groups.addAll(processGroups(userDto.getGroupsUserAdmin(), Profile.UserAdmin));
- //If it is a useradmin updating,
+ //If it is an useradmin updating,
//maybe we don't know all the groups the user is part of
if (!Profile.Administrator.equals(myProfile)) {
List myUserAdminGroups = userGroupRepository.findGroupIds(Specification.where(
@@ -642,7 +642,6 @@ public ResponseEntity updateUser(
List userGroups = userGroupRepository.findAll(UserGroupSpecs
.hasUserId(user.getId()));
- //userAudit.setUserGroups(userGroups);
UserAuditable userAuditable = UserAuditable.build(user, userGroups);
userAuditableService.auditSave(userAuditable);
@@ -706,7 +705,7 @@ public ResponseEntity resetUserPassword(
}
Optional user = userRepository.findById(userIdentifier);
- if (!user.isPresent()) {
+ if (user.isEmpty()) {
throw new UserNotFoundEx(Integer.toString(userIdentifier));
}
@@ -756,10 +755,12 @@ public List retrieveUserGroups(
if (Profile.Administrator.equals(myProfile) || Profile.UserAdmin.equals(myProfile) || myUserId.equals(Integer.toString(userIdentifier))) {
// -- get the profile of the user id supplied
- User user = userRepository.findById(userIdentifier).get();
- if (user == null) {
+ Optional userOptional = userRepository.findById(userIdentifier);
+
+ if (userOptional.isEmpty()) {
throw new IllegalArgumentException("user " + userIdentifier + " doesn't exist");
}
+ User user = userOptional.get();
String userProfile = user.getProfile().name();
@@ -825,7 +826,7 @@ private void setUserGroups(final User user, List userGroups)
.hasUserId(user.getId()));
// Have a quick reference of existing groups and profiles for this user
- Set listOfAddedProfiles = new HashSet();
+ Set listOfAddedProfiles = new HashSet<>();
for (UserGroup ug : all) {
String key = ug.getProfile().name() + ug.getGroup().getId();
listOfAddedProfiles.add(key);
@@ -833,11 +834,10 @@ private void setUserGroups(final User user, List userGroups)
// We start removing all old usergroup objects. We will remove the
// explicitly defined for this call
- Collection toRemove = new ArrayList();
- toRemove.addAll(all);
+ Collection toRemove = new ArrayList<>(all);
// New pairs of group-profile we need to add
- Collection toAdd = new ArrayList();
+ Collection toAdd = new ArrayList<>();
// For each of the parameters on the request, make sure the group is
// updated.
@@ -897,7 +897,7 @@ private void setUserGroups(final User user, List userGroups)
private List processGroups(List groupsToProcessList, Profile profile) {
- List groups = new LinkedList();
+ List groups = new LinkedList<>();
for (String g : groupsToProcessList) {
groups.add(new GroupElem(profile.name(), Integer.parseInt(g)));
}
diff --git a/web-ui/src/main/resources/catalog/components/viewer/layermanager/partials/layermanageritem.html b/web-ui/src/main/resources/catalog/components/viewer/layermanager/partials/layermanageritem.html
index b40b9faa08b..5a1e1fee2ff 100644
--- a/web-ui/src/main/resources/catalog/components/viewer/layermanager/partials/layermanageritem.html
+++ b/web-ui/src/main/resources/catalog/components/viewer/layermanager/partials/layermanageritem.html
@@ -29,7 +29,6 @@
diff --git a/web-ui/src/main/resources/catalog/js/admin/UserGroupController.js b/web-ui/src/main/resources/catalog/js/admin/UserGroupController.js
index 9b9987b94c7..3eace89f974 100644
--- a/web-ui/src/main/resources/catalog/js/admin/UserGroupController.js
+++ b/web-ui/src/main/resources/catalog/js/admin/UserGroupController.js
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2001-2016 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)
*
@@ -49,8 +49,10 @@
"$rootScope",
"$translate",
"$timeout",
+ "$log",
"gnConfig",
"gnConfigService",
+ "gnAuditableService",
function (
$scope,
$routeParams,
@@ -58,8 +60,10 @@
$rootScope,
$translate,
$timeout,
+ $log,
gnConfig,
- gnConfigService
+ gnConfigService,
+ gnAuditableService
) {
$scope.searchObj = {
params: {
@@ -319,17 +323,19 @@
);
// Load user changes
- $http.get("../api/auditable/user/" + u.id).then(
+ gnAuditableService.getEntityHistory("user", u.id).then(
function (response) {
$scope.userHistory = response.data;
},
function (response) {
// TODO
+ $log.error("Error retrieving the audit history of user " + u.id);
}
);
},
function (response) {
// TODO
+ $log.error("Error retrieving the info of user " + u.id);
}
);
diff --git a/web-ui/src/main/resources/catalog/style/gn_viewer.less b/web-ui/src/main/resources/catalog/style/gn_viewer.less
index 2ca082d6b22..e2e1deddcc9 100644
--- a/web-ui/src/main/resources/catalog/style/gn_viewer.less
+++ b/web-ui/src/main/resources/catalog/style/gn_viewer.less
@@ -308,7 +308,6 @@
}
}
.dropdown-left {
-
@toggleWidth: 32px;
@toggleHeight: 32px;
@@ -339,10 +338,7 @@
}
}
}
-
}
-
-
}
.gn-searchlayer-list {
diff --git a/web/src/main/webapp/WEB-INF/classes/org/fao/geonet/api/Messages_fre.properties b/web/src/main/webapp/WEB-INF/classes/org/fao/geonet/api/Messages_fre.properties
index b4342a19af9..cf055c76285 100644
--- a/web/src/main/webapp/WEB-INF/classes/org/fao/geonet/api/Messages_fre.properties
+++ b/web/src/main/webapp/WEB-INF/classes/org/fao/geonet/api/Messages_fre.properties
@@ -244,8 +244,8 @@ api.metadata.status.errorSetStatusNotAllowed=Seul le propri\u00E9taire des m\u00
feedback_subject_userFeedback=Commentaire de l'utilisateur
-audit.revision=Updated by %s on %s:\n\
+audit.revision=Mise \u00E0 jour par %s le %s:\n\
%s
-audit.revision.field.set=- Field '%s' set to '%s'
-audit.revision.field.unset=- Field '%s' unset
-audit.revision.field.updated=- Field '%s' changed from '%s' to '%s'
+audit.revision.field.set=- Champ '%s' d\u00E9fini \u00E0 '%s'
+audit.revision.field.unset=- Champ '%s' d\u00E9sactiv\u00E9
+audit.revision.field.updated=- Champ '%s' modifi\u00E9 de '%s' \u00E0 '%s'