Search in sources :

Example 86 with Handler

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

the class UpdateCenterHandlers method getUpdateComponentCount.

@Handler(id = "getUpdateComponentCount")
public static void getUpdateComponentCount(HandlerContext handlerCtx) {
    boolean donotPing = false;
    // If user set NO_NETWORK system properties, don't try to do anything.
    boolean noNetwork = (Boolean) GuiUtil.getSessionValue("_noNetwork");
    if (noNetwork) {
        GuiUtil.getLogger().info(GuiUtil.getMessage(BUNDLE, "noNetworkDetected"));
        donotPing = true;
    } else {
        UpdateCheckFrequency userPreference = SystemInfo.getUpdateCheckFrequency();
        if (userPreference == UpdateCheckFrequency.NEVER) {
            GuiUtil.getLogger().info(GuiUtil.getMessage(BUNDLE, "noCheckPerformed"));
            GuiUtil.setSessionValue("_doNotPing", "true");
            donotPing = true;
        }
    }
    if (donotPing) {
        GuiUtil.setSessionValue("_hideUpdateMsg", Boolean.TRUE);
        return;
    }
    GuiUtil.setSessionValue("_hideUpdateMsg", Boolean.FALSE);
    GuiUtil.setSessionValue("_updateCountMsg", "");
    UcThread thread = new UcThread((HttpSession) FacesContext.getCurrentInstance().getExternalContext().getSession(false));
    thread.start();
}
Also used : UpdateCheckFrequency(com.sun.pkg.client.SystemInfo.UpdateCheckFrequency) Handler(com.sun.jsftemplating.annotation.Handler)

Example 87 with Handler

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

the class UpdateCenterHandlers method setProxyInfo.

@Handler(id = "setProxyInfo", input = { @HandlerInput(name = "connection", type = String.class), @HandlerInput(name = "host", type = String.class), @HandlerInput(name = "port", type = String.class) })
public static void setProxyInfo(HandlerContext handlerCtx) {
    String connection = (String) handlerCtx.getInputValue("connection");
    String host = (String) handlerCtx.getInputValue("host");
    String port = (String) handlerCtx.getInputValue("port");
    try {
        Image image = getUpdateCenterImage();
        if (image == null) {
            String ucDir = (String) GuiUtil.getSessionValue("topDir");
            GuiUtil.handleError(handlerCtx, GuiUtil.getMessage(BUNDLE, "NoImage", new String[] { ucDir }));
            return;
        }
        if (connection.equals("useProxy")) {
            int portNo = Integer.parseInt(port);
            SocketAddress address = new InetSocketAddress(host, portNo);
            image.setProxy(new Proxy(Proxy.Type.HTTP, address));
            String url = "http://" + host + ":" + portNo;
            Properties prop = new Properties();
            prop.setProperty("proxy.URL", url);
            SystemInfo.initUpdateToolProps(prop);
        } else {
            image.setProxy(null);
            Properties prop = new Properties();
            prop.setProperty("proxy.URL", "");
            SystemInfo.initUpdateToolProps(prop);
        }
    } catch (Exception ex) {
        GuiUtil.handleException(handlerCtx, ex);
    }
}
Also used : Proxy(java.net.Proxy) InetSocketAddress(java.net.InetSocketAddress) Image(com.sun.pkg.client.Image) SocketAddress(java.net.SocketAddress) InetSocketAddress(java.net.InetSocketAddress) Properties(java.util.Properties) Handler(com.sun.jsftemplating.annotation.Handler)

Example 88 with Handler

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

the class UpdateCenterHandlers method getPkgDetailsInfo.

