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 * George Lefter 018 * 019 * $Id$ 020 */ 021 022package org.nuxeo.ecm.directory.api; 023 024import java.util.List; 025 026import org.nuxeo.ecm.core.api.DocumentModel; 027import org.nuxeo.ecm.directory.Directory; 028import org.nuxeo.ecm.directory.BaseDirectoryDescriptor; 029import org.nuxeo.ecm.directory.DirectoryException; 030import org.nuxeo.ecm.directory.Session; 031 032/** 033 * @author <a href="mailto:glefter@nuxeo.com">George Lefter</a> 034 */ 035public interface DirectoryService { 036 037 /** 038 * Gets the directory ids. 039 */ 040 List<String> getDirectoryNames(); 041 042 /** 043 * Gets all the directories. 044 */ 045 List<Directory> getDirectories(); 046 047 /** 048 * Returns the directory for the specified id and document context. 049 * <p> 050 * The context is given by the document. The document service will try to find the directory local configuration of 051 * the document that will specify the suffix. The directory service will fetch the id + suffix found. If no local 052 * configuration is found the service will return the directory with the given id. 053 * <p> 054 * If the id is {@code null}, returns {@code null}. 055 * 056 * @param id the directory id 057 * @param documentContext the document context 058 * @return the directory, or {@code null} if not found 059 */ 060 Directory getDirectory(String id, DocumentModel documentContext); 061 062 /** 063 * Return the directory with the given id. 064 * <p> 065 * If the id is {@code null}, returns {@code null}. 066 * 067 * @param id the directory id 068 * @return the directory, or {@code null} if not found 069 */ 070 Directory getDirectory(String id); 071 072 /** 073 * Gets the effective directory descriptor for the given directory. 074 * 075 * @param id the directory id 076 * @return the effective directory descriptor, or {@code null} if not registered 077 * 078 * @since 8.2 079 */ 080 BaseDirectoryDescriptor getDirectoryDescriptor(String id); 081 082 /** 083 * Opens a session on specified directory. 084 * <p> 085 * This method prefers to throw rather than returning null. 086 * 087 * @param directoryName 088 * @return the session 089 * @throws DirectoryException in case the session cannot be created 090 */ 091 Session open(String directoryName) throws DirectoryException; 092 093 /** 094 * Opens a session on the directory for the specified context. The context is given by the document. The document 095 * service will try to find the directory local configuration of the document that will specify the suffix. the 096 * directory will fetch the directoryName + suffix found. If no local configuration is found the service will return 097 * the directoryName directory. 098 * <p> 099 * This method prefers to throw rather than returning null. 100 * 101 * @param directoryName 102 * @param documentContext 103 * @return the session 104 * @throws DirectoryException in case the session cannot be created 105 */ 106 Session open(String directoryName, DocumentModel documentContext) throws DirectoryException; 107 108 /** 109 * Gets the schema for a directory. 110 * 111 * @param id the directory id 112 * @return the schema for the directory 113 * @throws DirectoryException if the directory does not exist 114 */ 115 String getDirectorySchema(String id) throws DirectoryException; 116 117 /** 118 * Gets the id field for a directory. 119 * 120 * @param id the directory id 121 * @return the id field for the directory 122 * @throws DirectoryException if the directory does not exist 123 */ 124 String getDirectoryIdField(String id) throws DirectoryException; 125 126 /** 127 * Gets the password field for a directory. 128 * 129 * @param id the directory id 130 * @return the password field for the directory 131 * @throws DirectoryException if the directory does not exist 132 */ 133 String getDirectoryPasswordField(String directoryName) throws DirectoryException; 134 135 /** 136 * Gets the parent directory id a directory. 137 * 138 * @param id the directory id 139 * @return the parent directory id, which may be {@code null} 140 * @throws DirectoryException if the directory does not exist 141 */ 142 String getParentDirectoryName(String id) throws DirectoryException; 143 144 /** 145 * INTERNAL registers a directory descriptor. 146 */ 147 void registerDirectoryDescriptor(BaseDirectoryDescriptor descriptor); 148 149 /** 150 * INTERNAL unregisters a directory descriptor. 151 */ 152 void unregisterDirectoryDescriptor(BaseDirectoryDescriptor descriptor); 153 154}