use of org.sonar.db.component.ComponentDto in project sonarqube by SonarSource.
the class ApplyTemplateAction method doHandle.
private void doHandle(ApplyTemplateWsRequest request) {
try (DbSession dbSession = dbClient.openSession(false)) {
PermissionTemplateDto template = wsSupport.findTemplate(dbSession, newTemplateRef(request.getTemplateId(), request.getOrganization(), request.getTemplateName()));
ComponentDto project = wsSupport.getRootComponentOrModule(dbSession, newWsProjectRef(request.getProjectId(), request.getProjectKey()));
checkGlobalAdmin(userSession, template.getOrganizationUuid());
permissionTemplateService.apply(dbSession, template, Collections.singletonList(project));
}
}
use of org.sonar.db.component.ComponentDto in project sonarqube by SonarSource.
the class BulkApplyTemplateAction method doHandle.
private void doHandle(BulkApplyTemplateWsRequest request) {
try (DbSession dbSession = dbClient.openSession(false)) {
PermissionTemplateDto template = wsSupport.findTemplate(dbSession, newTemplateRef(request.getTemplateId(), request.getOrganization(), request.getTemplateName()));
checkGlobalAdmin(userSession, template.getOrganizationUuid());
ComponentQuery componentQuery = ComponentQuery.builder().setNameOrKeyQuery(request.getQuery()).setQualifiers(qualifiers(request.getQualifier())).build();
List<ComponentDto> projects = dbClient.componentDao().selectByQuery(dbSession, template.getOrganizationUuid(), componentQuery, 0, Integer.MAX_VALUE);
permissionTemplateService.apply(dbSession, template, projects);
}
}
use of org.sonar.db.component.ComponentDto in project sonarqube by SonarSource.
the class IndexAction method handle.
@Override
public void handle(Request request, Response response) throws Exception {
try (DbSession dbSession = dbClient.openSession(false)) {
List<ComponentDto> projects = getAuthorizedComponents(dbSession, searchComponents(dbSession, request));
JsonWriter json = response.newJsonWriter();
json.beginArray();
for (ComponentDto project : projects) {
addProject(json, project);
}
json.endArray();
json.close();
}
}
use of org.sonar.db.component.ComponentDto in project sonarqube by SonarSource.
the class ProvisionedAction method handle.
@Override
public void handle(Request request, Response response) throws Exception {
userSession.checkLoggedIn();
SearchOptions options = new SearchOptions().setPage(request.mandatoryParamAsInt(Param.PAGE), request.mandatoryParamAsInt(Param.PAGE_SIZE));
Set<String> desiredFields = desiredFields(request);
String query = request.param(Param.TEXT_QUERY);
try (DbSession dbSession = dbClient.openSession(false)) {
OrganizationDto organization = support.getOrganization(dbSession, request.getParam(PARAM_ORGANIZATION).or(defaultOrganizationProvider.get()::getKey));
userSession.checkPermission(PROVISION_PROJECTS, organization);
RowBounds rowBounds = new RowBounds(options.getOffset(), options.getLimit());
List<ComponentDto> projects = dbClient.componentDao().selectProvisioned(dbSession, organization.getUuid(), query, QUALIFIERS_FILTER, rowBounds);
int nbOfProjects = dbClient.componentDao().countProvisioned(dbSession, organization.getUuid(), query, QUALIFIERS_FILTER);
JsonWriter json = response.newJsonWriter().beginObject();
writeProjects(projects, json, desiredFields);
options.writeJson(json, nbOfProjects);
json.endObject().close();
}
}
use of org.sonar.db.component.ComponentDto in project sonarqube by SonarSource.
the class ProvisionedAction method writeProjects.
private static void writeProjects(List<ComponentDto> projects, JsonWriter json, Set<String> desiredFields) {
json.name("projects");
json.beginArray();
for (ComponentDto project : projects) {
json.beginObject();
json.prop("uuid", project.uuid());
writeIfNeeded(json, "key", project.key(), desiredFields);
writeIfNeeded(json, "name", project.name(), desiredFields);
writeIfNeeded(json, "creationDate", project.getCreatedAt(), desiredFields);
json.endObject();
}
json.endArray();
}
Aggregations