001/*
002 * (C) Copyright 2011 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 *     bjalon
018 */
019package org.nuxeo.ecm.platform.usermanager;
020
021import java.io.Serializable;
022import java.util.Map;
023import java.util.Set;
024
025import org.nuxeo.ecm.core.api.DocumentModel;
026import org.nuxeo.ecm.core.query.sql.model.QueryBuilder;
027
028/**
029 * Implementations of this interface manages the multi-tenant behavior for UserManager. This class will be used to fetch
030 * the User Directory and the Group characteristics
031 *
032 * @author bjalon
033 */
034public interface UserMultiTenantManagement {
035
036    /**
037     * Transform filter and fulltext to fetch Groups for the given context and the query specified with the given filter
038     * and fulltext. Be careful the filter map and the fulltext set object will be modified so copy them before.
039     */
040    void queryTransformer(UserManager um, Map<String, Serializable> filter, Set<String> fulltext, DocumentModel context);
041
042    /**
043     * Transform the Group DocumentModel store it into the tenant described by the context
044     *
045     * @param group to modified
046     * @param context that bring the tenant information
047     */
048    DocumentModel groupTransformer(UserManager um, DocumentModel group, DocumentModel context);
049
050    /**
051     * Transforms the query builder to add tenant-related information.
052     *
053     * @return the transformed query builder
054     * @since 10.3
055     */
056    QueryBuilder groupQueryTransformer(UserManager um, QueryBuilder queryBuilder, DocumentModel context);
057
058    /**
059     * Transform the GroupName to add to tenant characteristic.
060     *
061     * @param groupname to modified
062     * @param context that bring the tenant information
063     */
064    String groupnameTranformer(UserManager um, String groupname, DocumentModel context);
065
066}