+ public Response aaiGetPnfUsingPnfName(@PathParam("pnfName") final String pnfName) {
+ return getResponse(pnfName, INVALID_PNF_FILE_NAME);
+ }
+
+ /**
+ * A&AI get PNF query using pnf-id.
+ *
+ * @return the result
+ */
+ @GET
+ @Path("/{version:v16|v21}/network/pnfs/pnf")
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Produces("application/json")
+ public Response aaiGetPnfUsingPnfId(@QueryParam("pnf-id") final String pnfId) {
+ return getResponse(pnfId, INVALID_PNF_FILE_NAME);
+ }
+
+ /**
+ * A&AI get VNF query using vnf-id.
+ *
+ * @return the result
+ */
+ @GET
+ @Path("/{version:v16|v21}/network/generic-vnfs/generic-vnf/{vnfId}")
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Produces("application/json")
+ public Response aaiGetVnfUsingVnfId(@PathParam("vnfId") final String vnfId) {
+ return getResponse(vnfId, INVALID_VNF_FILE_NAME);
+ }
+
+ /**
+ * A&AI get VNF query using vnf-name.
+ *
+ * @return the result
+ */
+ @GET
+ @Path("/{version:v16|v21}/network/generic-vnfs/generic-vnf")
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Produces("application/json")
+ public Response aaiGetVnfUsingVnfName(@QueryParam("vnf-name") final String vnfName) {
+ return getResponse(vnfName, INVALID_VNF_FILE_NAME);
+ }
+
+ private Response getResponse(final String expectedFileName, final String defaultFileName) {
+ String resourceLocation = getResourceLocation();
+ var responseString = ResourceUtils.getResourceAsString(resourceLocation + expectedFileName + DOT_JSON);
+ if (null == responseString) {
+ // if a response file is not found in expected location, look for it in default location
+ responseString = ResourceUtils.getResourceAsString(DEFAULT_RESOURCE_LOCATION + expectedFileName + DOT_JSON);
+ }
+ if (null != responseString) {
+ return Response.ok(responseString).build();
+ } else {
+ // if a response file is not available in expected or default location, return an appropriate 404 response
+ responseString = ResourceUtils.getResourceAsString(DEFAULT_RESOURCE_LOCATION + defaultFileName + DOT_JSON);
+ return Response.status(Response.Status.NOT_FOUND).entity(responseString).build();