Search in sources :

Example 6 with Image

use of com.sun.pkg.client.Image in project Payara by payara.

the class UcThread method run.

@Override
public void run() {
    int count = -1;
    try {
        Integer countInt = null;
        session.setAttribute("_updateCountMsg", "");
        Image image = UpdateCenterHandlers.getUpdateCenterImage((String) session.getAttribute("topDir"), true);
        if (image == null) {
            return;
        }
        countInt = UpdateCenterHandlers.updateCountInSession(image);
        count = countInt.intValue();
        if (count == 0) {
            session.setAttribute("_updateCountMsg", GuiUtil.getMessage(UpdateCenterHandlers.BUNDLE, "msg.noUpdates"));
        } else if (count > 0) {
            session.setAttribute("_updateCountMsg", GuiUtil.getMessage(UpdateCenterHandlers.BUNDLE, "msg.updatesAvailable", new String[] { "" + count }));
        }
    } catch (Exception ex) {
        if (GuiUtil.getLogger().isLoggable(Level.FINE)) {
            ex.printStackTrace();
        }
    }
}
Also used : Image(com.sun.pkg.client.Image)

Example 7 with Image

use of com.sun.pkg.client.Image 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 8 with Image

use of com.sun.pkg.client.Image 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 9 with Image

use of com.sun.pkg.client.Image 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 10 with Image

use of com.sun.pkg.client.Image 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)

Aggregations

Image (com.sun.pkg.client.Image)15 Handler (com.sun.jsftemplating.annotation.Handler)8 HashMap (java.util.HashMap)7 TreeMap (java.util.TreeMap)7 ArrayList (java.util.ArrayList)6 Map (java.util.Map)6 SortedMap (java.util.SortedMap)6 Fmri (com.sun.pkg.client.Fmri)5 List (java.util.List)5 Manifest (com.sun.pkg.client.Manifest)3 RegistrationException (com.sun.enterprise.registration.RegistrationException)2 Properties (java.util.Properties)2 SystemInfo (com.sun.pkg.client.SystemInfo)1 File (java.io.File)1 IOException (java.io.IOException)1 InetSocketAddress (java.net.InetSocketAddress)1 Proxy (java.net.Proxy)1 SocketAddress (java.net.SocketAddress)1 Timer (java.util.Timer)1 TimerTask (java.util.TimerTask)1