From 7c7906c9fe7518d8cb1ef50efc1967094a9fe55a Mon Sep 17 00:00:00 2001 From: YuriyZ Date: Mon, 27 Sep 2021 11:15:45 +0300 Subject: [PATCH] feat: added more logs to add user method --- .../oxauth/service/common/UserService.java | 45 +++++++++++-------- 1 file changed, 26 insertions(+), 19 deletions(-) diff --git a/common/src/main/java/org/gluu/oxauth/service/common/UserService.java b/common/src/main/java/org/gluu/oxauth/service/common/UserService.java index 555cb6f9e3..9311db663d 100644 --- a/common/src/main/java/org/gluu/oxauth/service/common/UserService.java +++ b/common/src/main/java/org/gluu/oxauth/service/common/UserService.java @@ -150,33 +150,40 @@ public User addDefaultUser(String uid) { } public User addUser(User user, boolean active) { - String peopleBaseDN = getPeopleBaseDn(); + try { + String peopleBaseDN = getPeopleBaseDn(); - String inum = inumService.generatePeopleInum(); + String inum = inumService.generatePeopleInum(); - user.setDn("inum=" + inum + "," + peopleBaseDN); - user.setAttribute("inum", inum, false); + user.setDn("inum=" + inum + "," + peopleBaseDN); + user.setAttribute("inum", inum, false); - GluuStatus status = active ? GluuStatus.ACTIVE : GluuStatus.REGISTER; - user.setAttribute("gluuStatus", status.getValue(), false); + GluuStatus status = active ? GluuStatus.ACTIVE : GluuStatus.REGISTER; + user.setAttribute("gluuStatus", status.getValue(), false); - List personCustomObjectClassList = getPersonCustomObjectClassList(); - if ((personCustomObjectClassList != null) && !personCustomObjectClassList.isEmpty()) { - Set allObjectClasses = new HashSet<>(); - allObjectClasses.addAll(personCustomObjectClassList); + List personCustomObjectClassList = getPersonCustomObjectClassList(); + if ((personCustomObjectClassList != null) && !personCustomObjectClassList.isEmpty()) { + Set allObjectClasses = new HashSet<>(); + allObjectClasses.addAll(personCustomObjectClassList); - String currentObjectClasses[] = user.getCustomObjectClasses(); - if (ArrayHelper.isNotEmpty(currentObjectClasses)) { - allObjectClasses.addAll(Arrays.asList(currentObjectClasses)); - } + String currentObjectClasses[] = user.getCustomObjectClasses(); + if (ArrayHelper.isNotEmpty(currentObjectClasses)) { + allObjectClasses.addAll(Arrays.asList(currentObjectClasses)); + } - user.setCustomObjectClasses(allObjectClasses.toArray(new String[allObjectClasses.size()])); - } + user.setCustomObjectClasses(allObjectClasses.toArray(new String[allObjectClasses.size()])); + } - user.setCreatedAt(new Date()); - persistenceEntryManager.persist(user); + user.setCreatedAt(new Date()); + persistenceEntryManager.persist(user); + + return getUserByDn(user.getDn()); + } catch (Exception e) { + if (log.isErrorEnabled()) + log.error("Failed to add user entry. " + e.getMessage(), e); + throw e; + } - return getUserByDn(user.getDn()); } public User getUserByAttribute(String attributeName, Object attributeValue) {