Remove ResourceList class 75/104475/4
authorIvan Hrasko <ivan.hrasko@pantheon.tech>
Wed, 22 Feb 2023 12:46:06 +0000 (13:46 +0100)
committerRobert Varga <nite@hq.sk>
Fri, 24 Feb 2023 08:28:06 +0000 (08:28 +0000)
Remove ResourceList class and all its usages. The methods which were
using it were never called making class itself unused.

In addition, the class was not according to OAS v2 nor OAS v3.

JIRA: NETCONF-938
Change-Id: I9fba1a8425d44c0d8f14233669c4cbbcfc56ee33
Signed-off-by: Ivan Hrasko <ivan.hrasko@pantheon.tech>
restconf/sal-rest-docgen/src/main/java/org/opendaylight/netconf/sal/rest/doc/impl/BaseYangSwaggerGenerator.java
restconf/sal-rest-docgen/src/main/java/org/opendaylight/netconf/sal/rest/doc/swagger/ResourceList.java [deleted file]

index 7c987afd2021d37a2addec1114f8f725df1399cd..864a574f81eb49069bda56f2ea0ab6c2e7ddb3d4 100644 (file)
@@ -7,7 +7,6 @@
  */
 package org.opendaylight.netconf.sal.rest.doc.impl;
 
-import static org.opendaylight.netconf.sal.rest.doc.impl.ApiDocServiceImpl.DEFAULT_PAGESIZE;
 import static org.opendaylight.netconf.sal.rest.doc.model.builder.OperationBuilder.TOP;
 import static org.opendaylight.netconf.sal.rest.doc.model.builder.OperationBuilder.buildDelete;
 import static org.opendaylight.netconf.sal.rest.doc.model.builder.OperationBuilder.buildGet;
@@ -28,9 +27,7 @@ import com.google.common.base.Preconditions;
 import com.google.common.collect.ImmutableList;
 import com.google.common.collect.Range;
 import java.io.IOException;
-import java.net.URI;
 import java.time.format.DateTimeParseException;
-import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collection;
 import java.util.Collections;
@@ -50,8 +47,6 @@ import org.opendaylight.netconf.sal.rest.doc.swagger.CommonApiObject;
 import org.opendaylight.netconf.sal.rest.doc.swagger.Components;
 import org.opendaylight.netconf.sal.rest.doc.swagger.Info;
 import org.opendaylight.netconf.sal.rest.doc.swagger.OpenApiObject;
-import org.opendaylight.netconf.sal.rest.doc.swagger.Resource;
-import org.opendaylight.netconf.sal.rest.doc.swagger.ResourceList;
 import org.opendaylight.netconf.sal.rest.doc.swagger.Server;
 import org.opendaylight.netconf.sal.rest.doc.swagger.SwaggerObject;
 import org.opendaylight.netconf.sal.rest.doc.util.JsonUtil;
@@ -97,54 +92,6 @@ public abstract class BaseYangSwaggerGenerator {
         return schemaService;
     }
 
-    public ResourceList getResourceListing(final UriInfo uriInfo, final EffectiveModelContext schemaContext,
-                                           final String context, final OAversion oaversion) {
-        return getResourceListing(uriInfo, schemaContext, context, 0, true, oaversion);
-    }
-
-    /**
-     * Return list of modules converted to swagger compliant resource list.
-     */
-    public ResourceList getResourceListing(final UriInfo uriInfo, final EffectiveModelContext schemaContext,
-                                           final String context, final int pageNum, final boolean all,
-                                           final OAversion oaversion) {
-        final ResourceList resourceList = createResourceList();
-
-        final Set<Module> modules = getSortedModules(schemaContext);
-
-        final List<Resource> resources = new ArrayList<>(DEFAULT_PAGESIZE);
-
-        LOG.info("Modules found [{}]", modules.size());
-        final int start = DEFAULT_PAGESIZE * pageNum;
-        final int end = start + DEFAULT_PAGESIZE;
-        int count = 0;
-        for (final Module module : modules) {
-            final String revisionString = module.getQNameModule().getRevision().map(Revision::toString).orElse(null);
-
-            LOG.debug("Working on [{},{}]...", module.getName(), revisionString);
-            final SwaggerObject doc = getApiDeclaration(module.getName(), revisionString, uriInfo, schemaContext,
-                    context, oaversion);
-            if (doc != null) {
-                count++;
-                if (count >= start && count < end || all) {
-                    final Resource resource = new Resource();
-                    resource.setPath(generatePath(uriInfo, module.getName(), revisionString));
-                    resources.add(resource);
-                }
-
-                if (count >= end && !all) {
-                    break;
-                }
-            } else {
-                LOG.warn("Could not generate doc for {},{}", module.getName(), revisionString);
-            }
-        }
-
-        resourceList.setApis(resources);
-
-        return resourceList;
-    }
-
     public SwaggerObject getAllModulesDoc(final UriInfo uriInfo, final DefinitionNames definitionNames,
                                           final OAversion oaversion) {
         final EffectiveModelContext schemaContext = schemaService.getGlobalContext();
@@ -220,18 +167,6 @@ public abstract class BaseYangSwaggerGenerator {
         }
     }
 
