Delete ProjectAdminService visibleProjects, suggestParentCandidates
This has been replaced by the REST API /projects/ and is not necessary anymore. Clients should use the REST API over HTTP, and the `gerrit ls-projects` API over SSH. Change-Id: I22ea50c77a07de3ac635b2567d5b7b6aa6697459
This commit is contained in:
@@ -28,10 +28,7 @@ import java.util.Set;
|
||||
|
||||
@RpcImpl(version = Version.V2_0)
|
||||
public interface ProjectAdminService extends RemoteJsonService {
|
||||
void visibleProjects(AsyncCallback<ProjectList> callback);
|
||||
|
||||
void visibleProjectDetails(AsyncCallback<List<ProjectDetail>> callback);
|
||||
void suggestParentCandidates(AsyncCallback<List<Project>> callback);
|
||||
|
||||
void projectDetail(Project.NameKey projectName,
|
||||
AsyncCallback<ProjectDetail> callback);
|
||||
|
||||
@@ -1,43 +0,0 @@
|
||||
// Copyright (C) 2011 The Android Open Source Project
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License
|
||||
|
||||
package com.google.gerrit.common.data;
|
||||
|
||||
import com.google.gerrit.reviewdb.client.Project;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class ProjectList {
|
||||
protected List<Project> projects;
|
||||
protected boolean canCreateProject;
|
||||
|
||||
public ProjectList() {
|
||||
}
|
||||
|
||||
public List<Project> getProjects() {
|
||||
return projects;
|
||||
}
|
||||
|
||||
public void setProjects(List<Project> projects) {
|
||||
this.projects = projects;
|
||||
}
|
||||
|
||||
public boolean canCreateProject() {
|
||||
return canCreateProject;
|
||||
}
|
||||
|
||||
public void setCanCreateProject(boolean canCreateProject) {
|
||||
this.canCreateProject = canCreateProject;
|
||||
}
|
||||
}
|
||||
@@ -19,7 +19,6 @@ import com.google.gerrit.common.data.ListBranchesResult;
|
||||
import com.google.gerrit.common.data.ProjectAccess;
|
||||
import com.google.gerrit.common.data.ProjectAdminService;
|
||||
import com.google.gerrit.common.data.ProjectDetail;
|
||||
import com.google.gerrit.common.data.ProjectList;
|
||||
import com.google.gerrit.reviewdb.client.Branch;
|
||||
import com.google.gerrit.reviewdb.client.Project;
|
||||
import com.google.gwtjsonrpc.common.AsyncCallback;
|
||||
@@ -37,12 +36,10 @@ class ProjectAdminServiceImpl implements ProjectAdminService {
|
||||
private final ChangeProjectSettings.Factory changeProjectSettingsFactory;
|
||||
private final DeleteBranches.Factory deleteBranchesFactory;
|
||||
private final ListBranches.Factory listBranchesFactory;
|
||||
private final VisibleProjects.Factory visibleProjectsFactory;
|
||||
private final VisibleProjectDetails.Factory visibleProjectDetailsFactory;
|
||||
private final ProjectAccessFactory.Factory projectAccessFactory;
|
||||
private final CreateProjectHandler.Factory createProjectHandlerFactory;
|
||||
private final ProjectDetailFactory.Factory projectDetailFactory;
|
||||
private final SuggestParentCandidatesHandler.Factory suggestParentCandidatesHandlerFactory;
|
||||
|
||||
@Inject
|
||||
ProjectAdminServiceImpl(final AddBranch.Factory addBranchFactory,
|
||||
@@ -50,28 +47,19 @@ class ProjectAdminServiceImpl implements ProjectAdminService {
|
||||
final ChangeProjectSettings.Factory changeProjectSettingsFactory,
|
||||
final DeleteBranches.Factory deleteBranchesFactory,
|
||||
final ListBranches.Factory listBranchesFactory,
|
||||
final VisibleProjects.Factory visibleProjectsFactory,
|
||||
final VisibleProjectDetails.Factory visibleProjectDetailsFactory,
|
||||
final ProjectAccessFactory.Factory projectAccessFactory,
|
||||
final ProjectDetailFactory.Factory projectDetailFactory,
|
||||
final SuggestParentCandidatesHandler.Factory parentCandidatesFactory,
|
||||
final CreateProjectHandler.Factory createNewProjectFactory) {
|
||||
this.addBranchFactory = addBranchFactory;
|
||||
this.changeProjectAccessFactory = changeProjectAccessFactory;
|
||||
this.changeProjectSettingsFactory = changeProjectSettingsFactory;
|
||||
this.deleteBranchesFactory = deleteBranchesFactory;
|
||||
this.listBranchesFactory = listBranchesFactory;
|
||||
this.visibleProjectsFactory = visibleProjectsFactory;
|
||||
this.visibleProjectDetailsFactory = visibleProjectDetailsFactory;
|
||||
this.projectAccessFactory = projectAccessFactory;
|
||||
this.projectDetailFactory = projectDetailFactory;
|
||||
this.createProjectHandlerFactory = createNewProjectFactory;
|
||||
this.suggestParentCandidatesHandlerFactory = parentCandidatesFactory;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visibleProjects(final AsyncCallback<ProjectList> callback) {
|
||||
visibleProjectsFactory.create().to(callback);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -79,11 +67,6 @@ class ProjectAdminServiceImpl implements ProjectAdminService {
|
||||
visibleProjectDetailsFactory.create().to(callback);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void suggestParentCandidates(AsyncCallback<List<Project>> callback) {
|
||||
suggestParentCandidatesHandlerFactory.create().to(callback);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void projectDetail(final Project.NameKey projectName,
|
||||
final AsyncCallback<ProjectDetail> callback) {
|
||||
|
||||
@@ -34,11 +34,9 @@ public class ProjectModule extends RpcServletModule {
|
||||
factory(ChangeProjectSettings.Factory.class);
|
||||
factory(DeleteBranches.Factory.class);
|
||||
factory(ListBranches.Factory.class);
|
||||
factory(VisibleProjects.Factory.class);
|
||||
factory(VisibleProjectDetails.Factory.class);
|
||||
factory(ProjectAccessFactory.Factory.class);
|
||||
factory(ProjectDetailFactory.Factory.class);
|
||||
factory(SuggestParentCandidatesHandler.Factory.class);
|
||||
}
|
||||
});
|
||||
rpc(ProjectAdminServiceImpl.class);
|
||||
|
||||
@@ -1,40 +0,0 @@
|
||||
// Copyright (C) 2011 The Android Open Source Project
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License
|
||||
|
||||
package com.google.gerrit.httpd.rpc.project;
|
||||
|
||||
import com.google.gerrit.httpd.rpc.Handler;
|
||||
import com.google.gerrit.reviewdb.client.Project;
|
||||
import com.google.gerrit.server.project.SuggestParentCandidates;
|
||||
import com.google.inject.Inject;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class SuggestParentCandidatesHandler extends Handler<List<Project>> {
|
||||
interface Factory {
|
||||
SuggestParentCandidatesHandler create();
|
||||
}
|
||||
|
||||
private final SuggestParentCandidates suggestParentCandidates;
|
||||
|
||||
@Inject
|
||||
SuggestParentCandidatesHandler(final SuggestParentCandidates suggestParentCandidates) {
|
||||
this.suggestParentCandidates = suggestParentCandidates;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Project> call() throws Exception {
|
||||
return suggestParentCandidates.getProjects();
|
||||
}
|
||||
}
|
||||
@@ -1,75 +0,0 @@
|
||||
// Copyright (C) 2009 The Android Open Source Project
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package com.google.gerrit.httpd.rpc.project;
|
||||
|
||||
import com.google.gerrit.common.data.ProjectList;
|
||||
import com.google.gerrit.httpd.rpc.Handler;
|
||||
import com.google.gerrit.reviewdb.client.Project;
|
||||
import com.google.gerrit.server.CurrentUser;
|
||||
import com.google.gerrit.server.project.NoSuchProjectException;
|
||||
import com.google.gerrit.server.project.ProjectCache;
|
||||
import com.google.gerrit.server.project.ProjectControl;
|
||||
import com.google.inject.Inject;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
|
||||
class VisibleProjects extends Handler<ProjectList> {
|
||||
interface Factory {
|
||||
VisibleProjects create();
|
||||
}
|
||||
|
||||
private final ProjectControl.Factory projectControlFactory;
|
||||
private final ProjectCache projectCache;
|
||||
private final CurrentUser user;
|
||||
|
||||
@Inject
|
||||
VisibleProjects(final ProjectControl.Factory projectControlFactory,
|
||||
final ProjectCache projectCache, final CurrentUser user) {
|
||||
this.projectControlFactory = projectControlFactory;
|
||||
this.projectCache = projectCache;
|
||||
this.user = user;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ProjectList call() {
|
||||
ProjectList result = new ProjectList();
|
||||
result.setProjects(getProjects());
|
||||
result.setCanCreateProject(user.getCapabilities().canCreateProject());
|
||||
return result;
|
||||
}
|
||||
|
||||
private List<Project> getProjects() {
|
||||
List<Project> result = new ArrayList<Project>();
|
||||
for (Project.NameKey p : projectCache.all()) {
|
||||
try {
|
||||
ProjectControl c = projectControlFactory.controlFor(p);
|
||||
if (c.isVisible() || c.isOwner()) {
|
||||
result.add(c.getProject());
|
||||
}
|
||||
} catch (NoSuchProjectException e) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
Collections.sort(result, new Comparator<Project>() {
|
||||
public int compare(final Project a, final Project b) {
|
||||
return a.getName().compareTo(b.getName());
|
||||
}
|
||||
});
|
||||
return result;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user