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;
}
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;
}
Aggregations