/** * Retrieves the argument as a String object, if any, of an option. * * @param option the option that we want argument value to be returned for * @param defaultValue is the default value to be returned if the option is not specified * * @return Value of the argument if option is set, and has an argument, otherwise defaultValue. */ public String getStringValue(Option option, String defaultValue) { String answer = getStringValue(option); return (answer != null) ? answer : defaultValue; }
if (useSsl && (StringUtils.isBlank(argParser.getStringValue(usernameOpt)) || StringUtils.isBlank(argParser.getStringValue(passwordOpt))))
/** * Retrieves the argument as a String object, if any, of an option. * * @param option the option that we want argument value to be returned for * @param defaultValue is the default value to be returned if the option is not specified * * @return Value of the argument if option is set, and has an argument, otherwise defaultValue. */ public String getStringValue(Option option, String defaultValue) { String answer = getStringValue(option); return (answer != null) ? answer : defaultValue; }
if (useSsl && (StringUtils.isBlank(argParser.getStringValue(usernameOpt)) || StringUtils.isBlank(argParser.getStringValue(passwordOpt)))) if (StringUtils.isNotBlank(argParser.getStringValue(s3SecretKeyOpt)) && StringUtils.isBlank(argParser.getStringValue(s3AccessKeyOpt))) if (StringUtils.isNotBlank(argParser.getStringValue(s3AccessKeyOpt)) && StringUtils.isBlank(argParser.getStringValue(s3SecretKeyOpt))) regServerHost = argParser.getStringValue(regServerHostOpt); if (StringUtils.isBlank(regServerHost)) regServerHost = argParser.getStringValue(dmRegServerHostOpt); if (StringUtils.isBlank(regServerHost)) if (StringUtils.isNotBlank(argParser.getStringValue(dmRegServerHostOpt)))
/** * Retrieves the argument as a File object, if any, of an option. * * @param option the option that we want argument value to be returned for * * @return Value of the argument if option is set, and has an argument, otherwise defaultValue. */ public File getFileValue(Option option) { String value = getStringValue(option); return (value != null) ? new File(value) : null; }
if (useSsl && (StringUtils.isBlank(argParser.getStringValue(usernameOpt)) || StringUtils.isBlank(argParser.getStringValue(passwordOpt)))) if (StringUtils.isNotBlank(argParser.getStringValue(s3SecretKeyOpt)) && StringUtils.isBlank(argParser.getStringValue(s3AccessKeyOpt))) if (StringUtils.isNotBlank(argParser.getStringValue(s3AccessKeyOpt)) && StringUtils.isBlank(argParser.getStringValue(s3SecretKeyOpt))) regServerHost = argParser.getStringValue(regServerHostOpt); if (StringUtils.isBlank(regServerHost)) regServerHost = argParser.getStringValue(dmRegServerHostOpt); if (StringUtils.isBlank(regServerHost)) if (StringUtils.isNotBlank(argParser.getStringValue(dmRegServerHostOpt)))
/** * Retrieves the argument as an Integer object, if any, of an option. * * @param option the option that we want argument value to be returned for * * @return Value of the argument if option is set, and has an argument, otherwise defaultValue. * @throws NumberFormatException if there are problems parsing the option value into the Integer type */ public Integer getIntegerValue(Option option) throws NumberFormatException { String value = getStringValue(option); return (value != null) ? Integer.parseInt(value) : null; }
if (useSsl && (StringUtils.isBlank(argParser.getStringValue(usernameOpt)) || StringUtils.isBlank(argParser.getStringValue(passwordOpt))))
/** * Retrieves the argument as a File object, if any, of an option. * * @param option the option that we want argument value to be returned for * * @return Value of the argument if option is set, and has an argument, otherwise defaultValue. */ public File getFileValue(Option option) { String value = getStringValue(option); return (value != null) ? new File(value) : null; }
/** * Retrieves the argument as an Integer object, if any, of an option. * * @param option the option that we want argument value to be returned for * * @return Value of the argument if option is set, and has an argument, otherwise defaultValue. * @throws NumberFormatException if there are problems parsing the option value into the Integer type */ public Integer getIntegerValue(Option option) throws NumberFormatException { String value = getStringValue(option); return (value != null) ? Integer.parseInt(value) : null; }
RegServerAccessParamsDto.builder().withRegServerHost(argParser.getStringValue(regServerHostOpt)).withRegServerPort(regServerPort).withUseSsl(useSsl) .withUsername(argParser.getStringValue(usernameOpt)).withPassword(argParser.getStringValue(passwordOpt)) .withTrustSelfSignedCertificate(trustSelfSignedCertificate).withDisableHostnameVerification(disableHostnameVerification).build(); controller.performRetentionExpirationExport(argParser.getStringValue(namespaceOpt), argParser.getStringValue(businessObjectDefinitionNameOpt), argParser.getFileValue(localOutputFileOpt), regServerAccessParamsDto, argParser.getStringValue(udcServerHostOpt));
String stringValue = getStringValue(option);
String stringValue = getStringValue(option);
S3FileTransferRequestParamsDto params = S3FileTransferRequestParamsDto.builder().withLocalPath(argParser.getStringValue(localPathOpt)) .withAwsAccessKeyId(argParser.getStringValue(s3AccessKeyOpt)).withAwsSecretKey(argParser.getStringValue(s3SecretKeyOpt)) .withS3Endpoint(argParser.getStringValue(s3EndpointOpt)).withMaxThreads(maxThreads).withHttpProxyHost(argParser.getStringValue(httpProxyHostOpt)) .withHttpProxyPort(httpProxyPort).withSocketTimeout(argParser.getIntegerValue(socketTimeoutOpt)).build(); RegServerAccessParamsDto regServerAccessParamsDto = RegServerAccessParamsDto.builder().withRegServerHost(regServerHost).withRegServerPort(regServerPort).withUseSsl(useSsl) .withUsername(argParser.getStringValue(usernameOpt)).withPassword(argParser.getStringValue(passwordOpt)) .withTrustSelfSignedCertificate(trustSelfSignedCertificate).withDisableHostnameVerification(disableHostnameVerification).build(); controller.performDownload(regServerAccessParamsDto, argParser.getFileValue(manifestPathOpt), params);
S3FileTransferRequestParamsDto.builder().withLocalPath(argParser.getStringValue(localPathOpt)).withUseRrs(argParser.getBooleanValue(rrsOpt)) .withAwsAccessKeyId(argParser.getStringValue(s3AccessKeyOpt)).withAwsSecretKey(argParser.getStringValue(s3SecretKeyOpt)) .withS3Endpoint(argParser.getStringValue(s3EndpointOpt)).withMaxThreads(maxThreads) .withHttpProxyHost(argParser.getStringValue(httpProxyHostOpt)).withHttpProxyPort(httpProxyPort) .withSocketTimeout(argParser.getIntegerValue(socketTimeoutOpt)).build(); RegServerAccessParamsDto regServerAccessParamsDto = RegServerAccessParamsDto.builder().withRegServerHost(regServerHost).withRegServerPort(regServerPort).withUseSsl(useSsl) .withUsername(argParser.getStringValue(usernameOpt)).withPassword(argParser.getStringValue(passwordOpt)) .withTrustSelfSignedCertificate(trustSelfSignedCertificate).withDisableHostnameVerification(disableHostnameVerification).build(); controller.performUpload(regServerAccessParamsDto, argParser.getFileValue(manifestPathOpt), params, argParser.getBooleanValue(createNewVersionOpt),
/** * Runs the application by parsing the command line arguments and calling the controller to export business object data that passed its relative retention * expiration. This is the main entry into the application class itself and is typically called from a main method. * * @param args the command line arguments passed to the program * * @return the return value of the application * @throws Exception if any problems were encountered */ protected ToolsCommonConstants.ReturnValue go(String[] args) throws Exception { // Create the Spring application context. ApplicationContext applicationContext = createApplicationContext(); // Parse the command line arguments and return a return value if we shouldn't continue processing (e.g. we displayed usage information, etc.). ToolsCommonConstants.ReturnValue returnValue = parseCommandLineArguments(args, applicationContext); if (returnValue != null) { return returnValue; } // Create a DTO to communicate with herd registration server. RegServerAccessParamsDto regServerAccessParamsDto = RegServerAccessParamsDto.builder().withRegServerHost(argParser.getStringValue(regServerHostOpt)).withRegServerPort(regServerPort).withUseSsl(useSsl) .withUsername(argParser.getStringValue(usernameOpt)).withPassword(argParser.getStringValue(passwordOpt)) .withTrustSelfSignedCertificate(trustSelfSignedCertificate).withDisableHostnameVerification(disableHostnameVerification).build(); // Call the controller with the user specified parameters to perform the upload. RetentionExpirationDestroyerController controller = applicationContext.getBean(RetentionExpirationDestroyerController.class); controller.performRetentionExpirationDestruction(argParser.getFileValue(localInputFileOpt), regServerAccessParamsDto); // No exceptions were returned so return success. return ToolsCommonConstants.ReturnValue.SUCCESS; }
@Test public void testGetStringValue() throws ParseException { final String testDefaultValue = "default_str_value"; ArgumentParser argParser = new ArgumentParser(""); Option strOpt = argParser.addArgument("s", "str", true, "Some string input parameter", false); String inputValue; String resultValue; final String shortStrOpt = String.format("-%s", strOpt.getOpt()); final String longStrOpt = String.format("--%s", strOpt.getLongOpt()); argParser.parseArguments(new String[] {}); assertNull(argParser.getStringValue(strOpt)); assertEquals(testDefaultValue, argParser.getStringValue(strOpt, testDefaultValue)); inputValue = "my_string_value_1"; argParser.parseArguments(new String[] {shortStrOpt, inputValue}); resultValue = argParser.getStringValue(strOpt); assertNotNull(resultValue); assertEquals(inputValue, resultValue); inputValue = "my_string_value_2"; argParser.parseArguments(new String[] {shortStrOpt, inputValue}); resultValue = argParser.getStringValue(strOpt, testDefaultValue); assertNotNull(resultValue); assertEquals(inputValue, resultValue); inputValue = "my_string_value_3"; argParser.parseArguments(new String[] {longStrOpt, inputValue}); resultValue = argParser.getStringValue(strOpt); assertNotNull(resultValue); assertEquals(inputValue, resultValue); }