Search in sources :

Example 71 with Handler

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

the class MonitoringHandlers method filterWebStats.

/*
     * Filter the request,session,jsp and servlets. 
     * Filed an issue :12687.
     * Once this issue is resolved, we can remove this handler.
     */
@Handler(id = "filterWebStats", input = { @HandlerInput(name = "webStats", type = List.class, required = true), @HandlerInput(name = "statType", type = String.class, required = true) }, output = { @HandlerOutput(name = "stats", type = List.class) })
public static void filterWebStats(HandlerContext handlerCtx) {
    List<Map> webStats = (List<Map>) handlerCtx.getInputValue("webStats");
    String statType = (String) handlerCtx.getInputValue("statType");
    List<String> requestStatNames = java.util.Arrays.asList("MaxTime", "ProcessingTime", "RequestCount", "ErrorCount");
    List stats = new ArrayList();
    if (webStats != null) {
        for (Map webStat : webStats) {
            String statName = (String) webStat.get("name");
            if (requestStatNames.contains(statName) && statType.equals("Request")) {
                stats.add(webStat);
            } else if (statName.contains(statType) && !(statType.equals("Request"))) {
                stats.add(webStat);
            }
        }
    }
    handlerCtx.setOutputValue("stats", stats);
}
Also used : 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 72 with Handler

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

the class PluginHandlers method getPluginResources.

/**
 *	<p> This handler returns a
 *	    <code>Map&lt;String id, List&lt;URL&gt;&gt;</code> containing all
 *	    the matches of the requested resource.  Each <code>List</code> in
 *	    the <code>Map</code> is associated with a GUI Plugin, and the key
 *	    to the <code>Map</code> is the plugin id.</p>
 *
 *	@param	handlerCtx	The <code>HandlerContext</code>.
 */
@Handler(id = "getPluginResources", input = { @HandlerInput(name = "name", type = String.class, required = true) }, output = { @HandlerOutput(name = "resources", type = Map.class) })
public static void getPluginResources(HandlerContext handlerCtx) {
    String name = (String) handlerCtx.getInputValue("name");
    ConsolePluginService cps = getPluginService(handlerCtx.getFacesContext());
    handlerCtx.setOutputValue("resources", cps.getResources(name));
}
Also used : ConsolePluginService(org.glassfish.admingui.plugin.ConsolePluginService) Handler(com.sun.jsftemplating.annotation.Handler) LayoutViewHandler(com.sun.jsftemplating.layout.LayoutViewHandler)

Example 73 with Handler

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

the class PluginHandlers method retrievePluginPageContents.

/**
 *	<p> This handler is used for the navigation nodes that request content
 *	    from an external URL.  This handler pulls the "real url" from from
 *	    the component specified by the <code>compId</code> parameter (this
 *	    necessarily depends on the presence of the navigation container in
 *	    the view for the component look up to work).  Once the component
 *	    has been found, the url is retrieved from the attribute map, and
 *	    its contents retrieved.  If <code>processPage</code> is true, the
 *	    URL contents are interpretted and the resulting component(s) are
 *	    added to the component tree (This feature is not currently
 *	    supported)..  Otherwise, the contents are returned in the output
 *	    parameter <code>pluginPage</code> to be output as-is on the
 *	    page.</p>
 *
 * @param handlerCtx    The <code>HandlerContext</code>.
 */
@Handler(id = "retrievePluginPageContents", input = { @HandlerInput(name = "compId", type = String.class, required = true) }, output = { @HandlerOutput(name = "pluginPage", type = String.class) })
public static void retrievePluginPageContents(HandlerContext handlerCtx) {
    String id = (String) handlerCtx.getInputValue("compId");
    UIComponent comp = handlerCtx.getFacesContext().getViewRoot().findComponent(id);
    String urlContents = "";
    if (comp != null) {
        String url = (String) comp.getAttributes().get(NavigationNodeFactory.REAL_URL);
        try {
            // Read from the URL...
            URL contentUrl = FileUtil.searchForFile(url, null);
            if (contentUrl == null) {
                throw new IOException("Unable to locate file: " + url);
            }
            urlContents = new String(FileUtil.readFromURL(contentUrl));
        // FIXME: Implement processPage support
        /*
		if (processPage) {
		    // probably do something like what includeIntegrations does
		    ...
		}
		*/
        } catch (IOException ex) {
            GuiUtil.getLogger().log(Level.SEVERE, "Unable to read url: " + url, ex);
        }
    }
    // Set the content to output...
    handlerCtx.setOutputValue("pluginPage", urlContents);
}
Also used : UIComponent(javax.faces.component.UIComponent) IOException(java.io.IOException) URL(java.net.URL) Handler(com.sun.jsftemplating.annotation.Handler) LayoutViewHandler(com.sun.jsftemplating.layout.LayoutViewHandler)

