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.netconf.sal.restconf.impl;
11 import java.net.URISyntaxException;
12 import java.text.ParseException;
13 import java.util.ArrayList;
14 import java.util.Collection;
15 import java.util.Date;
16 import java.util.HashSet;
17 import java.util.List;
19 import org.opendaylight.yangtools.yang.common.QName;
20 import org.opendaylight.yangtools.yang.common.QNameModule;
21 import org.opendaylight.yangtools.yang.common.SimpleDateFormatUtil;
22 import org.opendaylight.yangtools.yang.model.api.AugmentationSchema;
23 import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode;
24 import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
25 import org.opendaylight.yangtools.yang.model.api.Deviation;
26 import org.opendaylight.yangtools.yang.model.api.ExtensionDefinition;
27 import org.opendaylight.yangtools.yang.model.api.FeatureDefinition;
28 import org.opendaylight.yangtools.yang.model.api.GroupingDefinition;
29 import org.opendaylight.yangtools.yang.model.api.IdentitySchemaNode;
30 import org.opendaylight.yangtools.yang.model.api.Module;
31 import org.opendaylight.yangtools.yang.model.api.ModuleImport;
32 import org.opendaylight.yangtools.yang.model.api.NotificationDefinition;
33 import org.opendaylight.yangtools.yang.model.api.RpcDefinition;
34 import org.opendaylight.yangtools.yang.model.api.TypeDefinition;
35 import org.opendaylight.yangtools.yang.model.api.UnknownSchemaNode;
36 import org.opendaylight.yangtools.yang.model.api.UsesNode;
39 * Special case only use by GET restconf/operations (since moment of old Yang
40 * parser and old yang model API removal) to build and use fake module to create
44 class ModuleImpl implements Module {
46 private final List<DataSchemaNode> listChild = new ArrayList<>();
47 static QNameModule moduleQName;
51 date = SimpleDateFormatUtil.getRevisionFormat().parse("2016-06-28");
52 } catch (final ParseException e) {
53 throw new RestconfDocumentedException("Problem while parsing revision.", e);
56 moduleQName = QNameModule.create(new URI("urn:ietf:params:xml:ns:yang:ietf-restconf"), date);
57 } catch (final URISyntaxException e) {
58 throw new RestconfDocumentedException("Problem while creating URI.", e);
63 * Set container for this module
65 * @param fakeContSchNode
66 * - fake container schema node
69 public ModuleImpl(final ContainerSchemaNode fakeContSchNode) {
70 this.listChild.add(fakeContSchNode);
74 public Set<TypeDefinition<?>> getTypeDefinitions() {
75 throw new UnsupportedOperationException("Not supported operations.");
79 public Collection<DataSchemaNode> getChildNodes() {
80 return this.listChild;
84 public Set<GroupingDefinition> getGroupings() {
85 throw new UnsupportedOperationException("Not supported operations.");
89 public DataSchemaNode getDataChildByName(final QName name) {
90 for (final DataSchemaNode node : this.listChild) {
91 if (node.getQName().equals(name)) {
95 throw new RestconfDocumentedException(name + " is not in child of " + ModuleImpl.moduleQName);
99 public Set<UsesNode> getUses() {
100 throw new UnsupportedOperationException("Not supported operations.");
104 public String getModuleSourcePath() {
105 throw new UnsupportedOperationException("Not supported operations.");
109 public QNameModule getQNameModule() {
114 public String getName() {
115 return "ietf-restconf";
119 public URI getNamespace() {
120 return moduleQName.getNamespace();
124 public Date getRevision() {
125 return moduleQName.getRevision();
129 public String getPrefix() {
134 public String getYangVersion() {
135 throw new UnsupportedOperationException("Not supported operations.");
139 public String getDescription() {
140 throw new UnsupportedOperationException("Not supported operations.");
144 public String getReference() {
145 throw new UnsupportedOperationException("Not supported operations.");
149 public String getOrganization() {
150 throw new UnsupportedOperationException("Not supported operations.");
154 public String getContact() {
155 throw new UnsupportedOperationException("Not supported operations.");
159 public Set<ModuleImport> getImports() {
160 return new HashSet<>();
164 public Set<Module> getSubmodules() {
165 throw new UnsupportedOperationException("Not supported operations.");
169 public Set<FeatureDefinition> getFeatures() {
170 throw new UnsupportedOperationException("Not supported operations.");
174 public Set<NotificationDefinition> getNotifications() {
175 throw new UnsupportedOperationException("Not supported operations.");
179 public Set<AugmentationSchema> getAugmentations() {
180 throw new UnsupportedOperationException("Not supported operations.");
184 public Set<RpcDefinition> getRpcs() {
185 throw new UnsupportedOperationException("Not supported operations.");
189 public Set<Deviation> getDeviations() {
190 throw new UnsupportedOperationException("Not supported operations.");
194 public Set<IdentitySchemaNode> getIdentities() {
195 throw new UnsupportedOperationException("Not supported operations.");
199 public List<ExtensionDefinition> getExtensionSchemaNodes() {
200 throw new UnsupportedOperationException("Not supported operations.");
204 public List<UnknownSchemaNode> getUnknownSchemaNodes() {
205 throw new UnsupportedOperationException("Not supported operations.");
209 public String getSource() {
210 throw new UnsupportedOperationException("Not supported operations.");