- public Response createConfigurationData(final String identifier, final CompositeNode payload) {
- if (payload == null) {
- throw new RestconfDocumentedException("Input is required.", ErrorType.PROTOCOL, ErrorTag.MALFORMED_MESSAGE);
- }
-
- URI payloadNS = this.namespace(payload);
- 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);
- }
-
- InstanceIdWithSchemaNode iiWithData = null;
- CompositeNode value = null;
- if (this.representsMountPointRootData(payload)) {
- // payload represents mount point data and URI represents path to the mount point
-
- if (this.endsWithMountPoint(identifier)) {
- throw new RestconfDocumentedException("URI has bad format. URI should be without \""
- + ControllerContext.MOUNT + "\" for POST operation.", ErrorType.PROTOCOL,
- ErrorTag.INVALID_VALUE);
- }
-
- final String completeIdentifier = this.addMountPointIdentifier(identifier);
- iiWithData = this.controllerContext.toInstanceIdentifier(completeIdentifier);
-
- value = this.normalizeNode(payload, iiWithData.getSchemaNode(), iiWithData.getMountPoint());
- } else {
- final InstanceIdWithSchemaNode incompleteInstIdWithData = this.controllerContext
- .toInstanceIdentifier(identifier);
- final DataNodeContainer parentSchema = (DataNodeContainer) incompleteInstIdWithData.getSchemaNode();
- MountInstance mountPoint = incompleteInstIdWithData.getMountPoint();
- final Module module = this.findModule(mountPoint, payload);
- if (module == null) {
- throw new RestconfDocumentedException("Module was not found for \"" + payloadNS + "\"",
- ErrorType.PROTOCOL, ErrorTag.UNKNOWN_ELEMENT);
- }
-
- String payloadName = this.getName(payload);
- final DataSchemaNode schemaNode = this.controllerContext.findInstanceDataChildByNameAndNamespace(
- parentSchema, payloadName, module.getNamespace());
- value = this.normalizeNode(payload, schemaNode, mountPoint);
-
- iiWithData = this.addLastIdentifierFromData(incompleteInstIdWithData, value, schemaNode);
- }