001/*
002 * (C) Copyright 2006-2007 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 *     Nuxeo - initial API and implementation
018 * $Id$
019 */
020
021package org.nuxeo.ecm.directory;
022
023import java.util.Collection;
024import java.util.List;
025import java.util.Map;
026
027import org.nuxeo.ecm.core.api.Blob;
028import org.nuxeo.ecm.core.schema.types.Field;
029import org.nuxeo.ecm.directory.api.DirectoryDeleteConstraint;
030
031/**
032 * The directory interface.
033 * <p>
034 * This interface is implemented in order to create an NXDirectory. One should implement this interface in order to
035 * create either a new Directory implementation or a new Directory Source.
036 *
037 * @author glefter@nuxeo.com
038 */
039public interface Directory {
040
041    /**
042     * INTERNAL, DO NOT CALL. Initializes the directory when Nuxeo starts. Called without a transaction.
043     *
044     * @since 10.10
045     */
046    void initialize();
047
048    /**
049     * INTERNAL, DO NOT CALL. Initializes the directory when Nuxeo starts. Called without a transaction.
050     *
051     * @since 10.10
052     */
053    void initializeReferences();
054
055    /**
056     * INTERNAL, DO NOT CALL. Initializes the directory when Nuxeo starts. Called without a transaction.
057     *
058     * @since 10.10
059     */
060    void initializeInverseReferences();
061
062    /**
063     * Loads a CSV into a Directory.
064     *
065     * @see BaseDirectoryDescriptor#DATA_LOADING_POLICIES
066     * @since 11.1
067     */
068    void loadFromCSV(Blob dataBlob, String dataLoadingPolicy);
069
070    /**
071     * Gets the unique name of the directory, used for registering.
072     *
073     * @return the unique directory name
074     */
075    String getName();
076
077    /**
078     * Gets the schema name used by this directory.
079     *
080     * @return the schema name
081     */
082    String getSchema();
083
084    /**
085     * Gets the name of the parent directory. This is used for hierarchical vocabularies.
086     *
087     * @return the name of the parent directory, or null.
088     */
089    String getParentDirectory();
090
091    /**
092     * Gets the id field of the schema for this directory.
093     *
094     * @return the id field.
095     */
096    String getIdField();
097
098    /**
099     * Gets the password field of the schema for this directory.
100     *
101     * @return the password field.
102     */
103    String getPasswordField();
104
105    /**
106     * Checks if this directory is read-only.
107     *
108     * @since 8.2
109     */
110    boolean isReadOnly();
111
112    /**
113     * Shuts down the directory.
114     */
115    void shutdown();
116
117    /**
118     * Creates a session for accessing entries in this directory.
119     *
120     * @return a Session object
121     */
122    Session getSession();
123
124    /**
125     * Lookup a Reference by field name.
126     *
127     * @return the matching reference implementation or null
128     * @deprecated since 7.4, kept for compatibility with old code, use {@link #getReferences(String)} instead
129     */
130    @Deprecated(since = "7.4")
131    Reference getReference(String referenceFieldName);
132
133    /**
134     * Lookup the References by field name.
135     *
136     * @return the matching references implementation or null
137     */
138    List<Reference> getReferences(String referenceFieldName);
139
140    /**
141     * Lookup all References defined on the directory.
142     *
143     * @return all registered references
144     */
145    Collection<Reference> getReferences();
146
147    /**
148     * Gets the cache instance of the directory
149     *
150     * @return the cache of the directory
151     */
152    DirectoryCache getCache();
153
154    /**
155     * Invalidates the cache instance of the directory
156     */
157    void invalidateDirectoryCache();
158
159    /**
160     * Returns {@code true} if this directory is a multi tenant directory, {@code false} otherwise.
161     *
162     * @since 5.6
163     */
164    boolean isMultiTenant();
165
166    /**
167     * @since 8.4
168     */
169    List<String> getTypes();
170
171    /**
172     * @since 8.4
173     */
174    List<DirectoryDeleteConstraint> getDirectoryDeleteConstraints();
175
176    /**
177     * Invalidate caches
178     *
179     * @since 9.2
180     */
181    void invalidateCaches();
182
183    /**
184     * Get schema field map
185     *
186     * @since 9.2
187     */
188    Map<String, Field> getSchemaFieldMap();
189
190    /**
191     * Get descriptor
192     *
193     * @since 9.2
194     */
195    BaseDirectoryDescriptor getDescriptor();
196
197}