Example usage for org.apache.commons.cli Parser parse

List of usage examples for org.apache.commons.cli Parser parse

Introduction

In this page you can find the example usage for org.apache.commons.cli Parser parse.

Prototype

public CommandLine parse(Options options, String[] arguments) throws ParseException 

Source Link

Document

Parses the specified arguments based on the specifed Options .

Usage

From source file:org.onebusaway.uk.network_rail.gtfs_realtime.GenerateBerthAreaToStanoxAreaMappingMain.java

private void run(String[] args) throws ParseException, IOException {
    Options options = new Options();
    buildOptions(options);//from  w ww  . j a v a2s . co m

    Parser parser = new PosixParser();
    CommandLine cli = parser.parse(options, args);

    Set<Module> modules = new HashSet<Module>();
    NetworkRailGtfsRealtimeModule.addModuleAndDependencies(modules);
    Injector injector = Guice.createInjector(modules);
    injector.injectMembers(this);

    Map<String, Set<String>> berthAreaToStanoxAreas = new HashMap<String, Set<String>>();

    BufferedReader reader = new BufferedReader(new FileReader(cli.getOptionValue(ARG_BERTH_MAPPING_PATH)));
    String line = null;

    while ((line = reader.readLine()) != null) {
        String[] tokens = line.split(",");
        String area = tokens[0];
        String stanoxValue = tokens[4];
        if (stanoxValue.length() < 2) {
            _log.info("stanox without area: " + stanoxValue);
            continue;
        }
        String stanoxArea = stanoxValue.substring(0, 2);
        Set<String> stanoxAreas = berthAreaToStanoxAreas.get(area);
        if (stanoxAreas == null) {
            stanoxAreas = new HashSet<String>();
            berthAreaToStanoxAreas.put(area, stanoxAreas);
        }
        stanoxAreas.add(stanoxArea);
    }

    reader.close();

    List<String> berthAreas = new ArrayList<String>(berthAreaToStanoxAreas.keySet());
    Collections.sort(berthAreas);

    OutputStream out = cli.hasOption(ARG_OUTPUT_PATH)
            ? new FileOutputStream(cli.getOptionValue(ARG_OUTPUT_PATH))
            : System.out;
    PrintWriter writer = new PrintWriter(new OutputStreamWriter(out));
    writer.println("berth_area,stanox_area");

    for (String berthArea : berthAreas) {
        List<String> stanoxAreas = new ArrayList<String>(berthAreaToStanoxAreas.get(berthArea));
        Collections.sort(stanoxAreas);
        for (String stanoxArea : stanoxAreas) {
            writer.println(berthArea + "," + stanoxArea);
        }
    }

    writer.close();
}

From source file:org.onebusaway.uk.network_rail.gtfs_realtime.GenerateNarrativesMain.java

private void run(String[] args) throws ParseException, IOException {
    Options options = new Options();
    buildOptions(options);/*from w  ww .j a  va  2  s .  c  om*/

    Parser parser = new PosixParser();
    CommandLine cli = parser.parse(options, args);

    Set<Module> modules = new HashSet<Module>();
    NetworkRailGtfsRealtimeModule.addModuleAndDependencies(modules);
    Injector injector = Guice.createInjector(modules);
    injector.injectMembers(this);

    _timetableService.readScheduleData(new File(cli.getOptionValue(ARG_ATOC_TIMETABLE_PATH)));
    _timetableService
            .readBerthToStanoxAreaMapping(new File(cli.getOptionValue(ARG_BERTH_TO_STANOX_AREA_MAPPING_PATH)));

    _trainTrackingService.addListener(new TrainTrackingListenerImpl());

    _narrativePbPath = cli.getOptionValue(ARG_NARRATIVE_PB_PATH);
    _narrativeAsciiPath = cli.getOptionValue(ARG_NARRATIVE_ASCII_PATH);

    _lifecycleService.start();

    File logPath = new File(cli.getOptionValue(ARG_LOG_PATH));
    FileMatcher matcher = new FileMatcher();
    matcher.setExtension(".json");
    // matcher.setMinLastModifiedTime(System.currentTimeMillis()
    // - (43 * 24 * 60 * 60 * 1000L));
    List<File> logFiles = matcher.matchFiles(logPath);
    _log.info("files=" + logFiles.size());
    _logReplayService.parseLogFiles(logPath, logFiles);

    _trainTrackingService.pruneAllInstances();
}

