001/*
002 * (C) Copyright 2006-2014 Nuxeo SA (http://nuxeo.com/) and others.
003 *
004 * Licensed under the Apache License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 *     http://www.apache.org/licenses/LICENSE-2.0
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 *
016 * Contributors:
017 *     Bogdan Stefanescu
018 *     Florent Guillaume
019 */
020package org.nuxeo.ecm.core.api.repository;
021
022import java.util.Collection;
023import java.util.List;
024
025/**
026 * High-level service to get to a {@link org.nuxeo.ecm.core.api.repository.Repository Repository} and from there to
027 * {@link org.nuxeo.ecm.core.api.CoreSession CoreSession} objects.
028 */
029public interface RepositoryManager {
030
031    /**
032     * Gets all registered repositories.
033     *
034     * @return a read-only collection of repositories or an empty one if no repositories was defined
035     */
036    Collection<Repository> getRepositories();
037
038    /**
039     * Gets the names of registered repositories.
040     *
041     * @since 5.9.3
042     * @return a list of repository names
043     */
044    List<String> getRepositoryNames();
045
046    /**
047     * Gets a repository by its name.
048     *
049     * @param name the repository name
050     * @return the repository or null if not found
051     */
052    Repository getRepository(String name);
053
054    /**
055     * Registers a new repository.
056     *
057     * @param repository the repository to register
058     */
059    void addRepository(Repository repository);
060
061    /**
062     * Removes a registered repository.
063     * <p>
064     * Do nothing if the repository is not registered.
065     *
066     * @param name the repository name to unregister
067     */
068    void removeRepository(String name);
069
070    /**
071     * Gets the default repository.
072     * <p>
073     * If there is not a default repository returns the first registered. repository
074     * <p>
075     * This is a convenient method to get the repository for application having a single repository.
076     *
077     * @return the default repository
078     */
079    Repository getDefaultRepository();
080
081    /**
082     * Gets the name of the default repository.
083     * <p>
084     * If there is not a default repository, returns the name of the first registered repository.
085     *
086     * @return the default repository name
087     */
088    String getDefaultRepositoryName();
089
090}