import javax.ws.rs.Consumes;
import javax.ws.rs.DELETE;
+import javax.ws.rs.DefaultValue;
import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.PUT;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.QueryParam;
+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 org.codehaus.enunciate.jaxrs.ResponseCode;
import org.codehaus.enunciate.jaxrs.StatusCodes;
return o.extractFields(fields);
}
+ @Context
+ UriInfo uriInfo;
+
/**
* Returns a list of all Ports */
@QueryParam("device_id") String queryDeviceID,
@QueryParam("device_owner") String queryDeviceOwner,
@QueryParam("tenant_id") String queryTenantID,
- // pagination
- @QueryParam("limit") String limit,
+ // linkTitle
+ @QueryParam("limit") Integer limit,
@QueryParam("marker") String marker,
- @QueryParam("page_reverse") String pageReverse
+ @DefaultValue("false") @QueryParam("page_reverse") Boolean pageReverse
// sorting not supported
) {
INeutronPortCRUD portInterface = NeutronCRUDInterfaces.getINeutronPortCRUD(this);
}
}
}
- //TODO: apply pagination to results
+
+ if (limit != null && ans.size() > 1) {
+ // Return a paginated request
+ NeutronPortRequest request = (NeutronPortRequest) PaginatedRequestFactory.createRequest(limit,
+ marker, pageReverse, uriInfo, ans, NeutronPort.class);
+ return Response.status(200).entity(request).build();
+ }
+
return Response.status(200).entity(
new NeutronPortRequest(ans)).build();
}
if (portInterface.macInUse(singleton.getMacAddress())) {
throw new ResourceConflictException("MAC Address is in use.");
}
- Object[] instances = ServiceHelper.getGlobalInstances(INeutronPortAware.class, this, null);
- if (instances != null) {
- for (Object instance : instances) {
- INeutronPortAware service = (INeutronPortAware) instance;
- int status = service.canCreatePort(singleton);
- if (status < 200 || status > 299) {
- return Response.status(status).build();
- }
- }
- }
/*
* if fixed IPs are specified, each one has to have an existing subnet ID
* that is in the same scoping network as the port. In addition, if an IP
}
}
+ Object[] instances = ServiceHelper.getGlobalInstances(INeutronPortAware.class, this, null);
+ if (instances != null) {
+ for (Object instance : instances) {
+ INeutronPortAware service = (INeutronPortAware) instance;
+ int status = service.canCreatePort(singleton);
+ if (status < 200 || status > 299) {
+ return Response.status(status).build();
+ }
+ }
+ }
+
+
// add the port to the cache
portInterface.addPort(singleton);
if (instances != null) {
if (portInterface.macInUse(test.getMacAddress())) {
throw new ResourceConflictException("MAC address in use");
}
- if (instances != null) {
- for (Object instance : instances) {
- INeutronPortAware service = (INeutronPortAware) instance;
- int status = service.canCreatePort(test);
- if (status < 200 || status > 299) {
- return Response.status(status).build();
- }
- }
- }
+
/*
* if fixed IPs are specified, each one has to have an existing subnet ID
* that is in the same scoping network as the port. In addition, if an IP
}
}
}
+ if (instances != null) {
+ for (Object instance : instances) {
+ INeutronPortAware service = (INeutronPortAware) instance;
+ int status = service.canCreatePort(test);
+ if (status < 200 || status > 299) {
+ return Response.status(status).build();
+ }
+ }
+ }
}
//once everything has passed, then we can add to the cache