class BusinessObjectDataStorageUnitServiceImpl implements BusinessObjectDataStorageUnitService {

    protected void validateBusinessObjectDataStorageUnitCreateRequest(BusinessObjectDataStorageUnitCreateRequest request)
    {
        Assert.notNull(request, "A business object data storage unit create request must be specified.");

        storageUnitHelper.validateBusinessObjectDataStorageUnitKey(request.getBusinessObjectDataStorageUnitKey());

        if (BooleanUtils.isTrue(request.isDiscoverStorageFiles()))
        {
            // The auto-discovery of storage files is enabled, thus a storage directory is required and storage files cannot be specified.
            Assert.isTrue(request.getStorageDirectory() != null, "A storage directory must be specified when discovery of storage files is enabled.");
            Assert.isTrue(CollectionUtils.isEmpty(request.getStorageFiles()), "Storage files cannot be specified when discovery of storage files is enabled.");
        }
        else
        {
            // Since auto-discovery is disabled, a storage directory or at least one storage file are required for each storage unit.
            Assert.isTrue(request.getStorageDirectory() != null || CollectionUtils.isNotEmpty(request.getStorageFiles()),
                "A storage directory or at least one storage file must be specified when discovery of storage files is not enabled.");
        }

        // If storageDirectory element is present in the request, we require it to contain a non-empty directoryPath element.
        if (request.getStorageDirectory() != null)
        {
            Assert.hasText(request.getStorageDirectory().getDirectoryPath(), "A storage directory path must be specified.");
            request.getStorageDirectory().setDirectoryPath(request.getStorageDirectory().getDirectoryPath().trim());
        }

        // Validate a list of storage files, if specified.
        if (CollectionUtils.isNotEmpty(request.getStorageFiles()))
        {
            storageFileHelper.validateCreateRequestStorageFiles(request.getStorageFiles());
        }
    }

}