- val uncompleteIdentifierWithSchemaNode = identifier.resolveInstanceIdentifier
- var schemaNode = (uncompleteIdentifierWithSchemaNode.schemaNode as DataNodeContainer).getSchemaChildNode(payload)
- if (schemaNode === null) {
- schemaNode = payload.findModule(uncompleteIdentifierWithSchemaNode.instanceIdentifier)?.getSchemaChildNode(payload)
- }
- val value = normalizeNode(payload, schemaNode, uncompleteIdentifierWithSchemaNode.instanceIdentifier)
- val completeIdentifierWithSchemaNode = uncompleteIdentifierWithSchemaNode.addLastIdentifierFromData(value, schemaNode)
- val status = broker.commitConfigurationDataPost(completeIdentifierWithSchemaNode.instanceIdentifier, value)?.get();
+ if (payload.namespace === null) {
+ throw new ResponseException(BAD_REQUEST,
+ "Data has bad format. Root element node must have namespace (XML format) or module name(JSON format)");
+ }
+ var InstanceIdWithSchemaNode iiWithData;
+ var CompositeNode value;
+ if (payload.representsMountPointRootData) { // payload represents mount point data and URI represents path to the mount point
+ if (identifier.endsWithMountPoint) {
+ throw new ResponseException(BAD_REQUEST,
+ "URI has bad format. URI should be without \"" + ControllerContext.MOUNT + "\" for POST operation.");
+ }
+ val completIdentifier = identifier.addMountPointIdentifier
+ iiWithData = completIdentifier.toInstanceIdentifier
+ value = normalizeNode(payload, iiWithData.schemaNode, iiWithData.mountPoint)
+ } else {
+ val uncompleteInstIdWithData = identifier.toInstanceIdentifier
+ val parentSchema = uncompleteInstIdWithData.schemaNode as DataNodeContainer
+ val module = uncompleteInstIdWithData.mountPoint.findModule(payload)
+ if (module === null) {
+ throw new ResponseException(BAD_REQUEST, "Module was not found for \"" + payload.namespace + "\"")
+ }
+ val schemaNode = parentSchema.findInstanceDataChildByNameAndNamespace(payload.name, module.namespace)
+ value = normalizeNode(payload, schemaNode, uncompleteInstIdWithData.mountPoint)
+ iiWithData = uncompleteInstIdWithData.addLastIdentifierFromData(value, schemaNode)
+ }
+ var RpcResult<TransactionStatus> status = null
+ if (iiWithData.mountPoint !== null) {
+ status = broker.commitConfigurationDataPostBehindMountPoint(iiWithData.mountPoint,
+ iiWithData.instanceIdentifier, value)?.get();
+ } else {
+ status = broker.commitConfigurationDataPost(iiWithData.instanceIdentifier, value)?.get();
+ }