use of org.onosproject.yang.model.ResourceData in project onos by opennetworkinglab.
the class RestconfManager method runPostOperationOnDataResource.
@Override
public void runPostOperationOnDataResource(URI uri, ObjectNode rootNode) throws RestconfException {
DataResourceLocator rl = DataResourceLocator.newInstance(uri);
ResourceData receivedData = convertJsonToDataNode(rl.uriForYangRuntime(), rootNode);
ResourceId rid = receivedData.resourceId();
List<DataNode> dataNodeList = receivedData.dataNodes();
if (dataNodeList == null || dataNodeList.isEmpty()) {
log.warn("There is no one Data Node can be proceed.");
return;
}
if (dataNodeList.size() > 1) {
log.warn("There are more than one Data Node can be proceed: {}", dataNodeList.size());
}
DataNode dataNode = dataNodeList.get(0);
if (rid == null) {
rid = ResourceId.builder().addBranchPointSchema("/", null).build();
dataNode = removeTopNode(dataNode);
}
try {
dynamicConfigService.createNode(rl.ridForDynConfig(), dataNode);
} catch (Exception e) {
if (e.getMessage().startsWith("Requested node already present")) {
throw new RestconfException("Already exists", e, RestconfError.ErrorTag.DATA_EXISTS, CONFLICT, Optional.of(uri.getPath()));
} else {
log.error("ERROR: DynamicConfigService: creating {} with {}", ResourceIds.toInstanceIdentifier(rl.ridForDynConfig()), dataNode, e);
throw new RestconfException("ERROR: DynamicConfigService", e, RestconfError.ErrorTag.OPERATION_FAILED, INTERNAL_SERVER_ERROR, Optional.of(uri.getPath()));
}
}
}
use of org.onosproject.yang.model.ResourceData in project onos by opennetworkinglab.
the class OdtnDcsModelCheckCommand method getResourceId.
private ResourceId getResourceId(ModelObjectId modelId) {
ModelObjectData data = DefaultModelObjectData.builder().identifier(modelId).build();
ResourceData rnode = modelConverter.createDataNode(data);
return rnode.resourceId();
}
use of org.onosproject.yang.model.ResourceData in project onos by opennetworkinglab.
the class TapiObjectHandler method deleteOnDcs.
private void deleteOnDcs() {
dcsSetup();
ResourceData rData = toResourceData(getChildModelObjectData());
dcs.deleteNode(rData.resourceId());
}
use of org.onosproject.yang.model.ResourceData in project onos by opennetworkinglab.
the class TapiObjectHandler method readOnDcs.
@SuppressWarnings("unchecked")
private T readOnDcs() {
dcsSetup();
ResourceData rData1 = toResourceData(getChildModelObjectData());
ResourceData rData2 = toResourceData(getModelObjectData());
DataNode rNode = dcs.readNode(rData1.resourceId(), Filter.builder().build());
obj = toModelObject(rNode, rData2.resourceId());
return obj;
}
use of org.onosproject.yang.model.ResourceData in project onos by opennetworkinglab.
the class TapiObjectHandler method toResourceData.
private ResourceData toResourceData(ModelObjectData data) {
dcsSetup();
ResourceData rData = modelConverter.createDataNode(data);
// for debug
CharSequence strNode = toCharSequence(toXmlCompositeStream(toCompositeData(rData)));
log.debug("XML:\n{}", XmlString.prettifyXml(strNode));
return rData;
}
Aggregations