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 *
019 * $Id: JOOoConvertPluginImpl.java 18651 2007-05-13 20:28:53Z sfermigier $
020 */
021
022package org.nuxeo.ecm.directory;
023
024import java.util.List;
025
026/**
027 * Base interface for references between directory fields.
028 * <p>
029 * References are used to leverage SQL joins or attributes that store a list of distinguished names in LDAP servers
030 * (e.g. uniqueMember).
031 * <p>
032 * In nuxeo directories, references are special entry fields that are string list of entry ids of a target directory.
033 *
034 * @author ogrisel
035 */
036public interface Reference {
037
038    String getFieldName();
039
040    Directory getSourceDirectory() throws DirectoryException;
041
042    void setSourceDirectoryName(String sourceDirectoryName);
043
044    Directory getTargetDirectory() throws DirectoryException;
045
046    /**
047     * @deprecated since 9.2 (unused)
048     */
049    @Deprecated
050    void setTargetDirectoryName(String targetDirectoryName);
051
052    void addLinks(String sourceId, List<String> targetIds) throws DirectoryException;
053
054    void addLinks(List<String> sourceIds, String targetId) throws DirectoryException;
055
056    void removeLinksForSource(String sourceId) throws DirectoryException;
057
058    void removeLinksForTarget(String targetId) throws DirectoryException;
059
060    List<String> getTargetIdsForSource(String sourceId) throws DirectoryException;
061
062    List<String> getSourceIdsForTarget(String targetId) throws DirectoryException;
063
064    void setTargetIdsForSource(String sourceId, List<String> targetIds) throws DirectoryException;
065
066    void setSourceIdsForTarget(String targetId, List<String> sourceIds) throws DirectoryException;
067
068    /**
069     * Adds the links between the source id and the target ids
070     *
071     * @param sourceId the source id
072     * @param targetIds the target ids
073     * @param session the session
074     * @throws DirectoryException
075     * @since 9.2
076     */
077    void addLinks(String sourceId, List<String> targetIds, Session session) throws DirectoryException;
078
079    /**
080     * Adds the links between the source ids and the target id
081     *
082     * @param sourceIds the source ids
083     * @param targetId the target id
084     * @param session the session
085     * @throws DirectoryException
086     * @since 9.2
087     */
088    void addLinks(List<String> sourceIds, String targetId, Session session) throws DirectoryException;
089
090    /**
091     * Sets all source ids to be associated to the given target id
092     *
093     * @param targetId the target id
094     * @param sourceIds the source ids
095     * @param session the session
096     * @since 9.2
097     */
098    void setSourceIdsForTarget(String targetId, List<String> sourceIds, Session session) throws DirectoryException;
099
100    /**
101     * Sets all target ids to be associated to the given source id
102     *
103     * @param sourceId the source id
104     * @param targetIds the target ids
105     * @param session the session
106     * @since 9.2
107     */
108    void setTargetIdsForSource(String sourceId, List<String> targetIds, Session session) throws DirectoryException;
109
110    /**
111     * Removes all the links for a given target id
112     *
113     * @param targetId the target id
114     * @param session the session
115     * @since 9.2
116     */
117    void removeLinksForTarget(String targetId, Session session) throws DirectoryException;
118
119    /**
120     * Removes all the links for a given source id
121     *
122     * @param sourceId the source id
123     * @param session the session
124     * @since 9.2
125     */
126    void removeLinksForSource(String sourceId, Session session) throws DirectoryException;
127
128}