Michael Kublin has uploaded a new change for review.

Change subject: engine: Additional clean up in AuditLogDirector
......................................................................

engine: Additional clean up in AuditLogDirector

Variable auditLogable can not be null, if it null we will fail on
NullPointerException inside updateTimeoutLogableObject method.
After removing such condition, were removed all relevant and dead code.
Also, I chnaged tempVar to auditLog varibale, don't see reason for using tempVar

Change-Id: Ia0eb406d78965bb0d84c7ce80761028877ab2879
Signed-off-by: Michael Kublin <[email protected]>
---
M 
backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dal/dbbroker/auditloghandling/AuditLogDirector.java
1 file changed, 38 insertions(+), 48 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/26/13426/1

diff --git 
a/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dal/dbbroker/auditloghandling/AuditLogDirector.java
 
b/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dal/dbbroker/auditloghandling/AuditLogDirector.java
index a23fbdb..fa4b14a 100644
--- 
a/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dal/dbbroker/auditloghandling/AuditLogDirector.java
+++ 
b/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dal/dbbroker/auditloghandling/AuditLogDirector.java
@@ -798,7 +798,7 @@
     public static void log(AuditLogableBase auditLogable, AuditLogType 
logType, String loggerString) {
         updateTimeoutLogableObject(auditLogable, logType);
 
-        if (auditLogable == null || auditLogable.getLegal()) {
+        if (auditLogable.getLegal()) {
             String message = null;
             String resolvedMessage = null;
             AuditLogSeverity severity = severities.get(logType);
@@ -807,55 +807,45 @@
                 log.infoFormat("No severity for {0} audit log type, assuming 
Normal severity", logType);
             }
             AuditLog auditLog = null;
-            if (auditLogable != null) {
-                AuditLog tempVar = null;
-                // handle external log messages invoked by plugins via the API
-                if (auditLogable.isExternal()) {
-                    resolvedMessage = message = loggerString; // message is 
sent as an argument, no need to resolve.
-                    tempVar = new AuditLog(logType,
-                                    severity,
-                                    resolvedMessage,
-                                    auditLogable.getUserId(),
-                                    auditLogable.getUserName(),
-                                    auditLogable.getVmIdRef(),
-                                    auditLogable.getVmName(),
-                                    auditLogable.getVdsIdRef(),
-                                    auditLogable.getVdsName(),
-                                    auditLogable.getVmTemplateIdRef(),
-                                    auditLogable.getVmTemplateName(),
-                                    auditLogable.getOrigin(),
-                                    auditLogable.getCustomEventId(),
-                                    auditLogable.getEventFloodInSec(),
-                                    auditLogable.getCustomData());
-                }
-                else if ((message = messages.get(logType)) != null) { // 
Application log message from AuditLogMessages
-                    resolvedMessage = resolveMessage(message, auditLogable);
-                    tempVar = new AuditLog(logType, severity, resolvedMessage, 
auditLogable.getUserId(),
-                            auditLogable.getUserName(), 
auditLogable.getVmIdRef(), auditLogable.getVmName(),
-                            auditLogable.getVdsIdRef(), 
auditLogable.getVdsName(), auditLogable.getVmTemplateIdRef(),
-                            auditLogable.getVmTemplateName());
-                }
-                if (tempVar != null) {
-                    
tempVar.setstorage_domain_id(auditLogable.getStorageDomainId());
-                    
tempVar.setstorage_domain_name(auditLogable.getStorageDomainName());
-                    
tempVar.setstorage_pool_id(auditLogable.getStoragePoolId());
-                    
tempVar.setstorage_pool_name(auditLogable.getStoragePoolName());
-                    tempVar.setvds_group_id(auditLogable.getVdsGroupId());
-                    tempVar.setvds_group_name(auditLogable.getVdsGroupName());
-                    tempVar.setCorrelationId(auditLogable.getCorrelationId());
-                    tempVar.setJobId(auditLogable.getJobId());
-                    
tempVar.setGlusterVolumeId(auditLogable.getGlusterVolumeId());
-                    
tempVar.setGlusterVolumeName(auditLogable.getGlusterVolumeName());
-                    tempVar.setExternal(auditLogable.isExternal());
-                    tempVar.setQuotaId(auditLogable.getQuotaIdForLog());
-                    tempVar.setQuotaName(auditLogable.getQuotaNameForLog());
-                    auditLog = tempVar;
-                }
-            } else {
-                auditLog = new AuditLog(logType, severity, resolvedMessage, 
null, null, null, null, null, null,
-                        null, null);
+            // handle external log messages invoked by plugins via the API
+            if (auditLogable.isExternal()) {
+                resolvedMessage = message = loggerString; // message is sent 
as an argument, no need to resolve.
+                auditLog = new AuditLog(logType,
+                        severity,
+                        resolvedMessage,
+                        auditLogable.getUserId(),
+                        auditLogable.getUserName(),
+                        auditLogable.getVmIdRef(),
+                        auditLogable.getVmName(),
+                        auditLogable.getVdsIdRef(),
+                        auditLogable.getVdsName(),
+                        auditLogable.getVmTemplateIdRef(),
+                        auditLogable.getVmTemplateName(),
+                        auditLogable.getOrigin(),
+                        auditLogable.getCustomEventId(),
+                        auditLogable.getEventFloodInSec(),
+                        auditLogable.getCustomData());
+            } else if ((message = messages.get(logType)) != null) { // 
Application log message from AuditLogMessages
+                resolvedMessage = resolveMessage(message, auditLogable);
+                auditLog = new AuditLog(logType, severity, resolvedMessage, 
auditLogable.getUserId(),
+                        auditLogable.getUserName(), auditLogable.getVmIdRef(), 
auditLogable.getVmName(),
+                        auditLogable.getVdsIdRef(), auditLogable.getVdsName(), 
auditLogable.getVmTemplateIdRef(),
+                        auditLogable.getVmTemplateName());
             }
             if (auditLog != null) {
+                
auditLog.setstorage_domain_id(auditLogable.getStorageDomainId());
+                
auditLog.setstorage_domain_name(auditLogable.getStorageDomainName());
+                auditLog.setstorage_pool_id(auditLogable.getStoragePoolId());
+                
auditLog.setstorage_pool_name(auditLogable.getStoragePoolName());
+                auditLog.setvds_group_id(auditLogable.getVdsGroupId());
+                auditLog.setvds_group_name(auditLogable.getVdsGroupName());
+                auditLog.setCorrelationId(auditLogable.getCorrelationId());
+                auditLog.setJobId(auditLogable.getJobId());
+                auditLog.setGlusterVolumeId(auditLogable.getGlusterVolumeId());
+                
auditLog.setGlusterVolumeName(auditLogable.getGlusterVolumeName());
+                auditLog.setExternal(auditLogable.isExternal());
+                auditLog.setQuotaId(auditLogable.getQuotaIdForLog());
+                auditLog.setQuotaName(auditLogable.getQuotaNameForLog());
                 getDbFacadeInstance().getAuditLogDao().save(auditLog);
                 if (!"".equals(loggerString)) {
                     log.infoFormat(loggerString, resolvedMessage);


--
To view, visit http://gerrit.ovirt.org/13426
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ia0eb406d78965bb0d84c7ce80761028877ab2879
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-engine
Gerrit-Branch: master
Gerrit-Owner: Michael Kublin <[email protected]>
_______________________________________________
Engine-patches mailing list
[email protected]
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to