})
public Response readData(@Context final UriInfo uriInfo) {
final var readParams = QueryParams.newReadDataParams(uriInfo);
- return readData(server.bindRequestRoot(databindProvider.currentContext()), readParams);
+ return readData(server.bindRequestRoot(), readParams);
}
/**
public Response readData(@Encoded @PathParam("identifier") final String identifier,
@Context final UriInfo uriInfo) {
final var readParams = QueryParams.newReadDataParams(uriInfo);
- return readData(server.bindRequestPath(databindProvider.currentContext(), identifier), readParams);
+ return readData(server.bindRequestPath(identifier), readParams);
}
private Response readData(final InstanceIdentifierContext reqPath, final ReadDataParams readParams) {
}
if (node == null) {
throw new RestconfDocumentedException(
- "Request could not be completed because the relevant data model content does not exist",
- ErrorType.PROTOCOL, ErrorTag.DATA_MISSING);
+ "Request could not be completed because the relevant data model content does not exist",
+ ErrorType.PROTOCOL, ErrorTag.DATA_MISSING);
}
return switch (readParams.content()) {
private void putData(final @Nullable String identifier, final UriInfo uriInfo, final ResourceBody body,
final AsyncResponse ar) {
- final var reqPath = server.bindRequestPath(databindProvider.currentContext(), identifier);
+ final var reqPath = server.bindRequestPath(identifier);
final var insert = QueryParams.parseInsert(reqPath.getSchemaContext(), uriInfo);
final var req = bindResourceRequest(reqPath, body);
})
public void postDataJSON(@Encoded @PathParam("identifier") final String identifier, final InputStream body,
@Context final UriInfo uriInfo, @Suspended final AsyncResponse ar) {
- final var reqPath = server.bindRequestPath(databindProvider.currentContext(), identifier);
+ final var reqPath = server.bindRequestPath(identifier);
if (reqPath.getSchemaNode() instanceof ActionDefinition) {
try (var jsonBody = new JsonOperationInputBody(body)) {
invokeAction(reqPath, jsonBody, ar);
})
public void postDataXML(@Encoded @PathParam("identifier") final String identifier, final InputStream body,
@Context final UriInfo uriInfo, @Suspended final AsyncResponse ar) {
- final var reqPath = server.bindRequestPath(databindProvider.currentContext(), identifier);
+ final var reqPath = server.bindRequestPath(identifier);
if (reqPath.getSchemaNode() instanceof ActionDefinition) {
try (var xmlBody = new XmlOperationInputBody(body)) {
invokeAction(reqPath, xmlBody, ar);
@Path("/data/{identifier:.+}")
public void deleteData(@Encoded @PathParam("identifier") final String identifier,
@Suspended final AsyncResponse ar) {
- final var reqPath = server.bindRequestPath(databindProvider.currentContext(), identifier);
+ final var reqPath = server.bindRequestPath(identifier);
final var strategy = server.getRestconfStrategy(reqPath.getSchemaContext(), reqPath.getMountPoint());
strategy.delete(reqPath.getInstanceIdentifier()).addCallback(new JaxRsRestconfCallback<>(ar) {
* @param ar {@link AsyncResponse} which needs to be completed
*/
private void plainPatchData(final ResourceBody body, final AsyncResponse ar) {
- plainPatchData(server.bindRequestRoot(databindProvider.currentContext()), body, ar);
+ plainPatchData(server.bindRequestRoot(), body, ar);
}
/**
* @param ar {@link AsyncResponse} which needs to be completed
*/
private void plainPatchData(final String identifier, final ResourceBody body, final AsyncResponse ar) {
- plainPatchData(server.bindRequestPath(databindProvider.currentContext(), identifier), body, ar);
+ plainPatchData(server.bindRequestPath(identifier), body, ar);
}
/**
}
private void yangPatchData(final @NonNull PatchBody body, final AsyncResponse ar) {
- final var context = databindProvider.currentContext().modelContext();
+ final var context = server.bindRequestRoot().getSchemaContext();
yangPatchData(context, parsePatchBody(context, YangInstanceIdentifier.of(), body), null, ar);
}
private void yangPatchData(final String identifier, final @NonNull PatchBody body,
final AsyncResponse ar) {
- final var reqPath = server.bindRequestPath(databindProvider.currentContext(), identifier);
+ final var reqPath = server.bindRequestPath(identifier);
final var modelContext = reqPath.getSchemaContext();
yangPatchData(modelContext, parsePatchBody(modelContext, reqPath.getInstanceIdentifier(), body),
reqPath.getMountPoint(), ar);
private static Status getStatusCode(final PatchStatusContext result) {
if (result.ok()) {
return Status.OK;
+ } else if (result.globalErrors() == null || result.globalErrors().isEmpty()) {
+ return result.editCollection().stream()
+ .filter(patchStatus -> !patchStatus.isOk() && !patchStatus.getEditErrors().isEmpty())
+ .findFirst()
+ .map(PatchStatusEntity::getEditErrors)
+ .flatMap(errors -> errors.stream().findFirst())
+ .map(error -> ErrorTags.statusOf(error.getErrorTag()))
+ .orElse(Status.INTERNAL_SERVER_ERROR);
} else {
- if (result.globalErrors() == null || result.globalErrors().isEmpty()) {
- return result.editCollection().stream()
- .filter(patchStatus -> !patchStatus.isOk() && !patchStatus.getEditErrors().isEmpty())
- .findFirst()
- .map(PatchStatusEntity::getEditErrors)
- .flatMap(errors -> errors.stream().findFirst())
- .map(error -> ErrorTags.statusOf(error.getErrorTag()))
- .orElse(Status.INTERNAL_SERVER_ERROR);
- } else {
- final var error = result.globalErrors().iterator().next();
- return ErrorTags.statusOf(error.getErrorTag());
- }
+ final var error = result.globalErrors().iterator().next();
+ return ErrorTags.statusOf(error.getErrorTag());
}
}