use of com.sequenceiq.cloudbreak.api.model.DatabaseVendor in project cloudbreak by hortonworks.
the class RDSConfigRequestToRDSConfigConverter method convert.
@Override
public RDSConfig convert(RDSConfigRequest source) {
RDSConfig rdsConfig = new RDSConfig();
if (Strings.isNullOrEmpty(source.getName())) {
rdsConfig.setName(missingResourceNameGenerator.generateName(APIResourceType.RDS_CONFIG));
} else {
rdsConfig.setName(source.getName());
}
rdsConfig.setConnectionURL(source.getConnectionURL());
Optional<DatabaseVendor> databaseVendor = DatabaseVendor.getVendorByJdbcUrl(source.getConnectionURL());
if (databaseVendor.isPresent()) {
rdsConfig.setDatabaseEngine(databaseVendor.get().name());
rdsConfig.setConnectionDriver(databaseVendor.get().connectionDriver());
} else {
throw new BadRequestException("Not a valid DatabaseVendor which was provided in the jdbc url.");
}
rdsConfig.setConnectionUserName(source.getConnectionUserName());
rdsConfig.setConnectionPassword(source.getConnectionPassword());
rdsConfig.setCreationDate(new Date().getTime());
rdsConfig.setStatus(ResourceStatus.USER_MANAGED);
rdsConfig.setType(source.getType());
return rdsConfig;
}
Aggregations