Fix more generic exceptions in common 17/32017/2
authorJim Hahn <jrh3@att.com>
Fri, 16 Feb 2018 23:11:21 +0000 (18:11 -0500)
committerJim Hahn <jrh3@att.com>
Fri, 16 Feb 2018 23:29:40 +0000 (18:29 -0500)
Fixed a few more generic exceptions in integrity-audit and
integrity-monitor.
Fixed license dates.

Change-Id: Ibbc21ae5f853896e0d3e416e33b5ea2a13672f62
Issue-ID: POLICY-246
Signed-off-by: Jim Hahn <jrh3@att.com>
24 files changed:
integrity-audit/src/main/java/org/onap/policy/common/ia/AuditThread.java
integrity-audit/src/main/java/org/onap/policy/common/ia/DbAudit.java
integrity-audit/src/main/java/org/onap/policy/common/ia/DbAuditException.java
integrity-audit/src/main/java/org/onap/policy/common/ia/DbDAO.java
integrity-audit/src/main/java/org/onap/policy/common/ia/DbDaoTransactionException.java
integrity-audit/src/main/java/org/onap/policy/common/ia/IntegrityAudit.java
integrity-audit/src/main/java/org/onap/policy/common/ia/IntegrityAuditPropertiesException.java
integrity-audit/src/test/java/org/onap/policy/common/ia/IntegrityAuditTestBase.java
integrity-monitor/src/main/java/org/onap/policy/common/im/AdministrativeStateException.java
integrity-monitor/src/main/java/org/onap/policy/common/im/AllSeemsWellException.java
integrity-monitor/src/main/java/org/onap/policy/common/im/ForwardProgressException.java
integrity-monitor/src/main/java/org/onap/policy/common/im/IntegrityMonitor.java
integrity-monitor/src/main/java/org/onap/policy/common/im/IntegrityMonitorException.java
integrity-monitor/src/main/java/org/onap/policy/common/im/IntegrityMonitorPropertiesException.java
integrity-monitor/src/main/java/org/onap/policy/common/im/StandbyStatusException.java
integrity-monitor/src/main/java/org/onap/policy/common/im/StateManagement.java
integrity-monitor/src/main/java/org/onap/policy/common/im/StateManagementException.java
integrity-monitor/src/main/java/org/onap/policy/common/im/StateTransition.java
integrity-monitor/src/main/java/org/onap/policy/common/im/StateTransitionException.java
integrity-monitor/src/main/java/org/onap/policy/common/im/jmx/ComponentAdmin.java
integrity-monitor/src/main/java/org/onap/policy/common/im/jmx/ComponentAdminException.java
integrity-monitor/src/main/java/org/onap/policy/common/im/jmx/ComponentAdminMBean.java
integrity-monitor/src/main/java/org/onap/policy/common/im/jmx/JmxAgentConnection.java
integrity-monitor/src/test/java/org/onap/policy/common/im/ExceptionsTest.java

