Search in sources :

Example 1 with BusinessObjectDataInvalidateUnregisteredResponse

use of org.finra.herd.model.api.xml.BusinessObjectDataInvalidateUnregisteredResponse in project herd by FINRAOS.

the class BusinessObjectDataInvalidateUnregisteredHelper method getBusinessObjectDataInvalidateUnregisteredResponse.

/**
 * Constructs the response from the given request and the list of objects that have been registered.
 *
 * @param request the original request
 * @param registeredBusinessObjectDataEntities list of {@link BusinessObjectDataEntity} that have been newly created.
 *
 * @return {@link BusinessObjectDataInvalidateUnregisteredResponse}
 */
private BusinessObjectDataInvalidateUnregisteredResponse getBusinessObjectDataInvalidateUnregisteredResponse(BusinessObjectDataInvalidateUnregisteredRequest request, List<BusinessObjectDataEntity> registeredBusinessObjectDataEntities) {
    BusinessObjectDataInvalidateUnregisteredResponse response = new BusinessObjectDataInvalidateUnregisteredResponse();
    response.setNamespace(request.getNamespace());
    response.setBusinessObjectDefinitionName(request.getBusinessObjectDefinitionName());
    response.setBusinessObjectFormatUsage(request.getBusinessObjectFormatUsage());
    response.setBusinessObjectFormatFileType(request.getBusinessObjectFormatFileType());
    response.setBusinessObjectFormatVersion(request.getBusinessObjectFormatVersion());
    response.setPartitionValue(request.getPartitionValue());
    response.setSubPartitionValues(request.getSubPartitionValues());
    response.setStorageName(request.getStorageName());
    response.setRegisteredBusinessObjectDataList(getResponseBusinessObjectDatas(registeredBusinessObjectDataEntities));
    return response;
}
Also used : BusinessObjectDataInvalidateUnregisteredResponse(org.finra.herd.model.api.xml.BusinessObjectDataInvalidateUnregisteredResponse)

Example 2 with BusinessObjectDataInvalidateUnregisteredResponse

use of org.finra.herd.model.api.xml.BusinessObjectDataInvalidateUnregisteredResponse in project herd by FINRAOS.

the class InvalidateUnregisteredBusinessObjectData method executeImpl.

@Override
public void executeImpl(DelegateExecution execution) throws Exception {
    String contentTypeString = activitiHelper.getRequiredExpressionVariableAsString(this.contentType, execution, "contentType");
    String businessObjectDataInvalidateUnregisteredRequestString = activitiHelper.getRequiredExpressionVariableAsString(this.businessObjectDataInvalidateUnregisteredRequest, execution, "businessObjectDataInvalidateUnregisteredRequest");
    BusinessObjectDataInvalidateUnregisteredRequest businessObjectDataInvalidateUnregisteredRequest = getRequestObject(contentTypeString, businessObjectDataInvalidateUnregisteredRequestString, BusinessObjectDataInvalidateUnregisteredRequest.class);
    BusinessObjectDataInvalidateUnregisteredResponse businessObjectDataInvalidateUnregisteredResponse = businessObjectDataService.invalidateUnregisteredBusinessObjectData(businessObjectDataInvalidateUnregisteredRequest);
    // Trigger notifications.
    businessObjectDataDaoHelper.triggerNotificationsForInvalidateUnregisteredBusinessObjectData(businessObjectDataInvalidateUnregisteredResponse);
    setJsonResponseAsWorkflowVariable(businessObjectDataInvalidateUnregisteredResponse, execution);
}
Also used : BusinessObjectDataInvalidateUnregisteredRequest(org.finra.herd.model.api.xml.BusinessObjectDataInvalidateUnregisteredRequest) BusinessObjectDataInvalidateUnregisteredResponse(org.finra.herd.model.api.xml.BusinessObjectDataInvalidateUnregisteredResponse)

Example 3 with BusinessObjectDataInvalidateUnregisteredResponse

use of org.finra.herd.model.api.xml.BusinessObjectDataInvalidateUnregisteredResponse in project herd by FINRAOS.

the class BusinessObjectDataRestController method invalidateUnregisteredBusinessObjectData.

/**
 * Registers data as INVALID for objects which exist in S3 but are not registered in herd. <p> Requires WRITE permission on namespace </p>
 *
 * @param businessObjectDataInvalidateUnregisteredRequest the business object data invalidate un-register request
 *
 * @return the business object data invalidate unregistered response
 */