Example 74 with Handler

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

the class PluginHandlers method getContentOfIntegrationPoints.

/**
 *	Finds the integration point of the specified type.  Returns the contents of this IP type as a list.
 *  The content can be a comma separated String.
 * This is useful for the case such as dropdown or list box to allow additional options in the component.
 */
@Handler(id = "getContentOfIntegrationPoints", input = { @HandlerInput(name = "type", type = String.class, required = true) }, output = { @HandlerOutput(name = "labels", type = List.class), @HandlerOutput(name = "values", type = List.class) })
public static void getContentOfIntegrationPoints(HandlerContext handlerCtx) throws java.io.IOException {
    // Get the input
    String type = (String) handlerCtx.getInputValue("type");
    // Get the IntegrationPoints
    FacesContext ctx = handlerCtx.getFacesContext();
    Set<IntegrationPoint> points = getSortedIntegrationPoints(getIntegrationPoints(ctx, type));
    List labels = new ArrayList();
    List values = new ArrayList();
    if (points != null) {
        for (IntegrationPoint it : points) {
            String content = it.getContent();
            if (GuiUtil.isEmpty(content)) {
                GuiUtil.getLogger().warning("No Content specified for Integration Point: " + type + " id : " + it.getId());
                continue;
            }
            List<String> labelsAndValues = GuiUtil.parseStringList(content, "|");
            values.add(labelsAndValues.get(0));
            labels.add(GuiUtil.getMessage(labelsAndValues.get(1), labelsAndValues.get(2)));
        }
    }
    handlerCtx.setOutputValue("labels", labels);
    handlerCtx.setOutputValue("values", values);
}
Also used : FacesContext(javax.faces.context.FacesContext) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) IntegrationPoint(org.glassfish.admingui.connector.IntegrationPoint) Handler(com.sun.jsftemplating.annotation.Handler) LayoutViewHandler(com.sun.jsftemplating.layout.LayoutViewHandler)

Example 75 with Handler

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

the class PluginHandlers method getPluginIdFromViewId.

@Handler(id = "getPluginIdFromViewId", input = { @HandlerInput(name = "viewId", type = String.class, required = true) }, output = { @HandlerOutput(name = "pluginId", type = String.class) })
public static void getPluginIdFromViewId(HandlerContext handlerCtx) {
    String viewId = (String) handlerCtx.getInputValue("viewId");
    if (viewId == null) {
        return;
    }
    ConsolePluginService cps = getPluginService(handlerCtx.getFacesContext());
    String pluginId = "common";
    int next = viewId.indexOf("/", 1);
    if (next > -1) {
        pluginId = viewId.substring(0, next);
        String resource = viewId.substring(next);
        if (pluginId.startsWith("/")) {
            pluginId = pluginId.substring(1);
        }
        ClassLoader cl = cps.getModuleClassLoader(pluginId);
        URL url = null;
        if (cl != null) {
            url = cl.getResource(resource);
        }
        if (url == null) {
            pluginId = "common";
        }
    }
    handlerCtx.setOutputValue("pluginId", pluginId);
}
Also used : ConsolePluginService(org.glassfish.admingui.plugin.ConsolePluginService) IntegrationPoint(org.glassfish.admingui.connector.IntegrationPoint) URL(java.net.URL) Handler(com.sun.jsftemplating.annotation.Handler) LayoutViewHandler(com.sun.jsftemplating.layout.LayoutViewHandler)

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