summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSudarshan Kumar <sudarshan.kumar@att.com>2020-10-14 15:30:16 +0530
committerSudarshan Kumar <sudarshan.kumar@att.com>2020-10-14 15:32:23 +0530
commit9a58d8972ee93ea52a07b92330c3b437c2f09b8a (patch)
tree036abd28a6184efe6b92627dd9e318071e7547bd
parent1d0a5a4a3645271b72a685e4fe8ca33021cefee6 (diff)
Deleted User Role Mapping
Delete User Role Mapping in Portal DB if the same role is already deleted from AAF Issue-ID: PORTAL-1029 Change-Id: I2b15c1ce49a9a65160abb1f502590490c88b7256 Signed-off-by: Sudarshan Kumar <sudarshan.kumar@att.com>
-rw-r--r--ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/service/ExternalAccessRolesServiceImpl.java24
1 files changed, 24 insertions, 0 deletions
diff --git a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/service/ExternalAccessRolesServiceImpl.java b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/service/ExternalAccessRolesServiceImpl.java
index ad06dd96..acc83516 100644
--- a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/service/ExternalAccessRolesServiceImpl.java
+++ b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/service/ExternalAccessRolesServiceImpl.java
@@ -2812,6 +2812,11 @@ public class ExternalAccessRolesServiceImpl implements ExternalAccessRolesServic
EPRole updateRoleInactive = roleList.get(0);
updateRoleInactive.setActive(false);
dataAccessService.saveDomainObject(updateRoleInactive, null);
+
+ /**
+ * Newly Added - Deleting User Role association as this role is not present in AAF and got removed from AAF directly
+ */
+ deleteUserRoleAssociation(updateRoleInactive, app);
}
}
} catch (Exception e) {
@@ -2820,6 +2825,25 @@ public class ExternalAccessRolesServiceImpl implements ExternalAccessRolesServic
}
}
}
+
+ /**
+ * Delete User Role Association mapping in Portal DB - In case of particular role is already removed from AAF directly.
+ * @param epRole
+ */
+ private void deleteUserRoleAssociation(EPRole epRole, EPApp app) {
+ Session localSession = sessionFactory.openSession();
+ Query query = null;
+ try {
+ String sql = "DELETE FROM FN_USER_ROLE where role_id=" +epRole.getId() + " AND app_id=" +app.getId();
+ logger.debug(EELFLoggerDelegate.debugLogger,"deleteUserRoleAssociation: sql :"+ sql);
+ query = localSession.createSQLQuery(sql);
+ query.executeUpdate();
+ } catch (Exception e) {
+ logger.error(EELFLoggerDelegate.errorLogger, "deleteUserRoleAssociation: failed", e);
+ } finally {
+ localSession.close();
+ }
+ }
@Override
@SuppressWarnings("unchecked")