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.rest.services.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.netconf.sal.restconf.impl.RestconfDocumentedException;
20 import org.opendaylight.yangtools.yang.common.QName;
21 import org.opendaylight.yangtools.yang.common.QNameModule;
22 import org.opendaylight.yangtools.yang.common.SimpleDateFormatUtil;
23 import org.opendaylight.yangtools.yang.model.api.AugmentationSchema;
24 import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode;
25 import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
26 import org.opendaylight.yangtools.yang.model.api.Deviation;
27 import org.opendaylight.yangtools.yang.model.api.ExtensionDefinition;
28 import org.opendaylight.yangtools.yang.model.api.FeatureDefinition;
29 import org.opendaylight.yangtools.yang.model.api.GroupingDefinition;
30 import org.opendaylight.yangtools.yang.model.api.IdentitySchemaNode;
31 import org.opendaylight.yangtools.yang.model.api.Module;
32 import org.opendaylight.yangtools.yang.model.api.ModuleImport;
33 import org.opendaylight.yangtools.yang.model.api.NotificationDefinition;
34 import org.opendaylight.yangtools.yang.model.api.RpcDefinition;
35 import org.opendaylight.yangtools.yang.model.api.TypeDefinition;
36 import org.opendaylight.yangtools.yang.model.api.UnknownSchemaNode;
37 import org.opendaylight.yangtools.yang.model.api.UsesNode;
40 * Special case only use by GET restconf/operations (since moment of old Yang
41 * parser and old yang model API removal) to build and use fake module to create
45 class ModuleImpl implements Module {
47 private final List<DataSchemaNode> listChild = new ArrayList<>();
48 static QNameModule moduleQName;
52 date = SimpleDateFormatUtil.getRevisionFormat().parse("2016-06-28");
53 } catch (final ParseException e) {
54 throw new RestconfDocumentedException("Problem while parsing revision.", e);
57 moduleQName = QNameModule.create(new URI("urn:ietf:params:xml:ns:yang:ietf-restconf"), date);
58 } catch (final URISyntaxException e) {
59 throw new RestconfDocumentedException("Problem while creating URI.", e);
64 * Set container for this module
66 * @param fakeContSchNode
67 * - fake container schema node
70 public ModuleImpl(final ContainerSchemaNode fakeContSchNode) {
71 this.listChild.add(fakeContSchNode);
75 public Set<TypeDefinition<?>> getTypeDefinitions() {
76 throw new UnsupportedOperationException("Not supported operations.");
80 public Collection<DataSchemaNode> getChildNodes() {
81 return this.listChild;
85 public Set<GroupingDefinition> getGroupings() {
86 throw new UnsupportedOperationException("Not supported operations.");
90 public DataSchemaNode getDataChildByName(final QName name) {
91 for (final DataSchemaNode node : this.listChild) {
92 if (node.getQName().equals(name)) {
96 throw new RestconfDocumentedException(name + " is not in child of " + ModuleImpl.moduleQName);
100 public DataSchemaNode getDataChildByName(final String name) {
101 for (final DataSchemaNode node : this.listChild) {
102 if (node.getQName().getLocalName().equals(name)) {
106 throw new RestconfDocumentedException(name + " is not in child of " + ModuleImpl.moduleQName);
110 public Set<UsesNode> getUses() {
111 throw new UnsupportedOperationException("Not supported operations.");
115 public String getModuleSourcePath() {
116 throw new UnsupportedOperationException("Not supported operations.");
120 public QNameModule getQNameModule() {
125 public String getName() {
126 return "ietf-restconf";
130 public URI getNamespace() {
131 return moduleQName.getNamespace();
135 public Date getRevision() {
136 return moduleQName.getRevision();
140 public String getPrefix() {
145 public String getYangVersion() {
146 throw new UnsupportedOperationException("Not supported operations.");
150 public String getDescription() {
151 throw new UnsupportedOperationException("Not supported operations.");
155 public String getReference() {
156 throw new UnsupportedOperationException("Not supported operations.");
160 public String getOrganization() {
161 throw new UnsupportedOperationException("Not supported operations.");
165 public String getContact() {
166 throw new UnsupportedOperationException("Not supported operations.");
170 public Set<ModuleImport> getImports() {
171 return new HashSet<>();
175 public Set<Module> getSubmodules() {
176 throw new UnsupportedOperationException("Not supported operations.");
180 public Set<FeatureDefinition> getFeatures() {
181 throw new UnsupportedOperationException("Not supported operations.");
185 public Set<NotificationDefinition> getNotifications() {
186 throw new UnsupportedOperationException("Not supported operations.");
190 public Set<AugmentationSchema> getAugmentations() {
191 throw new UnsupportedOperationException("Not supported operations.");
195 public Set<RpcDefinition> getRpcs() {
196 throw new UnsupportedOperationException("Not supported operations.");
200 public Set<Deviation> getDeviations() {
201 throw new UnsupportedOperationException("Not supported operations.");
205 public Set<IdentitySchemaNode> getIdentities() {
206 throw new UnsupportedOperationException("Not supported operations.");
210 public List<ExtensionDefinition> getExtensionSchemaNodes() {
211 throw new UnsupportedOperationException("Not supported operations.");
215 public List<UnknownSchemaNode> getUnknownSchemaNodes() {
216 throw new UnsupportedOperationException("Not supported operations.");
220 public String getSource() {
221 throw new UnsupportedOperationException("Not supported operations.");