Adding safegaurd when adding new relationships. 65/23365/1
authorShwetank Dave <shwetank.dave@amdocs.com>
Mon, 13 Nov 2017 15:31:07 +0000 (10:31 -0500)
committerShwetank Dave <shwetank.dave@amdocs.com>
Mon, 13 Nov 2017 15:33:00 +0000 (10:33 -0500)
When creating new relationships use POST,
if PUT is used, it should return 400 BAD_REQUEST.

When deleting relationships, ID should be passed
in the URL.

IssueID: AAI-463
Change-Id: I6dbe84707d54c509da3a01feb52e1b52f462f9bc
Signed-off-by: Shwetank Dave <shwetank.dave@amdocs.com>
src/main/java/org/openecomp/crud/service/CrudRestService.java

index 09193ad..bef7b04 100644 (file)
@@ -221,6 +221,21 @@ public class CrudRestService {
     return response;
   }
 
+  @PUT
+  @Path("/relationships/{version}/{type}/")
+  @Consumes({MediaType.APPLICATION_JSON})
+  @Produces({MediaType.APPLICATION_JSON})
+  public Response updateEdgeWithoutId(String content, @Context HttpHeaders headers, @Context HttpServletRequest req) {
+
+    LoggingUtil.initMdcContext(req, headers);
+
+    logger.debug("Incoming request..." + content);
+    Response response = Response.status (Status.BAD_REQUEST).entity ("Cannot Update Edge Without Specifying Id in URL").build();
+
+    LoggingUtil.logRestRequest(logger, auditLogger, req, response);
+    return response;
+  }
+
   @PUT
   @Path("/relationships/{version}/{type}/{id}")
   @Consumes({MediaType.APPLICATION_JSON})
@@ -621,6 +636,20 @@ public class CrudRestService {
     return response;
   }
 
+  @DELETE
+  @Path("/relationships/{version}/{type}/")
+  @Consumes({MediaType.APPLICATION_JSON})
+  @Produces({MediaType.APPLICATION_JSON})
+  public Response deleteEdgeWithouId(String content, @Context HttpHeaders headers, @Context HttpServletRequest req) {
+
+    LoggingUtil.initMdcContext(req, headers);
+
+    logger.debug("Incoming request..." + content);
+    Response response = Response.status ( Status.BAD_REQUEST ).entity ( "Cannot Delete Edge Without Specifying Id in URL" ).build ();
+    LoggingUtil.logRestRequest(logger, auditLogger, req, response);
+    return response;
+  }
+
   @DELETE
   @Path("/relationships/{version}/{type}/{id}")
   @Consumes({MediaType.APPLICATION_JSON})