diff options
Diffstat (limited to 'applications/common/src')
10 files changed, 58 insertions, 45 deletions
diff --git a/applications/common/src/main/java/org/onap/policy/pdp/xacml/application/common/matchable/MatchablePolicyType.java b/applications/common/src/main/java/org/onap/policy/pdp/xacml/application/common/matchable/MatchablePolicyType.java index cf9d7a94..e3174dda 100644 --- a/applications/common/src/main/java/org/onap/policy/pdp/xacml/application/common/matchable/MatchablePolicyType.java +++ b/applications/common/src/main/java/org/onap/policy/pdp/xacml/application/common/matchable/MatchablePolicyType.java @@ -3,6 +3,7 @@ * ONAP * ================================================================================ * Copyright (C) 2020 AT&T Intellectual Property. All rights reserved. + * Modifications Copyright (C) 2020 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -29,10 +30,10 @@ import java.util.function.Function; import lombok.Getter; import lombok.NonNull; import org.onap.policy.models.tosca.authorative.concepts.ToscaDataType; -import org.onap.policy.models.tosca.authorative.concepts.ToscaEntrySchema; import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyIdentifier; import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyType; import org.onap.policy.models.tosca.authorative.concepts.ToscaProperty; +import org.onap.policy.models.tosca.authorative.concepts.ToscaSchemaDefinition; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -58,7 +59,7 @@ public class MatchablePolicyType { TOSCA_PRIMITIVE_TIMESTAMP, MatchablePropertyTypeTimestamp::new ); - private static final Map<String, Function<ToscaEntrySchema, MatchablePropertyTypeBase<?>>> + private static final Map<String, Function<ToscaSchemaDefinition, MatchablePropertyTypeBase<?>>> mapPrimitivesSchema = Map.of( TOSCA_PRIMITIVE_STRING, MatchablePropertyTypeString::new, TOSCA_PRIMITIVE_INTEGER, MatchablePropertyTypeInteger::new, @@ -110,7 +111,7 @@ public class MatchablePolicyType { * * @param properties Map of ToscaProperties to scan * @param matchables Found matchables will be put into this list - * @param callback Callback routine for finding Policy Types and Data Types + * @param callback Callback routine for finding Policy Types and Data Types */ public static void scanProperties(Map<String, ToscaProperty> properties, Map<String, MatchableProperty> matchables, MatchableCallback callback) { @@ -144,7 +145,7 @@ public class MatchablePolicyType { /** * handlePrimitive - handles a primitive type only if its matchable. * - * @param property String containing property name + * @param property String containing property name * @param toscaProperty ToscaProperty object * @return MatchableProperty object */ @@ -164,13 +165,13 @@ public class MatchablePolicyType { * handlePrimitive from a schema. Note that a ToscaEntrySchema does NOT have a metadata section * so you cannot check if its matchable. * - * @param property String containing property name + * @param property String containing property name * @param toscaSchema ToscaSchema * @return MatchableProperty object */ - public static MatchableProperty handlePrimitive(String property, ToscaEntrySchema toscaSchema) { - Function<ToscaEntrySchema, MatchablePropertyTypeBase<?>> function = - mapPrimitivesSchema.get(toscaSchema.getType()); + public static MatchableProperty handlePrimitive(String property, ToscaSchemaDefinition toscaSchema) { + Function<ToscaSchemaDefinition, MatchablePropertyTypeBase<?>> function = + mapPrimitivesSchema.get(toscaSchema.getType()); if (function != null) { return new MatchableProperty(property, function.apply(toscaSchema)); } @@ -180,15 +181,16 @@ public class MatchablePolicyType { /** * handleList - iterates a list looking for matchables. * - * @param property String containing property name + * @param property String containing property name * @param toscaProperty ToscaProperty object - * @param matchables list of matchables to add to - * @param callback MatchableCallback to retrieve Data Types + * @param matchables list of matchables to add to + * @param callback MatchableCallback to retrieve Data Types * @return MatchableProperty object */ public static MatchableProperty handleList(@NonNull String property, @NonNull ToscaProperty toscaProperty, - Map<String, MatchableProperty> matchables, @NonNull MatchableCallback callback) { - if (! TOSCA_TYPE_LIST.equals(toscaProperty.getType())) { + Map<String, MatchableProperty> matchables, + @NonNull MatchableCallback callback) { + if (!TOSCA_TYPE_LIST.equals(toscaProperty.getType())) { throw new IllegalArgumentException("must be a list"); } // @@ -219,15 +221,16 @@ public class MatchablePolicyType { /** * handleMap - iterates a map looking for matchables. * - * @param property String containing property name + * @param property String containing property name * @param toscaProperty ToscaProperty object - * @param matchables list of matchables to add to - * @param callback MatchableCallback to retrieve Data Types + * @param matchables list of matchables to add to + * @param callback MatchableCallback to retrieve Data Types * @return MatchableProperty object */ public static MatchableProperty handleMap(@NonNull String property, @NonNull ToscaProperty toscaProperty, - Map<String, MatchableProperty> matchables, @NonNull MatchableCallback callback) { - if (! TOSCA_TYPE_MAP.equals(toscaProperty.getType())) { + Map<String, MatchableProperty> matchables, + @NonNull MatchableCallback callback) { + if (!TOSCA_TYPE_MAP.equals(toscaProperty.getType())) { throw new IllegalArgumentException("must be a map"); } // @@ -259,11 +262,11 @@ public class MatchablePolicyType { * scanDatatype - scans a datatypes schema properties for matchables. * * @param toscaProperty ToscaProperty object - * @param matchables list of matchables to add to - * @param callback MatchableCallback to retrieve Data Types + * @param matchables list of matchables to add to + * @param callback MatchableCallback to retrieve Data Types */ public static void scanDatatype(@NonNull ToscaProperty toscaProperty, Map<String, MatchableProperty> matchables, - @NonNull MatchableCallback callback) { + @NonNull MatchableCallback callback) { // // Don't check for matchable property, as that does not make sense to support right now. But we need to // scan the datatype for matchable properties. @@ -287,11 +290,12 @@ public class MatchablePolicyType { * scanDatatypes - scans a datatype schema for matchables. * * @param toscaSchema ToscaEntrySchema - * @param matchables list of matchables to add to - * @param callback MatchableCallback object for retrieving other data types + * @param matchables list of matchables to add to + * @param callback MatchableCallback object for retrieving other data types */ - public static void scanDatatype(@NonNull ToscaEntrySchema toscaSchema, Map<String, MatchableProperty> matchables, - @NonNull MatchableCallback callback) { + public static void scanDatatype(@NonNull ToscaSchemaDefinition toscaSchema, + Map<String, MatchableProperty> matchables, + @NonNull MatchableCallback callback) { // // Don't check for matchable property, as that does not make sense to support right now. But we need to // scan the datatype for matchable properties. @@ -337,4 +341,5 @@ public class MatchablePolicyType { } return "true".equalsIgnoreCase(isMatchable); } + } diff --git a/applications/common/src/main/java/org/onap/policy/pdp/xacml/application/common/matchable/MatchablePropertyTypeBase.java b/applications/common/src/main/java/org/onap/policy/pdp/xacml/application/common/matchable/MatchablePropertyTypeBase.java index f93f8a3d..b98ef9f0 100644 --- a/applications/common/src/main/java/org/onap/policy/pdp/xacml/application/common/matchable/MatchablePropertyTypeBase.java +++ b/applications/common/src/main/java/org/onap/policy/pdp/xacml/application/common/matchable/MatchablePropertyTypeBase.java @@ -3,6 +3,7 @@ * ONAP * ================================================================================ * Copyright (C) 2020 AT&T Intellectual Property. All rights reserved. + * Modifications Copyright (C) 2020 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -23,19 +24,19 @@ package org.onap.policy.pdp.xacml.application.common.matchable; import lombok.Getter; -import org.onap.policy.models.tosca.authorative.concepts.ToscaEntrySchema; import org.onap.policy.models.tosca.authorative.concepts.ToscaProperty; +import org.onap.policy.models.tosca.authorative.concepts.ToscaSchemaDefinition; @Getter public abstract class MatchablePropertyTypeBase<T> implements MatchablePropertyType<T> { private ToscaProperty toscaProperty; - private ToscaEntrySchema toscaSchema; + private ToscaSchemaDefinition toscaSchema; public MatchablePropertyTypeBase(ToscaProperty inProperty) { this.toscaProperty = inProperty; } - public MatchablePropertyTypeBase(ToscaEntrySchema inSchema) { + public MatchablePropertyTypeBase(ToscaSchemaDefinition inSchema) { this.toscaSchema = inSchema; } diff --git a/applications/common/src/main/java/org/onap/policy/pdp/xacml/application/common/matchable/MatchablePropertyTypeBoolean.java b/applications/common/src/main/java/org/onap/policy/pdp/xacml/application/common/matchable/MatchablePropertyTypeBoolean.java index d3b16c21..8ea65307 100644 --- a/applications/common/src/main/java/org/onap/policy/pdp/xacml/application/common/matchable/MatchablePropertyTypeBoolean.java +++ b/applications/common/src/main/java/org/onap/policy/pdp/xacml/application/common/matchable/MatchablePropertyTypeBoolean.java @@ -3,6 +3,7 @@ * ONAP * ================================================================================ * Copyright (C) 2020 AT&T Intellectual Property. All rights reserved. + * Modifications Copyright (C) 2020 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -24,8 +25,8 @@ package org.onap.policy.pdp.xacml.application.common.matchable; import com.att.research.xacml.api.Identifier; import com.att.research.xacml.api.XACML3; -import org.onap.policy.models.tosca.authorative.concepts.ToscaEntrySchema; import org.onap.policy.models.tosca.authorative.concepts.ToscaProperty; +import org.onap.policy.models.tosca.authorative.concepts.ToscaSchemaDefinition; import org.onap.policy.pdp.xacml.application.common.ToscaPolicyConversionException; import org.onap.policy.pdp.xacml.application.common.ToscaPolicyTranslatorUtils; @@ -35,7 +36,7 @@ public class MatchablePropertyTypeBoolean extends MatchablePropertyTypeBase<Bool super(inProperty); } - public MatchablePropertyTypeBoolean(ToscaEntrySchema toscaSchema) { + public MatchablePropertyTypeBoolean(ToscaSchemaDefinition toscaSchema) { super(toscaSchema); } diff --git a/applications/common/src/main/java/org/onap/policy/pdp/xacml/application/common/matchable/MatchablePropertyTypeFloat.java b/applications/common/src/main/java/org/onap/policy/pdp/xacml/application/common/matchable/MatchablePropertyTypeFloat.java index 5231ca62..bc702c1c 100644 --- a/applications/common/src/main/java/org/onap/policy/pdp/xacml/application/common/matchable/MatchablePropertyTypeFloat.java +++ b/applications/common/src/main/java/org/onap/policy/pdp/xacml/application/common/matchable/MatchablePropertyTypeFloat.java @@ -3,6 +3,7 @@ * ONAP * ================================================================================ * Copyright (C) 2020 AT&T Intellectual Property. All rights reserved. + * Modifications Copyright (C) 2020 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -24,8 +25,8 @@ package org.onap.policy.pdp.xacml.application.common.matchable; import com.att.research.xacml.api.Identifier; import com.att.research.xacml.api.XACML3; -import org.onap.policy.models.tosca.authorative.concepts.ToscaEntrySchema; import org.onap.policy.models.tosca.authorative.concepts.ToscaProperty; +import org.onap.policy.models.tosca.authorative.concepts.ToscaSchemaDefinition; import org.onap.policy.pdp.xacml.application.common.ToscaPolicyConversionException; import org.onap.policy.pdp.xacml.application.common.ToscaPolicyTranslatorUtils; @@ -35,7 +36,7 @@ public class MatchablePropertyTypeFloat extends MatchablePropertyTypeBase<Float> super(inProperty); } - public MatchablePropertyTypeFloat(ToscaEntrySchema toscaSchema) { + public MatchablePropertyTypeFloat(ToscaSchemaDefinition toscaSchema) { super(toscaSchema); } diff --git a/applications/common/src/main/java/org/onap/policy/pdp/xacml/application/common/matchable/MatchablePropertyTypeInteger.java b/applications/common/src/main/java/org/onap/policy/pdp/xacml/application/common/matchable/MatchablePropertyTypeInteger.java index ea798a5a..b23d344f 100644 --- a/applications/common/src/main/java/org/onap/policy/pdp/xacml/application/common/matchable/MatchablePropertyTypeInteger.java +++ b/applications/common/src/main/java/org/onap/policy/pdp/xacml/application/common/matchable/MatchablePropertyTypeInteger.java @@ -3,6 +3,7 @@ * ONAP * ================================================================================ * Copyright (C) 2020 AT&T Intellectual Property. All rights reserved. + * Modifications Copyright (C) 2020 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -24,8 +25,8 @@ package org.onap.policy.pdp.xacml.application.common.matchable; import com.att.research.xacml.api.Identifier; import com.att.research.xacml.api.XACML3; -import org.onap.policy.models.tosca.authorative.concepts.ToscaEntrySchema; import org.onap.policy.models.tosca.authorative.concepts.ToscaProperty; +import org.onap.policy.models.tosca.authorative.concepts.ToscaSchemaDefinition; import org.onap.policy.pdp.xacml.application.common.ToscaPolicyConversionException; import org.onap.policy.pdp.xacml.application.common.ToscaPolicyTranslatorUtils; @@ -35,7 +36,7 @@ public class MatchablePropertyTypeInteger extends MatchablePropertyTypeBase<Inte super(inProperty); } - public MatchablePropertyTypeInteger(ToscaEntrySchema toscaSchema) { + public MatchablePropertyTypeInteger(ToscaSchemaDefinition toscaSchema) { super(toscaSchema); } diff --git a/applications/common/src/main/java/org/onap/policy/pdp/xacml/application/common/matchable/MatchablePropertyTypeList.java b/applications/common/src/main/java/org/onap/policy/pdp/xacml/application/common/matchable/MatchablePropertyTypeList.java index 7b19ad47..52f4ae11 100644 --- a/applications/common/src/main/java/org/onap/policy/pdp/xacml/application/common/matchable/MatchablePropertyTypeList.java +++ b/applications/common/src/main/java/org/onap/policy/pdp/xacml/application/common/matchable/MatchablePropertyTypeList.java @@ -3,6 +3,7 @@ * ONAP * ================================================================================ * Copyright (C) 2020 AT&T Intellectual Property. All rights reserved. + * Modifications Copyright (C) 2020 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -26,8 +27,8 @@ import com.att.research.xacml.api.Identifier; import java.util.Collections; import java.util.List; import oasis.names.tc.xacml._3_0.core.schema.wd_17.AnyOfType; -import org.onap.policy.models.tosca.authorative.concepts.ToscaEntrySchema; import org.onap.policy.models.tosca.authorative.concepts.ToscaProperty; +import org.onap.policy.models.tosca.authorative.concepts.ToscaSchemaDefinition; import org.onap.policy.pdp.xacml.application.common.ToscaPolicyConversionException; import org.onap.policy.pdp.xacml.application.common.ToscaPolicyTranslatorUtils; @@ -42,7 +43,7 @@ public class MatchablePropertyTypeList extends MatchablePropertyTypeBase<List<Ma public MatchablePropertyTypeList(ToscaProperty toscaProperty) { super(toscaProperty); - ToscaEntrySchema schema = toscaProperty.getEntrySchema(); + ToscaSchemaDefinition schema = toscaProperty.getEntrySchema(); this.primitiveProperty = MatchablePolicyType.handlePrimitive(schema.getType(), schema); } diff --git a/applications/common/src/main/java/org/onap/policy/pdp/xacml/application/common/matchable/MatchablePropertyTypeMap.java b/applications/common/src/main/java/org/onap/policy/pdp/xacml/application/common/matchable/MatchablePropertyTypeMap.java index d5083e1b..5687e251 100644 --- a/applications/common/src/main/java/org/onap/policy/pdp/xacml/application/common/matchable/MatchablePropertyTypeMap.java +++ b/applications/common/src/main/java/org/onap/policy/pdp/xacml/application/common/matchable/MatchablePropertyTypeMap.java @@ -3,6 +3,7 @@ * ONAP * ================================================================================ * Copyright (C) 2020 AT&T Intellectual Property. All rights reserved. + * Modifications Copyright (C) 2020 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -29,8 +30,8 @@ import java.util.Map; import java.util.Map.Entry; import lombok.NonNull; import oasis.names.tc.xacml._3_0.core.schema.wd_17.AnyOfType; -import org.onap.policy.models.tosca.authorative.concepts.ToscaEntrySchema; import org.onap.policy.models.tosca.authorative.concepts.ToscaProperty; +import org.onap.policy.models.tosca.authorative.concepts.ToscaSchemaDefinition; import org.onap.policy.pdp.xacml.application.common.ToscaPolicyConversionException; import org.onap.policy.pdp.xacml.application.common.ToscaPolicyTranslatorUtils; @@ -45,7 +46,7 @@ public class MatchablePropertyTypeMap extends MatchablePropertyTypeBase<Map<Stri public MatchablePropertyTypeMap(@NonNull ToscaProperty toscaProperty) { super(toscaProperty); - ToscaEntrySchema schema = toscaProperty.getEntrySchema(); + ToscaSchemaDefinition schema = toscaProperty.getEntrySchema(); this.primitiveProperty = MatchablePolicyType.handlePrimitive(schema.getType(), schema); } diff --git a/applications/common/src/main/java/org/onap/policy/pdp/xacml/application/common/matchable/MatchablePropertyTypeString.java b/applications/common/src/main/java/org/onap/policy/pdp/xacml/application/common/matchable/MatchablePropertyTypeString.java index 4605b845..83e9bc56 100644 --- a/applications/common/src/main/java/org/onap/policy/pdp/xacml/application/common/matchable/MatchablePropertyTypeString.java +++ b/applications/common/src/main/java/org/onap/policy/pdp/xacml/application/common/matchable/MatchablePropertyTypeString.java @@ -3,6 +3,7 @@ * ONAP * ================================================================================ * Copyright (C) 2020 AT&T Intellectual Property. All rights reserved. + * Modifications Copyright (C) 2020 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -24,8 +25,8 @@ package org.onap.policy.pdp.xacml.application.common.matchable; import com.att.research.xacml.api.Identifier; import com.att.research.xacml.api.XACML3; -import org.onap.policy.models.tosca.authorative.concepts.ToscaEntrySchema; import org.onap.policy.models.tosca.authorative.concepts.ToscaProperty; +import org.onap.policy.models.tosca.authorative.concepts.ToscaSchemaDefinition; import org.onap.policy.pdp.xacml.application.common.ToscaPolicyTranslatorUtils; public class MatchablePropertyTypeString extends MatchablePropertyTypeBase<String> { @@ -34,7 +35,7 @@ public class MatchablePropertyTypeString extends MatchablePropertyTypeBase<Strin super(toscaProperty); } - public MatchablePropertyTypeString(ToscaEntrySchema toscaSchema) { + public MatchablePropertyTypeString(ToscaSchemaDefinition toscaSchema) { super(toscaSchema); } diff --git a/applications/common/src/main/java/org/onap/policy/pdp/xacml/application/common/matchable/MatchablePropertyTypeTimestamp.java b/applications/common/src/main/java/org/onap/policy/pdp/xacml/application/common/matchable/MatchablePropertyTypeTimestamp.java index d24147cd..71ea55e8 100644 --- a/applications/common/src/main/java/org/onap/policy/pdp/xacml/application/common/matchable/MatchablePropertyTypeTimestamp.java +++ b/applications/common/src/main/java/org/onap/policy/pdp/xacml/application/common/matchable/MatchablePropertyTypeTimestamp.java @@ -3,6 +3,7 @@ * ONAP * ================================================================================ * Copyright (C) 2020 AT&T Intellectual Property. All rights reserved. + * Modifications Copyright (C) 2020 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -26,8 +27,8 @@ import com.att.research.xacml.api.Identifier; import com.att.research.xacml.api.XACML3; import com.att.research.xacml.std.datatypes.ISO8601DateTime; import java.text.ParseException; -import org.onap.policy.models.tosca.authorative.concepts.ToscaEntrySchema; import org.onap.policy.models.tosca.authorative.concepts.ToscaProperty; +import org.onap.policy.models.tosca.authorative.concepts.ToscaSchemaDefinition; import org.onap.policy.pdp.xacml.application.common.ToscaPolicyConversionException; import org.onap.policy.pdp.xacml.application.common.ToscaPolicyTranslatorUtils; @@ -37,7 +38,7 @@ public class MatchablePropertyTypeTimestamp extends MatchablePropertyTypeBase<IS super(inProperty); } - public MatchablePropertyTypeTimestamp(ToscaEntrySchema toscaSchema) { + public MatchablePropertyTypeTimestamp(ToscaSchemaDefinition toscaSchema) { super(toscaSchema); } diff --git a/applications/common/src/test/java/org/onap/policy/pdp/xacml/application/common/matchable/MatchablePolicyTypeTest.java b/applications/common/src/test/java/org/onap/policy/pdp/xacml/application/common/matchable/MatchablePolicyTypeTest.java index 508b96ea..e157f174 100644 --- a/applications/common/src/test/java/org/onap/policy/pdp/xacml/application/common/matchable/MatchablePolicyTypeTest.java +++ b/applications/common/src/test/java/org/onap/policy/pdp/xacml/application/common/matchable/MatchablePolicyTypeTest.java @@ -48,10 +48,10 @@ import org.onap.policy.common.utils.coder.CoderException; import org.onap.policy.common.utils.coder.StandardYamlCoder; import org.onap.policy.common.utils.resources.ResourceUtils; import org.onap.policy.models.tosca.authorative.concepts.ToscaDataType; -import org.onap.policy.models.tosca.authorative.concepts.ToscaEntrySchema; import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicy; import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyType; import org.onap.policy.models.tosca.authorative.concepts.ToscaProperty; +import org.onap.policy.models.tosca.authorative.concepts.ToscaSchemaDefinition; import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate; import org.onap.policy.models.tosca.simple.concepts.JpaToscaServiceTemplate; import org.onap.policy.pdp.xacml.application.common.ToscaDictionary; @@ -128,7 +128,7 @@ public class MatchablePolicyTypeTest implements MatchableCallback { // // Unlikely these would be called - just get code coverage on them // - ToscaEntrySchema schema = new ToscaEntrySchema(); + ToscaSchemaDefinition schema = new ToscaSchemaDefinition(); schema.setType("integer"); assertThat(MatchablePolicyType.handlePrimitive("foo", schema)).isNotNull(); schema.setType("float"); @@ -183,7 +183,7 @@ public class MatchablePolicyTypeTest implements MatchableCallback { assertThatExceptionOfType(ToscaPolicyConversionException.class).isThrownBy(() -> timestampValue.validate("foo")); - ToscaEntrySchema schema = new ToscaEntrySchema(); + ToscaSchemaDefinition schema = new ToscaSchemaDefinition(); schema.setType("string"); property.setEntrySchema(schema); MatchablePropertyTypeMap mapValue = new MatchablePropertyTypeMap(property); |