Package com.sun.enterprise.admin.util

Examples of com.sun.enterprise.admin.util.ColumnFormatter


     */
    public String list() throws BackupException {
        StringBuffer sb = new StringBuffer();
        String headings[] = { BACKUP, USER, DATE, FILENAME };
        List<Integer> badPropsList = null;
        ColumnFormatter cf = null;
        boolean itemInRow = false;
        TreeSet<Status>statusSet = new TreeSet<Status>(new FileNameComparator());
       
        // If a backup config was not provided then look for all zips
        // including those in the backup config directories.
        // If a backup config was provided then only look for zips in
        // that backup config directory.
        findZips(request.backupConfig == null);

        badPropsList = new ArrayList<Integer>();

        // it is GUARANTEED that the length > 0
        for(int i = 0; i < zips.length; i++) {
            Status status = new Status();

            if (!status.loadProps(zips[i]))
                badPropsList.add(new Integer(i));
            else {
                //XXX: if (request.terse)  How indicate no headers?

                statusSet.add(status);
                itemInRow = true;
            }
        }

        if (itemInRow) {
            for (Status status : statusSet) {
                if (request.verbose) {
                    File f = null;

                    try {
                        f = new File(status.getBackupPath());
                    } catch (NullPointerException e) {
                    }

                    if (f != null) {
                        sb.append(status.read(f, request.terse));
                        sb.append("\n\n");
                    }
                } else {
                    String filename = status.getFileName();

                    if (cf == null) {
                        cf = new ColumnFormatter(headings);
                    }

                    if (filename == null)
                        filename = strings.get("backup-list.unavailable");

                    cf.addRow(new Object[] {
                              status.getBackupConfigName(),
                              status.getUserName(),
                              status.getTimeStamp(),
                              filename
                         });
                }
            }
        }


        if (cf != null)
            sb.append(cf.toString());

        // If no items in the row and we are not in terse mode indicate
        // there was nothing to list.
        if (!itemInRow && !request.terse)
            sb.append("\n" + strings.get("backup-list.nothing"));
View Full Code Here


     * Entry point from the framework into the command execution
     * @param context context for the command.
     */
    public void execute(AdminCommandContext context) {
        final ActionReport report = context.getActionReport();
        ColumnFormatter cf = new ColumnFormatter();

        ActionReport.MessagePart part = report.getTopMessagePart();
        int numOfApplications = 0;
        if ( !terse && long_opt ) {
            String[] headings= new String[] { "NAME", "STATUS" };
            cf = new ColumnFormatter(headings);
        }
        for (ApplicationRef ref : domain.getApplicationRefsInTarget(target)) {
            Object[] row = new Object[] { ref.getRef() };
            if( !terse && long_opt ){
                row = new Object[]{ ref.getRef(), getLongStatus(ref) };
            }
            cf.addRow(row);
            numOfApplications++;
        }
        if (numOfApplications != 0) {
            report.setMessage(cf.toString());
        } else if ( !terse) {
            part.setMessage(localStrings.getLocalString("list.components.no.elements.to.list", "Nothing to List."));
        }
        report.setActionExitCode(ActionReport.ExitCode.SUCCESS);
    }
View Full Code Here

    ////////  static formatting stuff below   ///////////////////////////////
    /////////////////////////////////////////////////////////////////////////

    public static String format(List<InstanceInfo> infos) {
        String headings[] = {NAME, HOST, PORT, PID, CLUSTER, STATE};
        ColumnFormatter cf = new ColumnFormatter(headings);
        for (InstanceInfo info : infos) {
            cf.addRow(new Object[]{
                        info.getName(),
                        info.getHost(),
                        info.getPort(),
                        formatPid(info),
                        info.getDisplayCluster(),
                        info.getDisplayState()
                    });
        }
        return cf.toString();
    }
View Full Code Here

        }
        return cf.toString();
    }

    public static String formatBrief(List<InstanceInfo> infos) {
        ColumnFormatter cf = new ColumnFormatter();
        for (InstanceInfo info : infos) {
            cf.addRow(new Object[]{
                        info.getName(),
                        info.getDisplayState()
                    });
        }
        return cf.toString();
    }
View Full Code Here

    ////////  static formatting stuff below   ///////////////////////////////
    /////////////////////////////////////////////////////////////////////////

    public static String format(List<InstanceInfo> infos) {
        String headings[] = {NAME, HOST, PORT, PID, CLUSTER, STATE};
        ColumnFormatter cf = new ColumnFormatter(headings);
        for (InstanceInfo info : infos) {
            cf.addRow(new Object[]{
                        info.getName(),
                        info.getHost(),
                        info.getPort(),
                        formatPid(info),
                        info.getDisplayCluster(),
                        info.getDisplayState()
                    });
        }
        return cf.toString();
    }
View Full Code Here

        }
        return cf.toString();
    }

    public static String formatBrief(List<InstanceInfo> infos) {
        ColumnFormatter cf = new ColumnFormatter();
        for (InstanceInfo info : infos) {
            cf.addRow(new Object[]{
                        info.getName(),
                        info.getDisplayState()
                    });
        }
        return cf.toString();
    }
View Full Code Here

TOP

Related Classes of com.sun.enterprise.admin.util.ColumnFormatter

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.