mirror of https://github.com/apache/cloudstack.git
Generate alerts_types.xml document along with other xml docs.
This commit is contained in:
parent
a705b104e7
commit
e256285b05
|
|
@ -0,0 +1,20 @@
|
|||
package com.cloud.api.doc;
|
||||
|
||||
public class Alert {
|
||||
private String type;
|
||||
private int value;
|
||||
|
||||
public Alert(String type, int value) {
|
||||
this.type = type;
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public int getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -41,6 +41,7 @@ import java.util.zip.ZipOutputStream;
|
|||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import com.cloud.alert.AlertManager;
|
||||
import com.cloud.api.BaseAsyncCmd;
|
||||
import com.cloud.api.BaseAsyncCreateCmd;
|
||||
import com.cloud.api.BaseCmd;
|
||||
|
|
@ -200,6 +201,9 @@ public class ApiXmlDocWriter {
|
|||
regularUser.close();
|
||||
regularUserSorted.close();
|
||||
|
||||
//write alerttypes to xml
|
||||
writeAlertTypes(xmlDocDir);
|
||||
|
||||
//gzip directory with xml doc
|
||||
//zipDir(dirName + "xmldoc.zip", xmlDocDir);
|
||||
|
||||
|
|
@ -401,6 +405,25 @@ public class ApiXmlDocWriter {
|
|||
}
|
||||
|
||||
|
||||
private static void writeAlertTypes(String dirName) {
|
||||
XStream xs = new XStream();
|
||||
xs.alias("alert", Alert.class);
|
||||
try {
|
||||
ObjectOutputStream out = xs.createObjectOutputStream(new FileWriter(dirName + "/alert_types.xml"), "alerts");
|
||||
for(Field f : AlertManager.class.getFields()){
|
||||
String name = f.getName().substring(11);
|
||||
Alert alert = new Alert(name, f.getInt(null));
|
||||
out.writeObject(alert);
|
||||
}
|
||||
out.close();
|
||||
} catch (IOException e) {
|
||||
s_logger.error("Failed to create output stream to write an alert types ", e);
|
||||
} catch (IllegalAccessException e) {
|
||||
s_logger.error("Failed to read alert fields ", e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private static class LinkedProperties extends Properties {
|
||||
private final LinkedList<Object> keys = new LinkedList<Object>();
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue