import java.util.Date;
import java.util.List;
import javax.inject.Singleton;
+import javax.ws.rs.BadRequestException;
import javax.ws.rs.Consumes;
import javax.ws.rs.DELETE;
import javax.ws.rs.Encoded;
import org.opendaylight.restconf.api.ApiPath;
import org.opendaylight.restconf.api.FormattableBody;
import org.opendaylight.restconf.api.MediaTypes;
+import org.opendaylight.restconf.api.QueryParameters;
import org.opendaylight.restconf.common.errors.RestconfDocumentedException;
import org.opendaylight.restconf.common.errors.RestconfError;
import org.opendaylight.restconf.common.errors.RestconfFuture;
import org.opendaylight.restconf.nb.rfc8040.URLConstants;
-import org.opendaylight.restconf.nb.rfc8040.databind.jaxrs.QueryParams;
import org.opendaylight.restconf.nb.rfc8040.legacy.ErrorTags;
import org.opendaylight.restconf.nb.rfc8040.legacy.NormalizedNodePayload;
import org.opendaylight.restconf.server.api.ConfigurationMetadata;
}
};
- private final RestconfServer server;
+ private final @NonNull RestconfServer server;
public JaxRsRestconf(final RestconfServer server) {
this.server = requireNonNull(server);
return ApiPath.class.equals(rawType) ? (ParamConverter<T>) API_PATH_CONVERTER : null;
}
+ private static @NonNull QueryParameters queryParams(final UriInfo uriInfo) {
+ try {
+ return QueryParameters.ofMultiValue(uriInfo.getQueryParameters());
+ } catch (IllegalArgumentException e) {
+ throw new BadRequestException(e.getMessage(), e);
+ }
+ }
+
/**
* Delete the target data resource.
*
MediaType.TEXT_XML
})
public void dataGET(@Context final UriInfo uriInfo, @Suspended final AsyncResponse ar) {
- completeDataGET(server.dataGET(QueryParams.newDataGetParams(uriInfo)), ar);
+ completeDataGET(server.dataGET(queryParams(uriInfo)), ar);
}
/**
})
public void dataGET(@Encoded @PathParam("identifier") final ApiPath identifier, @Context final UriInfo uriInfo,
@Suspended final AsyncResponse ar) {
- completeDataGET(server.dataGET(identifier, QueryParams.newDataGetParams(uriInfo)), ar);
+ completeDataGET(server.dataGET(identifier, queryParams(uriInfo)), ar);
}
private static void completeDataGET(final RestconfFuture<DataGetResult> future, final AsyncResponse ar) {
public void dataYangJsonPATCH(final InputStream body, @Context final UriInfo uriInfo,
@Suspended final AsyncResponse ar) {
try (var jsonBody = new JsonPatchBody(body)) {
- completeDataYangPATCH(server.dataPATCH(QueryParams.normalize(uriInfo), jsonBody), ar);
+ completeDataYangPATCH(server.dataPATCH(queryParams(uriInfo), jsonBody), ar);
}
}
public void dataYangJsonPATCH(@Encoded @PathParam("identifier") final ApiPath identifier, final InputStream body,
@Context final UriInfo uriInfo, @Suspended final AsyncResponse ar) {
try (var jsonBody = new JsonPatchBody(body)) {
- completeDataYangPATCH(server.dataPATCH(identifier, QueryParams.normalize(uriInfo), jsonBody), ar);
+ completeDataYangPATCH(server.dataPATCH(identifier, queryParams(uriInfo), jsonBody), ar);
}
}
public void dataYangXmlPATCH(final InputStream body, @Context final UriInfo uriInfo,
@Suspended final AsyncResponse ar) {
try (var xmlBody = new XmlPatchBody(body)) {
- completeDataYangPATCH(server.dataPATCH(QueryParams.normalize(uriInfo), xmlBody), ar);
+ completeDataYangPATCH(server.dataPATCH(queryParams(uriInfo), xmlBody), ar);
}
}
public void dataYangXmlPATCH(@Encoded @PathParam("identifier") final ApiPath identifier, final InputStream body,
@Context final UriInfo uriInfo, @Suspended final AsyncResponse ar) {
try (var xmlBody = new XmlPatchBody(body)) {
- completeDataYangPATCH(server.dataPATCH(identifier, QueryParams.normalize(uriInfo), xmlBody), ar);
+ completeDataYangPATCH(server.dataPATCH(identifier, queryParams(uriInfo), xmlBody), ar);
}
}
public void postDataJSON(final InputStream body, @Context final UriInfo uriInfo,
@Suspended final AsyncResponse ar) {
try (var jsonBody = new JsonChildBody(body)) {
- completeDataPOST(server.dataPOST(jsonBody, QueryParams.normalize(uriInfo)), uriInfo, ar);
+ completeDataPOST(server.dataPOST(queryParams(uriInfo), jsonBody), uriInfo, ar);
}
}
})
public void postDataJSON(@Encoded @PathParam("identifier") final ApiPath identifier, final InputStream body,
@Context final UriInfo uriInfo, @Suspended final AsyncResponse ar) {
- completeDataPOST(server.dataPOST(identifier, new JsonDataPostBody(body), QueryParams.normalize(uriInfo)),
- uriInfo, ar);
+ completeDataPOST(server.dataPOST(identifier, queryParams(uriInfo), new JsonDataPostBody(body)), uriInfo, ar);
}
/**
})
public void postDataXML(final InputStream body, @Context final UriInfo uriInfo, @Suspended final AsyncResponse ar) {
try (var xmlBody = new XmlChildBody(body)) {
- completeDataPOST(server.dataPOST(xmlBody, QueryParams.normalize(uriInfo)), uriInfo, ar);
+ completeDataPOST(server.dataPOST(queryParams(uriInfo), xmlBody), uriInfo, ar);
}
}
})
public void postDataXML(@Encoded @PathParam("identifier") final ApiPath identifier, final InputStream body,
@Context final UriInfo uriInfo, @Suspended final AsyncResponse ar) {
- completeDataPOST(server.dataPOST(identifier, new XmlDataPostBody(body), QueryParams.normalize(uriInfo)),
- uriInfo, ar);
+ completeDataPOST(server.dataPOST(identifier, queryParams(uriInfo), new XmlDataPostBody(body)), uriInfo, ar);
}
private static void completeDataPOST(final RestconfFuture<? extends DataPostResult> future, final UriInfo uriInfo,
})
public void dataJsonPUT(@Context final UriInfo uriInfo, final InputStream body, @Suspended final AsyncResponse ar) {
try (var jsonBody = new JsonResourceBody(body)) {
- completeDataPUT(server.dataPUT(jsonBody, QueryParams.normalize(uriInfo)), ar);
+ completeDataPUT(server.dataPUT(queryParams(uriInfo), jsonBody), ar);
}
}
public void dataJsonPUT(@Encoded @PathParam("identifier") final ApiPath identifier, @Context final UriInfo uriInfo,
final InputStream body, @Suspended final AsyncResponse ar) {
try (var jsonBody = new JsonResourceBody(body)) {
- completeDataPUT(server.dataPUT(identifier, jsonBody, QueryParams.normalize(uriInfo)), ar);
+ completeDataPUT(server.dataPUT(identifier, queryParams(uriInfo), jsonBody), ar);
}
}
})
public void dataXmlPUT(@Context final UriInfo uriInfo, final InputStream body, @Suspended final AsyncResponse ar) {
try (var xmlBody = new XmlResourceBody(body)) {
- completeDataPUT(server.dataPUT(xmlBody, QueryParams.normalize(uriInfo)), ar);
+ completeDataPUT(server.dataPUT(queryParams(uriInfo), xmlBody), ar);
}
}
public void dataXmlPUT(@Encoded @PathParam("identifier") final ApiPath identifier, @Context final UriInfo uriInfo,
final InputStream body, @Suspended final AsyncResponse ar) {
try (var xmlBody = new XmlResourceBody(body)) {
- completeDataPUT(server.dataPUT(identifier, xmlBody, QueryParams.normalize(uriInfo)), ar);
+ completeDataPUT(server.dataPUT(identifier, queryParams(uriInfo), xmlBody), ar);
}
}
private void operationsPOST(final ApiPath identifier, final UriInfo uriInfo, final AsyncResponse ar,
final OperationInputBody body) {
- server.operationsPOST(uriInfo.getBaseUri(), identifier, QueryParams.normalize(uriInfo), body)
+ server.operationsPOST(uriInfo.getBaseUri(), identifier, queryParams(uriInfo), body)
.addCallback(new JaxRsRestconfCallback<>(ar) {
@Override
Response transform(final InvokeResult result) {