/*
- * ================================================================================
+ * ===========LICENSE_START=====================================================================
* Copyright (c) 2018 AT&T Intellectual Property. All rights reserved.
+ * Copyright (c) 2022 Wipro Limited 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 java.time.ZonedDateTime;
import java.util.concurrent.atomic.AtomicInteger;
+import java.util.List;
import org.onap.dcae.analytics.model.common.ConfigSource;
import org.onap.dcae.analytics.tca.core.exception.AnalyticsParsingException;
+import org.onap.dcae.analytics.tca.core.exception.TcaProcessingException;
import org.onap.dcae.analytics.tca.model.policy.TcaPolicy;
import org.onap.dcae.analytics.tca.model.policy.TcaPolicyModel;
import org.onap.dcae.analytics.tca.web.TcaAppProperties;
this.policyVersion = getPolicyVersion(new AtomicInteger(0));
}
- public TcaPolicy getTcaPolicy() {
+ public List<TcaPolicy> getTcaPolicy() {
String tcaPolicyString = tcaAppProperties.getTca().getPolicy();
boolean isConfigBindingServiceProfileActive = tcaAppProperties.isConfigBindingServiceProfileActive();
if (isConfigBindingServiceProfileActive) {
tcaPolicy, configSource.name(), policyVersion);
}
- return convertTcaPolicy(tcaPolicyString);
+ List<TcaPolicy> tcaPolicyList = convertTcaPolicy(tcaPolicyString);
+ if( tcaPolicyList.size() > 2)
+ {
+ throw new TcaProcessingException(" TCA Policy size exceeding limit of 2");
+ }
+ else
+ return tcaPolicyList;
+
}
- public void setTcaPolicy(TcaPolicy tcaPolicy, ConfigSource configSource) {
+ public void setTcaPolicy(List<TcaPolicy> tcaPolicy, ConfigSource configSource) {
this.tcaPolicy = tcaPolicy.toString();
this.configSource = configSource;
}
- public TcaPolicy convertTcaPolicy(String tcaPolicyString) {
+ public List<TcaPolicy> convertTcaPolicy(String tcaPolicyString) {
return TCA_POLICY_JSON_FUNCTION.apply(tcaPolicyString).orElseThrow(
() -> new AnalyticsParsingException("Unable to parse Tca Policy String: " + tcaPolicyString,
new IllegalArgumentException()));