use of com.sequenceiq.cloudbreak.controller.BadRequestException in project cloudbreak by hortonworks.
the class TopologyService method create.
@Transactional(TxType.NEVER)
public Topology create(IdentityUser user, Topology topology) {
LOGGER.debug("Creating topology: [User: '{}', Account: '{}']", user.getUsername(), user.getAccount());
Topology savedTopology;
topology.setOwner(user.getUserId());
topology.setAccount(user.getAccount());
try {
savedTopology = topologyRepository.save(topology);
} catch (DataIntegrityViolationException ex) {
String msg = String.format("Error with resource [%s], error: [%s]", APIResourceType.TOPOLOGY, getProperSqlErrorMessage(ex));
throw new BadRequestException(msg);
}
return savedTopology;
}
use of com.sequenceiq.cloudbreak.controller.BadRequestException in project cloudbreak by hortonworks.
the class UserProfileService method put.
public void put(UserProfileRequest request, IdentityUser user) {
UserProfile userProfile = get(user.getAccount(), user.getUserId(), user.getUsername());
if (request.getCredentialId() != null) {
Credential credential = credentialService.get(request.getCredentialId(), userProfile.getAccount());
userProfile.setCredential(credential);
} else if (request.getCredentialName() != null) {
Credential credential = credentialService.get(request.getCredentialName(), userProfile.getAccount());
userProfile.setCredential(credential);
}
for (Entry<String, Object> uiStringObjectEntry : request.getUiProperties().entrySet()) {
Map<String, Object> map = userProfile.getUiProperties().getMap();
if (map == null || map.isEmpty()) {
map = new HashMap<>();
}
map.put(uiStringObjectEntry.getKey(), uiStringObjectEntry.getValue());
try {
userProfile.setUiProperties(new Json(map));
} catch (JsonProcessingException ignored) {
throw new BadRequestException("The modification of the ui properties was unsuccesfull.");
}
}
userProfileRepository.save(userProfile);
}
Aggregations