Bug 5526 - Implementations of services
[netconf.git] / restconf / sal-rest-connector / src / main / java / org / opendaylight / restconf / rest / impl / services / RestconfSchemaServiceImpl.java
1 /*
2  * Copyright (c) 2016 Cisco Systems, Inc. and others.  All rights reserved.
3  *
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
7  */
8 package org.opendaylight.restconf.rest.impl.services;
9
10 import org.opendaylight.netconf.md.sal.rest.schema.SchemaExportContext;
11 import org.opendaylight.restconf.rest.api.schema.context.SchemaContextHandler;
12 import org.opendaylight.restconf.rest.api.services.schema.RestconfSchemaService;
13 import org.opendaylight.restconf.utils.parser.ParserIdentifier;
14 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
15
16 /**
17  * Implementation of {@link RestconfSchemaService}.
18  *
19  */
20 public class RestconfSchemaServiceImpl implements RestconfSchemaService {
21
22     private final SchemaContextHandler schemaContextHandler;
23
24     /**
25      * Set {@link SchemaContextHandler} for getting actual {@link SchemaContext}
26      * .
27      *
28      * @param schemaContextHandler
29      *            - handling schema context
30      */
31     public RestconfSchemaServiceImpl(final SchemaContextHandler schemaContextHandler) {
32         this.schemaContextHandler = schemaContextHandler;
33     }
34
35     @Override
36     public SchemaExportContext getSchema(final String identifier) {
37         final SchemaContextRef schemaContextRef = new SchemaContextRef(this.schemaContextHandler.getSchemaContext());
38         return ParserIdentifier.toSchemaExportContextFromIdentifier(schemaContextRef.get(), identifier);
39     }
40 }