Skip to content

Commit ab51a4e

Browse files
committed
separate method
1 parent f170084 commit ab51a4e

File tree

1 file changed

+16
-3
lines changed

1 file changed

+16
-3
lines changed

server/src/main/java/org/elasticsearch/repositories/RepositoriesService.java

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -893,13 +893,26 @@ public Repository createRepository(RepositoryMetadata repositoryMetadata) {
893893
* <li>The repository metadata should be associated to an already registered non-internal repository type and factory pair.</li>
894894
* </ul>
895895
*
896-
* @param projectId the project that the repository is associated with. May be null if the repository is at cluster level
896+
* @param projectId the project that the repository is associated with
897897
* @param repositoryMetadata the repository metadata
898898
* @return the started repository
899899
* @throws RepositoryException if repository type is not registered
900900
*/
901-
public Repository createRepository(@Nullable ProjectId projectId, RepositoryMetadata repositoryMetadata) {
902-
return createRepository(projectId, repositoryMetadata, typesRegistry, RepositoriesService::throwRepositoryTypeDoesNotExists);
901+
public Repository createRepository(ProjectId projectId, RepositoryMetadata repositoryMetadata) {
902+
return createRepository(
903+
Objects.requireNonNull(projectId),
904+
repositoryMetadata,
905+
typesRegistry,
906+
RepositoriesService::throwRepositoryTypeDoesNotExists
907+
);
908+
}
909+
910+
/**
911+
* Similar to {@link #createRepository(ProjectId, RepositoryMetadata)}, but repository is not associated with a project, i.e. the
912+
* repository is at the cluster level.
913+
*/
914+
public Repository createNonProjectRepository(RepositoryMetadata repositoryMetadata) {
915+
return createRepository(null, repositoryMetadata, typesRegistry, RepositoriesService::throwRepositoryTypeDoesNotExists);
903916
}
904917

905918
private static Repository throwRepositoryTypeDoesNotExists(ProjectId projectId, RepositoryMetadata repositoryMetadata) {

0 commit comments

Comments
 (0)