Most of these are minor issues along with a few others.
They have been bugging me so I thought I would get them
done. Some also do not show up on sonarlint.
Issue-ID: POLICY-1129
Change-Id: I31f2765f6babdfa80b23f0589daacc98da8d2002
Signed-off-by: Pamela Dragosh <pdragosh@research.att.com>
private static final String GENERIC_VNF_VNF_NAME = "generic-vnf.vnf-name";
private static final String GENERIC_VNF_VNF_ID = "generic-vnf.vnf-id";
- @Override
- public String toString() {
- return "ControlLoopOperationManager [onset=" + (onset != null ? onset.getRequestId() : "null") + ", policy="
- + (policy != null ? policy.getId() : "null") + ", attempts=" + attempts + ", policyResult="
- + policyResult + ", currentOperation=" + currentOperation + ", operationHistory=" + operationHistory
- + "]";
- }
-
//
// These properties are not changeable, but accessible
// for Drools Rule statements.
private PolicyResult policyResult = null;
private ControlLoopEventManager eventManager = null;
private String targetEntity;
+ private String guardApprovalStatus = "NONE";// "NONE", "PERMIT", "DENY"
+ private transient Object operationRequest;
+
+ /**
+ * Construct an instance.
+ *
+ * @param onset the onset event
+ * @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 {
+ 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":
+ if ("ModifyConfig".equalsIgnoreCase(policy.getRecipe())) {
+ /*
+ * The target vnf-id may not be the same as the source vnf-id specified in the
+ * yaml, the target vnf-id is retrieved by a named query to A&AI.
+ */
+ String targetVnf = AppcLcmActorServiceProvider.vnfNamedQuery(policy.getTarget().getResourceID(),
+ this.targetEntity);
+ this.targetEntity = targetVnf;
+ }
+ break;
+ case "SO":
+ break;
+ case "SDNR":
+ break;
+ case "VFC":
+ break;
+ default:
+ throw new ControlLoopException("ControlLoopEventManager: policy has an unknown actor.");
+ }
+ }
public ControlLoopEventManager getEventManager() {
return eventManager;
return this.targetEntity;
}
+ @Override
+ public String toString() {
+ return "ControlLoopOperationManager [onset=" + (onset != null ? onset.getRequestId() : "null") + ", policy="
+ + (policy != null ? policy.getId() : "null") + ", attempts=" + attempts + ", policyResult="
+ + policyResult + ", currentOperation=" + currentOperation + ", operationHistory=" + operationHistory
+ + "]";
+ }
+
//
// Internal class used for tracking
//
}
}
- private String guardApprovalStatus = "NONE";// "NONE", "PERMIT", "DENY"
- private transient Object operationRequest;
-
public Object getOperationRequest() {
return operationRequest;
}
}
}
- /**
- * Construct an instance.
- *
- * @param onset the onset event
- * @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 {
- 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":
- if ("ModifyConfig".equalsIgnoreCase(policy.getRecipe())) {
- /*
- * The target vnf-id may not be the same as the source vnf-id specified in the
- * yaml, the target vnf-id is retrieved by a named query to A&AI.
- */
- String targetVnf = AppcLcmActorServiceProvider.vnfNamedQuery(policy.getTarget().getResourceID(),
- this.targetEntity);
- this.targetEntity = targetVnf;
- }
- break;
- case "SO":
- break;
- case "SDNR":
- break;
- case "VFC":
- break;
- default:
- throw new ControlLoopException("ControlLoopEventManager: policy has an unknown actor.");
- }
- }
-
/**
* Start an operation.
*
* @return The result of the response handling
*/
private PolicyResult onResponse(VFCResponse vfcResponse) {
- if (vfcResponse.getResponseDescriptor().getStatus().equalsIgnoreCase("finished")) {
+ if ("finished".equalsIgnoreCase(vfcResponse.getResponseDescriptor().getStatus())) {
//
// Consider it as success
//
throw new ControlLoopException("current oepration has failed after " + this.attempts + " retries");
}
}
-
- return;
}
private boolean isRetriesMaxedOut() {
String opsHistPu = System.getProperty("OperationsHistoryPU");
- if (opsHistPu == null || !opsHistPu.equals("TestOperationsHistoryPU")) {
+ if (!"TestOperationsHistoryPU".equals(opsHistPu)) {
opsHistPu = "OperationsHistoryPU";
} else {
props.clear();
* @param outcome the abatement outcome
*/
public void commitAbatement(String message, String outcome) {
- logger.info("commitAbatement: " + message + ", " + outcome);
+ logger.info("commitAbatement: {}. {}", message, outcome);
if (this.currentOperation == null) {
try {
}
protected void evicted(VirtualControlLoopNotification notification) {
- // transaction(notification, ZonedDateTime.now());
- MDCTransaction trans = MDCTransaction
+ MDCTransaction
.newTransaction(notification.getRequestId().toString(), notification.getFrom())
.setServiceName(notification.getClosedLoopControlName()).setTargetEntity(notification.getTarget())
.setStartTime(notification.getNotificationTime().toInstant()).setEndTime(Instant.now())
default:
/* unexpected */
logger.warn("unexpected notification type {} in notification {}",
- notification.getNotification().toString(), notification);
+ notification.getNotification(), notification);
break;
}
@Override
public String toString() {
- final StringBuffer sb = new StringBuffer("CacheBasedControlLoopMetricsManager{");
+ final StringBuilder sb = new StringBuilder();
+ sb.append("CacheBasedControlLoopMetricsManager{");
sb.append("cacheSize=").append(cacheSize);
sb.append(", transactionTimeout=").append(transactionTimeout);
sb.append('}');
//
// Create an artificial Guard response in case we didn't get a clear Permit or Deny
//
- if (guardResponse.getResult().equals("Indeterminate")) {
+ if ("Indeterminate".equals(guardResponse.getResult())) {
guardResponse.setOperation(recipe);
guardResponse.setRequestID(UUID.fromString(requestId));
}
// Notice, we are checking here for the base issuer prefix.
if (!string.contains(this.getIssuer())) {
logger.debug("Requested issuer '{}' does not match {}", string, getIssuer());
- logger.debug("FeqLimiter PIP - Issuer {} does not match with: ", string, this.getIssuer());
+ logger.debug("FeqLimiter PIP - Issuer {} does not match with: {}", string, this.getIssuer());
return StdPIPResponse.PIP_RESPONSE_EMPTY;
}
}
if (pipResponse.getStatus() != null && !pipResponse.getStatus().isOk()) {
if (logger.isWarnEnabled()) {
logger.warn("PIP response error {}: {}", pipRequest.getAttributeId().stringValue(),
- pipResponse.getStatus().toString());
+ pipResponse.getStatus());
}
return null;
}
if (pipResponse.getAttributes() != null && pipResponse.getAttributes().isEmpty()) {
if (logger.isWarnEnabled()) {
logger.warn("No attributes in POP response {}: {}", pipRequest.getAttributeId().stringValue(),
- pipResponse.getStatus().toString());
+ pipResponse.getStatus());
}
return null;
}
EntityManager em = null;
String opsHistPu = System.getProperty("OperationsHistoryPU");
- if (opsHistPu == null || !opsHistPu.equals("TestOperationsHistoryPU")) {
+ if (!"TestOperationsHistoryPU".equals(opsHistPu)) {
opsHistPu = "OperationsHistoryPU";
} else {
props.clear();
try {
diff = now - getMsFromTimeWindow(timeWindow);
} catch (Exception ex) {
- logger.error("PIP thread got Exception " + ex);
+ logger.error("PIP thread got Exception ", ex);
return -1;
}
* ============LICENSE_START=======================================================
* guard
* ================================================================================
- * 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.
import org.yaml.snakeyaml.constructor.Constructor;
public final class Util {
- private Util() {
- // This static class cannot be instantiated
- }
-
/*
* Keys for guard properties
*/
}
}
+ private Util() {
+ // This static class cannot be instantiated
+ }
+
/**
* Load a Yaml file.
*
* Walk the items looking for VF modules, allocating the list only when an item is
* found.
*/
- List<AaiNqInventoryResponseItem> vfModuleItems = new ArrayList<>(itemList.size());;
+ List<AaiNqInventoryResponseItem> vfModuleItems = new ArrayList<>(itemList.size());
for (AaiNqInventoryResponseItem inventoryResponseItem : itemList) {
AaiNqVfModule vfmod = inventoryResponseItem.getVfModule();
* ============LICENSE_START=======================================================
* aai
* ================================================================================
- * 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.
public final class Serialization {
- private Serialization() {}
-
public static final Gson gsonPretty = new GsonBuilder().disableHtmlEscaping().setPrettyPrinting()
- // .registerTypeAdapter(AAIQueryParameters.class, new notificationTypeAdapter())
.create();
+
+ private Serialization() {}
+
}
public final class Serialization {
public static final DateTimeFormatter format = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss.SSSSSSxxx");
+ public static final Gson gsonPretty = new GsonBuilder().disableHtmlEscaping().setPrettyPrinting()
+ .registerTypeAdapter(ZonedDateTime.class, new GsonUtcAdapter())
+ .registerTypeAdapter(Instant.class, new GsonInstantAdapter())
+ // .registerTypeAdapter(CommonHeader1607.class, new gsonCommonHeaderInstance())
+ // .registerTypeAdapter(ResponseStatus1607.class, new gsonResponseStatus())
+ .create();
+
private Serialization() {}
public static class GsonUtcAdapter implements JsonSerializer<ZonedDateTime>, JsonDeserializer<ZonedDateTime> {
}
- public static final Gson gsonPretty = new GsonBuilder().disableHtmlEscaping().setPrettyPrinting()
- .registerTypeAdapter(ZonedDateTime.class, new GsonUtcAdapter())
- .registerTypeAdapter(Instant.class, new GsonInstantAdapter())
- // .registerTypeAdapter(CommonHeader1607.class, new gsonCommonHeaderInstance())
- // .registerTypeAdapter(ResponseStatus1607.class, new gsonResponseStatus())
- .create();
-
}
* ============LICENSE_START=======================================================
* appc
* ================================================================================
- * 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.
import org.onap.policy.appclcm.LcmResponse;
public final class Serialization {
+ public static final Gson gsonPretty = new GsonBuilder().disableHtmlEscaping().setPrettyPrinting()
+ .registerTypeAdapter(Instant.class, new InstantAdapter()).create();
+
+ public static final Gson gson = new GsonBuilder().disableHtmlEscaping().setPrettyPrinting()
+ .registerTypeAdapter(LcmRequest.class, new RequestAdapter())
+ .registerTypeAdapter(LcmResponse.class, new ResponseAdapter()).create();
+
+ public static final Gson gsonJunit = new GsonBuilder().disableHtmlEscaping().setPrettyPrinting()
+ .registerTypeAdapter(Instant.class, new InstantJunitAdapter()).create();
+
private Serialization() {}
public static class RequestAdapter implements JsonSerializer<LcmRequest>, JsonDeserializer<LcmRequest> {
}
- public static final Gson gsonPretty = new GsonBuilder().disableHtmlEscaping().setPrettyPrinting()
- .registerTypeAdapter(Instant.class, new InstantAdapter()).create();
-
- public static final Gson gson = new GsonBuilder().disableHtmlEscaping().setPrettyPrinting()
- .registerTypeAdapter(LcmRequest.class, new RequestAdapter())
- .registerTypeAdapter(LcmResponse.class, new ResponseAdapter()).create();
-
- public static final Gson gsonJunit = new GsonBuilder().disableHtmlEscaping().setPrettyPrinting()
- .registerTypeAdapter(Instant.class, new InstantJunitAdapter()).create();
-
}
*/
public PhysicalControlLoopEvent(PhysicalControlLoopEvent event) {
super(event);
- if (event == null) {
- return;
- }
}
}
*/
public PhysicalControlLoopNotification(PhysicalControlLoopEvent event) {
super(event);
- if (event == null) {
- return;
- }
}
}
import org.slf4j.LoggerFactory;
public final class Serialization {
+ public static final Gson gson =
+ new GsonBuilder().disableHtmlEscaping().registerTypeAdapter(ZonedDateTime.class, new GsonUtcAdapter())
+ .registerTypeAdapter(Instant.class, new GsonInstantAdapter())
+ .registerTypeAdapter(ControlLoopNotificationType.class, new NotificationTypeAdapter())
+ .registerTypeAdapter(ControlLoopTargetType.class, new TargetTypeAdapter()).create();
+
+
+ public static final Gson gsonPretty = new GsonBuilder().disableHtmlEscaping().setPrettyPrinting()
+ .registerTypeAdapter(ZonedDateTime.class, new GsonUtcAdapter())
+ .registerTypeAdapter(Instant.class, new GsonInstantAdapter())
+ .registerTypeAdapter(ControlLoopNotificationType.class, new NotificationTypeAdapter())
+ .registerTypeAdapter(ControlLoopTargetType.class, new TargetTypeAdapter()).create();
+
+ public static final Gson gsonJunit = new GsonBuilder().disableHtmlEscaping().setPrettyPrinting()
+ .registerTypeAdapter(ZonedDateTime.class, new GsonUtcAdapter())
+ .registerTypeAdapter(Instant.class, new GsonInstantAdapter())
+ .registerTypeAdapter(ControlLoopTargetType.class, new TargetTypeAdapter()).create();
+
private Serialization() {}
public static class NotificationTypeAdapter
}
- public static final Gson gson =
- new GsonBuilder().disableHtmlEscaping().registerTypeAdapter(ZonedDateTime.class, new GsonUtcAdapter())
- .registerTypeAdapter(Instant.class, new GsonInstantAdapter())
- .registerTypeAdapter(ControlLoopNotificationType.class, new NotificationTypeAdapter())
- .registerTypeAdapter(ControlLoopTargetType.class, new TargetTypeAdapter()).create();
-
-
- public static final Gson gsonPretty = new GsonBuilder().disableHtmlEscaping().setPrettyPrinting()
- .registerTypeAdapter(ZonedDateTime.class, new GsonUtcAdapter())
- .registerTypeAdapter(Instant.class, new GsonInstantAdapter())
- .registerTypeAdapter(ControlLoopNotificationType.class, new NotificationTypeAdapter())
- .registerTypeAdapter(ControlLoopTargetType.class, new TargetTypeAdapter()).create();
-
- public static final Gson gsonJunit = new GsonBuilder().disableHtmlEscaping().setPrettyPrinting()
- .registerTypeAdapter(ZonedDateTime.class, new GsonUtcAdapter())
- .registerTypeAdapter(Instant.class, new GsonInstantAdapter())
- .registerTypeAdapter(ControlLoopTargetType.class, new TargetTypeAdapter()).create();
-
}
public class HttpDeleteWithBody extends HttpEntityEnclosingRequestBase {
public static final String METHOD_NAME = "DELETE";
- public String getMethod() {
- return METHOD_NAME;
- }
-
public HttpDeleteWithBody(final String uri) {
super();
setURI(URI.create(uri));
public HttpDeleteWithBody() {
super();
}
+
+ public String getMethod() {
+ return METHOD_NAME;
+ }
+
}
* sdnr
* ================================================================================
* Copyright (C) 2018 Wipro Limited Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 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.
public final class Serialization {
+ public static final Gson gsonPretty = new GsonBuilder().disableHtmlEscaping().setPrettyPrinting()
+ .registerTypeAdapter(Instant.class, new InstantAdapter()).create();
+
+ public static final Gson gson = new GsonBuilder().disableHtmlEscaping().setPrettyPrinting()
+ .registerTypeAdapter(PciRequest.class, new RequestAdapter())
+ .registerTypeAdapter(PciResponse.class, new ResponseAdapter()).create();
+
+ public static final Gson gsonJunit = new GsonBuilder().disableHtmlEscaping().setPrettyPrinting()
+ .registerTypeAdapter(Instant.class, new InstantJunitAdapter()).create();
+
private Serialization() {}
public static class RequestAdapter implements JsonSerializer<PciRequest>, JsonDeserializer<PciRequest> {
}
- public static final Gson gsonPretty = new GsonBuilder().disableHtmlEscaping().setPrettyPrinting()
- .registerTypeAdapter(Instant.class, new InstantAdapter()).create();
-
- public static final Gson gson = new GsonBuilder().disableHtmlEscaping().setPrettyPrinting()
- .registerTypeAdapter(PciRequest.class, new RequestAdapter())
- .registerTypeAdapter(PciResponse.class, new ResponseAdapter()).create();
-
- public static final Gson gsonJunit = new GsonBuilder().disableHtmlEscaping().setPrettyPrinting()
- .registerTypeAdapter(Instant.class, new InstantJunitAdapter()).create();
-
}
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2017 Intel Corp. All rights reserved.
+ * Copyright (C) 2017-2018 Intel Corp. All rights reserved.
+ * Modifications Copyright (C) 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.
import com.google.gson.GsonBuilder;
public final class Serialization {
- private Serialization() {
- }
-
public static final Gson gsonPretty = new GsonBuilder().disableHtmlEscaping()
.setPrettyPrinting()
.create();
+ private Serialization() {
+ }
+
}
<suppressions>
<suppress checks="AbbreviationAsWordInName"
- files="ControlLoopCompiler.java|Target.java|ControlLoopPolicyBuilder.java"
+ files="Target.java|ControlLoopPolicyBuilder.java"
lines="1-9999"/>
</suppressions>
String policyId, String connectedPolicy,
FinalResultNodeWrapper finalResultNodeWrapper,
PolicyResult policyResult, NodeWrapper node) throws CompilerException {
- FinalResult finalResult = FinalResult.toResult(finalResultNodeWrapper.getID());
+ FinalResult finalResult = FinalResult.toResult(finalResultNodeWrapper.getId());
if (FinalResult.isResult(connectedPolicy, finalResult)) {
graph.addEdge(node, finalResultNodeWrapper, new LabeledEdge(node, finalResultNodeWrapper,
new FinalResultEdgeWrapper(finalResult)));
validatePolicyNodeWrapper(graph, node, callback);
}
for (LabeledEdge edge : graph.outgoingEdgesOf(node)) {
- LOGGER.info(edge.from.getID() + " invokes " + edge.to.getID() + " upon " + edge.edge.getID());
+ LOGGER.info("{} invokes {} upon {}", edge.from.getId(), edge.to.getId(), edge.edge.getId());
}
}
}
private static void validateTriggerNodeWrapper(DirectedGraph<NodeWrapper, LabeledEdge> graph,
NodeWrapper node) throws CompilerException {
if (LOGGER.isDebugEnabled()) {
- LOGGER.info("Trigger Node {}", node.toString());
+ LOGGER.info("Trigger Node {}", node);
}
if (graph.inDegreeOf(node) > 0 ) {
//
private static void validateFinalResultNodeWrapper(DirectedGraph<NodeWrapper, LabeledEdge> graph,
NodeWrapper node) throws CompilerException {
if (LOGGER.isDebugEnabled()) {
- LOGGER.info("FinalResult Node {}", node.toString());
+ LOGGER.info("FinalResult Node {}", node);
}
//
// FinalResult nodes should NEVER have an out edge
private static void validatePolicyNodeWrapper(DirectedGraph<NodeWrapper, LabeledEdge> graph,
NodeWrapper node, ControlLoopCompilerCallback callback) throws CompilerException {
if (LOGGER.isDebugEnabled()) {
- LOGGER.info("Policy Node {}", node.toString());
+ LOGGER.info("Policy Node {}", node);
}
//
// All Policy Nodes should have the 5 out degrees defined.
// All Policy Nodes should have at least 1 in degrees
//
if (graph.inDegreeOf(node) == 0 && callback != null) {
- callback.onWarning("Policy " + node.getID() + " is not reachable.");
+ callback.onWarning("Policy " + node.getId() + " is not reachable.");
}
}
private static boolean okToAdd(Policy operPolicy, ControlLoopCompilerCallback callback) {
boolean isOk = isPolicyIdOk(operPolicy, callback);
- isOk = isActorOk(operPolicy, callback) ? isOk : false;
- isOk = isRecipeOk(operPolicy, callback) ? isOk : false;
- isOk = isTargetOk(operPolicy, callback) ? isOk : false;
- isOk = arePolicyResultsOk(operPolicy, callback) ? isOk : false;
+ if (! isActorOk(operPolicy, callback)) {
+ isOk = false;
+ }
+ if (! isRecipeOk(operPolicy, callback)) {
+ isOk = false;
+ }
+ if (! isTargetOk(operPolicy, callback) ) {
+ isOk = false;
+ }
+ if (! arePolicyResultsOk(operPolicy, callback) ) {
+ isOk = false;
+ }
return isOk;
}
// Check that policy results are connected to either default final * or another policy
//
boolean isOk = isSuccessPolicyResultOk(operPolicy, callback);
- isOk = isFailurePolicyResultOk(operPolicy, callback) ? isOk : false;
- isOk = isFailureRetriesPolicyResultOk(operPolicy, callback) ? isOk : false;
- isOk = isFailureTimeoutPolicyResultOk(operPolicy, callback) ? isOk : false;
- isOk = isFailureExceptionPolicyResultOk(operPolicy, callback) ? isOk : false;
- isOk = isFailureGuardPolicyResultOk(operPolicy, callback) ? isOk : false;
+ if (! isFailurePolicyResultOk(operPolicy, callback) ) {
+ isOk = false;
+ }
+ if (! isFailureRetriesPolicyResultOk(operPolicy, callback) ) {
+ isOk = false;
+ }
+ if (! isFailureTimeoutPolicyResultOk(operPolicy, callback) ) {
+ isOk = false;
+ }
+ if (! isFailureExceptionPolicyResultOk(operPolicy, callback) ) {
+ isOk = false;
+ }
+ if (! isFailureGuardPolicyResultOk(operPolicy, callback) ) {
+ isOk = false;
+ }
return isOk;
}
@FunctionalInterface
private interface NodeWrapper extends Serializable {
- public String getID();
+ public String getId();
}
private static class TriggerNodeWrapper implements NodeWrapper {
}
@Override
- public String getID() {
+ public String getId() {
return closedLoopControlName;
}
}
@Override
- public String getID() {
+ public String getId() {
return result.toString();
}
}
}
@Override
- public String getID() {
+ public String getId() {
return policy.getId();
}
}
@FunctionalInterface
private interface EdgeWrapper extends Serializable {
- public String getID();
+ public String getId();
}
}
@Override
- public String getID() {
+ public String getId() {
return trigger;
}
}
@Override
- public String getID() {
+ public String getId() {
return policyResult.toString();
}
}
@Override
- public String getID() {
+ public String getId() {
return finalResult.toString();
}
}
//Does Nothing Empty Constructor
}
+ public Policy(String id) {
+ this.id = id;
+ }
+
+ /**
+ * Constructor.
+ *
+ * @param name name
+ * @param actor actor
+ * @param recipe recipe
+ * @param payload payload
+ * @param target target
+ */
+ public Policy(String name, String actor, String recipe, Map<String, String> payload, Target target) {
+ this.name = name;
+ this.actor = actor;
+ this.recipe = recipe;
+ this.target = target;
+ if (payload != null) {
+ this.payload = Collections.unmodifiableMap(payload);
+ }
+ }
+
+ /**
+ * Constructor.
+ *
+ * @param name name
+ * @param actor actor
+ * @param recipe recipe
+ * @param payload payload
+ * @param target target
+ * @param retries retries
+ * @param timeout timeout
+ */
+ public Policy(String name, String actor, String recipe, Map<String, String> payload, Target target,
+ Integer retries, Integer timeout) {
+ this(name, actor, recipe, payload, target);
+ this.retry = retries;
+ this.timeout = timeout;
+ }
+
+ /**
+ * Constructor.
+ *
+ * @param id id
+ * @param name name
+ * @param description description
+ * @param actor actor
+ * @param payload payload
+ * @param target target
+ * @param recipe recipe
+ * @param retries retries
+ * @param timeout timeout
+ */
+ public Policy(String id, String name, String description, String actor, Map<String, String> payload,
+ Target target, String recipe, Integer retries, Integer timeout) {
+ this(name, actor, recipe, payload, target, retries, timeout);
+ this.id = id;
+ this.description = description;
+ }
+
+ /**
+ * Constructor.
+ *
+ * @param policy copy object
+ */
+ public Policy(Policy policy) {
+ this.id = policy.id;
+ this.name = policy.name;
+ this.description = policy.description;
+ this.actor = policy.actor;
+ this.recipe = policy.recipe;
+ if (policy.payload != null) {
+ this.payload = Collections.unmodifiableMap(policy.payload);
+ }
+ this.target = policy.target;
+ this.operationsAccumulateParams = policy.operationsAccumulateParams;
+ this.retry = policy.retry;
+ this.timeout = policy.timeout;
+ this.success = policy.success;
+ this.failure = policy.failure;
+ this.failureException = policy.failureException;
+ this.failureGuard = policy.failureGuard;
+ this.failureRetries = policy.failureRetries;
+ this.failureTimeout = policy.failureTimeout;
+ }
+
public String getId() {
return id;
}
this.failureGuard = failureGuard;
}
- public Policy(String id) {
- this.id = id;
- }
-
- /**
- * Constructor.
- *
- * @param name name
- * @param actor actor
- * @param recipe recipe
- * @param payload payload
- * @param target target
- */
- public Policy(String name, String actor, String recipe, Map<String, String> payload, Target target) {
- this.name = name;
- this.actor = actor;
- this.recipe = recipe;
- this.target = target;
- if (payload != null) {
- this.payload = Collections.unmodifiableMap(payload);
- }
- }
-
- /**
- * Constructor.
- *
- * @param name name
- * @param actor actor
- * @param recipe recipe
- * @param payload payload
- * @param target target
- * @param retries retries
- * @param timeout timeout
- */
- public Policy(String name, String actor, String recipe, Map<String, String> payload, Target target,
- Integer retries, Integer timeout) {
- this(name, actor, recipe, payload, target);
- this.retry = retries;
- this.timeout = timeout;
- }
-
- /**
- * Constructor.
- *
- * @param id id
- * @param name name
- * @param description description
- * @param actor actor
- * @param payload payload
- * @param target target
- * @param recipe recipe
- * @param retries retries
- * @param timeout timeout
- */
- public Policy(String id, String name, String description, String actor, Map<String, String> payload,
- Target target, String recipe, Integer retries, Integer timeout) {
- this(name, actor, recipe, payload, target, retries, timeout);
- this.id = id;
- this.description = description;
- }
-
- /**
- * Constructor.
- *
- * @param policy copy object
- */
- public Policy(Policy policy) {
- this.id = policy.id;
- this.name = policy.name;
- this.description = policy.description;
- this.actor = policy.actor;
- this.recipe = policy.recipe;
- if (policy.payload != null) {
- this.payload = Collections.unmodifiableMap(policy.payload);
- }
- this.target = policy.target;
- this.operationsAccumulateParams = policy.operationsAccumulateParams;
- this.retry = policy.retry;
- this.timeout = policy.timeout;
- this.success = policy.success;
- this.failure = policy.failure;
- this.failureException = policy.failureException;
- this.failureGuard = policy.failureGuard;
- this.failureRetries = policy.failureRetries;
- this.failureTimeout = policy.failureTimeout;
- }
-
public boolean isValid() {
return id != null && name != null && actor != null && recipe != null && target != null;
}
//Does Nothing Empty Constructor
}
- public String getResourceID() {
- return resourceId;
- }
-
- public void setResourceID(String resourceId) {
- this.resourceId = resourceId;
- }
-
- public TargetType getType() {
- return type;
- }
-
- public void setType(TargetType type) {
- this.type = type;
- }
-
public Target(TargetType type) {
this.type = type;
}
this.resourceId = target.resourceId;
}
+ public String getResourceID() {
+ return resourceId;
+ }
+
+ public void setResourceID(String resourceId) {
+ this.resourceId = resourceId;
+ }
+
+ public TargetType getType() {
+ return type;
+ }
+
+ public void setType(TargetType type) {
+ this.type = type;
+ }
+
@Override
public String toString() {
return "Target [type=" + type + ", resourceId=" + resourceId + "]";
public class BuilderException extends Exception {
+ private static final long serialVersionUID = 610064813684337895L;
+
public BuilderException(String string) {
super(string);
}
- private static final long serialVersionUID = 610064813684337895L;
-
}
this.maxVnfCount = maxVnfCount;
}
-
+ /**
+ * Check if these constraint values are valid.
+ *
+ * @return true if valid
+ */
public boolean isValid() {
- return ((freqLimitPerTarget == null && timeWindow != null)
- || (timeWindow == null && freqLimitPerTarget != null)) ? false : true;
+ //
+ // Sonar likes these statements combined as well as not use
+ // boolean literals.
+ //
+ // If the freqLimitPerTarget is null AND the timeWindow is NOT null
+ // OR
+ // timeWindow is null AND the freqLimitPerTarget is NOT null
+ //
+ // then we want to return false (hence the preceding !)
+ //
+ return ! ((freqLimitPerTarget == null && timeWindow != null)
+ || (timeWindow == null && freqLimitPerTarget != null));
}
@Override
//Do Nothing Empty Constructor.
}
- public String getId() {
- return id;
- }
-
- public void setId(String id) {
- this.id = id;
- }
-
- public String getName() {
- return name;
- }
-
- public void setName(String name) {
- this.name = name;
- }
-
- public String getDescription() {
- return description;
- }
-
- public void setDescription(String description) {
- this.description = description;
- }
-
- public MatchParameters getMatch_parameters() {
- return matchParameters;
- }
-
- public void setMatch_parameters(MatchParameters matchParameters) {
- this.matchParameters = matchParameters;
- }
-
- public LinkedList<Constraint> getLimit_constraints() {
- return limitConstraints;
- }
-
- public void setLimit_constraints(LinkedList<Constraint> limitConstraints) {
- this.limitConstraints = limitConstraints;
- }
-
public GuardPolicy(String id) {
this.id = id;
}
}
}
+ public String getId() {
+ return id;
+ }
+
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getDescription() {
+ return description;
+ }
+
+ public void setDescription(String description) {
+ this.description = description;
+ }
+
+ public MatchParameters getMatch_parameters() {
+ return matchParameters;
+ }
+
+ public void setMatch_parameters(MatchParameters matchParameters) {
+ this.matchParameters = matchParameters;
+ }
+
+ public LinkedList<Constraint> getLimit_constraints() {
+ return limitConstraints;
+ }
+
+ public void setLimit_constraints(LinkedList<Constraint> limitConstraints) {
+ this.limitConstraints = limitConstraints;
+ }
+
public boolean isValid() {
return (id == null || name == null) ? false : true;
}
// Do Nothing Empty Constructor.
}
- public String getControlLoopName() {
- return controlLoopName;
- }
-
- public void setControlLoopName(String controlLoopName) {
- this.controlLoopName = controlLoopName;
- }
-
- public String getActor() {
- return actor;
- }
-
- public void setActor(String actor) {
- this.actor = actor;
- }
-
- public String getRecipe() {
- return recipe;
- }
-
- public void setRecipe(String recipe) {
- this.recipe = recipe;
- }
-
- public List<String> getTargets() {
- return targets;
- }
-
- public void setTargets(List<String> targets) {
- this.targets = targets;
- }
-
public MatchParameters(String actor, String recipe) {
this.actor = actor;
this.recipe = recipe;
}
}
+ public String getControlLoopName() {
+ return controlLoopName;
+ }
+
+ public void setControlLoopName(String controlLoopName) {
+ this.controlLoopName = controlLoopName;
+ }
+
+ public String getActor() {
+ return actor;
+ }
+
+ public void setActor(String actor) {
+ this.actor = actor;
+ }
+
+ public String getRecipe() {
+ return recipe;
+ }
+
+ public void setRecipe(String recipe) {
+ this.recipe = recipe;
+ }
+
+ public List<String> getTargets() {
+ return targets;
+ }
+
+ public void setTargets(List<String> targets) {
+ this.targets = targets;
+ }
+
@Override
public String toString() {
return "MatchParameters [controlLoopName=" + controlLoopName + ", actor=" + actor + ", recipe=" + recipe
try {
ControlLoopGuardCompiler.compile(clGuard, callback);
} catch (CompilerException e) {
- logger.error(e.getMessage() + e);
+ logger.error("Build specification threw ", e);
callback.results.addMessage(new MessageImpl(e.getMessage(), MessageLevel.EXCEPTION));
}
//
public class AaiSimulatorJaxRs {
private static final String VSERVER = "vserver";
+ private static final String DISABLE_CLOSEDLOOP = "disableClosedLoop";
+ private static final String ERROR = "error";
+ private static final String GETFAIL = "getFail";
/**
* A&AI get query.
if (request.getInstanceFilters().getInstanceFilter().get(0).containsKey(VSERVER)) {
final String vserverName =
request.getInstanceFilters().getInstanceFilter().get(0).get(VSERVER).get("vserver-name");
- if ("error".equals(vserverName)) {
+ if (ERROR.equals(vserverName)) {
Map<String,String> params = new TreeMap<>();
params.put("type", VSERVER);
return load("aai/AaiNqResponse-Error.json", params);
} else {
final String vnfId =
request.getInstanceFilters().getInstanceFilter().get(0).get("generic-vnf").get("vnf-id");
- if ("error".equals(vnfId)) {
+ if (ERROR.equals(vnfId)) {
Map<String,String> params = new TreeMap<>();
params.put("type", "generic-vnf");
return load("aai/AaiNqResponse-Error.json", params);
@Consumes(MediaType.APPLICATION_JSON)
@Produces("application/json")
public String getByVnfName(@QueryParam("vnf-name") final String vnfName) {
- if ("getFail".equals(vnfName)) {
+ if (GETFAIL.equals(vnfName)) {
return "{\"requestError\":{\"serviceException\":{\"messageId\":\"SVC3001\",\"text\":\"Resource not found"
+ " for %1 using id %2 (msg=%3) (ec=%4)\",\"variables\":[\"GET\",\"network/generic-vnfs/"
+ "generic-vnf\",\"Node Not Found:No Node of type generic-vnf found at network/generic-vnfs"
+ "/generic-vnf\",\"ERR.5.4.6114\"]}}}";
}
- final boolean isDisabled = "disableClosedLoop".equals(vnfName);
- if ("error".equals(vnfName)) {
+ final boolean isDisabled = DISABLE_CLOSEDLOOP.equals(vnfName);
+ if (ERROR.equals(vnfName)) {
return "{ \"vnf-id\": \"error\", \"vnf-name\": \"" + vnfName
+ "\", \"vnf-type\": \"RT\", \"service-id\": \"d7bb0a21-66f2-4e6d-87d9-9ef3ced63ae4\", \""
+ "equipment-role\": \"UCPE\", \"orchestration-status\": \"created\", \"management-option\": \""
@Consumes(MediaType.APPLICATION_JSON)
@Produces("application/json")
public String getByVnfId(@PathParam("vnfId") final String vnfId) {
- if ("getFail".equals(vnfId)) {
+ if (GETFAIL.equals(vnfId)) {
return "{\"requestError\":{\"serviceException\":{\"messageId\":\"SVC3001\",\"text\":\"Resource not found"
+ " for %1 using id %2 (msg=%3) (ec=%4)\",\"variables\":[\"GET\",\"network/generic-vnfs/"
+ "generic-vnf/getFail\",\"Node Not Found:No Node of type generic-vnf found at network/"
+ "generic-vnfs/generic-vnf/getFail\",\"ERR.5.4.6114\"]}}}";
}
- final boolean isDisabled = "disableClosedLoop".equals(vnfId);
+ final boolean isDisabled = DISABLE_CLOSEDLOOP.equals(vnfId);
final String vnfName = getUuidValue(vnfId, "USUCP0PCOIL0110UJRT01");
return "{ \"vnf-id\": \"" + vnfId + "\", \"vnf-name\": \"" + vnfName
+ "\", \"vnf-type\": \"RT\", \"service-id\": \""
@Consumes(MediaType.APPLICATION_JSON)
@Produces("application/json")
public String getByVserverName(@QueryParam("vserver-name") final String vserverName) {
- if ("getFail".equals(vserverName)) {
+ if (GETFAIL.equals(vserverName)) {
return "{\"requestError\":{\"serviceException\":{\"messageId\":\"SVC3001\",\"text\":\"Resource not found"
+ " for %1 using id %2 (msg=%3) (ec=%4)\",\"variables\":[\"GET\",\"nodes/vservers\",\"Node Not"
+ " Found:No Node of type generic-vnf found at nodes/vservers\",\"ERR.5.4.6114\"]}}}";
}
- final boolean isDisabled = "disableClosedLoop".equals(vserverName);
+ final boolean isDisabled = DISABLE_CLOSEDLOOP.equals(vserverName);
final String vserverId = getUuidValue(vserverName, "d0668d4f-c25e-4a1b-87c4-83845c01efd8");
return "{\"vserver\": [{ \"vserver-id\": \"" + vserverId + "\", \"vserver-name\": \"" + vserverName
+ "\", \"vserver-name2\": \"vjunos0\", \"vserver-selflink\": \"https://aai-ext1.test.att.com:8443/aai/v7/cloud-infrastructure/cloud-regions/cloud-region/att-aic/AAIAIC25/tenants/tenant/USMSO1SX7NJ0103UJZZ01%3A%3AuCPE-VMS/vservers/vserver/d0668d4f-c25e-4a1b-87c4-83845c01efd8\", \"in-maint\": false, \"is-closed-loop-disabled\": "
import org.onap.policy.common.utils.network.NetworkUtil;
public class Util {
- private Util() {
- // Prevent instantiation of thic class
- }
-
public static final String AAISIM_SERVER_NAME = "aaiSim";
public static final String SOSIM_SERVER_NAME = "soSim";
public static final String VFCSIM_SERVER_NAME = "vfcSim";
public static final int SOSIM_SERVER_PORT = 6667;
public static final int VFCSIM_SERVER_PORT = 6668;
public static final int GUARDSIM_SERVER_PORT = 6669;
+
+ private static final String CANNOT_CONNECT = "cannot connect to port ";
+ private static final String LOCALHOST = "localhost";
+
+ private Util() {
+ // Prevent instantiation of thic class
+ }
/**
* Build an A&AI simulator.
*/
public static HttpServletServer buildAaiSim() throws InterruptedException, IOException {
final HttpServletServer testServer =
- HttpServletServer.factory.build(AAISIM_SERVER_NAME, "localhost", AAISIM_SERVER_PORT, "/", false, true);
+ HttpServletServer.factory.build(AAISIM_SERVER_NAME, LOCALHOST, AAISIM_SERVER_PORT, "/", false, true);
testServer.addServletClass("/*", AaiSimulatorJaxRs.class.getName());
testServer.waitedStart(5000);
- if (!NetworkUtil.isTcpPortOpen("localhost", testServer.getPort(), 5, 10000L)) {
- throw new IllegalStateException("cannot connect to port " + testServer.getPort());
+ if (!NetworkUtil.isTcpPortOpen(LOCALHOST, testServer.getPort(), 5, 10000L)) {
+ throw new IllegalStateException(CANNOT_CONNECT + testServer.getPort());
}
return testServer;
}
*/
public static HttpServletServer buildSoSim() throws InterruptedException, IOException {
final HttpServletServer testServer =
- HttpServletServer.factory.build(SOSIM_SERVER_NAME, "localhost", SOSIM_SERVER_PORT, "/", false, true);
+ HttpServletServer.factory.build(SOSIM_SERVER_NAME, LOCALHOST, SOSIM_SERVER_PORT, "/", false, true);
testServer.addServletClass("/*", SoSimulatorJaxRs.class.getName());
testServer.waitedStart(5000);
- if (!NetworkUtil.isTcpPortOpen("localhost", testServer.getPort(), 5, 10000L)) {
- throw new IllegalStateException("cannot connect to port " + testServer.getPort());
+ if (!NetworkUtil.isTcpPortOpen(LOCALHOST, testServer.getPort(), 5, 10000L)) {
+ throw new IllegalStateException(CANNOT_CONNECT + testServer.getPort());
}
return testServer;
}
*/
public static HttpServletServer buildVfcSim() throws InterruptedException, IOException {
final HttpServletServer testServer =
- HttpServletServer.factory.build(VFCSIM_SERVER_NAME, "localhost", VFCSIM_SERVER_PORT, "/", false, true);
+ HttpServletServer.factory.build(VFCSIM_SERVER_NAME,LOCALHOST, VFCSIM_SERVER_PORT, "/", false, true);
testServer.addServletClass("/*", VfcSimulatorJaxRs.class.getName());
testServer.waitedStart(5000);
- if (!NetworkUtil.isTcpPortOpen("localhost", testServer.getPort(), 5, 10000L)) {
- throw new IllegalStateException("cannot connect to port " + testServer.getPort());
+ if (!NetworkUtil.isTcpPortOpen(LOCALHOST, testServer.getPort(), 5, 10000L)) {
+ throw new IllegalStateException(CANNOT_CONNECT + testServer.getPort());
}
return testServer;
}
* @throws IOException if an IO errror occurs
*/
public static HttpServletServer buildGuardSim() throws InterruptedException, IOException {
- HttpServletServer testServer = HttpServletServer.factory.build(GUARDSIM_SERVER_NAME, "localhost",
+ HttpServletServer testServer = HttpServletServer.factory.build(GUARDSIM_SERVER_NAME, LOCALHOST,
GUARDSIM_SERVER_PORT, "/", false, true);
testServer.addServletClass("/*", GuardSimulatorJaxRs.class.getName());
testServer.waitedStart(5000);
- if (!NetworkUtil.isTcpPortOpen("localhost", testServer.getPort(), 5, 10000L)) {
- throw new IllegalStateException("cannot connect to port " + testServer.getPort());
+ if (!NetworkUtil.isTcpPortOpen(LOCALHOST, testServer.getPort(), 5, 10000L)) {
+ throw new IllegalStateException(CANNOT_CONNECT + testServer.getPort());
}
return testServer;
}