use of com.sun.jsftemplating.annotation.Handler in project Payara by payara.
the class WoodstockHandler method populateApplicationsMonitorDropDown.
/**
* <p>
* Returns the list of monitorable application components</p>
*/
@Handler(id = "populateApplicationsMonitorDropDown", input = { @HandlerInput(name = "AppsList", type = List.class, required = true), @HandlerInput(name = "monitorURL", type = String.class, required = true) }, output = { @HandlerOutput(name = "MonitorList", type = Option[].class), @HandlerOutput(name = "FirstItem", type = String.class) })
public void populateApplicationsMonitorDropDown(HandlerContext handlerCtx) {
List aList = (List) handlerCtx.getInputValue("AppsList");
String monitorURL = (String) handlerCtx.getInputValue("monitorURL");
ArrayList menuList = new ArrayList();
String firstItem = null;
String title = null;
if (aList != null) {
ListIterator al = aList.listIterator();
while (al.hasNext()) {
ArrayList moduleList = new ArrayList();
String appName = (String) al.next();
// Add the application name link in the dropdown if there are any app scoped resources.
if (MonitoringHandlers.doesMonitoringDataExist(monitorURL + "/applications/" + appName + "/resources")) {
moduleList.add(appName);
}
Set<String> modules = new HashSet<String>();
try {
modules = RestUtil.getChildMap(GuiUtil.getSessionValue("REST_URL") + "/applications/application/" + appName + "/module").keySet();
} catch (Exception ex) {
GuiUtil.handleException(handlerCtx, ex);
}
for (String moduleName : modules) {
if (MonitoringHandlers.doesAppProxyExist(appName, moduleName)) {
if (!moduleList.contains(moduleName)) {
moduleList.add(moduleName);
}
}
}
if (moduleList.isEmpty()) {
menuList.add(new Option(appName, appName));
if (firstItem == null) {
firstItem = appName;
}
} else {
OptionGroup menuOptions = getMenuOptions(moduleList, appName, "", false);
menuList.add(menuOptions);
if (firstItem == null) {
firstItem = (String) moduleList.get(0);
}
}
}
}
// Add Menu Options.
jumpMenuOptions = (Option[]) menuList.toArray(new Option[menuList.size()]);
handlerCtx.setOutputValue("MonitorList", jumpMenuOptions);
handlerCtx.setOutputValue("FirstItem", firstItem);
}
use of com.sun.jsftemplating.annotation.Handler in project Payara by payara.
the class WoodstockHandler method uploadFileToTempDir.
/**
* <p>
* This method uploads a file temp directory</p>
* <p>
* Input value: "file" -- Type:
* <code>com.sun.webui.jsf.model.UploadedFile</code></p>
* <p>
* Output value: "uploadDir" -- Type: <code>java.lang.String</code></p>
*
* @param handlerCtx The HandlerContext.
*/
@Handler(id = "uploadFileToTempDir", input = { @HandlerInput(name = "file", type = UploadedFile.class) }, output = { @HandlerOutput(name = "origPath", type = String.class), @HandlerOutput(name = "uploadedTempFile", type = String.class) })
public static void uploadFileToTempDir(HandlerContext handlerCtx) {
Logger logger = GuiUtil.getLogger();
if (logger.isLoggable(Level.FINE)) {
logger.fine(GuiUtil.getCommonMessage("log.inUploadFileToTmpDir"));
}
UploadedFile uploadedFile = (UploadedFile) handlerCtx.getInputValue("file");
File tmpFile = null;
String uploadTmpFile = "";
if (uploadedFile != null) {
String name = uploadedFile.getOriginalName();
logger.info("uploadFileName=" + name);
// see bug# 6498910, for IE, getOriginalName() returns the full path, including the drive.
// for any other browser, it just returns the file name.
int lastIndex = name.lastIndexOf("\\");
if (lastIndex != -1) {
name = name.substring(lastIndex + 1, name.length());
}
int index = name.indexOf(".");
if (index <= 0) {
logger.info("name=" + name + ",index=" + index);
String mesg = GuiUtil.getMessage("msg.deploy.nullArchiveError");
GuiUtil.handleError(handlerCtx, mesg);
return;
}
String suffix = name.substring(index);
String prefix = name.substring(0, index);
handlerCtx.setOutputValue("origPath", prefix);
try {
// createTempFile requires min. of 3 char for prefix.
if (prefix.length() <= 2) {
prefix = prefix + new SecureRandom().nextInt(100000);
}
tmpFile = File.createTempFile(prefix, suffix);
tmpFile.deleteOnExit();
if (logger.isLoggable(Level.FINE)) {
logger.fine(GuiUtil.getCommonMessage("log.writeToTmpFile"));
}
uploadedFile.write(tmpFile);
if (logger.isLoggable(Level.FINE)) {
logger.fine(GuiUtil.getCommonMessage("log.afterWriteToTmpFile"));
}
uploadTmpFile = tmpFile.getCanonicalPath();
} catch (IOException ioex) {
try {
if (tmpFile != null) {
uploadTmpFile = tmpFile.getAbsolutePath();
}
} catch (Exception ex) {
// Handle AbsolutePathException here
}
} catch (Exception ex) {
GuiUtil.handleException(handlerCtx, ex);
}
}
if (logger.isLoggable(Level.FINE)) {
logger.fine(GuiUtil.getCommonMessage("log.successfullyUploadedTmp") + uploadTmpFile);
}
handlerCtx.setOutputValue("uploadedTempFile", uploadTmpFile);
}
use of com.sun.jsftemplating.annotation.Handler in project Payara by payara.
the class ConnectorsHandlers method updateConnectorConnectionPoolWizardStep2.
/**
* <p> updates the wizard map properties on step 2
*/
@Handler(id = "updateConnectorConnectionPoolWizardStep2")
public static void updateConnectorConnectionPoolWizardStep2(HandlerContext handlerCtx) {
Map extra = (Map) handlerCtx.getFacesContext().getExternalContext().getSessionMap().get("wizardPoolExtra");
Map attrs = (Map) handlerCtx.getFacesContext().getExternalContext().getSessionMap().get("wizardMap");
String resAdapter = (String) extra.get("resourceAdapterName");
String definition = (String) extra.get("connectiondefinitionname");
String name = (String) extra.get("name");
attrs.put("name", name);
attrs.put("connectiondefinitionname", definition);
attrs.put("resourceAdapterName", resAdapter);
}
use of com.sun.jsftemplating.annotation.Handler in project Payara by payara.
the class ConnectorsHandlers method updateConnectorConnectionPoolWizard.
/**
* <p> updates the wizard map
*/
@Handler(id = "gf.updateConnectorConnectionPoolWizard", input = { @HandlerInput(name = "props", type = List.class), @HandlerInput(name = "currentAdapter", type = String.class), @HandlerInput(name = "currentDef", type = String.class), @HandlerInput(name = "hasConfidential", type = Boolean.class) })
public static void updateConnectorConnectionPoolWizard(HandlerContext handlerCtx) {
List<Map> props = (List<Map>) handlerCtx.getInputValue("props");
Boolean hasConfidential = (Boolean) handlerCtx.getInputValue("hasConfidential");
if (props != null) {
handlerCtx.getFacesContext().getExternalContext().getSessionMap().put("wizardPoolProperties", props);
} else {
handlerCtx.getFacesContext().getExternalContext().getSessionMap().put("wizardPoolProperties", new ArrayList());
}
handlerCtx.getFacesContext().getExternalContext().getSessionMap().put("hasConfidential", hasConfidential);
Map extra = (Map) handlerCtx.getFacesContext().getExternalContext().getSessionMap().get("wizardPoolExtra");
extra.put("previousDefinition", (String) handlerCtx.getInputValue("currentDef"));
extra.put("previousResAdapter", (String) handlerCtx.getInputValue("currentAdapter"));
}
use of com.sun.jsftemplating.annotation.Handler in project Payara by payara.
the class JmsHandlers method flushJMSDestination.
/**
* <p> This handler takes in selected rows, and removes selected config
* @param context The HandlerContext.
*/
@Handler(id = "flushJMSDestination", input = { @HandlerInput(name = "selectedRows", type = List.class, required = true) })
public static void flushJMSDestination(HandlerContext handlerCtx) {
List<Map> selectedRows = (List) handlerCtx.getInputValue("selectedRows");
try {
for (Map oneRow : selectedRows) {
String name = (String) oneRow.get("name");
String type = ((String) oneRow.get("type"));
JMXUtil.invoke(getJmsDestinationObjectName(SUBTYPE_CONFIG, name, type), OP_PURGE);
}
} catch (Exception ex) {
GuiUtil.handleException(handlerCtx, ex);
}
}
Aggregations