X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=src%2Fmain%2Fjava%2Forg%2Fonap%2Fcrud%2Fservice%2FCrudRestService.java;h=2af205a34115b7f2e5c05b6a6fe7062763c4b34c;hb=d41ef90610aadb5aa3372d5922155e4fc4e0a407;hp=895b45953744571df18fbb216baf687adf3b5245;hpb=1bb61ff3e013bcd41beffc5d9f01964f422f8a9e;p=aai%2Fgizmo.git diff --git a/src/main/java/org/onap/crud/service/CrudRestService.java b/src/main/java/org/onap/crud/service/CrudRestService.java index 895b459..2af205a 100644 --- a/src/main/java/org/onap/crud/service/CrudRestService.java +++ b/src/main/java/org/onap/crud/service/CrudRestService.java @@ -1,27 +1,23 @@ /** * ============LICENSE_START======================================================= - * Gizmo + * org.onap.aai * ================================================================================ - * Copyright © 2017 AT&T Intellectual Property. - * Copyright © 2017 Amdocs - * All rights reserved. + * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved. + * Copyright © 2017-2018 Amdocs * ================================================================================ * 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 - *

+ * + * 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. * ============LICENSE_END========================================================= - *

- * ECOMP is a trademark and service mark of AT&T Intellectual Property. */ - package org.onap.crud.service; import com.google.gson.JsonElement; @@ -76,6 +72,13 @@ public class CrudRestService { this.graphDataService = graphDataService; this.auth = new Auth(CrudServiceConstants.CRD_AUTH_FILE); } + + // For unit testing + public CrudRestService(AbstractGraphDataService graphDataService, Auth auth) throws Exception { + this.graphDataService = graphDataService; + this.auth = auth; + } + public enum Action { POST, GET, PUT, DELETE, PATCH @@ -97,10 +100,14 @@ public class CrudRestService { logger.debug("Incoming request..." + content); Response response = null; + Map params = new HashMap(); + for (Map.Entry> e : uriInfo.getQueryParameters().entrySet()) { + params.put(e.getKey(), e.getValue().get(0)); + } try { if (validateRequest(req, uri, content, Action.GET, CrudServiceConstants.CRD_AUTH_POLICY_NAME, headers)) { - String result = graphDataService.getVertex(version, id, type); + String result = graphDataService.getVertex(version, id, type, params); response = Response.status(Status.OK).entity(result).type(mediaType).build(); } else { response = Response.status(Status.FORBIDDEN).entity(content).type(MediaType.APPLICATION_JSON).build(); @@ -175,11 +182,15 @@ public class CrudRestService { logger.debug("Incoming request..." + content); Response response = null; + Map params = new HashMap(); + for (Map.Entry> e : uriInfo.getQueryParameters().entrySet()) { + params.put(e.getKey(), e.getValue().get(0)); + } try { if (validateRequest(req, uri, content, Action.GET, CrudServiceConstants.CRD_AUTH_POLICY_NAME, headers)) { - String result = graphDataService.getEdge(version, id, type); + String result = graphDataService.getEdge(version, id, type, params); response = Response.status(Status.OK).entity(result).type(mediaType).build(); } else { response = Response.status(Status.FORBIDDEN).entity(content).type(MediaType.APPLICATION_JSON).build();