1 /* 2 * Copyright 2017 LINE Corporation 3 * 4 * LINE Corporation licenses this file to you under the Apache License, 5 * version 2.0 (the "License"); you may not use this file except in compliance 6 * with the License. You may obtain a copy of the License at: 7 * 8 * https://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 12 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 * License for the specific language governing permissions and limitations 14 * under the License. 15 */ 16 17 package com.linecorp.centraldogma.server.storage.project; 18 19 import static com.linecorp.centraldogma.server.storage.project.ProjectUtil.internalRepos; 20 import static java.util.Objects.requireNonNull; 21 22 import java.util.List; 23 24 import javax.annotation.Nullable; 25 26 import com.google.common.base.Ascii; 27 28 import com.linecorp.centraldogma.common.Author; 29 import com.linecorp.centraldogma.server.metadata.ProjectMetadata; 30 import com.linecorp.centraldogma.server.storage.repository.MetaRepository; 31 import com.linecorp.centraldogma.server.storage.repository.RepositoryManager; 32 33 /** 34 * A top-level element in Central Dogma storage model. A project has {@code "dogma"} and {@code "meta"} 35 * repositories by default which contain project configuration files accessible by system administrators 36 * and project owners respectively. 37 */ 38 public interface Project { 39 /** 40 * The repository that contains project configuration files, which are accessible by system administrators. 41 */ 42 String REPO_DOGMA = "dogma"; 43 44 /** 45 * The repository that contains project configuration files, which are accessible by project owners. 46 */ 47 String REPO_META = "meta"; 48 49 /** 50 * Returns the name of this project. 51 */ 52 String name(); 53 54 /** 55 * Returns the creation time of this project, in milliseconds. 56 */ 57 long creationTimeMillis(); 58 59 /** 60 * Returns the author who initially created this project. 61 */ 62 Author author(); 63 64 /** 65 * Returns the {@link MetaRepository} of this project. 66 */ 67 MetaRepository metaRepo(); 68 69 /** 70 * Returns the {@link RepositoryManager} of this project. 71 */ 72 RepositoryManager repos(); 73 74 /** 75 * Returns the {@link ProjectMetadata} of this project. 76 * {@code null} if the project is internal. 77 */ 78 @Nullable 79 ProjectMetadata metadata(); 80 81 /** 82 * Returns the list of internal repositories which are {@link #REPO_DOGMA} and {@link #REPO_META}. 83 */ 84 static List<String> internalRepos() { 85 return internalRepos; 86 } 87 88 /** 89 * Returns {@code true} if the specified repository is an internal repository. 90 */ 91 static boolean isInternalRepo(String repoName) { 92 requireNonNull(repoName, "repoName"); 93 repoName = Ascii.toLowerCase(repoName); 94 return internalRepos().contains(repoName); 95 } 96 97 /** 98 * Returns {@code true} if the specified repository name is reserved by Central Dogma. 99 * 100 * @deprecated Use {@link #isInternalRepo(String)} instead. 101 */ 102 @Deprecated 103 static boolean isReservedRepoName(String repoName) { 104 return isInternalRepo(repoName); 105 } 106 107 /** 108 * Resets the {@link MetaRepository} of this project. 109 * 110 * @deprecated This will be removed after migrating the content in meta repository to dogma repository. 111 */ 112 @Deprecated 113 MetaRepository resetMetaRepository(); 114 }