use of com.sequenceiq.cloudbreak.domain.FlexSubscription in project cloudbreak by hortonworks.
the class FlexSubscriptionController method createFlexSubscription.
private FlexSubscriptionResponse createFlexSubscription(FlexSubscriptionRequest json, boolean publicInAccount) {
IdentityUser identityUser = authenticatedUserService.getCbUser();
FlexSubscription subscription = toFlexSubscriptionConverter.convert(json);
subscription.setAccount(identityUser.getAccount());
subscription.setOwner(identityUser.getUserId());
subscription.setPublicInAccount(publicInAccount);
subscription = flexService.create(subscription);
return toJsonConverter.convert(subscription);
}
use of com.sequenceiq.cloudbreak.domain.FlexSubscription in project cloudbreak by hortonworks.
the class FlexSubscriptionController method getPrivates.
@Override
public List<FlexSubscriptionResponse> getPrivates() {
IdentityUser identityUser = authenticatedUserService.getCbUser();
List<FlexSubscription> subscriptions = flexService.findByOwner(identityUser.getUserId());
return toJsonConverter.convert(subscriptions);
}
use of com.sequenceiq.cloudbreak.domain.FlexSubscription in project cloudbreak by hortonworks.
the class FlexSubscriptionController method setDefaultInAccount.
@Override
public void setDefaultInAccount(Long id) {
IdentityUser identityUser = authenticatedUserService.getCbUser();
FlexSubscription flexSubscription = flexService.findOneById(id);
flexService.setDefaultFlexSubscription(flexSubscription.getName(), identityUser);
}
use of com.sequenceiq.cloudbreak.domain.FlexSubscription in project cloudbreak by hortonworks.
the class FlexSubscriptionController method getPublics.
@Override
public List<FlexSubscriptionResponse> getPublics() {
IdentityUser identityUser = authenticatedUserService.getCbUser();
List<FlexSubscription> subscriptions = flexService.findPublicInAccountForUser(identityUser);
return toJsonConverter.convert(subscriptions);
}
use of com.sequenceiq.cloudbreak.domain.FlexSubscription in project cloudbreak by hortonworks.
the class FlexSubscriptionRequestToFlexSubscriptionConverter method convert.
@Override
public FlexSubscription convert(FlexSubscriptionRequest source) {
FlexSubscription subscription = new FlexSubscription();
subscription.setName(source.getName());
subscription.setSubscriptionId(source.getSubscriptionId());
subscription.setDefault(source.getUsedAsDefault());
subscription.setUsedForController(source.isUsedForController());
Long smartSenseSubscriptionId = source.getSmartSenseSubscriptionId();
try {
SmartSenseSubscription smartSenseSubscription = smartSenseSubscriptionService.findOneById(smartSenseSubscriptionId);
subscription.setSmartSenseSubscription(smartSenseSubscription);
} catch (NotFoundException ignored) {
throw new BadRequestException("SmartSense subscription could not be found with id: " + smartSenseSubscriptionId);
}
return subscription;
}
Aggregations