diff --git a/edc-extensions/bpn-validation/src/main/java/org/eclipse/tractusx/edc/validation/businesspartner/BusinessPartnerEvaluationExtension.java b/edc-extensions/bpn-validation/src/main/java/org/eclipse/tractusx/edc/validation/businesspartner/BusinessPartnerEvaluationExtension.java index 316175066..e60d5e04f 100644 --- a/edc-extensions/bpn-validation/src/main/java/org/eclipse/tractusx/edc/validation/businesspartner/BusinessPartnerEvaluationExtension.java +++ b/edc-extensions/bpn-validation/src/main/java/org/eclipse/tractusx/edc/validation/businesspartner/BusinessPartnerEvaluationExtension.java @@ -35,12 +35,12 @@ *
* { * "constraint": { - * "leftOperand": "BusinessPartnerGroup", + * "leftOperand": "https://w3id.org/tractusx/v0.0.1/ns/BusinessPartnerGroup", * "operator": "isAnyOf", * "rightOperand": ["gold_customer","platin_partner"] * } @@ -52,7 +52,6 @@ @Extension(value = "Registers a function to evaluate whether a BPN number is covered by a certain policy or not", categories = {"policy", "contract"}) public class BusinessPartnerEvaluationExtension implements ServiceExtension { - public static final String BUSINESS_PARTNER_CONSTRAINT_KEY = "BusinessPartnerGroup"; private static final String USE = "USE"; @Inject private RuleBindingRegistry ruleBindingRegistry; @@ -72,8 +71,8 @@ public void initialize(ServiceExtensionContext context) { private void bindToScope(BusinessPartnerGroupFunction function, String scope) { ruleBindingRegistry.bind(USE, scope); - ruleBindingRegistry.bind(BUSINESS_PARTNER_CONSTRAINT_KEY, scope); + ruleBindingRegistry.bind(BusinessPartnerGroupFunction.BUSINESS_PARTNER_CONSTRAINT_KEY, scope); - policyEngine.registerFunction(scope, Permission.class, BUSINESS_PARTNER_CONSTRAINT_KEY, function); + policyEngine.registerFunction(scope, Permission.class, BusinessPartnerGroupFunction.BUSINESS_PARTNER_CONSTRAINT_KEY, function); } } diff --git a/edc-extensions/bpn-validation/src/main/java/org/eclipse/tractusx/edc/validation/businesspartner/functions/BusinessPartnerGroupFunction.java b/edc-extensions/bpn-validation/src/main/java/org/eclipse/tractusx/edc/validation/businesspartner/functions/BusinessPartnerGroupFunction.java index 5bed93886..012ec1371 100644 --- a/edc-extensions/bpn-validation/src/main/java/org/eclipse/tractusx/edc/validation/businesspartner/functions/BusinessPartnerGroupFunction.java +++ b/edc-extensions/bpn-validation/src/main/java/org/eclipse/tractusx/edc/validation/businesspartner/functions/BusinessPartnerGroupFunction.java @@ -35,6 +35,7 @@ import static org.eclipse.edc.policy.model.Operator.IS_ANY_OF; import static org.eclipse.edc.policy.model.Operator.IS_NONE_OF; import static org.eclipse.edc.policy.model.Operator.NEQ; +import static org.eclipse.tractusx.edc.edr.spi.CoreConstants.TX_NAMESPACE; /** * This function evaluates, that a particular {@link ParticipantAgent} is a member of a particular group. @@ -46,7 +47,7 @@ ** { * "constraint": { - * "leftOperand": "BusinessPartnerGroup", + * "leftOperand": "https://w3id.org/tractusx/v0.0.1/ns/BusinessPartnerGroup", * "operator": "isAnyOf", * "rightOperand": ["gold_customer","platin_partner"] * } @@ -70,6 +71,7 @@ */ public class BusinessPartnerGroupFunction implements AtomicConstraintFunction{ public static final String REFERRING_CONNECTOR_CLAIM = "referringConnector"; + public static final String BUSINESS_PARTNER_CONSTRAINT_KEY = TX_NAMESPACE + "BusinessPartnerGroup"; private static final List ALLOWED_OPERATORS = List.of(EQ, NEQ, IN, IS_ALL_OF, IS_ANY_OF, IS_NONE_OF); private static final Map > OPERATOR_EVALUATOR_MAP = new HashMap<>(); private final BusinessPartnerGroupStore store; diff --git a/edc-extensions/bpn-validation/src/test/java/org/eclipse/tractusx/edc/validation/businesspartner/functions/BusinessPartnerGroupFunctionTest.java b/edc-extensions/bpn-validation/src/test/java/org/eclipse/tractusx/edc/validation/businesspartner/functions/BusinessPartnerGroupFunctionTest.java index 99e221eed..e317ec1b2 100644 --- a/edc-extensions/bpn-validation/src/test/java/org/eclipse/tractusx/edc/validation/businesspartner/functions/BusinessPartnerGroupFunctionTest.java +++ b/edc-extensions/bpn-validation/src/test/java/org/eclipse/tractusx/edc/validation/businesspartner/functions/BusinessPartnerGroupFunctionTest.java @@ -48,7 +48,7 @@ import static org.eclipse.edc.policy.model.Operator.LEQ; import static org.eclipse.edc.policy.model.Operator.LT; import static org.eclipse.edc.policy.model.Operator.NEQ; -import static org.eclipse.tractusx.edc.validation.businesspartner.BusinessPartnerEvaluationExtension.BUSINESS_PARTNER_CONSTRAINT_KEY; +import static org.eclipse.tractusx.edc.validation.businesspartner.functions.BusinessPartnerGroupFunction.BUSINESS_PARTNER_CONSTRAINT_KEY; import static org.eclipse.tractusx.edc.validation.businesspartner.functions.BusinessPartnerGroupFunction.REFERRING_CONNECTOR_CLAIM; import static org.mockito.ArgumentMatchers.endsWith; import static org.mockito.ArgumentMatchers.eq; diff --git a/edc-extensions/business-partner-store-sql/src/main/java/org/eclipse/tractusx/edc/validation/businesspartner/store/sql/BusinessPartnerGroupStatements.java b/edc-extensions/business-partner-store-sql/src/main/java/org/eclipse/tractusx/edc/validation/businesspartner/store/sql/BusinessPartnerGroupStatements.java index 83eecad3a..08171a887 100644 --- a/edc-extensions/business-partner-store-sql/src/main/java/org/eclipse/tractusx/edc/validation/businesspartner/store/sql/BusinessPartnerGroupStatements.java +++ b/edc-extensions/business-partner-store-sql/src/main/java/org/eclipse/tractusx/edc/validation/businesspartner/store/sql/BusinessPartnerGroupStatements.java @@ -14,6 +14,9 @@ package org.eclipse.tractusx.edc.validation.businesspartner.store.sql; +/** + * Statement templates and SQL table+column names required for the {@link SqlBusinessPartnerGroupStore} + */ public interface BusinessPartnerGroupStatements { default String getBpnColumn() { diff --git a/edc-extensions/business-partner-store-sql/src/main/java/org/eclipse/tractusx/edc/validation/businesspartner/store/sql/PostgresBusinessPartnerGroupStatements.java b/edc-extensions/business-partner-store-sql/src/main/java/org/eclipse/tractusx/edc/validation/businesspartner/store/sql/PostgresBusinessPartnerGroupStatements.java index 4d8961de4..37ba72377 100644 --- a/edc-extensions/business-partner-store-sql/src/main/java/org/eclipse/tractusx/edc/validation/businesspartner/store/sql/PostgresBusinessPartnerGroupStatements.java +++ b/edc-extensions/business-partner-store-sql/src/main/java/org/eclipse/tractusx/edc/validation/businesspartner/store/sql/PostgresBusinessPartnerGroupStatements.java @@ -19,6 +19,9 @@ import static java.lang.String.format; +/** + * Postgres-specific statement templates for the {@link SqlBusinessPartnerGroupStore} + */ public class PostgresBusinessPartnerGroupStatements implements BusinessPartnerGroupStatements { @Override public String findByBpnTemplate() { @@ -44,7 +47,7 @@ public String countQuery() { public String updateTemplate() { return format("UPDATE %s SET %s=?%s WHERE %s=?", getTable(), getGroupsColumn(), getFormatJsonOperator(), getBpnColumn()); } - + @NotNull private String getFormatJsonOperator() { return PostgresDialect.getJsonCastOperator();