Skip to content

Commit

Permalink
CLOUDSTACK-8562: Deprecate commands.properties
Browse files Browse the repository at this point in the history
- Fixes apidocs and marvin to be independent of commands.properties usage
- Removes bundling of commands.properties in deb/rpm packaging
- Removes file references across codebase

Signed-off-by: Rohit Yadav <[email protected]>
  • Loading branch information
rohityadavcloud committed Apr 12, 2016
1 parent 0dcaf19 commit 5e5ee17
Show file tree
Hide file tree
Showing 13 changed files with 32 additions and 528 deletions.
File renamed without changes.
1 change: 0 additions & 1 deletion debian/cloudstack-management.install
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
/etc/cloudstack/management/catalina.policy
/etc/cloudstack/management/catalina.properties
/etc/cloudstack/management/logging.properties
/etc/cloudstack/management/commands.properties
/etc/cloudstack/management/ehcache.xml
/etc/cloudstack/management/server-ssl.xml
/etc/cloudstack/management/server-nonssl.xml
Expand Down
3 changes: 0 additions & 3 deletions scripts/installer/windows/client.wxs
Original file line number Diff line number Diff line change
Expand Up @@ -595,9 +595,6 @@
<Component Id="cmp71D36BFB6B214FAAD323C31A1CE3BC19" Guid="{EF4C61E1-F77E-4E4D-80EA-131511E0804E}">
<File Id="fil44B623C422B90349A635A113C5F4D417" KeyPath="yes" Source="!(wix.SourceClient)\WEB-INF\classes\cloudmanagementserver.keystore" />
</Component>
<Component Id="cmp19EB0E73466EB36D5AA02AB4CE8164B0" Guid="{D3EDCF5B-8A0F-444B-AE64-6C3EEE5F25F0}">
<File Id="filAB20DD6954DD207821DD0311C1F48FAA" KeyPath="yes" Source="!(wix.SourceClient)\WEB-INF\classes\commands.properties" />
</Component>
<Component Id="cmp68E096BB729948107692341D8202CC5A" Guid="{0D5D3AF3-0BC0-48EE-ABA3-AF07535169BF}">
<File Id="fil3E9BCB1A8CB8F8415FE3E71B65A94878" KeyPath="yes" Source="!(wix.SourceClient)\WEB-INF\classes\context.xml" />
</Component>
Expand Down
120 changes: 9 additions & 111 deletions server/src/com/cloud/api/doc/ApiXmlDocWriter.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.FileWriter;
import java.io.IOException;
Expand All @@ -67,16 +66,10 @@
public class ApiXmlDocWriter {
public static final Logger s_logger = Logger.getLogger(ApiXmlDocWriter.class.getName());

private static final short DOMAIN_ADMIN_COMMAND = 4;
private static final short USER_COMMAND = 8;
private static String s_dirName = "";
private static Map<String, Class<?>> s_apiNameCmdClassMap = new HashMap<String, Class<?>>();
private static LinkedHashMap<Object, String> s_allApiCommands = new LinkedHashMap<Object, String>();
private static LinkedHashMap<Object, String> s_domainAdminApiCommands = new LinkedHashMap<Object, String>();
private static LinkedHashMap<Object, String> s_regularUserApiCommands = new LinkedHashMap<Object, String>();
private static TreeMap<Object, String> s_allApiCommandsSorted = new TreeMap<Object, String>();
private static TreeMap<Object, String> s_domainAdminApiCommandsSorted = new TreeMap<Object, String>();
private static TreeMap<Object, String> s_regularUserApiCommandsSorted = new TreeMap<Object, String>();
private static String s_dirName = "";
private static final List<String> AsyncResponses = setAsyncResponses();

private static List<String> setAsyncResponses() {
Expand Down Expand Up @@ -123,155 +116,61 @@ public static void main(String[] args) {
s_apiNameCmdClassMap.put(apiName, cmdClass);
}
}

LinkedProperties preProcessedCommands = new LinkedProperties();
String[] fileNames = null;

System.out.printf("Scanned and found %d APIs\n", s_apiNameCmdClassMap.size());
List<String> argsList = Arrays.asList(args);
Iterator<String> iter = argsList.iterator();
while (iter.hasNext()) {
String arg = iter.next();
// populate the file names
if (arg.equals("-f")) {
fileNames = iter.next().split(",");
}
if (arg.equals("-d")) {
s_dirName = iter.next();
}
}

if ((fileNames == null) || (fileNames.length == 0)) {
System.out.println("Please specify input file(s) separated by coma using -f option");
System.exit(2);
}

for (String fileName : fileNames) {
try(FileInputStream in = new FileInputStream(fileName);) {
preProcessedCommands.load(in);
} catch (FileNotFoundException ex) {
System.out.println("Can't find file " + fileName);
System.exit(2);
} catch (IOException ex1) {
System.out.println("Error reading from file " + ex1);
System.exit(2);
}
}

Iterator<?> propertiesIterator = preProcessedCommands.keys.iterator();
// Get command classes and response object classes
while (propertiesIterator.hasNext()) {
String key = (String)propertiesIterator.next();
String preProcessedCommand = preProcessedCommands.getProperty(key);
int splitIndex = preProcessedCommand.lastIndexOf(";");
String commandRoleMask = preProcessedCommand.substring(splitIndex + 1);
Class<?> cmdClass = s_apiNameCmdClassMap.get(key);
if (cmdClass == null) {
System.out.println("Check, is this api part of another build profile? Null value for key: " + key + " preProcessedCommand=" + preProcessedCommand);
continue;
}
String commandName = cmdClass.getName();
s_allApiCommands.put(key, commandName);

short cmdPermissions = 1;
if (commandRoleMask != null) {
cmdPermissions = Short.parseShort(commandRoleMask);
}

if ((cmdPermissions & DOMAIN_ADMIN_COMMAND) != 0) {
s_domainAdminApiCommands.put(key, commandName);
}
if ((cmdPermissions & USER_COMMAND) != 0) {
s_regularUserApiCommands.put(key, commandName);
}
for (Map.Entry<String, Class<?>> entry: s_apiNameCmdClassMap.entrySet()) {
Class<?> cls = entry.getValue();
s_allApiCommands.put(entry.getKey(), cls.getName());
}

s_allApiCommandsSorted.putAll(s_allApiCommands);
s_domainAdminApiCommandsSorted.putAll(s_domainAdminApiCommands);
s_regularUserApiCommandsSorted.putAll(s_regularUserApiCommands);

try {
// Create object writer
XStream xs = new XStream();
xs.alias("command", Command.class);
xs.alias("arg", Argument.class);
String xmlDocDir = s_dirName + "/xmldoc";
String rootAdminDirName = xmlDocDir + "/root_admin";
String domainAdminDirName = xmlDocDir + "/domain_admin";
String regularUserDirName = xmlDocDir + "/regular_user";
String rootAdminDirName = xmlDocDir + "/apis";
(new File(rootAdminDirName)).mkdirs();
(new File(domainAdminDirName)).mkdirs();
(new File(regularUserDirName)).mkdirs();

ObjectOutputStream out = xs.createObjectOutputStream(new FileWriter(s_dirName + "/commands.xml"), "commands");
ObjectOutputStream rootAdmin = xs.createObjectOutputStream(new FileWriter(rootAdminDirName + "/" + "rootAdminSummary.xml"), "commands");
ObjectOutputStream rootAdminSorted = xs.createObjectOutputStream(new FileWriter(rootAdminDirName + "/" + "rootAdminSummarySorted.xml"), "commands");
ObjectOutputStream domainAdmin = xs.createObjectOutputStream(new FileWriter(domainAdminDirName + "/" + "domainAdminSummary.xml"), "commands");
ObjectOutputStream outDomainAdminSorted = xs.createObjectOutputStream(new FileWriter(domainAdminDirName + "/" + "domainAdminSummarySorted.xml"), "commands");
ObjectOutputStream regularUser = xs.createObjectOutputStream(new FileWriter(regularUserDirName + "/regularUserSummary.xml"), "commands");
ObjectOutputStream regularUserSorted = xs.createObjectOutputStream(new FileWriter(regularUserDirName + "/regularUserSummarySorted.xml"), "commands");

// Write commands in the order they are represented in commands.properties.in file
ObjectOutputStream rootAdmin = xs.createObjectOutputStream(new FileWriter(rootAdminDirName + "/" + "apiSummary.xml"), "commands");
ObjectOutputStream rootAdminSorted = xs.createObjectOutputStream(new FileWriter(rootAdminDirName + "/" + "apiSummarySorted.xml"), "commands");

Iterator<?> it = s_allApiCommands.keySet().iterator();
while (it.hasNext()) {
String key = (String)it.next();

// Write admin commands
writeCommand(out, key);
writeCommand(rootAdmin, key);

// Write single commands to separate xml files
ObjectOutputStream singleRootAdminCommandOs = xs.createObjectOutputStream(new FileWriter(rootAdminDirName + "/" + key + ".xml"), "command");
writeCommand(singleRootAdminCommandOs, key);
singleRootAdminCommandOs.close();

if (s_domainAdminApiCommands.containsKey(key)) {
writeCommand(domainAdmin, key);
ObjectOutputStream singleDomainAdminCommandOs = xs.createObjectOutputStream(new FileWriter(domainAdminDirName + "/" + key + ".xml"), "command");
writeCommand(singleDomainAdminCommandOs, key);
singleDomainAdminCommandOs.close();
}

if (s_regularUserApiCommands.containsKey(key)) {
writeCommand(regularUser, key);
ObjectOutputStream singleRegularUserCommandOs = xs.createObjectOutputStream(new FileWriter(regularUserDirName + "/" + key + ".xml"), "command");
writeCommand(singleRegularUserCommandOs, key);
singleRegularUserCommandOs.close();
}
}

// Write sorted commands
it = s_allApiCommandsSorted.keySet().iterator();
while (it.hasNext()) {
String key = (String)it.next();

writeCommand(rootAdminSorted, key);

if (s_domainAdminApiCommands.containsKey(key)) {
writeCommand(outDomainAdminSorted, key);
}

if (s_regularUserApiCommands.containsKey(key)) {
writeCommand(regularUserSorted, key);
}
}

out.close();
rootAdmin.close();
rootAdminSorted.close();
domainAdmin.close();
outDomainAdminSorted.close();
regularUser.close();
regularUserSorted.close();

// write alerttypes to xml
writeAlertTypes(xmlDocDir);

// gzip directory with xml doc
// zipDir(dirName + "xmldoc.zip", xmlDocDir);

// Delete directory
// deleteDir(new File(xmlDocDir));

} catch (Exception ex) {
ex.printStackTrace();
System.exit(2);
Expand Down Expand Up @@ -537,5 +436,4 @@ public Object put(Object key, Object value) {
return super.put(key, value);
}
}

}
64 changes: 8 additions & 56 deletions tools/apidoc/XmlToHtmlConverter.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,87 +23,39 @@ public class XmlToHtmlConverter extends XmlToHtmlConverterData {
// To turn off generation of API docs for certain roles, comment out
public static void main(String[] args) {
XmlToHtmlConverter x = new XmlToHtmlConverter();
x.populateForRootAdmin();
x.populateForDomainAdmin();
x.populateForUser();
x.populateForApi();
x.generateToc();
x.generateIndividualCommandPages();
}

public void generateToc() {
try {
TransformerFactory tFactory = TransformerFactory.newInstance();
// Generate the TOC for the API reference for User role
Transformer transformer = tFactory.newTransformer(new javax.xml.transform.stream.StreamSource("generatetocforuser.xsl"));
// Modify this path to match your own setup.
transformer.transform(new javax.xml.transform.stream.StreamSource("regular_user/regularUserSummary.xml"), new javax.xml.transform.stream.StreamResult(
new FileOutputStream("html/TOC_User.html")));
// Generate the TOC for root administrator role
Transformer transformer1 = tFactory.newTransformer(new javax.xml.transform.stream.StreamSource("generatetocforadmin.xsl"));
// Modify this path to match your own setup.
transformer1.transform(new javax.xml.transform.stream.StreamSource("root_admin/rootAdminSummary.xml"),
// Modify this path to your own desired output location.
new javax.xml.transform.stream.StreamResult(new FileOutputStream("html/TOC_Root_Admin.html")));
// Generate the TOC for domain admin role
Transformer transformer2 = tFactory.newTransformer(new javax.xml.transform.stream.StreamSource("generatetocfordomainadmin.xsl"));

// The XML to be transformed must be at the location below.
Transformer transformer1 = tFactory.newTransformer(new javax.xml.transform.stream.StreamSource("generatetoc.xsl"));
// Modify this path to match your own setup.
transformer2.transform(new javax.xml.transform.stream.StreamSource("domain_admin/domainAdminSummary.xml"),
transformer1.transform(new javax.xml.transform.stream.StreamSource("apis/apiSummarySorted.xml"),
// Modify this path to your own desired output location.
new javax.xml.transform.stream.StreamResult(new FileOutputStream("html/TOC_Domain_Admin.html")));

new javax.xml.transform.stream.StreamResult(new FileOutputStream("html/index.html")));
} catch (Exception e) {
e.printStackTrace();
}
}

// Create man pages
public void generateIndividualCommandPages() {
for (String commandName : rootAdminCommandNames) {
for (String commandName : allCommandNames) {

try {

TransformerFactory tFactory = TransformerFactory.newInstance();
Transformer transformer = tFactory.newTransformer(new javax.xml.transform.stream.StreamSource("generateadmincommands.xsl"));
Transformer transformer = tFactory.newTransformer(new javax.xml.transform.stream.StreamSource("generatecommands.xsl"));

transformer.transform
// Modify this path to the location of the input files on your system.
(new javax.xml.transform.stream.StreamSource("root_admin/" + commandName + ".xml"),
(new javax.xml.transform.stream.StreamSource("apis/" + commandName + ".xml"),
// Modify this path with the desired output location.
new javax.xml.transform.stream.StreamResult(new FileOutputStream("html/root_admin/" + commandName + ".html")));
} catch (Exception e) {
e.printStackTrace();
}
}

for (String commandName : domainAdminCommandNames) {

try {

TransformerFactory tFactory = TransformerFactory.newInstance();
Transformer transformer = tFactory.newTransformer(new javax.xml.transform.stream.StreamSource("generatedomainadmincommands.xsl"));

transformer.transform
// Modify this path with the location of the input files on your system.
(new javax.xml.transform.stream.StreamSource("domain_admin/" + commandName + ".xml"),
// Modify this path to the desired output location.
new javax.xml.transform.stream.StreamResult(new FileOutputStream("html/domain_admin/" + commandName + ".html")));
} catch (Exception e) {
e.printStackTrace();
}
}

for (String commandName : userCommandNames) {

try {

TransformerFactory tFactory = TransformerFactory.newInstance();

Transformer transformer = tFactory.newTransformer(new javax.xml.transform.stream.StreamSource("generateusercommands.xsl"));

transformer.transform(new javax.xml.transform.stream.StreamSource("regular_user/" + commandName + ".xml"), new javax.xml.transform.stream.StreamResult(
new FileOutputStream("html/user/" + commandName + ".html")));
new javax.xml.transform.stream.StreamResult(new FileOutputStream("html/apis/" + commandName + ".html")));
} catch (Exception e) {
e.printStackTrace();
}
Expand Down
15 changes: 4 additions & 11 deletions tools/apidoc/build-apidoc.sh
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,7 @@ set -e
(cd "$DISTDIR/xmldoc"
cp "$thisdir"/*.java .
cp "$thisdir"/*.xsl .
sed -e 's,%API_HEADER%,User API,g' "$thisdir/generatetoc_header.xsl" >generatetocforuser.xsl
sed -e 's,%API_HEADER%,Root Admin API,g' "$thisdir/generatetoc_header.xsl" >generatetocforadmin.xsl
sed -e 's,%API_HEADER%,Domain Admin API,g' "$thisdir/generatetoc_header.xsl" >generatetocfordomainadmin.xsl
sed -e 's,%API_HEADER%,All APIs,g' "$thisdir/generatetoc_header.xsl" >generatetoc.xsl

PLATFORM=`uname -s`
if [[ "$PLATFORM" =~ .*WIN.* ]]
Expand All @@ -74,15 +72,10 @@ set -e
python "$thisdir/gen_toc.py" $(find . -type f)
fi

cat generatetocforuser_include.xsl >>generatetocforuser.xsl
cat generatetocforadmin_include.xsl >>generatetocforadmin.xsl
cat generatetocfordomainadmin_include.xsl >>generatetocfordomainadmin.xsl
cat generatetoc_include.xsl >> generatetoc.xsl
cat "$thisdir/generatetoc_footer.xsl" >>generatetoc.xsl

cat "$thisdir/generatetoc_footer.xsl" >>generatetocforuser.xsl
cat "$thisdir/generatetoc_footer.xsl" >>generatetocforadmin.xsl
cat "$thisdir/generatetoc_footer.xsl" >>generatetocfordomainadmin.xsl

mkdir -p html/user html/domain_admin html/root_admin
mkdir -p html/apis
cp -r "$thisdir/includes" html
cp -r "$thisdir/images" html

Expand Down
Loading

0 comments on commit 5e5ee17

Please sign in to comment.