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.user.directory;
017
018import java.util.Map;
019
020import org.ametys.core.user.InvalidModificationException;
021import org.ametys.runtime.model.Model;
022import org.ametys.runtime.model.View;
023import org.ametys.runtime.parameter.Errors;
024
025/**
026 * Abstraction for getting users list and verify the presence of a particular
027 * user and finally modifying this list.
028 */
029public interface ModifiableUserDirectory extends UserDirectory, Model
030{
031    /**
032     * Add a new user to the list.
033     * @param userInformation Informations about the user, see implementation. Cannot be null.
034     * @throws InvalidModificationException if the login exists yet or
035     *         if at least one of the parameter is invalid. 
036     */
037    public void add(Map<String, String> userInformation) throws InvalidModificationException;
038
039    /**
040     * Modify informations about an user of the list.
041     * @param userInformation New informations about the user, see implementation. Cannot be null.
042     * @throws InvalidModificationException if the login does not match
043     *         in the list or if at least one of the parameter is invalid. 
044     */
045    public void update(Map<String, String> userInformation) throws InvalidModificationException;
046
047    /**
048     * Remove an user from the list.
049     * @param login The user's login. Cannot be null.
050     * @throws InvalidModificationException if the user cannot be removed
051     */
052    public void remove(String login) throws InvalidModificationException;
053    
054    /**
055     * Validate user information.
056     * @param userInformation Informations about the user, see implementation. Cannot be null.
057     * @return validation errors.
058     */
059    public Map<String, Errors> validate(Map<String, String> userInformation);
060    
061    /**
062     * Retrieve the view of the Model
063     * @return The View
064     */
065    public View getView();
066}