/** * Throw a {@link MissingArgumentException} if the current option * didn't receive the number of arguments expected. */ private void checkRequiredArgs() throws ParseException { if (currentOption != null && currentOption.requiresArg()) { throw new MissingArgumentException(currentOption); } }
throw new MissingArgumentException(opt);
@Override public int execute(final String fullCommand, final CommandLine cl, final Shell shellState) throws Exception { final String tableName = OptUtil.getTableOpt(cl, shellState); final boolean decode = cl.hasOption(base64Opt.getOpt()); final TreeSet<Text> splits = new TreeSet<>(); if (cl.hasOption(optSplitsFile.getOpt())) { splits.addAll(ShellUtil.scanFile(cl.getOptionValue(optSplitsFile.getOpt()), decode)); } else { if (cl.getArgList().isEmpty()) { throw new MissingArgumentException("No split points specified"); } for (String s : cl.getArgs()) { splits.add(new Text(s.getBytes(Shell.CHARSET))); } } if (!shellState.getAccumuloClient().tableOperations().exists(tableName)) { throw new TableNotFoundException(null, tableName, null); } shellState.getAccumuloClient().tableOperations().addSplits(tableName, splits); return 0; }
throw new MissingArgumentException("No terms specified");
/** * Helper method used by command line parsing logic to convert historical * ASC language codes into a java {@link Locale} objecst. * * @param language ASC language code to convert * @return A {@link Locale} object for the specified asc language code. * @throws MissingArgumentException Thrown if the specified language code is * not a valid asc language code. */ private static Locale getLocaleForLanguage(String language) throws MissingArgumentException { Locale result = localeMap.get(language); if (result != null) return result; throw new MissingArgumentException("Language option must be one of: " + Joiner.on(", ").join(localeMap.keySet())); }
/** * Helper method used by command line parsing logic to convert historical * ASC language codes into a java {@link Locale} objecst. * * @param language ASC language code to convert * @return A {@link Locale} object for the specified asc language code. * @throws MissingArgumentException Thrown if the specified language code is * not a valid asc language code. */ private static Locale getLocaleForLanguage(String language) throws MissingArgumentException { Locale result = localeMap.get(language); if (result != null) return result; throw new MissingArgumentException("Language option must be one of: " + Joiner.on(", ").join(localeMap.keySet())); }
/** * Helper method used by command line parsing logic to convert historical * ASC language codes into a java {@link Locale} objecst. * * @param language ASC language code to convert * @return A {@link Locale} object for the specified asc language code. * @throws MissingArgumentException Thrown if the specified language code is * not a valid asc language code. */ private static Locale getLocaleForLanguage(String language) throws MissingArgumentException { Locale result = localeMap.get(language); if (result != null) return result; throw new MissingArgumentException("Language option must be one of: " + Joiner.on(", ").join(localeMap.keySet())); }
/** * Throw a {@link MissingArgumentException} if the current option * didn't receive the number of arguments expected. */ private void checkRequiredArgs() throws ParseException { if (currentOption != null && currentOption.requiresArg()) { throw new MissingArgumentException(currentOption); } }
private static Code toCode(String codeComponents) throws MissingArgumentException { String[] components = codeComponents.split(":"); if (components.length < 3) throw new MissingArgumentException("Invalid code specified " + " code can be specified as codevalue" + ":codeschemedesignator" + ":codemeaning:codeversion where only " + "version is optional"); return new Code(components[0], components[2], components.length == 4 ? components[3] : null,components[1]); }
@Override public void execute(CommandLine options) throws Exception { String[] args = options.getArgs(); if (args.length < min) { throw new MissingArgumentException("missing required arguments"); } if (args.length > max) { throw new UnrecognizedOptionException("unknown extra argument \"" + args[max] + "\""); } } }
private static void init(CommandLine cl, WadoRS wadoRS) throws Exception { if (cl.getArgList().isEmpty()) throw new MissingArgumentException("Specify at least one url as an argument"); wadoRS.setAcceptType(cl.hasOption("a") ? cl.getOptionValue("a") : wildcard); wadoRS.setUser(cl.getOptionValue("u")); if (cl.hasOption("out-dir")) wadoRS.setOutputDirectory(cl.getOptionValue("out-dir")); wadoRS.setHeader(cl.hasOption("header")); }
private static void init(CommandLine cl, WadoRS wadoRS) throws Exception { if (cl.getArgList().isEmpty()) throw new MissingArgumentException("Specify at least one url as an argument"); wadoRS.setAcceptType(cl.hasOption("a") ? cl.getOptionValue("a") : wildcard); wadoRS.setUser(cl.getOptionValue("u")); if (cl.hasOption("out-dir")) wadoRS.setOutputDirectory(cl.getOptionValue("out-dir")); wadoRS.setHeader(cl.hasOption("header")); }
private static void doNecessaryChecks(CommandLine cl, StowRS instance, List<String> files) throws Exception { if (files.isEmpty()) throw new MissingArgumentException("No pixel data files or dicom files specified"); if ((instance.URL = cl.getOptionValue("url")) == null) throw new MissingOptionException("Missing url."); checkFileType(files, instance); instance.user = cl.getOptionValue("u"); instance.metadataFile = cl.getOptionValue("f"); setContentAndAcceptType(instance, cl); instance.pixelHeader = cl.hasOption("pixel-header"); instance.noAppn = cl.hasOption("no-appn"); instance.isSecondaryCapture = cl.hasOption("sc"); instance.sampleMetadataResourceURL = cl.hasOption("sc") ? "resource:secondaryCaptureImageMetadata.xml" : cl.hasOption("xc") ? "resource:vlPhotographicImageMetadata.xml" : cl.hasOption("pdf") ? "resource:encapsulatedPDFMetadata.xml" : cl.hasOption("cda") ? "resource:encapsulatedCDAMetadata.xml" : null; }
protected boolean handleCommonOption(final GfxdOption opt, final String cmd, final String cmdDescKey) throws ParseException { if (SYSTEM_PROPERTY.equals(opt.getOpt())) { String optValue = opt.getValue(); int indexOfEquals = optValue.indexOf('='); if (indexOfEquals >= 0) { System.setProperty(optValue.substring(0, indexOfEquals), optValue.substring(indexOfEquals + 1)); } else { throw new MissingArgumentException(opt); } } else if (HELP.equals(opt.getOpt())) { showUsage(null, cmd, cmdDescKey); throw new GemFireTerminateError(null, 0); } else { return false; } return true; }
@Override public int execute(final String fullCommand, final CommandLine cl, final Shell shellState) throws Exception { final String tableName = OptUtil.getTableOpt(cl, shellState); final boolean decode = cl.hasOption(base64Opt.getOpt()); final TreeSet<Text> splits = new TreeSet<>(); if (cl.hasOption(optSplitsFile.getOpt())) { splits.addAll(ShellUtil.scanFile(cl.getOptionValue(optSplitsFile.getOpt()), decode)); } else { if (cl.getArgList().isEmpty()) { throw new MissingArgumentException("No split points specified"); } for (String s : cl.getArgs()) { splits.add(new Text(s.getBytes(Shell.CHARSET))); } } if (!shellState.getConnector().tableOperations().exists(tableName)) { throw new TableNotFoundException(null, tableName, null); } shellState.getConnector().tableOperations().addSplits(tableName, splits); return 0; }
@Override protected ArtifactoryServer run() throws Exception { String artifactoryUrl = step.getUrl(); if (StringUtils.isEmpty(artifactoryUrl)) { getContext().onFailure(new MissingArgumentException("Artifactory server URL is mandatory")); } if (!StringUtils.isEmpty(step.getCredentialsId())) { return new ArtifactoryServer(artifactoryUrl, step.getCredentialsId()); } return new ArtifactoryServer(artifactoryUrl, step.getUsername(), step.getPassword()); } }
@Override protected Boolean run() throws Exception { DistributionConfig distributionConfig = step.getDistributionConfig(); if (StringUtils.isEmpty(distributionConfig.getBuildName())) { getContext().onFailure(new MissingArgumentException("Distribution build name is mandatory")); return false; } if (StringUtils.isEmpty(distributionConfig.getBuildNumber())) { getContext().onFailure(new MissingArgumentException("Distribution build number is mandatory")); return false; } if (StringUtils.isEmpty(distributionConfig.getTargetRepo())) { getContext().onFailure(new MissingArgumentException("Distribution target repository is mandatory")); return false; } new DistributionExecutor(Utils.prepareArtifactoryServer(null, step.getServer()), build, listener, getContext(), distributionConfig).execute(); return true; } }
@Override protected Boolean run() throws Exception { PromotionConfig promotionConfig = step.getPromotionConfig(); if (StringUtils.isEmpty(promotionConfig.getBuildName())) { getContext().onFailure(new MissingArgumentException("Promotion build name is mandatory")); return false; } if (StringUtils.isEmpty(promotionConfig.getBuildNumber())) { getContext().onFailure(new MissingArgumentException("Promotion build number is mandatory")); return false; } if (StringUtils.isEmpty(promotionConfig.getTargetRepo())) { getContext().onFailure(new MissingArgumentException("Promotion target repository is mandatory")); return false; } new PromotionExecutor(Utils.prepareArtifactoryServer(null, step.getServer()), build, listener, getContext(), promotionConfig).execute(); return true; } }
public static IDWithIssuer toIDWithIssuer(String optionValue) throws MissingArgumentException { String[] components = optionValue.split(":"); if (components.length < 2) throw new MissingArgumentException("Missing issuer information"); if (components.length == 2) // pid and local entity uid return new IDWithIssuer(components[0], components[1]); else if (components.length == 3) // pid with universal entity and type return new IDWithIssuer(components[0], new Issuer(null, components[1], components[2])); else return new IDWithIssuer(components[0], new Issuer(components[1], components[2], components[3])); }
@Override protected BuildInfo run() throws Exception { if (step.getImage() == null) { getContext().onFailure(new MissingArgumentException("Missing 'image' parameter")); return null; } BuildInfo buildInfo = Utils.prepareBuildinfo(build, step.getBuildInfo()); String imageTag = step.getImage(); if (!DockerUtils.isImageVersioned(imageTag)) { imageTag += ":latest"; } ArtifactoryServer server = step.getServer(); String username = server.createCredentialsConfig().provideUsername(build.getParent()); String password = server.createCredentialsConfig().providePassword(build.getParent()); DockerAgentUtils.pullImage(launcher, imageTag, username, password, step.getHost()); JenkinsBuildInfoLog log = new JenkinsBuildInfoLog(listener); log.info("Successfully pulled docker image: " + imageTag); return buildInfo; } }