sonu gupta | 1bb37b8 | 2016-11-11 16:51:18 +0530 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2016-present Open Networking Laboratory |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | package org.onosproject.yms.app.ydt; |
| 18 | |
| 19 | import com.google.common.collect.ImmutableMap; |
sonu gupta | eff184b | 2016-11-24 12:43:49 +0530 | [diff] [blame] | 20 | import org.onosproject.yangutils.datamodel.YangAugment; |
| 21 | import org.onosproject.yangutils.datamodel.YangLeaf; |
sonu gupta | 1bb37b8 | 2016-11-11 16:51:18 +0530 | [diff] [blame] | 22 | import org.onosproject.yangutils.datamodel.YangList; |
| 23 | import org.onosproject.yangutils.datamodel.YangSchemaNode; |
| 24 | import org.onosproject.yangutils.datamodel.YangSchemaNodeContextInfo; |
| 25 | import org.onosproject.yangutils.datamodel.YangSchemaNodeIdentifier; |
sonu gupta | eff184b | 2016-11-24 12:43:49 +0530 | [diff] [blame] | 26 | import org.onosproject.yms.app.ydt.exceptions.YdtException; |
sonu gupta | 1bb37b8 | 2016-11-11 16:51:18 +0530 | [diff] [blame] | 27 | import org.onosproject.yms.app.ysr.YangSchemaRegistry; |
sonu gupta | 1bb37b8 | 2016-11-11 16:51:18 +0530 | [diff] [blame] | 28 | import org.onosproject.yms.ydt.YdtContextOperationType; |
| 29 | import org.onosproject.yms.ydt.YdtType; |
| 30 | import org.onosproject.yms.ydt.YmsOperationType; |
| 31 | |
sonu gupta | eff184b | 2016-11-24 12:43:49 +0530 | [diff] [blame] | 32 | import java.util.HashSet; |
sonu gupta | 1bb37b8 | 2016-11-11 16:51:18 +0530 | [diff] [blame] | 33 | import java.util.Iterator; |
| 34 | import java.util.List; |
| 35 | import java.util.Map; |
| 36 | import java.util.Set; |
| 37 | |
sonu gupta | 1bb37b8 | 2016-11-11 16:51:18 +0530 | [diff] [blame] | 38 | import static org.onosproject.yms.app.ydt.AppNodeFactory.getAppContext; |
| 39 | import static org.onosproject.yms.app.ydt.RequestedCallType.LEAF; |
sonu gupta | eff184b | 2016-11-24 12:43:49 +0530 | [diff] [blame] | 40 | import static org.onosproject.yms.app.ydt.RequestedCallType.NON_LEAF; |
sonu gupta | 1bb37b8 | 2016-11-11 16:51:18 +0530 | [diff] [blame] | 41 | import static org.onosproject.yms.app.ydt.RequestedCardinality.MULTI_INSTANCE; |
| 42 | import static org.onosproject.yms.app.ydt.RequestedCardinality.MULTI_INSTANCE_LEAF; |
| 43 | import static org.onosproject.yms.app.ydt.RequestedCardinality.SINGLE_INSTANCE; |
| 44 | import static org.onosproject.yms.app.ydt.RequestedCardinality.UNKNOWN; |
| 45 | import static org.onosproject.yms.app.ydt.YdtConstants.errorMsg; |
sonu gupta | eff184b | 2016-11-24 12:43:49 +0530 | [diff] [blame] | 46 | import static org.onosproject.yms.app.ydt.YdtNodeFactory.getNode; |
| 47 | import static org.onosproject.yms.app.ydt.YdtNodeFactory.getYangSchemaNodeTypeSpecificContext; |
| 48 | import static org.onosproject.yms.app.ydt.YdtUtils.checkElementCount; |
| 49 | import static org.onosproject.yms.app.ydt.YdtUtils.freeRestResources; |
| 50 | import static org.onosproject.yms.app.ydt.YdtUtils.getAppOpTypeFromYdtOpType; |
| 51 | import static org.onosproject.yms.app.ydt.YdtUtils.getAugmentingSchemaNode; |
| 52 | import static org.onosproject.yms.app.ydt.YdtUtils.getNodeIdentifier; |
| 53 | import static org.onosproject.yms.app.ydt.YdtUtils.getValidOpType; |
sonu gupta | 1bb37b8 | 2016-11-11 16:51:18 +0530 | [diff] [blame] | 54 | import static org.onosproject.yms.ydt.YdtContextOperationType.DELETE; |
sonu gupta | 1bb37b8 | 2016-11-11 16:51:18 +0530 | [diff] [blame] | 55 | import static org.onosproject.yms.ydt.YdtContextOperationType.REMOVE; |
| 56 | import static org.onosproject.yms.ydt.YdtType.MULTI_INSTANCE_LEAF_VALUE_NODE; |
| 57 | import static org.onosproject.yms.ydt.YdtType.MULTI_INSTANCE_NODE; |
| 58 | |
| 59 | /** |
| 60 | * Represents YANG request work bench which contains all parameters for |
| 61 | * request handling and methods to build and obtain YANG data tree |
| 62 | * which is data (sub)instance representation, abstract of protocol. |
| 63 | */ |
| 64 | public class YangRequestWorkBench implements YdtExtendedBuilder { |
| 65 | |
sonu gupta | eff184b | 2016-11-24 12:43:49 +0530 | [diff] [blame] | 66 | // Ydt formatted error string |
sonu gupta | 1bb37b8 | 2016-11-11 16:51:18 +0530 | [diff] [blame] | 67 | private static final String FMT_NOT_EXIST = |
| 68 | "Application with name \"%s\" doesn't exist."; |
sonu gupta | eff184b | 2016-11-24 12:43:49 +0530 | [diff] [blame] | 69 | |
| 70 | // Ydt error strings. |
| 71 | private static final String E_USE_ADD_LEAF = |
| 72 | "Requested Node should be created using addLeaf interface."; |
| 73 | |
sonu gupta | 1bb37b8 | 2016-11-11 16:51:18 +0530 | [diff] [blame] | 74 | private static final String E_INVOKE_PARENT = |
sonu gupta | eff184b | 2016-11-24 12:43:49 +0530 | [diff] [blame] | 75 | "Can't invoke get parent at logical root node."; |
sonu gupta | 1bb37b8 | 2016-11-11 16:51:18 +0530 | [diff] [blame] | 76 | |
| 77 | /* |
sonu gupta | eff184b | 2016-11-24 12:43:49 +0530 | [diff] [blame] | 78 | * Reference for the current context node in YANG data tree. |
sonu gupta | 1bb37b8 | 2016-11-11 16:51:18 +0530 | [diff] [blame] | 79 | */ |
| 80 | private YdtNode curNode; |
| 81 | |
| 82 | /* |
sonu gupta | eff184b | 2016-11-24 12:43:49 +0530 | [diff] [blame] | 83 | * Reference for the logical root node in YANG data tree. |
sonu gupta | 1bb37b8 | 2016-11-11 16:51:18 +0530 | [diff] [blame] | 84 | */ |
| 85 | private YdtNode rootNode; |
| 86 | |
| 87 | /* |
sonu gupta | eff184b | 2016-11-24 12:43:49 +0530 | [diff] [blame] | 88 | * Reference for the current context in ydt application tree. |
sonu gupta | 1bb37b8 | 2016-11-11 16:51:18 +0530 | [diff] [blame] | 89 | */ |
| 90 | private YdtAppContext appCurNode; |
| 91 | |
| 92 | /* |
sonu gupta | eff184b | 2016-11-24 12:43:49 +0530 | [diff] [blame] | 93 | * Reference for the logical root node context in ydt application tree. |
sonu gupta | 1bb37b8 | 2016-11-11 16:51:18 +0530 | [diff] [blame] | 94 | */ |
| 95 | private YdtAppContext appRootNode; |
| 96 | |
| 97 | /** |
| 98 | * Root Node Tag attribute in YANG data tree, kept to maintain the root |
| 99 | * tag attributes in YDT. |
| 100 | * <p> |
| 101 | * First key param of map represent tagName name of tag attribute. |
| 102 | * Second param of map represent tagValue value of tag attribute |
| 103 | */ |
| 104 | private Map<String, String> rootTagAttributeMap; |
| 105 | |
| 106 | /* |
| 107 | * YANG schema registry reference. |
| 108 | */ |
| 109 | private YangSchemaRegistry registry = null; |
| 110 | |
| 111 | /* |
| 112 | * YMS operation type. |
| 113 | */ |
| 114 | private final YmsOperationType ymsOperationType; |
| 115 | |
| 116 | /* |
| 117 | * YDT default operation type. |
| 118 | */ |
| 119 | private YdtContextOperationType ydtDefaultOpType; |
| 120 | |
| 121 | /* |
| 122 | * Flag to identify data validation need to be done by YDT or not. |
| 123 | */ |
Vidyashree Rama | 76faccc | 2016-10-17 22:06:52 +0530 | [diff] [blame] | 124 | private boolean validate = false; |
sonu gupta | 1bb37b8 | 2016-11-11 16:51:18 +0530 | [diff] [blame] | 125 | // TODO validate need to be handle later with interaction type basis in |
| 126 | // future when it will be supported |
| 127 | |
sonu gupta | eff184b | 2016-11-24 12:43:49 +0530 | [diff] [blame] | 128 | /* |
| 129 | * Reference for application tree node set. |
| 130 | * This set contains the method name's generated for an augmented |
| 131 | * target node to avoid the duplicate entries in YDT application tree for |
| 132 | * multiple augmented nodes under a single XPATH. |
| 133 | */ |
| 134 | private Set<String> augGenMethodSet; |
sonu gupta | 1bb37b8 | 2016-11-11 16:51:18 +0530 | [diff] [blame] | 135 | |
| 136 | /** |
| 137 | * Creates an instance of YANG request work bench which is use to initialize |
| 138 | * logical rootNode and and schema registry. |
| 139 | * |
| 140 | * @param name name of logical container of a protocol |
| 141 | * which is a holder of the complete tree |
| 142 | * @param namespace namespace of logical container |
| 143 | * @param opType type of operation done by using YANG |
| 144 | * interface |
sonu gupta | eff184b | 2016-11-24 12:43:49 +0530 | [diff] [blame] | 145 | * @param reg Yang schema registry |
sonu gupta | 1bb37b8 | 2016-11-11 16:51:18 +0530 | [diff] [blame] | 146 | * @param isValidate Flag to identify data validation need to be |
| 147 | * done by YDT or not |
| 148 | */ |
| 149 | public YangRequestWorkBench(String name, String namespace, |
| 150 | YmsOperationType opType, |
sonu gupta | eff184b | 2016-11-24 12:43:49 +0530 | [diff] [blame] | 151 | YangSchemaRegistry reg, |
sonu gupta | 1bb37b8 | 2016-11-11 16:51:18 +0530 | [diff] [blame] | 152 | boolean isValidate) { |
sonu gupta | eff184b | 2016-11-24 12:43:49 +0530 | [diff] [blame] | 153 | |
| 154 | setRootNode(new YdtLogicalNode(name, namespace)); |
| 155 | registry = reg; |
sonu gupta | 1bb37b8 | 2016-11-11 16:51:18 +0530 | [diff] [blame] | 156 | ymsOperationType = opType; |
| 157 | validate = isValidate; |
sonu gupta | 1bb37b8 | 2016-11-11 16:51:18 +0530 | [diff] [blame] | 158 | |
sonu gupta | eff184b | 2016-11-24 12:43:49 +0530 | [diff] [blame] | 159 | setAppRootNode(getAppContext(true)); |
sonu gupta | 1bb37b8 | 2016-11-11 16:51:18 +0530 | [diff] [blame] | 160 | } |
| 161 | |
| 162 | /** |
sonu gupta | eff184b | 2016-11-24 12:43:49 +0530 | [diff] [blame] | 163 | * Sets the logical root node for ydt. |
Vidyashree Rama | 76faccc | 2016-10-17 22:06:52 +0530 | [diff] [blame] | 164 | * |
sonu gupta | eff184b | 2016-11-24 12:43:49 +0530 | [diff] [blame] | 165 | * @param node ydt logical root node |
sonu gupta | 1bb37b8 | 2016-11-11 16:51:18 +0530 | [diff] [blame] | 166 | */ |
| 167 | private void setRootNode(YdtNode node) { |
| 168 | rootNode = node; |
| 169 | curNode = node; |
| 170 | } |
| 171 | |
| 172 | /** |
sonu gupta | eff184b | 2016-11-24 12:43:49 +0530 | [diff] [blame] | 173 | * Sets the logical root node for ydt application tree. |
sonu gupta | 1bb37b8 | 2016-11-11 16:51:18 +0530 | [diff] [blame] | 174 | * |
sonu gupta | eff184b | 2016-11-24 12:43:49 +0530 | [diff] [blame] | 175 | * @param node ydt application context logical root node |
sonu gupta | 1bb37b8 | 2016-11-11 16:51:18 +0530 | [diff] [blame] | 176 | */ |
| 177 | private void setAppRootNode(YdtAppContext node) { |
| 178 | appRootNode = node; |
| 179 | appCurNode = node; |
| 180 | } |
| 181 | |
| 182 | /** |
| 183 | * Returns the YANG schema registry of Ydt. |
| 184 | * This method will be used by ytb. |
| 185 | * |
| 186 | * @return YANG schema registry |
| 187 | */ |
| 188 | public YangSchemaRegistry getYangSchemaRegistry() { |
| 189 | return registry; |
| 190 | } |
| 191 | |
| 192 | /** |
sonu gupta | eff184b | 2016-11-24 12:43:49 +0530 | [diff] [blame] | 193 | * Returns the ydt app context tree logical root node. |
| 194 | * This method will be used by yab and ytb. |
sonu gupta | 1bb37b8 | 2016-11-11 16:51:18 +0530 | [diff] [blame] | 195 | * |
sonu gupta | eff184b | 2016-11-24 12:43:49 +0530 | [diff] [blame] | 196 | * @return YdtAppContext app tree logical root node |
sonu gupta | 1bb37b8 | 2016-11-11 16:51:18 +0530 | [diff] [blame] | 197 | */ |
| 198 | public YdtAppContext getAppRootNode() { |
| 199 | return appRootNode; |
| 200 | } |
| 201 | |
| 202 | /** |
sonu gupta | eff184b | 2016-11-24 12:43:49 +0530 | [diff] [blame] | 203 | * Returns the ydt module node with requested node identifier. |
sonu gupta | 1bb37b8 | 2016-11-11 16:51:18 +0530 | [diff] [blame] | 204 | * |
sonu gupta | eff184b | 2016-11-24 12:43:49 +0530 | [diff] [blame] | 205 | * @param id module/application node identifier |
sonu gupta | 1bb37b8 | 2016-11-11 16:51:18 +0530 | [diff] [blame] | 206 | * @return YANG data tree node |
sonu gupta | eff184b | 2016-11-24 12:43:49 +0530 | [diff] [blame] | 207 | * @throws YdtException when user requested node schema doesn't exist or |
| 208 | * requested node is already part of the tree |
sonu gupta | 1bb37b8 | 2016-11-11 16:51:18 +0530 | [diff] [blame] | 209 | */ |
sonu gupta | eff184b | 2016-11-24 12:43:49 +0530 | [diff] [blame] | 210 | private YdtNode moduleHandler(YangSchemaNodeIdentifier id) |
| 211 | throws YdtException { |
sonu gupta | 1bb37b8 | 2016-11-11 16:51:18 +0530 | [diff] [blame] | 212 | |
sonu gupta | eff184b | 2016-11-24 12:43:49 +0530 | [diff] [blame] | 213 | YangSchemaNode node = |
| 214 | registry.getYangSchemaNodeUsingSchemaName(id.getName()); |
sonu gupta | 1bb37b8 | 2016-11-11 16:51:18 +0530 | [diff] [blame] | 215 | |
sonu gupta | eff184b | 2016-11-24 12:43:49 +0530 | [diff] [blame] | 216 | String namespace = id.getNameSpace().getModuleNamespace(); |
| 217 | |
| 218 | /* |
| 219 | * Checking received schema node is having same namespace as |
| 220 | * requested by user or not. |
| 221 | */ |
| 222 | if (node == null || namespace != null && |
| 223 | !namespace.equals(node.getYangSchemaNodeIdentifier() |
| 224 | .getNameSpace() |
| 225 | .getModuleNamespace())) { |
| 226 | throw new YdtException(errorMsg(FMT_NOT_EXIST, id.getName())); |
sonu gupta | 1bb37b8 | 2016-11-11 16:51:18 +0530 | [diff] [blame] | 227 | } |
| 228 | |
sonu gupta | eff184b | 2016-11-24 12:43:49 +0530 | [diff] [blame] | 229 | /* |
| 230 | * If yms operation is for query then no validation need to be |
| 231 | * performed. |
| 232 | */ |
| 233 | if (ymsOperationType != YmsOperationType.QUERY_REQUEST) { |
| 234 | // Checking whether module node is already exits in YDT or not. |
| 235 | try { |
| 236 | curNode.getCollidingChild(id); |
| 237 | } catch (YdtException e) { |
| 238 | throw new YdtException(e.getLocalizedMessage()); |
| 239 | } |
| 240 | } |
| 241 | |
| 242 | YdtNode newNode = new YdtSingleInstanceNode(node); |
sonu gupta | 1bb37b8 | 2016-11-11 16:51:18 +0530 | [diff] [blame] | 243 | newNode.setYangSchemaNode(node); |
sonu gupta | 1bb37b8 | 2016-11-11 16:51:18 +0530 | [diff] [blame] | 244 | return newNode; |
| 245 | } |
| 246 | |
| 247 | @Override |
| 248 | public void setRootTagAttributeMap(Map<String, String> attributeTag) { |
| 249 | rootTagAttributeMap = attributeTag; |
| 250 | } |
| 251 | |
| 252 | @Override |
| 253 | public Map<String, String> getRootTagAttributeMap() { |
| 254 | if (rootTagAttributeMap != null) { |
| 255 | return ImmutableMap.copyOf(rootTagAttributeMap); |
| 256 | } |
| 257 | return null; |
| 258 | } |
| 259 | |
| 260 | @Override |
sonu gupta | eff184b | 2016-11-24 12:43:49 +0530 | [diff] [blame] | 261 | public void addChild(String name, String namespace) |
| 262 | throws IllegalArgumentException { |
| 263 | addChild(name, namespace, UNKNOWN, null, NON_LEAF); |
sonu gupta | 1bb37b8 | 2016-11-11 16:51:18 +0530 | [diff] [blame] | 264 | } |
| 265 | |
| 266 | @Override |
sonu gupta | eff184b | 2016-11-24 12:43:49 +0530 | [diff] [blame] | 267 | public void addChild(String name, String namespace, YdtType ydtType) |
| 268 | throws IllegalArgumentException { |
sonu gupta | 1bb37b8 | 2016-11-11 16:51:18 +0530 | [diff] [blame] | 269 | addChild(name, namespace, ydtType, null); |
| 270 | } |
| 271 | |
| 272 | @Override |
| 273 | public void addChild(String name, String namespace, |
sonu gupta | eff184b | 2016-11-24 12:43:49 +0530 | [diff] [blame] | 274 | YdtContextOperationType opType) |
| 275 | throws IllegalArgumentException { |
| 276 | addChild(name, namespace, UNKNOWN, opType, NON_LEAF); |
sonu gupta | 1bb37b8 | 2016-11-11 16:51:18 +0530 | [diff] [blame] | 277 | } |
| 278 | |
| 279 | @Override |
| 280 | public void addChild(String name, String namespace, YdtType ydtType, |
sonu gupta | eff184b | 2016-11-24 12:43:49 +0530 | [diff] [blame] | 281 | YdtContextOperationType opType) |
| 282 | throws IllegalArgumentException { |
| 283 | RequestedCardinality cardinality; |
sonu gupta | 1bb37b8 | 2016-11-11 16:51:18 +0530 | [diff] [blame] | 284 | switch (ydtType) { |
| 285 | case MULTI_INSTANCE_NODE: |
| 286 | cardinality = MULTI_INSTANCE; |
| 287 | break; |
| 288 | case SINGLE_INSTANCE_NODE: |
| 289 | cardinality = SINGLE_INSTANCE; |
| 290 | break; |
| 291 | default: |
sonu gupta | eff184b | 2016-11-24 12:43:49 +0530 | [diff] [blame] | 292 | throw new IllegalArgumentException(E_USE_ADD_LEAF); |
sonu gupta | 1bb37b8 | 2016-11-11 16:51:18 +0530 | [diff] [blame] | 293 | } |
sonu gupta | eff184b | 2016-11-24 12:43:49 +0530 | [diff] [blame] | 294 | addChild(name, namespace, cardinality, opType, NON_LEAF); |
sonu gupta | 1bb37b8 | 2016-11-11 16:51:18 +0530 | [diff] [blame] | 295 | } |
| 296 | |
| 297 | /** |
| 298 | * Adds a last child to YANG data tree; this method is to be used by all |
| 299 | * protocols internally which are aware or unaware of the nature |
| 300 | * (single/multiple) of node. |
| 301 | * |
| 302 | * @param name name of child to be added |
| 303 | * @param namespace namespace of child to be added |
| 304 | * @param cardinality type of YANG data tree node operation |
| 305 | * @param opType type of requested operation over a node |
| 306 | * @param callType to identify the whether its a leaf or other node |
sonu gupta | eff184b | 2016-11-24 12:43:49 +0530 | [diff] [blame] | 307 | * @throws IllegalArgumentException when method has been passed an illegal |
| 308 | * or inappropriate argument. |
sonu gupta | 1bb37b8 | 2016-11-11 16:51:18 +0530 | [diff] [blame] | 309 | */ |
| 310 | private void addChild(String name, String namespace, |
| 311 | RequestedCardinality cardinality, |
| 312 | YdtContextOperationType opType, |
sonu gupta | eff184b | 2016-11-24 12:43:49 +0530 | [diff] [blame] | 313 | RequestedCallType callType) |
| 314 | throws IllegalArgumentException { |
sonu gupta | 1bb37b8 | 2016-11-11 16:51:18 +0530 | [diff] [blame] | 315 | |
sonu gupta | eff184b | 2016-11-24 12:43:49 +0530 | [diff] [blame] | 316 | YdtNode newNode; |
| 317 | boolean contextSwitch = false; |
sonu gupta | 1bb37b8 | 2016-11-11 16:51:18 +0530 | [diff] [blame] | 318 | YangSchemaNode augmentingSchema = null; |
sonu gupta | eff184b | 2016-11-24 12:43:49 +0530 | [diff] [blame] | 319 | YangSchemaNodeIdentifier id = getNodeIdentifier(name, namespace); |
sonu gupta | 1bb37b8 | 2016-11-11 16:51:18 +0530 | [diff] [blame] | 320 | |
sonu gupta | eff184b | 2016-11-24 12:43:49 +0530 | [diff] [blame] | 321 | try { |
| 322 | // Module/sub-module node handler. |
| 323 | if (curNode.equals(rootNode)) { |
| 324 | newNode = moduleHandler(id); |
sonu gupta | 1bb37b8 | 2016-11-11 16:51:18 +0530 | [diff] [blame] | 325 | } else { |
sonu gupta | eff184b | 2016-11-24 12:43:49 +0530 | [diff] [blame] | 326 | |
| 327 | YangSchemaNode schemaNode; |
| 328 | YangSchemaNodeContextInfo contextInfo; |
| 329 | |
| 330 | // If namespace given by user null, then take namespace from parent. |
| 331 | if (namespace == null) { |
| 332 | id.setNameSpace(curNode.getYangSchemaNode().getNameSpace()); |
sonu gupta | 1bb37b8 | 2016-11-11 16:51:18 +0530 | [diff] [blame] | 333 | } |
sonu gupta | eff184b | 2016-11-24 12:43:49 +0530 | [diff] [blame] | 334 | |
| 335 | /* |
| 336 | * Get the already exiting YDT node in YDT tree with same |
| 337 | * nodeIdentifier |
| 338 | */ |
| 339 | newNode = curNode.getCollidingChild(id); |
| 340 | |
| 341 | /* |
| 342 | * If colliding child doesn't exist , |
| 343 | * then query yang data model for schema of given node. |
| 344 | */ |
| 345 | if (newNode == null) { |
| 346 | /* |
| 347 | * Get Yang Schema node context info which is having |
| 348 | * YangSchemaNode and ContextSwitchedNode. |
| 349 | */ |
| 350 | contextInfo = curNode.getSchemaNodeContextInfo(id); |
| 351 | |
| 352 | if (contextInfo.getContextSwitchedNode() != null) { |
| 353 | augmentingSchema = getAugmentingSchemaNode( |
| 354 | id, contextInfo); |
| 355 | if (augmentingSchema != null) { |
| 356 | /* |
| 357 | * As two tree(YDT and YDT Application Tree) are getting |
| 358 | * prepared in parallel, So setting context switch |
| 359 | * flag it will help ydt to keep the track whether |
| 360 | * ydtApp tree also need to be traversed back to parent |
| 361 | * or not with YDT tree traverse to parent call. |
| 362 | */ |
| 363 | contextSwitch = true; |
| 364 | } |
| 365 | } |
| 366 | schemaNode = contextInfo.getSchemaNode(); |
| 367 | } else { |
| 368 | /* |
| 369 | * If colliding child exist , then it will be leaf-list or list. |
| 370 | * If its leaf-list then return and add new requested |
| 371 | * value/valueSet in same node else take yang data model |
| 372 | * information from colliding child. |
| 373 | */ |
| 374 | if (newNode.getYdtType() == MULTI_INSTANCE_LEAF_VALUE_NODE) { |
| 375 | curNode = newNode; |
| 376 | return; |
| 377 | } |
| 378 | schemaNode = newNode.getYangSchemaNode(); |
| 379 | } |
| 380 | |
| 381 | /* |
| 382 | * For yms query request node specific validation are not |
| 383 | * required as rest-conf can call addChild api for leaf/leaf-list |
| 384 | * node addition also in ydt. |
| 385 | */ |
| 386 | if (ymsOperationType == YmsOperationType.QUERY_REQUEST) { |
| 387 | newNode = getYangSchemaNodeTypeSpecificContext(schemaNode); |
| 388 | } else { |
| 389 | newNode = getNode(schemaNode, cardinality, callType); |
| 390 | } |
sonu gupta | 1bb37b8 | 2016-11-11 16:51:18 +0530 | [diff] [blame] | 391 | } |
sonu gupta | eff184b | 2016-11-24 12:43:49 +0530 | [diff] [blame] | 392 | |
| 393 | opType = getValidOpType(opType, ydtDefaultOpType, newNode, curNode); |
| 394 | |
| 395 | newNode.setYdtContextOperationType(opType); |
| 396 | |
| 397 | curNode.addChild(newNode, true); |
| 398 | } catch (YdtException e) { |
| 399 | freeRestResources(rootNode); |
| 400 | throw new IllegalArgumentException(e.getLocalizedMessage()); |
sonu gupta | 1bb37b8 | 2016-11-11 16:51:18 +0530 | [diff] [blame] | 401 | } |
| 402 | |
sonu gupta | 1bb37b8 | 2016-11-11 16:51:18 +0530 | [diff] [blame] | 403 | // Update parent ydt node map. |
sonu gupta | eff184b | 2016-11-24 12:43:49 +0530 | [diff] [blame] | 404 | curNode.updateYdtMap(newNode); |
sonu gupta | 1bb37b8 | 2016-11-11 16:51:18 +0530 | [diff] [blame] | 405 | |
sonu gupta | eff184b | 2016-11-24 12:43:49 +0530 | [diff] [blame] | 406 | processAppTree(opType, newNode, augmentingSchema, contextSwitch); |
sonu gupta | 1bb37b8 | 2016-11-11 16:51:18 +0530 | [diff] [blame] | 407 | |
sonu gupta | eff184b | 2016-11-24 12:43:49 +0530 | [diff] [blame] | 408 | curNode = newNode; |
sonu gupta | 1bb37b8 | 2016-11-11 16:51:18 +0530 | [diff] [blame] | 409 | } |
| 410 | |
| 411 | /** |
| 412 | * Processes application tree on the bases of requested ydt node. |
| 413 | * |
| 414 | * @param opType user requested operation type |
| 415 | * @param childNode requested ydt node |
| 416 | * @param augmentingSchema schema of last augmenting node |
sonu gupta | eff184b | 2016-11-24 12:43:49 +0530 | [diff] [blame] | 417 | * @param contextSwitch true, for module node call; false for modules |
sonu gupta | 1bb37b8 | 2016-11-11 16:51:18 +0530 | [diff] [blame] | 418 | * sub-node calls |
| 419 | */ |
| 420 | private void processAppTree( |
| 421 | YdtContextOperationType opType, YdtNode childNode, |
sonu gupta | eff184b | 2016-11-24 12:43:49 +0530 | [diff] [blame] | 422 | YangSchemaNode augmentingSchema, boolean contextSwitch) { |
sonu gupta | 1bb37b8 | 2016-11-11 16:51:18 +0530 | [diff] [blame] | 423 | |
sonu gupta | eff184b | 2016-11-24 12:43:49 +0530 | [diff] [blame] | 424 | if (curNode == rootNode) { |
| 425 | augGenMethodSet = new HashSet<>(); |
sonu gupta | 1bb37b8 | 2016-11-11 16:51:18 +0530 | [diff] [blame] | 426 | } |
sonu gupta | eff184b | 2016-11-24 12:43:49 +0530 | [diff] [blame] | 427 | |
sonu gupta | 1bb37b8 | 2016-11-11 16:51:18 +0530 | [diff] [blame] | 428 | if (opType == null) { |
| 429 | opType = curNode.getYdtContextOperationType(); |
| 430 | } else { |
| 431 | // Updating operation type for parent nodes |
| 432 | appCurNode.updateAppOperationType(opType); |
| 433 | } |
| 434 | |
| 435 | /* |
sonu gupta | eff184b | 2016-11-24 12:43:49 +0530 | [diff] [blame] | 436 | * This is to avoid multiple entries of single augmented target. |
sonu gupta | 1bb37b8 | 2016-11-11 16:51:18 +0530 | [diff] [blame] | 437 | */ |
sonu gupta | eff184b | 2016-11-24 12:43:49 +0530 | [diff] [blame] | 438 | if (augmentingSchema != null) { |
| 439 | if (!augGenMethodSet.add(((YangAugment) augmentingSchema) |
| 440 | .getSetterMethodName())) { |
| 441 | return; |
| 442 | } |
| 443 | } |
| 444 | |
| 445 | /* |
| 446 | * Create entry of module node in ydt app tree. |
| 447 | * Or if context switch happened then also add entry for same |
| 448 | * augmented ydt node in the ydt application tree. |
| 449 | */ |
| 450 | if (curNode.equals(rootNode) || contextSwitch) { |
sonu gupta | 1bb37b8 | 2016-11-11 16:51:18 +0530 | [diff] [blame] | 451 | addChildInAppTree(childNode, augmentingSchema, opType, |
sonu gupta | eff184b | 2016-11-24 12:43:49 +0530 | [diff] [blame] | 452 | contextSwitch); |
sonu gupta | 1bb37b8 | 2016-11-11 16:51:18 +0530 | [diff] [blame] | 453 | |
| 454 | // Setting app tree node operation. |
| 455 | appCurNode.setOperationType(getAppOpTypeFromYdtOpType(opType)); |
| 456 | } |
| 457 | |
| 458 | // Updating the delete operation list in app tree. |
| 459 | if (opType == DELETE || opType == REMOVE) { |
| 460 | appCurNode.addDeleteNode(childNode); |
| 461 | } |
| 462 | } |
| 463 | |
sonu gupta | 1bb37b8 | 2016-11-11 16:51:18 +0530 | [diff] [blame] | 464 | |
| 465 | /** |
| 466 | * Adds a last child to YANG app data tree.this method is to be used |
| 467 | * internally by other ydt interfaces. |
| 468 | * |
| 469 | * @param childNode node to be added in tree |
| 470 | * @param schemaNode last augmenting module node |
| 471 | * @param childOpType operation type of node |
| 472 | * @param isContextSwitch true, for module node call; false for modules |
| 473 | * sub-node calls |
| 474 | */ |
| 475 | private void addChildInAppTree(YdtNode childNode, |
| 476 | YangSchemaNode schemaNode, |
| 477 | YdtContextOperationType childOpType, |
| 478 | boolean isContextSwitch) { |
| 479 | |
| 480 | YdtAppNodeOperationType opType; |
| 481 | |
| 482 | DefaultYdtAppContext appContext = getAppContext(isContextSwitch); |
| 483 | |
| 484 | // Add context switched child in ydt App tree. |
| 485 | appCurNode.addChild(appContext); |
sonu gupta | eff184b | 2016-11-24 12:43:49 +0530 | [diff] [blame] | 486 | |
sonu gupta | 1bb37b8 | 2016-11-11 16:51:18 +0530 | [diff] [blame] | 487 | appCurNode = appContext; |
| 488 | |
sonu gupta | 1bb37b8 | 2016-11-11 16:51:18 +0530 | [diff] [blame] | 489 | opType = getAppOpTypeFromYdtOpType(childOpType); |
| 490 | |
| 491 | appCurNode.setAppData(childNode, schemaNode); |
| 492 | |
| 493 | appCurNode.setOperationType(opType); |
| 494 | |
| 495 | childNode.setAppContextSwitch(); |
| 496 | } |
| 497 | |
sonu gupta | 1bb37b8 | 2016-11-11 16:51:18 +0530 | [diff] [blame] | 498 | @Override |
sonu gupta | eff184b | 2016-11-24 12:43:49 +0530 | [diff] [blame] | 499 | public void addLeaf(String name, String namespace, String value) |
| 500 | throws IllegalArgumentException { |
sonu gupta | 1bb37b8 | 2016-11-11 16:51:18 +0530 | [diff] [blame] | 501 | addLeaf(name, namespace, value, null, UNKNOWN); |
| 502 | } |
| 503 | |
| 504 | @Override |
sonu gupta | eff184b | 2016-11-24 12:43:49 +0530 | [diff] [blame] | 505 | public void addLeaf(String name, String namespace, Set<String> valueSet) |
| 506 | throws IllegalArgumentException { |
sonu gupta | 1bb37b8 | 2016-11-11 16:51:18 +0530 | [diff] [blame] | 507 | addLeaf(name, namespace, null, valueSet, MULTI_INSTANCE_LEAF); |
| 508 | } |
| 509 | |
| 510 | /** |
| 511 | * Adds a last leaf with list of values/single value to YANG data tree. |
| 512 | * This method is used by all protocols which knows the nature |
| 513 | * (single/multiple) or not. |
| 514 | * Value of leaf can be null which indicates selection node in get |
| 515 | * operation. |
| 516 | * |
| 517 | * @param name name of child to be added |
| 518 | * @param namespace namespace of child to be added, if it's |
| 519 | * null, parent's |
| 520 | * namespace will be applied to child |
| 521 | * @param value value of the child |
| 522 | * @param valueSet list of value of the child |
| 523 | * @param cardinality type of YANG data tree node operation |
sonu gupta | eff184b | 2016-11-24 12:43:49 +0530 | [diff] [blame] | 524 | * @throws IllegalArgumentException when method has been passed an illegal |
| 525 | * or inappropriate argument. |
sonu gupta | 1bb37b8 | 2016-11-11 16:51:18 +0530 | [diff] [blame] | 526 | */ |
| 527 | private void addLeaf(String name, String namespace, String value, |
| 528 | Set<String> valueSet, |
sonu gupta | eff184b | 2016-11-24 12:43:49 +0530 | [diff] [blame] | 529 | RequestedCardinality cardinality) |
| 530 | throws IllegalArgumentException { |
| 531 | try { |
| 532 | addChild(name, namespace, cardinality, null, LEAF); |
sonu gupta | 1bb37b8 | 2016-11-11 16:51:18 +0530 | [diff] [blame] | 533 | |
sonu gupta | eff184b | 2016-11-24 12:43:49 +0530 | [diff] [blame] | 534 | // After successful addition of child node updating the values in same. |
| 535 | if (value != null) { |
| 536 | curNode.addValue(value); |
| 537 | } else if (valueSet != null) { |
| 538 | curNode.addValueSet(valueSet); |
| 539 | } |
| 540 | } catch (YdtException e) { |
| 541 | freeRestResources(rootNode); |
| 542 | throw new IllegalArgumentException(e.getLocalizedMessage()); |
sonu gupta | 1bb37b8 | 2016-11-11 16:51:18 +0530 | [diff] [blame] | 543 | } |
| 544 | } |
| 545 | |
| 546 | @Override |
sonu gupta | eff184b | 2016-11-24 12:43:49 +0530 | [diff] [blame] | 547 | public void traverseToParent() throws IllegalStateException { |
sonu gupta | 1bb37b8 | 2016-11-11 16:51:18 +0530 | [diff] [blame] | 548 | // If traverse back to parent for logical root node comes |
| 549 | if (curNode.equals(rootNode)) { |
sonu gupta | eff184b | 2016-11-24 12:43:49 +0530 | [diff] [blame] | 550 | freeRestResources(rootNode); |
| 551 | throw new IllegalStateException(E_INVOKE_PARENT); |
sonu gupta | 1bb37b8 | 2016-11-11 16:51:18 +0530 | [diff] [blame] | 552 | } |
| 553 | |
sonu gupta | eff184b | 2016-11-24 12:43:49 +0530 | [diff] [blame] | 554 | try { |
sonu gupta | 1bb37b8 | 2016-11-11 16:51:18 +0530 | [diff] [blame] | 555 | |
sonu gupta | eff184b | 2016-11-24 12:43:49 +0530 | [diff] [blame] | 556 | // If node is of multiInstanceNode type then check key uniqueness. |
| 557 | if (curNode.getYdtType() == MULTI_INSTANCE_NODE) { |
| 558 | curNode.createKeyNodeList(); |
| 559 | } |
sonu gupta | 1bb37b8 | 2016-11-11 16:51:18 +0530 | [diff] [blame] | 560 | |
sonu gupta | eff184b | 2016-11-24 12:43:49 +0530 | [diff] [blame] | 561 | /* |
| 562 | * Check application switch for curNode if set, |
| 563 | * then traverseToParent in YDT application tree. |
| 564 | */ |
| 565 | if (curNode.getParent().equals(rootNode) || |
| 566 | curNode.getAppContextSwitch()) { |
| 567 | traverseToAppTreeParent(); |
| 568 | } |
sonu gupta | 1bb37b8 | 2016-11-11 16:51:18 +0530 | [diff] [blame] | 569 | |
sonu gupta | eff184b | 2016-11-24 12:43:49 +0530 | [diff] [blame] | 570 | /* |
| 571 | * Validate all multi Instance inside current context, |
| 572 | * This is not valid for leaf and leaf-list node. |
| 573 | */ |
| 574 | if (curNode instanceof YdtMultiInstanceNode || |
| 575 | curNode instanceof YdtSingleInstanceNode) { |
| 576 | curNode.validateMultiInstanceNode(); |
| 577 | } |
| 578 | |
| 579 | curNode = curNode.getParent(); |
| 580 | } catch (YdtException e) { |
| 581 | freeRestResources(rootNode); |
| 582 | throw new IllegalStateException(e.getLocalizedMessage()); |
| 583 | } |
sonu gupta | 1bb37b8 | 2016-11-11 16:51:18 +0530 | [diff] [blame] | 584 | } |
| 585 | |
| 586 | /** |
| 587 | * Traverses up in YANG application tree to the parent node, |
| 588 | * This will be used when Ydt current context switch flag is set. |
| 589 | */ |
| 590 | private void traverseToAppTreeParent() { |
| 591 | appCurNode = appCurNode.getParent(); |
| 592 | } |
| 593 | |
| 594 | @Override |
janani b | 9069eb4 | 2016-11-24 17:50:08 +0530 | [diff] [blame] | 595 | public YdtExtendedContext getCurNode() { |
sonu gupta | 1bb37b8 | 2016-11-11 16:51:18 +0530 | [diff] [blame] | 596 | return curNode; |
| 597 | } |
| 598 | |
| 599 | @Override |
| 600 | public void setDefaultEditOperationType( |
| 601 | YdtContextOperationType opType) { |
| 602 | ydtDefaultOpType = opType; |
| 603 | } |
| 604 | |
| 605 | @Override |
| 606 | public YdtExtendedContext getRootNode() { |
| 607 | return rootNode; |
| 608 | } |
| 609 | |
| 610 | @Override |
| 611 | public YmsOperationType getYmsOperationType() { |
| 612 | return ymsOperationType; |
| 613 | } |
| 614 | |
| 615 | @Override |
| 616 | public void addMultiInstanceChild(String name, String namespace, |
| 617 | List<String> keysValueList, |
sonu gupta | eff184b | 2016-11-24 12:43:49 +0530 | [diff] [blame] | 618 | YdtContextOperationType opType) |
| 619 | throws IllegalArgumentException { |
| 620 | |
sonu gupta | 1bb37b8 | 2016-11-11 16:51:18 +0530 | [diff] [blame] | 621 | addChild(name, namespace, UNKNOWN, opType, |
| 622 | RequestedCallType.MULTI_INSTANCE); |
| 623 | int inputCount = keysValueList.size(); |
sonu gupta | 1bb37b8 | 2016-11-11 16:51:18 +0530 | [diff] [blame] | 624 | |
sonu gupta | eff184b | 2016-11-24 12:43:49 +0530 | [diff] [blame] | 625 | try { |
| 626 | if (curNode.getYdtType() == MULTI_INSTANCE_LEAF_VALUE_NODE) { |
| 627 | |
| 628 | /* |
| 629 | * Calculating the current leaf-list node array size by adding |
| 630 | * existing elements count and new supplied elements by user for |
| 631 | * the same. |
| 632 | */ |
| 633 | // TODO instance count for leaf list need to be handled. |
| 634 | // if (curNode.getValueSet().size() + inputCount > expectedCount) { |
| 635 | // curNode.errorHandler( |
| 636 | // errorMsg(FMT_MANY_INS, name, expectedCount), rootNode); |
| 637 | // } |
| 638 | |
| 639 | /* |
| 640 | * After successful addition of child node updating |
| 641 | * the values in same. |
| 642 | */ |
| 643 | for (String value : keysValueList) { |
| 644 | curNode.addValue(value); |
sonu gupta | 1bb37b8 | 2016-11-11 16:51:18 +0530 | [diff] [blame] | 645 | } |
sonu gupta | eff184b | 2016-11-24 12:43:49 +0530 | [diff] [blame] | 646 | } else if (curNode.getYdtType() == MULTI_INSTANCE_NODE) { |
sonu gupta | 1bb37b8 | 2016-11-11 16:51:18 +0530 | [diff] [blame] | 647 | |
sonu gupta | eff184b | 2016-11-24 12:43:49 +0530 | [diff] [blame] | 648 | YangList yangListHolder = (YangList) curNode.getYangSchemaNode(); |
| 649 | List<String> schemaKeyList = yangListHolder.getKeyList(); |
| 650 | int expectedCount = schemaKeyList.size(); |
| 651 | checkElementCount(name, expectedCount, inputCount); |
| 652 | |
| 653 | //After validation adding the key nodes under the list node. |
| 654 | Iterator<String> sklIter = schemaKeyList.iterator(); |
| 655 | Iterator<String> kvlIter = keysValueList.iterator(); |
| 656 | String keyEleName; |
| 657 | |
| 658 | while (kvlIter.hasNext()) { |
| 659 | String value = kvlIter.next(); |
| 660 | keyEleName = sklIter.next(); |
| 661 | addLeaf(keyEleName, namespace, value); |
| 662 | if (kvlIter.hasNext()) { |
| 663 | traverseToParentWithoutValidation(); |
| 664 | } |
| 665 | } |
| 666 | |
| 667 | curNode = curNode.getParent(); |
| 668 | } |
| 669 | } catch (YdtException e) { |
| 670 | freeRestResources(rootNode); |
| 671 | throw new IllegalArgumentException(e.getLocalizedMessage()); |
sonu gupta | 1bb37b8 | 2016-11-11 16:51:18 +0530 | [diff] [blame] | 672 | } |
| 673 | } |
| 674 | |
| 675 | /** |
| 676 | * Adds a last child to YANG data tree, this method is to be used by |
| 677 | * YANG object builder sub-calls internally. |
| 678 | * |
| 679 | * @param opType type of requested operation over a node |
| 680 | * @return returns added ydt node in YDT tree |
| 681 | */ |
| 682 | private YdtNode addExtendedChildNode(YdtContextOperationType opType, |
| 683 | YangSchemaNode schemaNode) { |
| 684 | |
sonu gupta | eff184b | 2016-11-24 12:43:49 +0530 | [diff] [blame] | 685 | YdtNode childNode = getYangSchemaNodeTypeSpecificContext(schemaNode); |
sonu gupta | 1bb37b8 | 2016-11-11 16:51:18 +0530 | [diff] [blame] | 686 | |
| 687 | childNode.setYangSchemaNode(schemaNode); |
| 688 | |
| 689 | childNode.setYdtContextOperationType(opType); |
| 690 | |
| 691 | curNode.addChild(childNode, true); |
| 692 | |
| 693 | curNode = childNode; |
| 694 | |
| 695 | return childNode; |
| 696 | } |
| 697 | |
| 698 | @Override |
| 699 | public YdtExtendedContext addChild(YdtContextOperationType opType, |
| 700 | YangSchemaNode schemaNode) { |
| 701 | return addExtendedChildNode(opType, schemaNode); |
| 702 | } |
| 703 | |
| 704 | @Override |
| 705 | public YdtExtendedContext addLeafList(Set<String> valueSet, |
| 706 | YangSchemaNode schemaNode) { |
| 707 | YdtNode childNode = addExtendedChildNode(null, schemaNode); |
| 708 | |
sonu gupta | eff184b | 2016-11-24 12:43:49 +0530 | [diff] [blame] | 709 | /* |
| 710 | * After successful addition of child node updating the values in |
| 711 | * valueSet. |
| 712 | */ |
sonu gupta | 1bb37b8 | 2016-11-11 16:51:18 +0530 | [diff] [blame] | 713 | childNode.addValueSetWithoutValidation(valueSet); |
| 714 | return childNode; |
| 715 | } |
| 716 | |
| 717 | @Override |
sonu gupta | eff184b | 2016-11-24 12:43:49 +0530 | [diff] [blame] | 718 | public YdtExtendedContext addLeaf(String value, YangSchemaNode schemaNode) { |
| 719 | |
sonu gupta | 1bb37b8 | 2016-11-11 16:51:18 +0530 | [diff] [blame] | 720 | YdtNode childNode = addExtendedChildNode(null, schemaNode); |
| 721 | |
| 722 | // After successful addition of child node updating the values in same. |
sonu gupta | eff184b | 2016-11-24 12:43:49 +0530 | [diff] [blame] | 723 | childNode.addValueWithoutValidation(value, ((YangLeaf) schemaNode) |
| 724 | .isKeyLeaf()); |
sonu gupta | 1bb37b8 | 2016-11-11 16:51:18 +0530 | [diff] [blame] | 725 | return childNode; |
| 726 | } |
| 727 | |
| 728 | @Override |
sonu gupta | eff184b | 2016-11-24 12:43:49 +0530 | [diff] [blame] | 729 | public void traverseToParentWithoutValidation() |
| 730 | throws IllegalStateException { |
| 731 | // If traverse back to parent for logical root node comes. |
sonu gupta | 1bb37b8 | 2016-11-11 16:51:18 +0530 | [diff] [blame] | 732 | if (curNode.equals(rootNode)) { |
sonu gupta | eff184b | 2016-11-24 12:43:49 +0530 | [diff] [blame] | 733 | freeRestResources(rootNode); |
| 734 | throw new IllegalStateException(E_INVOKE_PARENT); |
sonu gupta | 1bb37b8 | 2016-11-11 16:51:18 +0530 | [diff] [blame] | 735 | } |
| 736 | curNode = curNode.getParent(); |
| 737 | } |
sonu gupta | eff184b | 2016-11-24 12:43:49 +0530 | [diff] [blame] | 738 | |
| 739 | /** |
| 740 | * Returns the method name's set for an augmented target node in an |
| 741 | * application tree. |
| 742 | * |
| 743 | * @return augGenMethodSet set of method name's |
| 744 | */ |
| 745 | public Set<String> getAugGenMethodSet() { |
| 746 | return augGenMethodSet; |
| 747 | } |
| 748 | |
| 749 | /** |
| 750 | * Sets the method name's set for an augmented target node in an |
| 751 | * application tree. |
| 752 | * |
| 753 | * @param augGenMethodSet set of method name's |
| 754 | */ |
| 755 | public void setAugGenMethodSet(Set<String> augGenMethodSet) { |
| 756 | this.augGenMethodSet = augGenMethodSet; |
| 757 | } |
sonu gupta | 1bb37b8 | 2016-11-11 16:51:18 +0530 | [diff] [blame] | 758 | } |