import java.io.IOException;
import java.io.InputStream;
+import java.text.ParseException;
import org.eclipse.jdt.annotation.NonNull;
+import org.opendaylight.restconf.api.ApiPath;
import org.opendaylight.restconf.common.errors.RestconfDocumentedException;
import org.opendaylight.restconf.common.patch.PatchContext;
+import org.opendaylight.restconf.nb.rfc8040.legacy.InstanceIdentifierContext;
import org.opendaylight.restconf.nb.rfc8040.utils.parser.IdentifierCodec;
-import org.opendaylight.restconf.nb.rfc8040.utils.parser.ParserIdentifier;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.patch.rev170222.yang.patch.yang.patch.Edit.Operation;
import org.opendaylight.yangtools.yang.common.ErrorTag;
import org.opendaylight.yangtools.yang.common.ErrorType;
}
try {
- return ParserIdentifier.toInstanceIdentifier(targetUrl, context, null).getInstanceIdentifier();
- } catch (RestconfDocumentedException e) {
+ return InstanceIdentifierContext.ofApiPath(ApiPath.parse(targetUrl), context, null).getInstanceIdentifier();
+ } catch (ParseException | RestconfDocumentedException e) {
throw new RestconfDocumentedException("Failed to parse target " + target,
ErrorType.RPC, ErrorTag.MALFORMED_MESSAGE, e);
}
/**
* Util class for parsing identifier.
*/
-public final class ParserIdentifier {
+@Deprecated(forRemoval = true)
+final class ParserIdentifier {
private ParserIdentifier() {
// Hidden on purpose
}
* @param mountPointService mount point service
* @return {@link InstanceIdentifierContext}
*/
- public static InstanceIdentifierContext toInstanceIdentifier(final String identifier,
+ static InstanceIdentifierContext toInstanceIdentifier(final String identifier,
final EffectiveModelContext schemaContext, final @Nullable DOMMountPointService mountPointService) {
final ApiPath apiPath;
try {
import java.io.IOException;
import java.io.InputStream;
+import java.text.ParseException;
import java.util.Optional;
import java.util.function.Function;
import org.eclipse.jdt.annotation.NonNull;
import org.opendaylight.mdsal.dom.api.DOMMountPointService;
import org.opendaylight.mdsal.dom.api.DOMSchemaService;
import org.opendaylight.mdsal.dom.spi.FixedDOMSchemaService;
+import org.opendaylight.restconf.api.ApiPath;
import org.opendaylight.restconf.common.patch.PatchContext;
import org.opendaylight.restconf.nb.rfc8040.AbstractInstanceIdentifierTest;
-import org.opendaylight.restconf.nb.rfc8040.utils.parser.ParserIdentifier;
+import org.opendaylight.restconf.nb.rfc8040.legacy.InstanceIdentifierContext;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
@RunWith(MockitoJUnitRunner.Silent.class)
} else {
uriPath = prefix + '/' + suffix;
}
+ final ApiPath apiPath;
+ try {
+ apiPath = ApiPath.parse(uriPath);
+ } catch (ParseException e) {
+ throw new AssertionError(e);
+ }
- final var iid = ParserIdentifier.toInstanceIdentifier(uriPath, IID_SCHEMA, mountPointService);
+ final var iid = InstanceIdentifierContext.ofApiPath(apiPath, IID_SCHEMA, mountPointService);
try (var body = bodyConstructor.apply(stringInputStream(patchBody))) {
return body.toPatchContext(iid.getSchemaContext(), iid.getInstanceIdentifier());
import java.io.IOException;
import java.io.InputStream;
+import java.text.ParseException;
import java.util.Optional;
import java.util.function.Function;
import org.eclipse.jdt.annotation.NonNull;
import org.opendaylight.mdsal.dom.api.DOMMountPointService;
import org.opendaylight.mdsal.dom.api.DOMSchemaService;
import org.opendaylight.mdsal.dom.spi.FixedDOMSchemaService;
+import org.opendaylight.restconf.api.ApiPath;
import org.opendaylight.restconf.common.errors.RestconfDocumentedException;
-import org.opendaylight.restconf.nb.rfc8040.utils.parser.ParserIdentifier;
+import org.opendaylight.restconf.nb.rfc8040.legacy.InstanceIdentifierContext;
import org.opendaylight.yangtools.yang.common.ErrorTag;
import org.opendaylight.yangtools.yang.common.ErrorType;
import org.opendaylight.yangtools.yang.common.QName;
}
private @NonNull NormalizedNode parse(final String uriPath, final InputStream patchBody) throws IOException {
+ final ApiPath apiPath;
+ try {
+ apiPath = ApiPath.parse(uriPath);
+ } catch (ParseException e) {
+ throw new AssertionError(e);
+ }
+
try (var body = bodyConstructor.apply(patchBody)) {
- final var context = ParserIdentifier.toInstanceIdentifier(uriPath, MODEL_CONTEXT, mountPointService);
+ final var context = InstanceIdentifierContext.ofApiPath(apiPath, MODEL_CONTEXT, mountPointService);
return body.toNormalizedNode(context.getInstanceIdentifier(), context.inference(), context.getSchemaNode());
}
}