Search in sources :

Example 1 with FlexSubscription

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);
}
Also used : IdentityUser(com.sequenceiq.cloudbreak.common.model.user.IdentityUser) FlexSubscription(com.sequenceiq.cloudbreak.domain.FlexSubscription)

Example 2 with FlexSubscription

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);
}
Also used : IdentityUser(com.sequenceiq.cloudbreak.common.model.user.IdentityUser) FlexSubscription(com.sequenceiq.cloudbreak.domain.FlexSubscription)

Example 3 with FlexSubscription

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);
}
Also used : IdentityUser(com.sequenceiq.cloudbreak.common.model.user.IdentityUser) FlexSubscription(com.sequenceiq.cloudbreak.domain.FlexSubscription)

Example 4 with FlexSubscription

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);
}
Also used : IdentityUser(com.sequenceiq.cloudbreak.common.model.user.IdentityUser) FlexSubscription(com.sequenceiq.cloudbreak.domain.FlexSubscription)

Example 5 with FlexSubscription

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;
}
Also used : FlexSubscription(com.sequenceiq.cloudbreak.domain.FlexSubscription) SmartSenseSubscription(com.sequenceiq.cloudbreak.domain.SmartSenseSubscription) NotFoundException(com.sequenceiq.cloudbreak.controller.NotFoundException) BadRequestException(com.sequenceiq.cloudbreak.controller.BadRequestException)

Aggregations

FlexSubscription (com.sequenceiq.cloudbreak.domain.FlexSubscription)22 IdentityUser (com.sequenceiq.cloudbreak.common.model.user.IdentityUser)8 Test (org.junit.Test)6 BadRequestException (com.sequenceiq.cloudbreak.controller.BadRequestException)2 Blueprint (com.sequenceiq.cloudbreak.domain.Blueprint)2 SmartSenseSubscription (com.sequenceiq.cloudbreak.domain.SmartSenseSubscription)2 FlexUsageCbdInstanceJson (com.sequenceiq.cloudbreak.api.model.flex.FlexUsageCbdInstanceJson)1 BlueprintProcessingException (com.sequenceiq.cloudbreak.blueprint.BlueprintProcessingException)1 BlueprintView (com.sequenceiq.cloudbreak.blueprint.template.views.BlueprintView)1 FileSystemConfigurationView (com.sequenceiq.cloudbreak.blueprint.template.views.FileSystemConfigurationView)1 HostgroupView (com.sequenceiq.cloudbreak.blueprint.template.views.HostgroupView)1 BlueprintStackInfo (com.sequenceiq.cloudbreak.blueprint.templates.BlueprintStackInfo)1 GeneralClusterConfigs (com.sequenceiq.cloudbreak.blueprint.templates.GeneralClusterConfigs)1 NotFoundException (com.sequenceiq.cloudbreak.controller.NotFoundException)1 CloudbreakUsage (com.sequenceiq.cloudbreak.domain.CloudbreakUsage)1 KerberosConfig (com.sequenceiq.cloudbreak.domain.KerberosConfig)1 LdapConfig (com.sequenceiq.cloudbreak.domain.LdapConfig)1 RDSConfig (com.sequenceiq.cloudbreak.domain.RDSConfig)1 CloudbreakServiceException (com.sequenceiq.cloudbreak.service.CloudbreakServiceException)1 IOException (java.io.IOException)1