*/
public final class ParserIdentifier {
private static final Logger LOG = LoggerFactory.getLogger(ParserIdentifier.class);
- private static final Splitter MP_SPLITTER = Splitter.on("/" + RestconfConstants.MOUNT);
+
+ // FIXME: Remove this constant. All logic relying on this constant should instead rely on YangInstanceIdentifier
+ // equivalent coming out of argument parsing. This may require keeping List<YangInstanceIdentifier> as the
+ // nested path split on yang-ext:mount. This splitting needs to be based on consulting the
+ // EffectiveModelContext and allowing it only where yang-ext:mount is actually used in models.
+ private static final String MOUNT = "yang-ext:mount";
+ private static final Splitter MP_SPLITTER = Splitter.on("/" + MOUNT);
private ParserIdentifier() {
// Hidden on purpose
//
public static InstanceIdentifierContext toInstanceIdentifier(final String identifier,
final EffectiveModelContext schemaContext, final Optional<DOMMountPointService> mountPointService) {
- if (identifier == null || !identifier.contains(RestconfConstants.MOUNT)) {
+ if (identifier == null || !identifier.contains(MOUNT)) {
return createIIdContext(schemaContext, identifier, null);
}
if (mountPointService.isEmpty()) {
ErrorTag.INVALID_VALUE);
}
- final int mountIndex = identifier.indexOf(RestconfConstants.MOUNT);
+ final int mountIndex = identifier.indexOf(MOUNT);
final String moduleNameAndRevision;
if (mountIndex >= 0) {
- moduleNameAndRevision = identifier.substring(mountIndex + RestconfConstants.MOUNT.length())
- .replaceFirst("/", "");
+ moduleNameAndRevision = identifier.substring(mountIndex + MOUNT.length()).replaceFirst("/", "");
} else {
moduleNameAndRevision = identifier;
}
final DOMYangTextSourceProvider sourceProvider) {
final Iterable<String> pathComponents = RestconfConstants.SLASH_SPLITTER.split(identifier);
final Iterator<String> componentIter = pathComponents.iterator();
- if (!Iterables.contains(pathComponents, RestconfConstants.MOUNT)) {
+ if (!Iterables.contains(pathComponents, MOUNT)) {
final String moduleName = validateAndGetModulName(componentIter);
final Revision revision = validateAndGetRevision(componentIter);
final Module module = schemaContext.findModule(moduleName, revision).orElse(null);
while (componentIter.hasNext()) {
final String current = componentIter.next();
- if (RestconfConstants.MOUNT.equals(current)) {
- pathBuilder.append('/').append(RestconfConstants.MOUNT);
+ if (MOUNT.equals(current)) {
+ pathBuilder.append('/').append(MOUNT);
break;
}
import org.opendaylight.restconf.common.errors.RestconfError;
import org.opendaylight.restconf.nb.rfc8040.TestRestconfUtils;
import org.opendaylight.restconf.nb.rfc8040.rests.services.api.SchemaExportContext;
-import org.opendaylight.restconf.nb.rfc8040.utils.RestconfConstants;
import org.opendaylight.yangtools.yang.common.ErrorTag;
import org.opendaylight.yangtools.yang.common.ErrorType;
import org.opendaylight.yangtools.yang.common.QName;
}
/**
- * Positive test of creating <code>InstanceIdentifierContext</code> from identifier containing
- * {@link RestconfConstants#MOUNT}.
+ * Positive test of creating {@code InstanceIdentifierContext} from identifier containing {@code yang-ext:mount}.
*/
@Test
public void toInstanceIdentifierMountPointTest() {
}
/**
- * Negative test when identifier contains {@link RestconfConstants#MOUNT} but identifier part is not valid. Test
- * should fail with <code>RestconfDocumentedException</code>.
+ * Negative test when identifier contains {@code yang-ext:mount} but identifier part is not valid. Test
+ * should fail with {@link RestconfDocumentedException}.
*/
@Test
public void toInstanceIdentifierMountPointInvalidIdentifierNegativeTest() {