use of org.glassfish.admin.rest.generator.ResourcesGenerator in project Payara by payara.
the class GeneratorResource method get.
@GET
@Produces({ "text/plain" })
public String get(@QueryParam("outputDir") String outputDir) {
if (outputDir == null) {
outputDir = DEFAULT_OUTPUT_DIR;
}
String retVal = "Code Generation done at : " + outputDir;
try {
LocatorBridge locatorBridge = habitat.getService(LocatorBridge.class);
Dom dom = Dom.unwrap(locatorBridge.getRemoteLocator().<Domain>getService(Domain.class));
DomDocument document = dom.document;
ConfigModel rootModel = dom.document.getRoot().model;
ResourcesGenerator resourcesGenerator = new TextResourcesGenerator(outputDir, habitat);
resourcesGenerator.generateSingle(rootModel, document);
resourcesGenerator.endGeneration();
} catch (Exception ex) {
RestLogging.restLogger.log(Level.SEVERE, null, ex);
retVal = "Exception encountered during generation process: " + ex.toString() + "\nPlease look at server.log for more information.";
}
return retVal;
}
use of org.glassfish.admin.rest.generator.ResourcesGenerator in project Payara by payara.
the class StatusGenerator method getPlain.
@GET
@Produces({ "text/plain" })
public String getPlain() {
// status.append("Status of Command usage\n");
try {
Domain entity = serviceLocator.getService(Domain.class);
Dom dom = Dom.unwrap(entity);
DomDocument document = dom.document;
ConfigModel rootModel = dom.document.getRoot().model;
ResourcesGenerator resourcesGenerator = new NOOPResourcesGenerator(serviceLocator);
resourcesGenerator.generateSingle(rootModel, document);
resourcesGenerator.endGeneration();
} catch (Exception ex) {
RestLogging.restLogger.log(Level.SEVERE, null, ex);
// retVal = "Exception encountered during generation process: " + ex.toString() + "\nPlease look at server.log for more information.";
}
status.append("\n------------------------");
status.append("All Commands used in REST Admin:\n");
for (String ss : commandsUsed) {
status.append(ss + "\n");
}
listOfCommands();
for (String ss : commandsUsed) {
allCommands.remove(ss);
}
status.append("\n------------------------");
status.append("Missing Commands not used in REST Admin:\n");
for (String ss : allCommands) {
if (hasTargetParam(ss)) {
status.append(ss + " has a target param " + "\n");
} else {
status.append(ss + "\n");
}
}
status.append("\n------------------------");
status.append("REST-REDIRECT Commands defined on ConfigBeans:\n");
for (String ss : restRedirectCommands) {
status.append(ss + "\n");
}
status.append("\n------------------------");
status.append("Commands to Resources Mapping Usage in REST Admin:\n");
for (String ss : commandsToResources.keySet()) {
if (hasTargetParam(ss)) {
status.append(ss + " :::target::: " + commandsToResources.get(ss) + "\n");
} else {
status.append(ss + " ::: " + commandsToResources.get(ss) + "\n");
}
}
status.append("\n------------------------");
status.append("Resources with Delete Commands in REST Admin (not counting RESTREDIRECT:\n");
for (String ss : resourcesToDeleteCommands.keySet()) {
status.append(ss + " ::: " + resourcesToDeleteCommands.get(ss) + "\n");
}
FileOutputStream f = null;
try {
f = new FileOutputStream(System.getProperty("user.home") + "/GlassFishI18NData.properties");
propsI18N.store(f, "");
} catch (Exception ex) {
RestLogging.restLogger.log(Level.SEVERE, null, ex);
} finally {
if (f != null) {
try {
f.close();
} catch (IOException ex) {
RestLogging.restLogger.log(Level.SEVERE, null, ex);
}
}
}
return status.toString();
}
use of org.glassfish.admin.rest.generator.ResourcesGenerator in project Payara by payara.
the class RestManagementResourceProvider method generateASM.
private void generateASM(ServiceLocator habitat) {
try {
Domain entity = habitat.getService(Domain.class);
Dom dom = Dom.unwrap(entity);
ResourcesGenerator resourcesGenerator = new ASMResourcesGenerator(habitat);
resourcesGenerator.generateSingle(dom.document.getRoot().model, dom.document);
resourcesGenerator.endGeneration();
} catch (Exception ex) {
RestLogging.restLogger.log(Level.SEVERE, null, ex);
}
}
use of org.glassfish.admin.rest.generator.ResourcesGenerator in project Payara by payara.
the class StatusGenerator method getHtml.
@GET
@Produces({ MediaType.TEXT_HTML })
public String getHtml() {
try {
Domain entity = serviceLocator.getService(Domain.class);
Dom dom = Dom.unwrap(entity);
DomDocument document = dom.document;
ConfigModel rootModel = dom.document.getRoot().model;
ResourcesGenerator resourcesGenerator = new NOOPResourcesGenerator(serviceLocator);
resourcesGenerator.generateSingle(rootModel, document);
resourcesGenerator.endGeneration();
} catch (Exception ex) {
RestLogging.restLogger.log(Level.SEVERE, null, ex);
}
status.append("<h4>All Commands used in REST Admin</h4>\n<ul>\n");
for (String ss : commandsUsed) {
status.append("<li>").append(ss).append("</li>\n");
}
listOfCommands();
for (String ss : commandsUsed) {
allCommands.remove(ss);
}
status.append("</ul>\n<hr/>\n").append("<h4>Missing Commands not used in REST Admin</h4>\n<ul>\n");
for (String ss : allCommands) {
if (hasTargetParam(ss)) {
status.append("<li>").append(ss).append(" has a target param.</li>\n");
} else {
status.append("<li>").append(ss).append("</li>\n");
}
}
status.append("</ul>\n<hr/>\n").append("<h4>REST-REDIRECT Commands defined on ConfigBeans</h4>\n<ul>\n");
for (String ss : restRedirectCommands) {
status.append("<li>").append(ss).append("</li>\n");
}
status.append("</ul>\n<hr/>\n").append("<h4>Commands to Resources Mapping Usage in REST Admin</h4>\n").append("<table border=\"1\" style=\"border-collapse: collapse\">\n").append("<tr><th>Command</th><th>Target</th><th>Resource</th></tr>\n");
for (String ss : commandsToResources.keySet()) {
status.append("<tr><td>").append(ss).append("</td><td>").append(hasTargetParam(ss) ? "target" : "").append("</td><td>").append(commandsToResources.get(ss)).append("</td></tr>\n");
}
status.append("</table>\n<hr/>\n").append("<h4>Resources with Delete Commands in REST Admin (not counting RESTREDIRECT)</h4>\n").append("<table border=\"1\" style=\"border-collapse: collapse\">\n").append("<tr><th>Resource</th><th>Delete Command</th></tr>\n");
for (String ss : resourcesToDeleteCommands.keySet()) {
status.append("<tr><td>").append(ss).append("</td><td>").append(resourcesToDeleteCommands.get(ss)).append("</td></tr>\n");
}
status.append("</table>");
FileOutputStream f = null;
try {
f = new FileOutputStream(System.getProperty("user.home") + "/GlassFishI18NData.properties");
propsI18N.store(f, "");
} catch (Exception ex) {
RestLogging.restLogger.log(Level.SEVERE, null, ex);
} finally {
if (f != null) {
try {
f.close();
} catch (IOException ex) {
RestLogging.restLogger.log(Level.SEVERE, null, ex);
}
}
}
return status.toString();
}
Aggregations