import org.onap.policy.controlloop.actorserviceprovider.CallbackManager;
import org.onap.policy.controlloop.actorserviceprovider.Operation;
import org.onap.policy.controlloop.actorserviceprovider.OperationOutcome;
+import org.onap.policy.controlloop.actorserviceprovider.OperationProperties;
import org.onap.policy.controlloop.actorserviceprovider.parameters.ControlLoopOperationParams;
import org.onap.policy.controlloop.actorserviceprovider.parameters.OperatorConfig;
import org.onap.policy.controlloop.actorserviceprovider.pipeline.PipelineControllerFuture;
return params.getOperation();
}
- /**
- * Sets a property.
- *
- * @param name property name
- * @param value new value
- */
+ @Override
+ public boolean containsProperty(String name) {
+ return properties.containsKey(name);
+ }
+
+ @Override
public void setProperty(String name, Object value) {
+ logger.info("{}: set property {}={}", getFullName(), name, value);
properties.put(name, value);
}
- /**
- * Gets a property's value.
- *
- * @param name name of the property of interest
- * @return the property's value, or {@code null} if it has no value
- */
@SuppressWarnings("unchecked")
+ @Override
public <T> T getProperty(String name) {
return (T) properties.get(name);
}
// propagate "stop" to the callbacks
controller.add(callbacks);
- final OperationOutcome outcome2 = params.makeOutcome();
+ final OperationOutcome outcome2 = params.makeOutcome(getTargetEntity());
// TODO need a FAILURE_MISSING_DATA (e.g., A&AI)
Map<String, Object> guard = new LinkedHashMap<>();
guard.put("actor", params.getActor());
guard.put("operation", params.getOperation());
- guard.put("target", params.getTargetEntity());
+ guard.put("target", getTargetEntity());
guard.put("requestId", params.getRequestId());
String clname = params.getContext().getEvent().getClosedLoopControlName();
/**
* Generates and sets {@link #subRequestId} to a new subrequest ID.
+ *
* @param attempt attempt number, typically starting with 1
*/
public void generateSubRequestId(int attempt) {
logger.info("{}: start operation attempt {} for {}", getFullName(), attempt, params.getRequestId());
final Executor executor = params.getExecutor();
- final OperationOutcome outcome = params.makeOutcome();
+ final OperationOutcome outcome = params.makeOutcome(getTargetEntity());
final CallbackManager callbacks = new CallbackManager();
// this operation attempt gets its own controller
outcome = origOutcome;
} else {
logger.warn("{}: null outcome; treating as a failure for {}", getFullName(), params.getRequestId());
- outcome = this.setOutcome(params.makeOutcome(), PolicyResult.FAILURE);
+ outcome = this.setOutcome(params.makeOutcome(getTargetEntity()), PolicyResult.FAILURE);
}
// ensure correct actor/operation
private Function<Throwable, OperationOutcome> fromException(String type) {
return thrown -> {
- OperationOutcome outcome = params.makeOutcome();
+ OperationOutcome outcome = params.makeOutcome(getTargetEntity());
if (thrown instanceof CancellationException || thrown.getCause() instanceof CancellationException) {
// do not include exception in the message, as it just clutters the log
return DEFAULT_RETRY_WAIT_MS;
}
+ /**
+ * Gets the target entity, first trying the properties and then the parameters.
+ *
+ * @return the target entity
+ */
+ protected String getTargetEntity() {
+ String targetEntity = getProperty(OperationProperties.AAI_TARGET_ENTITY);
+ return (targetEntity != null ? targetEntity : params.getTargetEntity());
+ }
+
/**
* Gets the operation timeout.
*