Merge "Removed AccessApi and AccessApi Impl"
This commit is contained in:
commit
937854a833
|
@ -1,34 +0,0 @@
|
|||
// Copyright (C) 2016 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.api.access.ProjectAccessInfo;
|
||||
import com.google.gerrit.extensions.restapi.NotImplementedException;
|
||||
import com.google.gerrit.extensions.restapi.RestApiException;
|
||||
|
||||
public interface AccessApi {
|
||||
ProjectAccessInfo get() throws RestApiException;
|
||||
|
||||
/**
|
||||
* A default implementation which allows source compatibility
|
||||
* when adding new methods to the interface.
|
||||
**/
|
||||
class NotImplemented implements AccessApi {
|
||||
@Override
|
||||
public ProjectAccessInfo get() throws RestApiException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,50 +0,0 @@
|
|||
// Copyright (C) 2016 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.server.api.projects;
|
||||
|
||||
import com.google.gerrit.extensions.api.projects.AccessApi;
|
||||
import com.google.gerrit.extensions.api.access.ProjectAccessInfo;
|
||||
import com.google.gerrit.extensions.restapi.RestApiException;
|
||||
import com.google.gerrit.server.project.GetAccess;
|
||||
import com.google.gerrit.server.project.ProjectResource;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.assistedinject.Assisted;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
public class AccessApiImpl implements AccessApi {
|
||||
interface Factory {
|
||||
AccessApiImpl create(ProjectResource project);
|
||||
}
|
||||
|
||||
private final ProjectResource project;
|
||||
private final GetAccess getAccess;
|
||||
|
||||
@Inject
|
||||
AccessApiImpl(GetAccess getAccess,
|
||||
@Assisted ProjectResource project) {
|
||||
this.project = project;
|
||||
this.getAccess = getAccess;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ProjectAccessInfo get() throws RestApiException {
|
||||
try {
|
||||
return getAccess.apply(project);
|
||||
} catch (IOException e) {
|
||||
throw new RestApiException("Cannot get access rights", e);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -26,6 +26,5 @@ public class Module extends FactoryModule {
|
|||
factory(TagApiImpl.Factory.class);
|
||||
factory(ProjectApiImpl.Factory.class);
|
||||
factory(ChildProjectApiImpl.Factory.class);
|
||||
factory(AccessApiImpl.Factory.class);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -35,6 +35,7 @@ import com.google.gerrit.extensions.restapi.TopLevelResource;
|
|||
import com.google.gerrit.server.CurrentUser;
|
||||
import com.google.gerrit.server.project.ChildProjectsCollection;
|
||||
import com.google.gerrit.server.project.CreateProject;
|
||||
import com.google.gerrit.server.project.GetAccess;
|
||||
import com.google.gerrit.server.project.GetDescription;
|
||||
import com.google.gerrit.server.project.ListBranches;
|
||||
import com.google.gerrit.server.project.ListChildProjects;
|
||||
|
@ -71,7 +72,7 @@ public class ProjectApiImpl implements ProjectApi {
|
|||
private final String name;
|
||||
private final BranchApiImpl.Factory branchApi;
|
||||
private final TagApiImpl.Factory tagApi;
|
||||
private final AccessApiImpl.Factory accessApi;
|
||||
private final GetAccess getAccess;
|
||||
private final Provider<ListBranches> listBranchesProvider;
|
||||
private final Provider<ListTags> listTagsProvider;
|
||||
|
||||
|
@ -87,13 +88,13 @@ public class ProjectApiImpl implements ProjectApi {
|
|||
ProjectJson projectJson,
|
||||
BranchApiImpl.Factory branchApiFactory,
|
||||
TagApiImpl.Factory tagApiFactory,
|
||||
AccessApiImpl.Factory accessApiFactory,
|
||||
GetAccess getAccess,
|
||||
Provider<ListBranches> listBranchesProvider,
|
||||
Provider<ListTags> listTagsProvider,
|
||||
@Assisted ProjectResource project) {
|
||||
this(user, createProjectFactory, projectApi, projects, getDescription,
|
||||
putDescription, childApi, children, projectJson, branchApiFactory,
|
||||
tagApiFactory, accessApiFactory, listBranchesProvider, listTagsProvider,
|
||||
tagApiFactory, getAccess, listBranchesProvider, listTagsProvider,
|
||||
project, null);
|
||||
}
|
||||
|
||||
|
@ -109,13 +110,13 @@ public class ProjectApiImpl implements ProjectApi {
|
|||
ProjectJson projectJson,
|
||||
BranchApiImpl.Factory branchApiFactory,
|
||||
TagApiImpl.Factory tagApiFactory,
|
||||
AccessApiImpl.Factory accessApiFactory,
|
||||
GetAccess getAccess,
|
||||
Provider<ListBranches> listBranchesProvider,
|
||||
Provider<ListTags> listTagsProvider,
|
||||
@Assisted String name) {
|
||||
this(user, createProjectFactory, projectApi, projects, getDescription,
|
||||
putDescription, childApi, children, projectJson, branchApiFactory,
|
||||
tagApiFactory, accessApiFactory, listBranchesProvider, listTagsProvider,
|
||||
tagApiFactory, getAccess, listBranchesProvider, listTagsProvider,
|
||||
null, name);
|
||||
}
|
||||
|
||||
|
@ -130,7 +131,7 @@ public class ProjectApiImpl implements ProjectApi {
|
|||
ProjectJson projectJson,
|
||||
BranchApiImpl.Factory branchApiFactory,
|
||||
TagApiImpl.Factory tagApiFactory,
|
||||
AccessApiImpl.Factory accessApiFactory,
|
||||
GetAccess getAccess,
|
||||
Provider<ListBranches> listBranchesProvider,
|
||||
Provider<ListTags> listTagsProvider,
|
||||
ProjectResource project,
|
||||
|
@ -148,7 +149,7 @@ public class ProjectApiImpl implements ProjectApi {
|
|||
this.name = name;
|
||||
this.branchApi = branchApiFactory;
|
||||
this.tagApi = tagApiFactory;
|
||||
this.accessApi = accessApiFactory;
|
||||
this.getAccess = getAccess;
|
||||
this.listBranchesProvider = listBranchesProvider;
|
||||
this.listTagsProvider = listTagsProvider;
|
||||
}
|
||||
|
@ -191,7 +192,11 @@ public class ProjectApiImpl implements ProjectApi {
|
|||
|
||||
@Override
|
||||
public ProjectAccessInfo access() throws RestApiException {
|
||||
return accessApi.create(checkExists()).get();
|
||||
try {
|
||||
return getAccess.apply(checkExists());
|
||||
} catch (IOException e) {
|
||||
throw new RestApiException("Cannot get access rights", e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
Loading…
Reference in New Issue