-    public ResourceList createResourceList() {
-        final ResourceList resourceList = new ResourceList();
-        resourceList.setApiVersion(API_VERSION);
-        resourceList.setSwaggerVersion(SWAGGER_VERSION);
-        return resourceList;
-    }
-
-    public String generatePath(final UriInfo uriInfo, final String name, final String revision) {
-        final URI uri = uriInfo.getRequestUriBuilder().replaceQuery("").path(generateCacheKey(name, revision)).build();
-        return uri.toASCIIString();
-    }
-
     public CommonApiObject getApiDeclaration(final String module, final String revision, final UriInfo uriInfo,
                                              final OAversion oaversion) {
         final EffectiveModelContext schemaContext = schemaService.getGlobalContext();
@@ -288,7 +223,6 @@ public abstract class BaseYangSwaggerGenerator {
             true);
     }
 
-
     public SwaggerObject getSwaggerDocSpec(final Module module, final String context, final Optional<String> deviceName,
                                            final EffectiveModelContext schemaContext, final OAversion oaversion,
                                            final DefinitionNames definitionNames, final SwaggerObject doc,
@@ -432,10 +366,6 @@ public abstract class BaseYangSwaggerGenerator {
 
     public abstract String getResourcePathPart(String resourceType);
 
-    private static String generateCacheKey(final String module, final String revision) {
-        return module + "(" + revision + ")";
-    }
-
     private void addPaths(final DataSchemaNode node, final Optional<String> deviceName, final String moduleName,
                           final ObjectNode paths, final ArrayNode parentPathParams,
                           final EffectiveModelContext schemaContext, final boolean isConfig, final String parentName,
diff --git a/restconf/sal-rest-docgen/src/main/java/org/opendaylight/netconf/sal/rest/doc/swagger/ResourceList.java b/restconf/sal-rest-docgen/src/main/java/org/opendaylight/netconf/sal/rest/doc/swagger/ResourceList.java
deleted file mode 100644 (file)
index 3e8c7b7..0000000
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * Copyright (c) 2014 Cisco Systems, Inc. and others.  All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-package org.opendaylight.netconf.sal.rest.doc.swagger;
-
-import java.util.List;
-
-/**
- * Implementation of swagger spec (see <a href=
- * "https://github.com/wordnik/swagger-spec/blob/master/versions/1.2.md#51-resource-listing"
- * > https://github.com/wordnik/swagger-spec/blob/master/versions/1.2.md#51-
- * resource-listing</a>).
- */
-public class ResourceList {
-    private String apiVersion;
-    private String swaggerVersion;
-    private List<Resource> apis;
-
-    public String getApiVersion() {
-        return apiVersion;
-    }
-
-    public void setApiVersion(String apiVersion) {
-        this.apiVersion = apiVersion;
-    }
-
-    public String getSwaggerVersion() {
-        return swaggerVersion;
-    }
-
-    public void setSwaggerVersion(String swaggerVersion) {
-        this.swaggerVersion = swaggerVersion;
-    }
-
-    public List<Resource> getApis() {
-        return apis;
-    }
-
-    public void setApis(List<Resource> apis) {
-        this.apis = apis;
-    }
-}