001/*
002 * (C) Copyright 2006-2007 Nuxeo SAS (http://nuxeo.com/) and contributors.
003 *
004 * All rights reserved. This program and the accompanying materials
005 * are made available under the terms of the GNU Lesser General Public License
006 * (LGPL) version 2.1 which accompanies this distribution, and is available at
007 * http://www.gnu.org/licenses/lgpl.html
008 *
009 * This library is distributed in the hope that it will be useful,
010 * but WITHOUT ANY WARRANTY; without even the implied warranty of
011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
012 * Lesser General Public License for more details.
013 *
014 * Contributors:
015 *     Nuxeo - initial API and implementation
016 * $Id$
017 */
018
019package org.nuxeo.ecm.directory;
020
021import java.util.Collection;
022import java.util.List;
023
024/**
025 * The directory interface.
026 * <p>
027 * This interface is implemented in order to create an NXDirectory. One should implement this interface in order to
028 * create either a new Directory implementation or a new Directory Source.
029 *
030 * @author glefter@nuxeo.com
031 */
032// TODO: maybe separate Directory implementation and Directory Source
033public interface Directory {
034
035    /**
036     * Gets the unique name of the directory, used for registering.
037     *
038     * @return the unique directory name
039     * @throws DirectoryException
040     */
041    String getName() throws DirectoryException;
042
043    /**
044     * Gets the schema name used by this directory.
045     *
046     * @return the schema name
047     * @throws DirectoryException
048     */
049    String getSchema() throws DirectoryException;
050
051    /**
052     * Gets the name of the parent directory. This is used for hierarchical vocabularies.
053     *
054     * @return the name of the parent directory, or null.
055     */
056    String getParentDirectory() throws DirectoryException;
057
058    /**
059     * Gets the id field of the schema for this directory.
060     *
061     * @return the id field.
062     * @throws DirectoryException
063     */
064    String getIdField() throws DirectoryException;
065
066    /**
067     * Gets the password field of the schema for this directory.
068     *
069     * @return the password field.
070     * @throws DirectoryException
071     */
072    String getPasswordField() throws DirectoryException;
073
074    /**
075     * Shuts down the directory.
076     *
077     * @throws DirectoryException
078     */
079    void shutdown() throws DirectoryException;
080
081    /**
082     * Creates a session for accessing entries in this directory.
083     *
084     * @return a Session object
085     * @throws DirectoryException if a session cannot be created
086     */
087    Session getSession() throws DirectoryException;
088
089    /**
090     * Lookup a Reference by field name.
091     *
092     * @return the matching reference implementation or null
093     * @throws DirectoryException
094     * @deprecated since 7.4, kept for compatibility with old code, use {@link #getReferences(String)} instead
095     */
096    @Deprecated
097    Reference getReference(String referenceFieldName) throws DirectoryException;
098
099    /**
100     * Lookup the References by field name.
101     *
102     * @return the matching references implementation or null
103     * @throws DirectoryException
104     */
105    List<Reference> getReferences(String referenceFieldName) throws DirectoryException;
106
107    /**
108     * Lookup all References defined on the directory.
109     *
110     * @return all registered references
111     * @throws DirectoryException
112     */
113    Collection<Reference> getReferences() throws DirectoryException;
114
115    /**
116     * Gets the cache instance of the directory
117     *
118     * @return the cache of the directory
119     * @throws DirectoryException
120     */
121    DirectoryCache getCache() throws DirectoryException;
122
123    /**
124     * Invalidates the cache instance of the directory
125     *
126     * @throws DirectoryException
127     */
128    void invalidateDirectoryCache() throws DirectoryException;
129
130    /**
131     * Returns {@code true} if this directory is a multi tenant directory, {@code false} otherwise.
132     *
133     * @since 5.6
134     */
135    boolean isMultiTenant() throws DirectoryException;
136
137}