diff options
author | Magnusen, Drew (dm741q) <dm741q@att.com> | 2017-08-11 13:19:34 -0500 |
---|---|---|
committer | Magnusen, Drew (dm741q) <dm741q@att.com> | 2017-08-15 08:58:28 -0500 |
commit | d1077082cafafdd275aa8e210cf5f430ec11934d (patch) | |
tree | d42af9f948cb583af4be6ecc5fa661d4ac313771 /integrity-monitor/src/main/java/org/onap/policy/common/im/StateTransition.java | |
parent | 8e9b3d288bc5b51f691183715d5862489f09d95d (diff) |
Resolve major/critical issues in integrity-monitor
Resolved major and critical sonar issues in integrity-monitor
module.
Issue-ID: [POLICY-96]
Change-Id: If1da196134a73535668d42f429d647fc819ecaee
Signed-off-by: Magnusen, Drew (dm741q) <dm741q@att.com>
Diffstat (limited to 'integrity-monitor/src/main/java/org/onap/policy/common/im/StateTransition.java')
-rw-r--r-- | integrity-monitor/src/main/java/org/onap/policy/common/im/StateTransition.java | 28 |
1 files changed, 13 insertions, 15 deletions
diff --git a/integrity-monitor/src/main/java/org/onap/policy/common/im/StateTransition.java b/integrity-monitor/src/main/java/org/onap/policy/common/im/StateTransition.java index 746e0cef..a45a536b 100644 --- a/integrity-monitor/src/main/java/org/onap/policy/common/im/StateTransition.java +++ b/integrity-monitor/src/main/java/org/onap/policy/common/im/StateTransition.java @@ -22,7 +22,6 @@ package org.onap.policy.common.im; import java.util.*; -//import org.apache.log4j.Logger; import org.onap.policy.common.im.StateElement; import org.onap.policy.common.im.StateManagement; @@ -41,23 +40,22 @@ public class StateTransition { public static final String STANDBY_STATUS = "standbyStatus"; public static final String ACTOIN_NAME = "actionName"; - private HashMap<String, String> StateTable = new HashMap<String, String>(); + private HashMap<String, String> StateTable = new HashMap<>(); /** * StateTransition constructor * @throws Exception */ - public StateTransition() throws Exception + public StateTransition() throws StateTransitionException { logger.debug("StateTransition constructor"); try { logger.debug("Load StateTable started"); - setupStateTable(); // - //displayStateTable(); + setupStateTable(); } catch(Exception ex) { - throw new Exception("StateTransition Exception: " + ex.toString()); + throw new StateTransitionException("StateTransition Exception: " + ex.toString()); } } @@ -72,7 +70,7 @@ public class StateTransition { * @throws Exception */ public StateElement getEndingState(String adminState, String opState, String availStatus, - String standbyStatus, String actionName) throws Exception + String standbyStatus, String actionName) throws StateTransitionException { logger.info("getEndingState"); logger.info("adminState=[" + adminState + "], opState=[" + opState + "], availStatus=[" + @@ -84,25 +82,25 @@ public class StateTransition { standbyStatus="null"; } if(adminState==null || opState==null || actionName==null){ - throw new Exception("Exception:StateTransition unable to process state: adminState=[" + adminState + "], opState=[" + opState + "], availStatus=[" + + throw new StateTransitionException("Exception:StateTransition unable to process state: adminState=[" + adminState + "], opState=[" + opState + "], availStatus=[" + availStatus + "], standbyStatus=[" + standbyStatus + "], actionName=[" + actionName + "]"); }else if(!(adminState.equals(StateManagement.LOCKED) || adminState.equals(StateManagement.UNLOCKED))){ - throw new Exception("Exception:StateTransition unable to process state: adminState=[" + adminState + "], opState=[" + opState + "], availStatus=[" + + throw new StateTransitionException("Exception:StateTransition unable to process state: adminState=[" + adminState + "], opState=[" + opState + "], availStatus=[" + availStatus + "], standbyStatus=[" + standbyStatus + "], actionName=[" + actionName + "]"); }else if(!(opState.equals(StateManagement.ENABLED) || opState.equals(StateManagement.DISABLED))){ - throw new Exception("Exception:StateTransition unable to process state: adminState=[" + adminState + "], opState=[" + opState + "], availStatus=[" + + throw new StateTransitionException("Exception:StateTransition unable to process state: adminState=[" + adminState + "], opState=[" + opState + "], availStatus=[" + availStatus + "], standbyStatus=[" + standbyStatus + "], actionName=[" + actionName + "]"); }else if(!(standbyStatus.equals(StateManagement.NULL_VALUE) || standbyStatus.equals(StateManagement.COLD_STANDBY) || standbyStatus.equals(StateManagement.HOT_STANDBY) || standbyStatus.equals(StateManagement.PROVIDING_SERVICE))){ - throw new Exception("Exception:StateTransition unable to process state: adminState=[" + adminState + "], opState=[" + opState + "], availStatus=[" + + throw new StateTransitionException("Exception:StateTransition unable to process state: adminState=[" + adminState + "], opState=[" + opState + "], availStatus=[" + availStatus + "], standbyStatus=[" + standbyStatus + "], actionName=[" + actionName + "]"); }else if(!(availStatus.equals(StateManagement.NULL_VALUE) || availStatus.equals(StateManagement.DEPENDENCY) || availStatus.equals(StateManagement.DEPENDENCY_FAILED) || availStatus.equals(StateManagement.FAILED))){ - throw new Exception("Exception:StateTransition unable to process state: adminState=[" + adminState + "], opState=[" + opState + "], availStatus=[" + + throw new StateTransitionException("Exception:StateTransition unable to process state: adminState=[" + adminState + "], opState=[" + opState + "], availStatus=[" + availStatus + "], standbyStatus=[" + standbyStatus + "], actionName=[" + actionName + "]"); } else if(!(actionName.equals(StateManagement.DEMOTE) || @@ -113,7 +111,7 @@ public class StateTransition { actionName.equals(StateManagement.LOCK) || actionName.equals(StateManagement.PROMOTE) || actionName.equals(StateManagement.UNLOCK))){ - throw new Exception("Exception:StateTransition unable to process state: adminState=[" + adminState + "], opState=[" + opState + "], availStatus=[" + + throw new StateTransitionException("Exception:StateTransition unable to process state: adminState=[" + adminState + "], opState=[" + opState + "], availStatus=[" + availStatus + "], standbyStatus=[" + standbyStatus + "], actionName=[" + actionName + "]"); } @@ -151,10 +149,10 @@ public class StateTransition { String msg = "Ending state not found, adminState=[" + adminState + "], opState=[" + opState + "], availStatus=[" + availStatus + "], standbyStatus=[" + standbyStatus + "], actionName=[" + actionName + "]"; logger.error(msg); - throw new Exception(msg); + throw new StateTransitionException(msg); } } catch (Exception ex) { - throw new Exception("Exception: " + ex.toString() + ", adminState=[" + adminState + "], opState=[" + opState + "], availStatus=[" + + throw new StateTransitionException("Exception: " + ex.toString() + ", adminState=[" + adminState + "], opState=[" + opState + "], availStatus=[" + availStatus + "], standbyStatus=[" + standbyStatus + "], actionName=[" + actionName + "]"); } |