-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathNetconfException.cc
143 lines (131 loc) · 4.29 KB
/
NetconfException.cc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
#include "NetconfException.hh"
using namespace xercesc;
#include "DomUtils.hh"
#include "NetconfIdentities.hh"
// NetconfException
xercesc::DOMNode*
NetconfException::createRpcReply(xercesc::DOMDocument* document,
xercesc::DOMNode* rpc) const
{
DOMNode* reply = document->importNode(rpc, false);
document->renameNode(reply,
NetconfIdentities::NETCONF_XMLNS.xmlCh(),
NetconfIdentities::RPC_REPLY.xmlCh());
return reply;
}
std::string
BadElement::createResponse(DomUtils& domUtils,
xercesc::DOMNode* rpc) const
{
DOMDocument* document = domUtils.newDocument();
DOMNode* rpcReply = createRpcReply(document, rpc);
DOMElement* errorTypeElement = document->createElementNS(
NetconfIdentities::NETCONF_XMLNS.xmlCh(),
NetconfIdentities::ERROR_TYPE.xmlCh());
rpcReply->appendChild(errorTypeElement);
DOMText* text;
switch (_errorType) {
case Protocol:
text = document->createTextNode(NetconfIdentities::PROTOCOL.xmlCh());
break;
case Application:
text = document->createTextNode(NetconfIdentities::APPLICATION.xmlCh());
break;
default:
assert(false && "Unknown errorType getOperationNotSupported ");
}
errorTypeElement->appendChild(text);
DOMElement* errorTagElement = document->createElementNS(
NetconfIdentities::NETCONF_XMLNS.xmlCh(),
NetconfIdentities::ERROR_TAG.xmlCh());
rpcReply->appendChild(errorTagElement);
text = document->createTextNode(NetconfIdentities::BAD_ELEMENT.xmlCh());
errorTagElement->appendChild(text);
std::string result = domUtils.serialize(rpcReply);
document->release();
return result;
}
std::string
OperationNotSupported::createResponse(
DomUtils& domUtils,
xercesc::DOMNode* rpc) const
{
DOMDocument* document = domUtils.newDocument();
DOMNode* rpcReply = createRpcReply(document, rpc);
DOMElement* errorTypeElement = document->createElementNS(
NetconfIdentities::NETCONF_XMLNS.xmlCh(),
NetconfIdentities::ERROR_TYPE.xmlCh());
rpcReply->appendChild(errorTypeElement);
DOMText* text;
switch (_errorType) {
case Protocol:
text = document->createTextNode(NetconfIdentities::PROTOCOL.xmlCh());
break;
case Application:
text = document->createTextNode(NetconfIdentities::APPLICATION.xmlCh());
break;
default:
assert(false && "Unknown errorType getOperationNotSupported ");
}
errorTypeElement->appendChild(text);
DOMElement* errorTagElement = document->createElementNS(
NetconfIdentities::NETCONF_XMLNS.xmlCh(),
NetconfIdentities::ERROR_TAG.xmlCh());
rpcReply->appendChild(errorTagElement);
text = document->createTextNode(
NetconfIdentities::OPERATION_NOT_SUPPORTED.xmlCh());
errorTagElement->appendChild(text);
std::string result = domUtils.serialize(rpcReply);
document->release();
return result;
}
// OperationFailed
std::string
OperationFailedcreateResponse(DomUtils& domUtils)
{
}
std::string
OperationFailed::createResponse(DomUtils& domUtils,
xercesc::DOMNode* rpc) const
{
DOMDocument* document = domUtils.newDocument();
DOMNode* rpcReply = createRpcReply(document, rpc);
DOMElement* errorTypeElement = document->createElementNS(
NetconfIdentities::NETCONF_XMLNS.xmlCh(),
NetconfIdentities::ERROR_TYPE.xmlCh());
rpcReply->appendChild(errorTypeElement);
DOMText* text;
switch (_errorType) {
case Rpc:
text = document->createTextNode(NetconfIdentities::RPC.xmlCh());
case Protocol:
text = document->createTextNode(NetconfIdentities::PROTOCOL.xmlCh());
break;
case Application:
text = document->createTextNode(NetconfIdentities::APPLICATION.xmlCh());
break;
default:
assert(false && "Unknown errorType getOperationFailes ");
}
errorTypeElement->appendChild(text);
DOMElement* errorTagElement = document->createElementNS(
NetconfIdentities::NETCONF_XMLNS.xmlCh(),
NetconfIdentities::ERROR_TAG.xmlCh());
rpcReply->appendChild(errorTagElement);
text = document->createTextNode(
NetconfIdentities::OPERATION_FAILED.xmlCh());
errorTagElement->appendChild(text);
std::string result = domUtils.serialize(rpcReply);
document->release();
return result;
}
std::string
ResourceDenied::createResponse(DomUtils& domUtils) const
{
return "ResourceDeined";
}
std::string
ResourceDenied::createResponse(DomUtils& domUtils, DOMNode* rpc) const
{
return "ResourceDeined";
}