Move some project classes to extension to expose them in Project API

Change-Id: I25a8d463b50fd3cd016c7d182790ae54883b7401
This commit is contained in:
David Ostrovsky
2014-02-04 09:20:27 +01:00
committed by David Ostrovsky
parent c72b30cab8
commit 99dea4bfba
55 changed files with 267 additions and 183 deletions

View File

@@ -31,12 +31,12 @@ import com.google.gerrit.acceptance.RestResponse;
import com.google.gerrit.acceptance.SshSession;
import com.google.gerrit.extensions.api.changes.ReviewInput;
import com.google.gerrit.extensions.api.changes.SubmitInput;
import com.google.gerrit.extensions.common.InheritableBoolean;
import com.google.gerrit.extensions.common.SubmitType;
import com.google.gerrit.reviewdb.client.Change;
import com.google.gerrit.reviewdb.client.PatchSet;
import com.google.gerrit.reviewdb.client.PatchSetApproval;
import com.google.gerrit.reviewdb.client.Project;
import com.google.gerrit.reviewdb.client.Project.InheritableBoolean;
import com.google.gerrit.reviewdb.client.Project.SubmitType;
import com.google.gerrit.server.ApprovalsUtil;
import com.google.gerrit.server.change.ChangeJson.ChangeInfo;
import com.google.gerrit.server.change.ChangeJson.LabelInfo;

View File

@@ -19,8 +19,8 @@ import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertSame;
import com.google.gerrit.acceptance.PushOneCommit;
import com.google.gerrit.reviewdb.client.Project.SubmitType;
import com.google.gwtorm.server.OrmException;
import com.google.gerrit.extensions.common.SubmitType;
import com.jcraft.jsch.JSchException;

View File

@@ -18,7 +18,7 @@ import static com.google.gerrit.acceptance.GitUtil.checkout;
import static org.junit.Assert.assertEquals;
import com.google.gerrit.acceptance.PushOneCommit;
import com.google.gerrit.reviewdb.client.Project.SubmitType;
import com.google.gerrit.extensions.common.SubmitType;
import org.eclipse.jgit.api.Git;
import org.eclipse.jgit.revwalk.RevCommit;

View File

@@ -18,7 +18,7 @@ import static com.google.gerrit.acceptance.GitUtil.checkout;
import static org.junit.Assert.assertEquals;
import com.google.gerrit.acceptance.PushOneCommit;
import com.google.gerrit.reviewdb.client.Project.SubmitType;
import com.google.gerrit.extensions.common.SubmitType;
import com.google.gwtorm.server.OrmException;
import com.jcraft.jsch.JSchException;

View File

@@ -4,7 +4,7 @@ import static com.google.gerrit.acceptance.GitUtil.checkout;
import static org.junit.Assert.assertEquals;
import com.google.gerrit.acceptance.PushOneCommit;
import com.google.gerrit.reviewdb.client.Project.SubmitType;
import com.google.gerrit.extensions.common.SubmitType;
import com.google.gwtorm.server.OrmException;
import com.jcraft.jsch.JSchException;

View File

@@ -18,7 +18,7 @@ import static com.google.gerrit.acceptance.GitUtil.checkout;
import static org.junit.Assert.assertEquals;
import com.google.gerrit.acceptance.PushOneCommit;
import com.google.gerrit.reviewdb.client.Project.SubmitType;
import com.google.gerrit.extensions.common.SubmitType;
import org.eclipse.jgit.api.Git;
import org.eclipse.jgit.revwalk.RevCommit;

View File

