@@ -1051,28 +1051,64 @@ private void createOrUpdatePluginInfo(final RangerPluginInfo pluginInfo, int ent
10511051 final Runnable commitWork ;
10521052
10531053 if (httpCode == HttpServletResponse .SC_NOT_MODIFIED ) {
1054- if (!pluginActivityAuditLogNotModified ) {
1054+ RangerPluginInfo dbObj = null ;
1055+ Long pluginActivationTime = null ;
1056+ Long dbLastActivationTime = null ;
1057+
1058+ if (StringUtils .isNotBlank (pluginInfo .getServiceName ())) {
1059+ XXPluginInfo xObj = rangerDaoManager .getXXPluginInfo ().find (pluginInfo .getServiceName (), pluginInfo .getHostName (), pluginInfo .getAppType ());
1060+ if (xObj != null ) {
1061+ dbObj = pluginInfoService .populateViewObject (xObj );
1062+ }
1063+ }
1064+
1065+ // Create or update PluginInfo record after transaction is completed. If it is created in-line here
1066+ // then the TransactionManager will roll-back the changes because the HTTP return code is
1067+ // HttpServletResponse.SC_NOT_MODIFIED
1068+
1069+ switch (entityType ) {
1070+ case RangerPluginInfo .ENTITY_TYPE_POLICIES :
1071+ isTagVersionResetNeeded = rangerDaoManager .getXXService ().findAssociatedTagService (pluginInfo .getServiceName ()) == null ;
1072+
1073+ pluginActivationTime = pluginInfo .getPolicyActivationTime ();
1074+ dbLastActivationTime = dbObj != null ? dbObj .getPolicyActivationTime () : null ;
1075+ break ;
1076+ case RangerPluginInfo .ENTITY_TYPE_TAGS :
1077+ isTagVersionResetNeeded = false ;
1078+
1079+ pluginActivationTime = pluginInfo .getTagActivationTime ();
1080+ dbLastActivationTime = dbObj != null ? dbObj .getTagActivationTime () : null ;
1081+ break ;
1082+ case RangerPluginInfo .ENTITY_TYPE_ROLES :
1083+ isTagVersionResetNeeded = false ;
1084+
1085+ pluginActivationTime = pluginInfo .getRoleActivationTime ();
1086+ dbLastActivationTime = dbObj != null ? dbObj .getRoleActivationTime () : null ;
1087+ break ;
1088+ case RangerPluginInfo .ENTITY_TYPE_USERSTORE :
1089+ isTagVersionResetNeeded = false ;
1090+
1091+ pluginActivationTime = pluginInfo .getUserStoreActivationTime ();
1092+ dbLastActivationTime = dbObj != null ? dbObj .getUserStoreActivationTime () : null ;
1093+ break ;
1094+ case RangerPluginInfo .ENTITY_TYPE_GDS :
1095+ isTagVersionResetNeeded = false ;
1096+
1097+ pluginActivationTime = pluginInfo .getGdsActivationTime ();
1098+ dbLastActivationTime = dbObj != null ? dbObj .getGdsActivationTime () : null ;
1099+ break ;
1100+ default :
1101+ isTagVersionResetNeeded = false ;
1102+ break ;
1103+ }
1104+
1105+ boolean isLastActivationTimeUpdateNeeded = pluginActivationTime != null && pluginActivationTime > 0 && (dbLastActivationTime == null || !dbLastActivationTime .equals (pluginActivationTime ));
1106+
1107+ if (!pluginActivityAuditLogNotModified && !isLastActivationTimeUpdateNeeded ) {
10551108 logger .debug ("Not logging HttpServletResponse. SC_NOT_MODIFIED. To enable, set configuration: {}=true" , PROP_PLUGIN_ACTIVITY_AUDIT_NOT_MODIFIED );
10561109
10571110 commitWork = null ;
10581111 } else {
1059- // Create or update PluginInfo record after transaction is completed. If it is created in-line here
1060- // then the TransactionManager will roll-back the changes because the HTTP return code is
1061- // HttpServletResponse.SC_NOT_MODIFIED
1062-
1063- switch (entityType ) {
1064- case RangerPluginInfo .ENTITY_TYPE_POLICIES :
1065- isTagVersionResetNeeded = rangerDaoManager .getXXService ().findAssociatedTagService (pluginInfo .getServiceName ()) == null ;
1066- break ;
1067- case RangerPluginInfo .ENTITY_TYPE_TAGS :
1068- case RangerPluginInfo .ENTITY_TYPE_ROLES :
1069- case RangerPluginInfo .ENTITY_TYPE_USERSTORE :
1070- case RangerPluginInfo .ENTITY_TYPE_GDS :
1071- default :
1072- isTagVersionResetNeeded = false ;
1073- break ;
1074- }
1075-
10761112 commitWork = () -> doCreateOrUpdateXXPluginInfo (pluginInfo , entityType , isTagVersionResetNeeded , clusterName );
10771113 }
10781114 } else if (httpCode == HttpServletResponse .SC_NOT_FOUND ) {
0 commit comments