From source file:org.onebusaway.uk.network_rail.gtfs_realtime.graph.ConstructBerthToStanoxGraphMain.java

private void run(String[] args) throws ParseException, IOException {
    Options options = new Options();
    buildOptions(options);//from  w w w.j a v  a 2 s .co m

    Parser parser = new PosixParser();
    CommandLine cli = parser.parse(options, args);

    Set<Module> modules = new HashSet<Module>();
    NetworkRailGtfsRealtimeModule.addModuleAndDependencies(modules);
    Injector injector = Guice.createInjector(modules);
    injector.injectMembers(this);

    _timetableService.readScheduleData(new File(cli.getOptionValue(ARG_ATOC_TIMETABLE_PATH)));
    // _timetableService.readBerthToStanoxAreaMapping(new File(
    // cli.getOptionValue(ARG_BERTH_TO_STANOX_AREA_MAPPING_PATH)));

    _edgeLogPath = cli.getOptionValue(ARG_EDGE_LOG_PATH);

    _lifecycleService.start();

    File narrativePath = new File(cli.getOptionValue(ARG_NARRATIVE_PATH));
    FileMatcher matcher = new FileMatcher();
    matcher.setExtension(".pb");
    List<File> narrativeFiles = matcher.matchFiles(narrativePath);
    _log.info("files=" + narrativeFiles.size());

    _edgeLog = new BufferedWriter(new FileWriter(_edgeLogPath));

    int i = 0;
    for (File narrativeFile : narrativeFiles) {
        if (i % 1000 == 0) {
            _log.info("files=" + i);
        }
        i++;
        InputStream in = new BufferedInputStream(new FileInputStream(narrativeFile));
        SerializedNarrative.TrainInstance trainInstance = SerializedNarrative.TrainInstance.parseFrom(in);
        expandGraph(trainInstance);
    }
    _edgeLog.close();

    _graph.write(new File(cli.getOptionValue(ARG_GRAPH_PATH)));
}

From source file:org.onebusaway.uk.network_rail.gtfs_realtime.graph.DetermineStanoxToBerthConnectivityMain.java

private void run(String[] args) throws ParseException, IOException {
    Options options = new Options();
    buildOptions(options);//  ww  w.j  a  v  a2  s  .c  o m

    Parser parser = new PosixParser();
    CommandLine cli = parser.parse(options, args);

    Set<Module> modules = new HashSet<Module>();
    NetworkRailGtfsRealtimeModule.addModuleAndDependencies(modules);
    Injector injector = Guice.createInjector(modules);
    injector.injectMembers(this);

    _graph.read(new File(cli.getOptionValue(ARG_INPUT_GRAPH_PATH)));

    RawStanoxNode node = (RawStanoxNode) _graph.getNode(TrackIdentifier.getStanoxIdentifier(87972));
    List<Ordered<String>> what = new ArrayList<Ordered<String>>();
    for (Map.Entry<RawNode, List<Integer>> entry : node.getIncoming().entrySet()) {
        RawNode to = entry.getKey();
        int avg = RawNode.average(entry.getValue());
        what.add(new Ordered<String>(to + " " + avg, entry.getValue().size()));
    }
    Collections.sort(what);
    for (Ordered<String> key : what) {
        System.out.println(key.toString());
    }
    _graph.write(new File(cli.getOptionValue(ARG_OUTPUT_GRAPH_PATH)));
}

From source file:org.onebusaway.uk.network_rail.gtfs_realtime.graph.PositionBerthToStanoxGraphMain.java