@RequestMapping(value = "/businessObjectData/unregistered/invalidation", method = RequestMethod.POST, consumes = { "application/xml", "application/json" })
@Secured(SecurityFunctions.FN_BUSINESS_OBJECT_DATA_UNREGISTERED_INVALIDATE)
public BusinessObjectDataInvalidateUnregisteredResponse invalidateUnregisteredBusinessObjectData(@RequestBody BusinessObjectDataInvalidateUnregisteredRequest businessObjectDataInvalidateUnregisteredRequest) {
    BusinessObjectDataInvalidateUnregisteredResponse businessObjectDataInvalidateUnregisteredResponse = businessObjectDataService.invalidateUnregisteredBusinessObjectData(businessObjectDataInvalidateUnregisteredRequest);
    // Trigger notifications.
    businessObjectDataDaoHelper.triggerNotificationsForInvalidateUnregisteredBusinessObjectData(businessObjectDataInvalidateUnregisteredResponse);
    return businessObjectDataInvalidateUnregisteredResponse;
}
Also used : BusinessObjectDataInvalidateUnregisteredResponse(org.finra.herd.model.api.xml.BusinessObjectDataInvalidateUnregisteredResponse) Secured(org.springframework.security.access.annotation.Secured) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 4 with BusinessObjectDataInvalidateUnregisteredResponse

use of org.finra.herd.model.api.xml.BusinessObjectDataInvalidateUnregisteredResponse in project herd by FINRAOS.

the class BusinessObjectDataInvalidateUnregisteredHelperTest method testInvalidateUnregisteredBusinessObjectDataS31Herd0.

/**
 * Test case where S3 has 1 object, and herd has no object registered. Expects one new registration in INVALID status.
 */
@Test
public void testInvalidateUnregisteredBusinessObjectDataS31Herd0() throws Exception {
    BusinessObjectDataInvalidateUnregisteredRequest request = new BusinessObjectDataInvalidateUnregisteredRequest(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, PARTITION_VALUE, NO_SUBPARTITION_VALUES, StorageEntity.MANAGED_STORAGE);
    // Given a business object format
    // Given an object in S3
    BusinessObjectFormatEntity businessObjectFormatEntity;
    try {
        businessObjectFormatEntity = businessObjectFormatServiceTestHelper.createBusinessObjectFormat(request);
        businessObjectDataServiceTestHelper.createS3Object(businessObjectFormatEntity, request, 0);
    } catch (Exception e) {
        throw new IllegalArgumentException("Test failed during setup. Most likely setup or developer error.", e);
    }
    // Call API
    BusinessObjectDataInvalidateUnregisteredResponse actualResponse = businessObjectDataInvalidateUnregisteredHelper.invalidateUnregisteredBusinessObjectData(request);
    // Make assertions
    Assert.assertNotNull("response business object datas is null", actualResponse.getRegisteredBusinessObjectDataList());
    Assert.assertEquals("response business object datas size", 1, actualResponse.getRegisteredBusinessObjectDataList().size());
    {
        BusinessObjectData businessObjectData = actualResponse.getRegisteredBusinessObjectDataList().get(0);
        Assert.assertEquals("response business object data[0] version", 0, businessObjectData.getVersion());
        Assert.assertEquals("response business object data[0] status", BusinessObjectDataInvalidateUnregisteredHelper.UNREGISTERED_STATUS, businessObjectData.getStatus());
        Assert.assertNotNull("response business object data[0] storage units is null", businessObjectData.getStorageUnits());
        Assert.assertEquals("response business object data[0] storage units size", 1, businessObjectData.getStorageUnits().size());
        {
            String expectedS3KeyPrefix = s3KeyPrefixHelper.buildS3KeyPrefix(S3_KEY_PREFIX_VELOCITY_TEMPLATE, businessObjectFormatEntity, businessObjectDataHelper.createBusinessObjectDataKey(businessObjectData), STORAGE_NAME);
            StorageUnit storageUnit = businessObjectData.getStorageUnits().get(0);
            Assert.assertNotNull("response business object data[0] storage unit[0] storage directory is null", storageUnit.getStorageDirectory());
            Assert.assertEquals("response business object data[0] storage unit[0] storage directory path", expectedS3KeyPrefix, storageUnit.getStorageDirectory().getDirectoryPath());
        }
    }
}
Also used : BusinessObjectDataInvalidateUnregisteredRequest(org.finra.herd.model.api.xml.BusinessObjectDataInvalidateUnregisteredRequest) BusinessObjectData(org.finra.herd.model.api.xml.BusinessObjectData) StorageUnit(org.finra.herd.model.api.xml.StorageUnit) BusinessObjectFormatEntity(org.finra.herd.model.jpa.BusinessObjectFormatEntity) ObjectNotFoundException(org.finra.herd.model.ObjectNotFoundException) BusinessObjectDataInvalidateUnregisteredResponse(org.finra.herd.model.api.xml.BusinessObjectDataInvalidateUnregisteredResponse) Test(org.junit.Test) AbstractServiceTest(org.finra.herd.service.AbstractServiceTest)

