Examples of UsageException


Examples of Framework.UsageException

    public void setHelpURL(String urlString) {
        try {
            URL url = new URL(urlString);
            UserWindow.createHelp(this, url);
        } catch (MalformedURLException e) {
            UsageException err = new UsageException("Cannot create help URL", e);
            ErrorMgr.addError(err);
            throw err;
        }
    }
View Full Code Here

Examples of Framework.UsageException

    public void setHelpURL(String urlString) {
        try {
            URL url = new URL(urlString);
            UserWindow.createHelp(this, url);
        } catch (MalformedURLException e) {
            UsageException err = new UsageException("Cannot create help URL", e);
            ErrorMgr.addError(err);
            throw err;
        }
    }
View Full Code Here

Examples of cloudsync.exceptions.UsageException

    CommandLine cmd;
    try {
      cmd = parser.parse(options, args);
    } catch (ParseException e) {

      throw new UsageException(e.getMessage());
    }

    type = null;
    path = null;
    if ((path = cmd.getOptionValue(SyncType.BACKUP.getName())) != null) {
      type = SyncType.BACKUP;
    } else if ((path = cmd.getOptionValue(SyncType.RESTORE.getName())) != null) {
      type = SyncType.RESTORE;
    } else if ((path = cmd.getOptionValue(SyncType.CLEAN.getName())) != null) {
      type = SyncType.CLEAN;
    } else if (cmd.hasOption(SyncType.LIST.getName())) {
      type = SyncType.LIST;
    }

    String config = cmd.getOptionValue("config", "." + Item.SEPARATOR + "config" + Item.SEPARATOR + "cloudsync.config");
    if (config.startsWith("." + Item.SEPARATOR)) {
      config = System.getProperty("user.dir") + Item.SEPARATOR + config;
    }

    boolean configValid = config != null && new File(config).isFile();
    prop = new Properties();
    try {
      prop.load(new FileInputStream(config));
    } catch (final IOException e) {
      configValid = false;
    }

    name = getOptionValue(cmd, "name", null);

    remoteConnector = prop.getProperty("REMOTE_CONNECTOR");

    passphrase = prop.getProperty("PASSPHRASE");
    if (StringUtils.isEmpty(passphrase)) {
      throw new CloudsyncException("'PASSPHRASE' is not configured");
    }
    String value = getOptionValue(cmd, "followlinks", LinkType.EXTERNAL.getName());
    followlinks = LinkType.fromName(value);
    value = getOptionValue(cmd, "duplicate", SyncType.CLEAN.equals(type) ? DuplicateType.RENAME.getName() : DuplicateType.STOP.getName());
    duplicate = DuplicateType.fromName(value);
    value = getOptionValue(cmd, "permissions", PermissionType.SET.getName());
    permissions = PermissionType.fromName(value);

    history = (type != null && type.equals("backup")) ? Integer.parseInt(getOptionValue(cmd, "history", "0")) : 0;

    nocache = cmd.hasOption("nocache") || SyncType.CLEAN.equals(type);
    forcestart = cmd.hasOption("forcestart");
    testrun = cmd.hasOption("test");
    String pattern = getOptionValue(cmd, "include", null);
    if (pattern != null)
      includePatterns = pattern.contains("|") ? pattern.split("\\|") : new String[] { pattern };
    pattern = getOptionValue(cmd, "exclude", null);
    if (pattern != null)
      excludePatterns = pattern.contains("|") ? pattern.split("\\|") : new String[] { pattern };

    if (!StringUtils.isEmpty(name)) {
      logfilePath = Helper.preparePath(getOptionValue(cmd, "logfile", null), name);
      cachefilePath = Helper.preparePath(getOptionValue(cmd, "cachefile", null), name);
      pidfilePath = cachefilePath.substring(0, cachefilePath.lastIndexOf(".")) + ".pid";
      lockfilePath = cachefilePath.substring(0, cachefilePath.lastIndexOf(".")) + ".lock";
    }

    final boolean baseValid = SyncType.LIST.equals(type) || (path != null && new File(path).isDirectory());
    boolean logfileValid = logfilePath == null || new File(logfilePath).getParentFile().isDirectory();
    boolean cachefileValid = cachefilePath == null || new File(cachefilePath).getParentFile().isDirectory();

    if (cmd.hasOption("help") || type == null || name == null || followlinks == null || duplicate == null || permissions == null || !baseValid || config == null || !configValid || !logfileValid
        || !cachefileValid) {

      List<String> messages = new ArrayList<String>();
      if (cmd.getOptions().length > 0) {

        messages.add("error: missing or wrong options");
        if (type == null) {
          messages.add(" You must specifiy --backup, --restore, --list or --clean");
        } else if (!baseValid) {
          messages.add(" --" + type.getName() + " <path> not valid");
        }
        if (name == null) {
          messages.add(" Missing --name <name>");
        }
        if (followlinks == null) {
          messages.add(" Wrong --followlinks behavior set");
        }
        if (duplicate == null) {
          messages.add(" Wrong --duplicate behavior set");
        }
        if (permissions == null) {
          messages.add(" Wrong --permissions behavior set");
        }
        if (config == null) {
          messages.add(" Missing --config <path>");
        } else if (!configValid) {
          messages.add(" --config <path> not valid");
        }
        if (!logfileValid) {
          messages.add(" --logfile <path> not valid");
        }
        if (!cachefileValid) {
          messages.add(" --cachefile <path> not valid");
        }
      }
      throw new UsageException(StringUtils.join(messages, '\n'));
    }
  }
