Search in sources :

Example 16 with Handler

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);
}
Also used : OptionGroup(com.sun.webui.jsf.model.OptionGroup) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) Option(com.sun.webui.jsf.model.Option) ListIterator(java.util.ListIterator) IOException(java.io.IOException) HashSet(java.util.HashSet) Handler(com.sun.jsftemplating.annotation.Handler)

Example 17 with Handler

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);
}
Also used : UploadedFile(com.sun.webui.jsf.model.UploadedFile) SecureRandom(java.security.SecureRandom) IOException(java.io.IOException) Logger(java.util.logging.Logger) UploadedFile(com.sun.webui.jsf.model.UploadedFile) File(java.io.File) IOException(java.io.IOException) Handler(com.sun.jsftemplating.annotation.Handler)

Example 18 with Handler

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);
}
Also used : Map(java.util.Map) HashMap(java.util.HashMap) Handler(com.sun.jsftemplating.annotation.Handler)

Example 19 with Handler

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"));
}
Also used : ArrayList(java.util.ArrayList) List(java.util.List) ArrayList(java.util.ArrayList) Map(java.util.Map) HashMap(java.util.HashMap) Handler(com.sun.jsftemplating.annotation.Handler)

Example 20 with Handler

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);
    }
}
Also used : AttributeList(javax.management.AttributeList) ArrayList(java.util.ArrayList) List(java.util.List) HashMap(java.util.HashMap) Map(java.util.Map) ConnectorRuntimeException(com.sun.appserv.connectors.internal.api.ConnectorRuntimeException) Handler(com.sun.jsftemplating.annotation.Handler)

Aggregations

Handler (com.sun.jsftemplating.annotation.Handler)167 ArrayList (java.util.ArrayList)85 Map (java.util.Map)85 List (java.util.List)82 HashMap (java.util.HashMap)81 TreeMap (java.util.TreeMap)14 IOException (java.io.IOException)12 Date (java.util.Date)9 ConnectorRuntimeException (com.sun.appserv.connectors.internal.api.ConnectorRuntimeException)8 LayoutViewHandler (com.sun.jsftemplating.layout.LayoutViewHandler)8 Image (com.sun.pkg.client.Image)8 ListIterator (java.util.ListIterator)8 UnsupportedEncodingException (java.io.UnsupportedEncodingException)7 FacesContext (javax.faces.context.FacesContext)7 AttributeList (javax.management.AttributeList)7 RestResponse (org.glassfish.admingui.common.util.RestResponse)7 URL (java.net.URL)6 IntegrationPoint (org.glassfish.admingui.connector.IntegrationPoint)6 MultipleListDataProvider (com.sun.jsftemplating.component.dataprovider.MultipleListDataProvider)5 TableRowGroup (com.sun.webui.jsf.component.TableRowGroup)5