@Handler(id = "getPkgDetailsInfo", input = { @HandlerInput(name = "fmriStr", type = String.class, required = true), @HandlerInput(name = "auth", type = String.class, required = true) }, output = { @HandlerOutput(name = "details", type = java.util.Map.class) })
public static void getPkgDetailsInfo(HandlerContext handlerCtx) {
    String fmriStr = (String) handlerCtx.getInputValue("fmriStr");
    // Called by the intiPage and don't need to process.  When we can use beforeCreate to do this, we can remove this check.
    if (fmriStr == null) {
        handlerCtx.setOutputValue("details", new HashMap());
        return;
    }
    Fmri fmri = new Fmri(fmriStr);
    Map details = new HashMap();
    Image img = getUpdateCenterImage();
    try {
        details.put("pkgName", fmri.getName());
        details.put("uid", fmri.toString());
        details.put("version", getPkgVersion(fmri.getVersion()));
        details.put("date", fmri.getVersion().getPublishDate());
        details.put("auth", (String) handlerCtx.getInputValue("auth"));
        details.put("url", fmri.getURLPath());
        if (img != null) {
            Manifest manifest = img.getManifest(fmri);
            details.put("category", getCategory(manifest));
            details.put("bytes", "" + manifest.getPackageSize());
            details.put("pkgSize", getPkgSize(manifest));
            // look for description in the following order:
            // pkg.description, description_long, pkg.summary, description
            // since description_long and description has been deprecated.
            String desc = manifest.getAttribute(PKG_DESC);
            if (GuiUtil.isEmpty(desc)) {
                desc = manifest.getAttribute(DESC_LONG);
                if (GuiUtil.isEmpty(desc)) {
                    desc = manifest.getAttribute(PKG_SUMMARY);
                    if (GuiUtil.isEmpty(desc))
                        desc = manifest.getAttribute(DESC);
                }
            }
            details.put("desc", desc);
        }
    } catch (Exception ex) {
        ex.printStackTrace();
    }
    handlerCtx.setOutputValue("details", details);
}
Also used : HashMap(java.util.HashMap) Image(com.sun.pkg.client.Image) Manifest(com.sun.pkg.client.Manifest) 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 89 with Handler

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

the class WebHandlers method changeNetworkListenersInVS.

@Handler(id = "changeNetworkListenersInVS", input = { @HandlerInput(name = "vsAttrs", type = Map.class, required = true), @HandlerInput(name = "listenerName", type = String.class, required = true), @HandlerInput(name = "addFlag", type = Boolean.class, required = true) }, output = { @HandlerOutput(name = "result", type = Map.class) })
public static void changeNetworkListenersInVS(HandlerContext handlerCtx) {
    // get the virtual server and add this network listener to it.
    Map vsAttrs = (HashMap) handlerCtx.getInputValue("vsAttrs");
    String listenerName = (String) handlerCtx.getInputValue("listenerName");
    Boolean addFlag = (Boolean) handlerCtx.getInputValue("addFlag");
    String nwListeners = (String) vsAttrs.get("networkListeners");
    List<String> listeners = GuiUtil.parseStringList(nwListeners, ",");
    if (addFlag.equals(Boolean.TRUE)) {
        if (!listeners.contains(listenerName)) {
            listeners.add(listenerName);
        }
    } else {
        if (listeners.contains(listenerName)) {
            listeners.remove(listenerName);
        }
    }
    String ll = GuiUtil.listToString(listeners, ",");
    vsAttrs.put("networkListeners", ll);
    handlerCtx.setOutputValue("result", vsAttrs);
}
Also used : HashMap(java.util.HashMap) Map(java.util.Map) HashMap(java.util.HashMap) Handler(com.sun.jsftemplating.annotation.Handler)

Example 90 with Handler

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

the class RestUtil2 method sendRequestToCollectionResource.

@Handler(id = "rest.list", input = { @HandlerInput(name = "endpoint", type = String.class, required = true), @HandlerInput(name = "attrs", type = Map.class, required = false) }, output = { @HandlerOutput(name = "result", type = List.class) })
public static void sendRequestToCollectionResource(HandlerContext handlerCtx) {
    // Map<String, Object> attrs = (Map<String, Object>) handlerCtx.getInputValue("attrs");
    String endpoint = fixEndpoint((String) handlerCtx.getInputValue("endpoint"));
    Response resp = RestUtil.getJerseyClient().target(endpoint).request(RestUtil.RESPONSE_TYPE).cookie(new Cookie(RestUtil.REST_TOKEN_COOKIE, RestUtil.getRestToken())).get(Response.class);
    if (!isSuccess(resp.getStatus())) {
        throw new RuntimeException(resp.readEntity(String.class));
    }
    List list = resp.readEntity(List.class);
    handlerCtx.setOutputValue("result", list);
}
Also used : Response(javax.ws.rs.core.Response) Cookie(javax.ws.rs.core.Cookie) List(java.util.List) 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