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 *     Thierry Delprat
018 * *
019 */
020
021package org.nuxeo.ecm.platform.computedgroups;
022
023import java.io.Serializable;
024import java.util.List;
025import java.util.Map;
026import java.util.Set;
027
028import org.nuxeo.ecm.core.query.sql.model.QueryBuilder;
029import org.nuxeo.ecm.platform.usermanager.NuxeoPrincipalImpl;
030
031/**
032 * Interface that must be implemented by all contributed {@link GroupComputer}s.
033 *
034 * @author Thierry Delprat
035 */
036public interface GroupComputer {
037
038    /**
039     * Returns the group names for a give User.
040     */
041    List<String> getGroupsForUser(NuxeoPrincipalImpl nuxeoPrincipal);
042
043    /**
044     * Return all group ids. If you class can not efficiently compute this list, you can return an empty list. In this
045     * case you need to implement the searchGroups method.
046     */
047    List<String> getAllGroupIds();
048
049    /**
050     * Returns the members for a give group.
051     */
052    List<String> getGroupMembers(String groupName);
053
054    /**
055     * Return parent groups.
056     */
057    List<String> getParentsGroupNames(String groupName);
058
059    /**
060     * Returns children groups.
061     */
062    List<String> getSubGroupsNames(String groupName);
063
064    /**
065     * Searches for a group. (This method is used in particular from UI to search/select a group).
066     */
067    List<String> searchGroups(Map<String, Serializable> filter, Set<String> fulltext);
068
069    /**
070     * Searches for groups.
071     *
072     * @param queryBuilder the query
073     * @return the list of computed group ids
074     * @since 10.3
075     */
076    List<String> searchGroups(QueryBuilder queryBuilder);
077
078    /**
079     * Returns true if the given group exists.
080     */
081    boolean hasGroup(String name);
082
083}