- final DOMMountPoint mountPoint = payload.getInstanceIdentifierContext().getMountPoint();
- final EffectiveModelContext ref = mountPoint == null
- ? schemaContextHandler.get() : modelContext(mountPoint);
-
- final RestconfStrategy strategy = getRestconfStrategy(mountPoint);
- return PutDataTransactionUtil.putData(payload, ref, strategy, checkedParms.insert, checkedParms.point);
- }
-
- private static QueryParams checkQueryParameters(final UriInfo uriInfo) {
- boolean insertUsed = false;
- boolean pointUsed = false;
- InsertParameter insert = null;
- PointParameter point = null;
-
- for (final Entry<String, List<String>> entry : uriInfo.getQueryParameters().entrySet()) {
- final String uriName = entry.getKey();
- if (InsertParameter.uriName().equals(uriName)) {
- if (insertUsed) {
- throw new RestconfDocumentedException("Insert parameter can be used only once.",
- ErrorType.PROTOCOL, ErrorTag.BAD_ELEMENT);
- }
-
- insertUsed = true;
- final String str = entry.getValue().get(0);
- insert = InsertParameter.forUriValue(str);
- if (insert == null) {
- throw new RestconfDocumentedException("Unrecognized insert parameter value '" + str + "'",
- ErrorType.PROTOCOL, ErrorTag.BAD_ELEMENT);
- }
- } else if (PointParameter.uriName().equals(uriName)) {
- if (pointUsed) {
- throw new RestconfDocumentedException("Point parameter can be used only once.",
- ErrorType.PROTOCOL, ErrorTag.BAD_ELEMENT);
- }
-
- pointUsed = true;
- point = PointParameter.forUriValue(entry.getValue().get(0));
- } else {
- throw new RestconfDocumentedException("Bad parameter for post: " + uriName,
- ErrorType.PROTOCOL, ErrorTag.BAD_ELEMENT);
- }
- }
-
- checkQueryParams(insertUsed, pointUsed, insert);
- return new QueryParams(insert, point);
- }
-
- private static void checkQueryParams(final boolean insertUsed, final boolean pointUsed,
- final InsertParameter insert) {
- if (pointUsed) {
- if (!insertUsed) {
- throw new RestconfDocumentedException("Point parameter can't be used without Insert parameter.",
- ErrorType.PROTOCOL, ErrorTag.BAD_ELEMENT);
- }
- if (insert != InsertParameter.BEFORE && insert != InsertParameter.AFTER) {
- throw new RestconfDocumentedException(
- "Point parameter can be used only with 'after' or 'before' values of Insert parameter.",
- ErrorType.PROTOCOL, ErrorTag.BAD_ELEMENT);
- }
- }