private void run(String[] args) throws ParseException, IOException {
    Options options = new Options();
    buildOptions(options);//from   www .java 2s. c o m

    Parser parser = new PosixParser();
    CommandLine cli = parser.parse(options, args);

    Set<Module> modules = new HashSet<Module>();
    NetworkRailGtfsRealtimeModule.addModuleAndDependencies(modules);
    Injector injector = Guice.createInjector(modules);
    injector.injectMembers(this);

    _timetableService.readScheduleData(new File(cli.getOptionValue(ARG_ATOC_TIMETABLE_PATH)));
    if (cli.hasOption(ARG_STATIONS_PATH)) {
        _timetableService.readStationLocations(new File(cli.getOptionValue(ARG_STATIONS_PATH)));
    }
    if (cli.hasOption(ARG_OSM_SHAPES_PATH)) {
        _railwayShapeService.readOsmShapeData(new File(cli.getOptionValue(ARG_OSM_SHAPES_PATH)));
    }

    _graph.read(new File(cli.getOptionValue(ARG_GRAPH_PATH)));

    buildStanoxLocations();
    setBerthLocationsFromStanox();

    loop();
    exportLocationsToKml();
}

From source file:org.onebusaway.uk.network_rail.gtfs_realtime.graph.SimplifyBerthGraphMain.java

private void run(String[] args) throws ParseException, IOException {
    Options options = new Options();
    buildOptions(options);/*  ww  w  . j  ava2 s.  c o m*/

    Parser parser = new PosixParser();
    CommandLine cli = parser.parse(options, args);

    Set<Module> modules = new HashSet<Module>();
    NetworkRailGtfsRealtimeModule.addModuleAndDependencies(modules);
    Injector injector = Guice.createInjector(modules);
    injector.injectMembers(this);

    _graph.read(new File(cli.getOptionValue(ARG_INPUT_GRAPH_PATH)));

    List<RawBerthNode> berthNodes = new ArrayList<RawBerthNode>();
    List<RawStanoxNode> stanoxNodes = new ArrayList<RawStanoxNode>();
    for (RawNode node : _graph.getNodes()) {
        if (node instanceof RawBerthNode) {
            berthNodes.add((RawBerthNode) node);
        } else if (node instanceof RawStanoxNode) {
            stanoxNodes.add((RawStanoxNode) node);
        }
    }

    RawStanoxNode a = (RawStanoxNode) _graph.getNode(TrackIdentifier.getStanoxIdentifier(3054));
    RawBerthNode b = (RawBerthNode) _graph.getNode(TrackIdentifier.getBerthIdentifier("WH_0347-WH_COUT"));
    System.out.println(a.getIncoming().get(b));
    System.out.println(a.getOutgoing().get(b));

    _log.info("stanox edges=" + countStanoxEdges(stanoxNodes));
    System.out.println(a.getIncoming().keySet());
    System.out.println(a.getOutgoing().keySet());

    for (RawStanoxNode node : stanoxNodes) {
        pruneStanox(node.getIncoming().keySet(), 0);
        pruneStanox(node.getOutgoing().keySet(), 0);
        pruneStanox(node.getIncoming().keySet(), node.getId().getStanox());
        pruneStanox(node.getOutgoing().keySet(), node.getId().getStanox());
    }

    _log.info("stanox edges=" + countStanoxEdges(stanoxNodes));
    System.out.println(a.getIncoming().keySet());
    System.out.println(a.getOutgoing().keySet());
    pruneLongStanoxToBerthEdges(stanoxNodes, 15 * 60);

    _log.info("stanox edges=" + countStanoxEdges(stanoxNodes));
    // System.out.println(a.getIncoming().keySet());
    // System.out.println(a.getOutgoing().keySet());

    for (RawStanoxNode node : stanoxNodes) {
        pruneInfrequentStanoxToBerthEdges(node, 0.25);
    }

    _log.info("stanox edges=" + countStanoxEdges(stanoxNodes));
    // System.out.println(a.getIncoming().keySet());
    // System.out.println(a.getOutgoing().keySet());

    for (RawStanoxNode node : stanoxNodes) {
        pruneRedundantBerthStepEdges(node, true);
        pruneRedundantBerthStepEdges(node, false);
    }

    _log.info("stanox edges=" + countStanoxEdges(stanoxNodes));
    // System.out.println(a.getIncoming().keySet());
    // System.out.println(a.getOutgoing().keySet());

    for (RawStanoxNode node : stanoxNodes) {
        pruneDistantBerthEdges(node, 15);
    }

    _log.info("stanox edges=" + countStanoxEdges(stanoxNodes));
    // System.out.println(a.getIncoming().keySet());
    // System.out.println(a.getOutgoing().keySet());

    _log.info("edges=" + countEdges(berthNodes));
    pruneSelfEdges(berthNodes);

    _log.info("edges=" + countEdges(berthNodes));
    Map<RawBerthNode, Set<RawBerthNode>> directParents = new HashMap<RawBerthNode, Set<RawBerthNode>>();
    pruneIndirectBerthEdges(berthNodes, directParents);

    _log.info("edges=" + countEdges(berthNodes));
    pruneIndirectParentBerthEdges(berthNodes, directParents);

    _log.info("edges=" + countEdges(berthNodes));
    pruneInfrequentBerthEdges(berthNodes, 0.25);

    _log.info("edges=" + countEdges(berthNodes));
    pruneLongBerthEdges(berthNodes, 15 * 60);

    _log.info("edges=" + countEdges(berthNodes));

    _graph.write(new File(cli.getOptionValue(ARG_OUTPUT_GRAPH_PATH)));
}

