Search in sources :

Example 81 with Handler

use of com.sun.jsftemplating.annotation.Handler in project Payara by payara.

the class UpdateCenterHandlers method updateCenterProcess.

@Handler(id = "updateCenterProcess", input = { @HandlerInput(name = "action", type = String.class, required = true), @HandlerInput(name = "selectedRows", type = java.util.List.class, required = true) })
public static void updateCenterProcess(HandlerContext handlerCtx) {
    Image image = getUpdateCenterImage();
    boolean install = false;
    String action = (String) handlerCtx.getInputValue("action");
    if (action.equals("install")) {
        install = true;
    }
    List obj = (List) handlerCtx.getInputValue("selectedRows");
    if (obj == null) {
        // no row selected
        return;
    }
    List<Map> selectedRows = (List) obj;
    // do not use Fmri list to pass to installPackages, use String array to avoid UPDATECENTER2-2187
    String[] fmris = new String[selectedRows.size()];
    int i = 0;
    try {
        for (Map oneRow : selectedRows) {
            fmris[i++] = ((Fmri) oneRow.get("fmri")).toString();
        }
        if (install) {
            image.installPackages(fmris);
        // updateCountInSession(image);   No need to update the update count since the count will not change.  Only installing new component is allowed.
        } else {
            image.uninstallPackages(fmris);
        }
        GuiUtil.setSessionValue("restartRequired", Boolean.TRUE);
    } catch (Exception ex) {
        GuiUtil.handleException(handlerCtx, ex);
        ex.printStackTrace();
    }
}
Also used : ArrayList(java.util.ArrayList) List(java.util.List) Image(com.sun.pkg.client.Image) HashMap(java.util.HashMap) Map(java.util.Map) TreeMap(java.util.TreeMap) SortedMap(java.util.SortedMap) Handler(com.sun.jsftemplating.annotation.Handler)

Example 82 with Handler

use of com.sun.jsftemplating.annotation.Handler in project Payara by payara.

the class UpdateCenterHandlers method getAuthList.

@Handler(id = "getAuthList", output = { @HandlerOutput(name = "result", type = java.util.List.class) })
public static void getAuthList(HandlerContext handlerCtx) {
    List result = new ArrayList();
    try {
        Image image = getUpdateCenterImage();
        if (image == null) {
            handlerCtx.setOutputValue("result", result);
            return;
        }
        String[] auths = image.getAuthorityNames();
        for (int i = 0; i < auths.length; i++) {
            Map oneRow = new HashMap();
            oneRow.put("authName", auths[i]);
            result.add(oneRow);
        }
    } catch (Exception ex1) {
        ex1.printStackTrace();
    }
    handlerCtx.setOutputValue("result", result);
}
Also used : HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) Image(com.sun.pkg.client.Image) HashMap(java.util.HashMap) Map(java.util.Map) TreeMap(java.util.TreeMap) SortedMap(java.util.SortedMap) Handler(com.sun.jsftemplating.annotation.Handler)

Example 83 with Handler

use of com.sun.jsftemplating.annotation.Handler in project Payara by payara.

the class UpdateCenterHandlers method getLicenseText.

// getLicenseText(selectedRows="#{selectedRows}" license=>$page{license});
@Handler(id = "getLicenseText", input = { @HandlerInput(name = "selectedRows", type = java.util.List.class, required = true) }, output = { @HandlerOutput(name = "license", type = String.class), @HandlerOutput(name = "hasLicense", type = Boolean.class) })
public static void getLicenseText(HandlerContext handlerCtx) {
    List obj = (List) handlerCtx.getInputValue("selectedRows");
    Image image = getUpdateCenterImage();
    List<Map> selectedRows = (List) obj;
    try {
        StringBuffer allLicense = new StringBuffer();
        for (Map oneRow : selectedRows) {
            Fmri fmri = (Fmri) oneRow.get("fmri");
            allLicense.append(getLicense(image, fmri));
        }
        handlerCtx.setOutputValue("license", "" + allLicense);
        handlerCtx.setOutputValue("hasLicense", (allLicense.length() > 0));
    } catch (Exception ex) {
        GuiUtil.handleException(handlerCtx, ex);
    // ex.printStackTrace();
    }
}
Also used : ArrayList(java.util.ArrayList) List(java.util.List) Image(com.sun.pkg.client.Image) HashMap(java.util.HashMap) Map(java.util.Map) TreeMap(java.util.TreeMap) SortedMap(java.util.SortedMap) Fmri(com.sun.pkg.client.Fmri) Handler(com.sun.jsftemplating.annotation.Handler)

Example 84 with Handler

use of com.sun.jsftemplating.annotation.Handler in project Payara by payara.

the class UpdateCenterHandlers method getInstalledPath.

@Handler(id = "getInstalledPath", output = { @HandlerOutput(name = "result", type = String.class) })
public static void getInstalledPath(HandlerContext handlerCtx) {
    Image image = getUpdateCenterImage();
    handlerCtx.setOutputValue("result", (image == null) ? GuiUtil.getMessage(BUNDLE, "updateCenter.NoImageDirectory") : image.getRootDirectory());
}
Also used : Image(com.sun.pkg.client.Image) Handler(com.sun.jsftemplating.annotation.Handler)

Example 85 with Handler

use of com.sun.jsftemplating.annotation.Handler in project Payara by payara.

the class UpdateCenterHandlers method getAuthority.

@Handler(id = "getAuthority", output = { @HandlerOutput(name = "result", type = String.class) })
public static void getAuthority(HandlerContext handlerCtx) {
    Image image = getUpdateCenterImage();
    handlerCtx.setOutputValue("result", (image == null) ? "" : image.getPreferredAuthorityName());
}
Also used : Image(com.sun.pkg.client.Image) 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