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;
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;
@Path("/")
public class ConnectionManagerNorthbound {
private String username;
+ private QueryContext queryContext;
+ @Context
+ public void setQueryContext(ContextResolver<QueryContext> 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();
@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");
}
} 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;
}
/**
}
try {
- Node node = new Node(nodeType, nodeId);
+ Node node = Node.fromString(nodeType, nodeId);
Status status = connectionManager.disconnect(node);
if (status.isSuccess()) {
return Response.ok().build();