summaryrefslogtreecommitdiffstats
path: root/controlloop/common/eventmanager/src/main/java
diff options
context:
space:
mode:
authorJim Hahn <jrh3@att.com>2019-08-05 14:17:01 -0400
committerJim Hahn <jrh3@att.com>2019-08-13 09:24:52 -0400
commit9e8023a455633c7daf0dd291c6268986e39352d7 (patch)
treedc25ae63c4a042a7f16c53d8c50ebcdb4493f5cb /controlloop/common/eventmanager/src/main/java
parent177b67a70f99e0125fec7732f39c18840409f968 (diff)
Fix sonar issues in drools-applications
Addressed sonar issue, "Move constants to a class or enum.", by moving the "manager" object from the ControlLoopMetrics interface into a utility class, ControlLoopMetricsManager. Addressed sonar issue, "duplicated blocks of code must be removed.", by refactoring PolicyGuardYamlToXacml, extracing common functions. Addressed sonar issue, "Remove this unused import", in RestControlLoopManager. Addressed sonar issue, "Refactor this method to throw at most one checked exception", in event manager. Fixed likely new sonar issue with assigning to a parameter. Moved logging line to more appropriate place. Addressed reviewer comment: Use "replace" instead of "replaceAll", thus avoiding escaping Change-Id: I47db957c83c1b3e2bd2330474e261987c6f0aac6 Issue-ID: POLICY-1967 Signed-off-by: Jim Hahn <jrh3@att.com>
Diffstat (limited to 'controlloop/common/eventmanager/src/main/java')
-rw-r--r--controlloop/common/eventmanager/src/main/java/org/onap/policy/controlloop/eventmanager/ControlLoopEventManager.java3
-rw-r--r--controlloop/common/eventmanager/src/main/java/org/onap/policy/controlloop/eventmanager/ControlLoopOperationManager.java108
2 files changed, 62 insertions, 49 deletions
diff --git a/controlloop/common/eventmanager/src/main/java/org/onap/policy/controlloop/eventmanager/ControlLoopEventManager.java b/controlloop/common/eventmanager/src/main/java/org/onap/policy/controlloop/eventmanager/ControlLoopEventManager.java
index 7d42f8f76..298513619 100644
--- a/controlloop/common/eventmanager/src/main/java/org/onap/policy/controlloop/eventmanager/ControlLoopEventManager.java
+++ b/controlloop/common/eventmanager/src/main/java/org/onap/policy/controlloop/eventmanager/ControlLoopEventManager.java
@@ -399,9 +399,8 @@ public class ControlLoopEventManager implements LockCallback, Serializable {
*
* @return a ControlLoopOperationManager
* @throws ControlLoopException if an error occurs
- * @throws AaiException if an error occurs retrieving information from A&AI
*/
- public ControlLoopOperationManager processControlLoop() throws ControlLoopException, AaiException {
+ public ControlLoopOperationManager processControlLoop() throws ControlLoopException {
validateFinalControlLoop();
//
// Is there a current operation?
diff --git a/controlloop/common/eventmanager/src/main/java/org/onap/policy/controlloop/eventmanager/ControlLoopOperationManager.java b/controlloop/common/eventmanager/src/main/java/org/onap/policy/controlloop/eventmanager/ControlLoopOperationManager.java
index 006899efe..cac1b8ee3 100644
--- a/controlloop/common/eventmanager/src/main/java/org/onap/policy/controlloop/eventmanager/ControlLoopOperationManager.java
+++ b/controlloop/common/eventmanager/src/main/java/org/onap/policy/controlloop/eventmanager/ControlLoopOperationManager.java
@@ -98,33 +98,39 @@ public class ControlLoopOperationManager implements Serializable {
* @param policy the policy
* @param em the event manager
* @throws ControlLoopException if an error occurs
- * @throws AaiException if an error occurs retrieving information from A&AI
*/
public ControlLoopOperationManager(ControlLoopEvent onset, Policy policy, ControlLoopEventManager em)
- throws ControlLoopException, AaiException {
+ throws ControlLoopException {
+
this.onset = onset;
this.policy = policy;
this.guardApprovalStatus = "NONE";
this.eventManager = em;
this.targetEntity = getTarget(policy);
- //
- // Let's make a sanity check
- //
- switch (policy.getActor()) {
- case "APPC":
- initAppc(onset, policy);
- break;
- case "SO":
- break;
- case "SDNR":
- break;
- case "VFC":
- break;
- case "SDNC":
- break;
- default:
- throw new ControlLoopException("ControlLoopEventManager: policy has an unknown actor.");
+ try {
+
+ //
+ // Let's make a sanity check
+ //
+ switch (policy.getActor()) {
+ case "APPC":
+ initAppc(onset, policy);
+ break;
+ case "SO":
+ break;
+ case "SDNR":
+ break;
+ case "VFC":
+ break;
+ case "SDNC":
+ break;
+ default:
+ throw new ControlLoopException("ControlLoopEventManager: policy has an unknown actor.");
+ }
+
+ } catch (AaiException e) {
+ throw new ControlLoopException(e.getMessage(), e);
}
}
@@ -210,9 +216,8 @@ public class ControlLoopOperationManager implements Serializable {
* @param policy the policy
* @return the target
* @throws ControlLoopException if an error occurs
- * @throws AaiException if an error occurs retrieving information from A&AI
*/
- public String getTarget(Policy policy) throws ControlLoopException, AaiException {
+ public String getTarget(Policy policy) throws ControlLoopException {
if (policy.getTarget() == null) {
throw new ControlLoopException("The target is null");
}
@@ -235,7 +240,7 @@ public class ControlLoopOperationManager implements Serializable {
}
- private String getVfModuleTarget() throws AaiException, ControlLoopException {
+ private String getVfModuleTarget() throws ControlLoopException {
VirtualControlLoopEvent virtualOnsetEvent = (VirtualControlLoopEvent) this.onset;
if (this.onset.getTarget().equalsIgnoreCase(VSERVER_VSERVER_NAME)) {
return virtualOnsetEvent.getAai().get(VSERVER_VSERVER_NAME);
@@ -253,17 +258,22 @@ public class ControlLoopOperationManager implements Serializable {
* If the vnf-name was retrieved from the onset then the vnf-id must be obtained from the event
* manager's A&AI GET query
*/
- String vnfId;
- if (Boolean.valueOf(PolicyEngine.manager.getEnvironmentProperty(AAI_CUSTOM_QUERY))) {
- vnfId = this.eventManager.getCqResponse((VirtualControlLoopEvent) onset).getDefaultGenericVnf()
- .getVnfId();
- } else {
- vnfId = this.eventManager.getVnfResponse().getVnfId();
- }
- if (vnfId == null) {
- throw new AaiException("No vnf-id found");
+ try {
+ String vnfId;
+ if (Boolean.valueOf(PolicyEngine.manager.getEnvironmentProperty(AAI_CUSTOM_QUERY))) {
+ vnfId = this.eventManager.getCqResponse((VirtualControlLoopEvent) onset).getDefaultGenericVnf()
+ .getVnfId();
+ } else {
+ vnfId = this.eventManager.getVnfResponse().getVnfId();
+ }
+ if (vnfId == null) {
+ throw new AaiException("No vnf-id found");
+ }
+ return vnfId;
+
+ } catch (AaiException e) {
+ throw new ControlLoopException(e.getMessage(), e);
}
- return vnfId;
}
throw new ControlLoopException("Target does not match target type");
}
@@ -274,10 +284,9 @@ public class ControlLoopOperationManager implements Serializable {
* @param onset the onset event
* @return the operation request
* @throws ControlLoopException if an error occurs
- * @throws AaiException if error occurs
*/
public Object startOperation(/* VirtualControlLoopEvent */ControlLoopEvent onset)
- throws ControlLoopException, AaiException {
+ throws ControlLoopException {
verifyOperatonCanRun();
//
@@ -293,19 +302,24 @@ public class ControlLoopOperationManager implements Serializable {
//
// Now determine which actor we need to construct a request for
//
- switch (policy.getActor()) {
- case "APPC":
- return startAppcOperation(onset, operation);
- case "SO":
- return startSoOperation(onset, operation);
- case "VFC":
- return startVfcOperation(onset, operation);
- case "SDNR":
- return startSdnrOperation(onset, operation);
- case "SDNC":
- return startSdncOperation(onset, operation);
- default:
- throw new ControlLoopException("invalid actor " + policy.getActor() + " on policy");
+ try {
+ switch (policy.getActor()) {
+ case "APPC":
+ return startAppcOperation(onset, operation);
+ case "SO":
+ return startSoOperation(onset, operation);
+ case "VFC":
+ return startVfcOperation(onset, operation);
+ case "SDNR":
+ return startSdnrOperation(onset, operation);
+ case "SDNC":
+ return startSdncOperation(onset, operation);
+ default:
+ throw new ControlLoopException("invalid actor " + policy.getActor() + " on policy");
+ }
+
+ } catch (AaiException e) {
+ throw new ControlLoopException(e.getMessage(), e);
}
}