From a42de79292d9541db7865b54e93be2d0b6e6a094 Mon Sep 17 00:00:00 2001 From: "serena.spinoso" Date: Thu, 7 Sep 2017 10:22:39 +0200 Subject: update verigraph JIRA: PARSER-154 code optimizations about graph manipulation and formula generation. Change-Id: Idebef19b128281aa2bc40d1aeab6e208c7ddd93d Signed-off-by: serena.spinoso --- .../escape/verify/resources/GraphResource.java | 167 --------------- .../escape/verify/resources/NeighbourResource.java | 141 ------------- .../escape/verify/resources/NodeResource.java | 230 --------------------- .../verify/resources/beans/VerificationBean.java | 67 ------ 4 files changed, 605 deletions(-) delete mode 100644 verigraph/src/main/java/it/polito/escape/verify/resources/GraphResource.java delete mode 100644 verigraph/src/main/java/it/polito/escape/verify/resources/NeighbourResource.java delete mode 100644 verigraph/src/main/java/it/polito/escape/verify/resources/NodeResource.java delete mode 100644 verigraph/src/main/java/it/polito/escape/verify/resources/beans/VerificationBean.java (limited to 'verigraph/src/main/java/it/polito/escape/verify/resources') diff --git a/verigraph/src/main/java/it/polito/escape/verify/resources/GraphResource.java b/verigraph/src/main/java/it/polito/escape/verify/resources/GraphResource.java deleted file mode 100644 index e610f1d..0000000 --- a/verigraph/src/main/java/it/polito/escape/verify/resources/GraphResource.java +++ /dev/null @@ -1,167 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2017 Politecnico di Torino and others. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Apache License, Version 2.0 - * which accompanies this distribution, and is available at - * http://www.apache.org/licenses/LICENSE-2.0 - *******************************************************************************/ - -package it.polito.escape.verify.resources; - -import java.net.URI; -import java.util.List; - -import javax.ws.rs.BeanParam; -import javax.ws.rs.Consumes; -import javax.ws.rs.DELETE; -import javax.ws.rs.GET; -import javax.ws.rs.POST; -import javax.ws.rs.PUT; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.Produces; -import javax.ws.rs.core.Context; -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.Response; -import javax.ws.rs.core.UriInfo; - -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiOperation; -import io.swagger.annotations.ApiParam; -import io.swagger.annotations.ApiResponse; -import io.swagger.annotations.ApiResponses; -import it.polito.escape.verify.model.ErrorMessage; -import it.polito.escape.verify.model.Graph; -import it.polito.escape.verify.model.Verification; -import it.polito.escape.verify.resources.beans.VerificationBean; -import it.polito.escape.verify.service.GraphService; -import it.polito.escape.verify.service.VerificationService; - -@Path("/graphs") -@Api(value = "/graphs", description = "Manage graphs") -@Consumes(MediaType.APPLICATION_JSON) -@Produces(MediaType.APPLICATION_JSON) -public class GraphResource { - GraphService graphService = new GraphService(); - VerificationService verificationService = new VerificationService(); - - @GET - @ApiOperation( httpMethod = "GET", - value = "Returns all graphs", - notes = "Returns an array of graphs", - response = Graph.class, - responseContainer = "List") - @ApiResponses(value = { @ApiResponse( code = 200, - message = "All the graphs have been returned in the message body", - response = Graph.class, - responseContainer = "List"), - @ApiResponse(code = 500, message = "Internal server error", response = ErrorMessage.class)}) - public List getGraphs() { - return graphService.getAllGraphs(); - } - - @POST - @ApiOperation( httpMethod = "POST", - value = "Creates a graph", - notes = "Creates a signle graph", - response = Response.class) - @ApiResponses(value = { @ApiResponse(code = 400, message = "Invalid graph supplied", response = ErrorMessage.class), - @ApiResponse(code = 500, message = "Internal server error", response = ErrorMessage.class), - @ApiResponse(code = 201, message = "Graph successfully created", response = Graph.class) }) - public Response addGraph( @ApiParam(value = "New graph object", required = true) Graph graph, - @Context UriInfo uriInfo) { - Graph newGraph = graphService.addGraph(graph); - String newId = String.valueOf(newGraph.getId()); - URI uri = uriInfo.getAbsolutePathBuilder().path(newId).build(); - return Response.created(uri).entity(newGraph).build(); - } - - @GET - @Path("/{graphId}") - @ApiOperation( httpMethod = "GET", - value = "Returns a graph", - notes = "Returns a signle graph", - response = Graph.class) - @ApiResponses(value = { @ApiResponse(code = 403, message = "Invalid graph id", response = ErrorMessage.class), - @ApiResponse(code = 404, message = "Graph not found", response = ErrorMessage.class), - @ApiResponse(code = 500, message = "Internal server error", response = ErrorMessage.class), - @ApiResponse( code = 200, - message = "The requested graph has been returned in the message body", - response = Graph.class) }) - public Graph getGraph( @ApiParam(value = "Graph id", required = true) @PathParam("graphId") long graphId, - @Context UriInfo uriInfo) { - Graph graph = graphService.getGraph(graphId); - graph.addLink(getUriForSelf(uriInfo, graph), "self"); - graph.addLink(getUriForNodes(uriInfo, graph), "nodes"); - return graph; - } - - @PUT - @Path("/{graphId}") - @ApiOperation(httpMethod = "PUT", value = "Edits a graph", notes = "Edits a single graph", response = Graph.class) - @ApiResponses(value = { @ApiResponse(code = 400, message = "Invalid graph object", response = ErrorMessage.class), - @ApiResponse(code = 403, message = "Invalid graph id", response = ErrorMessage.class), - @ApiResponse(code = 404, message = "Graph not found", response = ErrorMessage.class), - @ApiResponse(code = 500, message = "Internal server error", response = ErrorMessage.class), - @ApiResponse(code = 200, message = "Graph edited successfully", response = Graph.class) }) - public Graph updateGraph( @ApiParam(value = "Graph id", required = true) @PathParam("graphId") long id, - @ApiParam(value = "Updated graph object", required = true) Graph graph) { - graph.setId(id); - return graphService.updateGraph(graph); - } - - @DELETE - @Path("/{graphId}") - @ApiOperation(httpMethod = "DELETE", value = "Deletes a graph", notes = "Deletes a signle graph") - @ApiResponses(value = { @ApiResponse(code = 403, message = "Invalid graph id", response = ErrorMessage.class), - @ApiResponse(code = 500, message = "Internal server error", response = ErrorMessage.class), - @ApiResponse(code = 204, message = "Graph successfully deleted") }) - public void deleteGraph(@ApiParam(value = "Graph id", required = true) @PathParam("graphId") long id) { - graphService.removeGraph(id); - } - - @GET - @Path("/{graphId}/policy") - @ApiOperation( httpMethod = "GET", - value = "Verifies a given policy in a graph", - notes = "In order to verify a given policy (e.g. 'reachability') all nodes of the desired graph must have a valid configuration.") - @ApiResponses(value = { @ApiResponse( code = 403, - message = "Invalid graph id or invalid configuration for source and/or destination node", - response = ErrorMessage.class), - @ApiResponse( code = 404, - message = "Graph not found or source node not found or destination node not found or configuration for source and/or destination node not available", - response = ErrorMessage.class), - @ApiResponse(code = 500, message = "Internal server error", response = ErrorMessage.class),}) - public Verification verifyGraph(@ApiParam(value = "Graph id", required = true) @PathParam("graphId") long graphId, - @ApiParam( value = "'source' and 'destination' must refer to names of existing nodes in the same graph, 'type' refers to the required verification between the two (e.g. 'reachability')", - required = true) @BeanParam VerificationBean verificationBean) { - - return verificationService.verify(graphId, verificationBean); - } - - private String getUriForSelf(UriInfo uriInfo, Graph graph) { - String uri = uriInfo.getBaseUriBuilder() - .path(GraphResource.class) - .path(Long.toString(graph.getId())) - .build() - .toString(); - return uri; - } - - private String getUriForNodes(UriInfo uriInfo, Graph graph) { - String uri = uriInfo.getBaseUriBuilder() - .path(GraphResource.class) - .path(GraphResource.class, "getNodeResource") - // .path(NodeResource.class) - .resolveTemplate("graphId", graph.getId()) - .build() - .toString(); - return uri; - } - - @Path("/{graphId}/nodes") - public NodeResource getNodeResource() { - return new NodeResource(); - } -} diff --git a/verigraph/src/main/java/it/polito/escape/verify/resources/NeighbourResource.java b/verigraph/src/main/java/it/polito/escape/verify/resources/NeighbourResource.java deleted file mode 100644 index 63376da..0000000 --- a/verigraph/src/main/java/it/polito/escape/verify/resources/NeighbourResource.java +++ /dev/null @@ -1,141 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2017 Politecnico di Torino and others. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Apache License, Version 2.0 - * which accompanies this distribution, and is available at - * http://www.apache.org/licenses/LICENSE-2.0 - *******************************************************************************/ - -package it.polito.escape.verify.resources; - -import java.net.URI; -import java.util.List; - -import javax.ws.rs.Consumes; -import javax.ws.rs.DELETE; -import javax.ws.rs.GET; -import javax.ws.rs.POST; -import javax.ws.rs.PUT; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.Produces; -import javax.ws.rs.core.Context; -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.Response; -import javax.ws.rs.core.UriInfo; - -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiOperation; -import io.swagger.annotations.ApiParam; -import io.swagger.annotations.ApiResponse; -import io.swagger.annotations.ApiResponses; -import it.polito.escape.verify.model.ErrorMessage; -import it.polito.escape.verify.model.Neighbour; -import it.polito.escape.verify.service.NeighbourService; - -//@Path("/") -@Api( hidden= true, value = "", description = "Manage neighbours" ) -@Produces(MediaType.APPLICATION_JSON) -@Consumes(MediaType.APPLICATION_JSON) -public class NeighbourResource { - private NeighbourService neighboursService = new NeighbourService(); - - @GET - @ApiOperation( - httpMethod = "GET", - value = "Returns all neighbours of a given node belonging to a given graph", - notes = "Returns an array of neighbours of a given node belonging to a given graph", - response = Neighbour.class, - responseContainer = "List") - @ApiResponses(value = { @ApiResponse(code = 403, message = "Invalid graph and/or node id", response=ErrorMessage.class), - @ApiResponse(code = 404, message = "Graph and/or node not found", response=ErrorMessage.class), - @ApiResponse(code = 500, message = "Internal server error", response = ErrorMessage.class), - @ApiResponse(code = 200, message = "All the neighbours have been returned in the message body", response=Neighbour.class, responseContainer="List")}) - public List getAllNeighbours( - @ApiParam(value = "Graph id", required = true) @PathParam("graphId") long graphId, - @ApiParam(value = "Node id", required = true) @PathParam("nodeId") long nodeId){ - return neighboursService.getAllNeighbours(graphId, nodeId); - } - - @POST - @ApiOperation( - httpMethod = "POST", - value = "Adds a neighbour to a given node belonging to a given graph", - notes = "Adds single neighbour to a given node belonging to a given graph", - response = Neighbour.class) - @ApiResponses(value = { @ApiResponse(code = 403, message = "Invalid graph and/or node id", response=ErrorMessage.class), - @ApiResponse(code = 404, message = "Graph and/or node not found", response=ErrorMessage.class), - @ApiResponse(code = 400, message = "Invalid neighbour object", response=ErrorMessage.class), - @ApiResponse(code = 500, message = "Internal server error", response = ErrorMessage.class), - @ApiResponse(code = 201, message = "Neighbour successfully created", response=Neighbour.class)}) - public Response addNeighbour( - @ApiParam(value = "Graph id", required = true) @PathParam("graphId") long graphId, - @ApiParam(value = "Node id", required = true) @PathParam("nodeId") long nodeId, - @ApiParam(value = "New neighbour object. Neighbour name must refer to the name of an existing node of the same graph", required = true) Neighbour neighbour, - @Context UriInfo uriInfo){ - Neighbour newNeighbour = neighboursService.addNeighbour(graphId, nodeId, neighbour); - String newId = String.valueOf(newNeighbour.getId()); - URI uri = uriInfo.getAbsolutePathBuilder().path(newId).build(); - return Response.created(uri) - .entity(newNeighbour) - .build(); - } - - @PUT - @Path("{neighbourId}") - @ApiOperation( - httpMethod = "PUT", - value = "Edits a neighbour of a given node belonging to a given graph", - notes = "Edits a single neighbour of a given node belonging to a given graph", - response = Neighbour.class) - @ApiResponses(value = { @ApiResponse(code = 403, message = "Invalid graph and/or node and/or neighbour id", response=ErrorMessage.class), - @ApiResponse(code = 404, message = "Graph and/or node and /or neighbour not found", response=ErrorMessage.class), - @ApiResponse(code = 400, message = "Invalid neighbour object", response=ErrorMessage.class), - @ApiResponse(code = 500, message = "Internal server error", response = ErrorMessage.class), - @ApiResponse(code = 200, message = "Neighbour edited successfully", response=Neighbour.class)}) - public Neighbour updateNeighbour( - @ApiParam(value = "Graph id", required = true) @PathParam("graphId") long graphId, - @ApiParam(value = "Node id", required = true) @PathParam("nodeId") long nodeId, - @ApiParam(value = "Neighbour id", required = true) @PathParam("neighbourId") long neighbourId, - @ApiParam(value = "Updated neighbour object. Neighbour name must refer to the name of an existing node of the same graph", required = true) Neighbour neighbour){ - neighbour.setId(neighbourId); - return neighboursService.updateNeighbour(graphId, nodeId, neighbour); - } - - @DELETE - @Path("{neighbourId}") - @ApiOperation( - httpMethod = "DELETE", - value = "Removes a neighbour from a given node belonging to a given graph", - notes = "Deletes a single neighbour of a given node belonging to a given graph", - response = Neighbour.class) - @ApiResponses(value = { @ApiResponse(code = 403, message = "Invalid graph and/or node and/or neighbour id", response=ErrorMessage.class), - @ApiResponse(code = 404, message = "Graph and/or node not found", response=ErrorMessage.class), - @ApiResponse(code = 500, message = "Internal server error", response = ErrorMessage.class), - @ApiResponse(code = 204, message = "Node successfully deleted")}) - public void deleteNeighbour( - @ApiParam(value = "Graph id", required = true) @PathParam("graphId") long graphId, - @ApiParam(value = "Node id", required = true) @PathParam("nodeId") long nodeId, - @ApiParam(value = "Neighbour id", required = true) @PathParam("neighbourId") long neighbourId){ - neighboursService.removeNeighbour(graphId, nodeId, neighbourId); - } - - @GET - @Path("{neighbourId}") - @ApiOperation( - httpMethod = "GET", - value = "Returns a neighbour of a given node belonging to a given graph", - notes = "Returns a single neighbour of a given node belonging to a given graph", - response = Neighbour.class) - @ApiResponses(value = { @ApiResponse(code = 403, message = "Invalid graph and/or node and/or neighbour id", response=ErrorMessage.class), - @ApiResponse(code = 404, message = "Graph and/or node and /or neighbour not found", response=ErrorMessage.class), - @ApiResponse(code = 500, message = "Internal server error", response = ErrorMessage.class), - @ApiResponse(code = 200, message = "The requested neighbour has been returned in the message body", response=Neighbour.class)}) - public Neighbour getNeighbour( - @ApiParam(value = "Graph id", required = true) @PathParam("graphId") long graphId, - @ApiParam(value = "Node id", required = true) @PathParam("nodeId") long nodeId, - @ApiParam(value = "Neighbour id", required = true) @PathParam("neighbourId") long neighbourId){ - return neighboursService.getNeighbour(graphId, nodeId, neighbourId); - } -} diff --git a/verigraph/src/main/java/it/polito/escape/verify/resources/NodeResource.java b/verigraph/src/main/java/it/polito/escape/verify/resources/NodeResource.java deleted file mode 100644 index 58d4064..0000000 --- a/verigraph/src/main/java/it/polito/escape/verify/resources/NodeResource.java +++ /dev/null @@ -1,230 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2017 Politecnico di Torino and others. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Apache License, Version 2.0 - * which accompanies this distribution, and is available at - * http://www.apache.org/licenses/LICENSE-2.0 - *******************************************************************************/ - -package it.polito.escape.verify.resources; - -import java.net.URI; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import javax.ws.rs.Consumes; -import javax.ws.rs.DELETE; -import javax.ws.rs.GET; -import javax.ws.rs.POST; -import javax.ws.rs.PUT; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.Produces; -import javax.ws.rs.core.Context; -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.Response; -import javax.ws.rs.core.UriInfo; - -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiOperation; -import io.swagger.annotations.ApiParam; -import io.swagger.annotations.ApiResponse; -import io.swagger.annotations.ApiResponses; -import it.polito.escape.verify.exception.BadRequestException; -import it.polito.escape.verify.exception.ForbiddenException; -import it.polito.escape.verify.model.Configuration; -import it.polito.escape.verify.model.ErrorMessage; -import it.polito.escape.verify.model.Graph; -import it.polito.escape.verify.model.Neighbour; -import it.polito.escape.verify.model.Node; -import it.polito.escape.verify.service.GraphService; -import it.polito.escape.verify.service.NodeService; - -@Api( hidden= true, value = "", description = "Manage nodes" ) -@Consumes(MediaType.APPLICATION_JSON) -@Produces(MediaType.APPLICATION_JSON) -public class NodeResource { - - NodeService nodeService = new NodeService(); - - - @GET - @ApiOperation( - httpMethod = "GET", - value = "Returns all nodes of a given graph", - notes = "Returns an array of nodes belonging to a given graph", - response = Node.class, - responseContainer = "List") - @ApiResponses(value = { @ApiResponse(code = 403, message = "Invalid graph id", response = ErrorMessage.class), - @ApiResponse(code = 404, message = "Graph not found", response = ErrorMessage.class), - @ApiResponse(code = 500, message = "Internal server error", response = ErrorMessage.class), - @ApiResponse(code = 200, message = "All the nodes have been returned in the message body", response = Node.class, responseContainer = "List") }) - public List getNodes(@ApiParam(value = "Graph id", required = true) @PathParam("graphId") long graphId){ - return nodeService.getAllNodes(graphId); - } - - @POST - @ApiOperation( - httpMethod = "POST", - value = "Creates a node in a given graph", - notes = "Creates a single node for a given graph", - response = Response.class) - @ApiResponses(value = { @ApiResponse(code = 400, message = "Invalid node supplied", response = ErrorMessage.class), - @ApiResponse(code = 403, message = "Invalid graph id", response = ErrorMessage.class), - @ApiResponse(code = 404, message = "Graph not found", response = ErrorMessage.class), - @ApiResponse(code = 500, message = "Internal server error", response = ErrorMessage.class), - @ApiResponse(code = 201, message = "Node successfully created", response = Node.class)}) - public Response addNode( - @ApiParam(value = "Graph id", required = true) @PathParam("graphId") long graphId, - @ApiParam(value = "New node object", required = true) Node node, - @Context UriInfo uriInfo) { - Node newNode = nodeService.addNode(graphId, node); - String newId = String.valueOf(newNode.getId()); - URI uri = uriInfo.getAbsolutePathBuilder().path(newId).build(); - return Response.created(uri) - .entity(newNode) - .build(); - } - - @GET - @Path("{nodeId}") - @ApiOperation( - httpMethod = "GET", - value = "Returns a node of a given graph", - notes = "Returns a single node of a given graph", - response = Node.class) - @ApiResponses(value = { @ApiResponse(code = 403, message = "Invalid graph and/or node id", response = ErrorMessage.class), - @ApiResponse(code = 404, message = "Graph and/or node not found", response = ErrorMessage.class), - @ApiResponse(code = 500, message = "Internal server error", response = ErrorMessage.class), - @ApiResponse(code = 200, message = "The requested node has been returned in the message body", response = Node.class)}) - public Node getNode( - @ApiParam(value = "Graph id", required = true) @PathParam("graphId") long graphId, - @ApiParam(value = "Node id", required = true) @PathParam("nodeId") long nodeId, - @Context UriInfo uriInfo){ - Node node = nodeService.getNode(graphId, nodeId); - node.addLink(getUriForSelf(uriInfo, graphId, node), "self"); - node.addLink(getUriForNeighbours(uriInfo, graphId, node), "neighbours"); - return node; - } - - @PUT - @Path("{nodeId}/configuration") - @ApiOperation( - httpMethod = "PUT", - value = "Adds/edits a configuration to a node of a given graph", - notes = "Configures a node. Once all the nodes of a graph have been configured a given policy can be verified for the graph (e.g. 'reachability' between two nodes).") - @ApiResponses(value = { @ApiResponse(code = 403, message = "Invalid graph and/or node id", response = ErrorMessage.class), - @ApiResponse(code = 404, message = "Graph and/or node not found", response = ErrorMessage.class), - @ApiResponse(code = 500, message = "Internal server error", response = ErrorMessage.class), - @ApiResponse(code = 200, message = "Configuration updated for the requested node")}) - public void addNodeConfiguration( - @ApiParam(value = "Graph id", required = true) @PathParam("graphId") long graphId, - @ApiParam(value = "Node id", required = true) @PathParam("nodeId") long nodeId, - @ApiParam(value = "Node configuration", required = true) Configuration nodeConfiguration, - @Context UriInfo uriInfo){ - if (graphId <= 0) { - throw new ForbiddenException("Illegal graph id: " + graphId); - } - if (nodeId <= 0) { - throw new ForbiddenException("Illegal node id: " + nodeId); - } - Graph graph = new GraphService().getGraph(graphId); - if (graph == null){ - throw new BadRequestException("Graph with id " + graphId + " not found"); - } - Node node = nodeService.getNode(graphId, nodeId); - if (node == null){ - throw new BadRequestException("Node with id " + nodeId + " not found in graph with id " + graphId); - } - Node nodeCopy = new Node(); - nodeCopy.setId(node.getId()); - nodeCopy.setName(node.getName()); - nodeCopy.setFunctional_type(node.getFunctional_type()); - Map nodes = new HashMap(); - nodes.putAll(node.getNeighbours()); - nodeCopy.setNeighbours(nodes); - nodeConfiguration.setId(nodeCopy.getName()); - nodeCopy.setConfiguration(nodeConfiguration); - - Graph graphCopy = new Graph(); - graphCopy.setId(graph.getId()); - graphCopy.setNodes(new HashMap(graph.getNodes())); - graphCopy.getNodes().remove(node.getId()); - - NodeService.validateNode(graphCopy, nodeCopy); - graph.getNodes().put(nodeId, nodeCopy); - } - - - @PUT - @Path("{nodeId}") - @ApiOperation( - httpMethod = "PUT", - value = "Edits a node of a given graph", - notes = "Edits a single node of a given graph", - response = Node.class) - @ApiResponses(value = { @ApiResponse(code = 400, message = "Invalid node object", response = ErrorMessage.class), - @ApiResponse(code = 403, message = "Invalid graph and/or node id", response = ErrorMessage.class), - @ApiResponse(code = 404, message = "Graph and/or node not found", response = ErrorMessage.class), - @ApiResponse(code = 500, message = "Internal server error", response = ErrorMessage.class), - @ApiResponse(code = 200, message = "Node edited successfully", response = Node.class)}) - public Node updateNode( - @ApiParam(value = "Graph id", required = true) @PathParam("graphId") long graphId, - @ApiParam(value = "Node id", required = true) @PathParam("nodeId") long nodeId, - @ApiParam(value = "Updated node object", required = true) Node node){ - node.setId(nodeId); - return nodeService.updateNode(graphId, node); - } - - @DELETE - @Path("{nodeId}") - @ApiOperation( - httpMethod = "DELETE", - value = "Deletes a node of a given graph", - notes = "Deletes a single node of a given graph") - @ApiResponses(value = { @ApiResponse(code = 403, message = "Invalid graph and/or node id", response = ErrorMessage.class), - @ApiResponse(code = 500, message = "Internal server error", response = ErrorMessage.class), - @ApiResponse(code = 204, message = "Node successfully deleted")}) - public void deleteNode( - @ApiParam(value = "Graph id", required = true) @PathParam("graphId") long graphId, - @ApiParam(value = "Node id", required = true) @PathParam("nodeId") long nodeId){ - nodeService.removeNode(graphId, nodeId); - } - - private String getUriForSelf(UriInfo uriInfo, long graphId, Node node) { - String uri = uriInfo.getBaseUriBuilder() - //.path(NodeResource.class) - .path(GraphResource.class) - .path(GraphResource.class, "getNodeResource") - .resolveTemplate("graphId", graphId) - .path(Long.toString(node.getId())) - .build() - .toString(); - return uri; - } - - private String getUriForNeighbours(UriInfo uriInfo, long graphId, Node node) { - String uri = uriInfo.getBaseUriBuilder() - .path(GraphResource.class) - .path(GraphResource.class, "getNodeResource") - .resolveTemplate("graphId", graphId) - .path(Long.toString(node.getId())) - .path("neighbours") - .build() - .toString(); -// .path(NodeResource.class) -// .path(NodeResource.class, "getNeighbourResource") -// .path(NeighbourResource.class) -// .resolveTemplate("nodeId", node.getId()) -// .build() -// .toString(); - return uri; - } - - @Path("{nodeId}/neighbours") - public NeighbourResource getNeighbourResource(){ - return new NeighbourResource(); - } -} diff --git a/verigraph/src/main/java/it/polito/escape/verify/resources/beans/VerificationBean.java b/verigraph/src/main/java/it/polito/escape/verify/resources/beans/VerificationBean.java deleted file mode 100644 index d6f9ca6..0000000 --- a/verigraph/src/main/java/it/polito/escape/verify/resources/beans/VerificationBean.java +++ /dev/null @@ -1,67 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2017 Politecnico di Torino and others. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Apache License, Version 2.0 - * which accompanies this distribution, and is available at - * http://www.apache.org/licenses/LICENSE-2.0 - *******************************************************************************/ - -package it.polito.escape.verify.resources.beans; - -import javax.ws.rs.QueryParam; - -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; - -@ApiModel("Verification") -public class VerificationBean { - - @ApiModelProperty(example = "webclient", value = "Source node. Must refer to an existing node of the same graph") - private @QueryParam("source") String source; - - @ApiModelProperty( example = "webserver", - value = "Destination node. Must refer to an existing node of the same graph") - private @QueryParam("destination") String destination; - - @ApiModelProperty( example = "reachability", - value = "Verification policy ('reachability', 'isolation', 'traversal')") - private @QueryParam("type") String type; - - @ApiModelProperty( example = "firewall", - value = "Absent if verification type is 'reachability', equal to the name of a middlebox to be avoided if verification type is 'isolation', equal to the name of a middlebox to be traversed if verification type is 'traversal'") - private @QueryParam("middlebox") String middlebox; - - public String getSource() { - return source; - } - - public void setSource(String source) { - this.source = source; - } - - public String getDestination() { - return destination; - } - - public void setDestination(String destination) { - this.destination = destination; - } - - public String getType() { - return type; - } - - public void setType(String type) { - this.type = type; - } - - public String getMiddlebox() { - return middlebox; - } - - public void setMiddlebox(String middlebox) { - this.middlebox = middlebox; - } - -} -- cgit 1.2.3-korg