001/*
002 * Copyright (c) 2006-2014 Nuxeo SA (http://nuxeo.com/) and others.
003 *
004 * All rights reserved. This program and the accompanying materials
005 * are made available under the terms of the Eclipse Public License v1.0
006 * which accompanies this distribution, and is available at
007 * http://www.eclipse.org/legal/epl-v10.html
008 *
009 * Contributors:
010 *     Bogdan Stefanescu
011 *     Florent Guillaume
012 */
013package org.nuxeo.ecm.core.api.repository;
014
015import java.util.Collection;
016import java.util.List;
017
018/**
019 * High-level service to get to a {@link org.nuxeo.ecm.core.api.repository.Repository Repository} and from there to
020 * {@link org.nuxeo.ecm.core.api.CoreSession CoreSession} objects.
021 */
022public interface RepositoryManager {
023
024    /**
025     * Gets all registered repositories.
026     *
027     * @return a read-only collection of repositories or an empty one if no repositories was defined
028     */
029    Collection<Repository> getRepositories();
030
031    /**
032     * Gets the names of registered repositories.
033     *
034     * @since 5.9.3
035     * @return a list of repository names
036     */
037    List<String> getRepositoryNames();
038
039    /**
040     * Gets a repository by its name.
041     *
042     * @param name the repository name
043     * @return the repository or null if not found
044     */
045    Repository getRepository(String name);
046
047    /**
048     * Registers a new repository.
049     *
050     * @param repository the repository to register
051     */
052    void addRepository(Repository repository);
053
054    /**
055     * Removes a registered repository.
056     * <p>
057     * Do nothing if the repository is not registered.
058     *
059     * @param name the repository name to unregister
060     */
061    void removeRepository(String name);
062
063    /**
064     * Gets the default repository.
065     * <p>
066     * If there is not a default repository returns the first registered. repository
067     * <p>
068     * This is a convenient method to get the repository for application having a single repository.
069     *
070     * @return the default repository
071     */
072    Repository getDefaultRepository();
073
074    /**
075     * Gets the name of the default repository.
076     * <p>
077     * If there is not a default repository, returns the name of the first registered repository.
078     *
079     * @return the default repository name
080     */
081    String getDefaultRepositoryName();
082
083}