use of com.sequenceiq.cloudbreak.domain.AccountPreferences in project cloudbreak by hortonworks.
the class SimpleAccountPreferencesService method getOneById.
@Override
public AccountPreferences getOneById(Long id, IdentityUser user) {
AccountPreferences accountPreferences = repository.findOne(id);
if (!user.getRoles().contains(IdentityUserRole.ADMIN)) {
throw new BadRequestException("AccountPreferences are only available for admin users!");
} else if (accountPreferences == null) {
throw new BadRequestException(String.format("AccountPreferences could not find with id: %s", id));
} else if (!accountPreferences.getAccount().equals(user.getAccount())) {
throw new BadRequestException("AccountPreferences are only available for the owner admin user!");
}
authorizationService.hasReadPermission(accountPreferences);
return accountPreferences;
}
use of com.sequenceiq.cloudbreak.domain.AccountPreferences in project cloudbreak by hortonworks.
the class SimpleAccountPreferencesService method createDefaultAccountPreferences.
private AccountPreferences createDefaultAccountPreferences(String account) {
AccountPreferences defaultPreferences = new AccountPreferences();
defaultPreferences.setAccount(account);
defaultPreferences.setMaxNumberOfClusters(ZERO);
defaultPreferences.setMaxNumberOfNodesPerCluster(ZERO);
defaultPreferences.setMaxNumberOfClustersPerUser(ZERO);
defaultPreferences.setAllowedInstanceTypes(Collections.emptyList());
defaultPreferences.setClusterTimeToLive(ZERO);
defaultPreferences.setUserTimeToLive(ZERO);
return defaultPreferences;
}
use of com.sequenceiq.cloudbreak.domain.AccountPreferences in project cloudbreak by hortonworks.
the class SimpleAccountPreferencesService method delete.
@Override
public void delete(IdentityUser user) {
AccountPreferences preferences = getOneByAccount(user);
repository.delete(preferences);
}
use of com.sequenceiq.cloudbreak.domain.AccountPreferences in project cloudbreak by hortonworks.
the class AccountPreferencesRequestToAccountPreferencesConverter method convert.
@Override
public AccountPreferences convert(AccountPreferencesJson source) {
AccountPreferences target = new AccountPreferences();
target.setMaxNumberOfClusters(source.getMaxNumberOfClusters());
target.setMaxNumberOfNodesPerCluster(source.getMaxNumberOfNodesPerCluster());
List<String> allowedInstanceTypes = source.getAllowedInstanceTypes();
if (allowedInstanceTypes != null && !allowedInstanceTypes.isEmpty()) {
target.setAllowedInstanceTypes(allowedInstanceTypes);
}
target.setClusterTimeToLive(source.getClusterTimeToLive() * HOUR_IN_MS);
target.setUserTimeToLive(source.getUserTimeToLive() * HOUR_IN_MS);
target.setMaxNumberOfClustersPerUser(source.getMaxNumberOfClustersPerUser());
target.setPlatforms(source.getPlatforms());
target.setDefaultTags(getTags(source.getDefaultTags()));
return target;
}
use of com.sequenceiq.cloudbreak.domain.AccountPreferences in project cloudbreak by hortonworks.
the class AccountPreferencesController method get.
@Override
public AccountPreferencesJson get() {
IdentityUser user = authenticatedUserService.getCbUser();
AccountPreferences preferences = service.getOneByAccount(user);
return convert(preferences);
}
Aggregations