@@ -24,15 +24,15 @@ import com.google.common.collect.Lists;
import com.google.common.collect.Sets;
import com.google.gerrit.acceptance.AbstractDaemonTest;
import com.google.gerrit.acceptance.RestResponse;
import com.google.gerrit.extensions.api.projects.ProjectInput;
import com.google.gerrit.extensions.common.InheritableBoolean;
import com.google.gerrit.extensions.common.SubmitType;
import com.google.gerrit.reviewdb.client.AccountGroup;
import com.google.gerrit.reviewdb.client.Project;
import com.google.gerrit.reviewdb.client.Project.InheritableBoolean;
import com.google.gerrit.reviewdb.client.Project.SubmitType;
import com.google.gerrit.reviewdb.client.RefNames;
import com.google.gerrit.server.account.GroupCache;
import com.google.gerrit.server.git.GitRepositoryManager;
import com.google.gerrit.server.group.SystemGroupBackend;
import com.google.gerrit.server.project.CreateProject;
import com.google.gerrit.server.project.ProjectCache;
import com.google.gerrit.server.project.ProjectJson.ProjectInfo;
import com.google.gerrit.server.project.ProjectState;
@@ -80,7 +80,7 @@ public class CreateProjectIT extends AbstractDaemonTest {
@Test
public void testCreateProjectWithNameMismatch_BadRequest() throws IOException {
CreateProject.Input in = new CreateProject.Input();
ProjectInput in = new ProjectInput();
in.name = "otherName";
RestResponse r = adminSession.put("/projects/someName", in);
assertEquals(HttpStatus.SC_BAD_REQUEST, r.getStatusCode());
@@ -89,7 +89,7 @@ public class CreateProjectIT extends AbstractDaemonTest {
@Test
public void testCreateProjectWithProperties() throws IOException {
final String newProjectName = "newProject";
CreateProject.Input in = new CreateProject.Input();
ProjectInput in = new ProjectInput();
in.description = "Test description";
in.submitType = SubmitType.CHERRY_PICK;
in.useContributorAgreements = InheritableBoolean.TRUE;
@@ -115,7 +115,7 @@ public class CreateProjectIT extends AbstractDaemonTest {
RestResponse r = adminSession.put("/projects/" + parentName);
r.consume();
final String childName = "child";
CreateProject.Input in = new CreateProject.Input();
ProjectInput in = new ProjectInput();
in.parent = parentName;
r = adminSession.put("/projects/" + childName, in);
Project project = projectCache.get(new Project.NameKey(childName)).getProject();
@@ -124,7 +124,7 @@ public class CreateProjectIT extends AbstractDaemonTest {
public void testCreateChildProjectUnderNonExistingParent_UnprocessableEntity()
throws IOException {
CreateProject.Input in = new CreateProject.Input();
ProjectInput in = new ProjectInput();
in.parent = "non-existing-project";
RestResponse r = adminSession.put("/projects/child", in);
assertEquals(HttpStatus.SC_UNPROCESSABLE_ENTITY, r.getStatusCode());
@@ -133,7 +133,7 @@ public class CreateProjectIT extends AbstractDaemonTest {
@Test
public void testCreateProjectWithOwner() throws IOException {
final String newProjectName = "newProject";
CreateProject.Input in = new CreateProject.Input();
ProjectInput in = new ProjectInput();
in.owners = Lists.newArrayListWithCapacity(3);
in.owners.add("Anonymous Users"); // by name
in.owners.add(SystemGroupBackend.REGISTERED_USERS.get()); // by UUID
@@ -150,7 +150,7 @@ public class CreateProjectIT extends AbstractDaemonTest {
public void testCreateProjectWithNonExistingOwner_UnprocessableEntity()
throws IOException {
CreateProject.Input in = new CreateProject.Input();
ProjectInput in = new ProjectInput();
in.owners = Collections.singletonList("non-existing-group");
RestResponse r = adminSession.put("/projects/newProject", in);
assertEquals(HttpStatus.SC_UNPROCESSABLE_ENTITY, r.getStatusCode());
@@ -159,7 +159,7 @@ public class CreateProjectIT extends AbstractDaemonTest {
@Test
public void testCreatePermissionOnlyProject() throws IOException {
final String newProjectName = "newProject";
CreateProject.Input in = new CreateProject.Input();
ProjectInput in = new ProjectInput();
in.permissionsOnly = true;
adminSession.put("/projects/" + newProjectName, in);
assertHead(newProjectName, RefNames.REFS_CONFIG);
@@ -168,7 +168,7 @@ public class CreateProjectIT extends AbstractDaemonTest {
@Test
public void testCreateProjectWithEmptyCommit() throws IOException {
final String newProjectName = "newProject";
CreateProject.Input in = new CreateProject.Input();
ProjectInput in = new ProjectInput();
in.createEmptyCommit = true;
adminSession.put("/projects/" + newProjectName, in);
assertEmptyCommit(newProjectName, "refs/heads/master");
@@ -177,7 +177,7 @@ public class CreateProjectIT extends AbstractDaemonTest {
@Test
public void testCreateProjectWithBranches() throws IOException {
final String newProjectName = "newProject";
CreateProject.Input in = new CreateProject.Input();
ProjectInput in = new ProjectInput();
in.createEmptyCommit = true;
in.branches = Lists.newArrayListWithCapacity(3);
in.branches.add("refs/heads/test");

View File

@@ -39,6 +39,7 @@ java_library(
srcs = glob([SRC + 'common/**/*.java'], excludes = ANNOTATIONS),
deps = [
':annotations',
'//gerrit-extension-api:api',
'//gerrit-patch-jgit:server',
'//gerrit-prettify:server',
'//gerrit-reviewdb:server',

View File

@@ -14,10 +14,10 @@
package com.google.gerrit.common.data;
import com.google.gerrit.extensions.common.SubmitType;
import com.google.gerrit.reviewdb.client.Change;
import com.google.gerrit.reviewdb.client.ChangeMessage;
import com.google.gerrit.reviewdb.client.PatchSet;
import com.google.gerrit.reviewdb.client.Project;
import java.util.List;
import java.util.Set;
@@ -41,7 +41,7 @@ public class ChangeDetail {
protected List<PatchSet> patchSets;
protected Set<PatchSet.Id> patchSetsWithDraftComments;
protected List<SubmitRecord> submitRecords;
protected Project.SubmitType submitType;
protected SubmitType submitType;
protected SubmitTypeRecord submitTypeRecord;
protected boolean canSubmit;
protected List<ChangeMessage> messages;

View File

@@ -14,7 +14,7 @@
package com.google.gerrit.common.data;
import com.google.gerrit.reviewdb.client.Project;
import com.google.gerrit.extensions.common.SubmitType;
/**
* Describes the submit type for a change.
@@ -31,7 +31,7 @@ public class SubmitTypeRecord {
RULE_ERROR
}
public static SubmitTypeRecord OK(Project.SubmitType type) {
public static SubmitTypeRecord OK(SubmitType type) {
SubmitTypeRecord r = new SubmitTypeRecord();
r.status = Status.OK;
r.type = type;
@@ -39,7 +39,7 @@ public class SubmitTypeRecord {
}
public Status status;
public Project.SubmitType type;
public SubmitType type;
public String errorMessage;
public String toString() {

View File

@@ -4,8 +4,11 @@ SRCS = glob([SRC + '**/*.java'])
gwt_module(
name = 'client',
srcs = glob([
SRC + 'api/projects/ProjectState.java',
SRC + 'common/InheritableBoolean.java',
SRC + 'common/ListChangesOption.java',
SRC + 'common/SubmitType.java',
SRC + 'webui/GerritTopMenu.java',
SRC + 'common/ListChangesOption.java'
]),
gwtxml = SRC + 'Extensions.gwt.xml',
visibility = ['PUBLIC'],

View File

@@ -14,6 +14,7 @@
limitations under the License.
-->
<module>
<source path='webui' />
<source path='api' />
<source path='common' />
<source path='webui' />
</module>

View File

@@ -0,0 +1,43 @@
// Copyright (C) 2014 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.extensions.api.projects;
import com.google.gerrit.extensions.common.InheritableBoolean;
import com.google.gerrit.extensions.common.SubmitType;
import java.util.List;
import java.util.Map;
public class ProjectInput {
public String name;
public String parent;
public String description;
public boolean permissionsOnly;
public boolean createEmptyCommit;
public SubmitType submitType;
public List<String> branches;
public List<String> owners;
public InheritableBoolean useContributorAgreements;
public InheritableBoolean useSignedOffBy;
public InheritableBoolean useContentMerge;
public InheritableBoolean requireChangeId;
public String maxObjectSizeLimit;
public Map<String, Map<String, ConfigValue>> pluginConfigValues;
public static class ConfigValue {
public String value;
public List<String> values;
}
}

View File

@@ -0,0 +1,21 @@
// Copyright (C) 2014 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.extensions.api.projects;
public enum ProjectState {
ACTIVE,
READ_ONLY,
HIDDEN
}

View File

@@ -0,0 +1,21 @@
// Copyright (C) 2014 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.extensions.common;
public enum InheritableBoolean {
TRUE,
FALSE,
INHERIT
}

View File

@@ -0,0 +1,23 @@
// Copyright (C) 2014 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.extensions.common;
public enum SubmitType {
FAST_FORWARD_ONLY,
MERGE_IF_NECESSARY,
REBASE_IF_NECESSARY,
MERGE_ALWAYS,
CHERRY_PICK
}

View File

@@ -34,10 +34,11 @@ import com.google.gerrit.client.rpc.ScreenLoadCallback;
import com.google.gerrit.client.ui.NpIntTextBox;
import com.google.gerrit.client.ui.OnEditEnabler;
import com.google.gerrit.client.ui.SmallHeading;
import com.google.gerrit.extensions.api.projects.ProjectState;
import com.google.gerrit.extensions.common.InheritableBoolean;
import com.google.gerrit.extensions.common.SubmitType;
import com.google.gerrit.reviewdb.client.AccountGeneralPreferences.DownloadCommand;
import com.google.gerrit.reviewdb.client.Project;
import com.google.gerrit.reviewdb.client.Project.InheritableBoolean;
import com.google.gerrit.reviewdb.client.Project.SubmitType;
import com.google.gwt.event.dom.client.ChangeEvent;
import com.google.gwt.event.dom.client.ChangeHandler;
import com.google.gwt.event.dom.client.ClickEvent;
@@ -185,7 +186,7 @@ public class ProjectInfoScreen extends ProjectScreen {
grid.addHeader(new SmallHeading(Util.C.headingProjectOptions()));
submitType = new ListBox();
for (final Project.SubmitType type : Project.SubmitType.values()) {
for (final SubmitType type : SubmitType.values()) {
submitType.addItem(Util.toLongString(type), type.name());
}
submitType.addChangeHandler(new ChangeHandler() {
@@ -198,7 +199,7 @@ public class ProjectInfoScreen extends ProjectScreen {
grid.add(Util.C.headingProjectSubmitType(), submitType);
state = new ListBox();
for (final Project.State stateValue : Project.State.values()) {
for (final ProjectState stateValue : ProjectState.values()) {
state.addItem(Util.toLongString(stateValue), stateValue.name());
}
saveEnabler.listenTo(state);
@@ -238,7 +239,7 @@ public class ProjectInfoScreen extends ProjectScreen {
* content merge the useContentMerge checkbox gets disabled.
*/
private void setEnabledForUseContentMerge() {
if (SubmitType.FAST_FORWARD_ONLY.equals(Project.SubmitType
if (SubmitType.FAST_FORWARD_ONLY.equals(SubmitType
.valueOf(submitType.getValue(submitType.getSelectedIndex())))) {
contentMerge.setEnabled(false);
InheritedBooleanInfo b = InheritedBooleanInfo.create();
@@ -263,7 +264,7 @@ public class ProjectInfoScreen extends ProjectScreen {
grid.addHtml(Util.C.useSignedOffBy(), signedOffBy);
}
private void setSubmitType(final Project.SubmitType newSubmitType) {
private void setSubmitType(final SubmitType newSubmitType) {
int index = -1;
if (submitType != null) {
for (int i = 0; i < submitType.getItemCount(); i++) {
@@ -277,7 +278,7 @@ public class ProjectInfoScreen extends ProjectScreen {
}
}
private void setState(final Project.State newState) {
private void setState(final ProjectState newState) {
if (state != null) {
for (int i = 0; i < state.getItemCount(); i++) {
if (newState.name().equals(state.getValue(i))) {
@@ -569,8 +570,8 @@ public class ProjectInfoScreen extends ProjectScreen {
getBool(contributorAgreements), getBool(contentMerge),
getBool(signedOffBy), getBool(requireChangeID),
maxObjectSizeLimit.getText().trim(),
Project.SubmitType.valueOf(submitType.getValue(submitType.getSelectedIndex())),
Project.State.valueOf(state.getValue(state.getSelectedIndex())),
SubmitType.valueOf(submitType.getValue(submitType.getSelectedIndex())),
ProjectState.valueOf(state.getValue(state.getSelectedIndex())),
getPluginConfigValues(), new GerritCallback<ConfigInfo>() {
@Override
public void onSuccess(ConfigInfo result) {

View File

@@ -15,7 +15,8 @@
package com.google.gerrit.client.admin;
import com.google.gerrit.common.data.ProjectAdminService;
import com.google.gerrit.reviewdb.client.Project;
import com.google.gerrit.extensions.api.projects.ProjectState;
import com.google.gerrit.extensions.common.SubmitType;
import com.google.gwt.core.client.GWT;
import com.google.gwtjsonrpc.client.JsonUtil;
@@ -31,7 +32,7 @@ public class Util {
AdminResources.I.css().ensureInjected();
}
public static String toLongString(final Project.SubmitType type) {
public static String toLongString(final SubmitType type) {
if (type == null) {
return "";
}
@@ -51,7 +52,7 @@ public class Util {
}
}
public static String toLongString(final Project.State type) {
public static String toLongString(final ProjectState type) {
if (type == null) {
return "";
}

View File

@@ -48,11 +48,10 @@ import com.google.gerrit.client.ui.Screen;
import com.google.gerrit.client.ui.UserActivityMonitor;
import com.google.gerrit.common.PageLinks;
import com.google.gerrit.extensions.common.ListChangesOption;
import com.google.gerrit.extensions.common.SubmitType;
import com.google.gerrit.reviewdb.client.Change;
import com.google.gerrit.reviewdb.client.Change.Status;
import com.google.gerrit.reviewdb.client.PatchSet;
import com.google.gerrit.reviewdb.client.Project;
import com.google.gerrit.reviewdb.client.Project.SubmitType;
import com.google.gwt.core.client.GWT;
import com.google.gwt.core.client.JsArray;
import com.google.gwt.core.client.JsArrayString;
@@ -841,7 +840,7 @@ public class ChangeScreen2 extends Screen {
private void renderSubmitType(String action) {
try {
SubmitType type = Project.SubmitType.valueOf(action);
SubmitType type = SubmitType.valueOf(action);
submitActionText.setInnerText(
com.google.gerrit.client.admin.Util.toLongString(type));
} catch (IllegalArgumentException e) {

View File

@@ -42,6 +42,7 @@ import com.google.gerrit.common.data.ChangeDetail;
import com.google.gerrit.common.data.ChangeInfo;
import com.google.gerrit.common.data.SubmitTypeRecord;
import com.google.gerrit.extensions.common.ListChangesOption;
import com.google.gerrit.extensions.common.SubmitType;
import com.google.gerrit.reviewdb.client.AccountGeneralPreferences.CommentVisibilityStrategy;
import com.google.gerrit.reviewdb.client.Change;
import com.google.gerrit.reviewdb.client.Change.Status;
@@ -50,7 +51,6 @@ import com.google.gerrit.reviewdb.client.Patch;
import com.google.gerrit.reviewdb.client.Patch.ChangeType;
import com.google.gerrit.reviewdb.client.Patch.PatchType;
import com.google.gerrit.reviewdb.client.PatchSet;
import com.google.gerrit.reviewdb.client.Project;
import com.google.gwt.core.client.JsArray;
import com.google.gwt.core.client.JsArrayString;
import com.google.gwt.event.dom.client.ChangeEvent;
@@ -311,7 +311,7 @@ public class ChangeScreen extends Screen
@Override
public void onSuccess(NativeString result) {
event.getValue().setSubmitTypeRecord(SubmitTypeRecord.OK(
Project.SubmitType.valueOf(result.asString())));
SubmitType.valueOf(result.asString())));
}
public void onFailure(Throwable caught) {}
}));

View File

@@ -36,11 +36,11 @@ import com.google.gerrit.common.PageLinks;
import com.google.gerrit.common.data.ChangeDetail;
import com.google.gerrit.common.data.SubmitTypeRecord;
import com.google.gerrit.extensions.common.ListChangesOption;
import com.google.gerrit.extensions.common.SubmitType;
import com.google.gerrit.reviewdb.client.Change;
import com.google.gerrit.reviewdb.client.Patch;
import com.google.gerrit.reviewdb.client.PatchLineComment;
import com.google.gerrit.reviewdb.client.PatchSet;
import com.google.gerrit.reviewdb.client.Project;
import com.google.gwt.core.client.JsArray;
import com.google.gwt.core.client.JsArrayString;
import com.google.gwt.event.dom.client.ClickEvent;
@@ -169,7 +169,7 @@ public class PublishCommentScreen extends AccountScreen implements
@Override
public void onSuccess(NativeString result) {
submitTypeRecord = SubmitTypeRecord.OK(
Project.SubmitType.valueOf(result.asString()));
SubmitType.valueOf(result.asString()));
}
public void onFailure(Throwable caught) {}
}));

View File

@@ -17,9 +17,9 @@ package com.google.gerrit.client.projects;
import com.google.gerrit.client.ErrorDialog;
import com.google.gerrit.client.actions.ActionInfo;
import com.google.gerrit.client.rpc.NativeMap;
import com.google.gerrit.reviewdb.client.Project;
import com.google.gerrit.reviewdb.client.Project.InheritableBoolean;
import com.google.gerrit.reviewdb.client.Project.SubmitType;
import com.google.gerrit.extensions.api.projects.ProjectState;
import com.google.gerrit.extensions.common.InheritableBoolean;
import com.google.gerrit.extensions.common.SubmitType;
import com.google.gwt.core.client.JavaScriptObject;
import com.google.gwt.core.client.JsArray;
import com.google.gwt.core.client.JsArrayString;
@@ -63,11 +63,11 @@ public class ConfigInfo extends JavaScriptObject {
private final native String submit_typeRaw()
/*-{ return this.submit_type }-*/;
public final Project.State state() {
public final ProjectState state() {
if (stateRaw() == null) {
return Project.State.ACTIVE;
return ProjectState.ACTIVE;
}
return Project.State.valueOf(stateRaw());
return ProjectState.valueOf(stateRaw());
}
private final native String stateRaw()
/*-{ return this.state }-*/;

View File

@@ -19,9 +19,10 @@ import com.google.gerrit.client.rpc.CallbackGroup;
import com.google.gerrit.client.rpc.NativeMap;
import com.google.gerrit.client.rpc.NativeString;
import com.google.gerrit.client.rpc.RestApi;
import com.google.gerrit.extensions.api.projects.ProjectState;
import com.google.gerrit.extensions.common.InheritableBoolean;
import com.google.gerrit.extensions.common.SubmitType;
import com.google.gerrit.reviewdb.client.Project;
import com.google.gerrit.reviewdb.client.Project.InheritableBoolean;
import com.google.gerrit.reviewdb.client.Project.SubmitType;
import com.google.gwt.core.client.JavaScriptObject;
import com.google.gwt.core.client.JsArray;
import com.google.gwt.user.client.rpc.AsyncCallback;
@@ -85,7 +86,7 @@ public class ProjectApi {
InheritableBoolean useContributorAgreements,
InheritableBoolean useContentMerge, InheritableBoolean useSignedOffBy,
InheritableBoolean requireChangeId, String maxObjectSizeLimit,
SubmitType submitType, Project.State state,
SubmitType submitType, ProjectState state,
Map<String, Map<String, ConfigParameterValue>> pluginConfigValues,
AsyncCallback<ConfigInfo> cb) {
ConfigInput in = ConfigInput.create();
@@ -217,7 +218,7 @@ public class ProjectApi {
private final native void setSubmitTypeRaw(String t)
/*-{ if(t)this.submit_type=t; }-*/;
final void setState(Project.State s) {
final void setState(ProjectState s) {
setStateRaw(s.name());
}
private final native void setStateRaw(String s)

View File

@@ -14,6 +14,7 @@
package com.google.gerrit.client.projects;
import com.google.gerrit.extensions.api.projects.ProjectState;
import com.google.gerrit.reviewdb.client.Project;
import com.google.gwt.core.client.JavaScriptObject;
import com.google.gwt.user.client.ui.SuggestOracle;
@@ -28,8 +29,8 @@ public class ProjectInfo
public final native String name() /*-{ return this.name; }-*/;
public final native String description() /*-{ return this.description; }-*/;
public final Project.State state() {
return Project.State.valueOf(getStringState());
public final ProjectState state() {
return ProjectState.valueOf(getStringState());
}
private final native String getStringState() /*-{ return this.state; }-*/;

View File

@@ -5,6 +5,7 @@ gwt_module(
srcs = glob([SRC + 'client/**/*.java']),
gwtxml = SRC + 'ReviewDB.gwt.xml',
compile_deps = [
'//gerrit-extension-api:client',
'//lib:gwtorm',
'//lib:gwtorm_src'
],
@@ -15,6 +16,9 @@ java_library(
name = 'server',
srcs = glob([SRC + '**/*.java']),
resources = glob(['src/main/resources/**/*']),
deps = ['//lib:gwtorm'],
deps = [
'//gerrit-extension-api:api',
'//lib:gwtorm',
],
visibility = ['PUBLIC'],
)

View File

@@ -14,7 +14,7 @@
package com.google.gerrit.reviewdb.client;
import com.google.gerrit.reviewdb.client.Project.InheritableBoolean;
import com.google.gerrit.extensions.common.InheritableBoolean;
public class InheritedBoolean {

View File

@@ -14,6 +14,9 @@
package com.google.gerrit.reviewdb.client;
import com.google.gerrit.extensions.api.projects.ProjectState;
import com.google.gerrit.extensions.common.InheritableBoolean;
import com.google.gerrit.extensions.common.SubmitType;
import com.google.gwtorm.client.Column;
import com.google.gwtorm.client.StringKey;
@@ -65,32 +68,6 @@ public final class Project {
}
}
public static enum SubmitType {
FAST_FORWARD_ONLY,
MERGE_IF_NECESSARY,
REBASE_IF_NECESSARY,
MERGE_ALWAYS,
CHERRY_PICK
}
public static enum State {
ACTIVE,
READ_ONLY,
HIDDEN
}
public static enum InheritableBoolean {
TRUE,
FALSE,
INHERIT
}
protected NameKey name;
protected String description;
@@ -101,7 +78,7 @@ public final class Project {
protected SubmitType submitType;
protected State state;
protected ProjectState state;
protected NameKey parent;
@@ -123,7 +100,7 @@ public final class Project {
public Project(Project.NameKey nameKey) {
name = nameKey;
submitType = SubmitType.MERGE_IF_NECESSARY;
state = State.ACTIVE;
state = ProjectState.ACTIVE;
useContributorAgreements = InheritableBoolean.INHERIT;
useSignedOffBy = InheritableBoolean.INHERIT;
requireChangeID = InheritableBoolean.INHERIT;
@@ -194,11 +171,11 @@ public final class Project {
submitType = type;
}
public State getState() {
public ProjectState getState() {
return state;
}
public void setState(final State newState) {
public void setState(final ProjectState newState) {
state = newState;
}

View File

@@ -15,13 +15,13 @@
package com.google.gerrit.server.change;
import com.google.common.collect.Sets;
import com.google.gerrit.extensions.common.SubmitType;
import com.google.gerrit.extensions.restapi.AuthException;
import com.google.gerrit.extensions.restapi.BadRequestException;
import com.google.gerrit.extensions.restapi.ResourceConflictException;
import com.google.gerrit.extensions.restapi.RestReadView;
import com.google.gerrit.reviewdb.client.Change;
import com.google.gerrit.reviewdb.client.PatchSet;
import com.google.gerrit.reviewdb.client.Project;
import com.google.gerrit.reviewdb.client.RevId;
import com.google.gerrit.reviewdb.server.ReviewDb;
import com.google.gerrit.server.git.CodeReviewCommit;
@@ -59,7 +59,7 @@ public class Mergeable implements RestReadView<RevisionResource> {
private static final Logger log = LoggerFactory.getLogger(Mergeable.class);
public static class MergeableInfo {
public Project.SubmitType submitType;
public SubmitType submitType;
public boolean mergeable;
}
@@ -132,7 +132,7 @@ public class Mergeable implements RestReadView<RevisionResource> {
private boolean refresh(Change change,
final PatchSet ps,
Project.SubmitType type,
SubmitType type,
Repository git,
Map<String, Ref> refs,
final Ref ref) throws IOException, OrmException {

View File

@@ -17,11 +17,11 @@ package com.google.gerrit.server.change;
import static java.nio.charset.StandardCharsets.UTF_8;
import com.google.common.base.Objects;
import com.google.gerrit.extensions.common.SubmitType;
import com.google.gerrit.extensions.restapi.AuthException;
import com.google.gerrit.extensions.restapi.BadRequestException;
import com.google.gerrit.extensions.restapi.RestModifyView;
import com.google.gerrit.extensions.restapi.RestReadView;
import com.google.gerrit.reviewdb.client.Project.SubmitType;
import com.google.gerrit.reviewdb.server.ReviewDb;
import com.google.gerrit.rules.RulesCache;
import com.google.gerrit.server.change.TestSubmitRule.Filters;

View File

@@ -30,6 +30,7 @@ import com.google.gerrit.common.ChangeHooks;
import com.google.gerrit.common.Nullable;
import com.google.gerrit.common.data.Capable;
import com.google.gerrit.common.data.SubmitTypeRecord;
import com.google.gerrit.extensions.common.SubmitType;
import com.google.gerrit.reviewdb.client.Account;
import com.google.gerrit.reviewdb.client.Branch;
import com.google.gerrit.reviewdb.client.Change;
@@ -37,7 +38,6 @@ import com.google.gerrit.reviewdb.client.ChangeMessage;
import com.google.gerrit.reviewdb.client.PatchSet;
import com.google.gerrit.reviewdb.client.PatchSetApproval;
import com.google.gerrit.reviewdb.client.Project;
import com.google.gerrit.reviewdb.client.Project.SubmitType;
import com.google.gerrit.reviewdb.client.RefNames;
import com.google.gerrit.reviewdb.client.RevId;
import com.google.gerrit.reviewdb.server.ReviewDb;
@@ -242,7 +242,7 @@ public class MergeOp {
while (!toMerge.isEmpty()) {
toMergeNextTurn.clear();
final Set<SubmitType> submitTypes =
new HashSet<Project.SubmitType>(toMerge.keySet());
new HashSet<SubmitType>(toMerge.keySet());
for (final SubmitType submitType : submitTypes) {
if (reopen) {
branchUpdate = openBranch();
@@ -559,7 +559,7 @@ public class MergeOp {
}
}
final SubmitType submitType = getSubmitType(commit.getControl(), ps);
SubmitType submitType = getSubmitType(commit.getControl(), ps);
if (submitType == null) {
commits.put(changeId,
CodeReviewCommit.error(CommitMergeStatus.NO_SUBMIT_TYPE));

View File

@@ -39,12 +39,13 @@ import com.google.gerrit.common.data.Permission;
import com.google.gerrit.common.data.PermissionRule;
import com.google.gerrit.common.data.PermissionRule.Action;
import com.google.gerrit.common.data.RefConfigSection;
import com.google.gerrit.extensions.api.projects.ProjectState;
import com.google.gerrit.extensions.common.InheritableBoolean;
import com.google.gerrit.extensions.common.SubmitType;
import com.google.gerrit.reviewdb.client.AccountGroup;
import com.google.gerrit.reviewdb.client.RefNames;
import com.google.gerrit.reviewdb.client.AccountProjectWatch.NotifyType;
import com.google.gerrit.reviewdb.client.Project;
import com.google.gerrit.reviewdb.client.Project.State;
import com.google.gerrit.reviewdb.client.Project.SubmitType;
import com.google.gerrit.server.account.GroupBackend;
import com.google.gerrit.server.config.ConfigUtil;
import com.google.gerrit.server.config.PluginConfig;
@@ -142,8 +143,8 @@ public class ProjectConfig extends VersionedMetaData {
private static final SubmitType defaultSubmitAction =
SubmitType.MERGE_IF_NECESSARY;
private static final State defaultStateValue =
State.ACTIVE;
private static final ProjectState defaultStateValue =
ProjectState.ACTIVE;
private Project.NameKey projectName;
private Project project;
@@ -398,13 +399,13 @@ public class ProjectConfig extends VersionedMetaData {
}
p.setParentName(rc.getString(ACCESS, null, KEY_INHERIT_FROM));
p.setUseContributorAgreements(getEnum(rc, RECEIVE, null, KEY_REQUIRE_CONTRIBUTOR_AGREEMENT, Project.InheritableBoolean.INHERIT));
p.setUseSignedOffBy(getEnum(rc, RECEIVE, null, KEY_REQUIRE_SIGNED_OFF_BY, Project.InheritableBoolean.INHERIT));
p.setRequireChangeID(getEnum(rc, RECEIVE, null, KEY_REQUIRE_CHANGE_ID, Project.InheritableBoolean.INHERIT));
p.setUseContributorAgreements(getEnum(rc, RECEIVE, null, KEY_REQUIRE_CONTRIBUTOR_AGREEMENT, InheritableBoolean.INHERIT));
p.setUseSignedOffBy(getEnum(rc, RECEIVE, null, KEY_REQUIRE_SIGNED_OFF_BY, InheritableBoolean.INHERIT));
p.setRequireChangeID(getEnum(rc, RECEIVE, null, KEY_REQUIRE_CHANGE_ID, InheritableBoolean.INHERIT));
p.setMaxObjectSizeLimit(rc.getString(RECEIVE, null, KEY_MAX_OBJECT_SIZE_LIMIT));
p.setSubmitType(getEnum(rc, SUBMIT, null, KEY_ACTION, defaultSubmitAction));
p.setUseContentMerge(getEnum(rc, SUBMIT, null, KEY_MERGE_CONTENT, Project.InheritableBoolean.INHERIT));
p.setUseContentMerge(getEnum(rc, SUBMIT, null, KEY_MERGE_CONTENT, InheritableBoolean.INHERIT));
p.setState(getEnum(rc, PROJECT, null, KEY_STATE, defaultStateValue));
p.setDefaultDashboard(rc.getString(DASHBOARD, null, KEY_DEFAULT));
@@ -775,13 +776,13 @@ public class ProjectConfig extends VersionedMetaData {
}
set(rc, ACCESS, null, KEY_INHERIT_FROM, p.getParentName());
set(rc, RECEIVE, null, KEY_REQUIRE_CONTRIBUTOR_AGREEMENT, p.getUseContributorAgreements(), Project.InheritableBoolean.INHERIT);
set(rc, RECEIVE, null, KEY_REQUIRE_SIGNED_OFF_BY, p.getUseSignedOffBy(), Project.InheritableBoolean.INHERIT);
set(rc, RECEIVE, null, KEY_REQUIRE_CHANGE_ID, p.getRequireChangeID(), Project.InheritableBoolean.INHERIT);
set(rc, RECEIVE, null, KEY_REQUIRE_CONTRIBUTOR_AGREEMENT, p.getUseContributorAgreements(), InheritableBoolean.INHERIT);
set(rc, RECEIVE, null, KEY_REQUIRE_SIGNED_OFF_BY, p.getUseSignedOffBy(), InheritableBoolean.INHERIT);
set(rc, RECEIVE, null, KEY_REQUIRE_CHANGE_ID, p.getRequireChangeID(), InheritableBoolean.INHERIT);
set(rc, RECEIVE, null, KEY_MAX_OBJECT_SIZE_LIMIT, validMaxObjectSizeLimit(p.getMaxObjectSizeLimit()));
set(rc, SUBMIT, null, KEY_ACTION, p.getSubmitType(), defaultSubmitAction);
set(rc, SUBMIT, null, KEY_MERGE_CONTENT, p.getUseContentMerge(), Project.InheritableBoolean.INHERIT);
set(rc, SUBMIT, null, KEY_MERGE_CONTENT, p.getUseContentMerge(), InheritableBoolean.INHERIT);
set(rc, PROJECT, null, KEY_STATE, p.getState(), defaultStateValue);

View File

@@ -14,10 +14,10 @@
package com.google.gerrit.server.git.strategy;
import com.google.gerrit.extensions.common.SubmitType;
import com.google.gerrit.reviewdb.client.Branch;
import com.google.gerrit.reviewdb.client.Change;
import com.google.gerrit.reviewdb.client.PatchSetApproval;
import com.google.gerrit.reviewdb.client.Project.SubmitType;
import com.google.gerrit.reviewdb.server.ReviewDb;
import com.google.gerrit.server.ApprovalsUtil;
import com.google.gerrit.server.IdentifiedUser;

View File

@@ -14,8 +14,8 @@
package com.google.gerrit.server.git.strategy;
import com.google.gerrit.extensions.common.SubmitType;
import com.google.gerrit.reviewdb.client.Branch;
import com.google.gerrit.reviewdb.client.Project.SubmitType;
import com.google.gerrit.reviewdb.server.ReviewDb;
import com.google.gerrit.server.ApprovalsUtil;
import com.google.gerrit.server.GerritPersonIdent;

View File

@@ -22,6 +22,7 @@ import com.google.gerrit.common.data.PermissionRange;
import com.google.gerrit.common.data.RefConfigSection;
import com.google.gerrit.common.data.SubmitRecord;
import com.google.gerrit.common.data.SubmitTypeRecord;
import com.google.gerrit.extensions.common.SubmitType;
import com.google.gerrit.reviewdb.client.Account;
import com.google.gerrit.reviewdb.client.Change;
import com.google.gerrit.reviewdb.client.PatchSet;
@@ -640,7 +641,7 @@ public class ChangeControl {
String typeName = ((SymbolTerm)typeTerm).name();
try {
return SubmitTypeRecord.OK(
Project.SubmitType.valueOf(typeName.toUpperCase()));
SubmitType.valueOf(typeName.toUpperCase()));
} catch (IllegalArgumentException e) {
return logInvalidType(evaluator.getSubmitRule(), typeName);
}

View File

@@ -18,13 +18,13 @@ import com.google.common.base.Strings;
import com.google.common.collect.Iterables;
import com.google.common.collect.Maps;
import com.google.gerrit.extensions.common.ActionInfo;
import com.google.gerrit.extensions.common.InheritableBoolean;
import com.google.gerrit.extensions.common.SubmitType;
import com.google.gerrit.extensions.registration.DynamicMap;
import com.google.gerrit.extensions.registration.DynamicMap.Entry;
import com.google.gerrit.extensions.restapi.RestView;
import com.google.gerrit.extensions.webui.UiAction;
import com.google.gerrit.reviewdb.client.Project;
import com.google.gerrit.reviewdb.client.Project.InheritableBoolean;
import com.google.gerrit.reviewdb.client.Project.SubmitType;
import com.google.gerrit.server.config.AllProjectsNameProvider;
import com.google.gerrit.server.config.PluginConfig;
import com.google.gerrit.server.config.PluginConfigFactory;
@@ -48,7 +48,7 @@ public class ConfigInfo {
public InheritedBooleanInfo requireChangeId;
public MaxObjectSizeLimitInfo maxObjectSizeLimit;
public SubmitType submitType;
public Project.State state;
public com.google.gerrit.extensions.api.projects.ProjectState state;
public Map<String, Map<String, ConfigParameterInfo>> pluginConfig;
public Map<String, ActionInfo> actions;
@@ -108,7 +108,7 @@ public class ConfigInfo {
this.maxObjectSizeLimit = maxObjectSizeLimit;
this.submitType = p.getSubmitType();
this.state = p.getState() != Project.State.ACTIVE ? p.getState() : null;
this.state = p.getState() != com.google.gerrit.extensions.api.projects.ProjectState.ACTIVE ? p.getState() : null;
this.commentlinks = Maps.newLinkedHashMap();
for (CommentLinkInfo cl : projectState.getCommentLinks()) {

View File

@@ -20,6 +20,9 @@ import com.google.common.collect.Lists;
import com.google.gerrit.common.data.GlobalCapability;
import com.google.gerrit.common.errors.ProjectCreationFailedException;
import com.google.gerrit.extensions.annotations.RequiresCapability;
import com.google.gerrit.extensions.api.projects.ProjectInput;
import com.google.gerrit.extensions.common.InheritableBoolean;
import com.google.gerrit.extensions.common.SubmitType;
import com.google.gerrit.extensions.registration.DynamicSet;
import com.google.gerrit.extensions.restapi.BadRequestException;
import com.google.gerrit.extensions.restapi.ResourceConflictException;
@@ -30,14 +33,10 @@ import com.google.gerrit.extensions.restapi.TopLevelResource;
import com.google.gerrit.extensions.restapi.UnprocessableEntityException;
import com.google.gerrit.reviewdb.client.AccountGroup;
import com.google.gerrit.reviewdb.client.Project;
import com.google.gerrit.reviewdb.client.Project.InheritableBoolean;
import com.google.gerrit.reviewdb.client.Project.SubmitType;
import com.google.gerrit.server.CurrentUser;
import com.google.gerrit.server.git.ProjectConfig;
import com.google.gerrit.server.group.GroupsCollection;
import com.google.gerrit.server.project.CreateProject.Input;
import com.google.gerrit.server.project.ProjectJson.ProjectInfo;
import com.google.gerrit.server.project.PutConfig.ConfigValue;
import com.google.gerrit.server.validators.ProjectCreationValidationListener;
import com.google.gerrit.server.validators.ValidationException;
import com.google.inject.Inject;
@@ -48,27 +47,9 @@ import org.eclipse.jgit.errors.ConfigInvalidException;
import java.io.IOException;
import java.util.List;
import java.util.Map;
@RequiresCapability(GlobalCapability.CREATE_PROJECT)
public class CreateProject implements RestModifyView<TopLevelResource, Input> {
public static class Input {
public String name;
public String parent;
public String description;
public boolean permissionsOnly;
public boolean createEmptyCommit;
public SubmitType submitType;
public List<String> branches;
public List<String> owners;
public InheritableBoolean useContributorAgreements;
public InheritableBoolean useSignedOffBy;
public InheritableBoolean useContentMerge;
public InheritableBoolean requireChangeId;
public String maxObjectSizeLimit;
public Map<String, Map<String, ConfigValue>> pluginConfigValues;
}
public class CreateProject implements RestModifyView<TopLevelResource, ProjectInput> {
public static interface Factory {
CreateProject create(String name);
}
@@ -103,12 +84,12 @@ public class CreateProject implements RestModifyView<TopLevelResource, Input> {
}
@Override
public Response<ProjectInfo> apply(TopLevelResource resource, Input input)
public Response<ProjectInfo> apply(TopLevelResource resource, ProjectInput input)
throws BadRequestException, UnprocessableEntityException,
ResourceConflictException, ProjectCreationFailedException,
ResourceNotFoundException, IOException {
if (input == null) {
input = new Input();
input = new ProjectInput();
}
if (input.name != null && !name.equals(input.name)) {
throw new BadRequestException("name must match URL");

View File

@@ -14,10 +14,10 @@
package com.google.gerrit.server.project;
import com.google.gerrit.extensions.common.InheritableBoolean;
import com.google.gerrit.extensions.common.SubmitType;
import com.google.gerrit.reviewdb.client.AccountGroup;
import com.google.gerrit.reviewdb.client.Project;
import com.google.gerrit.reviewdb.client.Project.InheritableBoolean;
import com.google.gerrit.reviewdb.client.Project.SubmitType;
import java.util.List;

View File

@@ -22,12 +22,12 @@ import com.google.gerrit.common.data.GroupReference;
import com.google.gerrit.common.data.Permission;
import com.google.gerrit.common.data.PermissionRule;
import com.google.gerrit.common.errors.ProjectCreationFailedException;
import com.google.gerrit.extensions.common.SubmitType;
import com.google.gerrit.extensions.events.NewProjectCreatedListener;
import com.google.gerrit.extensions.registration.DynamicSet;
import com.google.gerrit.reviewdb.client.AccountGroup;
import com.google.gerrit.reviewdb.client.Project;
import com.google.gerrit.reviewdb.client.RefNames;
import com.google.gerrit.reviewdb.client.Project.SubmitType;
import com.google.gerrit.server.GerritPersonIdent;
import com.google.gerrit.server.IdentifiedUser;
import com.google.gerrit.server.account.GroupBackend;

View File

@@ -232,7 +232,8 @@ public class ProjectControl {
}
private boolean isHidden() {
return getProject().getState().equals(Project.State.HIDDEN);
return getProject().getState().equals(
com.google.gerrit.extensions.api.projects.ProjectState.HIDDEN);
}
/** Can this user see this project exists? */

View File

@@ -15,6 +15,7 @@
package com.google.gerrit.server.project;
import com.google.common.base.Strings;
import com.google.gerrit.extensions.api.projects.ProjectState;
import com.google.gerrit.extensions.restapi.Url;
import com.google.gerrit.reviewdb.client.Project;
import com.google.gerrit.server.config.AllProjectsName;
@@ -52,7 +53,7 @@ public class ProjectJson {
public String name;
public String parent;
public String description;
public Project.State state;
public ProjectState state;
public Map<String, String> branches;
void finish() {

View File

@@ -14,6 +14,7 @@
package com.google.gerrit.server.project;
import com.google.gerrit.extensions.api.projects.ProjectState;
import com.google.gerrit.extensions.restapi.RestResource;
import com.google.gerrit.extensions.restapi.RestView;
import com.google.gerrit.reviewdb.client.Project;
@@ -41,7 +42,7 @@ public class ProjectResource implements RestResource {
return control.getProject().getNameKey();
}
public Project.State getState() {
public ProjectState getState() {
return control.getProject().getState();
}

View File

@@ -29,9 +29,9 @@ import com.google.gerrit.common.data.LabelType;
import com.google.gerrit.common.data.LabelTypes;
import com.google.gerrit.common.data.Permission;
import com.google.gerrit.common.data.PermissionRule;
import com.google.gerrit.extensions.common.InheritableBoolean;
import com.google.gerrit.reviewdb.client.AccountGroup;
import com.google.gerrit.reviewdb.client.Project;
import com.google.gerrit.reviewdb.client.Project.InheritableBoolean;
import com.google.gerrit.reviewdb.client.RefNames;
import com.google.gerrit.rules.PrologEnvironment;
import com.google.gerrit.rules.RulesCache;

View File

@@ -17,6 +17,9 @@ package com.google.gerrit.server.project;
import com.google.common.base.CharMatcher;
import com.google.common.base.Joiner;
import com.google.common.base.Strings;
import com.google.gerrit.extensions.api.projects.ProjectInput.ConfigValue;
import com.google.gerrit.extensions.common.InheritableBoolean;
import com.google.gerrit.extensions.common.SubmitType;
import com.google.gerrit.extensions.registration.DynamicMap;
import com.google.gerrit.extensions.restapi.BadRequestException;
import com.google.gerrit.extensions.restapi.ResourceConflictException;
@@ -24,8 +27,6 @@ import com.google.gerrit.extensions.restapi.ResourceNotFoundException;
import com.google.gerrit.extensions.restapi.RestModifyView;
import com.google.gerrit.extensions.restapi.RestView;
import com.google.gerrit.reviewdb.client.Project;
import com.google.gerrit.reviewdb.client.Project.InheritableBoolean;
import com.google.gerrit.reviewdb.client.Project.SubmitType;
import com.google.gerrit.server.CurrentUser;
import com.google.gerrit.server.config.AllProjectsNameProvider;
import com.google.gerrit.server.config.PluginConfig;
@@ -52,10 +53,6 @@ import java.util.Map.Entry;
public class PutConfig implements RestModifyView<ProjectResource, Input> {
private static final Logger log = LoggerFactory.getLogger(PutConfig.class);
public static class ConfigValue {
public String value;
public List<String> values;
}
public static class Input {
public String description;
public InheritableBoolean useContributorAgreements;
@@ -64,7 +61,7 @@ public class PutConfig implements RestModifyView<ProjectResource, Input> {
public InheritableBoolean requireChangeId;
public String maxObjectSizeLimit;
public SubmitType submitType;
public Project.State state;
public com.google.gerrit.extensions.api.projects.ProjectState state;
public Map<String, Map<String, ConfigValue>> pluginConfigValues;
}

View File

@@ -14,14 +14,14 @@
package com.google.gerrit.server.project;
import com.google.gerrit.extensions.api.projects.ProjectInput;
import com.google.gerrit.extensions.restapi.ResourceConflictException;
import com.google.gerrit.extensions.restapi.Response;
import com.google.gerrit.extensions.restapi.RestModifyView;
import com.google.gerrit.server.project.CreateProject.Input;
public class PutProject implements RestModifyView<ProjectResource, Input> {
public class PutProject implements RestModifyView<ProjectResource, ProjectInput> {
@Override
public Response<?> apply(ProjectResource resource, Input input)
public Response<?> apply(ProjectResource resource, ProjectInput input)
throws ResourceConflictException {
throw new ResourceConflictException("Project \"" + resource.getName()
+ "\" already exists");

View File

@@ -22,7 +22,7 @@ import com.google.gerrit.common.data.PermissionRange;
import com.google.gerrit.common.data.PermissionRule;
import com.google.gerrit.common.data.RefConfigSection;
import com.google.gerrit.common.errors.InvalidNameException;
import com.google.gerrit.reviewdb.client.Project;
import com.google.gerrit.extensions.api.projects.ProjectState;
import com.google.gerrit.reviewdb.client.RefNames;
import com.google.gerrit.server.CurrentUser;
import com.google.gerrit.server.IdentifiedUser;
@@ -207,12 +207,12 @@ public class RefControl {
public boolean canWrite() {
return getProjectControl().getProject().getState().equals(
Project.State.ACTIVE);
ProjectState.ACTIVE);
}
public boolean canRead() {
return getProjectControl().getProject().getState().equals(
Project.State.READ_ONLY) || canWrite();
ProjectState.READ_ONLY) || canWrite();
}
private boolean canPushWithForce() {

View File

@@ -15,14 +15,14 @@
package com.google.gerrit.server.query.change;
import com.google.common.base.Objects;
import com.google.gerrit.reviewdb.client.Project.SubmitType;
import com.google.gerrit.extensions.common.SubmitType;
import org.eclipse.jgit.lib.ObjectId;
import java.io.Serializable;
public class ConflictKey implements Serializable {
private static final long serialVersionUID = 1L;
private static final long serialVersionUID = 2L;
private final ObjectId commit;
private final ObjectId otherCommit;

View File

@@ -17,8 +17,8 @@ package com.google.gerrit.server.query.change;
import com.google.common.collect.Lists;
import com.google.common.collect.Sets;
import com.google.gerrit.common.data.SubmitTypeRecord;
import com.google.gerrit.extensions.common.SubmitType;
import com.google.gerrit.reviewdb.client.Change;
import com.google.gerrit.reviewdb.client.Project.SubmitType;
import com.google.gerrit.reviewdb.server.ReviewDb;
import com.google.gerrit.server.git.CodeReviewCommit;
import com.google.gerrit.server.git.MergeException;

View File

@@ -28,9 +28,9 @@ import com.google.gerrit.common.data.LabelValue;
import com.google.gerrit.common.data.Permission;
import com.google.gerrit.common.data.PermissionRule;
import com.google.gerrit.common.data.PermissionRule.Action;
import com.google.gerrit.extensions.common.InheritableBoolean;
import com.google.gerrit.reviewdb.client.Project;
import com.google.gerrit.reviewdb.client.RefNames;
import com.google.gerrit.reviewdb.client.Project.InheritableBoolean;
import com.google.gerrit.server.GerritPersonIdent;
import com.google.gerrit.server.config.AllProjectsName;
import com.google.gerrit.server.extensions.events.GitReferenceUpdated;

View File

@@ -31,11 +31,12 @@ import com.google.gerrit.common.data.GroupReference;
import com.google.gerrit.common.data.LabelType;
import com.google.gerrit.common.data.Permission;
import com.google.gerrit.common.data.PermissionRule;
import com.google.gerrit.extensions.common.InheritableBoolean;
import com.google.gerrit.extensions.common.SubmitType;
import com.google.gerrit.reviewdb.client.AccountGroup;
import com.google.gerrit.reviewdb.client.RefNames;
import com.google.gerrit.reviewdb.client.PatchSetApproval.LabelId;
import com.google.gerrit.reviewdb.client.Project;
import com.google.gerrit.reviewdb.client.Project.InheritableBoolean;
import com.google.gerrit.reviewdb.client.SystemConfig;
import com.google.gerrit.reviewdb.server.ReviewDb;
import com.google.gerrit.server.GerritPersonIdent;
@@ -213,16 +214,16 @@ class Schema_53 extends SchemaVersion {
switch (rs.getString("submit_type").charAt(0)) {
case 'F':
project.setSubmitType(Project.SubmitType.FAST_FORWARD_ONLY);
project.setSubmitType(SubmitType.FAST_FORWARD_ONLY);
break;
case 'M':
project.setSubmitType(Project.SubmitType.MERGE_IF_NECESSARY);
project.setSubmitType(SubmitType.MERGE_IF_NECESSARY);
break;
case 'A':
project.setSubmitType(Project.SubmitType.MERGE_ALWAYS);
project.setSubmitType(SubmitType.MERGE_ALWAYS);
break;
case 'C':
project.setSubmitType(Project.SubmitType.CHERRY_PICK);
project.setSubmitType(SubmitType.CHERRY_PICK);
break;
default:
throw new OrmException("Unsupported submit_type="
@@ -238,8 +239,8 @@ class Schema_53 extends SchemaVersion {
private static InheritableBoolean asInheritableBoolean(ResultSet rs, String col)
throws SQLException {
return "Y".equals(rs.getString(col))
? Project.InheritableBoolean.TRUE
: Project.InheritableBoolean.INHERIT;
? InheritableBoolean.TRUE
: InheritableBoolean.INHERIT;
}
private void readOldRefRights(ReviewDb db) throws SQLException {

View File

@@ -14,7 +14,7 @@
package gerrit;
import com.google.gerrit.reviewdb.client.Project.SubmitType;
import com.google.gerrit.extensions.common.SubmitType;
import com.google.gerrit.rules.StoredValues;
import com.google.gerrit.server.project.ChangeControl;

View File

@@ -28,6 +28,7 @@ import com.google.common.collect.Lists;
import com.google.common.hash.Hashing;
import com.google.gerrit.common.Nullable;
import com.google.gerrit.extensions.api.changes.ReviewInput;
import com.google.gerrit.extensions.api.projects.ProjectInput;
import com.google.gerrit.extensions.restapi.TopLevelResource;
import com.google.gerrit.lifecycle.LifecycleManager;
import com.google.gerrit.reviewdb.client.Account;
@@ -833,7 +834,7 @@ public abstract class AbstractQueryChangesTest {
protected TestRepository<InMemoryRepository> createProject(String name)
throws Exception {
CreateProject create = projectFactory.create(name);
create.apply(TLR, new CreateProject.Input());
create.apply(TLR, new ProjectInput());
return new TestRepository<InMemoryRepository>(
repoManager.openRepository(new Project.NameKey(name)));
}

View File

@@ -46,6 +46,7 @@ java_test(
),
deps = [
':sshd',
'//gerrit-extension-api:api',
'//gerrit-server:server',
'//lib:guava',
'//lib:junit',

View File

@@ -21,16 +21,17 @@ import com.google.common.collect.Lists;
import com.google.gerrit.common.data.GlobalCapability;
import com.google.gerrit.common.errors.ProjectCreationFailedException;
import com.google.gerrit.extensions.annotations.RequiresCapability;
import com.google.gerrit.extensions.api.projects.ProjectInput;
import com.google.gerrit.extensions.api.projects.ProjectInput.ConfigValue;
import com.google.gerrit.extensions.common.InheritableBoolean;
import com.google.gerrit.extensions.common.SubmitType;
import com.google.gerrit.extensions.restapi.RestApiException;
import com.google.gerrit.extensions.restapi.TopLevelResource;
import com.google.gerrit.reviewdb.client.AccountGroup;
import com.google.gerrit.reviewdb.client.Project;
import com.google.gerrit.reviewdb.client.Project.InheritableBoolean;
import com.google.gerrit.reviewdb.client.Project.SubmitType;
import com.google.gerrit.server.project.CreateProject;
import com.google.gerrit.server.project.NoSuchProjectException;
import com.google.gerrit.server.project.ProjectControl;
import com.google.gerrit.server.project.PutConfig.ConfigValue;
import com.google.gerrit.server.project.SuggestParentCandidates;
import com.google.gerrit.sshd.CommandMetaData;
import com.google.gerrit.sshd.SshCommand;
@@ -148,7 +149,7 @@ final class CreateProjectCommand extends SshCommand {
throw new UnloggedFailure(1, "fatal: Project name is required.");
}
CreateProject.Input input = new CreateProject.Input();
ProjectInput input = new ProjectInput();
input.name = projectName;
if (ownerIds != null) {
input.owners = Lists.transform(ownerIds,

View File

@@ -16,10 +16,10 @@ package com.google.gerrit.sshd.commands;
import com.google.gerrit.common.data.GlobalCapability;
import com.google.gerrit.extensions.annotations.RequiresCapability;
import com.google.gerrit.extensions.api.projects.ProjectState;
import com.google.gerrit.extensions.common.InheritableBoolean;
import com.google.gerrit.extensions.common.SubmitType;
import com.google.gerrit.reviewdb.client.Project;
import com.google.gerrit.reviewdb.client.Project.InheritableBoolean;
import com.google.gerrit.reviewdb.client.Project.State;
import com.google.gerrit.reviewdb.client.Project.SubmitType;
import com.google.gerrit.server.git.MetaDataUpdate;
import com.google.gerrit.server.git.ProjectConfig;
import com.google.gerrit.server.project.ProjectCache;
@@ -106,7 +106,7 @@ final class SetProjectCommand extends SshCommand {
}
@Option(name = "--project-state", aliases = {"--ps"}, usage = "project's visibility state")
private State state;
private ProjectState state;
@Option(name = "--max-object-size-limit", usage = "max Git object size for this project")
private String maxObjectSizeLimit;

View File

@@ -14,11 +14,11 @@
package com.google.gerrit.sshd.commands;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
import com.google.gerrit.server.project.PutConfig.ConfigValue;
import com.google.gerrit.extensions.api.projects.ProjectInput.ConfigValue;
import org.junit.Before;
import org.junit.Test;