@@ -114,7 +114,9 @@ public class ComponentFinder { | |||
BASE_COMPONENT_ID_AND_KEY("baseComponentId", "baseComponentKey"), | |||
DEVELOPER_ID_AND_KEY("developerId", "developerKey"), | |||
COMPONENT_ID_AND_COMPONENT("componentId", "component"), | |||
PROJECT_ID_AND_PROJECT("projectId", "project"); | |||
PROJECT_ID_AND_PROJECT("projectId", "project"), | |||
PROJECT_ID_AND_FROM("projectId", "from") | |||
; | |||
private final String uuidParamName; | |||
private final String keyParamName; |
@@ -34,9 +34,9 @@ import org.sonarqube.ws.client.project.UpdateKeyWsRequest; | |||
import static org.sonar.core.util.Uuids.UUID_EXAMPLE_01; | |||
import static org.sonarqube.ws.client.project.ProjectsWsParameters.ACTION_UPDATE_KEY; | |||
import static org.sonarqube.ws.client.project.ProjectsWsParameters.PARAM_NEW_PROJECT; | |||
import static org.sonarqube.ws.client.project.ProjectsWsParameters.PARAM_PROJECT; | |||
import static org.sonarqube.ws.client.project.ProjectsWsParameters.PARAM_FROM; | |||
import static org.sonarqube.ws.client.project.ProjectsWsParameters.PARAM_PROJECT_ID; | |||
import static org.sonarqube.ws.client.project.ProjectsWsParameters.PARAM_TO; | |||
public class UpdateKeyAction implements ProjectsWsAction { | |||
private final DbClient dbClient; | |||
@@ -63,7 +63,7 @@ public class UpdateKeyAction implements ProjectsWsAction { | |||
"<li>'Administer System'</li>" + | |||
"<li>'Administer' rights on the specified project</li>" + | |||
"</ul>", | |||
PARAM_PROJECT, PARAM_PROJECT_ID) | |||
PARAM_FROM, PARAM_PROJECT_ID) | |||
.setSince("6.1") | |||
.setPost(true) | |||
.setHandler(this); | |||
@@ -76,12 +76,12 @@ public class UpdateKeyAction implements ProjectsWsAction { | |||
.setDeprecatedKey("id", "6.4") | |||
.setExampleValue(UUID_EXAMPLE_01); | |||
action.createParam(PARAM_PROJECT) | |||
action.createParam(PARAM_FROM) | |||
.setDescription("Project or module key") | |||
.setDeprecatedKey("key", "6.4") | |||
.setExampleValue("my_old_project"); | |||
action.createParam(PARAM_NEW_PROJECT) | |||
action.createParam(PARAM_TO) | |||
.setDescription("New component key") | |||
.setRequired(true) | |||
.setDeprecatedKey("newKey", "6.4") | |||
@@ -99,7 +99,7 @@ public class UpdateKeyAction implements ProjectsWsAction { | |||
private void doHandle(UpdateKeyWsRequest request) { | |||
DbSession dbSession = dbClient.openSession(false); | |||
try { | |||
ComponentDto projectOrModule = componentFinder.getByUuidOrKey(dbSession, request.getId(), request.getKey(), ParamNames.PROJECT_ID_AND_PROJECT); | |||
ComponentDto projectOrModule = componentFinder.getByUuidOrKey(dbSession, request.getId(), request.getKey(), ParamNames.PROJECT_ID_AND_FROM); | |||
componentService.updateKey(dbSession, projectOrModule, request.getNewKey()); | |||
dbSession.commit(); | |||
} finally { | |||
@@ -110,8 +110,8 @@ public class UpdateKeyAction implements ProjectsWsAction { | |||
private static UpdateKeyWsRequest toWsRequest(Request request) { | |||
return UpdateKeyWsRequest.builder() | |||
.setId(request.param(PARAM_PROJECT_ID)) | |||
.setKey(request.param(PARAM_PROJECT)) | |||
.setNewKey(request.mandatoryParam(PARAM_NEW_PROJECT)) | |||
.setKey(request.param(PARAM_FROM)) | |||
.setNewKey(request.mandatoryParam(PARAM_TO)) | |||
.build(); | |||
} | |||
} |
@@ -44,9 +44,9 @@ import static org.mockito.Matchers.eq; | |||
import static org.mockito.Mockito.mock; | |||
import static org.mockito.Mockito.verify; | |||
import static org.sonar.db.component.ComponentTesting.newProjectDto; | |||
import static org.sonarqube.ws.client.project.ProjectsWsParameters.PARAM_NEW_PROJECT; | |||
import static org.sonarqube.ws.client.project.ProjectsWsParameters.PARAM_PROJECT; | |||
import static org.sonarqube.ws.client.project.ProjectsWsParameters.PARAM_FROM; | |||
import static org.sonarqube.ws.client.project.ProjectsWsParameters.PARAM_PROJECT_ID; | |||
import static org.sonarqube.ws.client.project.ProjectsWsParameters.PARAM_TO; | |||
public class UpdateKeyActionTest { | |||
private static final String ANOTHER_KEY = "another_key"; | |||
@@ -121,7 +121,7 @@ public class UpdateKeyActionTest { | |||
assertThat(definition.params()) | |||
.hasSize(3) | |||
.extracting(Param::key) | |||
.containsOnlyOnce("projectId", "project", "newProject"); | |||
.containsOnlyOnce("projectId", "from", "to"); | |||
} | |||
private void assertCallComponentService(@Nullable String newKey) { | |||
@@ -147,10 +147,10 @@ public class UpdateKeyActionTest { | |||
request.setParam(PARAM_PROJECT_ID, uuid); | |||
} | |||
if (key != null) { | |||
request.setParam(PARAM_PROJECT, key); | |||
request.setParam(PARAM_FROM, key); | |||
} | |||
if (newKey != null) { | |||
request.setParam(PARAM_NEW_PROJECT, newKey); | |||
request.setParam(PARAM_TO, newKey); | |||
} | |||
return request.execute().getInput(); |
@@ -37,12 +37,13 @@ import static org.sonarqube.ws.client.project.ProjectsWsParameters.ACTION_SEARCH | |||
import static org.sonarqube.ws.client.project.ProjectsWsParameters.ACTION_UPDATE_KEY; | |||
import static org.sonarqube.ws.client.project.ProjectsWsParameters.CONTROLLER; | |||
import static org.sonarqube.ws.client.project.ProjectsWsParameters.PARAM_BRANCH; | |||
import static org.sonarqube.ws.client.project.ProjectsWsParameters.PARAM_FROM; | |||
import static org.sonarqube.ws.client.project.ProjectsWsParameters.PARAM_NAME; | |||
import static org.sonarqube.ws.client.project.ProjectsWsParameters.PARAM_NEW_PROJECT; | |||
import static org.sonarqube.ws.client.project.ProjectsWsParameters.PARAM_ORGANIZATION; | |||
import static org.sonarqube.ws.client.project.ProjectsWsParameters.PARAM_PROJECT; | |||
import static org.sonarqube.ws.client.project.ProjectsWsParameters.PARAM_PROJECT_ID; | |||
import static org.sonarqube.ws.client.project.ProjectsWsParameters.PARAM_QUALIFIERS; | |||
import static org.sonarqube.ws.client.project.ProjectsWsParameters.PARAM_TO; | |||
/** | |||
* Maps web service {@code api/projects}. | |||
@@ -80,8 +81,8 @@ public class ProjectsService extends BaseService { | |||
public void updateKey(UpdateKeyWsRequest request) { | |||
PostRequest post = new PostRequest(path(ACTION_UPDATE_KEY)) | |||
.setParam(PARAM_PROJECT_ID, request.getId()) | |||
.setParam(PARAM_PROJECT, request.getKey()) | |||
.setParam(PARAM_NEW_PROJECT, request.getNewKey()); | |||
.setParam(PARAM_FROM, request.getKey()) | |||
.setParam(PARAM_TO, request.getNewKey()); | |||
call(post); | |||
} |
@@ -33,7 +33,6 @@ public class ProjectsWsParameters { | |||
public static final String PARAM_PROJECT = "project"; | |||
public static final String PARAM_PROJECT_ID = "projectId"; | |||
public static final String PARAM_NEW_PROJECT = "newProject"; | |||
public static final String PARAM_NAME = "name"; | |||
public static final String PARAM_BRANCH = "branch"; | |||
public static final String PARAM_ORGANIZATION = "organization"; |