BusinessObjectDataServiceImpl implements BusinessObjectDataService { @NamespacePermission(fields = "#businessObjectDataKey.namespace", permissions = NamespacePermissionEnum.WRITE) @Override public BusinessObjectData updateBusinessObjectDataRetentionInformation(BusinessObjectDataKey businessObjectDataKey, BusinessObjectDataRetentionInformationUpdateRequest businessObjectDataRetentionInformationUpdateRequest) { businessObjectDataHelper.validateBusinessObjectDataKey(businessObjectDataKey, true, true); Assert.notNull(businessObjectDataRetentionInformationUpdateRequest, "A business object data retention information update request must be specified."); BusinessObjectDataEntity businessObjectDataEntity = businessObjectDataDaoHelper.getBusinessObjectDataEntity(businessObjectDataKey); BusinessObjectFormatKey businessObjectFormatKey = new BusinessObjectFormatKey(businessObjectDataKey.getNamespace(), businessObjectDataKey.getBusinessObjectDefinitionName(), businessObjectDataKey.getBusinessObjectFormatUsage(), businessObjectDataKey.getBusinessObjectFormatFileType(), null); BusinessObjectFormatEntity businessObjectFormatEntity = businessObjectFormatDaoHelper.getBusinessObjectFormatEntity(businessObjectFormatKey); if (businessObjectFormatEntity.getRetentionType() == null || !businessObjectFormatEntity.getRetentionType().getCode().equals(RetentionTypeEntity.BDATA_RETENTION_DATE)) { throw new IllegalArgumentException(String .format("Retention information with %s retention type must be configured for business object format. Business object format: {%s}", RetentionTypeEntity.BDATA_RETENTION_DATE, businessObjectFormatHelper.businessObjectFormatKeyToString(businessObjectFormatKey))); } businessObjectDataEntity.setRetentionExpiration(businessObjectDataRetentionInformationUpdateRequest.getRetentionExpirationDate() != null ? new Timestamp(businessObjectDataRetentionInformationUpdateRequest.getRetentionExpirationDate().toGregorianCalendar().getTimeInMillis()) : null); businessObjectDataEntity = businessObjectDataDao.saveAndRefresh(businessObjectDataEntity); return businessObjectDataHelper.createBusinessObjectDataFromEntity(businessObjectDataEntity); }  @NamespacePermission(fields = "#request.namespace", permissions = NamespacePermissionEnum.READ) @Override @Transactional(propagation = Propagation.REQUIRES_NEW) BusinessObjectDataAvailability checkBusinessObjectDataAvailability(BusinessObjectDataAvailabilityRequest request); @NamespacePermission(fields = "#request?.businessObjectDataAvailabilityRequests?.![namespace]", permissions = NamespacePermissionEnum.READ) @Override @Transactional(propagation = Propagation.REQUIRES_NEW) BusinessObjectDataAvailabilityCollectionResponse checkBusinessObjectDataAvailabilityCollection(
        BusinessObjectDataAvailabilityCollectionRequest request); @PublishNotificationMessages @NamespacePermission(fields = "#request.namespace", permissions = NamespacePermissionEnum.WRITE) @Override @Transactional(propagation = Propagation.REQUIRES_NEW) BusinessObjectData createBusinessObjectData(BusinessObjectDataCreateRequest request); @NamespacePermission(fields = "#businessObjectDataKey.namespace", permissions = NamespacePermissionEnum.WRITE) @Override BusinessObjectData deleteBusinessObjectData(BusinessObjectDataKey businessObjectDataKey, Boolean deleteFiles); @NamespacePermission(fields = "#businessObjectDataKey.namespace", permissions = NamespacePermissionEnum.WRITE) @Override @Transactional(propagation = Propagation.NOT_SUPPORTED) BusinessObjectData destroyBusinessObjectData(BusinessObjectDataKey businessObjectDataKey); @NamespacePermission(fields = "#request.namespace", permissions = NamespacePermissionEnum.READ) @Override @Transactional(propagation = Propagation.REQUIRES_NEW) BusinessObjectDataDdl generateBusinessObjectDataDdl(BusinessObjectDataDdlRequest request); @NamespacePermission(fields = "#request?.businessObjectDataDdlRequests?.![namespace]", permissions = NamespacePermissionEnum.READ) @Override @Transactional(propagation = Propagation.REQUIRES_NEW) BusinessObjectDataDdlCollectionResponse generateBusinessObjectDataDdlCollection(BusinessObjectDataDdlCollectionRequest request); @NamespacePermission(fields = "#businessObjectDefinitionKey.namespace", permissions = NamespacePermissionEnum.READ) @Override BusinessObjectDataKeys getAllBusinessObjectDataByBusinessObjectDefinition(BusinessObjectDefinitionKey businessObjectDefinitionKey); @NamespacePermission(fields = "#businessObjectFormatKey.namespace", permissions = NamespacePermissionEnum.READ) @Override BusinessObjectDataKeys getAllBusinessObjectDataByBusinessObjectFormat(BusinessObjectFormatKey businessObjectFormatKey); @NamespacePermission(fields = "#businessObjectDataKey.namespace", permissions = NamespacePermissionEnum.READ) @Override @Transactional(propagation = Propagation.REQUIRES_NEW) BusinessObjectData getBusinessObjectData(BusinessObjectDataKey businessObjectDataKey, String businessObjectFormatPartitionKey,
        String businessObjectDataStatus, Boolean includeBusinessObjectDataStatusHistory, Boolean includeStorageUnitStatusHistory,
        Boolean excludeBusinessObjectDataStorageFiles); @NamespacePermission(fields = "#businessObjectDataKey.namespace", permissions = NamespacePermissionEnum.READ) @Override BusinessObjectDataVersions getBusinessObjectDataVersions(BusinessObjectDataKey businessObjectDataKey); @PublishNotificationMessages @NamespacePermission(fields = "#businessObjectDataInvalidateUnregisteredRequest.namespace", permissions = NamespacePermissionEnum.WRITE) @Override @Transactional(propagation = Propagation.REQUIRES_NEW) BusinessObjectDataInvalidateUnregisteredResponse invalidateUnregisteredBusinessObjectData(
        BusinessObjectDataInvalidateUnregisteredRequest businessObjectDataInvalidateUnregisteredRequest); @NamespacePermission(fields = "#businessObjectDataKey.namespace", permissions = NamespacePermissionEnum.WRITE) @Override @Transactional(propagation = Propagation.NOT_SUPPORTED) BusinessObjectData restoreBusinessObjectData(BusinessObjectDataKey businessObjectDataKey, Integer expirationInDays, String archiveRetrievalOption); @NamespacePermission(fields = "#request.namespace", permissions = NamespacePermissionEnum.READ) @Override @Transactional(propagation = Propagation.REQUIRES_NEW) BusinessObjectDataPartitions generateBusinessObjectDataPartitions(BusinessObjectDataPartitionsRequest request); @NamespacePermission(fields = "#businessObjectDataKey.namespace", permissions = NamespacePermissionEnum.WRITE) @Override BusinessObjectData retryStoragePolicyTransition(BusinessObjectDataKey businessObjectDataKey,
        BusinessObjectDataRetryStoragePolicyTransitionRequest request); @NamespacePermission(fields = "#businessObjectDataSearchRequest.businessObjectDataSearchFilters[0].BusinessObjectDataSearchKeys[0].namespace", permissions = NamespacePermissionEnum.READ) @Override BusinessObjectDataSearchResultPagingInfoDto searchBusinessObjectData(Integer pageNum, Integer pageSize,
        BusinessObjectDataSearchRequest businessObjectDataSearchRequest); @NamespacePermission(fields = "#businessObjectDataKey.namespace", permissions = {NamespacePermissionEnum.WRITE, NamespacePermissionEnum.WRITE_ATTRIBUTE}) @Override BusinessObjectData updateBusinessObjectDataAttributes(BusinessObjectDataKey businessObjectDataKey,
        BusinessObjectDataAttributesUpdateRequest businessObjectDataAttributesUpdateRequest); @NamespacePermission(fields = "#businessObjectDataKey.namespace", permissions = NamespacePermissionEnum.WRITE) @Override BusinessObjectData updateBusinessObjectDataParents(BusinessObjectDataKey businessObjectDataKey,
        BusinessObjectDataParentsUpdateRequest businessObjectDataParentsUpdateRequest); @NamespacePermission(fields = "#businessObjectDataKey.namespace", permissions = NamespacePermissionEnum.WRITE) @Override BusinessObjectData updateBusinessObjectDataRetentionInformation(BusinessObjectDataKey businessObjectDataKey,
        BusinessObjectDataRetentionInformationUpdateRequest businessObjectDataRetentionInformationUpdateRequest); static final String NO_PARTITIONING_PARTITION_KEY; static final String NO_PARTITIONING_PARTITION_VALUE; static final String REASON_NOT_REGISTERED; }
