From: Michael Vorburger Date: Mon, 30 May 2016 17:41:35 +0000 (+0200) Subject: Clean up a lot of JavaDoc etc. to conform to current Checkstyle rules X-Git-Tag: release/boron~91^2 X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=commitdiff_plain;h=2678c08c680a02e5acbcbed30b8c966e8f5552dc;p=netconf.git Clean up a lot of JavaDoc etc. to conform to current Checkstyle rules Change-Id: I1b5613ad00633e6b59626dacca08f8c458f076f3 Signed-off-by: Michael Vorburger --- diff --git a/restconf/sal-rest-docgen/src/main/java/org/opendaylight/netconf/sal/rest/doc/api/ApiDocService.java b/restconf/sal-rest-docgen/src/main/java/org/opendaylight/netconf/sal/rest/doc/api/ApiDocService.java index 71e54bb752..e30dff77bf 100644 --- a/restconf/sal-rest-docgen/src/main/java/org/opendaylight/netconf/sal/rest/doc/api/ApiDocService.java +++ b/restconf/sal-rest-docgen/src/main/java/org/opendaylight/netconf/sal/rest/doc/api/ApiDocService.java @@ -28,9 +28,6 @@ public interface ApiDocService { * Generates index document for Swagger UI. This document lists out all * modules with link to get APIs for each module. The API for each module is * served by getDocByModule() method. - * - * @param uriInfo - * @return */ @GET @Produces(MediaType.APPLICATION_JSON) @@ -38,11 +35,6 @@ public interface ApiDocService { /** * Generates Swagger compliant document listing APIs for module. - * - * @param module - * @param revision - * @param uriInfo - * @return */ @GET @Path("/{module}({revision})") @@ -52,9 +44,6 @@ public interface ApiDocService { /** * Redirects to embedded swagger ui. - * - * @param uriInfo - * @return */ @GET @Path("/ui") @@ -65,9 +54,6 @@ public interface ApiDocService { * Generates index document for Swagger UI. This document lists out all * modules with link to get APIs for each module. The API for each module is * served by getDocByModule() method. - * - * @param uriInfo - * @return */ @GET @Path("/mounts") @@ -82,11 +68,6 @@ public interface ApiDocService { /** * Generates Swagger compliant document listing APIs for module. - * - * @param module - * @param revision - * @param uriInfo - * @return */ @GET @Path("/mounts/{instance}/{module}({revision})") diff --git a/restconf/sal-rest-docgen/src/main/java/org/opendaylight/netconf/sal/rest/doc/impl/ApiDocGenerator.java b/restconf/sal-rest-docgen/src/main/java/org/opendaylight/netconf/sal/rest/doc/impl/ApiDocGenerator.java index 64afdc7900..59cbba0719 100644 --- a/restconf/sal-rest-docgen/src/main/java/org/opendaylight/netconf/sal/rest/doc/impl/ApiDocGenerator.java +++ b/restconf/sal-rest-docgen/src/main/java/org/opendaylight/netconf/sal/rest/doc/impl/ApiDocGenerator.java @@ -15,7 +15,8 @@ import org.opendaylight.netconf.sal.rest.doc.swagger.ResourceList; import org.opendaylight.yangtools.yang.model.api.SchemaContext; /** - * This class gathers all YANG-defined {@link org.opendaylight.yangtools.yang.model.api.Module}s and generates Swagger compliant documentation. + * This class gathers all YANG-defined {@link org.opendaylight.yangtools.yang.model.api.Module}s and + * generates Swagger compliant documentation. */ public class ApiDocGenerator extends BaseYangSwaggerGenerator { @@ -36,18 +37,12 @@ public class ApiDocGenerator extends BaseYangSwaggerGenerator { } /** - * Returns singleton instance - * - * @return + * Returns singleton instance. */ public static ApiDocGenerator getInstance() { return INSTANCE; } - /** - * - * @param schemaService - */ public void setSchemaService(SchemaService schemaService) { this.schemaService = schemaService; } diff --git a/restconf/sal-rest-docgen/src/main/java/org/opendaylight/netconf/sal/rest/doc/impl/ApiDocServiceImpl.java b/restconf/sal-rest-docgen/src/main/java/org/opendaylight/netconf/sal/rest/doc/impl/ApiDocServiceImpl.java index 1f964a8500..f3294ec3d0 100644 --- a/restconf/sal-rest-docgen/src/main/java/org/opendaylight/netconf/sal/rest/doc/impl/ApiDocServiceImpl.java +++ b/restconf/sal-rest-docgen/src/main/java/org/opendaylight/netconf/sal/rest/doc/impl/ApiDocServiceImpl.java @@ -26,12 +26,11 @@ import org.opendaylight.netconf.sal.rest.doc.swagger.ResourceList; * >https://helloreverb.com/developers/swagger) compliant documentation for * RESTCONF APIs. The output of this is used by embedded Swagger UI. * - * NOTE: These API's need to be synchronized due to bug 1198. Thread access to + *

NOTE: These API's need to be synchronized due to bug 1198. Thread access to * the SchemaContext is not synchronized properly and thus you can end up with * missing definitions without this synchronization. There are likely otherways * to work around this limitation, but given that this API is a dev only tool * and not dependent UI, this was the fastest work around. - * */ public class ApiDocServiceImpl implements ApiDocService { @@ -45,9 +44,6 @@ public class ApiDocServiceImpl implements ApiDocService { * Generates index document for Swagger UI. This document lists out all * modules with link to get APIs for each module. The API for each module is * served by getDocByModule() method. - * - * @param uriInfo - * @return */ @Override public synchronized Response getRootDoc(UriInfo uriInfo) { @@ -59,11 +55,6 @@ public class ApiDocServiceImpl implements ApiDocService { /** * Generates Swagger compliant document listing APIs for module. - * - * @param module - * @param revision - * @param uriInfo - * @return */ @Override public synchronized Response getDocByModule(String module, String revision, UriInfo uriInfo) { @@ -75,9 +66,6 @@ public class ApiDocServiceImpl implements ApiDocService { /** * Redirects to embedded swagger ui. - * - * @param uriInfo - * @return */ @Override public synchronized Response getApiExplorer(UriInfo uriInfo) { diff --git a/restconf/sal-rest-docgen/src/main/java/org/opendaylight/netconf/sal/rest/doc/impl/BaseYangSwaggerGenerator.java b/restconf/sal-rest-docgen/src/main/java/org/opendaylight/netconf/sal/rest/doc/impl/BaseYangSwaggerGenerator.java index bc4c6bba8f..1db67f8301 100644 --- a/restconf/sal-rest-docgen/src/main/java/org/opendaylight/netconf/sal/rest/doc/impl/BaseYangSwaggerGenerator.java +++ b/restconf/sal-rest-docgen/src/main/java/org/opendaylight/netconf/sal/rest/doc/impl/BaseYangSwaggerGenerator.java @@ -22,7 +22,6 @@ import java.util.Arrays; import java.util.Calendar; import java.util.Collection; import java.util.Collections; -import java.util.Comparator; import java.util.Date; import java.util.GregorianCalendar; import java.util.List; @@ -64,7 +63,7 @@ public class BaseYangSwaggerGenerator { protected static final String RESTCONF_CONTEXT_ROOT = "restconf"; static final String MODULE_NAME_SUFFIX = "_module"; - protected final DateFormat SIMPLE_DATE_FORMAT = new SimpleDateFormat("yyyy-MM-dd"); + protected static final DateFormat SIMPLE_DATE_FORMAT = new SimpleDateFormat("yyyy-MM-dd"); private final ModelGenerator jsonConverter = new ModelGenerator(); // private Map MODULE_DOC_CACHE = new HashMap<>() @@ -76,11 +75,7 @@ public class BaseYangSwaggerGenerator { } /** - * - * @param uriInfo - * @param schemaContext - * @param context - * @return list of modules converted to swagger compliant resource list. + * Return list of modules converted to swagger compliant resource list. */ public ResourceList getResourceListing(UriInfo uriInfo, SchemaContext schemaContext, String context) { @@ -123,31 +118,32 @@ public class BaseYangSwaggerGenerator { return uri.toASCIIString(); } - public ApiDeclaration getApiDeclaration(String module, String revision, UriInfo uriInfo, SchemaContext schemaContext, String context) { + public ApiDeclaration getApiDeclaration(String moduleName, String revision, UriInfo uriInfo, SchemaContext schemaContext, String context) { Date rev = null; try { - if(revision != null && !revision.equals("0000-00-00")) { + if (revision != null && !revision.equals("0000-00-00")) { rev = SIMPLE_DATE_FORMAT.parse(revision); } } catch (ParseException e) { throw new IllegalArgumentException(e); } - if(rev != null) { + if (rev != null) { Calendar cal = new GregorianCalendar(); cal.setTime(rev); - if(cal.get(Calendar.YEAR) < 1970) { + if (cal.get(Calendar.YEAR) < 1970) { rev = null; } } - Module m = schemaContext.findModuleByName(module, rev); - Preconditions.checkArgument(m != null, "Could not find module by name,revision: " + module + "," + revision); + Module module = schemaContext.findModuleByName(moduleName, rev); + Preconditions.checkArgument(module != null, + "Could not find module by name,revision: " + moduleName + "," + revision); - return getApiDeclaration(m, rev, uriInfo, context, schemaContext); + return getApiDeclaration(module, rev, uriInfo, context, schemaContext); } public ApiDeclaration getApiDeclaration(Module module, Date revision, UriInfo uriInfo, String context, SchemaContext schemaContext) { @@ -175,7 +171,7 @@ public class BaseYangSwaggerGenerator { public ApiDeclaration getSwaggerDocSpec(Module m, String basePath, String context, SchemaContext schemaContext) { ApiDeclaration doc = createApiDeclaration(basePath); - List apis = new ArrayList(); + List apis = new ArrayList<>(); Collection dataSchemaNodes = m.getChildNodes(); LOG.debug("child nodes size [{}]", dataSchemaNodes.size()); @@ -184,12 +180,12 @@ public class BaseYangSwaggerGenerator { LOG.debug("Is Configuration node [{}] [{}]", node.isConfiguration(), node.getQName().getLocalName()); - List pathParams = new ArrayList(); + List pathParams = new ArrayList<>(); String resourcePath = getDataStorePath("/config/", context); addRootPostLink(m, (DataNodeContainer) node, pathParams, resourcePath, apis); addApis(node, apis, resourcePath, pathParams, schemaContext, true); - pathParams = new ArrayList(); + pathParams = new ArrayList<>(); resourcePath = getDataStorePath("/operational/", context); addApis(node, apis, resourcePath, pathParams, schemaContext, false); } @@ -222,12 +218,13 @@ public class BaseYangSwaggerGenerator { return null; } - private void addRootPostLink(final Module m, final DataNodeContainer node, final List pathParams, + private void addRootPostLink(final Module module, final DataNodeContainer node, final List pathParams, final String resourcePath, final List apis) { - if (containsListOrContainer(m.getChildNodes())) { + if (containsListOrContainer(module.getChildNodes())) { final Api apiForRootPostUri = new Api(); apiForRootPostUri.setPath(resourcePath); - apiForRootPostUri.setOperations(operationPost(m.getName()+MODULE_NAME_SUFFIX, m.getDescription(), m, pathParams, true)); + apiForRootPostUri.setOperations(operationPost(module.getName() + MODULE_NAME_SUFFIX, + module.getDescription(), module, pathParams, true)); apis.add(apiForRootPostUri); } } @@ -245,10 +242,6 @@ public class BaseYangSwaggerGenerator { return dataStore + context; } - private String generateCacheKey(Module m) { - return generateCacheKey(m.getName(), SIMPLE_DATE_FORMAT.format(m.getRevision())); - } - private String generateCacheKey(String module, String revision) { return module + "(" + revision + ")"; } @@ -257,13 +250,13 @@ public class BaseYangSwaggerGenerator { boolean addConfigApi) { Api api = new Api(); - List pathParams = new ArrayList(parentPathParams); + List pathParams = new ArrayList<>(parentPathParams); String resourcePath = parentPath + createPath(node, pathParams, schemaContext) + "/"; LOG.debug("Adding path: [{}]", resourcePath); api.setPath(resourcePath); - Iterable childSchemaNodes = Collections. emptySet(); + Iterable childSchemaNodes = Collections.emptySet(); if ((node instanceof ListSchemaNode) || (node instanceof ContainerSchemaNode)) { DataNodeContainer dataNodeContainer = (DataNodeContainer) node; childSchemaNodes = dataNodeContainer.getChildNodes(); @@ -291,11 +284,6 @@ public class BaseYangSwaggerGenerator { return false; } - /** - * @param node - * @param pathParams - * @return - */ private List operation(DataSchemaNode node, List pathParams, boolean isConfig, Iterable childSchemaNodes) { List operations = new ArrayList<>(); @@ -311,18 +299,13 @@ public class BaseYangSwaggerGenerator { operations.add(deleteBuilder.pathParams(pathParams).build()); if (containsListOrContainer(childSchemaNodes)) { - operations.addAll(operationPost(node.getQName().getLocalName(), node.getDescription(), (DataNodeContainer) node, - pathParams, isConfig)); + operations.addAll(operationPost(node.getQName().getLocalName(), node.getDescription(), + (DataNodeContainer) node, pathParams, isConfig)); } } return operations; } - /** - * @param node - * @param pathParams - * @return - */ private List operationPost(final String name, final String description, final DataNodeContainer dataNodeContainer, List pathParams, boolean isConfig) { List operations = new ArrayList<>(); if (isConfig) { @@ -333,7 +316,7 @@ public class BaseYangSwaggerGenerator { } private String createPath(final DataSchemaNode schemaNode, List pathParams, SchemaContext schemaContext) { - ArrayList pathListParams = new ArrayList(); + ArrayList pathListParams = new ArrayList<>(); StringBuilder path = new StringBuilder(); String localName = resolvePathArgumentsName(schemaNode, schemaContext); path.append(localName); @@ -341,8 +324,8 @@ public class BaseYangSwaggerGenerator { if ((schemaNode instanceof ListSchemaNode)) { final List listKeys = ((ListSchemaNode) schemaNode).getKeyDefinition(); for (final QName listKey : listKeys) { - DataSchemaNode _dataChildByName = ((DataNodeContainer) schemaNode).getDataChildByName(listKey); - pathListParams.add(((LeafSchemaNode) _dataChildByName)); + DataSchemaNode dataChildByName = ((DataNodeContainer) schemaNode).getDataChildByName(listKey); + pathListParams.add(((LeafSchemaNode) dataChildByName)); String pathParamIdentifier = new StringBuilder("/{").append(listKey.getLocalName()).append("}") .toString(); @@ -350,7 +333,7 @@ public class BaseYangSwaggerGenerator { Parameter pathParam = new Parameter(); pathParam.setName(listKey.getLocalName()); - pathParam.setDescription(_dataChildByName.getDescription()); + pathParam.setDescription(dataChildByName.getDescription()); pathParam.setType("string"); pathParam.setParamType("path"); @@ -392,20 +375,17 @@ public class BaseYangSwaggerGenerator { Set modules = schemaContext.getModules(); - SortedSet sortedModules = new TreeSet<>(new Comparator() { - @Override - public int compare(Module module1, Module module2) { - int result = module1.getName().compareTo(module2.getName()); - if (result == 0) { - Date module1Revision = module1.getRevision() != null ? module1.getRevision() : new Date(0); - Date module2Revision = module2.getRevision() != null ? module2.getRevision() : new Date(0); - result = module1Revision.compareTo(module2Revision); - } - if (result == 0) { - result = module1.getNamespace().compareTo(module2.getNamespace()); - } - return result; + SortedSet sortedModules = new TreeSet<>((module1, module2) -> { + int result = module1.getName().compareTo(module2.getName()); + if (result == 0) { + Date module1Revision = module1.getRevision() != null ? module1.getRevision() : new Date(0); + Date module2Revision = module2.getRevision() != null ? module2.getRevision() : new Date(0); + result = module1Revision.compareTo(module2Revision); + } + if (result == 0) { + result = module1.getNamespace().compareTo(module2.getNamespace()); } + return result; }); for (Module m : modules) { if (m != null) { diff --git a/restconf/sal-rest-docgen/src/main/java/org/opendaylight/netconf/sal/rest/doc/impl/ModelGenerator.java b/restconf/sal-rest-docgen/src/main/java/org/opendaylight/netconf/sal/rest/doc/impl/ModelGenerator.java index c0490c857b..04b80b94ce 100644 --- a/restconf/sal-rest-docgen/src/main/java/org/opendaylight/netconf/sal/rest/doc/impl/ModelGenerator.java +++ b/restconf/sal-rest-docgen/src/main/java/org/opendaylight/netconf/sal/rest/doc/impl/ModelGenerator.java @@ -54,7 +54,7 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; /** - * Generates JSON Schema for data defined in Yang + * Generates JSON Schema for data defined in YANG. */ @NotThreadSafe public class ModelGenerator { @@ -123,7 +123,7 @@ public class ModelGenerator { } private void processModules(final Module module, final JSONObject models) throws JSONException { - createConcreteModelForPost(models, module.getName()+ BaseYangSwaggerGenerator.MODULE_NAME_SUFFIX, createPropertiesForPost(module)); + createConcreteModelForPost(models, module.getName() + BaseYangSwaggerGenerator.MODULE_NAME_SUFFIX, createPropertiesForPost(module)); } private void processContainersAndLists(final Module module, final JSONObject models, final SchemaContext schemaContext) @@ -182,7 +182,6 @@ public class ModelGenerator { * The module from which the identity stmt will be processed * @param models * The JSONObject in which the parsed identity will be put as a 'model' obj - * @throws JSONException */ private static void processIdentities(final Module module, final JSONObject models) throws JSONException { @@ -229,13 +228,7 @@ public class ModelGenerator { } /** - * Processes the container and list nodes and populates the moduleJSON - * - * @param container - * @param moduleName - * @param isConfig - * @throws JSONException - * @throws IOException + * Processes the container and list nodes and populates the moduleJSON. */ private JSONObject processDataNodeContainer(final DataNodeContainer dataNode, final String moduleName, final JSONObject models, final SchemaContext schemaContext) throws JSONException, IOException { @@ -295,7 +288,7 @@ public class ModelGenerator { property.put(TYPE_KEY, childNode instanceof ListSchemaNode ? ARRAY_TYPE : OBJECT_TYPE); property.put(ITEMS_KEY, items); properties.put(childNode.getQName().getLocalName(), property); - } else if (childNode instanceof LeafSchemaNode){ + } else if (childNode instanceof LeafSchemaNode) { JSONObject property = processLeafNode((LeafSchemaNode)childNode); properties.put(childNode.getQName().getLocalName(), property); } @@ -309,18 +302,11 @@ public class ModelGenerator { } /** - * Processes the nodes - * - * @param nodes - * @param parentQName - * @param moduleName - * @param isConfig - * @return - * @throws JSONException - * @throws IOException + * Processes the nodes. */ - private JSONObject processChildren(final Iterable nodes, final QName parentQName, final String moduleName, - final JSONObject models, final boolean isConfig, final SchemaContext schemaContext) throws JSONException, IOException { + private JSONObject processChildren(final Iterable nodes, final QName parentQName, + final String moduleName, final JSONObject models, final boolean isConfig, final SchemaContext schemaContext) + throws JSONException, IOException { JSONObject properties = new JSONObject(); @@ -359,11 +345,6 @@ public class ModelGenerator { return properties; } - /** - * - * @param listNode - * @throws JSONException - */ private JSONObject processLeafListNode(final LeafListSchemaNode listNode) throws JSONException { JSONObject props = new JSONObject(); props.put(TYPE_KEY, ARRAY_TYPE); @@ -378,13 +359,6 @@ public class ModelGenerator { return props; } - /** - * - * @param choiceNode - * @param moduleName - * @throws JSONException - * @throws IOException - */ private JSONObject processChoiceNode(final ChoiceSchemaNode choiceNode, final String moduleName, final JSONObject models, final SchemaContext schemaContext) throws JSONException, IOException { @@ -408,12 +382,6 @@ public class ModelGenerator { return oneOfProps; } - /** - * - * @param constraints - * @param props - * @throws JSONException - */ private static void processConstraints(final ConstraintDefinition constraints, final JSONObject props) throws JSONException { boolean isMandatory = constraints.isMandatory(); props.put(REQUIRED_KEY, isMandatory); @@ -428,12 +396,6 @@ public class ModelGenerator { } } - /** - * - * @param leafNode - * @return - * @throws JSONException - */ private JSONObject processLeafNode(final LeafSchemaNode leafNode) throws JSONException { JSONObject property = new JSONObject(); @@ -446,12 +408,6 @@ public class ModelGenerator { return property; } - /** - * - * @param leafNode - * @return - * @throws JSONException - */ private static JSONObject processAnyXMLNode(final AnyXmlSchemaNode leafNode) throws JSONException { JSONObject property = new JSONObject(); @@ -463,12 +419,7 @@ public class ModelGenerator { return property; } - /** - * @param property - * @throws JSONException - */ private void processTypeDef(final TypeDefinition leafTypeDef, final JSONObject property) throws JSONException { - if (leafTypeDef instanceof ExtendedType) { processExtendedType(leafTypeDef, property); } else if (leafTypeDef instanceof BinaryTypeDefinition) { @@ -478,7 +429,8 @@ public class ModelGenerator { } else if (leafTypeDef instanceof EnumTypeDefinition) { processEnumType((EnumTypeDefinition) leafTypeDef, property); } else if (leafTypeDef instanceof IdentityrefTypeDefinition) { - property.putOpt(TYPE_KEY, ((IdentityrefTypeDefinition) leafTypeDef).getIdentity().getQName().getLocalName()); + property.putOpt(TYPE_KEY, + ((IdentityrefTypeDefinition) leafTypeDef).getIdentity().getQName().getLocalName()); } else if (leafTypeDef instanceof StringTypeDefinition) { processStringType((StringTypeDefinition) leafTypeDef, property); } else if (leafTypeDef instanceof UnionTypeDefinition) { @@ -492,12 +444,6 @@ public class ModelGenerator { } } - /** - * - * @param leafTypeDef - * @param property - * @throws JSONException - */ private void processExtendedType(final TypeDefinition leafTypeDef, final JSONObject property) throws JSONException { TypeDefinition leafBaseType = leafTypeDef.getBaseType(); if (leafBaseType instanceof ExtendedType) { @@ -524,27 +470,15 @@ public class ModelGenerator { property.put(MEDIA_KEY, media); } - /** - * - * @param enumLeafType - * @param property - * @throws JSONException - */ private static void processEnumType(final EnumTypeDefinition enumLeafType, final JSONObject property) throws JSONException { List enumPairs = enumLeafType.getValues(); - List enumNames = new ArrayList(); + List enumNames = new ArrayList<>(); for (EnumPair enumPair : enumPairs) { enumNames.add(enumPair.getName()); } property.putOpt(ENUM, new JSONArray(enumNames)); } - /** - * - * @param bitsType - * @param property - * @throws JSONException - */ private static void processBitsType(final BitsTypeDefinition bitsType, final JSONObject property) throws JSONException { property.put(TYPE_KEY, ARRAY_TYPE); property.put(MIN_ITEMS, 0); @@ -564,8 +498,8 @@ public class ModelGenerator { StringTypeDefinition type = stringType; List lengthConstraints = stringType.getLengthConstraints(); while (lengthConstraints.isEmpty() && type.getBaseType() != null) { - type = type.getBaseType(); - lengthConstraints = type.getLengthConstraints(); + type = type.getBaseType(); + lengthConstraints = type.getLengthConstraints(); } // FIXME: json-schema is not expressive enough to capture min/max laternatives. We should find the true minimum @@ -580,14 +514,7 @@ public class ModelGenerator { property.put(TYPE_KEY, STRING); } - /** - * - * @param unionType - * @param property - * @throws JSONException - */ private static void processUnionType(final UnionTypeDefinition unionType, final JSONObject property) throws JSONException { - StringBuilder type = new StringBuilder(); for (TypeDefinition typeDef : unionType.getTypes()) { if (type.length() > 0) { @@ -601,9 +528,6 @@ public class ModelGenerator { /** * Helper method to generate a pre-filled JSON schema object. - * - * @return - * @throws JSONException */ private static JSONObject getSchemaTemplate() throws JSONException { JSONObject schemaJSON = new JSONObject(); diff --git a/restconf/sal-rest-docgen/src/main/java/org/opendaylight/netconf/sal/rest/doc/jaxrs/JaxbContextResolver.java b/restconf/sal-rest-docgen/src/main/java/org/opendaylight/netconf/sal/rest/doc/jaxrs/JaxbContextResolver.java index 8208c8102c..de4e0a966f 100644 --- a/restconf/sal-rest-docgen/src/main/java/org/opendaylight/netconf/sal/rest/doc/jaxrs/JaxbContextResolver.java +++ b/restconf/sal-rest-docgen/src/main/java/org/opendaylight/netconf/sal/rest/doc/jaxrs/JaxbContextResolver.java @@ -33,13 +33,11 @@ public class JaxbContextResolver implements ContextResolver { } @Override - public ObjectMapper getContext(Class aClass) { - - if (ApiDeclaration.class.isAssignableFrom(aClass)) { + public ObjectMapper getContext(Class klass) { + if (ApiDeclaration.class.isAssignableFrom(klass)) { return ctx; } - return null;// must return null so that jax-rs can continue context - // search + return null; // must return null so that JAX-RS can continue context search } } diff --git a/restconf/sal-rest-docgen/src/main/java/org/opendaylight/netconf/sal/rest/doc/model/builder/OperationBuilder.java b/restconf/sal-rest-docgen/src/main/java/org/opendaylight/netconf/sal/rest/doc/model/builder/OperationBuilder.java index d4f01744cd..98f8af76d8 100644 --- a/restconf/sal-rest-docgen/src/main/java/org/opendaylight/netconf/sal/rest/doc/model/builder/OperationBuilder.java +++ b/restconf/sal-rest-docgen/src/main/java/org/opendaylight/netconf/sal/rest/doc/model/builder/OperationBuilder.java @@ -22,6 +22,7 @@ public final class OperationBuilder { public static final String CONFIG = "(config)"; public static final List CONSUMES_PUT_POST = new ArrayList<>(); + static { CONSUMES_PUT_POST.add("application/json"); CONSUMES_PUT_POST.add("application/xml"); @@ -110,7 +111,7 @@ public final class OperationBuilder { Parameter payload = new Parameter(); payload.setParamType("body"); payload.setType(CONFIG + node.getQName().getLocalName()); - payload.setName("**"+CONFIG + node.getQName().getLocalName()); + payload.setName("**" + CONFIG + node.getQName().getLocalName()); parameters.add(payload); } } diff --git a/restconf/sal-rest-docgen/src/main/java/org/opendaylight/netconf/sal/rest/doc/mountpoints/MountPointSwagger.java b/restconf/sal-rest-docgen/src/main/java/org/opendaylight/netconf/sal/rest/doc/mountpoints/MountPointSwagger.java index b20aa967b9..89a75b0c28 100644 --- a/restconf/sal-rest-docgen/src/main/java/org/opendaylight/netconf/sal/rest/doc/mountpoints/MountPointSwagger.java +++ b/restconf/sal-rest-docgen/src/main/java/org/opendaylight/netconf/sal/rest/doc/mountpoints/MountPointSwagger.java @@ -9,7 +9,6 @@ package org.opendaylight.netconf.sal.rest.doc.mountpoints; import com.google.common.base.Optional; import java.util.Collections; -import java.util.Comparator; import java.util.HashMap; import java.util.LinkedList; import java.util.List; @@ -43,12 +42,7 @@ public class MountPointSwagger extends BaseYangSwaggerGenerator implements Mount private DOMMountPointService mountService; private final Map instanceIdToLongId = new TreeMap<>( - new Comparator() { - @Override - public int compare(final YangInstanceIdentifier o1, final YangInstanceIdentifier o2) { - return o1.toString().compareToIgnoreCase(o2.toString()); - } - }); + (o1, o2) -> o1.toString().compareToIgnoreCase(o2.toString())); private final Map longIdToInstanceId = new HashMap<>(); private final Object lock = new Object(); @@ -116,7 +110,6 @@ public class MountPointSwagger extends BaseYangSwaggerGenerator implements Mount return null; // indicating not found. } SchemaContext context = getSchemaContext(iid); - String urlPrefix = getYangMountUrl(iid); if (context == null) { return createResourceList(); } @@ -125,6 +118,7 @@ public class MountPointSwagger extends BaseYangSwaggerGenerator implements Mount dataStores.setDescription("Provides methods for accessing the data stores."); dataStores.setPath(generatePath(uriInfo, DATASTORES_LABEL, DATASTORES_REVISION)); resources.add(dataStores); + String urlPrefix = getYangMountUrl(iid); ResourceList list = super.getResourceListing(uriInfo, context, urlPrefix); resources.addAll(list.getApis()); list.setApis(resources); @@ -172,8 +166,6 @@ public class MountPointSwagger extends BaseYangSwaggerGenerator implements Mount } private ApiDeclaration generateDataStoreApiDoc(final UriInfo uriInfo, final String context) { - - ApiDeclaration declaration = super.createApiDeclaration(createBasePathFromUriInfo(uriInfo)); List apis = new LinkedList<>(); apis.add(createGetApi("config", "Queries the config (startup) datastore on the mounted hosted.", context)); @@ -181,6 +173,8 @@ public class MountPointSwagger extends BaseYangSwaggerGenerator implements Mount "Queries the operational (running) datastore on the mounted hosted.", context)); apis.add(createGetApi("operations", "Queries the available operations (RPC calls) on the mounted hosted.", context)); + + ApiDeclaration declaration = super.createApiDeclaration(createBasePathFromUriInfo(uriInfo)); declaration.setApis(apis); return declaration; diff --git a/restconf/sal-rest-docgen/src/main/java/org/opendaylight/netconf/sal/rest/doc/util/RestDocgenUtil.java b/restconf/sal-rest-docgen/src/main/java/org/opendaylight/netconf/sal/rest/doc/util/RestDocgenUtil.java index 697fdcc00f..55d92c73f6 100644 --- a/restconf/sal-rest-docgen/src/main/java/org/opendaylight/netconf/sal/rest/doc/util/RestDocgenUtil.java +++ b/restconf/sal-rest-docgen/src/main/java/org/opendaylight/netconf/sal/rest/doc/util/RestDocgenUtil.java @@ -22,13 +22,14 @@ public class RestDocgenUtil { private RestDocgenUtil() { } - private static Map> namespaceAndRevisionToModule = new HashMap>(); + private static Map> namespaceAndRevisionToModule = new HashMap<>(); /** * Resolve path argument name for {@code node}. * - * The name can contain also prefix which consists of module name followed by colon. The module prefix is presented - * if namespace of {@code node} and its parent is different. In other cases only name of {@code node} is returned. + *

The name can contain also prefix which consists of module name followed by colon. The module + * prefix is presented if namespace of {@code node} and its parent is different. In other cases + * only name of {@code node} is returned. * * @return name of {@code node} */ @@ -48,7 +49,8 @@ public class RestDocgenUtil { } } - private synchronized static String resolveFullNameFromNode(final SchemaNode node, final SchemaContext schemaContext) { + private static synchronized String resolveFullNameFromNode(final SchemaNode node, + final SchemaContext schemaContext) { final URI namespace = node.getQName().getNamespace(); final Date revision = node.getQName().getRevision(); @@ -68,7 +70,8 @@ public class RestDocgenUtil { return node.getQName().getLocalName(); } - public static String resolveNodesName(final SchemaNode node, final Module module, final SchemaContext schemaContext) { + public static String resolveNodesName(final SchemaNode node, final Module module, + final SchemaContext schemaContext) { if (node.getQName().getNamespace().equals(module.getQNameModule().getNamespace()) && node.getQName().getRevision().equals(module.getQNameModule().getRevision())) { return node.getQName().getLocalName();