Set this class as serializable 29/11429/1
authorPamela Dragosh <pdragosh@research.att.com>
Fri, 8 Sep 2017 22:03:33 +0000 (18:03 -0400)
committerPamela Dragosh <pdragosh@research.att.com>
Fri, 8 Sep 2017 22:06:02 +0000 (18:06 -0400)
Fixing sonar critical to make this simple class serializable.

Issue-ID: POLICY-115
Change-Id: I6a3cf8b1c8c27f434e26d9f2909b2ef38c72825b
Signed-off-by: Pamela Dragosh <pdragosh@research.att.com>
controlloop/common/actors/actor.mso/src/main/java/org/onap/policy/controlloop/actor/mso/MSOActorServiceProvider.java
controlloop/common/guard/src/main/java/org/onap/policy/guard/PIPEngineGetHistory.java
controlloop/common/guard/src/main/java/org/onap/policy/guard/Util.java
controlloop/common/model-impl/aai/src/main/java/org/onap/policy/aai/RelationshipItem.java

index f3c563f..653022b 100644 (file)
@@ -269,7 +269,7 @@ public class MSOActorServiceProvider implements Actor {
                        setCloudRegionItemCloudRegionId(namedQueryResponseWrapper.aainqf199response.inventoryResponseItems.get(0).items.inventoryResponseItems.get(1).items.inventoryResponseItems.get(0).cloudRegion.cloudRegionId);
                
                } catch (Exception e) {
-                       logger.error(e.getMessage());
+                       logger.error(e.getMessage(), e);
                        VirtualControlLoopNotification notification = new VirtualControlLoopNotification(onset);
                        notification.notification = ControlLoopNotificationType.REJECTED;
                        notification.message = "Exception occurred " + e.getMessage();
@@ -281,7 +281,7 @@ public class MSOActorServiceProvider implements Actor {
                                logger.debug(Serialization.gsonPretty.toJson(notification));
                        } catch (Exception e1) {
                                logger.error("Can't deliver notification: " + notification);
-                               logger.error(e1.getMessage());
+                               logger.error(e1.getMessage(), e1);
                        }
                        //
                        notification.notification = ControlLoopNotificationType.FINAL_FAILURE;
@@ -291,7 +291,7 @@ public class MSOActorServiceProvider implements Actor {
                logger.debug(Serialization.gsonPretty.toJson(notification));
             } catch (Exception e1) {
                logger.error("Can't deliver notification: " + notification);
-               logger.error(e1.getMessage());
+               logger.error(e1.getMessage(), e1);
             }  
                        // Retract everything
                        return;
index d35726a..0ec0098 100644 (file)
@@ -190,23 +190,25 @@ public class PIPEngineGetHistory extends StdConfigurableEngine{
 
                try {
                        pipResponse     = pipFinder.getMatchingAttributes(pipRequest, this);
-                       if (pipResponse != null) {
-                               if (pipResponse.getStatus() != null && !pipResponse.getStatus().isOk()) {
-                                       logger.warn("Error retrieving {}: {}", pipRequest.getAttributeId().stringValue(), pipResponse.getStatus().toString());
-                                       pipResponse     = null;
-                               }
-                               if (pipResponse.getAttributes() != null && pipResponse.getAttributes().isEmpty()) {
-                                       logger.warn("Error retrieving {}: {}", pipRequest.getAttributeId().stringValue(), pipResponse.getStatus().toString());
-                                       logger.warn("Error retrieving {}: {}", pipRequest.getAttributeId().stringValue(), pipResponse.getStatus());
-                                       pipResponse     = null;
-                               }
-                               if (pipResponse.getAttributes() != null && pipResponse.getAttributes().isEmpty()) {
-                                       logger.warn("Error retrieving {}: {}", pipRequest.getAttributeId().stringValue(), pipResponse.getStatus());
-                                       pipResponse     = null;
-                               }
-                       }
                } catch (PIPException ex) {
                        logger.error("getAttribute threw:", ex);
+                       return null;
+               }
+               if (pipResponse == null) {
+                       return null;
+               }
+               if (pipResponse.getStatus() != null && !pipResponse.getStatus().isOk()) {
+                       logger.warn("Error retrieving {}: {}", pipRequest.getAttributeId().stringValue(), pipResponse.getStatus().toString());
+                       return null;
+               }
+               if (pipResponse.getAttributes() != null && pipResponse.getAttributes().isEmpty()) {
+                       logger.warn("Error retrieving {}: {}", pipRequest.getAttributeId().stringValue(), pipResponse.getStatus().toString());
+                       logger.warn("Error retrieving {}: {}", pipRequest.getAttributeId().stringValue(), pipResponse.getStatus());
+                       return null;
+               }
+               if (pipResponse.getAttributes() != null && pipResponse.getAttributes().isEmpty()) {
+                       logger.warn("Error retrieving {}: {}", pipRequest.getAttributeId().stringValue(), pipResponse.getStatus());
+                       return null;
                }
                return pipResponse;
        }
@@ -312,6 +314,7 @@ public class PIPEngineGetHistory extends StdConfigurableEngine{
                }catch(Exception ex){
                        logger.error("PIP thread got Exception. Can't connect to Operations History DB -- {}", OpsHistPU);
                        logger.error("getCountFromDB threw: ", ex);
+                       return 0;
                }
 
                DateUtil dateUtil = new DateUtil(){
index 6018c2c..b594aff 100644 (file)
@@ -24,19 +24,17 @@ import static org.junit.Assert.fail;
 
 import java.io.File;
 import java.io.FileInputStream;
-import java.io.FileNotFoundException;
 import java.io.IOException;
 import java.io.InputStream;
 import java.nio.charset.StandardCharsets;
 
 import org.apache.commons.io.IOUtils;
-import org.yaml.snakeyaml.Yaml;
-import org.yaml.snakeyaml.constructor.Constructor;
-
 import org.onap.policy.controlloop.policy.ControlLoopPolicy;
 import org.onap.policy.controlloop.policy.guard.ControlLoopGuard;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
+import org.yaml.snakeyaml.Yaml;
+import org.yaml.snakeyaml.constructor.Constructor;
 
 public final class Util {
 
@@ -60,14 +58,11 @@ public final class Util {
                        Yaml yaml = new Yaml(new Constructor(ControlLoopPolicy.class));
                        Object obj = yaml.load(contents);
                        
-                       //String ttt = ((ControlLoopPolicy)obj).policies.getFirst().payload.get("asdas");
                        logger.debug(contents);
-                       //for(Policy policy : ((ControlLoopPolicy)obj).policies){
                        
                        return new Pair<ControlLoopPolicy, String>((ControlLoopPolicy) obj, contents);
-               } catch (FileNotFoundException e) {
-                       fail(e.getLocalizedMessage());
                } catch (IOException e) {
+                       logger.error(e.getLocalizedMessage(), e);
                        fail(e.getLocalizedMessage());
                }
                return null;
@@ -82,9 +77,8 @@ public final class Util {
                        Yaml yaml = new Yaml(new Constructor(ControlLoopGuard.class));
                        Object obj = yaml.load(contents);
                        return (ControlLoopGuard) obj;
-               } catch (FileNotFoundException e) {
-                       fail(e.getLocalizedMessage());
                } catch (IOException e) {
+                       logger.error(e.getLocalizedMessage(), e);
                        fail(e.getLocalizedMessage());
                }
                return null;
index 0cfc82e..8451998 100644 (file)
 package org.onap.policy.aai;
 
 import java.util.List;
+import java.io.Serializable;
 import java.util.LinkedList;
 
 import com.google.gson.annotations.SerializedName;
 
-public class RelationshipItem {
+public class RelationshipItem implements Serializable {
+       
+       /**
+        * 
+        */
+       private static final long serialVersionUID = 1543404460741069628L;
        
        @SerializedName("related-to-property")
        public List<RelatedToPropertyItem> relatedToProperty = new LinkedList<RelatedToPropertyItem>();