Loading src/policy/src/main/java/org/etsi/tfs/policy/PolicyServiceImpl.java +6 −36 Original line number Diff line number Diff line Loading @@ -16,6 +16,8 @@ package org.etsi.tfs.policy; import static org.etsi.tfs.policy.common.ApplicationProperties.*; import io.smallrye.mutiny.Multi; import io.smallrye.mutiny.Uni; import io.smallrye.mutiny.groups.UniJoin; Loading Loading @@ -64,8 +66,7 @@ import org.jboss.logging.Logger; public class PolicyServiceImpl implements PolicyService { private static final Logger LOGGER = Logger.getLogger(PolicyServiceImpl.class); private static final String INVALID_MESSAGE = "%s is invalid."; private static final String VALID_MESSAGE = "%s is valid."; private static final int POLICY_EVALUATION_TIMEOUT = 5; private static final int ACCEPTABLE_NUMBER_OF_ALARMS = 3; private static final int MONITORING_WINDOW_IN_SECONDS = 5; Loading @@ -74,39 +75,6 @@ public class PolicyServiceImpl implements PolicyService { // Temporary solution for not calling the same rpc more than it's needed private static int noAlarms = 0; private static final PolicyRuleState INSERTED_POLICYRULE_STATE = new PolicyRuleState( PolicyRuleStateEnum.POLICY_INSERTED, "Successfully entered to INSERTED state"); private static final PolicyRuleState VALIDATED_POLICYRULE_STATE = new PolicyRuleState( PolicyRuleStateEnum.POLICY_VALIDATED, "Successfully transitioned to VALIDATED state"); private static final PolicyRuleState PROVISIONED_POLICYRULE_STATE = new PolicyRuleState( PolicyRuleStateEnum.POLICY_PROVISIONED, "Successfully transitioned from VALIDATED to PROVISIONED state"); private static final PolicyRuleState ACTIVE_POLICYRULE_STATE = new PolicyRuleState( PolicyRuleStateEnum.POLICY_ACTIVE, "Successfully transitioned from PROVISIONED to ACTIVE state"); private static final PolicyRuleState ENFORCED_POLICYRULE_STATE = new PolicyRuleState( PolicyRuleStateEnum.POLICY_ENFORCED, "Successfully transitioned from ACTIVE to ENFORCED state"); private static final PolicyRuleState INEFFECTIVE_POLICYRULE_STATE = new PolicyRuleState( PolicyRuleStateEnum.POLICY_INEFFECTIVE, "Transitioned from ENFORCED to INEFFECTIVE state"); private static final PolicyRuleState EFFECTIVE_POLICYRULE_STATE = new PolicyRuleState( PolicyRuleStateEnum.POLICY_EFFECTIVE, "Successfully transitioned from ENFORCED to EFFECTIVE state"); private static final PolicyRuleState UPDATED_POLICYRULE_STATE = new PolicyRuleState( PolicyRuleStateEnum.POLICY_UPDATED, "Successfully entered to UPDATED state"); private static final PolicyRuleState REMOVED_POLICYRULE_STATE = new PolicyRuleState( PolicyRuleStateEnum.POLICY_REMOVED, "Successfully entered to REMOVED state"); private final ContextService contextService; private final MonitoringService monitoringService; private final ServiceService serviceService; Loading Loading @@ -457,7 +425,9 @@ public class PolicyServiceImpl implements PolicyService { policyRuleBasic.getPolicyRuleId())); contextService.removePolicyRule(policyId).subscribe().with(x -> {}); subscriptionList.get(policyId).cancel(); // TODO: When the Map doesn't contains the policyId we should throw an exception? if (subscriptionList.contains(policyId)) subscriptionList.get(policyId).cancel(); return policyRuleBasic.getPolicyRuleState(); }); Loading src/policy/src/main/java/org/etsi/tfs/policy/common/ApplicationProperties.java 0 → 100644 +59 −0 Original line number Diff line number Diff line /* * Copyright 2022-2023 ETSI TeraFlowSDN - TFS OSG (https://tfs.etsi.org/) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.etsi.tfs.policy.common; import org.etsi.tfs.policy.model.PolicyRuleState; import org.etsi.tfs.policy.model.PolicyRuleStateEnum; public class ApplicationProperties { public static final String INVALID_MESSAGE = "%s is invalid."; public static final String VALID_MESSAGE = "%s is valid."; public static final PolicyRuleState INSERTED_POLICYRULE_STATE = new PolicyRuleState( PolicyRuleStateEnum.POLICY_INSERTED, "Successfully entered to INSERTED state"); public static final PolicyRuleState VALIDATED_POLICYRULE_STATE = new PolicyRuleState( PolicyRuleStateEnum.POLICY_VALIDATED, "Successfully transitioned to VALIDATED state"); public static final PolicyRuleState PROVISIONED_POLICYRULE_STATE = new PolicyRuleState( PolicyRuleStateEnum.POLICY_PROVISIONED, "Successfully transitioned from VALIDATED to PROVISIONED state"); public static final PolicyRuleState ACTIVE_POLICYRULE_STATE = new PolicyRuleState( PolicyRuleStateEnum.POLICY_ACTIVE, "Successfully transitioned from PROVISIONED to ACTIVE state"); public static final PolicyRuleState ENFORCED_POLICYRULE_STATE = new PolicyRuleState( PolicyRuleStateEnum.POLICY_ENFORCED, "Successfully transitioned from ACTIVE to ENFORCED state"); public static final PolicyRuleState INEFFECTIVE_POLICYRULE_STATE = new PolicyRuleState( PolicyRuleStateEnum.POLICY_INEFFECTIVE, "Transitioned from ENFORCED to INEFFECTIVE state"); public static final PolicyRuleState EFFECTIVE_POLICYRULE_STATE = new PolicyRuleState( PolicyRuleStateEnum.POLICY_EFFECTIVE, "Successfully transitioned from ENFORCED to EFFECTIVE state"); public static final PolicyRuleState UPDATED_POLICYRULE_STATE = new PolicyRuleState( PolicyRuleStateEnum.POLICY_UPDATED, "Successfully entered to UPDATED state"); public static final PolicyRuleState REMOVED_POLICYRULE_STATE = new PolicyRuleState( PolicyRuleStateEnum.POLICY_REMOVED, "Successfully entered to REMOVED state"); } src/policy/src/main/java/org/etsi/tfs/policy/model/PolicyRuleBasic.java +1 −1 Original line number Diff line number Diff line Loading @@ -64,7 +64,7 @@ public class PolicyRuleBasic { this.booleanOperator = BooleanOperator.POLICYRULE_CONDITION_BOOLEAN_UNDEFINED; this.policyRuleActions = new ArrayList<PolicyRuleAction>(); this.isValid = false; this.exceptionMessage = e.toString(); this.exceptionMessage = e.getMessage(); } } Loading src/policy/src/main/java/org/etsi/tfs/policy/model/PolicyRuleDevice.java +1 −1 Original line number Diff line number Diff line Loading @@ -40,7 +40,7 @@ public class PolicyRuleDevice { this.policyRuleBasic = policyRuleBasic; this.deviceIds = new ArrayList<String>(); this.isValid = false; this.exceptionMessage = e.toString(); this.exceptionMessage = e.getMessage(); } } Loading src/policy/src/main/java/org/etsi/tfs/policy/model/PolicyRuleService.java +1 −1 Original line number Diff line number Diff line Loading @@ -50,7 +50,7 @@ public class PolicyRuleService { this.serviceId = new ServiceId("", ""); this.deviceIds = new ArrayList<String>(); this.isValid = false; this.exceptionMessage = e.toString(); this.exceptionMessage = e.getMessage(); } } Loading Loading
src/policy/src/main/java/org/etsi/tfs/policy/PolicyServiceImpl.java +6 −36 Original line number Diff line number Diff line Loading @@ -16,6 +16,8 @@ package org.etsi.tfs.policy; import static org.etsi.tfs.policy.common.ApplicationProperties.*; import io.smallrye.mutiny.Multi; import io.smallrye.mutiny.Uni; import io.smallrye.mutiny.groups.UniJoin; Loading Loading @@ -64,8 +66,7 @@ import org.jboss.logging.Logger; public class PolicyServiceImpl implements PolicyService { private static final Logger LOGGER = Logger.getLogger(PolicyServiceImpl.class); private static final String INVALID_MESSAGE = "%s is invalid."; private static final String VALID_MESSAGE = "%s is valid."; private static final int POLICY_EVALUATION_TIMEOUT = 5; private static final int ACCEPTABLE_NUMBER_OF_ALARMS = 3; private static final int MONITORING_WINDOW_IN_SECONDS = 5; Loading @@ -74,39 +75,6 @@ public class PolicyServiceImpl implements PolicyService { // Temporary solution for not calling the same rpc more than it's needed private static int noAlarms = 0; private static final PolicyRuleState INSERTED_POLICYRULE_STATE = new PolicyRuleState( PolicyRuleStateEnum.POLICY_INSERTED, "Successfully entered to INSERTED state"); private static final PolicyRuleState VALIDATED_POLICYRULE_STATE = new PolicyRuleState( PolicyRuleStateEnum.POLICY_VALIDATED, "Successfully transitioned to VALIDATED state"); private static final PolicyRuleState PROVISIONED_POLICYRULE_STATE = new PolicyRuleState( PolicyRuleStateEnum.POLICY_PROVISIONED, "Successfully transitioned from VALIDATED to PROVISIONED state"); private static final PolicyRuleState ACTIVE_POLICYRULE_STATE = new PolicyRuleState( PolicyRuleStateEnum.POLICY_ACTIVE, "Successfully transitioned from PROVISIONED to ACTIVE state"); private static final PolicyRuleState ENFORCED_POLICYRULE_STATE = new PolicyRuleState( PolicyRuleStateEnum.POLICY_ENFORCED, "Successfully transitioned from ACTIVE to ENFORCED state"); private static final PolicyRuleState INEFFECTIVE_POLICYRULE_STATE = new PolicyRuleState( PolicyRuleStateEnum.POLICY_INEFFECTIVE, "Transitioned from ENFORCED to INEFFECTIVE state"); private static final PolicyRuleState EFFECTIVE_POLICYRULE_STATE = new PolicyRuleState( PolicyRuleStateEnum.POLICY_EFFECTIVE, "Successfully transitioned from ENFORCED to EFFECTIVE state"); private static final PolicyRuleState UPDATED_POLICYRULE_STATE = new PolicyRuleState( PolicyRuleStateEnum.POLICY_UPDATED, "Successfully entered to UPDATED state"); private static final PolicyRuleState REMOVED_POLICYRULE_STATE = new PolicyRuleState( PolicyRuleStateEnum.POLICY_REMOVED, "Successfully entered to REMOVED state"); private final ContextService contextService; private final MonitoringService monitoringService; private final ServiceService serviceService; Loading Loading @@ -457,7 +425,9 @@ public class PolicyServiceImpl implements PolicyService { policyRuleBasic.getPolicyRuleId())); contextService.removePolicyRule(policyId).subscribe().with(x -> {}); subscriptionList.get(policyId).cancel(); // TODO: When the Map doesn't contains the policyId we should throw an exception? if (subscriptionList.contains(policyId)) subscriptionList.get(policyId).cancel(); return policyRuleBasic.getPolicyRuleState(); }); Loading
src/policy/src/main/java/org/etsi/tfs/policy/common/ApplicationProperties.java 0 → 100644 +59 −0 Original line number Diff line number Diff line /* * Copyright 2022-2023 ETSI TeraFlowSDN - TFS OSG (https://tfs.etsi.org/) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.etsi.tfs.policy.common; import org.etsi.tfs.policy.model.PolicyRuleState; import org.etsi.tfs.policy.model.PolicyRuleStateEnum; public class ApplicationProperties { public static final String INVALID_MESSAGE = "%s is invalid."; public static final String VALID_MESSAGE = "%s is valid."; public static final PolicyRuleState INSERTED_POLICYRULE_STATE = new PolicyRuleState( PolicyRuleStateEnum.POLICY_INSERTED, "Successfully entered to INSERTED state"); public static final PolicyRuleState VALIDATED_POLICYRULE_STATE = new PolicyRuleState( PolicyRuleStateEnum.POLICY_VALIDATED, "Successfully transitioned to VALIDATED state"); public static final PolicyRuleState PROVISIONED_POLICYRULE_STATE = new PolicyRuleState( PolicyRuleStateEnum.POLICY_PROVISIONED, "Successfully transitioned from VALIDATED to PROVISIONED state"); public static final PolicyRuleState ACTIVE_POLICYRULE_STATE = new PolicyRuleState( PolicyRuleStateEnum.POLICY_ACTIVE, "Successfully transitioned from PROVISIONED to ACTIVE state"); public static final PolicyRuleState ENFORCED_POLICYRULE_STATE = new PolicyRuleState( PolicyRuleStateEnum.POLICY_ENFORCED, "Successfully transitioned from ACTIVE to ENFORCED state"); public static final PolicyRuleState INEFFECTIVE_POLICYRULE_STATE = new PolicyRuleState( PolicyRuleStateEnum.POLICY_INEFFECTIVE, "Transitioned from ENFORCED to INEFFECTIVE state"); public static final PolicyRuleState EFFECTIVE_POLICYRULE_STATE = new PolicyRuleState( PolicyRuleStateEnum.POLICY_EFFECTIVE, "Successfully transitioned from ENFORCED to EFFECTIVE state"); public static final PolicyRuleState UPDATED_POLICYRULE_STATE = new PolicyRuleState( PolicyRuleStateEnum.POLICY_UPDATED, "Successfully entered to UPDATED state"); public static final PolicyRuleState REMOVED_POLICYRULE_STATE = new PolicyRuleState( PolicyRuleStateEnum.POLICY_REMOVED, "Successfully entered to REMOVED state"); }
src/policy/src/main/java/org/etsi/tfs/policy/model/PolicyRuleBasic.java +1 −1 Original line number Diff line number Diff line Loading @@ -64,7 +64,7 @@ public class PolicyRuleBasic { this.booleanOperator = BooleanOperator.POLICYRULE_CONDITION_BOOLEAN_UNDEFINED; this.policyRuleActions = new ArrayList<PolicyRuleAction>(); this.isValid = false; this.exceptionMessage = e.toString(); this.exceptionMessage = e.getMessage(); } } Loading
src/policy/src/main/java/org/etsi/tfs/policy/model/PolicyRuleDevice.java +1 −1 Original line number Diff line number Diff line Loading @@ -40,7 +40,7 @@ public class PolicyRuleDevice { this.policyRuleBasic = policyRuleBasic; this.deviceIds = new ArrayList<String>(); this.isValid = false; this.exceptionMessage = e.toString(); this.exceptionMessage = e.getMessage(); } } Loading
src/policy/src/main/java/org/etsi/tfs/policy/model/PolicyRuleService.java +1 −1 Original line number Diff line number Diff line Loading @@ -50,7 +50,7 @@ public class PolicyRuleService { this.serviceId = new ServiceId("", ""); this.deviceIds = new ArrayList<String>(); this.isValid = false; this.exceptionMessage = e.toString(); this.exceptionMessage = e.getMessage(); } } Loading