Line data Source code
1 : // Copyright (C) 2014 The Android Open Source Project 2 : // 3 : // Licensed under the Apache License, Version 2.0 (the "License"); 4 : // you may not use this file except in compliance with the License. 5 : // You may obtain a copy of the License at 6 : // 7 : // http://www.apache.org/licenses/LICENSE-2.0 8 : // 9 : // Unless required by applicable law or agreed to in writing, software 10 : // distributed under the License is distributed on an "AS IS" BASIS, 11 : // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 : // See the License for the specific language governing permissions and 13 : // limitations under the License. 14 : 15 : package com.google.gerrit.server.change; 16 : 17 : import com.google.gerrit.extensions.restapi.RestResource; 18 : import com.google.gerrit.extensions.restapi.RestView; 19 : import com.google.gerrit.server.edit.ChangeEdit; 20 : import com.google.inject.TypeLiteral; 21 : 22 : /** 23 : * Represents change edit resource, that is actually two kinds of resources: 24 : * 25 : * <ul> 26 : * <li>the change edit itself 27 : * <li>a path within the edit 28 : * </ul> 29 : * 30 : * distinguished by whether path is null or not. 31 : */ 32 : public class ChangeEditResource implements RestResource { 33 152 : public static final TypeLiteral<RestView<ChangeEditResource>> CHANGE_EDIT_KIND = 34 152 : new TypeLiteral<>() {}; 35 : 36 : private final ChangeResource change; 37 : private final ChangeEdit edit; 38 : private final String path; 39 : 40 4 : public ChangeEditResource(ChangeResource change, ChangeEdit edit, String path) { 41 4 : this.change = change; 42 4 : this.edit = edit; 43 4 : this.path = path; 44 4 : } 45 : 46 : // TODO(davido): Make this cacheable. 47 : // Should just depend on the SHA-1 of the edit itself. 48 : public boolean isCacheable() { 49 0 : return false; 50 : } 51 : 52 : public ChangeResource getChangeResource() { 53 4 : return change; 54 : } 55 : 56 : public ChangeEdit getChangeEdit() { 57 4 : return edit; 58 : } 59 : 60 : public String getPath() { 61 4 : return path; 62 : } 63 : }