use of com.sun.jsftemplating.annotation.Handler in project Payara by payara.
the class JmsHandlers method updatePhysicalDestination.
/**
* <p>This handler updates a physical destination.</p>
* @param context The HandlerContext.
*/
@Handler(id = "updatePhysicalDestination", input = { @HandlerInput(name = "name", type = String.class, required = true), @HandlerInput(name = "attributes", type = Map.class, required = true), @HandlerInput(name = "type", type = String.class) })
public static void updatePhysicalDestination(HandlerContext handlerCtx) {
try {
final String type = (String) handlerCtx.getInputValue("type");
final String name = (String) handlerCtx.getInputValue("name");
AttributeList list = new AttributeList();
// Copy attributes to the AttributeList.
// Make it work, then make it right. :|
Map attrMap = (Map) handlerCtx.getInputValue("attributes");
buildAttributeList(list, attrMap, type);
String objectName = getJmsDestinationObjectName(SUBTYPE_CONFIG, name, type);
JMXUtil.getMBeanServer().setAttributes(new ObjectName(objectName), list);
} catch (Exception ex) {
GuiUtil.handleException(handlerCtx, ex);
}
}
use of com.sun.jsftemplating.annotation.Handler in project Payara by payara.
the class PayaraUtilHandlers method mapRemove.
/**
* @param context
*/
@Handler(id = "mapRemove", input = { @HandlerInput(name = "map", type = Map.class, required = true), @HandlerInput(name = "key", type = Object.class, required = true) })
public static void mapRemove(HandlerContext context) {
Map map = (Map) context.getInputValue("map");
Object key = context.getInputValue("key");
map.remove(key);
}
use of com.sun.jsftemplating.annotation.Handler in project Payara by payara.
the class PayaraRestApiHandlers method getRestEndpoints.
/**
* Gets the REST endpoints from a given app name and optional component name
* @param handlerCtx
*/
@Handler(id = "py.getRestEndpoints", input = { @HandlerInput(name = "appName", type = String.class, required = true), @HandlerInput(name = "componentName", type = String.class, required = false) }, output = { @HandlerOutput(name = "result", type = java.util.List.class) })
public static void getRestEndpoints(HandlerContext handlerCtx) {
List<Map<String, String>> result = new ArrayList<>();
try {
String appName = (String) handlerCtx.getInputValue("appName");
String encodedAppName = URLEncoder.encode(appName, "UTF-8");
String componentName = (String) handlerCtx.getInputValue("componentName");
String encodedComponentName = URLEncoder.encode(componentName, "UTF-8");
String prefix = GuiUtil.getSessionValue("REST_URL") + "/applications/application/" + encodedAppName;
// get the extra properties from the list-rest-endpoints command, passing in the component name
Map attrMap = new HashMap();
attrMap.put("componentname", encodedComponentName);
Map payaraEndpointDataMap = RestUtil.restRequest(prefix + "/list-rest-endpoints", attrMap, "GET", null, false, false);
Map payaraEndpointsExtraProps = (Map) ((Map) ((Map) payaraEndpointDataMap.get("data")).get("extraProperties"));
// Check if the command returned any endpoints
if (payaraEndpointsExtraProps.get("endpoints") != null) {
Map<String, List<String>> output = (Map<String, List<String>>) payaraEndpointsExtraProps.get("endpoints");
output.forEach((path, methods) -> {
methods.forEach(method -> {
Map<String, String> endpointDetails = new TreeMap<>();
endpointDetails.put("endpointPath", path);
endpointDetails.put("requestMethod", method);
result.add(endpointDetails);
});
});
}
} catch (Exception ex) {
GuiUtil.getLogger().info(GuiUtil.getCommonMessage("log.error.getRestEndpoints") + ex.getLocalizedMessage());
if (GuiUtil.getLogger().isLoggable(Level.FINE)) {
ex.printStackTrace();
}
}
handlerCtx.setOutputValue("result", result);
}
use of com.sun.jsftemplating.annotation.Handler in project Payara by payara.
the class UtilHandlers method convertStringtoListHandler.
/**
* <p> This handler takes in a string with delimiter and returns list
* @param handlerCtx
*/
@Handler(id = "convertStringtoList", input = { @HandlerInput(name = "str", type = String.class), @HandlerInput(name = "delimiter", type = String.class, defaultValue = ",") }, output = { @HandlerOutput(name = "result", type = List.class) })
public static void convertStringtoListHandler(HandlerContext handlerCtx) {
List result = convertStringToList((String) handlerCtx.getInputValue("str"), (String) handlerCtx.getInputValue("delimiter"));
handlerCtx.setOutputValue("result", result);
}
use of com.sun.jsftemplating.annotation.Handler in project Payara by payara.
the class UtilHandlers method convertMapToListOfMap.
/**
* This method converts a Map into a list of Map with keyName and ValueName. This is suitable for table display.
* @param handlerCtx
*/
@Handler(id = "gf.convertMapToListOfMap", input = { @HandlerInput(name = "map", type = Map.class, required = true), @HandlerInput(name = "keyName", type = String.class, defaultValue = "key"), @HandlerInput(name = "valueName", type = String.class, defaultValue = "value") }, output = { @HandlerOutput(name = "result", type = List.class) })
public static void convertMapToListOfMap(HandlerContext handlerCtx) {
Map map = ((Map) handlerCtx.getInputValue("map"));
String keyName = ((String) handlerCtx.getInputValue("keyName"));
String valueName = ((String) handlerCtx.getInputValue("valueName"));
List result = new ArrayList();
for (Map.Entry entry : (Set<Map.Entry>) map.entrySet()) {
Map oneRow = new HashMap();
oneRow.put(keyName, entry.getKey());
oneRow.put(valueName, entry.getValue());
result.add(oneRow);
}
handlerCtx.setOutputValue("result", result);
}
Aggregations