View Full Code Here

Examples of co.cask.cdap.common.utils.UsageException

    HelpFormatter formatter = new HelpFormatter();
    formatter.printOptions(pw, 100, options, 0, 10);
    pw.flush();
    pw.close();
    if (error) {
      throw new UsageException();
    }
  }
View Full Code Here

Examples of com.android.dx.command.UsageException

                    statistics = true;
                } else if (arg.startsWith("--optimize-list=")) {
                    if (dontOptimizeListFile != null) {
                        System.err.println("--optimize-list and "
                                + "--no-optimize-list are incompatible.");
                        throw new UsageException();
                    }
                    optimize = true;
                    optimizeListFile = arg.substring(arg.indexOf('=') + 1);
                } else if (arg.startsWith("--no-optimize-list=")) {
                    if (dontOptimizeListFile != null) {
                        System.err.println("--optimize-list and "
                                + "--no-optimize-list are incompatible.");
                        throw new UsageException();
                    }
                    optimize = true;
                    dontOptimizeListFile = arg.substring(arg.indexOf('=') + 1);
                } else if (arg.equals("--keep-classes")) {
                    keepClassesInJar = true;
                } else if (arg.startsWith("--output=")) {
                    outName = arg.substring(arg.indexOf('=') + 1);
                    if (outName.endsWith(".zip") ||
                            outName.endsWith(".jar") ||
                            outName.endsWith(".apk")) {
                        jarOutput = true;
                    } else if (outName.endsWith(".dex") ||
                               outName.equals("-")) {
                        jarOutput = false;
                    } else {
                        System.err.println("unknown output extension: " +
                                           outName);
                        throw new UsageException();
                    }
                } else if (arg.startsWith("--dump-to=")) {
                    humanOutName = arg.substring(arg.indexOf('=') + 1);
                } else if (arg.startsWith("--dump-width=")) {
                    arg = arg.substring(arg.indexOf('=') + 1);
                    dumpWidth = Integer.parseInt(arg);
                } else if (arg.startsWith("--dump-method=")) {
                    methodToDump = arg.substring(arg.indexOf('=') + 1);
                    jarOutput = false;
                } else if (arg.startsWith("--positions=")) {
                    String pstr = arg.substring(arg.indexOf('=') + 1).intern();
                    if (pstr == "none") {
                        positionInfo = PositionList.NONE;
                    } else if (pstr == "important") {
                        positionInfo = PositionList.IMPORTANT;
                    } else if (pstr == "lines") {
                        positionInfo = PositionList.LINES;
                    } else {
                        System.err.println("unknown positions option: " +
                                           pstr);
                        throw new UsageException();
                    }
                } else if (arg.equals("--no-locals")) {
                    localInfo = false;
                } else {
                    System.err.println("unknown option: " + arg);
                    throw new UsageException();
                }
            }

            int fileCount = args.length - at;

            if (fileCount == 0) {
                if (!emptyOk) {
                    System.err.println("no input files specified");
                    throw new UsageException();
                }
            } else if (emptyOk) {
                System.out.println("ignoring input files");
                at = 0;
                fileCount = 0;
View Full Code Here

Examples of com.dbdeploy.exceptions.UsageException

    checkForRequiredParameter(driver, "driver");
    checkForRequiredParameter(url, "url");
    checkForRequiredParameter(scriptdirectory, "dir");

    if (scriptdirectory == null || !scriptdirectory.isDirectory()) {
      throw new UsageException("Script directory must point to a valid directory");
    }
  }
