Search in sources :

Example 46 with Handler

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);
}
Also used : SimpleDateFormat(java.text.SimpleDateFormat) DateFormat(java.text.DateFormat) Date(java.util.Date) Handler(com.sun.jsftemplating.annotation.Handler)

Example 47 with Handler

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);
    }
}
Also used : HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) List(java.util.List) ArrayList(java.util.ArrayList) Map(java.util.Map) HashMap(java.util.HashMap) Handler(com.sun.jsftemplating.annotation.Handler)

Example 48 with Handler

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);
}
Also used : List(java.util.List) ArrayList(java.util.ArrayList) Map(java.util.Map) HashMap(java.util.HashMap) Handler(com.sun.jsftemplating.annotation.Handler)

Example 49 with Handler

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));
}
Also used : Vector(java.util.Vector) Handler(com.sun.jsftemplating.annotation.Handler)

Example 50 with Handler

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);
    }
}
Also used : HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) List(java.util.List) HashMap(java.util.HashMap) Map(java.util.Map) Handler(com.sun.jsftemplating.annotation.Handler)

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