Search in sources :

Example 1 with FilterTreeEvent

use of org.glassfish.admingui.common.tree.FilterTreeEvent in project Payara by payara.

the class CommonHandlers method filterAdminObjects.

/**
 *  <p> This handler filters out AdminObjects from a list-jms-resources, only return Connection Factories.
 */
@Handler(id = "filterAdminObjects")
public static List filterAdminObjects(HandlerContext context) {
    List result = new ArrayList();
    FilterTreeEvent event = null;
    try {
        if (context.getEventObject() instanceof FilterTreeEvent) {
            event = FilterTreeEvent.class.cast(context.getEventObject());
        } else {
            return result;
        }
        List<String> jmsResources = event.getChildObjects();
        if (jmsResources == null || jmsResources.size() <= 0) {
            return result;
        }
        List adminObjs = new ArrayList();
        Map responseMap = RestUtil.restRequest(GuiUtil.getSessionValue("REST_URL") + "/resources/admin-object-resource", null, "GET", null, false);
        Map<String, Object> extraPropsMap = (Map<String, Object>) ((Map<String, Object>) responseMap.get("data")).get("extraProperties");
        if (extraPropsMap != null) {
            Map<String, Object> childRes = (Map<String, Object>) extraPropsMap.get("childResources");
            if (childRes != null) {
                adminObjs = new ArrayList(childRes.keySet());
            }
        }
        for (String oneJms : jmsResources) {
            if (!adminObjs.contains(oneJms)) {
                result.add(oneJms);
            }
        }
    } catch (Exception ex) {
        // shouldn't happen.  But weill log in and return empty list.
        GuiUtil.getLogger().warning("Exception in filterAdminObjects()");
    }
    return result;
}
Also used : ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) FilterTreeEvent(org.glassfish.admingui.common.tree.FilterTreeEvent) HashMap(java.util.HashMap) Map(java.util.Map) IOException(java.io.IOException) Handler(com.sun.jsftemplating.annotation.Handler)

Example 2 with FilterTreeEvent

use of org.glassfish.admingui.common.tree.FilterTreeEvent in project Payara by payara.

the class CommonHandlers method filterProtocols.

/**
 *  <p> This handler filters out not required protocols from the list of protocols available
 */
@Handler(id = "filterProtocols")
public static List filterProtocols(HandlerContext context) {
    FilterTreeEvent event = FilterTreeEvent.class.cast(context.getEventObject());
    List protocols = event.getChildObjects();
    ArrayList result = new ArrayList();
    if (protocols != null && protocols.size() > 0) {
        for (int i = 0; i < protocols.size(); i++) {
            String protocol = (String) protocols.get(i);
            if (!(protocol.equals(ServerTags.PORT_UNIF_PROTOCOL_NAME) || protocol.equals(ServerTags.REDIRECT_PROTOCOL_NAME))) {
                result.add(protocol);
            }
        }
    }
    return result;
}
Also used : ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) FilterTreeEvent(org.glassfish.admingui.common.tree.FilterTreeEvent) Handler(com.sun.jsftemplating.annotation.Handler)

Aggregations

Handler (com.sun.jsftemplating.annotation.Handler)2 ArrayList (java.util.ArrayList)2 List (java.util.List)2 FilterTreeEvent (org.glassfish.admingui.common.tree.FilterTreeEvent)2 IOException (java.io.IOException)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1