use of com.sequenceiq.cloudbreak.domain.ConstraintTemplate in project cloudbreak by hortonworks.
the class ConstraintTemplateController method getPublics.
@Override
public Set<ConstraintTemplateResponse> getPublics() {
IdentityUser user = authenticatedUserService.getCbUser();
Set<ConstraintTemplate> templates = constraintTemplateService.retrieveAccountConstraintTemplates(user);
return convert(templates);
}
use of com.sequenceiq.cloudbreak.domain.ConstraintTemplate in project cloudbreak by hortonworks.
the class ConstraintTemplateController method createConstraintTemplate.
private ConstraintTemplateResponse createConstraintTemplate(IdentityUser user, ConstraintTemplateRequest constraintTemplateRequest, boolean publicInAccount) {
ConstraintTemplate constraintTemplate = convert(constraintTemplateRequest, publicInAccount);
constraintTemplate = constraintTemplateService.create(user, constraintTemplate);
return conversionService.convert(constraintTemplate, ConstraintTemplateResponse.class);
}
use of com.sequenceiq.cloudbreak.domain.ConstraintTemplate in project cloudbreak by hortonworks.
the class ConstraintTemplateRequestToConstraintTemplateConverter method convert.
@Override
public ConstraintTemplate convert(ConstraintTemplateRequest source) {
ConstraintTemplate constraintTemplate = new ConstraintTemplate();
constraintTemplate.setCpu(source.getCpu());
constraintTemplate.setMemory(source.getMemory());
constraintTemplate.setDisk(source.getDisk());
constraintTemplate.setOrchestratorType(source.getOrchestratorType());
constraintTemplate.setName(source.getName());
constraintTemplate.setDescription(source.getDescription());
constraintTemplate.setStatus(ResourceStatus.USER_MANAGED);
return constraintTemplate;
}
use of com.sequenceiq.cloudbreak.domain.ConstraintTemplate in project cloudbreak by hortonworks.
the class HostGroupDecorator method decorateConstraint.
private Constraint decorateConstraint(Long stackId, IdentityUser user, Constraint constraint, String instanceGroupName, String constraintTemplateName) {
if (instanceGroupName != null) {
InstanceGroup instanceGroup = instanceGroupRepository.findOneByGroupNameInStack(stackId, instanceGroupName);
if (instanceGroup == null) {
LOGGER.error("Instance group not found: {}", instanceGroupName);
throw new BadRequestException(String.format("Instance group '%s' not found on stack.", instanceGroupName));
}
constraint.setInstanceGroup(instanceGroup);
}
if (constraintTemplateName != null) {
ConstraintTemplate constraintTemplate = constraintTemplateRepository.findByNameInAccount(constraintTemplateName, user.getAccount(), user.getUserId());
if (constraintTemplate == null) {
throw new BadRequestException(String.format("Couldn't find constraint template with name: %s", constraintTemplateName));
}
constraint.setConstraintTemplate(constraintTemplate);
}
return constraint;
}
use of com.sequenceiq.cloudbreak.domain.ConstraintTemplate in project cloudbreak by hortonworks.
the class ConstraintTemplateService method getPublicTemplate.
public ConstraintTemplate getPublicTemplate(String name, IdentityUser user) {
ConstraintTemplate constraintTemplate = constraintTemplateRepository.findOneByName(name, user.getAccount());
if (constraintTemplate == null) {
throw new NotFoundException(String.format(CONSTRAINT_NOT_FOUND_MSG, name));
}
authorizationService.hasReadPermission(constraintTemplate);
return constraintTemplate;
}
Aggregations