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 com.google.common.base.Ascii;
25  
26  import com.linecorp.centraldogma.common.Author;
27  import com.linecorp.centraldogma.server.storage.repository.MetaRepository;
28  import com.linecorp.centraldogma.server.storage.repository.RepositoryManager;
29  
30  /**
31   * A top-level element in Central Dogma storage model. A project has {@code "dogma"} and {@code "meta"}
32   * repositories by default which contain project configuration files accessible by administrators
33   * and project owners respectively.
34   */
35  public interface Project {
36      /**
37       * The repository that contains project configuration files, which are accessible by administrators.
38       */
39      String REPO_DOGMA = "dogma";
40  
41      /**
42       * The repository that contains project configuration files, which are accessible by project owners.
43       */
44      String REPO_META = "meta";
45  
46      /**
47       * Returns the name of this project.
48       */
49      String name();
50  
51      /**
52       * Returns the creation time of this project, in milliseconds.
53       */
54      long creationTimeMillis();
55  
56      /**
57       * Returns the author who initially created this project.
58       */
59      Author author();
60  
61      /**
62       * Returns the {@link MetaRepository} of this project.
63       */
64      MetaRepository metaRepo();
65  
66      /**
67       * Returns the {@link RepositoryManager} of this project.
68       */
69      RepositoryManager repos();
70  
71      /**
72       * Returns the list of internal repositories which are {@link #REPO_DOGMA} and {@link #REPO_META}.
73       */
74      static List<String> internalRepos() {
75          return internalRepos;
76      }
77  
78      /**
79       * Returns {@code true} if the specified repository name is reserved by Central Dogma.
80       */
81      static boolean isReservedRepoName(String repoName) {
82          requireNonNull(repoName, "repoName");
83          repoName = Ascii.toLowerCase(repoName);
84          return internalRepos().contains(repoName);
85      }
86  }