Implement reviewer access via REST

This change enables users to request details about a reviewer given a
change and a reviewer id.  The returned result is a map including the
reviewers:
* kind (gerritcodereview#reviewer)
* id
* email
* name (if provided)

Example:
curl -s localhost:8080/
    changes/blah~master~I2933f24c1fc0d7f44a34bb1dc7a3242fdfd29028/
    reviewers/1000000

{
  "kind": "gerritcodereview#reviewer",
  "id": "1000000",
  "email": "cco3%40android.com"
}

Change-Id: I3e164527d5e4cc5707577b31a8618a7ae9f7b098
This commit is contained in:
Conley Owens
2012-11-19 14:56:58 -08:00
parent 07600e253d
commit d26313ae45
4 changed files with 95 additions and 15 deletions

View File

@@ -0,0 +1,38 @@
// Copyright (C) 2012 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.change;
import com.google.gerrit.reviewdb.client.Account;
public class ReviewerJson {
ReviewerJson() {
}
public ReviewerInfo format(ReviewerResource reviewerResource) {
ReviewerInfo reviewerInfo = new ReviewerInfo();
Account account = reviewerResource.getAccount();
reviewerInfo.id = account.getId().toString();
reviewerInfo.email = account.getPreferredEmail();
reviewerInfo.name = account.getFullName();
return reviewerInfo;
}
public static class ReviewerInfo {
final String kind = "gerritcodereview#reviewer";
String id;
String email;
String name;
}
}