ezntt commented on code in PR #7022:
URL: https://github.com/apache/cloudstack/pull/7022#discussion_r1057732297
##########
api/src/main/java/org/apache/cloudstack/api/BaseCmd.java:
##########
@@ -270,9 +267,22 @@ public String getActualCommandName() {
} else {
cmdName = this.getClass().getName();
}
- return cmdName;
+ return cmdName;
}
+ public static String getCommandNameByClass(Class<?> clazz) {
+ String cmdName = null;
+ if (clazz.getAnnotation(APICommand.class) != null) {
+ cmdName = clazz.getAnnotation(APICommand.class).name();
+ } else {
+ cmdName = clazz.getName();
+ }
+ return cmdName;
+ }
+
+ public static String getResponseNameByClass(Class<?> clazz) {
Review Comment:
> @ezntt , good initiative. What do you propose we do with the remaining 88?
As the PR is intended to clean up the repeated code (it will not change the
APIs behavior), I would rather not touch those 88 APIs here. My proposal for
those remaining 88 APIs is a later discussion on how we should handle them and
if changing them would affect any other place.
> is this being used?
Yes, it is used in class `UploadListener.java`:
```java
public static final Map<String, String> responseNameMap;
static {
Map<String, String> tempMap = new HashMap<String, String>();
tempMap.put(Type.ISO.toString(),
BaseCmd.getResponseNameByClass(ExtractIsoCmd.class));
tempMap.put(Type.TEMPLATE.toString(),
BaseCmd.getResponseNameByClass(ExtractTemplateCmd.class));
tempMap.put(Type.VOLUME.toString(),
BaseCmd.getResponseNameByClass(ExtractVolumeCmd.class));
tempMap.put("DEFAULT", "extractresponse");
responseNameMap = Collections.unmodifiableMap(tempMap);
}
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]