X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=blobdiff_plain;f=opendaylight%2Fnorthbound%2Fconnectionmanager%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fconnectionmanager%2Fnorthbound%2FConnectionManagerNorthbound.java;h=dde3210928689278af7d7f2e3103b0e78c114b47;hp=e2c1b32c4bf3ab129604d3e66763b3913f0f03d2;hb=31c83799d67d0bf4012aefedaba5356ebfaad8ab;hpb=b1e455ac4685602b7b3290192906c607d2c92c71 diff --git a/opendaylight/northbound/connectionmanager/src/main/java/org/opendaylight/controller/connectionmanager/northbound/ConnectionManagerNorthbound.java b/opendaylight/northbound/connectionmanager/src/main/java/org/opendaylight/controller/connectionmanager/northbound/ConnectionManagerNorthbound.java index e2c1b32c4b..dde3210928 100644 --- a/opendaylight/northbound/connectionmanager/src/main/java/org/opendaylight/controller/connectionmanager/northbound/ConnectionManagerNorthbound.java +++ b/opendaylight/northbound/connectionmanager/src/main/java/org/opendaylight/controller/connectionmanager/northbound/ConnectionManagerNorthbound.java @@ -27,6 +27,7 @@ import javax.ws.rs.core.Context; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; import javax.ws.rs.core.SecurityContext; +import javax.ws.rs.ext.ContextResolver; import org.codehaus.enunciate.jaxrs.ResponseCode; import org.codehaus.enunciate.jaxrs.StatusCodes; @@ -36,6 +37,7 @@ import org.opendaylight.controller.northbound.commons.exception.NotAcceptableExc import org.opendaylight.controller.northbound.commons.exception.ResourceNotFoundException; import org.opendaylight.controller.northbound.commons.exception.ServiceUnavailableException; import org.opendaylight.controller.northbound.commons.exception.UnauthorizedException; +import org.opendaylight.controller.northbound.commons.query.QueryContext; import org.opendaylight.controller.northbound.commons.utils.NorthboundUtils; import org.opendaylight.controller.sal.authorization.Privilege; import org.opendaylight.controller.sal.connection.ConnectionConstants; @@ -50,7 +52,14 @@ import org.opendaylight.controller.sal.utils.Status; @Path("/") public class ConnectionManagerNorthbound { private String username; + private QueryContext queryContext; + @Context + public void setQueryContext(ContextResolver queryCtxResolver) { + if (queryCtxResolver != null) { + queryContext = queryCtxResolver.getContext(QueryContext.class); + } + } @Context public void setSecurityContext(SecurityContext context) { if (context != null && context.getUserPrincipal() != null) username = context.getUserPrincipal().getName(); @@ -115,7 +124,8 @@ public class ConnectionManagerNorthbound { @ResponseCode(code = 406, condition = "Invalid Controller IP Address passed."), @ResponseCode(code = 503, condition = "Connection Manager Service not available")}) - public Nodes getNodes(@DefaultValue("") @QueryParam("controller") String controllerAddress) { + public Nodes getNodes(@DefaultValue("") @QueryParam("controller") String controllerAddress, + @QueryParam("_q") String queryString) { if (!NorthboundUtils.isAuthorized(getUserName(), "default", Privilege.READ, this)) { throw new UnauthorizedException("User is not authorized to perform this operation on container"); } @@ -140,7 +150,12 @@ public class ConnectionManagerNorthbound { } else { nodeSet = connectionManager.getLocalNodes(); } - return new Nodes(nodeSet); + Nodes nodes = new Nodes(nodeSet); + if (queryString != null) { + queryContext.createQuery(queryString, Nodes.class) + .filter(nodes, Node.class); + } + return nodes; } /**