View Full Code Here

Examples of com.ontology2.centipede.errors.UsageException

        OptionParser parser=new OptionParser(ExtractIsAOptions.class);
        applicationContext.getAutowireCapableBeanFactory().autowireBean(parser);

        ExtractIsAOptions options=(ExtractIsAOptions) parser.parse(Lists.newArrayList(strings));
        if (options.input.isEmpty())
            throw new UsageException("You did not specify a value for -input");

        if (options.output==null || options.output.isEmpty())
            throw new UsageException("You did not specify a value for -output");

        if (options.type.isEmpty())
            throw new UsageException("You did not specify a value for -type");

        if(options.reducerCount<1) {
            options.reducerCount=1;
        }
        return options;
View Full Code Here

Examples of com.ontology2.centipede.errors.UsageException

        OptionParser parser=new OptionParser(DiffFactsOptions.class);
        applicationContext.getAutowireCapableBeanFactory().autowireBean(parser);

        DiffFactsOptions o= (DiffFactsOptions) parser.parse(Lists.newArrayList(strings));
        if (o.left.isEmpty())
            throw new UsageException("you did not specify a value for -left");

        if (o.right.isEmpty())
            throw new UsageException("you did not specify a value for -right");

        if (o.output.isEmpty())
            throw new UsageException("you did not specify a value for -output");

        conf.set("mapred.compress.map.output", "true");
        conf.set("mapred.output.compression.type", "BLOCK");
        conf.set("mapred.map.output.compression.codec", "org.apache.hadoop.io.compress.GzipCodec");
        conf.set(SetJoinMapper.INPUTS+".1", Joiner.on(",").join(o.left));
View Full Code Here

Examples of com.ontology2.centipede.errors.UsageException

    protected void _run(String[] arguments) throws Exception {
        NewPersistentClusterOptions options=extractOptions(arguments);

        Cluster cluster=options.clusterId.isEmpty() ? defaultCluster : applicationContext.getBean(options.clusterId,Cluster.class);
        if (!(cluster instanceof AmazonEMRCluster)) {
            throw new UsageException("the -clusterId must specify an Amazon EMR Cluster");
        }

        String name=((AmazonEMRCluster) cluster).createPersistentCluster("Persistent Cluster");
        System.out.println(name);
    }
View Full Code Here

Examples of com.ontology2.centipede.errors.UsageException

    private String keyPairName;

    @Override
    protected void _run(String[] strings) throws Exception {
        if(strings.length<1)
            throw new UsageException("must specify AWS instance number");

        String targetId=strings[0];
        String instanceId="";

        if(targetId.startsWith("j-")) {
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.