use of com.sun.jsftemplating.annotation.Handler in project Payara by payara.
the class CommonHandlers method getCurrentTime.
/**
* <p> Returns the current system time formatted<p>
* <p> Output value: "Time" -- Type: <code>String</code></p>
*/
@Handler(id = "getCurrentTime", output = { @HandlerOutput(name = "CurrentTime", type = String.class) })
public void getCurrentTime(HandlerContext handlerCtx) {
Date d = new Date(System.currentTimeMillis());
DateFormat dateFormat = DateFormat.getDateTimeInstance(DateFormat.MEDIUM, DateFormat.MEDIUM, handlerCtx.getFacesContext().getViewRoot().getLocale());
String currentTime = dateFormat.format(d);
handlerCtx.setOutputValue("CurrentTime", currentTime);
}
use of com.sun.jsftemplating.annotation.Handler in project Payara by payara.
the class InstanceHandler method saveJvmOptionValues.
@Handler(id = "saveJvmOptionValues", input = { @HandlerInput(name = "endpoint", type = String.class, required = true), @HandlerInput(name = "target", type = String.class, required = true), @HandlerInput(name = "attrs", type = Map.class, required = false), @HandlerInput(name = "profiler", type = String.class, required = true), @HandlerInput(name = "options", type = List.class), @HandlerInput(name = "deleteProfileEndpoint", type = String.class), @HandlerInput(name = "origList", type = List.class) })
public static void saveJvmOptionValues(HandlerContext handlerCtx) {
String endpoint = (String) handlerCtx.getInputValue("endpoint");
String target = (String) handlerCtx.getInputValue("target");
try {
List<Map> options = (List<Map>) handlerCtx.getInputValue("options");
ArrayList<String> newList = new ArrayList();
for (Map oneRow : options) {
newList.add((String) oneRow.get(PROPERTY_VALUE));
}
ArrayList<String> oldList = getJvmOptions(handlerCtx);
if (newList.equals(oldList)) {
// if old list is same as new list, return without saving anything
return;
}
Map<String, Object> payload = new HashMap<String, Object>();
payload.put("profiler", (String) handlerCtx.getInputValue("profiler"));
prepareJvmOptionPayload(payload, target, options);
RestUtil.restRequest(endpoint, payload, "POST", handlerCtx, false, true);
} catch (Exception ex) {
// If this is called during create profile, we want to delete the profile which was created, and stay at the same
// place for user to fix the jvm options.
String deleteProfileEndpoint = (String) handlerCtx.getInputValue("deleteProfileEndpoint");
if (!GuiUtil.isEmpty(deleteProfileEndpoint)) {
Map attrMap = new HashMap();
attrMap.put("target", (String) handlerCtx.getInputValue("target"));
RestUtil.restRequest(deleteProfileEndpoint, attrMap, "DELETE", handlerCtx, false, false);
}
// If the origList is not empty, we want to restore it. Since POST remove all options first and then add it back. As a
// result, all previous existing option is gone.
List<Map> origList = (List<Map>) handlerCtx.getInputValue("origList");
Map<String, Object> payload1 = new HashMap<String, Object>();
if (endpoint.contains("profiler")) {
payload1.put("profiler", "true");
}
if ((origList != null) && origList.size() > 0) {
prepareJvmOptionPayload(payload1, target, origList);
RestUtil.restRequest(endpoint, payload1, "POST", handlerCtx, false, false);
}
GuiUtil.handleException(handlerCtx, ex);
}
}
use of com.sun.jsftemplating.annotation.Handler in project Payara by payara.
the class LoggingHandlers method changeLoggerLevels.
@Handler(id = "changeLoggerLevels", input = { @HandlerInput(name = "newLogLevel", type = String.class, required = true), @HandlerInput(name = "allRows", type = List.class, required = true) }, output = { @HandlerOutput(name = "newList", type = List.class) })
public static void changeLoggerLevels(HandlerContext handlerCtx) {
String newLogLevel = (String) handlerCtx.getInputValue("newLogLevel");
List obj = (List) handlerCtx.getInputValue("allRows");
List<Map> allRows = (List) obj;
if (GuiUtil.isEmpty(newLogLevel)) {
handlerCtx.setOutputValue("newList", allRows);
return;
}
for (Map oneRow : allRows) {
boolean selected = (Boolean) oneRow.get("selected");
if (selected) {
oneRow.put("level", newLogLevel);
oneRow.put("selected", false);
}
}
handlerCtx.setOutputValue("newList", allRows);
}
use of com.sun.jsftemplating.annotation.Handler in project Payara by payara.
the class NewSSLHandlers method convertToDifferentCiphersGroup.
@Handler(id = "convertToDifferentCiphersGroup", input = { @HandlerInput(name = "ciphers", type = Object.class) }, output = { @HandlerOutput(name = "CommonCiphersList", type = String[].class), @HandlerOutput(name = "EphemeralCiphersList", type = String[].class), @HandlerOutput(name = "OtherCiphersList", type = String[].class), @HandlerOutput(name = "EccCiphersList", type = String[].class) })
public static void convertToDifferentCiphersGroup(HandlerContext handlerCtx) {
Vector ciphersVector = null;
Object ciphers = (Object) handlerCtx.getInputValue("ciphers");
if (ciphers != null) {
if (ciphers instanceof String) {
String[] ary = getSelectedCiphersList((String) ciphers);
ciphersVector = getCiphersVector(ary);
} else {
ciphersVector = getCiphersVector((String[]) ciphers);
}
}
handlerCtx.setOutputValue("CommonCiphersList", getCommonCiphers(ciphersVector));
handlerCtx.setOutputValue("EphemeralCiphersList", getEphemeralCiphers(ciphersVector));
handlerCtx.setOutputValue("OtherCiphersList", getOtherCiphers(ciphersVector));
handlerCtx.setOutputValue("EccCiphersList", getEccCiphers(ciphersVector));
}
use of com.sun.jsftemplating.annotation.Handler in project Payara by payara.
the class ApplicationHandlers method changeAppTargets.
@Handler(id = "gf.changeAppTargets", input = { @HandlerInput(name = "appName", type = String.class, required = true), @HandlerInput(name = "targets", type = String[].class, required = true), @HandlerInput(name = "status", type = String.class) })
public static void changeAppTargets(HandlerContext handlerCtx) {
String appName = (String) handlerCtx.getInputValue("appName");
String status = (String) handlerCtx.getInputValue("status");
String[] selTargets = (String[]) handlerCtx.getInputValue("targets");
List<String> selectedTargets = Arrays.asList(selTargets);
List clusters = TargetUtil.getClusters();
List standalone = TargetUtil.getStandaloneInstances();
List dgs = TargetUtil.getDeploymentGroups();
standalone.add("server");
Map attrs = new HashMap();
attrs.put("id", appName);
List<String> associatedTargets = DeployUtil.getApplicationTarget(appName, "application-ref");
for (String newTarget : selectedTargets) {
if (associatedTargets.contains(newTarget)) {
// no need to add or remove.
associatedTargets.remove(newTarget);
continue;
} else {
AppUtil.manageAppTarget(appName, newTarget, true, status, clusters, standalone, dgs, handlerCtx);
}
}
for (String oTarget : associatedTargets) {
AppUtil.manageAppTarget(appName, oTarget, false, null, clusters, standalone, dgs, handlerCtx);
}
}
Aggregations