Search in sources :

Example 36 with Handler

use of com.sun.jsftemplating.annotation.Handler in project Payara by payara.

the class ApplicationHandlers method getLifecyclesInfo.

@Handler(id = "gf.getLifecyclesInfo", input = { @HandlerInput(name = "children", type = List.class, required = true) }, output = { @HandlerOutput(name = "result", type = java.util.List.class) })
public static void getLifecyclesInfo(HandlerContext handlerCtx) {
    List<Map> children = (List) handlerCtx.getInputValue("children");
    List result = new ArrayList();
    String prefix = GuiUtil.getSessionValue("REST_URL") + "/applications/application/";
    if (children == null) {
        handlerCtx.setOutputValue("result", result);
        return;
    }
    for (Map oneChild : children) {
        Map oneRow = new HashMap();
        try {
            String name = (String) oneChild.get("message");
            String encodedName = URLEncoder.encode(name, "UTF-8");
            oneRow.put("name", name);
            oneRow.put("encodedName", encodedName);
            oneRow.put("selected", false);
            oneRow.put("loadOrder", RestUtil.getPropValue(prefix + encodedName, "load-order", handlerCtx));
            oneRow.put("enableURL", DeployUtil.getTargetEnableInfo(name, true, true));
            result.add(oneRow);
        } catch (Exception ex) {
            GuiUtil.getLogger().info(GuiUtil.getCommonMessage("log.error.getLifecyclesInfo") + ex.getLocalizedMessage());
            if (GuiUtil.getLogger().isLoggable(Level.FINE)) {
                ex.printStackTrace();
            }
        }
    }
    handlerCtx.setOutputValue("result", result);
}
Also used : HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) HashMap(java.util.HashMap) Map(java.util.Map) Handler(com.sun.jsftemplating.annotation.Handler)

Example 37 with Handler

use of com.sun.jsftemplating.annotation.Handler in project Payara by payara.

the class ApplicationHandlers method deleteLifecycle.

@Handler(id = "gf.deleteLifecycle", input = { @HandlerInput(name = "selectedList", type = List.class, required = true) })
public static void deleteLifecycle(HandlerContext handlerCtx) {
    List<Map> selectedList = (List) handlerCtx.getInputValue("selectedList");
    String endpoint = GuiUtil.getSessionValue("REST_URL") + "/applications/application/delete-lifecycle-module";
    Map attrs = new HashMap();
    try {
        for (Map oneRow : selectedList) {
            String name = (String) oneRow.get("name");
            String encodedName = URLEncoder.encode(name, "UTF-8");
            attrs.put("id", encodedName);
            // delete all application-ref first
            List<Map> appRefs = DeployUtil.getRefEndpoints(name, "application-ref");
            for (Map oneRef : appRefs) {
                attrs.put("target", oneRef.get("targetName"));
                RestUtil.restRequest((String) oneRef.get("endpoint"), attrs, "DELETE", null, false);
            }
            attrs.put("target", "domain");
            RestUtil.restRequest(endpoint, attrs, "POST", handlerCtx, false);
        }
    } catch (Exception ex) {
        GuiUtil.prepareException(handlerCtx, ex);
    }
}
Also used : HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) List(java.util.List) HashMap(java.util.HashMap) Map(java.util.Map) Handler(com.sun.jsftemplating.annotation.Handler)

Example 38 with Handler

use of com.sun.jsftemplating.annotation.Handler in project Payara by payara.

the class ApplicationHandlers method getVsForDeployment.

@Handler(id = "getVsForDeployment", input = { @HandlerInput(name = "targetConfig", type = String.class, defaultValue = "server-config") }, output = { @HandlerOutput(name = "result", type = List.class) })
public static void getVsForDeployment(HandlerContext handlerCtx) {
    String targetConfig = (String) handlerCtx.getInputValue("targetConfig");
    String endpoint = GuiUtil.getSessionValue("REST_URL") + "/configs/config/" + targetConfig + "/http-service/virtual-server";
    List vsList = new ArrayList();
    try {
        vsList = new ArrayList(RestUtil.getChildMap(endpoint).keySet());
        vsList.remove("__asadmin");
    } catch (Exception ex) {
    // TODO: error handling.
    }
    handlerCtx.setOutputValue("result", vsList);
}
Also used : ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) Handler(com.sun.jsftemplating.annotation.Handler)

Example 39 with Handler

use of com.sun.jsftemplating.annotation.Handler in project Payara by payara.

the class ApplicationHandlers method getDeployedAppsInfo.

/**
 *	<p> This handler returns the list of applications for populating the table.
 *  <p> Input  value: "serverName" -- Type: <code> java.lang.String</code></p>
 *	@param	handlerCtx	The HandlerContext.
 */