From source file:org.onebusaway.uk.network_rail.gtfs_realtime.graph.VisualizeBerthLocationsMain.java

private void run(String[] args) throws ParseException, IOException {
    Options options = new Options();
    buildOptions(options);/*from w  ww  .j  ava  2 s.  c  o m*/

    Parser parser = new PosixParser();
    CommandLine cli = parser.parse(options, args);

    Set<Module> modules = new HashSet<Module>();
    NetworkRailGtfsRealtimeModule.addModuleAndDependencies(modules);
    Injector injector = Guice.createInjector(modules);
    injector.injectMembers(this);

    TimetableService model = new TimetableService();
    model.readScheduleData(new File(cli.getOptionValue(ARG_ATOC_TIMETABLE_PATH)));

    Map<String, String> regionToStyle = new HashMap<String, String>();

    PrintWriter writer = new PrintWriter(new File(cli.getOptionValue(ARG_OUTPUT_PATH)));
    writer.println("area,style,from,to,region,stanox,tiploc,lat,lon,name");

    BufferedReader reader = new BufferedReader(new FileReader(cli.getOptionValue(ARG_BERTH_MAPPING_PATH)));
    String line = null;

    Map<String, Pair<Range>> rangesByArea = new HashMap<String, Pair<Range>>();

    while ((line = reader.readLine()) != null) {
        String[] tokens = line.split(",");
        String area = tokens[0];
        String from = tokens[2];
        String to = tokens[3];
        String stanoxValue = tokens[4];
        if (stanoxValue.length() < 2) {
            System.out.println(stanoxValue);
            continue;
        }
        int stanox = Integer.parseInt(stanoxValue);
        String region = stanoxValue.substring(0, 2);

        String style = regionToStyle.get(area);

        if (style == null) {
            style = IconStyles.SMALL[regionToStyle.size() % IconStyles.SMALL.length];
            regionToStyle.put(area, style);
        }

        Pair<Range> ranges = rangesByArea.get(area);
        if (ranges == null) {
            ranges = Tuples.pair(new Range(), new Range());
            rangesByArea.put(area, ranges);
        }
        Range xRange = ranges.getFirst();
        Range yRange = ranges.getSecond();

        for (String tiploc : model.getTiplocsForStanox(stanox)) {
            StationElement station = model.getStationForTiploc(tiploc);
            if (station != null) {
                writer.println(area + "," + style + "," + from + "," + to + "," + region + "," + stanox + ","
                        + tiploc + "," + station.getLat() + "," + station.getLon() + "," + station.getName());
                xRange.addValue(station.getEasting());
                yRange.addValue(station.getNorthing());
            }
        }
    }

    Max<String> maxRange = new Max<String>();
    for (Map.Entry<String, Pair<Range>> entry : rangesByArea.entrySet()) {
        String area = entry.getKey();
        Pair<Range> ranges = entry.getValue();
        if (ranges.getFirst().isEmpty()) {
            continue;
        }
        double dx = ranges.getFirst().getRange();
        double dy = ranges.getFirst().getRange();
        double v = Math.sqrt(dx * dx + dy * dy);
        maxRange.add(v, area);
    }

    System.out.println(maxRange.getMaxElement() + " " + maxRange.getMaxValue());

    reader.close();

    writer.close();
}

