function checkCanSetAsDefault(profileName)
% Run the required checks before a profile can be set as default. This
% function will throw an exception in the case that a check fails.

%   Copyright 2014-2018 The MathWorks, Inc.

s = parallel.Settings;
profile = s.findProfile('Name', profileName);
sched = profile.getSchedulerComponent();

% The scheduler type enum contains the licensing configuration
% information including whether or not this scheduler needs to
% have a valid login before continuing.
schedulerType = parallel.internal.types.SchedulerType.fromName(sched.Type);
if schedulerType.RequiresLogin
    parallel.internal.mwa.ensureLoggedInAndRegistered(schedulerType.LicenseCategory);
end
