From faa379b6c2d82d5c51ce034fbd698cb71f3dcecc Mon Sep 17 00:00:00 2001 From: Min Chen Date: Thu, 22 May 2014 16:56:36 -0700 Subject: [PATCH] CLOUDSTACK-6752: IAM command class separation caused ApiDoc warning of duplicated cmd class for the same api name. --- .../src/com/cloud/api/doc/ApiXmlDocWriter.java | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/server/src/com/cloud/api/doc/ApiXmlDocWriter.java b/server/src/com/cloud/api/doc/ApiXmlDocWriter.java index c19f7af8c35..0194f07c2c4 100644 --- a/server/src/com/cloud/api/doc/ApiXmlDocWriter.java +++ b/server/src/com/cloud/api/doc/ApiXmlDocWriter.java @@ -105,10 +105,21 @@ public class ApiXmlDocWriter { for (Class cmdClass : cmdClasses) { String apiName = cmdClass.getAnnotation(APICommand.class).name(); if (s_apiNameCmdClassMap.containsKey(apiName)) { - System.out.println("Warning, API Cmd class " + cmdClass.getName() + " has non-unique apiname" + apiName); - continue; + // handle API cmd separation into admin cmd and user cmd with the common api name + Class curCmd = s_apiNameCmdClassMap.get(apiName); + if (curCmd.isAssignableFrom(cmdClass)) { + // api_cmd map always keep the admin cmd class to get full response and parameters + s_apiNameCmdClassMap.put(apiName, cmdClass); + } else if (cmdClass.isAssignableFrom(curCmd)) { + // just skip this one without warning + continue; + } else { + System.out.println("Warning, API Cmd class " + cmdClass.getName() + " has non-unique apiname " + apiName); + continue; + } + } else { + s_apiNameCmdClassMap.put(apiName, cmdClass); } - s_apiNameCmdClassMap.put(apiName, cmdClass); } LinkedProperties preProcessedCommands = new LinkedProperties();