public class BulkDeleteAction implements ProjectsWsAction {
private static final String ACTION = "bulk_delete";
- public static final String PARAM_UUIDS = "ids";
+ public static final String PARAM_IDS = "ids";
public static final String PARAM_KEYS = "keys";
private final ComponentCleanerService componentCleanerService;
.setHandler(this);
action
- .createParam(PARAM_UUIDS)
- .setDescription("List of project UUIDs to delete")
+ .createParam(PARAM_IDS)
+ .setDescription("List of project ids to delete")
.setExampleValue("ce4c03d6-430f-40a9-b777-ad877c00aa4d,c526ef20-131b-4486-9357-063fa64b5079");
action
@Override
public void handle(Request request, Response response) throws Exception {
userSession.checkGlobalPermission(UserRole.ADMIN);
- List<String> uuids = request.paramAsStrings(PARAM_UUIDS);
+ List<String> uuids = request.paramAsStrings(PARAM_IDS);
List<String> keys = request.paramAsStrings(PARAM_KEYS);
DbSession dbSession = dbClient.openSession(false);
return dbClient.componentDao().selectByKeys(dbSession, keys);
}
- throw new IllegalArgumentException("UUIDs or keys must be provided");
+ throw new IllegalArgumentException("ids or keys must be provided");
}
}
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
import static org.sonar.server.project.ws.BulkDeleteAction.PARAM_KEYS;
-import static org.sonar.server.project.ws.BulkDeleteAction.PARAM_UUIDS;
+import static org.sonar.server.project.ws.BulkDeleteAction.PARAM_IDS;
@Category(DbTests.class)
public class BulkDeleteActionTest {
long snapshotId4 = insertNewProjectInDbAndReturnSnapshotId(4);
ws.newPostRequest("api/projects", ACTION)
- .setParam(PARAM_UUIDS, "project-uuid-1, project-uuid-3, project-uuid-4").execute();
+ .setParam(PARAM_IDS, "project-uuid-1, project-uuid-3, project-uuid-4").execute();
dbSession.commit();
assertThat(dbClient.componentDao().selectByUuids(dbSession, Arrays.asList("project-uuid-1", "project-uuid-3", "project-uuid-4"))).isEmpty();
public void web_service_returns_204() throws Exception {
insertNewProjectInDbAndReturnSnapshotId(1);
- WsTester.Result result = ws.newPostRequest("api/projects", ACTION).setParam(PARAM_UUIDS, "project-uuid-1").execute();
+ WsTester.Result result = ws.newPostRequest("api/projects", ACTION).setParam(PARAM_IDS, "project-uuid-1").execute();
result.assertNoContent();
}
userSessionRule.setGlobalPermissions(UserRole.CODEVIEWER, UserRole.ISSUE_ADMIN, UserRole.USER);
expectedException.expect(ForbiddenException.class);
- ws.newPostRequest("api/projects", ACTION).setParam(PARAM_UUIDS, "whatever-the-uuid").execute();
+ ws.newPostRequest("api/projects", ACTION).setParam(PARAM_IDS, "whatever-the-uuid").execute();
}
@Test
dbClient.componentDao().insert(dbSession, ComponentTesting.newFileDto(ComponentTesting.newProjectDto(), "file-uuid"));
dbSession.commit();
- ws.newPostRequest("api/projects", ACTION).setParam(PARAM_UUIDS, "file-uuid").execute();
+ ws.newPostRequest("api/projects", ACTION).setParam(PARAM_IDS, "file-uuid").execute();
}
@Test
dbSession.commit();
when(resourceType.getBooleanProperty(anyString())).thenReturn(false);
- ws.newPostRequest("api/projects", ACTION).setParam(PARAM_UUIDS, "project-uuid").execute();
+ ws.newPostRequest("api/projects", ACTION).setParam(PARAM_IDS, "project-uuid").execute();
}
private long insertNewProjectInDbAndReturnSnapshotId(int id) {