@Handler(id = "gf.getDeployedAppsInfo", input = { @HandlerInput(name = "appPropsMap", type = Map.class, required = true), @HandlerInput(name = "filterValue", type = String.class) }, output = { @HandlerOutput(name = "filters", type = java.util.List.class), @HandlerOutput(name = "result", type = java.util.List.class) })
public static void getDeployedAppsInfo(HandlerContext handlerCtx) {
    Map<String, String> appPropsMap = (Map) handlerCtx.getInputValue("appPropsMap");
    String filterValue = (String) handlerCtx.getInputValue("filterValue");
    Set filters = new TreeSet();
    filters.add("");
    if (GuiUtil.isEmpty(filterValue)) {
        filterValue = null;
    }
    List result = new ArrayList();
    if (appPropsMap == null) {
        handlerCtx.setOutputValue("result", result);
        return;
    }
    List<String> keys = new ArrayList(appPropsMap.keySet());
    Collections.sort(keys);
    String prefix = GuiUtil.getSessionValue("REST_URL") + "/applications/application/";
    for (String oneAppName : keys) {
        try {
            String engines = appPropsMap.get(oneAppName);
            HashMap oneRow = new HashMap();
            oneRow.put("name", oneAppName);
            final String encodedName = URLEncoder.encode(oneAppName, "UTF-8");
            oneRow.put("encodedName", encodedName);
            oneRow.put("selected", false);
            oneRow.put("enableURL", DeployUtil.getTargetEnableInfo(oneAppName, true, true));
            oneRow.put("sniffers", engines);
            oneRow.put("deploymentOrder", RestUtil.getAttributesMap(prefix + encodedName).get("deploymentOrder"));
            oneRow.put("deploymentTime", RestUtil.getAttributesMap(prefix + encodedName).get("deploymentTime"));
            oneRow.put("deploymentOccuranceTime", DateFormat.getDateTimeInstance().format(new Date(Long.valueOf((String) RestUtil.getAttributesMap(prefix + encodedName).get("timeDeployed")))));
            List sniffersList = GuiUtil.parseStringList(engines, ",");
            oneRow.put("sniffersList", sniffersList);
            for (int ix = 0; ix < sniffersList.size(); ix++) filters.add(sniffersList.get(ix));
            if (filterValue != null) {
                if (!sniffersList.contains(filterValue))
                    continue;
            }
            getLaunchInfo(oneAppName, null, oneRow);
            result.add(oneRow);
        } catch (Exception ex) {
            GuiUtil.getLogger().info(GuiUtil.getCommonMessage("log.error.getDeployedAppsInfo") + ex.getLocalizedMessage());
            if (GuiUtil.getLogger().isLoggable(Level.FINE)) {
                ex.printStackTrace();
            }
        }
    }
    handlerCtx.setOutputValue("result", result);
    handlerCtx.setOutputValue("filters", new ArrayList(filters));
}
Also used : Set(java.util.Set) TreeSet(java.util.TreeSet) HashMap(java.util.HashMap) TreeSet(java.util.TreeSet) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) HashMap(java.util.HashMap) Map(java.util.Map) Date(java.util.Date) Handler(com.sun.jsftemplating.annotation.Handler)

Example 40 with Handler

use of com.sun.jsftemplating.annotation.Handler in project Payara by payara.

the class CommonHandlers method initProductInfoAttributes.

/**
 * This function is called in login.jsf to set the various product specific attributes such as the
 *  product GIFs and product names. A similar function is called for Sailfin to set Sailfin specific
 *  product GIFs and name.
 *  The function is defined in com.sun.extensions.comms.SipUtilities
 */
@Handler(id = "initProductInfoAttributes")
public static void initProductInfoAttributes(HandlerContext handlerCtx) {
    Map sessionMap = handlerCtx.getFacesContext().getExternalContext().getSessionMap();
    // Ensure this method is called once per session
    Object initialized = sessionMap.get("_INFO_SESSION_INITIALIZED");
    if (initialized != null) {
        return;
    }
    // Initialize Product Specific Attributes
    sessionMap.put("productImageURL", GuiUtil.getMessage("productImage.URL"));
    sessionMap.put("productImageWidth", Integer.parseInt(GuiUtil.getMessage("productImage.width")));
    sessionMap.put("productImageHeight", Integer.parseInt(GuiUtil.getMessage("productImage.height")));
    sessionMap.put("loginProductImageURL", GuiUtil.getMessage("login.productImage.URL"));
    sessionMap.put("loginProductImageWidth", Integer.parseInt(GuiUtil.getMessage("login.productImage.width")));
    sessionMap.put("loginProductImageHeight", Integer.parseInt(GuiUtil.getMessage("login.productImage.height")));
    sessionMap.put("fullProductName", GuiUtil.getMessage("versionImage.description"));
    sessionMap.put("loginButtonTooltip", GuiUtil.getMessage("loginButtonTooltip"));
    sessionMap.put("mastHeadDescription", GuiUtil.getMessage("mastHeadDescription"));
    // showLoadBalancer is a Sailfin specific attribute. Sailfin uses Converged LB instead
    // of HTTP LB. It is true for GF and false for Sailfin. In sailfin this is set in
    // com.sun.extensions.comms.SipUtilities.initProductInfoAttributes() called for Sailfin in login.jsf
    // TODO-V3 may need to set this back to true
    // sessionMap.put("showLoadBalancer", true);
    sessionMap.put("_INFO_SESSION_INITIALIZED", "TRUE");
}
Also used : HashMap(java.util.HashMap) Map(java.util.Map) 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