use of com.sequenceiq.cloudbreak.domain.ClusterTemplate in project cloudbreak by hortonworks.
the class ClusterTemplateController method createClusterTemplateRequest.
private ClusterTemplateResponse createClusterTemplateRequest(IdentityUser user, ClusterTemplateRequest clusterTemplateRequest, boolean publicInAccount) {
ClusterTemplate clusterTemplate = conversionService.convert(clusterTemplateRequest, ClusterTemplate.class);
clusterTemplate.setPublicInAccount(publicInAccount);
clusterTemplate = clusterTemplateService.create(user, clusterTemplate);
notify(user, ResourceEvent.CLUSTER_TEMPLATE_CREATED);
return conversionService.convert(clusterTemplate, ClusterTemplateResponse.class);
}
use of com.sequenceiq.cloudbreak.domain.ClusterTemplate in project cloudbreak by hortonworks.
the class ClusterTemplateController method getPrivate.
@Override
public ClusterTemplateResponse getPrivate(String name) {
IdentityUser user = authenticatedUserService.getCbUser();
ClusterTemplate clusterTemplate = clusterTemplateService.getPrivateClusterTemplate(name, user);
return conversionService.convert(clusterTemplate, ClusterTemplateResponse.class);
}
use of com.sequenceiq.cloudbreak.domain.ClusterTemplate in project cloudbreak by hortonworks.
the class ClusterTemplateRequestToClusterTemplateConverter method convert.
@Override
public ClusterTemplate convert(ClusterTemplateRequest json) {
ClusterTemplate clusterTemplate = new ClusterTemplate();
clusterTemplate.setName(json.getName());
try {
clusterTemplate.setTemplate(new Json(json.getTemplate()));
} catch (JsonProcessingException e) {
LOGGER.error("Cloudtemplate cannot be converted to JSON: " + json.getTemplate(), e);
throw new BadRequestException("Cloudtemplate cannot be converted to JSON", e);
}
clusterTemplate.setType(json.getType());
return clusterTemplate;
}
use of com.sequenceiq.cloudbreak.domain.ClusterTemplate in project cloudbreak by hortonworks.
the class ClusterTemplateService method getByName.
public ClusterTemplate getByName(String name, IdentityUser user) {
ClusterTemplate clusterTemplate = clusterTemplateRepository.findByNameInAccount(name, user.getAccount(), user.getUserId());
if (clusterTemplate == null) {
throw new NotFoundException(String.format("Blueprint '%s' not found.", name));
}
authorizationService.hasReadPermission(clusterTemplate);
return clusterTemplate;
}
use of com.sequenceiq.cloudbreak.domain.ClusterTemplate in project cloudbreak by hortonworks.
the class ClusterTemplateService method create.
@Transactional(TxType.NEVER)
public ClusterTemplate create(IdentityUser user, ClusterTemplate clusterTemplate) {
LOGGER.debug("Creating clusterTemplate: [User: '{}', Account: '{}']", user.getUsername(), user.getAccount());
ClusterTemplate savedClusterTemplate;
clusterTemplate.setOwner(user.getUserId());
clusterTemplate.setAccount(user.getAccount());
try {
savedClusterTemplate = clusterTemplateRepository.save(clusterTemplate);
} catch (DataIntegrityViolationException ex) {
String msg = String.format("Error with resource [%s], error: [%s]", APIResourceType.CLUSTER_TEMPLATE, getProperSqlErrorMessage(ex));
throw new BadRequestException(msg);
}
return savedClusterTemplate;
}
Aggregations