Create project through web interface
It adds a new panel in the Admin->Projects Screen.It enables the users that are allowed to create projects via command-line to create them also via web interface. Bug: issue 203 Change-Id: I082ab755276ab9d08e17603bc0f69c23566ac405
This commit is contained in:
@@ -41,6 +41,7 @@ public class PageLinks {
|
||||
public static final String MINE = "/";
|
||||
public static final String ADMIN_GROUPS = "/admin/groups/";
|
||||
public static final String ADMIN_PROJECTS = "/admin/projects/";
|
||||
public static final String ADMIN_CREATE_PROJECT = "/admin/create-project/";
|
||||
|
||||
public static String toChange(final ChangeInfo c) {
|
||||
return toChange(c.getId());
|
||||
|
@@ -20,6 +20,7 @@ import com.google.gerrit.reviewdb.Project;
|
||||
import com.google.gwt.user.client.rpc.AsyncCallback;
|
||||
import com.google.gwtjsonrpc.client.RemoteJsonService;
|
||||
import com.google.gwtjsonrpc.client.RpcImpl;
|
||||
import com.google.gwtjsonrpc.client.VoidResult;
|
||||
import com.google.gwtjsonrpc.client.RpcImpl.Version;
|
||||
|
||||
import java.util.List;
|
||||
@@ -27,13 +28,18 @@ import java.util.Set;
|
||||
|
||||
@RpcImpl(version = Version.V2_0)
|
||||
public interface ProjectAdminService extends RemoteJsonService {
|
||||
void visibleProjects(AsyncCallback<List<Project>> callback);
|
||||
void visibleProjects(AsyncCallback<ProjectList> callback);
|
||||
|
||||
void visibleProjectDetails(AsyncCallback<List<ProjectDetail>> callback);
|
||||
|
||||
void projectDetail(Project.NameKey projectName,
|
||||
AsyncCallback<ProjectDetail> callback);
|
||||
|
||||
@SignInRequired
|
||||
void createNewProject(String projectName, String parentName,
|
||||
boolean emptyCommit, boolean permissionsOnly,
|
||||
AsyncCallback<VoidResult> callback);
|
||||
|
||||
void projectAccess(Project.NameKey projectName,
|
||||
AsyncCallback<ProjectAccess> callback);
|
||||
|
||||
|
@@ -0,0 +1,43 @@
|
||||
// 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.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;
|
||||
}
|
||||
}
|
@@ -14,6 +14,7 @@
|
||||
|
||||
package com.google.gerrit.client;
|
||||
|
||||
import static com.google.gerrit.common.PageLinks.ADMIN_CREATE_PROJECT;
|
||||
import static com.google.gerrit.common.PageLinks.ADMIN_GROUPS;
|
||||
import static com.google.gerrit.common.PageLinks.ADMIN_PROJECTS;
|
||||
import static com.google.gerrit.common.PageLinks.MINE;
|
||||
@@ -45,6 +46,7 @@ import com.google.gerrit.client.account.ValidateEmailScreen;
|
||||
import com.google.gerrit.client.admin.AccountGroupInfoScreen;
|
||||
import com.google.gerrit.client.admin.AccountGroupMembersScreen;
|
||||
import com.google.gerrit.client.admin.AccountGroupScreen;
|
||||
import com.google.gerrit.client.admin.CreateProjectScreen;
|
||||
import com.google.gerrit.client.admin.GroupListScreen;
|
||||
import com.google.gerrit.client.admin.ProjectAccessScreen;
|
||||
import com.google.gerrit.client.admin.ProjectBranchesScreen;
|
||||
@@ -579,6 +581,10 @@ public class Dispatcher {
|
||||
} else if (matchPrefix("/admin/projects/", token)) {
|
||||
Gerrit.display(token, selectProject());
|
||||
|
||||
} else if (matchExact(ADMIN_CREATE_PROJECT, token)
|
||||
|| matchExact("/admin/create-project", token)) {
|
||||
Gerrit.display(token, new CreateProjectScreen());
|
||||
|
||||
} else {
|
||||
Gerrit.display(token, new NotFoundScreen());
|
||||
}
|
||||
|
@@ -80,6 +80,8 @@ public interface GerritCss extends CssResource {
|
||||
String contributorAgreementLegal();
|
||||
String contributorAgreementShortDescription();
|
||||
String coverMessage();
|
||||
String createProjectLink();
|
||||
String createProjectPanel();
|
||||
String dataCell();
|
||||
String dataHeader();
|
||||
String diffLinkCell();
|
||||
|
@@ -22,7 +22,7 @@ import com.google.gerrit.client.ui.ProjectNameSuggestOracle;
|
||||
import com.google.gerrit.client.ui.ProjectsTable;
|
||||
import com.google.gerrit.common.PageLinks;
|
||||
import com.google.gerrit.common.data.AccountProjectWatchInfo;
|
||||
import com.google.gerrit.reviewdb.Project;
|
||||
import com.google.gerrit.common.data.ProjectList;
|
||||
import com.google.gwt.event.dom.client.ClickEvent;
|
||||
import com.google.gwt.event.dom.client.ClickHandler;
|
||||
import com.google.gwt.event.dom.client.KeyCodes;
|
||||
@@ -362,10 +362,10 @@ public class MyWatchedProjectsScreen extends SettingsScreen implements
|
||||
|
||||
protected void populateProjects() {
|
||||
Util.PROJECT_SVC.visibleProjects(
|
||||
new GerritCallback<List<Project>>() {
|
||||
new GerritCallback<ProjectList>() {
|
||||
@Override
|
||||
public void onSuccess(final List<Project> result) {
|
||||
projectsTab.display(result);
|
||||
public void onSuccess(final ProjectList result) {
|
||||
projectsTab.display(result.getProjects());
|
||||
if (firstPopupLoad) { // Display was delayed until table was loaded
|
||||
firstPopupLoad = false;
|
||||
displayPopup();
|
||||
|
@@ -31,10 +31,13 @@ public interface AdminConstants extends Constants {
|
||||
String buttonSaveDescription();
|
||||
String buttonRenameGroup();
|
||||
String buttonCreateGroup();
|
||||
String buttonCreateProject();
|
||||
String buttonChangeGroupOwner();
|
||||
String buttonChangeGroupType();
|
||||
String buttonSelectGroup();
|
||||
String buttonSaveChanges();
|
||||
String checkBoxEmptyCommit();
|
||||
String checkBoxPermissionsOnly();
|
||||
String useContentMerge();
|
||||
String useContributorAgreements();
|
||||
String useSignedOffBy();
|
||||
@@ -56,6 +59,9 @@ public interface AdminConstants extends Constants {
|
||||
String noMembersInfo();
|
||||
String headingExternalGroup();
|
||||
String headingCreateGroup();
|
||||
String headingCreateProject();
|
||||
String headingParentProjectName();
|
||||
String columnProjectName();
|
||||
String headingAgreements();
|
||||
|
||||
String projectSubmitType_FAST_FORWARD_ONLY();
|
||||
@@ -93,6 +99,7 @@ public interface AdminConstants extends Constants {
|
||||
String groupTabGeneral();
|
||||
String groupTabMembers();
|
||||
String projectListTitle();
|
||||
String createProjectTitle();
|
||||
String projectAdminTabGeneral();
|
||||
String projectAdminTabBranches();
|
||||
String projectAdminTabAccess();
|
||||
|
@@ -10,10 +10,13 @@ buttonAddGroupMember = Add
|
||||
buttonRenameGroup = Rename Group
|
||||
buttonSaveDescription = Save Description
|
||||
buttonCreateGroup = Create Group
|
||||
buttonCreateProject = Create Project
|
||||
buttonChangeGroupOwner = Change Owner
|
||||
buttonChangeGroupType = Change Type
|
||||
buttonSelectGroup = Select
|
||||
buttonSaveChanges = Save Changes
|
||||
checkBoxEmptyCommit = Create initial empty commit
|
||||
checkBoxPermissionsOnly = Only serve as parent for other projects
|
||||
useContentMerge = Automatically resolve conflicts
|
||||
useContributorAgreements = Require a valid contributor agreement to upload
|
||||
useSignedOffBy = Require <a href="http://gerrit.googlecode.com/svn/documentation/2.0/user-signedoffby.html#Signed-off-by" target="_blank"><code>Signed-off-by</code></a> in commit message
|
||||
@@ -22,6 +25,8 @@ headingGroupOptions = Group Options
|
||||
isVisibleToAll = Make group visible to all registered users.
|
||||
buttonSaveGroupOptions = Save Group Options
|
||||
suggestedGroupLabel = group
|
||||
headingParentProjectName = Rights Inherit From
|
||||
columnProjectName = Project Name
|
||||
|
||||
emailOnlyAuthors = Authors
|
||||
descriptionNotifications = Send email notifications about comments and actions by users in this group only to:
|
||||
@@ -36,6 +41,7 @@ headingIncludedGroups = Included Groups
|
||||
noMembersInfo = Group Members can only be viewed for Gerrit internal groups. For external groups and Gerrit system groups the members cannot be displayed.
|
||||
headingExternalGroup = Selected External Group
|
||||
headingCreateGroup = Create New Group
|
||||
headingCreateProject = Create New Project
|
||||
headingAgreements = Contributor Agreements
|
||||
|
||||
projectSubmitType_FAST_FORWARD_ONLY = Fast Forward Only
|
||||
@@ -73,6 +79,7 @@ groupListTitle = Groups
|
||||
groupTabGeneral = General
|
||||
groupTabMembers = Members
|
||||
projectListTitle = Projects
|
||||
createProjectTitle = Create Project
|
||||
projectAdminTabGeneral = General
|
||||
projectAdminTabBranches = Branches
|
||||
projectAdminTabAccess = Access
|
||||
|
@@ -0,0 +1,159 @@
|
||||
// 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.client.admin;
|
||||
|
||||
import com.google.gerrit.client.Dispatcher;
|
||||
import com.google.gerrit.client.ErrorDialog;
|
||||
import com.google.gerrit.client.Gerrit;
|
||||
import com.google.gerrit.client.rpc.GerritCallback;
|
||||
import com.google.gerrit.client.ui.HintTextBox;
|
||||
import com.google.gerrit.client.ui.ProjectNameSuggestOracle;
|
||||
import com.google.gerrit.client.ui.Screen;
|
||||
import com.google.gerrit.reviewdb.Project;
|
||||
import com.google.gwt.event.dom.client.ClickEvent;
|
||||
import com.google.gwt.event.dom.client.ClickHandler;
|
||||
import com.google.gwt.event.dom.client.KeyCodes;
|
||||
import com.google.gwt.event.dom.client.KeyPressEvent;
|
||||
import com.google.gwt.event.dom.client.KeyPressHandler;
|
||||
import com.google.gwt.user.client.History;
|
||||
import com.google.gwt.user.client.ui.Button;
|
||||
import com.google.gwt.user.client.ui.CheckBox;
|
||||
import com.google.gwt.user.client.ui.Grid;
|
||||
import com.google.gwt.user.client.ui.SuggestBox;
|
||||
import com.google.gwt.user.client.ui.VerticalPanel;
|
||||
import com.google.gwtexpui.globalkey.client.NpTextBox;
|
||||
import com.google.gwtjsonrpc.client.VoidResult;
|
||||
|
||||
public class CreateProjectScreen extends Screen {
|
||||
private NpTextBox project;
|
||||
private Button create;
|
||||
private HintTextBox parent;
|
||||
private SuggestBox sugestParent;
|
||||
private CheckBox emptyCommit;
|
||||
private CheckBox permissionsOnly;
|
||||
|
||||
public CreateProjectScreen() {
|
||||
super();
|
||||
setRequiresSignIn(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onLoad() {
|
||||
super.onLoad();
|
||||
display();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onInitUI() {
|
||||
super.onInitUI();
|
||||
setPageTitle(Util.C.createProjectTitle());
|
||||
|
||||
addCreateProjectPanel();
|
||||
}
|
||||
|
||||
private void addCreateProjectPanel() {
|
||||
final VerticalPanel fp = new VerticalPanel();
|
||||
fp.setStyleName(Gerrit.RESOURCES.css().createProjectPanel());
|
||||
|
||||
initCreateTxt();
|
||||
initCreateButton();
|
||||
initParentBox();
|
||||
|
||||
addGrid(fp);
|
||||
|
||||
emptyCommit = new CheckBox(Util.C.checkBoxEmptyCommit());
|
||||
permissionsOnly = new CheckBox(Util.C.checkBoxPermissionsOnly());
|
||||
fp.add(emptyCommit);
|
||||
fp.add(permissionsOnly);
|
||||
fp.add(create);
|
||||
add(fp);
|
||||
}
|
||||
|
||||
private void initCreateTxt() {
|
||||
project = new NpTextBox();
|
||||
project.setVisibleLength(50);
|
||||
project.addKeyPressHandler(new KeyPressHandler() {
|
||||
@Override
|
||||
public void onKeyPress(KeyPressEvent event) {
|
||||
if (event.getCharCode() == KeyCodes.KEY_ENTER) {
|
||||
doCreateProject();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void initCreateButton() {
|
||||
create = new Button(Util.C.buttonCreateProject());
|
||||
create.addClickHandler(new ClickHandler() {
|
||||
@Override
|
||||
public void onClick(final ClickEvent event) {
|
||||
doCreateProject();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void initParentBox() {
|
||||
parent = new HintTextBox();
|
||||
sugestParent =
|
||||
new SuggestBox(new ProjectNameSuggestOracle(), parent);
|
||||
parent.setVisibleLength(50);
|
||||
}
|
||||
|
||||
private void addGrid(final VerticalPanel fp) {
|
||||
final Grid grid = new Grid(2, 2);
|
||||
grid.setStyleName(Gerrit.RESOURCES.css().infoBlock());
|
||||
grid.setText(0, 0, Util.C.columnProjectName() + ":");
|
||||
grid.setWidget(0, 1, project);
|
||||
grid.setText(1, 0, Util.C.headingParentProjectName() + ":");
|
||||
grid.setWidget(1, 1, sugestParent);
|
||||
|
||||
fp.add(grid);
|
||||
}
|
||||
|
||||
private void doCreateProject() {
|
||||
final String projectName = project.getText().trim();
|
||||
final String parentName = sugestParent.getText().trim();
|
||||
|
||||
if ("".equals(projectName)) {
|
||||
project.setFocus(true);
|
||||
return;
|
||||
}
|
||||
|
||||
enableForm(false);
|
||||
Util.PROJECT_SVC.createNewProject(projectName, parentName,
|
||||
emptyCommit.getValue(), permissionsOnly.getValue(),
|
||||
new GerritCallback<VoidResult>() {
|
||||
@Override
|
||||
public void onSuccess(VoidResult result) {
|
||||
History.newItem(Dispatcher.toProjectAdmin(new Project.NameKey(
|
||||
projectName), ProjectScreen.INFO));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Throwable caught) {
|
||||
new ErrorDialog(caught.getMessage()).center();
|
||||
enableForm(true);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void enableForm(final boolean enabled) {
|
||||
project.setEnabled(enabled);
|
||||
create.setEnabled(enabled);
|
||||
parent.setEnabled(enabled);
|
||||
emptyCommit.setEnabled(enabled);
|
||||
permissionsOnly.setEnabled(enabled);
|
||||
}
|
||||
}
|
@@ -20,24 +20,24 @@ import com.google.gerrit.client.rpc.ScreenLoadCallback;
|
||||
import com.google.gerrit.client.ui.Hyperlink;
|
||||
import com.google.gerrit.client.ui.ProjectsTable;
|
||||
import com.google.gerrit.client.ui.Screen;
|
||||
import com.google.gerrit.client.ui.SmallHeading;
|
||||
import com.google.gerrit.common.PageLinks;
|
||||
import com.google.gerrit.common.data.ProjectList;
|
||||
import com.google.gerrit.reviewdb.Project;
|
||||
import com.google.gwt.user.client.History;
|
||||
import com.google.gwt.user.client.ui.VerticalPanel;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class ProjectListScreen extends Screen {
|
||||
private VerticalPanel createProjectLinkPanel;
|
||||
private ProjectsTable projects;
|
||||
|
||||
@Override
|
||||
protected void onLoad() {
|
||||
super.onLoad();
|
||||
Util.PROJECT_SVC.visibleProjects(new ScreenLoadCallback<List<Project>>(this) {
|
||||
Util.PROJECT_SVC.visibleProjects(new ScreenLoadCallback<ProjectList>(this) {
|
||||
@Override
|
||||
protected void preDisplay(final List<Project> result) {
|
||||
projects.display(result);
|
||||
protected void preDisplay(final ProjectList result) {
|
||||
createProjectLinkPanel.setVisible(result.canCreateProject());
|
||||
projects.display(result.getProjects());
|
||||
projects.finishDisplay();
|
||||
}
|
||||
});
|
||||
@@ -48,6 +48,13 @@ public class ProjectListScreen extends Screen {
|
||||
super.onInitUI();
|
||||
setPageTitle(Util.C.projectListTitle());
|
||||
|
||||
createProjectLinkPanel = new VerticalPanel();
|
||||
createProjectLinkPanel.setStyleName(Gerrit.RESOURCES.css()
|
||||
.createProjectLink());
|
||||
createProjectLinkPanel.add(new Hyperlink(Util.C.headingCreateProject(),
|
||||
PageLinks.ADMIN_CREATE_PROJECT));
|
||||
add(createProjectLinkPanel);
|
||||
|
||||
projects = new ProjectsTable() {
|
||||
@Override
|
||||
protected void onOpenRow(final int row) {
|
||||
@@ -69,10 +76,6 @@ public class ProjectListScreen extends Screen {
|
||||
projects.setSavePointerId(PageLinks.ADMIN_PROJECTS);
|
||||
|
||||
add(projects);
|
||||
|
||||
final VerticalPanel fp = new VerticalPanel();
|
||||
fp.setStyleName(Gerrit.RESOURCES.css().addSshKeyPanel());
|
||||
fp.add(new SmallHeading(Util.C.headingCreateGroup()));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@@ -1110,6 +1110,16 @@ a:hover.downloadLink {
|
||||
padding: 5px 5px 5px 5px;
|
||||
}
|
||||
|
||||
.createProjectLink {
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
|
||||
.createProjectPanel {
|
||||
margin-bottom: 10px;
|
||||
background-color: trimColor;
|
||||
padding: 5px 5px 5px 5px;
|
||||
}
|
||||
|
||||
.sshHostKeyPanel {
|
||||
margin-top: 10px;
|
||||
border: 1px solid trimColor;
|
||||
|
@@ -0,0 +1,85 @@
|
||||
// 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.common.errors.ProjectCreationFailedException;
|
||||
import com.google.gerrit.httpd.rpc.Handler;
|
||||
import com.google.gerrit.reviewdb.Project;
|
||||
import com.google.gerrit.reviewdb.Project.SubmitType;
|
||||
import com.google.gerrit.server.project.CreateProject;
|
||||
import com.google.gerrit.server.project.CreateProjectArgs;
|
||||
import com.google.gerrit.server.project.NoSuchProjectException;
|
||||
import com.google.gerrit.server.project.ProjectControl;
|
||||
import com.google.gwtjsonrpc.client.VoidResult;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.assistedinject.Assisted;
|
||||
|
||||
import org.eclipse.jgit.lib.Constants;
|
||||
|
||||
public class CreateProjectHandler extends Handler<VoidResult> {
|
||||
|
||||
interface Factory {
|
||||
CreateProjectHandler create(@Assisted("projectName") String projectName,
|
||||
@Assisted("parentName") String parentName,
|
||||
@Assisted("emptyCommit") boolean emptyCommit,
|
||||
@Assisted("permissionsOnly") boolean permissionsOnly);
|
||||
}
|
||||
|
||||
private final CreateProject.Factory createProjectFactory;
|
||||
private final ProjectControl.Factory projectControlFactory;
|
||||
private final String projectName;
|
||||
private final String parentName;
|
||||
private final boolean emptyCommit;
|
||||
private final boolean permissionsOnly;
|
||||
|
||||
@Inject
|
||||
public CreateProjectHandler(final CreateProject.Factory createProjectFactory,
|
||||
final ProjectControl.Factory projectControlFactory,
|
||||
@Assisted("projectName") final String projectName,
|
||||
@Assisted("parentName") final String parentName,
|
||||
@Assisted("emptyCommit") final boolean emptyCommit,
|
||||
@Assisted("permissionsOnly") final boolean permissionsOnly) {
|
||||
this.createProjectFactory = createProjectFactory;
|
||||
this.projectControlFactory = projectControlFactory;
|
||||
this.projectName = projectName;
|
||||
this.parentName = parentName;
|
||||
this.emptyCommit = emptyCommit;
|
||||
this.permissionsOnly = permissionsOnly;
|
||||
}
|
||||
|
||||
@Override
|
||||
public VoidResult call() throws ProjectCreationFailedException {
|
||||
final CreateProjectArgs args = new CreateProjectArgs();
|
||||
args.setProjectName(projectName);
|
||||
if (!parentName.equals("")) {
|
||||
final Project.NameKey nameKey = new Project.NameKey(parentName);
|
||||
try {
|
||||
args.newParent = projectControlFactory.validateFor(nameKey);
|
||||
} catch (NoSuchProjectException e) {
|
||||
throw new ProjectCreationFailedException("Parent project \""
|
||||
+ parentName + "\" does not exist.", e);
|
||||
}
|
||||
}
|
||||
args.projectDescription = "";
|
||||
args.submitType = SubmitType.MERGE_IF_NECESSARY;
|
||||
args.branch = Constants.MASTER;
|
||||
args.createEmptyCommit = emptyCommit;
|
||||
args.permissionsOnly = permissionsOnly;
|
||||
|
||||
final CreateProject createProject = createProjectFactory.create(args);
|
||||
createProject.createProject();
|
||||
return VoidResult.INSTANCE;
|
||||
}
|
||||
}
|
@@ -19,9 +19,11 @@ 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.Branch;
|
||||
import com.google.gerrit.reviewdb.Project;
|
||||
import com.google.gwt.user.client.rpc.AsyncCallback;
|
||||
import com.google.gwtjsonrpc.client.VoidResult;
|
||||
import com.google.inject.Inject;
|
||||
|
||||
import org.eclipse.jgit.lib.ObjectId;
|
||||
@@ -38,6 +40,7 @@ class ProjectAdminServiceImpl implements ProjectAdminService {
|
||||
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;
|
||||
|
||||
@Inject
|
||||
@@ -49,7 +52,8 @@ class ProjectAdminServiceImpl implements ProjectAdminService {
|
||||
final VisibleProjects.Factory visibleProjectsFactory,
|
||||
final VisibleProjectDetails.Factory visibleProjectDetailsFactory,
|
||||
final ProjectAccessFactory.Factory projectAccessFactory,
|
||||
final ProjectDetailFactory.Factory projectDetailFactory) {
|
||||
final ProjectDetailFactory.Factory projectDetailFactory,
|
||||
final CreateProjectHandler.Factory createNewProjectFactory) {
|
||||
this.addBranchFactory = addBranchFactory;
|
||||
this.changeProjectAccessFactory = changeProjectAccessFactory;
|
||||
this.changeProjectSettingsFactory = changeProjectSettingsFactory;
|
||||
@@ -59,10 +63,11 @@ class ProjectAdminServiceImpl implements ProjectAdminService {
|
||||
this.visibleProjectDetailsFactory = visibleProjectDetailsFactory;
|
||||
this.projectAccessFactory = projectAccessFactory;
|
||||
this.projectDetailFactory = projectDetailFactory;
|
||||
this.createProjectHandlerFactory = createNewProjectFactory;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visibleProjects(final AsyncCallback<List<Project>> callback) {
|
||||
public void visibleProjects(final AsyncCallback<ProjectList> callback) {
|
||||
visibleProjectsFactory.create().to(callback);
|
||||
}
|
||||
|
||||
@@ -117,4 +122,12 @@ class ProjectAdminServiceImpl implements ProjectAdminService {
|
||||
addBranchFactory.create(projectName, branchName, startingRevision).to(
|
||||
callback);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void createNewProject(String projectName, String parentName,
|
||||
boolean emptyCommit, boolean permissionsOnly,
|
||||
AsyncCallback<VoidResult> callback) {
|
||||
createProjectHandlerFactory.create(projectName, parentName, emptyCommit,
|
||||
permissionsOnly).to(callback);
|
||||
}
|
||||
}
|
||||
|
@@ -30,6 +30,7 @@ public class ProjectModule extends RpcServletModule {
|
||||
protected void configure() {
|
||||
factory(AddBranch.Factory.class);
|
||||
factory(ChangeProjectAccess.Factory.class);
|
||||
factory(CreateProjectHandler.Factory.class);
|
||||
factory(ChangeProjectSettings.Factory.class);
|
||||
factory(DeleteBranches.Factory.class);
|
||||
factory(ListBranches.Factory.class);
|
||||
|
@@ -14,9 +14,10 @@
|
||||
|
||||
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.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;
|
||||
@@ -27,23 +28,32 @@ import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
|
||||
class VisibleProjects extends Handler<List<Project>> {
|
||||
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 ProjectCache projectCache, final CurrentUser user) {
|
||||
this.projectControlFactory = projectControlFactory;
|
||||
this.projectCache = projectCache;
|
||||
this.user = user;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Project> call() {
|
||||
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 {
|
||||
|
Reference in New Issue
Block a user