2 * Copyright (c) 2016 Cisco Systems, Inc. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
8 package org.opendaylight.restconf.nb.rfc8040.rests.services.impl;
10 import static com.google.common.base.Preconditions.checkArgument;
11 import static java.util.Objects.requireNonNull;
13 import javax.ws.rs.Path;
14 import org.opendaylight.mdsal.dom.api.DOMMountPointService;
15 import org.opendaylight.mdsal.dom.api.DOMSchemaService;
16 import org.opendaylight.mdsal.dom.api.DOMYangTextSourceProvider;
17 import org.opendaylight.restconf.nb.rfc8040.rests.services.api.RestconfSchemaService;
18 import org.opendaylight.restconf.nb.rfc8040.rests.services.api.SchemaExportContext;
19 import org.opendaylight.restconf.nb.rfc8040.utils.parser.ParserIdentifier;
22 * Implementation of {@link RestconfSchemaService}.
25 public class RestconfSchemaServiceImpl implements RestconfSchemaService {
26 private final DOMSchemaService schemaService;
27 private final DOMMountPointService mountPointService;
28 private final DOMYangTextSourceProvider sourceProvider;
31 * Default constructor.
33 * @param schemaService a {@link DOMSchemaService}
34 * @param mountPointService a {@link DOMMountPointService}
36 public RestconfSchemaServiceImpl(final DOMSchemaService schemaService,
37 final DOMMountPointService mountPointService) {
38 this.schemaService = requireNonNull(schemaService);
39 this.mountPointService = requireNonNull(mountPointService);
40 sourceProvider = schemaService.getExtensions().getInstance(DOMYangTextSourceProvider.class);
41 checkArgument(sourceProvider != null, "No DOMYangTextSourceProvider available in %s", schemaService);
45 public SchemaExportContext getSchema(final String identifier) {
46 return ParserIdentifier.toSchemaExportContextFromIdentifier(schemaService.getGlobalContext(), identifier,
47 mountPointService, sourceProvider);