@Test public void testUpdateBusinessObjectDataRetentionInformation() { BusinessObjectDataKey businessObjectDataKey = new BusinessObjectDataKey(BDEF_NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, PARTITION_VALUE, SUBPARTITION_VALUES, DATA_VERSION); BusinessObjectDataRetentionInformationUpdateRequest businessObjectDataRetentionInformationUpdateRequest = new BusinessObjectDataRetentionInformationUpdateRequest(RETENTION_EXPIRATION_DATE); BusinessObjectDataEntity businessObjectDataEntity = new BusinessObjectDataEntity(); BusinessObjectFormatKey businessObjectFormatKey = new BusinessObjectFormatKey(BDEF_NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, NO_FORMAT_VERSION); RetentionTypeEntity retentionTypeEntity = new RetentionTypeEntity(); retentionTypeEntity.setCode(RetentionTypeEntity.BDATA_RETENTION_DATE); BusinessObjectFormatEntity businessObjectFormatEntity = new BusinessObjectFormatEntity(); businessObjectFormatEntity.setRetentionType(retentionTypeEntity); BusinessObjectData businessObjectData = new BusinessObjectData(); businessObjectData.setId(ID); when(businessObjectDataDaoHelper.getBusinessObjectDataEntity(businessObjectDataKey)).thenReturn(businessObjectDataEntity); when(businessObjectFormatDaoHelper.getBusinessObjectFormatEntity(businessObjectFormatKey)).thenReturn(businessObjectFormatEntity); when(businessObjectDataDao.saveAndRefresh(businessObjectDataEntity)).thenReturn(businessObjectDataEntity); when(businessObjectDataHelper.createBusinessObjectDataFromEntity(businessObjectDataEntity)).thenReturn(businessObjectData); BusinessObjectData result = businessObjectDataServiceImpl .updateBusinessObjectDataRetentionInformation(businessObjectDataKey, businessObjectDataRetentionInformationUpdateRequest); verify(businessObjectDataHelper).validateBusinessObjectDataKey(businessObjectDataKey, true, true); verify(businessObjectDataDaoHelper).getBusinessObjectDataEntity(businessObjectDataKey); verify(businessObjectFormatDaoHelper).getBusinessObjectFormatEntity(businessObjectFormatKey); verify(businessObjectDataDao).saveAndRefresh(businessObjectDataEntity); verify(businessObjectDataHelper).createBusinessObjectDataFromEntity(businessObjectDataEntity); verifyNoMoreInteractionsHelper(); assertEquals(businessObjectData, result); assertEquals(businessObjectDataEntity.getRetentionExpiration(), new Timestamp(RETENTION_EXPIRATION_DATE.toGregorianCalendar().getTimeInMillis())); }
@Test public void testUpdateBusinessObjectDataRetentionInformationBusinessObjectFormatHasInvalidRetentionType() { BusinessObjectDataKey businessObjectDataKey = new BusinessObjectDataKey(BDEF_NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, PARTITION_VALUE, SUBPARTITION_VALUES, DATA_VERSION); BusinessObjectDataRetentionInformationUpdateRequest businessObjectDataRetentionInformationUpdateRequest = new BusinessObjectDataRetentionInformationUpdateRequest(RETENTION_EXPIRATION_DATE); BusinessObjectDataEntity businessObjectDataEntity = new BusinessObjectDataEntity(); BusinessObjectFormatKey businessObjectFormatKey = new BusinessObjectFormatKey(BDEF_NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, NO_FORMAT_VERSION); RetentionTypeEntity retentionTypeEntity = new RetentionTypeEntity(); retentionTypeEntity.setCode(INVALID_VALUE); BusinessObjectFormatEntity businessObjectFormatEntity = new BusinessObjectFormatEntity(); businessObjectFormatEntity.setRetentionType(retentionTypeEntity); when(businessObjectDataDaoHelper.getBusinessObjectDataEntity(businessObjectDataKey)).thenReturn(businessObjectDataEntity); when(businessObjectFormatDaoHelper.getBusinessObjectFormatEntity(businessObjectFormatKey)).thenReturn(businessObjectFormatEntity); when(businessObjectFormatHelper.businessObjectFormatKeyToString(businessObjectFormatKey)).thenReturn(BUSINESS_OBJECT_FORMAT_KEY_AS_STRING); try { businessObjectDataServiceImpl .updateBusinessObjectDataRetentionInformation(businessObjectDataKey, businessObjectDataRetentionInformationUpdateRequest); fail(); } catch (IllegalArgumentException e) { assertEquals(String .format("Retention information with %s retention type must be configured for business object format. Business object format: {%s}", RetentionTypeEntity.BDATA_RETENTION_DATE, BUSINESS_OBJECT_FORMAT_KEY_AS_STRING), e.getMessage()); } verify(businessObjectDataHelper).validateBusinessObjectDataKey(businessObjectDataKey, true, true); verify(businessObjectDataDaoHelper).getBusinessObjectDataEntity(businessObjectDataKey); verify(businessObjectFormatDaoHelper).getBusinessObjectFormatEntity(businessObjectFormatKey); verify(businessObjectFormatHelper).businessObjectFormatKeyToString(businessObjectFormatKey); verifyNoMoreInteractionsHelper(); assertNull(businessObjectDataEntity.getRetentionExpiration()); }
@Test public void testUpdateBusinessObjectDataRetentionInformationBusinessObjectFormatHasNoRetentionType() { BusinessObjectDataKey businessObjectDataKey = new BusinessObjectDataKey(BDEF_NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, PARTITION_VALUE, SUBPARTITION_VALUES, DATA_VERSION); BusinessObjectDataRetentionInformationUpdateRequest businessObjectDataRetentionInformationUpdateRequest = new BusinessObjectDataRetentionInformationUpdateRequest(RETENTION_EXPIRATION_DATE); BusinessObjectDataEntity businessObjectDataEntity = new BusinessObjectDataEntity(); BusinessObjectFormatKey businessObjectFormatKey = new BusinessObjectFormatKey(BDEF_NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, NO_FORMAT_VERSION); BusinessObjectFormatEntity businessObjectFormatEntity = new BusinessObjectFormatEntity(); when(businessObjectDataDaoHelper.getBusinessObjectDataEntity(businessObjectDataKey)).thenReturn(businessObjectDataEntity); when(businessObjectFormatDaoHelper.getBusinessObjectFormatEntity(businessObjectFormatKey)).thenReturn(businessObjectFormatEntity); when(businessObjectFormatHelper.businessObjectFormatKeyToString(businessObjectFormatKey)).thenReturn(BUSINESS_OBJECT_FORMAT_KEY_AS_STRING); try { businessObjectDataServiceImpl .updateBusinessObjectDataRetentionInformation(businessObjectDataKey, businessObjectDataRetentionInformationUpdateRequest); fail(); } catch (IllegalArgumentException e) { assertEquals(String .format("Retention information with %s retention type must be configured for business object format. Business object format: {%s}", RetentionTypeEntity.BDATA_RETENTION_DATE, BUSINESS_OBJECT_FORMAT_KEY_AS_STRING), e.getMessage()); } verify(businessObjectDataHelper).validateBusinessObjectDataKey(businessObjectDataKey, true, true); verify(businessObjectDataDaoHelper).getBusinessObjectDataEntity(businessObjectDataKey); verify(businessObjectFormatDaoHelper).getBusinessObjectFormatEntity(businessObjectFormatKey); verify(businessObjectFormatHelper).businessObjectFormatKeyToString(businessObjectFormatKey); verifyNoMoreInteractionsHelper(); assertNull(businessObjectDataEntity.getRetentionExpiration()); }
@Test public void testUpdateBusinessObjectDataRetentionInformationMissingOptionalParameters() { BusinessObjectDataKey businessObjectDataKey = new BusinessObjectDataKey(BDEF_NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, PARTITION_VALUE, SUBPARTITION_VALUES, DATA_VERSION); BusinessObjectDataRetentionInformationUpdateRequest businessObjectDataRetentionInformationUpdateRequest = new BusinessObjectDataRetentionInformationUpdateRequest(NO_RETENTION_EXPIRATION_DATE); BusinessObjectDataEntity businessObjectDataEntity = new BusinessObjectDataEntity(); businessObjectDataEntity.setRetentionExpiration(new Timestamp(RETENTION_EXPIRATION_DATE.toGregorianCalendar().getTimeInMillis())); BusinessObjectFormatKey businessObjectFormatKey = new BusinessObjectFormatKey(BDEF_NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, NO_FORMAT_VERSION); RetentionTypeEntity retentionTypeEntity = new RetentionTypeEntity(); retentionTypeEntity.setCode(RetentionTypeEntity.BDATA_RETENTION_DATE); BusinessObjectFormatEntity businessObjectFormatEntity = new BusinessObjectFormatEntity(); businessObjectFormatEntity.setRetentionType(retentionTypeEntity); BusinessObjectData businessObjectData = new BusinessObjectData(); businessObjectData.setId(ID); when(businessObjectDataDaoHelper.getBusinessObjectDataEntity(businessObjectDataKey)).thenReturn(businessObjectDataEntity); when(businessObjectFormatDaoHelper.getBusinessObjectFormatEntity(businessObjectFormatKey)).thenReturn(businessObjectFormatEntity); when(businessObjectDataDao.saveAndRefresh(businessObjectDataEntity)).thenReturn(businessObjectDataEntity); when(businessObjectDataHelper.createBusinessObjectDataFromEntity(businessObjectDataEntity)).thenReturn(businessObjectData); BusinessObjectData result = businessObjectDataServiceImpl .updateBusinessObjectDataRetentionInformation(businessObjectDataKey, businessObjectDataRetentionInformationUpdateRequest); verify(businessObjectDataHelper).validateBusinessObjectDataKey(businessObjectDataKey, true, true); verify(businessObjectDataDaoHelper).getBusinessObjectDataEntity(businessObjectDataKey); verify(businessObjectFormatDaoHelper).getBusinessObjectFormatEntity(businessObjectFormatKey); verify(businessObjectDataDao).saveAndRefresh(businessObjectDataEntity); verify(businessObjectDataHelper).createBusinessObjectDataFromEntity(businessObjectDataEntity); verifyNoMoreInteractionsHelper(); assertEquals(businessObjectData, result); assertNull(businessObjectDataEntity.getRetentionExpiration()); }
@Test public void testUpdateBusinessObjectDataRetentionInformationMissingRequiredParameters() { BusinessObjectDataKey businessObjectDataKey = new BusinessObjectDataKey(BDEF_NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, PARTITION_VALUE, SUBPARTITION_VALUES, DATA_VERSION); try { businessObjectDataServiceImpl.updateBusinessObjectDataRetentionInformation(businessObjectDataKey, null); fail(); } catch (IllegalArgumentException e) { assertEquals("A business object data retention information update request must be specified.", e.getMessage()); } }