Package com.sun.pkg.client

Examples of com.sun.pkg.client.Image


   
    @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());
    }
View Full Code Here


            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
View Full Code Here

        if (Boolean.TRUE.equals(GuiUtil.getSessionValue("_noNetwork"))){
            handlerCtx.setOutputValue("result", result);
            return;
        }
        try {
            Image img = getUpdateCenterImage();
            if (img == null){
                handlerCtx.setOutputValue("result", result);
                return;
            }
            String state= (String)handlerCtx.getInputValue("state");
            if (state.equals("update")){
                handlerCtx.setOutputValue("result", getUpdateDisplayList(img, false));
                return;
            }
           
            List<Fmri> displayList = null;
            if (state.equals("installed"))
                displayList = getInstalledList(img);
            else
            if (state.equals("addOn"))
                displayList = getAddOnList(img);

          if (displayList != null){
            for (Fmri fmri : displayList){
                Map oneRow = new HashMap();
                try{
                    Manifest manifest = img.getManifest(fmri);
                    oneRow.put("selected", false);
                    oneRow.put("fmri", fmri);
                    oneRow.put("fmriStr", fmri.toString());
                    putInfo(oneRow, "pkgName", fmri.getName());
                    putInfo(oneRow, "version", getPkgVersion(fmri.getVersion()));
View Full Code Here

        @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);
            }
View Full Code Here

    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){
View Full Code Here

    @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();
View Full Code Here

        @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");
View Full Code Here

         return getUpdateCenterImage((String)GuiUtil.getSessionValue("topDir"), false);
        }
    }

    public static Image getUpdateCenterImage(String ucDir, boolean force){
        Image image = null;
        try{
            image = new Image (new File (ucDir));
            if (force || (GuiUtil.getSessionValue(CATALOG_REFRESHED) == null)){
                if (image != null){
        image.refreshCatalogs();
        GuiUtil.setSessionValue(CATALOG_REFRESHED, "TRUE");
    }
            }
        }catch(Exception ex){
            if(force && (image == null)){
View Full Code Here

        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();
View Full Code Here

        final Timer pingTimer = new Timer("PingService", true); //Mark the timer as daemon so that it does not hold up appserver shutdown

        TimerTask pingTask = new TimerTask() {
            public void run() {
                Image img = null;
                try {
                    HashMap<String,String> map = new HashMap<String,String>();

                    map.put("product", version.getProductName().replace(";", ":"));
                    map.put("version", getVersionNumber());
                    map.put("context", CONTEXT);
                    // Disable module status usage tracking.
                    //map.put("modules", activeModules.generateModuleStatus());


                    img = RegistrationUtil.getUpdateCenterImage();
                    img.setMetaData(map);
                    img.refreshCatalog(img.getPreferredAuthorityName());
                    logger.log(Level.INFO, "Domain Pinged: {0}",
                        img.getPreferredAuthorityName());
                    if (logger.isLoggable(Level.FINE)) {
                        logger.fine("X-JPkg-Metadata: product: " +
                            map.get("product"));
                        logger.fine("X-JPkg-Metadata: version: " +
                            map.get("version"));
                        logger.fine("X-JPkg-Metadata: context: " +
                            map.get("context"));
                        //logger.fine("X-JPkg-Metadata: modules: " + map.get("modules"));
                    }

                } catch (Exception e) {
                    // should the timer schedule be changed in case of
                    // exception?
                    if (img != null)
                        logger.log(Level.FINE, "Domain Ping: Unable to refresh catalog: {0}", img.getPreferredAuthorityName());
                    else
                        logger.log(Level.FINE, "Domain Ping: Unable to refresh catalog.  Null image.");
                    logger.fine(e.getMessage());
                }
                // set the time stamp even in case of failure to ping,
View Full Code Here

TOP

Related Classes of com.sun.pkg.client.Image

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.