From 2a83139d608b4ecffe02e48b05a763816fbd03f5 Mon Sep 17 00:00:00 2001 From: Urs Wolfer Date: Sun, 27 Apr 2014 21:12:41 +0200 Subject: [PATCH] Add extensions-api for accounts It's an initial skeleton only at the moment. Methods for getting an account and starChange / unstarChange are available which will also be implemented in the upcoming REST client. Change-Id: I1a8d0cbe9106a1bccdad29cbb1c9a313a844909a --- .../gerrit/extensions/api/GerritApi.java | 7 +++ .../extensions/api/accounts/AccountApi.java | 47 +++++++++++++++++++ .../extensions/api/accounts/Accounts.java | 39 +++++++++++++++ 3 files changed, 93 insertions(+) create mode 100644 gerrit-extension-api/src/main/java/com/google/gerrit/extensions/api/accounts/AccountApi.java create mode 100644 gerrit-extension-api/src/main/java/com/google/gerrit/extensions/api/accounts/Accounts.java diff --git a/gerrit-extension-api/src/main/java/com/google/gerrit/extensions/api/GerritApi.java b/gerrit-extension-api/src/main/java/com/google/gerrit/extensions/api/GerritApi.java index d071e2100e..cc5807b85b 100644 --- a/gerrit-extension-api/src/main/java/com/google/gerrit/extensions/api/GerritApi.java +++ b/gerrit-extension-api/src/main/java/com/google/gerrit/extensions/api/GerritApi.java @@ -14,11 +14,13 @@ package com.google.gerrit.extensions.api; +import com.google.gerrit.extensions.api.accounts.Accounts; import com.google.gerrit.extensions.api.changes.Changes; import com.google.gerrit.extensions.api.projects.Projects; import com.google.gerrit.extensions.restapi.NotImplementedException; public interface GerritApi { + public Accounts accounts(); public Changes changes(); public Projects projects(); @@ -27,6 +29,11 @@ public interface GerritApi { * when adding new methods to the interface. **/ public class NotImplemented implements GerritApi { + @Override + public Accounts accounts() { + throw new NotImplementedException(); + } + @Override public Changes changes() { throw new NotImplementedException(); diff --git a/gerrit-extension-api/src/main/java/com/google/gerrit/extensions/api/accounts/AccountApi.java b/gerrit-extension-api/src/main/java/com/google/gerrit/extensions/api/accounts/AccountApi.java new file mode 100644 index 0000000000..d571cfd3db --- /dev/null +++ b/gerrit-extension-api/src/main/java/com/google/gerrit/extensions/api/accounts/AccountApi.java @@ -0,0 +1,47 @@ +// 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.accounts; + +import com.google.gerrit.extensions.common.AccountInfo; +import com.google.gerrit.extensions.restapi.NotImplementedException; +import com.google.gerrit.extensions.restapi.RestApiException; + +public interface AccountApi { + AccountInfo get() throws RestApiException; + + void starChange(String id) throws RestApiException; + void unstarChange(String id) throws RestApiException; + + /** + * A default implementation which allows source compatibility + * when adding new methods to the interface. + **/ + public class NotImplemented implements AccountApi { + @Override + public AccountInfo get() throws RestApiException { + throw new NotImplementedException(); + } + + @Override + public void starChange(String id) throws RestApiException { + throw new NotImplementedException(); + } + + @Override + public void unstarChange(String id) throws RestApiException { + throw new NotImplementedException(); + } + } +} diff --git a/gerrit-extension-api/src/main/java/com/google/gerrit/extensions/api/accounts/Accounts.java b/gerrit-extension-api/src/main/java/com/google/gerrit/extensions/api/accounts/Accounts.java new file mode 100644 index 0000000000..749b12aa41 --- /dev/null +++ b/gerrit-extension-api/src/main/java/com/google/gerrit/extensions/api/accounts/Accounts.java @@ -0,0 +1,39 @@ +// 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.accounts; + +import com.google.gerrit.extensions.restapi.NotImplementedException; +import com.google.gerrit.extensions.restapi.RestApiException; + +public interface Accounts { + AccountApi id(String id) throws RestApiException; + AccountApi self() throws RestApiException; + + /** + * A default implementation which allows source compatibility + * when adding new methods to the interface. + **/ + public class NotImplemented implements Accounts { + @Override + public AccountApi id(String id) throws RestApiException { + throw new NotImplementedException(); + } + + @Override + public AccountApi self() throws RestApiException { + throw new NotImplementedException(); + } + } +}