use of org.finra.herd.model.api.xml.BusinessObjectDefinition in project herd by FINRAOS.
the class RetentionExpirationExporterWebClient method getBusinessObjectDefinition.
/**
* Retrieves business object definition from the herd registration server.
*
* @param namespace the namespace of the business object definition
* @param businessObjectDefinitionName the name of the business object definition
*
* @return the business object definition
* @throws JAXBException if a JAXB error was encountered
* @throws IOException if an I/O error was encountered
* @throws URISyntaxException if a URI syntax error was encountered
*/
BusinessObjectDefinition getBusinessObjectDefinition(String namespace, String businessObjectDefinitionName) throws IOException, JAXBException, URISyntaxException {
LOGGER.info("Retrieving business object definition information from the registration server...");
String uriPathBuilder = HERD_APP_REST_URI_PREFIX + "/businessObjectDefinitions" + "/namespaces/" + namespace + "/businessObjectDefinitionNames/" + businessObjectDefinitionName;
URIBuilder uriBuilder = new URIBuilder().setScheme(getUriScheme()).setHost(regServerAccessParamsDto.getRegServerHost()).setPort(regServerAccessParamsDto.getRegServerPort()).setPath(uriPathBuilder);
URI uri = uriBuilder.build();
try (CloseableHttpClient client = httpClientOperations.createHttpClient()) {
HttpGet request = new HttpGet(uri);
request.addHeader("Accepts", DEFAULT_ACCEPT);
// If SSL is enabled, set the client authentication header.
if (regServerAccessParamsDto.isUseSsl()) {
request.addHeader(getAuthorizationHeader());
}
LOGGER.info(String.format(" HTTP GET URI: %s", request.getURI().toString()));
LOGGER.info(String.format(" HTTP GET Headers: %s", Arrays.toString(request.getAllHeaders())));
BusinessObjectDefinition businessObjectDefinition = getBusinessObjectDefinition(httpClientOperations.execute(client, request));
LOGGER.info("Successfully retrieved business object definition from the registration server.");
return businessObjectDefinition;
}
}
use of org.finra.herd.model.api.xml.BusinessObjectDefinition in project herd by FINRAOS.
the class RetentionExpirationExporterWebClientTest method testGetBusinessObjectDefinitionUseSsl.
@Test
public void testGetBusinessObjectDefinitionUseSsl() throws Exception {
retentionExpirationExporterWebClient.getRegServerAccessParamsDto().setUseSsl(true);
BusinessObjectDefinition result = retentionExpirationExporterWebClient.getBusinessObjectDefinition(NAMESPACE, BUSINESS_OBJECT_DEFINITION_NAME);
assertNotNull(result);
}
use of org.finra.herd.model.api.xml.BusinessObjectDefinition in project herd by FINRAOS.
the class RetentionExpirationExporterWebClientTest method testGetBusinessObjectDefinition.
@Test
public void testGetBusinessObjectDefinition() throws Exception {
retentionExpirationExporterWebClient.getRegServerAccessParamsDto().setUseSsl(false);
BusinessObjectDefinition result = retentionExpirationExporterWebClient.getBusinessObjectDefinition(NAMESPACE, BUSINESS_OBJECT_DEFINITION_NAME);
assertNotNull(result);
}
use of org.finra.herd.model.api.xml.BusinessObjectDefinition in project herd by FINRAOS.
the class RetentionExpirationExporterController method performRetentionExpirationExport.
/**
* Executes the retention expiration exporter workflow.
*
* @param namespace the namespace of business object data
* @param businessObjectDefinitionName the business object definition name of business object data
* @param localOutputFile the local output file
* @param regServerAccessParamsDto the DTO for the parameters required to communicate with the registration server
* @param udcServerHost the hostname of the UDC application server
*
* @throws Exception if any problems were encountered
*/
void performRetentionExpirationExport(String namespace, String businessObjectDefinitionName, File localOutputFile, RegServerAccessParamsDto regServerAccessParamsDto, String udcServerHost) throws Exception {
// Fail if local output file already exists.
if (localOutputFile.exists()) {
throw new IllegalArgumentException(String.format("The specified local output file \"%s\" already exists.", localOutputFile.toString()));
}
// Initialize the web client.
retentionExpirationExporterWebClient.setRegServerAccessParamsDto(regServerAccessParamsDto);
// Validate that specified business object definition exists.
BusinessObjectDefinition businessObjectDefinition = retentionExpirationExporterWebClient.getBusinessObjectDefinition(namespace, businessObjectDefinitionName);
// Get business object display name.
String businessObjectDefinitionDisplayName = getBusinessObjectDefinitionDisplayName(businessObjectDefinition);
// Create a search request for business object data with the filter on retention expiration option.
BusinessObjectDataSearchKey businessObjectDataSearchKey = new BusinessObjectDataSearchKey();
businessObjectDataSearchKey.setNamespace(namespace);
businessObjectDataSearchKey.setBusinessObjectDefinitionName(businessObjectDefinitionName);
businessObjectDataSearchKey.setFilterOnRetentionExpiration(true);
List<BusinessObjectDataSearchKey> businessObjectDataSearchKeys = new ArrayList<>();
businessObjectDataSearchKeys.add(businessObjectDataSearchKey);
BusinessObjectDataSearchFilter businessObjectDataSearchFilter = new BusinessObjectDataSearchFilter(businessObjectDataSearchKeys);
BusinessObjectDataSearchRequest request = new BusinessObjectDataSearchRequest(Collections.singletonList(businessObjectDataSearchFilter));
// Create a result list for business object data.
List<BusinessObjectData> businessObjectDataList = new ArrayList<>();
// Fetch business object data from server until no records found.
int pageNumber = 1;
BusinessObjectDataSearchResult businessObjectDataSearchResult = retentionExpirationExporterWebClient.searchBusinessObjectData(request, pageNumber);
while (CollectionUtils.isNotEmpty(businessObjectDataSearchResult.getBusinessObjectDataElements())) {
LOGGER.info("Fetched {} business object data records from the registration server.", CollectionUtils.size(businessObjectDataSearchResult.getBusinessObjectDataElements()));
businessObjectDataList.addAll(businessObjectDataSearchResult.getBusinessObjectDataElements());
pageNumber++;
businessObjectDataSearchResult = retentionExpirationExporterWebClient.searchBusinessObjectData(request, pageNumber);
}
// Write business object data to the output CSV file.
writeToCsvFile(localOutputFile, businessObjectDefinition.getNamespace(), businessObjectDefinition.getBusinessObjectDefinitionName(), businessObjectDefinitionDisplayName, udcServerHost, businessObjectDataList);
}
use of org.finra.herd.model.api.xml.BusinessObjectDefinition in project herd by FINRAOS.
the class BusinessObjectDefinitionServiceImpl method createBusinessObjectDefinitionFromDto.
/**
* Creates a light-weight business object definition from a dto based on a set of requested fields.
*
* @param businessObjectDefinitionIndexSearchResponseDto the specified business object definition index search dto
* @param fields the set of requested fields
*
* @return the light-weight business object definition
*/
private BusinessObjectDefinition createBusinessObjectDefinitionFromDto(BusinessObjectDefinitionIndexSearchResponseDto businessObjectDefinitionIndexSearchResponseDto, Set<String> fields) {
BusinessObjectDefinition definition = new BusinessObjectDefinition();
// Populate namespace and business object definition name fields by default
definition.setNamespace(businessObjectDefinitionIndexSearchResponseDto.getNamespace().getCode());
definition.setBusinessObjectDefinitionName(businessObjectDefinitionIndexSearchResponseDto.getName());
// Decorate object with only the required fields
if (fields.contains(DATA_PROVIDER_NAME_FIELD)) {
definition.setDataProviderName(businessObjectDefinitionIndexSearchResponseDto.getDataProvider().getName());
}
if (fields.contains(SHORT_DESCRIPTION_FIELD)) {
// Get the configured value for short description's length
Integer shortDescMaxLength = configurationHelper.getProperty(ConfigurationValue.BUSINESS_OBJECT_DEFINITION_SHORT_DESCRIPTION_LENGTH, Integer.class);
definition.setShortDescription(HerdStringUtils.getShortDescription(businessObjectDefinitionIndexSearchResponseDto.getDescription(), shortDescMaxLength));
}
if (fields.contains(DISPLAY_NAME_FIELD)) {
definition.setDisplayName(businessObjectDefinitionIndexSearchResponseDto.getDisplayName());
}
return definition;
}
Aggregations