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.schema.types.Field; 028import org.nuxeo.ecm.directory.api.DirectoryDeleteConstraint; 029 030/** 031 * The directory interface. 032 * <p> 033 * This interface is implemented in order to create an NXDirectory. One should implement this interface in order to 034 * create either a new Directory implementation or a new Directory Source. 035 * 036 * @author [email protected] 037 */ 038// TODO: maybe separate Directory implementation and Directory Source 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 * Gets the unique name of the directory, used for registering. 064 * 065 * @return the unique directory name 066 */ 067 String getName(); 068 069 /** 070 * Gets the schema name used by this directory. 071 * 072 * @return the schema name 073 */ 074 String getSchema(); 075 076 /** 077 * Gets the name of the parent directory. This is used for hierarchical vocabularies. 078 * 079 * @return the name of the parent directory, or null. 080 */ 081 String getParentDirectory(); 082 083 /** 084 * Gets the id field of the schema for this directory. 085 * 086 * @return the id field. 087 */ 088 String getIdField(); 089 090 /** 091 * Gets the password field of the schema for this directory. 092 * 093 * @return the password field. 094 */ 095 String getPasswordField(); 096 097 /** 098 * Checks if this directory is read-only. 099 * 100 * @since 8.2 101 */ 102 boolean isReadOnly(); 103 104 /** 105 * Shuts down the directory. 106 */ 107 void shutdown(); 108 109 /** 110 * Creates a session for accessing entries in this directory. 111 * 112 * @return a Session object 113 */ 114 Session getSession(); 115 116 /** 117 * Lookup a Reference by field name. 118 * 119 * @return the matching reference implementation or null 120 * @deprecated since 7.4, kept for compatibility with old code, use {@link #getReferences(String)} instead 121 */ 122 @Deprecated 123 Reference getReference(String referenceFieldName); 124 125 /** 126 * Lookup the References by field name. 127 * 128 * @return the matching references implementation or null 129 */ 130 List<Reference> getReferences(String referenceFieldName); 131 132 /** 133 * Lookup all References defined on the directory. 134 * 135 * @return all registered references 136 */ 137 Collection<Reference> getReferences(); 138 139 /** 140 * Gets the cache instance of the directory 141 * 142 * @return the cache of the directory 143 */ 144 DirectoryCache getCache(); 145 146 /** 147 * Invalidates the cache instance of the directory 148 */ 149 void invalidateDirectoryCache(); 150 151 /** 152 * Returns {@code true} if this directory is a multi tenant directory, {@code false} otherwise. 153 * 154 * @since 5.6 155 */ 156 boolean isMultiTenant(); 157 158 /** 159 * @since 8.4 160 */ 161 List<String> getTypes(); 162 163 /** 164 * @since 8.4 165 */ 166 List<DirectoryDeleteConstraint> getDirectoryDeleteConstraints(); 167 168 /** 169 * Invalidate caches 170 * 171 * @since 9.2 172 */ 173 void invalidateCaches(); 174 175 /** 176 * Get schema field map 177 * 178 * @since 9.2 179 */ 180 Map<String, Field> getSchemaFieldMap(); 181 182 /** 183 * Get descriptor 184 * 185 * @since 9.2 186 */ 187 BaseDirectoryDescriptor getDescriptor(); 188 189}