From 0acdb1471fc36039a721f6d1a66b55859ec922de Mon Sep 17 00:00:00 2001 From: Bogumil Zebek Date: Thu, 5 Jul 2018 14:15:44 +0200 Subject: Fix sonar violations Change-Id: I0f2b7f58cb2176a017c0adf0bacdea2252d8026b Issue-ID: AAI-1364 Signed-off-by: Bogumil Zebek --- src/main/java/org/onap/crud/event/GraphEvent.java | 23 +++++++++++++++++++--- .../org/onap/crud/service/AaiResourceService.java | 6 +++--- 2 files changed, 23 insertions(+), 6 deletions(-) (limited to 'src/main/java') diff --git a/src/main/java/org/onap/crud/event/GraphEvent.java b/src/main/java/org/onap/crud/event/GraphEvent.java index 958c227..b189373 100644 --- a/src/main/java/org/onap/crud/event/GraphEvent.java +++ b/src/main/java/org/onap/crud/event/GraphEvent.java @@ -172,11 +172,28 @@ public class GraphEvent { public String toString() { return toJson(); } - + + @Override + public boolean equals(Object o){ + if(o == this){ + return true; + } + + if( !(o instanceof GraphEvent)){ + return false; + } + + GraphEvent graphEvent = (GraphEvent) o; + return this.dbTransactionId.equals( + graphEvent.getDbTransactionId()) + && this.timestamp == graphEvent.getTimestamp() + && this.operation.equals(graphEvent.getOperation() + ); + } + @Override public int hashCode() { - return Objects.hash(this.dbTransactionId, this.timestamp, this.edge, this.vertex, this.operation, - this.result); + return Objects.hash(this.dbTransactionId, this.timestamp, this.operation); } public String getObjectKey() { diff --git a/src/main/java/org/onap/crud/service/AaiResourceService.java b/src/main/java/org/onap/crud/service/AaiResourceService.java index afabe7e..63b9e4a 100644 --- a/src/main/java/org/onap/crud/service/AaiResourceService.java +++ b/src/main/java/org/onap/crud/service/AaiResourceService.java @@ -22,6 +22,7 @@ package org.onap.crud.service; import java.security.cert.X509Certificate; import java.util.AbstractMap; +import java.util.Arrays; import java.util.HashSet; import java.util.Map; import java.util.Map.Entry; @@ -505,7 +506,7 @@ public class AaiResourceService { authUser = subjectDn.toString(); } - return this.auth.validateRequest(authUser.toLowerCase(), action.toString() + ":" + authPolicyFunctionName); + return this.auth.validateRequest(authUser!=null ? authUser.toLowerCase():"", action.toString() + ":" + authPolicyFunctionName); } catch (Exception e) { logResult(action, uri, e); @@ -517,8 +518,7 @@ public class AaiResourceService { logger.error(CrudServiceMsgs.EXCEPTION_DURING_METHOD_CALL, op.toString(), - uri, - e.getStackTrace().toString()); + uri, Arrays.toString(e.getStackTrace())); // Clear the MDC context so that no other transaction inadvertently // uses our transaction id. -- cgit 1.2.3-korg