From source file:org.onebusaway.uk.network_rail.gtfs_realtime.graph.VisualizeStanoxLocationsMain.java

private void run(String[] args) throws ParseException, IOException {
    Options options = new Options();
    buildOptions(options);/*from  w  ww.ja v  a2 s.co m*/

    Parser parser = new PosixParser();
    CommandLine cli = parser.parse(options, args);

    Set<Module> modules = new HashSet<Module>();
    NetworkRailGtfsRealtimeModule.addModuleAndDependencies(modules);
    Injector injector = Guice.createInjector(modules);
    injector.injectMembers(this);

    TimetableService model = new TimetableService();
    model.readScheduleData(new File(cli.getOptionValue(ARG_ATOC_TIMETABLE_PATH)));

    Map<String, String> regionToStyle = new HashMap<String, String>();

    PrintWriter writer = new PrintWriter(new File(cli.getOptionValue(ARG_OUTPUT_PATH)));
    writer.println("region,style,stanox,tiploc,lat,lon,name");

    for (int stanox : model.getAllStanox()) {
        String stanoxValue = Integer.toString(stanox);
        if (stanoxValue.length() < 2) {
            System.out.println(stanox);
            continue;
        }
        String region = stanoxValue.substring(0, 2);
        String style = regionToStyle.get(region);
        if (style == null) {
            style = IconStyles.SMALL[regionToStyle.size() % IconStyles.SMALL.length];
            regionToStyle.put(region, style);
        }
        for (String tiploc : model.getTiplocsForStanox(stanox)) {
            StationElement station = model.getStationForTiploc(tiploc);
            if (station != null) {
                writer.println(region + "," + style + "," + stanox + "," + tiploc + "," + station.getLat() + ","
                        + station.getLon() + "," + station.getName());
            }
        }
    }

    writer.close();

}

From source file:org.onebusaway.uk.network_rail.gtfs_realtime.NetworkRailToGtfsRealtimeMain.java

public void run(String[] args) throws Exception {

    Options options = new Options();
    buildOptions(options);//from  www .  j a v a  2s  .  com
    Daemonizer.buildOptions(options);

    Parser parser = new PosixParser();
    CommandLine cli = parser.parse(options, args);

    Daemonizer.handleDaemonization(cli);

    Set<Module> modules = new HashSet<Module>();
    NetworkRailGtfsRealtimeModule.addModuleAndDependencies(modules);
    Injector injector = Guice.createInjector(modules);
    injector.injectMembers(this);

    _messageListenerService.setUsername(cli.getOptionValue(ARG_USERNAME));
    _messageListenerService.setPassword(cli.getOptionValue(ARG_PASSWORD));

    _gtfsRealtimeService.setAtocTimetablePath(new File(cli.getOptionValue(ARG_ATOC_TIMETABLE_PATH)));
    if (cli.hasOption(ARG_BERTH_MAPPING_PATH)) {
        _gtfsRealtimeService.setBerthMappingPath(new File(cli.getOptionValue(ARG_BERTH_MAPPING_PATH)));
    }
    if (cli.hasOption(ARG_LOG_PATH)) {
        _loggingService.setLogPath(cli.getOptionValue(ARG_LOG_PATH));
    }
    _loggingService.setReplayLogs(cli.hasOption(ARG_REPLAY_LOGS));

    if (cli.hasOption(ARG_STATE_PATH)) {
        _gtfsRealtimeService.setStatePath(new File(cli.getOptionValue(ARG_STATE_PATH)));
    }

    if (cli.hasOption(ARG_NARRATIVE_PATH)) {
        _narrativeService.setLogPath(cli.getOptionValue(ARG_NARRATIVE_PATH));
    }

    if (cli.hasOption(ARG_TRIP_UPDATES_PATH)) {
        TripUpdatesFileWriter writer = injector.getInstance(TripUpdatesFileWriter.class);
        writer.setPath(new File(cli.getOptionValue(ARG_TRIP_UPDATES_PATH)));
    }
    if (cli.hasOption(ARG_TRIP_UPDATES_URL)) {
        TripUpdatesServlet servlet = injector.getInstance(TripUpdatesServlet.class);
        servlet.setUrl(new URL(cli.getOptionValue(ARG_TRIP_UPDATES_URL)));
    }

    _lifecycleService.start();
}

