use of org.finra.herd.model.dto.RegServerAccessParamsDto in project herd by FINRAOS.
the class RetentionExpirationDestroyerApp method go.
/**
* 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)).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;
}
use of org.finra.herd.model.dto.RegServerAccessParamsDto in project herd by FINRAOS.
the class RetentionExpirationExporterControllerTest method testPerformRetentionExpirationExport.
@Test
public void testPerformRetentionExpirationExport() throws Exception {
File outputFile = new File(LOCAL_OUTPUT_FILE);
// Create and initialize the registration server DTO.
RegServerAccessParamsDto regServerAccessParamsDto = RegServerAccessParamsDto.builder().withRegServerHost(WEB_SERVICE_HOSTNAME).withRegServerPort(WEB_SERVICE_HTTPS_PORT).withUseSsl(true).withUsername(WEB_SERVICE_HTTPS_USERNAME).withPassword(WEB_SERVICE_HTTPS_PASSWORD).build();
// Perform the retention expiration export.
retentionExpirationExporterController.performRetentionExpirationExport(NAMESPACE, BUSINESS_OBJECT_DEFINITION_NAME, outputFile, regServerAccessParamsDto, UDC_SERVICE_HOSTNAME);
// Create the expected URI.
String expectedUri = String.format("https://%s/data-entities/%s/%s", UDC_SERVICE_HOSTNAME, NAMESPACE, BUSINESS_OBJECT_DEFINITION_NAME);
// Create the expected output file content.
String expectedOutputFileContent = ("\"Namespace\",\"Business Object Definition Name\",\"Business Object Format Usage\",\"Business Object Format File Type\"," + "\"Business Object Format Version\",\"Primary Partition Value\",\"Sub-Partition Value 1\",\"Sub-Partition Value 2\"," + "\"Sub-Partition Value 3\",\"Sub-Partition Value 4\",\"Business Object Data Version\",\"Business Object Definition Display Name\"," + "\"Business Object Definition URI\"") + System.lineSeparator() + String.format("\"%s\",\"%s\",\"%s\",\"%s\",\"%d\",\"%s\",\"%s\",\"%s\",\"%s\",\"%s\",\"%d\",\"%s\",\"%s\"%n", NAMESPACE, BUSINESS_OBJECT_DEFINITION_NAME, BUSINESS_OBJECT_FORMAT_USAGE, BUSINESS_OBJECT_FORMAT_FILE_TYPE, BUSINESS_OBJECT_FORMAT_VERSION, "primaryPartitionValue", "subPartitionValue1", "subPartitionValue2", "subPartitionValue3", "subPartitionValue4", BUSINESS_OBJECT_DATA_VERSION, BUSINESS_OBJECT_DEFINITION_DISPLAY_NAME, expectedUri) + String.format("\"%s\",\"%s\",\"%s\",\"%s\",\"%d\",\"%s\",\"%s\",\"%s\",\"%s\",\"%s\",\"%d\",\"%s\",\"%s\"%n", NAMESPACE, BUSINESS_OBJECT_DEFINITION_NAME, BUSINESS_OBJECT_FORMAT_USAGE, BUSINESS_OBJECT_FORMAT_FILE_TYPE, BUSINESS_OBJECT_FORMAT_VERSION, "primaryPartitionValue", "", "", "", "", BUSINESS_OBJECT_DATA_VERSION, BUSINESS_OBJECT_DEFINITION_DISPLAY_NAME, expectedUri);
// Validate the output file.
String outputFileContent;
try (FileInputStream inputStream = new FileInputStream(outputFile)) {
outputFileContent = IOUtils.toString(inputStream, Charset.defaultCharset());
}
assertEquals(expectedOutputFileContent, outputFileContent);
}
use of org.finra.herd.model.dto.RegServerAccessParamsDto in project herd by FINRAOS.
the class UploaderControllerTest method testPerformUploadInvalidLocalDir.
@Test
public void testPerformUploadInvalidLocalDir() throws Exception {
// Create uploader input manifest file in LOCAL_TEMP_PATH_INPUT directory
File manifestFile = createManifestFile(LOCAL_TEMP_PATH_INPUT.toString(), getTestUploaderInputManifestDto());
Assert.assertTrue(manifestFile.isFile());
// Try to run upload by specifying a non-existing local directory.
S3FileTransferRequestParamsDto s3FileTransferRequestParamsDto = getTestS3FileTransferRequestParamsDto();
s3FileTransferRequestParamsDto.setLocalPath(Paths.get(LOCAL_TEMP_PATH_INPUT.toString(), "I_DO_NOT_EXIST").toString());
RegServerAccessParamsDto regServerAccessParamsDto = RegServerAccessParamsDto.builder().withRegServerHost(WEB_SERVICE_HOSTNAME).withRegServerPort(WEB_SERVICE_HTTPS_PORT).withUseSsl(true).withUsername(WEB_SERVICE_HTTPS_USERNAME).withPassword(WEB_SERVICE_HTTPS_PASSWORD).build();
try {
uploaderController.performUpload(regServerAccessParamsDto, manifestFile, s3FileTransferRequestParamsDto, false, false, TEST_RETRY_ATTEMPTS, TEST_RETRY_DELAY_SECS);
fail("Should throw an IllegalArgumentException when local directory does not exist.");
} catch (IllegalArgumentException e) {
assertTrue(e.getMessage().startsWith("Invalid local base directory"));
}
}
use of org.finra.herd.model.dto.RegServerAccessParamsDto in project herd by FINRAOS.
the class UploaderControllerTest method runUpload.
/**
* Runs a normal upload scenario.
*
* @param numOfThreads the maximum number of threads to use for file transfer to S3
* @param attributes the attributes to be associated with the test data being uploaded
* @param createNewVersion if not set, only initial version of the business object data is allowed to be created
* @param force if set, allows upload to proceed when the latest version of the business object data has UPLOADING status by invalidating that version
* @param hostname optional override of the default web service hostname.
* @param storageName optional storage name
*/
protected void runUpload(Integer numOfThreads, HashMap<String, String> attributes, Boolean createNewVersion, Boolean force, String hostname, String storageName) throws Exception {
String hostnameToUse = hostname == null ? WEB_SERVICE_HOSTNAME : hostname;
// Create local data files in LOCAL_TEMP_PATH_INPUT directory
for (ManifestFile manifestFile : testManifestFiles) {
createLocalFile(LOCAL_TEMP_PATH_INPUT.toString(), manifestFile.getFileName(), FILE_SIZE_1_KB);
}
// Create uploader input manifest file in LOCAL_TEMP_PATH_INPUT directory
UploaderInputManifestDto uploaderInputManifestDto = getTestUploaderInputManifestDto();
uploaderInputManifestDto.setAttributes(attributes);
uploaderInputManifestDto.setStorageName(storageName);
File manifestFile = createManifestFile(LOCAL_TEMP_PATH_INPUT.toString(), uploaderInputManifestDto);
Assert.assertTrue(manifestFile.isFile());
// Perform the upload.
S3FileTransferRequestParamsDto s3FileTransferRequestParamsDto = getTestS3FileTransferRequestParamsDto();
s3FileTransferRequestParamsDto.setLocalPath(LOCAL_TEMP_PATH_INPUT.toString());
s3FileTransferRequestParamsDto.setMaxThreads(numOfThreads);
RegServerAccessParamsDto regServerAccessParamsDto = RegServerAccessParamsDto.builder().withRegServerHost(hostnameToUse).withRegServerPort(WEB_SERVICE_HTTPS_PORT).withUseSsl(true).withUsername(WEB_SERVICE_HTTPS_USERNAME).withPassword(WEB_SERVICE_HTTPS_PASSWORD).build();
uploaderController.performUpload(regServerAccessParamsDto, manifestFile, s3FileTransferRequestParamsDto, createNewVersion, force, TEST_RETRY_ATTEMPTS, TEST_RETRY_DELAY_SECS);
}
use of org.finra.herd.model.dto.RegServerAccessParamsDto in project herd by FINRAOS.
the class AbstractUploaderTest method setupEnv.
/**
* Sets up the test environment.
*/
@Before
public void setupEnv() throws IOException {
super.setupEnv();
// Initialize the uploader web client instance.
RegServerAccessParamsDto regServerAccessParamsDto = RegServerAccessParamsDto.builder().withRegServerHost(WEB_SERVICE_HOSTNAME).withRegServerPort(WEB_SERVICE_HTTPS_PORT).withUseSsl(true).withUsername(WEB_SERVICE_HTTPS_USERNAME).withPassword(WEB_SERVICE_HTTPS_PASSWORD).build();
uploaderWebClient.setRegServerAccessParamsDto(regServerAccessParamsDto);
}
Aggregations