Search in sources :

Example 6 with BusinessObjectDataVersions

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;
}
Also used : CloseableHttpClient(org.apache.http.impl.client.CloseableHttpClient) HttpGet(org.apache.http.client.methods.HttpGet) BusinessObjectDataVersions(org.finra.herd.model.api.xml.BusinessObjectDataVersions) URIBuilder(org.apache.http.client.utils.URIBuilder)

Example 7 with 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);
}
Also used : BusinessObjectDataVersions(org.finra.herd.model.api.xml.BusinessObjectDataVersions) BusinessObjectDataKey(org.finra.herd.model.api.xml.BusinessObjectDataKey)

Example 8 with 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());
}
Also used : BusinessObjectDataVersions(org.finra.herd.model.api.xml.BusinessObjectDataVersions) BusinessObjectDataKey(org.finra.herd.model.api.xml.BusinessObjectDataKey) Test(org.junit.Test)

Example 9 with BusinessObjectDataVersions

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());
}
Also used : BusinessObjectDataVersions(org.finra.herd.model.api.xml.BusinessObjectDataVersions) BusinessObjectDataKey(org.finra.herd.model.api.xml.BusinessObjectDataKey) Test(org.junit.Test)

Example 10 with BusinessObjectDataVersions

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());
}
Also used : BusinessObjectDataVersions(org.finra.herd.model.api.xml.BusinessObjectDataVersions) BusinessObjectDataKey(org.finra.herd.model.api.xml.BusinessObjectDataKey) Test(org.junit.Test)

Aggregations

BusinessObjectDataVersions (org.finra.herd.model.api.xml.BusinessObjectDataVersions)13 BusinessObjectDataKey (org.finra.herd.model.api.xml.BusinessObjectDataKey)12 Test (org.junit.Test)9 BusinessObjectDataVersion (org.finra.herd.model.api.xml.BusinessObjectDataVersion)3 ArrayList (java.util.ArrayList)1 Matcher (java.util.regex.Matcher)1 Pattern (java.util.regex.Pattern)1 HttpGet (org.apache.http.client.methods.HttpGet)1 URIBuilder (org.apache.http.client.utils.URIBuilder)1 CloseableHttpClient (org.apache.http.impl.client.CloseableHttpClient)1 NamespacePermission (org.finra.herd.model.annotation.NamespacePermission)1 BusinessObjectDataEntity (org.finra.herd.model.jpa.BusinessObjectDataEntity)1