From: Daniel Silverthorn Date: Mon, 29 Jan 2018 21:44:38 +0000 (-0500) Subject: Allow filtering by reserved properties X-Git-Tag: 2.0.0-ONAP~32 X-Git-Url: https://gerrit.onap.org/r/gitweb?p=aai%2Fgizmo.git;a=commitdiff_plain;h=1bb61ff3e013bcd41beffc5d9f01964f422f8a9e Allow filtering by reserved properties Change-Id: Ie43de57b63651fccb13147c9086276f0867a828c Issue-ID: AAI-702 Signed-off-by: Daniel Silverthorn --- diff --git a/src/main/java/org/onap/crud/service/CrudRestService.java b/src/main/java/org/onap/crud/service/CrudRestService.java index 2068709..895b459 100644 --- a/src/main/java/org/onap/crud/service/CrudRestService.java +++ b/src/main/java/org/onap/crud/service/CrudRestService.java @@ -133,9 +133,6 @@ public class CrudRestService { String propertiesKey = CrudProperties.get(CrudServiceConstants.CRD_COLLECTION_PROPERTIES_KEY); Map filter = new HashMap(); - for (Map.Entry> e : uriInfo.getQueryParameters().entrySet()) { - filter.put(e.getKey(), e.getValue().get(0)); - } for (Map.Entry> e : uriInfo.getQueryParameters().entrySet()) { if (!e.getKey().equals(propertiesKey)) { diff --git a/src/main/java/org/onap/schema/OxmModelValidator.java b/src/main/java/org/onap/schema/OxmModelValidator.java index 6260f83..ae3e18b 100644 --- a/src/main/java/org/onap/schema/OxmModelValidator.java +++ b/src/main/java/org/onap/schema/OxmModelValidator.java @@ -87,12 +87,18 @@ public class OxmModelValidator { } final DynamicType modelObjectType = jaxbContext.getDynamicType( CaseFormat.LOWER_CAMEL.to(CaseFormat.UPPER_CAMEL, CaseFormat.LOWER_HYPHEN.to(CaseFormat.UPPER_CAMEL, type))); + final DynamicType reservedObjectType = jaxbContext.getDynamicType("ReservedPropNames"); for (String key : filter.keySet()) { String keyJavaName = CaseFormat.LOWER_HYPHEN.to(CaseFormat.LOWER_CAMEL, key); - if (modelObjectType.getDescriptor().getMappingForAttributeName(keyJavaName) != null) { + DatabaseMapping mapping = modelObjectType.getDescriptor().getMappingForAttributeName(keyJavaName); + + // Try both the model for the specified type and the reserved properties for our key + if (mapping == null) { + mapping = reservedObjectType.getDescriptor().getMappingForAttributeName(keyJavaName); + } + if (mapping != null) { try { - DatabaseMapping mapping = modelObjectType.getDescriptor().getMappingForAttributeName(keyJavaName); Object value = CrudServiceUtil.validateFieldType(filter.get(key), mapping.getField().getType()); result.put(key, value); } catch (Exception ex) {