SetHead: Move static Input to separate file in extension API
Change-Id: I64d259dacfa8e70f10b4689e144d7ee31ab91ee3
This commit is contained in:
@@ -0,0 +1,21 @@
|
||||
// Copyright (C) 2017 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;
|
||||
|
||||
import com.google.gerrit.extensions.restapi.DefaultInput;
|
||||
|
||||
public class HeadInput {
|
||||
@DefaultInput public String ref;
|
||||
}
|
||||
@@ -15,11 +15,11 @@
|
||||
package com.google.gerrit.server.project;
|
||||
|
||||
import com.google.common.base.Strings;
|
||||
import com.google.gerrit.extensions.common.HeadInput;
|
||||
import com.google.gerrit.extensions.events.HeadUpdatedListener;
|
||||
import com.google.gerrit.extensions.registration.DynamicSet;
|
||||
import com.google.gerrit.extensions.restapi.AuthException;
|
||||
import com.google.gerrit.extensions.restapi.BadRequestException;
|
||||
import com.google.gerrit.extensions.restapi.DefaultInput;
|
||||
import com.google.gerrit.extensions.restapi.ResourceNotFoundException;
|
||||
import com.google.gerrit.extensions.restapi.RestModifyView;
|
||||
import com.google.gerrit.extensions.restapi.UnprocessableEntityException;
|
||||
@@ -31,7 +31,6 @@ import com.google.gerrit.server.git.GitRepositoryManager;
|
||||
import com.google.gerrit.server.permissions.PermissionBackend;
|
||||
import com.google.gerrit.server.permissions.PermissionBackendException;
|
||||
import com.google.gerrit.server.permissions.RefPermission;
|
||||
import com.google.gerrit.server.project.SetHead.Input;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Provider;
|
||||
import com.google.inject.Singleton;
|
||||
@@ -46,13 +45,9 @@ import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
@Singleton
|
||||
public class SetHead implements RestModifyView<ProjectResource, Input> {
|
||||
public class SetHead implements RestModifyView<ProjectResource, HeadInput> {
|
||||
private static final Logger log = LoggerFactory.getLogger(SetHead.class);
|
||||
|
||||
public static class Input {
|
||||
@DefaultInput public String ref;
|
||||
}
|
||||
|
||||
private final GitRepositoryManager repoManager;
|
||||
private final Provider<IdentifiedUser> identifiedUser;
|
||||
private final DynamicSet<HeadUpdatedListener> headUpdatedListeners;
|
||||
@@ -71,7 +66,7 @@ public class SetHead implements RestModifyView<ProjectResource, Input> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String apply(ProjectResource rsrc, Input input)
|
||||
public String apply(ProjectResource rsrc, HeadInput input)
|
||||
throws AuthException, ResourceNotFoundException, BadRequestException,
|
||||
UnprocessableEntityException, IOException, PermissionBackendException {
|
||||
if (input == null || Strings.isNullOrEmpty(input.ref)) {
|
||||
|
||||
@@ -14,11 +14,11 @@
|
||||
|
||||
package com.google.gerrit.sshd.commands;
|
||||
|
||||
import com.google.gerrit.extensions.common.HeadInput;
|
||||
import com.google.gerrit.extensions.restapi.UnprocessableEntityException;
|
||||
import com.google.gerrit.server.project.ProjectResource;
|
||||
import com.google.gerrit.server.project.ProjectState;
|
||||
import com.google.gerrit.server.project.SetHead;
|
||||
import com.google.gerrit.server.project.SetHead.Input;
|
||||
import com.google.gerrit.sshd.CommandMetaData;
|
||||
import com.google.gerrit.sshd.SshCommand;
|
||||
import com.google.inject.Inject;
|
||||
@@ -43,7 +43,7 @@ public class SetHeadCommand extends SshCommand {
|
||||
|
||||
@Override
|
||||
protected void run() throws Exception {
|
||||
Input input = new SetHead.Input();
|
||||
HeadInput input = new HeadInput();
|
||||
input.ref = newHead;
|
||||
try {
|
||||
setHead.apply(new ProjectResource(project, user), input);
|
||||
|
||||
Reference in New Issue
Block a user