class RemoteDataContextWorkaroundService {

    public FileSystem prepareFilesytem(Cluster requestedCluster, DatalakeResources datalakeResources) {
        Stack stack = stackService.getById(datalakeResources.getDatalakeStackId());
        prepareFilesystemIfNotPresentedButSdxHasIt(requestedCluster, stack);
        if (hasFilesystem(requestedCluster.getFileSystem())) {
            FileSystem fileSystem = requestedCluster.getFileSystem();
            if (hasLocations(fileSystem)) {
                CloudStorage cloudStorage = fileSystem.getCloudStorage();
                FileSystem dlFileSystem = stack.getCluster().getFileSystem();
                if (hasFilesystem(dlFileSystem)) {
                    if (hasLocations(dlFileSystem)) {
                        List<StorageLocation> dlStorageLocations = dlFileSystem.getCloudStorage().getLocations();
                        List<StorageLocation> hiveRelatedStorageConfigs = getHiveRelatedStorageConfigs(dlStorageLocations);
                        if (sdxHasHiveStorageConfiguration(hiveRelatedStorageConfigs)) {
                            List<StorageLocation> storageLocations = getStorageLocationsWithoutHiveRelatedLocations(cloudStorage.getLocations());
                            storageLocations.addAll(hiveRelatedStorageConfigs);
                            cloudStorage.setLocations(storageLocations);
                            fileSystem.setCloudStorage(cloudStorage);
                        }
                    }
                }
            }
        }
        return requestedCluster.getFileSystem();
    }

}