use of org.finra.herd.model.api.xml.BusinessObjectDataVersions in project herd by FINRAOS.
the class UploaderWebClient method getBusinessObjectDataVersions.
/**
* Retrieves all versions for the specified business object data key.
*
* @param businessObjectDataKey the business object data key
*
* @return {@link org.finra.herd.model.api.xml.BusinessObjectDataVersions}
* @throws URISyntaxException When error occurs while URI creation
* @throws IOException When error occurs communicating with server
* @throws JAXBException When error occurs parsing the XML
*/
public BusinessObjectDataVersions getBusinessObjectDataVersions(BusinessObjectDataKey businessObjectDataKey) throws URISyntaxException, IOException, JAXBException {
LOGGER.info("Retrieving business object data versions from the registration server...");
BusinessObjectDataVersions businessObjectDataVersions;
try (CloseableHttpClient client = httpClientOperations.createHttpClient()) {
StringBuilder uriPathBuilder = new StringBuilder(300);
uriPathBuilder.append(HERD_APP_REST_URI_PREFIX);
uriPathBuilder.append("/businessObjectData/namespaces/").append(businessObjectDataKey.getNamespace());
uriPathBuilder.append("/businessObjectDefinitionNames/").append(businessObjectDataKey.getBusinessObjectDefinitionName());
uriPathBuilder.append("/businessObjectFormatUsages/").append(businessObjectDataKey.getBusinessObjectFormatUsage());
uriPathBuilder.append("/businessObjectFormatFileTypes/").append(businessObjectDataKey.getBusinessObjectFormatFileType());
uriPathBuilder.append("/versions");
URIBuilder uriBuilder = new URIBuilder().setScheme(getUriScheme()).setHost(regServerAccessParamsDto.getRegServerHost()).setPort(regServerAccessParamsDto.getRegServerPort()).setPath(uriPathBuilder.toString()).setParameter("partitionValue", businessObjectDataKey.getPartitionValue());
if (businessObjectDataKey.getSubPartitionValues() != null) {
uriBuilder.setParameter("subPartitionValues", herdStringHelper.join(businessObjectDataKey.getSubPartitionValues(), "|", "\\"));
}
if (businessObjectDataKey.getBusinessObjectFormatVersion() != null) {
uriBuilder.setParameter("businessObjectFormatVersion", businessObjectDataKey.getBusinessObjectFormatVersion().toString());
}
if (businessObjectDataKey.getBusinessObjectDataVersion() != null) {
uriBuilder.setParameter("businessObjectDataVersion", businessObjectDataKey.getBusinessObjectDataVersion().toString());
}
HttpGet httpGet = new HttpGet(uriBuilder.build());
httpGet.addHeader("Accepts", DEFAULT_ACCEPT);
// If SSL is enabled, set the client authentication header.
if (regServerAccessParamsDto.isUseSsl()) {
httpGet.addHeader(getAuthorizationHeader());
}
LOGGER.info(String.format(" HTTP GET URI: %s", httpGet.getURI().toString()));
LOGGER.info(String.format(" HTTP GET Headers: %s", Arrays.toString(httpGet.getAllHeaders())));
businessObjectDataVersions = getBusinessObjectDataVersions(httpClientOperations.execute(client, httpGet));
}
LOGGER.info(String.format("Successfully retrieved %d already registered version(s) for the business object data. businessObjectDataKey=%s", businessObjectDataVersions.getBusinessObjectDataVersions().size(), jsonHelper.objectToJson(businessObjectDataKey)));
return businessObjectDataVersions;
}
use of org.finra.herd.model.api.xml.BusinessObjectDataVersions in project herd by FINRAOS.
the class UploaderWebClientTest method testGetBusinessObjectDataVersions.
/**
* Calls getBusinessObjectDataVersions() method and makes assertions.
*
* @param subPartitionValues the list of sub-partition values
* @param businessObjectFormatVersion the business object format version
* @param businessObjectDataVersion the business object data version
* @param useSsl specifies whether to use SSL or not
*
* @throws java.io.IOException
* @throws javax.xml.bind.JAXBException
* @throws java.net.URISyntaxException
*/
private void testGetBusinessObjectDataVersions(List<String> subPartitionValues, Integer businessObjectFormatVersion, Integer businessObjectDataVersion, boolean useSsl) throws IOException, JAXBException, URISyntaxException {
uploaderWebClient.getRegServerAccessParamsDto().setUseSsl(useSsl);
BusinessObjectDataKey businessObjectDataKey = new BusinessObjectDataKey();
businessObjectDataKey.setBusinessObjectFormatVersion(businessObjectFormatVersion);
businessObjectDataKey.setSubPartitionValues(subPartitionValues);
businessObjectDataKey.setBusinessObjectDataVersion(businessObjectDataVersion);
BusinessObjectDataVersions businessObjectDataVersions = uploaderWebClient.getBusinessObjectDataVersions(businessObjectDataKey);
assertNotNull("businessObjectDataVersions", businessObjectDataVersions);
}
use of org.finra.herd.model.api.xml.BusinessObjectDataVersions in project herd by FINRAOS.
the class BusinessObjectDataServiceGetBusinessObjectDataVersionsTest method testGetBusinessObjectDataMissingDataVersionParameter.
@Test
public void testGetBusinessObjectDataMissingDataVersionParameter() {
// Create and persist a business object data entities.
createTestDatabaseEntities(SUBPARTITION_VALUES);
// Retrieve business object data versions without specifying business object data version.
BusinessObjectDataVersions resultBusinessObjectDataVersions = businessObjectDataService.getBusinessObjectDataVersions(new BusinessObjectDataKey(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, INITIAL_FORMAT_VERSION, PARTITION_VALUE, SUBPARTITION_VALUES, null));
// Validate the returned object.
assertNotNull(resultBusinessObjectDataVersions);
assertEquals(NUMBER_OF_DATA_VERSIONS_PER_FORMAT_VERSION, resultBusinessObjectDataVersions.getBusinessObjectDataVersions().size());
}
use of org.finra.herd.model.api.xml.BusinessObjectDataVersions in project herd by FINRAOS.
the class BusinessObjectDataServiceGetBusinessObjectDataVersionsTest method testGetBusinessObjectDataMissingFormatVersionParameter.
@Test
public void testGetBusinessObjectDataMissingFormatVersionParameter() {
// Create and persist a business object data entities.
createTestDatabaseEntities(SUBPARTITION_VALUES);
// Retrieve business object data versions without specifying business object format version.
BusinessObjectDataVersions resultBusinessObjectDataVersions = businessObjectDataService.getBusinessObjectDataVersions(new BusinessObjectDataKey(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, null, PARTITION_VALUE, SUBPARTITION_VALUES, INITIAL_DATA_VERSION));
// Validate the returned object.
assertNotNull(resultBusinessObjectDataVersions);
assertEquals(NUMBER_OF_FORMAT_VERSIONS, resultBusinessObjectDataVersions.getBusinessObjectDataVersions().size());
}
use of org.finra.herd.model.api.xml.BusinessObjectDataVersions in project herd by FINRAOS.
the class BusinessObjectDataServiceGetBusinessObjectDataVersionsTest method testGetBusinessObjectDataLowerCaseParameters.
@Test
public void testGetBusinessObjectDataLowerCaseParameters() {
// Create and persist test database entities.
createTestDatabaseEntities(SUBPARTITION_VALUES);
// Retrieve business object data versions using lower case input parameters (except for case-sensitive partition values).
BusinessObjectDataVersions resultBusinessObjectDataVersions = businessObjectDataService.getBusinessObjectDataVersions(new BusinessObjectDataKey(NAMESPACE.toLowerCase(), BDEF_NAME.toLowerCase(), FORMAT_USAGE_CODE.toLowerCase(), FORMAT_FILE_TYPE_CODE.toLowerCase(), INITIAL_FORMAT_VERSION, PARTITION_VALUE, SUBPARTITION_VALUES, INITIAL_DATA_VERSION));
// Validate the returned object.
assertNotNull(resultBusinessObjectDataVersions);
assertEquals(1, resultBusinessObjectDataVersions.getBusinessObjectDataVersions().size());
}
Aggregations