use of org.sonar.db.property.PropertyDto in project sonarqube by SonarSource.
the class ServerIdManager method persistServerIdIfMissingOrOldFormatted.
/**
* Insert or update {@link CoreProperties#SERVER_ID} property in DB to a UUID if it doesn't exist or if it's a date
* (per the old format of {@link CoreProperties#SERVER_ID} before 6.1).
*/
private void persistServerIdIfMissingOrOldFormatted(DbSession dbSession, @Nullable PropertyDto dto) {
if (dto == null || dto.getValue().isEmpty() || isDate(dto.getValue())) {
dbClient.propertiesDao().saveProperty(dbSession, new PropertyDto().setKey(SERVER_ID).setValue(uuidFactory.create()));
dbSession.commit();
}
}
use of org.sonar.db.property.PropertyDto in project sonarqube by SonarSource.
the class StartupMetadataProvider method selectProperty.
private static String selectProperty(DbClient dbClient, DbSession dbSession, String key) {
PropertyDto prop = dbClient.propertiesDao().selectGlobalProperty(dbSession, key);
checkState(prop != null, "Property %s is missing in database", key);
checkState(!isBlank(prop.getValue()), "Property %s is set but empty in database", key);
return prop.getValue();
}
use of org.sonar.db.property.PropertyDto in project sonarqube by SonarSource.
the class SelectAction method doHandle.
private void doHandle(SelectWsRequest request) {
try (DbSession dbSession = dbClient.openSession(false)) {
checkQualityGate(dbSession, request.getGateId());
ComponentDto project = getProject(dbSession, request.getProjectId(), request.getProjectKey());
dbClient.propertiesDao().saveProperty(dbSession, new PropertyDto().setKey(SONAR_QUALITYGATE_PROPERTY).setResourceId(project.getId()).setValue(String.valueOf(request.getGateId())));
dbSession.commit();
}
}
use of org.sonar.db.property.PropertyDto in project sonarqube by SonarSource.
the class ShowAction method handle.
@Override
public void handle(Request request, Response response) throws Exception {
userSession.checkIsSystemAdministrator();
try (DbSession dbSession = dbClient.openSession(true)) {
Map<String, PropertyDto> properties = dbClient.propertiesDao().selectGlobalPropertiesByKeys(dbSession, SETTINGS_KEYS).stream().collect(Collectors.uniqueIndex(PropertyDto::getKey, Function.identity()));
writeProtobuf(doHandle(properties), request, response);
}
}
use of org.sonar.db.property.PropertyDto in project sonarqube by SonarSource.
the class SetAction method doHandle.
private void doHandle(DbSession dbSession, SetRequest request) {
Optional<ComponentDto> component = searchComponent(dbSession, request);
checkPermissions(component);
PropertyDefinition definition = propertyDefinitions.get(request.getKey());
String value;
commonChecks(request, component);
if (!request.getFieldValues().isEmpty()) {
value = doHandlePropertySet(dbSession, request, definition, component);
} else {
validate(request);
PropertyDto property = toProperty(request, component);
value = property.getValue();
dbClient.propertiesDao().saveProperty(dbSession, property);
}
dbSession.commit();
if (!component.isPresent()) {
settingsChangeNotifier.onGlobalPropertyChange(persistedKey(request), value);
}
}
Aggregations