001/* 002 * Copyright 2016 Anyware Services 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 */ 016package org.ametys.core.group.directory; 017 018import java.util.List; 019import java.util.Map; 020import java.util.Set; 021 022import org.ametys.core.group.Group; 023import org.ametys.core.user.UserIdentity; 024import org.ametys.runtime.i18n.I18nizableText; 025 026/** 027 * Abstraction for a directory of group. 028 */ 029public interface GroupDirectory 030{ 031 /** 032 * Get the id of the group directory. 033 * @return The id of the group directory 034 */ 035 public String getId(); 036 037 /** 038 * Get the label of the group directory. 039 * @return The label of the group directory 040 */ 041 public I18nizableText getLabel(); 042 043 /** 044 * Set the id of the group directory. 045 * @param id The id 046 */ 047 public void setId(String id); 048 049 /** 050 * Set the label of the group directory. 051 * @param label The label 052 */ 053 public void setLabel(I18nizableText label); 054 055 /** 056 * Get the id of the {@link GroupDirectoryModel} extension point 057 * @return the id of extension point 058 */ 059 public String getGroupDirectoryModelId(); 060 061 /** 062 * Get the values of parameters (from group directory model) 063 * @return the parameters' values 064 */ 065 public Map<String, Object> getParameterValues(); 066 067 /** 068 * Initialize the group directory with given parameter values. 069 * @param groupDirectoryModelId The id of group directory extension point 070 * @param paramValues The parameters' values 071 * @throws Exception If an error occured 072 */ 073 public void init(String groupDirectoryModelId, Map<String, Object> paramValues) throws Exception; 074 075 /** 076 * Returns a particular group. 077 * @param groupID The id of the group. 078 * @return The group or null if the group does not exist. 079 */ 080 public Group getGroup(String groupID); 081 082 /** 083 * Returns all groups. 084 * @return The groups as a Set of UserGroup, empty if an error occurs. 085 */ 086 public Set<Group> getGroups(); 087 088 /** 089 * Get all groups a particular user is in. 090 * @param userIdentity The identity of the user 091 * @return The groups as a Set of String (group ID), empty if the login does not match. 092 */ 093 public Set<String> getUserGroups(UserIdentity userIdentity); 094 095 /** 096 * Get groups 097 * @param count The maximum number of groups to sax. (-1 to sax all) 098 * @param offset The offset to start with, first is 0. 099 * @param parameters Parameters for saxing user list differently, see implementation. 100 * @return The matching groups 101 */ 102 public List<Group> getGroups(int count, int offset, Map parameters); 103 104}