class BusinessObjectDataServiceImpl implements BusinessObjectDataService {

    @NamespacePermission(fields = "#businessObjectDataKey.namespace", permissions = NamespacePermissionEnum.WRITE)
    @Override
    public BusinessObjectData updateBusinessObjectDataRetentionInformation(BusinessObjectDataKey businessObjectDataKey,
        BusinessObjectDataRetentionInformationUpdateRequest businessObjectDataRetentionInformationUpdateRequest)
    {
        // Validate and trim the business object data key.
        businessObjectDataHelper.validateBusinessObjectDataKey(businessObjectDataKey, true, true);

        // Validate the update request.
        Assert.notNull(businessObjectDataRetentionInformationUpdateRequest, "A business object data retention information update request must be specified.");

        // Retrieve the business object data and ensure it exists.
        BusinessObjectDataEntity businessObjectDataEntity = businessObjectDataDaoHelper.getBusinessObjectDataEntity(businessObjectDataKey);

        // Get the latest version of the business object format for this business object data.
        BusinessObjectFormatKey businessObjectFormatKey =
            new BusinessObjectFormatKey(businessObjectDataKey.getNamespace(), businessObjectDataKey.getBusinessObjectDefinitionName(),
                businessObjectDataKey.getBusinessObjectFormatUsage(), businessObjectDataKey.getBusinessObjectFormatFileType(), null);
        BusinessObjectFormatEntity businessObjectFormatEntity = businessObjectFormatDaoHelper.getBusinessObjectFormatEntity(businessObjectFormatKey);

        // Fail if business object format for this business object data does not have
        // retention information configured with BDATA_RETENTION_DATE retention type.
        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)));
        }

        // Update the retention information.
        businessObjectDataEntity.setRetentionExpiration(businessObjectDataRetentionInformationUpdateRequest.getRetentionExpirationDate() != null ?
            new Timestamp(businessObjectDataRetentionInformationUpdateRequest.getRetentionExpirationDate().toGregorianCalendar().getTimeInMillis()) : null);

        // Persist and refresh the entity.
        businessObjectDataEntity = businessObjectDataDao.saveAndRefresh(businessObjectDataEntity);

        // Create and return the business object data object from the persisted entity.
        return businessObjectDataHelper.createBusinessObjectDataFromEntity(businessObjectDataEntity);
    }

}