@@ -74,15 +74,15 @@ public class ReportSubmitter { | |||
* @throws NotFoundException if the organization with the specified key does not exist | |||
* @throws IllegalArgumentException if the organization with the specified key is not the organization of the specified project (when it already exists in DB) | |||
*/ | |||
public CeTask submit(String organizationKey, String projectKey, @Nullable String projectBranch, @Nullable String projectName, Map<String, String> characteristics, | |||
public CeTask submit(String organizationKey, String projectKey, @Nullable String deprecatedBranch, @Nullable String projectName, Map<String, String> characteristics, | |||
InputStream reportInput) { | |||
try (DbSession dbSession = dbClient.openSession(false)) { | |||
OrganizationDto organizationDto = getOrganizationDtoOrFail(dbSession, organizationKey); | |||
String effectiveProjectKey = ComponentKeys.createKey(projectKey, projectBranch); | |||
String effectiveProjectKey = ComponentKeys.createKey(projectKey, deprecatedBranch); | |||
Optional<ComponentDto> component = dbClient.componentDao().selectByKey(dbSession, effectiveProjectKey); | |||
validateProject(dbSession, component, projectKey); | |||
ensureOrganizationIsConsistent(component, organizationDto); | |||
ComponentDto project = component.or(() -> createProject(dbSession, organizationDto, projectKey, projectBranch, projectName)); | |||
ComponentDto project = component.or(() -> createProject(dbSession, organizationDto, projectKey, deprecatedBranch, projectName)); | |||
checkScanPermission(project); | |||
return submitReport(dbSession, reportInput, project, characteristics); | |||
} | |||
@@ -152,7 +152,7 @@ public class ReportSubmitter { | |||
.setOrganizationUuid(organization.getUuid()) | |||
.setKey(projectKey) | |||
.setName(defaultIfBlank(projectName, projectKey)) | |||
.setBranch(deprecatedBranch) | |||
.setDeprecatedBranch(deprecatedBranch) | |||
.setQualifier(Qualifiers.PROJECT) | |||
.setPrivate(newProjectPrivate) | |||
.build(); |
@@ -80,6 +80,7 @@ public class SubmitAction implements CeWsAction { | |||
.setDescription("Key of project") | |||
.setExampleValue("my_project"); | |||
// deprecated branch (see scanner parameter sonar.branch) | |||
action | |||
.createParam(PARAM_PROJECT_BRANCH) | |||
.setDescription("Optional branch of project") | |||
@@ -110,13 +111,13 @@ public class SubmitAction implements CeWsAction { | |||
.emptyAsNull() | |||
.or(defaultOrganizationProvider.get()::getKey); | |||
String projectKey = wsRequest.mandatoryParam(PARAM_PROJECT_KEY); | |||
String projectBranch = wsRequest.param(PARAM_PROJECT_BRANCH); | |||
String deprecatedBranch = wsRequest.param(PARAM_PROJECT_BRANCH); | |||
String projectName = abbreviate(defaultIfBlank(wsRequest.param(PARAM_PROJECT_NAME), projectKey), MAX_COMPONENT_NAME_LENGTH); | |||
Map<String, String> characteristics = parseTaskCharacteristics(wsRequest); | |||
try (InputStream report = new BufferedInputStream(wsRequest.mandatoryParamAsPart(PARAM_REPORT_DATA).getInputStream())) { | |||
CeTask task = reportSubmitter.submit(organizationKey, projectKey, projectBranch, projectName, characteristics, report); | |||
CeTask task = reportSubmitter.submit(organizationKey, projectKey, deprecatedBranch, projectName, characteristics, report); | |||
Ce.SubmitResponse submitResponse = Ce.SubmitResponse.newBuilder() | |||
.setTaskId(task.getUuid()) | |||
.setProjectId(task.getComponentUuid()) |
@@ -87,8 +87,8 @@ public class ComponentUpdater { | |||
} | |||
private ComponentDto createRootComponent(DbSession session, NewComponent newComponent) { | |||
checkBranchFormat(newComponent.qualifier(), newComponent.branch()); | |||
String keyWithBranch = ComponentKeys.createKey(newComponent.key(), newComponent.branch()); | |||
checkBranchFormat(newComponent.qualifier(), newComponent.deprecatedBranch()); | |||
String keyWithBranch = ComponentKeys.createKey(newComponent.key(), newComponent.deprecatedBranch()); | |||
checkRequest(!dbClient.componentDao().selectByKey(session, keyWithBranch).isPresent(), | |||
"Could not create %s, key already exists: %s", getQualifierToDisplay(newComponent.qualifier()), keyWithBranch); | |||
@@ -64,7 +64,7 @@ public class NewComponent { | |||
} | |||
@CheckForNull | |||
public String branch() { | |||
public String deprecatedBranch() { | |||
return branch; | |||
} | |||
@@ -98,8 +98,8 @@ public class NewComponent { | |||
return this; | |||
} | |||
public Builder setBranch(@Nullable String branch) { | |||
this.branch = branch; | |||
public Builder setDeprecatedBranch(@Nullable String s) { | |||
this.branch = s; | |||
return this; | |||
} | |||
@@ -124,7 +124,7 @@ public class CreateAction implements ProjectsWsAction { | |||
.setOrganizationUuid(organization.getUuid()) | |||
.setKey(request.getKey()) | |||
.setName(request.getName()) | |||
.setBranch(request.getBranch()) | |||
.setDeprecatedBranch(request.getBranch()) | |||
.setPrivate(changeToPrivate) | |||
.setQualifier(PROJECT) | |||
.build(), |
@@ -141,7 +141,7 @@ public class ComponentUpdaterTest { | |||
NewComponent.newComponentBuilder() | |||
.setKey(DEFAULT_PROJECT_KEY) | |||
.setName(DEFAULT_PROJECT_NAME) | |||
.setBranch("origin/master") | |||
.setDeprecatedBranch("origin/master") | |||
.setOrganizationUuid(db.getDefaultOrganization().getUuid()) | |||
.build(), | |||
null); | |||
@@ -320,7 +320,7 @@ public class ComponentUpdaterTest { | |||
NewComponent.newComponentBuilder() | |||
.setKey(DEFAULT_PROJECT_KEY) | |||
.setName(DEFAULT_PROJECT_NAME) | |||
.setBranch("origin?branch") | |||
.setDeprecatedBranch("origin?branch") | |||
.setOrganizationUuid(db.getDefaultOrganization().getUuid()) | |||
.build(), | |||
null); |