From source file:org.openmeetings.cli.Admin.java

private void process(String[] args) {
    String ctxName = System.getProperty("context", "openmeetings");
    File home = new File(System.getenv("RED5_HOME"));
    omHome = new File(new File(home, "webapps"), ctxName);
    File omUploadTemp = new File(omHome, OpenmeetingsVariables.UPLOAD_TEMP_DIR);

    Parser parser = new PosixParser();
    try {/*  w  w w.j  ava 2  s.c  o m*/
        cmdl = parser.parse(opts, args);
    } catch (ParseException e) {
        System.out.println(e.getMessage());
        usage();
        System.exit(1);
    }
    verbose = cmdl.hasOption('v');

    Command cmd = Command.usage;
    if (cmdl.hasOption('i')) {
        cmd = Command.install;
    } else if (cmdl.hasOption('b')) {
        cmd = Command.backup;
    } else if (cmdl.hasOption('r')) {
        cmd = Command.restore;
    } else if (cmdl.hasOption('f')) {
        cmd = Command.files;
    }

    String file = cmdl.getOptionValue("file", "");
    switch (cmd) {
    case install:
        try {
            if (cmdl.hasOption("file")
                    && (cmdl.hasOption("user") || cmdl.hasOption("email") || cmdl.hasOption("group"))) {
                System.out.println("Please specify even 'file' option or 'admin user'.");
                System.exit(1);
            }
            boolean force = cmdl.hasOption("force");
            if (cmdl.hasOption("skip-default-rooms")) {
                cfg.createDefaultRooms = "0";
            }
            if (cmdl.hasOption("disable-frontend-register")) {
                cfg.allowFrontendRegister = "0";
            }
            if (cmdl.hasOption("system-email-address")) {
                cfg.mailReferer = cmdl.getOptionValue("system-email-address");
            }
            if (cmdl.hasOption("smtp-server")) {
                cfg.smtpServer = cmdl.getOptionValue("smtp-server");
            }
            if (cmdl.hasOption("smtp-port")) {
                cfg.smtpPort = cmdl.getOptionValue("smtp-port");
            }
            if (cmdl.hasOption("email-auth-user")) {
                cfg.mailAuthName = cmdl.getOptionValue("email-auth-user");
            }
            if (cmdl.hasOption("email-auth-pass")) {
                cfg.mailAuthPass = cmdl.getOptionValue("email-auth-pass");
            }
            if (cmdl.hasOption("email-use-tls")) {
                cfg.mailUseTls = "1";
            }
            String langPath = new File(omHome, ImportInitvalues.languageFolderName).getAbsolutePath(); //FIXME need to be moved to helper
            ConnectionProperties connectionProperties = new ConnectionProperties();
            File conf = new File(omHome, "WEB-INF/classes/META-INF/persistence.xml");
            if (!conf.exists() || cmdl.hasOption("db-type") || cmdl.hasOption("db-host")
                    || cmdl.hasOption("db-port") || cmdl.hasOption("db-name") || cmdl.hasOption("db-user")
                    || cmdl.hasOption("db-pass")) {
                String dbType = cmdl.getOptionValue("db-type", "derby");
                File srcConf = new File(omHome, "WEB-INF/classes/META-INF/" + dbType + "_persistence.xml");
                ConnectionPropertiesPatcher.getPatcher(dbType).patch(srcConf, conf,
                        cmdl.getOptionValue("db-host", "localhost"), cmdl.getOptionValue("db-port", null),
                        cmdl.getOptionValue("db-name", null), cmdl.getOptionValue("db-user", null),
                        cmdl.getOptionValue("db-pass", null), connectionProperties);
            } else {
                //get properties from existent persistence.xml
                connectionProperties = ConnectionPropertiesPatcher.getConnectionProperties(conf);
            }
            if (cmdl.hasOption("file")) {
                File backup = checkRestoreFile(file);
                dropDB(connectionProperties);

                shutdownScheduledJobs(ctxName);
                ImportInitvalues importInit = getApplicationContext(ctxName).getBean(ImportInitvalues.class);
                importInit.loadSystem(langPath, cfg, force);
                restoreOm(ctxName, backup);
            } else {
                AdminUserDetails admin = checkAdminDetails(ctxName, langPath);
                dropDB(connectionProperties);

                shutdownScheduledJobs(ctxName);
                ImportInitvalues importInit = getApplicationContext(ctxName).getBean(ImportInitvalues.class);
                importInit.loadAll(langPath, cfg, admin.login, admin.pass, admin.email, admin.group, admin.tz,
                        force);
            }

            File installerFile = new File(new File(omHome, ScopeApplicationAdapter.configDirName),
                    InstallationDocumentHandler.installFileName);
            InstallationDocumentHandler.getInstance().createDocument(installerFile.getAbsolutePath(), 3);
        } catch (Exception e) {
            handleError("Install failed", e);
        }
        break;
    case backup:
        try {
            if (!cmdl.hasOption("file")) {
                file = "backup_" + CalendarPatterns.getTimeForStreamId(new Date()) + ".zip";
                System.out.println("File name was not specified, '" + file + "' will be used");
            }
            boolean includeFiles = Boolean.parseBoolean(cmdl.getOptionValue("exclude-files", "true"));
            File backup_dir = new File(omUploadTemp, "" + System.currentTimeMillis());
            backup_dir.mkdirs();

            shutdownScheduledJobs(ctxName);
            BackupExport export = getApplicationContext(ctxName).getBean(BackupExport.class);
            export.performExport(file, backup_dir, includeFiles, omHome.getAbsolutePath());
            export.deleteDirectory(backup_dir);
            backup_dir.delete();
        } catch (Exception e) {
            handleError("Backup failed", e);
        }
        break;
    case restore:
        try {
            shutdownScheduledJobs(ctxName);
            restoreOm(ctxName, checkRestoreFile(file));
        } catch (Exception e) {
            handleError("Restore failed", e);
        }
        break;
    case files:
        try {
            File omUpload = new File(omHome, OpenmeetingsVariables.UPLOAD_DIR);
            File omStreams = new File(omHome, OpenmeetingsVariables.STREAMS_DIR);
            System.out.println("Temporary upload files allocates: " + FileUtils.getHumanSize(omUploadTemp));
            System.out.println("Upload allocates: " + FileUtils.getHumanSize(omUpload));
            System.out.println("Recordings allocates: " + FileUtils.getHumanSize(omStreams));
            /*
            omHome
                    
            ClassPathXmlApplicationContext ctx = getApplicationContext(ctxName);
            //user pictures
            //dist/red5/webapps/openmeetings/upload/profiles/profile_<id> (check if ends with filename)
            UsersDaoImpl udao = ctx.getBean(UsersDaoImpl.class);
            for (Users u : udao.getAllUsersDeleted()) {
               System.out.println("id == " + u.getUser_id() + "; deleted ? " + u.getDeleted() + "; uri -> " + u.getPictureuri());
            }
                    
            */
            //Upload backup ???

            //Upload import ???

            //public/private files
            //Object: fileexploreritem (filehash == document file/folder)
            //webapps/openmeetings/upload/files (check if ends with filename)

            //public/private recordings
            //Object: flvrecording
            //webapps/openmeetings/streams/<room_id>/rec_<id>*            -->temporary files
            //webapps/openmeetings/streams/hibernate/flvRecording_<id>*      -->files
        } catch (Exception e) {
            handleError("Files failed", e);
        }
        break;
    case usage:
    default:
        usage();
        break;
    }

    System.out.println("... Done");
    System.exit(0);
}