+ @ApiOperation(value = "Update Vertex" , notes = "# Payload \n"
+ + "{\r\n" +
+ " \"type\" :\"vertex type from oxm like comcast.nodes.sdwan.vpn\",\r\n" +
+ " \"properties\": {\r\n" +
+ " \"prop1\" : \"value\",\r\n" +
+ " \"prop2\" :\"value\",\r\n" +
+ " ..}\r\n" +
+ " }")
+ @ApiResponses({
+ @ApiResponse(code = 200, message = "Success"),
+ @ApiResponse(code = 403, message = "Forbidden"),
+ @ApiResponse(code = 400, message = "Bad Request"),
+ @ApiResponse(code = 404, message = "Not Found"),
+ @ApiResponse(code = 500, message = "Internal Server Error") })
+ @ApiImplicitParams({
+ @ApiImplicitParam(name = "X-FromAppId", required = true, dataType = "string", paramType = "header"),
+ @ApiImplicitParam(name = "X-TransactionId", required = true, dataType = "string", paramType = "header"),
+ })
+ @PUT
+ @Path("/{version}/{type}/{id}")
+ @Consumes({MediaType.APPLICATION_JSON})
+ @Produces({MediaType.APPLICATION_JSON})
+ public Response updateVertex(String content, @PathParam("version") @ApiParam(value="oxm model version",defaultValue="v13") String version, @PathParam("type") String type,
+ @PathParam("id") String id, @PathParam("uri") @Encoded @ApiParam(hidden=true) String uri, @Context HttpHeaders headers,
+ @Context UriInfo uriInfo, @Context HttpServletRequest req) {
+
+ LoggingUtil.initMdcContext(req, headers);
+ logger.debug("Incoming request..." + content);
+
+ ResponseBuilder responseBuilder;
+
+ try {
+ if (validateRequest(req, uri, content, Action.PUT, CrudServiceConstants.CRD_AUTH_POLICY_NAME, headers)) {
+ VertexPayload payload = VertexPayload.fromJson(content);
+ if (payload.getProperties() == null || payload.getProperties().isJsonNull()) {
+ throw new CrudException("Invalid request Payload", Status.BAD_REQUEST);
+ }
+ if (payload.getId() != null && !payload.getId().equals(id)) {
+ throw new CrudException("ID Mismatch", Status.BAD_REQUEST);
+ }
+
+ payload.setProperties(
+ CrudServiceUtil.mergeHeaderInFoToPayload(payload.getProperties(), headers, false));
+
+ ImmutablePair<EntityTag, String> result;
+ if (headers.getRequestHeaders().getFirst(HTTP_PATCH_METHOD_OVERRIDE) != null
+ && headers.getRequestHeaders().getFirst(HTTP_PATCH_METHOD_OVERRIDE).equalsIgnoreCase("PATCH")) {
+ result = graphDataService.patchVertex(version, id, type, payload);
+ responseBuilder =
+ Response.status(Status.OK).entity(result.getValue()).type(mediaType).tag(result.getKey());
+ } else {
+ result = graphDataService.updateVertex(version, id, type, payload);
+ responseBuilder =
+ Response.status(Status.OK).entity(result.getValue()).type(mediaType).tag(result.getKey());
+ }
+
+ } else {
+ responseBuilder = Response.status(Status.FORBIDDEN).entity(content).type(MediaType.APPLICATION_JSON);
+ }
+ } catch (CrudException ce) {
+ responseBuilder = Response.status(ce.getHttpStatus()).entity(ce.getMessage());
+ } catch (Exception e) {
+ responseBuilder = Response.status(Status.INTERNAL_SERVER_ERROR).entity(e.getMessage());
+ }