Example 5 with BusinessObjectDataInvalidateUnregisteredResponse

use of org.finra.herd.model.api.xml.BusinessObjectDataInvalidateUnregisteredResponse in project herd by FINRAOS.

the class BusinessObjectDataInvalidateUnregisteredHelperTest method testInvalidateUnregisteredBusinessObjectDataS3PrefixWithSlash.

/**
 * The prefix search for S3 object should match prefixed directories, not sub-strings. For example: - If an S3 object exists with key "c/b/aa/test.txt" - If
 * a search for prefix "c/b/a" is executed - The S3 object should NOT match, since it is a prefix, but not a prefix directory.
 */
@Test
public void testInvalidateUnregisteredBusinessObjectDataS3PrefixWithSlash() throws Exception {
    BusinessObjectDataInvalidateUnregisteredRequest request = new BusinessObjectDataInvalidateUnregisteredRequest(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, PARTITION_VALUE, NO_SUBPARTITION_VALUES, StorageEntity.MANAGED_STORAGE);
    // Given a business object format
    // Given an object in S3
    BusinessObjectFormatEntity businessObjectFormatEntity;
    try {
        businessObjectFormatEntity = businessObjectFormatServiceTestHelper.createBusinessObjectFormat(request);
        // Create S3 object which is contains the partition value as substring
        request.setPartitionValue("AA");
        businessObjectDataServiceTestHelper.createS3Object(businessObjectFormatEntity, request, 0);
        // Send request with substring
        request.setPartitionValue("A");
    } catch (Exception e) {
        throw new IllegalArgumentException("Test failed during setup. Most likely setup or developer error.", e);
    }
    // Call API
    BusinessObjectDataInvalidateUnregisteredResponse actualResponse = businessObjectDataInvalidateUnregisteredHelper.invalidateUnregisteredBusinessObjectData(request);
    // Make assertions, expect no data updates since nothing should match
    Assert.assertNotNull("response business object datas is null", actualResponse.getRegisteredBusinessObjectDataList());
    Assert.assertEquals("response business object datas size", 0, actualResponse.getRegisteredBusinessObjectDataList().size());
}
Also used : BusinessObjectDataInvalidateUnregisteredRequest(org.finra.herd.model.api.xml.BusinessObjectDataInvalidateUnregisteredRequest) BusinessObjectFormatEntity(org.finra.herd.model.jpa.BusinessObjectFormatEntity) ObjectNotFoundException(org.finra.herd.model.ObjectNotFoundException) BusinessObjectDataInvalidateUnregisteredResponse(org.finra.herd.model.api.xml.BusinessObjectDataInvalidateUnregisteredResponse) Test(org.junit.Test) AbstractServiceTest(org.finra.herd.service.AbstractServiceTest)

Aggregations

BusinessObjectDataInvalidateUnregisteredResponse (org.finra.herd.model.api.xml.BusinessObjectDataInvalidateUnregisteredResponse)16 BusinessObjectDataInvalidateUnregisteredRequest (org.finra.herd.model.api.xml.BusinessObjectDataInvalidateUnregisteredRequest)13 Test (org.junit.Test)12 ObjectNotFoundException (org.finra.herd.model.ObjectNotFoundException)9 AbstractServiceTest (org.finra.herd.service.AbstractServiceTest)9 BusinessObjectFormatEntity (org.finra.herd.model.jpa.BusinessObjectFormatEntity)7 BusinessObjectData (org.finra.herd.model.api.xml.BusinessObjectData)4 StorageUnit (org.finra.herd.model.api.xml.StorageUnit)4 ArrayList (java.util.ArrayList)3 HashMap (java.util.HashMap)2 FieldExtension (org.activiti.bpmn.model.FieldExtension)2 Parameter (org.finra.herd.model.api.xml.Parameter)2 Secured (org.springframework.security.access.annotation.Secured)1 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)1