Skip to content

Commit be76a51

Browse files
committed
Api xml doc generator: define if command is sync or async in the xml doc
1 parent 7c7710c commit be76a51

3 files changed

Lines changed: 32 additions & 4 deletions

File tree

server/src/com/cloud/api/doc/ApiXmlDocReader.java

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,6 @@ public static void main (String[] args) {
110110
}
111111
}
112112

113-
114113
try {
115114
FileWriter fstream = new FileWriter(dirName + "/diff.txt");
116115
BufferedWriter out = new BufferedWriter(fstream);
@@ -130,12 +129,25 @@ public static void main (String[] args) {
130129
out.write("\nRemoved commands:\n");
131130
for (Command c : removedCommands) {
132131
if (c.getDescription() != null && !c.getDescription().isEmpty()) {
133-
out.write("\n " + c.getName() + " (" + c.getDescription() + ")\n");
132+
out.write("\n\t" + c.getName() + " (" + c.getDescription() + ")\n");
134133
} else {
135-
out.write("\n " + c.getName() + "\n");
134+
out.write("\n\t" + c.getName() + "\n");
136135
}
137136

138137
}
138+
139+
out.write("\n Changes in command type (sync versus async");
140+
//Verify if the command was sync and became async and vice versa
141+
for (String key : stableCommands.keySet()) {
142+
if (commands.get(key).isAsync() != oldCommands.get(key).isAsync()) {
143+
String type = "Sync";
144+
if (commands.get(key).isAsync()) {
145+
type = "Async";
146+
}
147+
out.write("\n\t" + stableCommands.get(key).getName() + " became " + type);
148+
}
149+
}
150+
139151

140152
//Print differences between commands arguments
141153
out.write("\nChanges in commands arguments:\n");

server/src/com/cloud/api/doc/ApiXmlDocWriter.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -314,6 +314,13 @@ private static void writeCommand(ObjectOutputStream out, String command) throws
314314
request = setRequestFields(fields);
315315

316316

317+
//Set Async information for the command
318+
if (superName.equals(BaseAsyncCmd.class.getName()) || superName.equals(BaseAsyncCreateCmd.class.getName())) {
319+
apiCommand.setAsync(true);
320+
} else {
321+
apiCommand.setAsync(false);
322+
}
323+
317324
//Get response parameters
318325
Class<?> responseClas = impl.responseObject();
319326
Field[] responseFields = responseClas.getDeclaredFields();

server/src/com/cloud/api/doc/Command.java

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ public class Command {
2424

2525
private String name;
2626
private String description;
27+
private boolean isAsync;
2728
private ArrayList<Argument> request;
2829
private ArrayList<Argument> response;
2930

@@ -66,7 +67,15 @@ public void setResponse(ArrayList<Argument> response) {
6667
this.response = response;
6768
}
6869

69-
public Argument getReqArgByName(String name){
70+
public boolean isAsync() {
71+
return isAsync;
72+
}
73+
74+
public void setAsync(boolean isAsync) {
75+
this.isAsync = isAsync;
76+
}
77+
78+
public Argument getReqArgByName(String name){
7079
for (Argument a : this.getRequest()) {
7180
if (a.getName().equals(name)) {
7281
return a;

0 commit comments

Comments
 (0)