index 7af8213..efa1b1d 100644 (file)
@@ -126,11 +126,11 @@ public class AuditThread extends Thread {
         * @param properties
         * @param integrityAuditPeriodSeconds
         * @param integrityAudit
-        * @throws Exception
+        * @throws IntegrityAuditException
         */
        public AuditThread(String resourceName, String persistenceUnit,
                        Properties properties, int integrityAuditPeriodSeconds, IntegrityAudit integrityAudit)
-                       throws Exception {
+                       throws IntegrityAuditException {
 
                this(resourceName, persistenceUnit, properties, TimeUnit.SECONDS.toMillis(integrityAuditPeriodSeconds),
                                integrityAudit, null);
@@ -144,12 +144,12 @@ public class AuditThread extends Thread {
         * @param integrityAuditMillis
         * @param integrityAudit
         * @param queue 
-        * @throws Exception
+        * @throws IntegrityAuditException
         */
        public AuditThread(String resourceName, String persistenceUnit,
                        Properties properties, long integrityAuditMillis, IntegrityAudit integrityAudit,
                        BlockingQueue<CountDownLatch> queue)
-                       throws Exception {
+                       throws IntegrityAuditException {
                this.resourceName = resourceName;
                this.persistenceUnit = persistenceUnit;
                this.properties = properties;
@@ -833,7 +833,7 @@ public class AuditThread extends Thread {
                return auditCompleted;
        }
 
-       private void runAudit(DbAudit dbAudit) throws Exception {
+       private void runAudit(DbAudit dbAudit) throws IntegrityAuditException {
 
                if (logger.isDebugEnabled()) {
                        logger.debug("runAudit: Entering, dbAudit=" + dbAudit
index 00b7991..6fb619e 100644 (file)
@@ -79,7 +79,7 @@ public class DbAudit {
         * @param nodeType
         * @throws Exception
         */
-       public void dbAudit(String resourceName, String persistenceUnit, String nodeType) throws Exception {
+       public void dbAudit(String resourceName, String persistenceUnit, String nodeType) throws IntegrityAuditException {
                
                if (logger.isDebugEnabled()) {
                        logger.debug("dbAudit: Entering, resourceName=" + resourceName
@@ -225,7 +225,7 @@ public class DbAudit {
                                if (logger.isDebugEnabled()) {
                                        logger.debug("dbAudit: Sleeping " + dbAuditSleepMillis + "ms");
                                }
-                               Thread.sleep(dbAuditSleepMillis);
+                               sleep();
                                if (logger.isDebugEnabled()) {
                                        logger.debug("dbAudit: Waking from sleep");
                                }
@@ -328,7 +328,7 @@ public class DbAudit {
                                if (logger.isDebugEnabled()) {
                                        logger.debug("dbAudit: Second comparison; sleeping " + dbAuditSleepMillis + "ms");
                                }
-                               Thread.sleep(dbAuditSleepMillis);
+                               sleep();
                                if (logger.isDebugEnabled()) {
                                        logger.debug("dbAudit: Second comparison; waking from sleep");
                                }
@@ -347,6 +347,20 @@ public class DbAudit {
                return; //all done
        }
 
+       /**
+        * Sleeps a bit.
+        * @throws IntegrityAuditException
+        */
+       private void sleep() throws IntegrityAuditException {
+               try {
+                       Thread.sleep(dbAuditSleepMillis);
+                       
+               } catch (InterruptedException e) {
+                       Thread.currentThread().interrupt();
+                       throw new IntegrityAuditException(e);
+               }
+       }
+
        /**
         * dbAuditSimulate simulates the DB audit
         * @param resourceName
@@ -435,19 +449,24 @@ public class DbAudit {
         * @param resourceName2
         * @param entry1
         * @param entry2
-        * @throws ClassNotFoundException
+        * @throws IntegrityAuditException
         */
        public void writeAuditDebugLog(String clazzName, String resourceName1,
-                       String resourceName2, Object entry1, Object entry2) throws ClassNotFoundException{
-               Class<?> entityClass = Class.forName(clazzName);
-               String tableName = entityClass.getAnnotation(Table.class).name();
-               String msg = "\nDB Audit Error: "
-                               + "\n    Table Name: " + tableName
-                               + "\n    Entry 1 (short prefix style): " + resourceName1 + ": " + new ReflectionToStringBuilder(entry1,ToStringStyle.SHORT_PREFIX_STYLE).toString()
-                               + "\n    Entry 2 (short prefix style): " + resourceName2 + ": " + new ReflectionToStringBuilder(entry2,ToStringStyle.SHORT_PREFIX_STYLE).toString()
-                               + "\n    Entry 1 (recursive style): " + resourceName1 + ": " + new ReflectionToStringBuilder(entry1, new RecursiveToStringStyle()).toString()
-                               + "\n    Entry 2 (recursive style): " + resourceName2 + ": " + new ReflectionToStringBuilder(entry2, new RecursiveToStringStyle()).toString();
-               logger.debug(msg);
+                       String resourceName2, Object entry1, Object entry2) throws IntegrityAuditException{
+               try {
+                       Class<?> entityClass = Class.forName(clazzName);
+                       String tableName = entityClass.getAnnotation(Table.class).name();
+                       String msg = "\nDB Audit Error: "
+                                       + "\n    Table Name: " + tableName
+                                       + "\n    Entry 1 (short prefix style): " + resourceName1 + ": " + new ReflectionToStringBuilder(entry1,ToStringStyle.SHORT_PREFIX_STYLE).toString()
+                                       + "\n    Entry 2 (short prefix style): " + resourceName2 + ": " + new ReflectionToStringBuilder(entry2,ToStringStyle.SHORT_PREFIX_STYLE).toString()
+                                       + "\n    Entry 1 (recursive style): " + resourceName1 + ": " + new ReflectionToStringBuilder(entry1, new RecursiveToStringStyle()).toString()
+                                       + "\n    Entry 2 (recursive style): " + resourceName2 + ": " + new ReflectionToStringBuilder(entry2, new RecursiveToStringStyle()).toString();
+                       logger.debug(msg);
+                       
+               } catch (ClassNotFoundException e) {
+                       throw new IntegrityAuditException(e);
+               }
                
        }
        
@@ -457,16 +476,20 @@ public class DbAudit {
         * @param resourceName1
         * @param resourceName2
         * @param keys
-        * @throws ClassNotFoundException
+        * @throws IntegrityAuditException
         */
        public void writeAuditSummaryLog(String clazzName, String resourceName1, 
-                       String resourceName2, String keys) throws ClassNotFoundException{
-               Class<?> entityClass = Class.forName(clazzName);
-               String tableName = entityClass.getAnnotation(Table.class).name();
-               String msg = " DB Audit Error: Table Name: " + tableName
-                               + ";  Mismatch between nodes: " + resourceName1 +" and " + resourceName2
-                               + ";  Mismatched entries (keys): " + keys;
-               logger.info(msg);
+                       String resourceName2, String keys) throws IntegrityAuditException{
+               try {
+                       Class<?> entityClass = Class.forName(clazzName);
+                       String tableName = entityClass.getAnnotation(Table.class).name();
+                       String msg = " DB Audit Error: Table Name: " + tableName
+                                       + ";  Mismatch between nodes: " + resourceName1 +" and " + resourceName2
+                                       + ";  Mismatched entries (keys): " + keys;
+                       logger.info(msg);
+               } catch (ClassNotFoundException e) {
+                       throw new IntegrityAuditException(e);
+               }
        }
 
        /**
index 8f00bf8..dc629c6 100644 (file)
@@ -2,7 +2,7 @@
  * ============LICENSE_START=======================================================
  * Integrity Audit
  * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
  * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -20,7 +20,7 @@
 
 package org.onap.policy.common.ia;
 
-public class DbAuditException extends Exception{
+public class DbAuditException extends IntegrityAuditException {
        private static final long serialVersionUID = 1L;
        public DbAuditException() {
                super();
index f34b24d..73beda7 100644 (file)
@@ -2,7 +2,7 @@
  * ============LICENSE_START=======================================================
  * Integrity Audit
  * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
  * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -75,9 +75,9 @@ public class DbDAO {
         * @param resourceName
         * @param persistenceUnit
         * @param properties
-        * @throws Exception
+        * @throws IntegrityAuditException
         */
-       public DbDAO(String resourceName, String persistenceUnit, Properties properties) throws Exception {
+       public DbDAO(String resourceName, String persistenceUnit, Properties properties) throws IntegrityAuditException {
                this(resourceName, persistenceUnit, properties, null);
        }
 
@@ -89,10 +89,10 @@ public class DbDAO {
         * @param properties
         * @param lastUpdateDate        may be {@code null}
         * @param altDbUrl                      may be {@code null}
-        * @throws Exception
+        * @throws IntegrityAuditException
         */
        protected DbDAO(String resourceName, String persistenceUnit, Properties properties, String altDbUrl)
-                       throws Exception {
+                       throws IntegrityAuditException {
                logger.debug("DbDAO contructor: enter");
 
                validateProperties(resourceName, persistenceUnit, properties);
index 344ea6a..7271627 100644 (file)
@@ -2,7 +2,7 @@
  * ============LICENSE_START=======================================================
  * Integrity Audit
  * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
  * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -20,7 +20,7 @@
 
 package org.onap.policy.common.ia;
 
-public class DbDaoTransactionException extends Exception{
+public class DbDaoTransactionException extends IntegrityAuditException {
        private static final long serialVersionUID = 1L;
        public DbDaoTransactionException() {
                super();
index f1dbfec..cab0861 100644 (file)
@@ -63,7 +63,7 @@ public class IntegrityAudit {
         * @param resourceName
         * @param persistenceUnit
         * @param properties
-        * @throws Exception
+        * @throws IntegrityAuditException
         */
        public IntegrityAudit(String resourceName, String persistenceUnit, Properties properties) throws IntegrityAuditException {
                
@@ -212,18 +212,18 @@ public class IntegrityAudit {
        }       
        /**
         * Starts the audit thread
-        * @throws Exception
+        * @throws IntegrityAuditException
         */
-       public void startAuditThread() throws Exception {
+       public void startAuditThread() throws IntegrityAuditException {
                startAuditThread(null);
        }
        /**
         * Starts the audit thread
         * @param queue 
         * @return {@code true} if the thread was started, {@code false} otherwise
-        * @throws Exception
+        * @throws IntegrityAuditException
         */
-       protected boolean startAuditThread(BlockingQueue<CountDownLatch> queue) throws Exception {
+       protected boolean startAuditThread(BlockingQueue<CountDownLatch> queue) throws IntegrityAuditException {
 
                logger.info("startAuditThread: Entering");
                
index 0480abf..766268b 100644 (file)
@@ -2,7 +2,7 @@
  * ============LICENSE_START=======================================================
  * Integrity Audit
  * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
  * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -20,7 +20,7 @@
 
 package org.onap.policy.common.ia;
 
-public class IntegrityAuditPropertiesException extends Exception{
+public class IntegrityAuditPropertiesException extends IntegrityAuditException {
        private static final long serialVersionUID = 1L;
        public IntegrityAuditPropertiesException() {
                super();
index 474879d..e30c563 100644 (file)
@@ -589,7 +589,7 @@ public class IntegrityAuditTestBase {
                 * with the thread.
                 */
                @Override
-               public final void startAuditThread() throws Exception {
+               public final void startAuditThread() throws IntegrityAuditException {
                        if (queue != null) {
                                // queue up a bogus latch, in case a thread is still running
                                queue.add(new CountDownLatch(1) {
@@ -606,7 +606,14 @@ public class IntegrityAuditTestBase {
                                // wait for the thread to start
                                CountDownLatch latch = new CountDownLatch(1);
                                queue.add(latch);
-                               waitLatch(latch);
+                               
+                               try {
+                                       waitLatch(latch);
+                                       
+                               } catch (InterruptedException e) {
+                                       Thread.currentThread().interrupt();
+                                       throw new IntegrityAuditException(e);
+                               }
                        }
                }
 
index 31be3ce..600d860 100644 (file)
@@ -2,7 +2,7 @@
  * ============LICENSE_START=======================================================
  * Integrity Monitor
  * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
  * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -20,7 +20,7 @@
 
 package org.onap.policy.common.im;
 
-public class AdministrativeStateException extends Exception{
+public class AdministrativeStateException extends IntegrityMonitorException {
        private static final long serialVersionUID = 1L;
        public AdministrativeStateException() {
                super();
index 5878e1d..588a4d6 100644 (file)
@@ -2,7 +2,7 @@
  * ============LICENSE_START=======================================================
  * Integrity Monitor
  * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
  * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -20,7 +20,7 @@
 
 package org.onap.policy.common.im;
 
-public class AllSeemsWellException extends Exception {
+public class AllSeemsWellException extends IntegrityMonitorException {
        
        /**
         * 
index fd545cd..5825c3a 100644 (file)
@@ -2,7 +2,7 @@
  * ============LICENSE_START=======================================================
  * Integrity Monitor
  * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
  * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -20,7 +20,7 @@
 
 package org.onap.policy.common.im;
 
-public class ForwardProgressException extends Exception{
+public class ForwardProgressException extends IntegrityMonitorException {
        private static final long serialVersionUID = 1L;
        public ForwardProgressException() {
                super();
index d272d1c..880d39f 100644 (file)
@@ -197,10 +197,10 @@ public class IntegrityMonitor {
         *            The resource name of the resource
         * @param properties
         *            a set of properties passed in from the resource
-        * @throws Exception
+        * @throws IntegrityMonitorException
         *             if any errors are encountered in the constructor
         */
-       protected IntegrityMonitor(String resourceName, Properties properties) throws Exception {
+       protected IntegrityMonitor(String resourceName, Properties properties) throws IntegrityMonitorException {
 
                this(resourceName, properties, null);
        }
@@ -218,11 +218,11 @@ public class IntegrityMonitor {
         *            a set of properties passed in from the resource
         * @param queue
         *            queue to use to control the FPManager thread, or {@code null}
-        * @throws Exception
+        * @throws IntegrityMonitorException
         *             if any errors are encountered in the constructor
         */
        protected IntegrityMonitor(String resourceName, Properties properties, BlockingQueue<CountDownLatch> queue)
-                       throws Exception {
+                       throws IntegrityMonitorException {
 
                // singleton check since this constructor can be called from a child or
                // sub-class
@@ -344,18 +344,23 @@ public class IntegrityMonitor {
                        throw e;
                }
 
-               // create instance of StateMangement class and pass emf to it
-               stateManager = new StateManagement(emf, resourceName);
-
-               /**
-                * Initialize the state and status attributes. This will maintain any
-                * Administrative state value but will set the operational state =
-                * enabled, availability status = null, standby status = null. The
-                * integrity monitor will set the operational state via the FPManager
-                * and the owning application must set the standby status by calling
-                * promote/demote on the StateManager.
-                */
-               stateManager.initializeState();
+               try {
+                       // create instance of StateMangement class and pass emf to it
+                       stateManager = new StateManagement(emf, resourceName);
+
+                       /**
+                        * Initialize the state and status attributes. This will maintain any
+                        * Administrative state value but will set the operational state =
+                        * enabled, availability status = null, standby status = null. The
+                        * integrity monitor will set the operational state via the FPManager
+                        * and the owning application must set the standby status by calling
+                        * promote/demote on the StateManager.
+                        */
+                       stateManager.initializeState();
+                       
+               } catch(StateManagementException e) {
+                       throw new IntegrityMonitorException(e);
+               }
 
                // create management bean
                try {
@@ -378,11 +383,11 @@ public class IntegrityMonitor {
         * @param properties
         *            a set of properties passed in from the resource
         * @return The new instance of IntegrityMonitor
-        * @throws Exception
+        * @throws IntegrityMonitorException
         *             if unable to create jmx url or the constructor returns an
         *             exception
         */
-       public static IntegrityMonitor getInstance(String resourceName, Properties properties) throws Exception {
+       public static IntegrityMonitor getInstance(String resourceName, Properties properties) throws IntegrityMonitorException {
                return getInstance(resourceName, properties, null);
        }
 
@@ -398,12 +403,12 @@ public class IntegrityMonitor {
         * @param queue
         *            queue to use to control the FPManager thread, or {@code null}
         * @return The new instance of IntegrityMonitor
-        * @throws Exception
+        * @throws IntegrityMonitorException
         *             if unable to create jmx url or the constructor returns an
         *             exception
         */
        protected static IntegrityMonitor getInstance(String resourceName, Properties properties,
-                       BlockingQueue<CountDownLatch> queue) throws Exception {
+                       BlockingQueue<CountDownLatch> queue) throws IntegrityMonitorException {
 
                synchronized (getInstanceLock) {
                        logger.debug("getInstance() called - resourceName= {}", resourceName);
@@ -420,7 +425,7 @@ public class IntegrityMonitor {
                }
        }
 
-       public static IntegrityMonitor getInstance() throws Exception {
+       public static IntegrityMonitor getInstance() throws IntegrityMonitorException {
                logger.debug("getInstance() called");
                if (instance == null) {
                        String msg = "No IntegrityMonitor instance exists."
@@ -524,7 +529,7 @@ public class IntegrityMonitor {
         * disabled, it will include the dependencyCheckErrorMsg which includes
         * information about any dependency (node) which has failed.
         */
-       public void evaluateSanity() throws Exception {
+       public void evaluateSanity() throws IntegrityMonitorException {
                logger.debug("evaluateSanity called ....");
                synchronized (evaluateSanityLock) {
 
@@ -1099,7 +1104,7 @@ public class IntegrityMonitor {
         *             throws admin state exception if resource is locked
         * @throws StandbyStatusException
         */
-       public void startTransaction() throws AdministrativeStateException, StandbyStatusException {
+       public void startTransaction() throws IntegrityMonitorException {
 
                synchronized (startTransactionLock) {
                        // check admin state and throw exception if locked
@@ -1225,7 +1230,7 @@ public class IntegrityMonitor {
        /**
         * Read and validate properties
         * 
-        * @throws Exception
+        * @throws IntegrityMonitorPropertiesException
         */
        private static void validateProperties(Properties prop) throws IntegrityMonitorPropertiesException {
 
index 072af23..f01be27 100644 (file)
@@ -2,7 +2,7 @@
  * ============LICENSE_START=======================================================
  * Integrity Monitor
  * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
  * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -36,4 +36,10 @@ public class IntegrityMonitorException extends Exception{
                super(message, cause);
        }
 
+       public IntegrityMonitorException(String message, Throwable cause, 
+                                       boolean enableSuppression, boolean writableStackTrace)
+       {
+               super(message, cause, enableSuppression, writableStackTrace);
+       }
+
 }
index 24a3aeb..0d73e8b 100644 (file)
@@ -2,7 +2,7 @@
  * ============LICENSE_START=======================================================
  * Integrity Monitor
  * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
  * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -20,7 +20,7 @@
 
 package org.onap.policy.common.im;
 
-public class IntegrityMonitorPropertiesException extends Exception{
+public class IntegrityMonitorPropertiesException extends IntegrityMonitorException {
        private static final long serialVersionUID = 1L;
        public IntegrityMonitorPropertiesException() {
                super();
index b871c9f..3d27a4c 100644 (file)
@@ -2,7 +2,7 @@
  * ============LICENSE_START=======================================================
  * Integrity Monitor
  * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
  * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -20,7 +20,7 @@
 
 package org.onap.policy.common.im;
 
-public class StandbyStatusException extends Exception {
+public class StandbyStatusException extends IntegrityMonitorException {
        /**
         * 
         */
index ccc12d4..1d899de 100644 (file)
@@ -2,7 +2,7 @@
  * ============LICENSE_START=======================================================
  * Integrity Monitor
  * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
  * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -96,7 +96,7 @@ public class StateManagement extends Observable {
    * StateManagement constructor
    * @param entityManagerFactory
    * @param resourceName
-   * @throws Exception
+   * @throws StateManagementException
    */
   public StateManagement(EntityManagerFactory entityManagerFactory, String resourceName) throws StateManagementException
   {
@@ -191,7 +191,7 @@ public class StateManagement extends Observable {
   
   /**
    * lock() changes the administrative state to locked.
-   * @throws Exception
+   * @throws StateManagementException
    */
   public void lock() throws StateManagementException
   {
@@ -237,7 +237,7 @@ public class StateManagement extends Observable {
   
   /**
    * unlock() changes the administrative state to unlocked.
-   * @throws Exception
+   * @throws StateManagementException
    */
   public void unlock() throws StateManagementException
   {
@@ -283,7 +283,7 @@ public class StateManagement extends Observable {
   /**
    * enableNotFailed() removes the "failed" availability status and changes the operational
    * state to enabled if no dependency is also failed.
-   * @throws Exception
+   * @throws StateManagementException
    */
   public void enableNotFailed() throws StateManagementException
   {
@@ -329,7 +329,7 @@ public class StateManagement extends Observable {
   
   /**
    * disableFailed() changes the operational state to disabled and adds availability status of "failed"
-   * @throws Exception
+   * @throws StateManagementException
    */
   public void disableFailed() throws StateManagementException
   {
@@ -374,7 +374,7 @@ public class StateManagement extends Observable {
   /**
    * This version of disableFailed is to be used to manipulate the state of a remote resource in the event
    * that remote resource has failed but its state is still showing that it is viable.
-   * @throws Exception
+   * @throws StateManagementException
    */
   public void disableFailed(String otherResourceName) throws StateManagementException
   {
@@ -426,7 +426,7 @@ public class StateManagement extends Observable {
 
   /**
    * disableDependency() changes operational state to disabled and adds availability status of "dependency"
-   * @throws Exception
+   * @throws StateManagementException
    */
   public void disableDependency() throws StateManagementException
   {
@@ -472,7 +472,7 @@ public class StateManagement extends Observable {
   /**
    * enableNoDependency() removes the availability status of "dependency " and will change the 
    * operational state to enabled if not otherwise failed.
-   * @throws Exception
+   * @throws StateManagementException
    */
   public void enableNoDependency() throws StateManagementException
   {
@@ -518,9 +518,9 @@ public class StateManagement extends Observable {
   /**
    * promote() changes the standby status to providingservice if not otherwise failed.
    * @throws StandbyStatusException
-   * @throws Exception
+   * @throws StateManagementException
    */
-  public void promote() throws StandbyStatusException, StateManagementException
+  public void promote() throws IntegrityMonitorException
   {
          synchronized (SYNCLOCK){
                  if(logger.isDebugEnabled()){
@@ -570,7 +570,7 @@ public class StateManagement extends Observable {
 
   /**
    * demote() changes standbystatus to hotstandby or, if failed, coldstandby
-   * @throws Exception
+   * @throws StateManagementException
    */
   public void demote() throws StateManagementException
   {
@@ -620,7 +620,7 @@ public class StateManagement extends Observable {
    * this is observed by PDP-D DroolsPdpsElectionHandler when it is trying to determine which PDP-D should
    * be designated as the lead.
    * @param otherResourceName
-   * @throws Exception
+   * @throws StateManagementException
    */
   public void demote(String otherResourceName) throws StateManagementException
   {
index 7591c1a..0a375b0 100644 (file)
@@ -2,7 +2,7 @@
  * ============LICENSE_START=======================================================
  * Integrity Monitor
  * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
  * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -20,7 +20,7 @@
 
 package org.onap.policy.common.im;
 
-public class StateManagementException extends Exception{
+public class StateManagementException extends IntegrityMonitorException {
        private static final long serialVersionUID = 1L;
        public StateManagementException() {
                super();
index a7f2d0e..99c092d 100644 (file)
@@ -2,7 +2,7 @@
  * ============LICENSE_START=======================================================
  * Integrity Monitor
  * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
  * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -44,7 +44,7 @@ public class StateTransition {
     
   /**
    * StateTransition constructor
-   * @throws Exception
+   * @throws StateTransitionException
    */
   public StateTransition() throws StateTransitionException
   {
@@ -72,7 +72,7 @@ public class StateTransition {
    * @param standbyStatus
    * @param actionName
    * @return
-   * @throws Exception
+   * @throws StateTransitionException
    */
   public StateElement getEndingState(String adminState, String opState, String availStatus, 
                  String standbyStatus, String actionName) throws StateTransitionException
index 3945ddc..7499842 100644 (file)
@@ -2,7 +2,7 @@
  * ============LICENSE_START=======================================================
  * Integrity Monitor
  * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
  * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -20,7 +20,7 @@
 
 package org.onap.policy.common.im;
 
-public class StateTransitionException extends Exception{
+public class StateTransitionException extends IntegrityMonitorException {
        private static final long serialVersionUID = 1L;
        public StateTransitionException() {
                super();
index a18b143..eb1d9f8 100644 (file)
@@ -2,7 +2,7 @@
  * ============LICENSE_START=======================================================
  * Integrity Monitor
  * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
  * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -36,6 +36,7 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 import org.onap.policy.common.im.IntegrityMonitor;
+import org.onap.policy.common.im.IntegrityMonitorException;
 import org.onap.policy.common.im.StateManagement;
 
 /**
@@ -187,7 +188,7 @@ public class ComponentAdmin implements ComponentAdminMBean {
        }
 
        @Override
-       public void test() throws Exception {
+       public void test() throws IntegrityMonitorException {
                // Call evaluateSanity on IntegrityMonitor to run the test
                logger.debug("test() called...");
                if (integrityMonitor != null) {
@@ -201,7 +202,7 @@ public class ComponentAdmin implements ComponentAdminMBean {
        }
 
        @Override
-       public void lock() throws Exception {
+       public void lock() throws IntegrityMonitorException {
                logger.debug("lock() called...");
                if (stateManager != null) {
                        stateManager.lock();
@@ -213,7 +214,7 @@ public class ComponentAdmin implements ComponentAdminMBean {
        }
 
        @Override
-       public void unlock() throws Exception {
+       public void unlock() throws IntegrityMonitorException {
                logger.debug("unlock() called...");
                if (stateManager != null) {
                        stateManager.unlock();
index e98288e..5ada6da 100644 (file)
@@ -20,7 +20,9 @@
 
 package org.onap.policy.common.im.jmx;
 
-public class ComponentAdminException extends Exception {
+import org.onap.policy.common.im.IntegrityMonitorException;
+
+public class ComponentAdminException extends IntegrityMonitorException {
        private static final long serialVersionUID = 1L;
 
        public ComponentAdminException() {
index d61add5..2c01193 100644 (file)
@@ -2,7 +2,7 @@
  * ============LICENSE_START=======================================================
  * Integrity Monitor
  * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
  * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -20,6 +20,8 @@
 
 package org.onap.policy.common.im.jmx;
 
+import org.onap.policy.common.im.IntegrityMonitorException;
+
 /**
  * Provides operations to test health, lock and unlock components.
  */
@@ -27,24 +29,24 @@ public interface ComponentAdminMBean {
        /**
         * Test health of component.
         * 
-        * @throws Exception
+        * @throws IntegrityMonitorException
         *            if the component fails the health check
         */
-       void test() throws Exception;
+       void test() throws IntegrityMonitorException;
 
        /**
         * Administratively lock component.
         * 
-        * @throws Exception
+        * @throws IntegrityMonitorException
         *            if the component lock fails
         */
-       void lock() throws Exception;
+       void lock() throws IntegrityMonitorException;
        
        /**
         * Administratively unlock component.
         * 
-        * @throws Exception
+        * @throws IntegrityMonitorException
         *            if the component unlock fails
         */
-       void unlock() throws Exception;
+       void unlock() throws IntegrityMonitorException;
 }
index d15fc5e..c9a2ce8 100644 (file)
@@ -2,7 +2,7 @@
  * ============LICENSE_START=======================================================
  * Integrity Monitor
  * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
  * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -35,6 +35,7 @@ import javax.management.remote.JMXConnector;
 import javax.management.remote.JMXConnectorFactory;
 import javax.management.remote.JMXServiceURL;
 
+import org.onap.policy.common.im.IntegrityMonitorException;
 import org.onap.policy.common.logging.flexlogger.FlexLogger;
 import org.onap.policy.common.logging.flexlogger.Logger;
 
@@ -86,35 +87,41 @@ public final class JmxAgentConnection {
        /**
         * Get a connection to the jmxAgent MBeanServer.
         * @return the connection
-        * @throws Exception on error
+        * @throws IntegrityMonitorException on error
         */
-       public MBeanServerConnection getMBeanConnection() throws Exception {
-               JMXServiceURL url;
-               if (jmxUrl == null) {
-                       url = new JMXServiceURL(jmxAgentUrl(host, port));
-               }
-               else {
-                       url = new JMXServiceURL(jmxUrl);
-               }
-               Map<String, Object> env = new HashMap<>();
-               
-               connector = JMXConnectorFactory.newJMXConnector(url, env);
-               connector.connect();
-               connector.addConnectionNotificationListener(
-                               new NotificationListener() {
+       public MBeanServerConnection getMBeanConnection() throws IntegrityMonitorException {
 
-                                       @Override
-                                       public void handleNotification(
-                                                       Notification notification, Object handback) {
-                                               if (notification.getType().equals(
-                                                               JMXConnectionNotification.FAILED)) {
-                                                       // handle disconnect
-                                                       disconnect();
-                                               }
-                                       }
-                               }, null, null);
+               try {
+                       JMXServiceURL url;
+                       if (jmxUrl == null) {
+                               url = new JMXServiceURL(jmxAgentUrl(host, port));
+                       }
+                       else {
+                               url = new JMXServiceURL(jmxUrl);
+                       }
+                       Map<String, Object> env = new HashMap<>();
+                       
+                       connector = JMXConnectorFactory.newJMXConnector(url, env);
+                       connector.connect();
+                       connector.addConnectionNotificationListener(
+                                       new NotificationListener() {
 
-               return connector.getMBeanServerConnection();
+                                               @Override
+                                               public void handleNotification(
+                                                               Notification notification, Object handback) {
+                                                       if (notification.getType().equals(
+                                                                       JMXConnectionNotification.FAILED)) {
+                                                               // handle disconnect
+                                                               disconnect();
+                                                       }
+                                               }
+                                       }, null, null);
+                       
+                       return connector.getMBeanServerConnection();
+                       
+               } catch (IOException e) {
+                       throw new IntegrityMonitorException(e);
+               }
        }
        
        /**
index 5066f9d..90de7c6 100644 (file)
@@ -61,7 +61,7 @@ public class ExceptionsTest extends ExceptionsTester {
 
        @Test
        public void testIntegrityMonitorException() throws Exception {
-               assertEquals(4, test(IntegrityMonitorException.class));
+               assertEquals(5, test(IntegrityMonitorException.class));
        }
 
        @Test