- if (payload == null) {
- throw new RestconfDocumentedException("Input is required.", ErrorType.PROTOCOL, ErrorTag.MALFORMED_MESSAGE);
- }
-
- final URI payloadNS = payload.getData().getNodeType().getNamespace();
- if (payloadNS == null) {
- throw new RestconfDocumentedException(
- "Data has bad format. Root element node must have namespace (XML format) or module name(JSON format)",
- ErrorType.PROTOCOL, ErrorTag.UNKNOWN_NAMESPACE);
- }
-
- final DOMMountPoint mountPoint = payload.getInstanceIdentifierContext().getMountPoint();
-
- final InstanceIdentifierContext iiWithData = mountPoint != null
- ? controllerContext.toMountPointIdentifier(identifier)
- : controllerContext.toInstanceIdentifier(identifier);
- final YangInstanceIdentifier normalizedII = iiWithData.getInstanceIdentifier();
-
- try {
- if (mountPoint != null) {
- broker.commitConfigurationDataPost(mountPoint, normalizedII, payload.getData());
- } else {
- broker.commitConfigurationDataPost(normalizedII, payload.getData());
- }
- } catch(final RestconfDocumentedException e) {
- throw e;
- } catch (final Exception e) {
- throw new RestconfDocumentedException("Error creating data", e);
- }
-
-
- final ResponseBuilder responseBuilder = Response.status(Status.NO_CONTENT);
- final URI location = resolveLocation(uriInfo, "config", mountPoint, normalizedII);
- if (location != null) {
- responseBuilder.location(location);
- }
- return responseBuilder.build();