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 * George Lefter 016 * 017 * $Id$ 018 */ 019 020package org.nuxeo.ecm.directory.api; 021 022import java.util.List; 023 024import org.nuxeo.ecm.core.api.DocumentModel; 025import org.nuxeo.ecm.directory.Directory; 026import org.nuxeo.ecm.directory.DirectoryException; 027import org.nuxeo.ecm.directory.DirectoryFactory; 028import org.nuxeo.ecm.directory.Session; 029import org.nuxeo.runtime.model.ComponentName; 030 031/** 032 * @author <a href="mailto:glefter@nuxeo.com">George Lefter</a> 033 */ 034public interface DirectoryService { 035 036 ComponentName NAME = new ComponentName("org.nuxeo.ecm.directory.DirectoryServiceImpl"); 037 038 List<String> getDirectoryNames(); 039 040 String getDirectorySchema(String directoryName) throws DirectoryException; 041 042 /** 043 * Opens a session on specified directory. 044 * <p> 045 * This method prefers to throw rather than returning null. 046 * 047 * @param directoryName 048 * @return the session 049 * @throws DirectoryException in case the session cannot be created 050 */ 051 Session open(String directoryName) throws DirectoryException; 052 053 /** 054 * Opens a session on the directory for the specified context. The context is given by the document. The document 055 * service will try to find the directory local configuration of the document that will specify the suffix. the 056 * directory will fetch the directoryName + suffix found. If no local configuration is found the service will return 057 * the directoryName directory. 058 * <p> 059 * This method prefers to throw rather than returning null. 060 * 061 * @param directoryName 062 * @param documentContext 063 * @return the session 064 * @throws DirectoryException in case the session cannot be created 065 */ 066 Session open(String directoryName, DocumentModel documentContext) throws DirectoryException; 067 068 /** 069 * Return the directory for the specified context. The context is given by the document. The document service will 070 * try to find the directory local configuration of the document that will specify the suffix. The directory service 071 * will fetch the directoryName + suffix found. If no local configuration is found the service will return the 072 * directoryName directory. 073 * <p> 074 * If the directoryName is null, return null. 075 * 076 * @param directoryName 077 * @param documentContext 078 * @return the directory, if the factory of the directory or the directory itself is not found return null 079 * @throws DirectoryException 080 */ 081 Directory getDirectory(String directoryName, DocumentModel documentContext) throws DirectoryException; 082 083 /** 084 * Return the directory with the name directoryName. 085 * <p> 086 * If the directoryName is null, return null. 087 * 088 * @param directoryName 089 * @return the directory, if the factory of the directory or the directory itself is not found return null 090 * @throws DirectoryException 091 */ 092 Directory getDirectory(String directoryName) throws DirectoryException; 093 094 /** 095 * Return all the directories registered into the service. 096 * <p> 097 * 098 * @throws DirectoryException 099 */ 100 List<Directory> getDirectories() throws DirectoryException; 101 102 void registerDirectory(String directoryName, DirectoryFactory factory); 103 104 void unregisterDirectory(String directoryName, DirectoryFactory factory); 105 106 String getDirectoryIdField(String directoryName) throws DirectoryException; 107 108 String getDirectoryPasswordField(String directoryName) throws DirectoryException; 109 110 /** 111 * Returns the name of the parent directory of specified directory, if applicable. 112 * 113 * @param directoryName 114 * @return the name, or null 115 * @throws DirectoryException 116 */ 117 String getParentDirectoryName(String directoryName) throws DirectoryException; 118 119}