1 /* 2 * Copyright (c) 2002-2017, Mairie de Paris 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 9 * 1. Redistributions of source code must retain the above copyright notice 10 * and the following disclaimer. 11 * 12 * 2. Redistributions in binary form must reproduce the above copyright notice 13 * and the following disclaimer in the documentation and/or other materials 14 * provided with the distribution. 15 * 16 * 3. Neither the name of 'Mairie de Paris' nor 'Lutece' nor the names of its 17 * contributors may be used to endorse or promote products derived from 18 * this software without specific prior written permission. 19 * 20 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 21 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 23 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE 24 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 25 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 26 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 27 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 28 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 29 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 30 * POSSIBILITY OF SUCH DAMAGE. 31 * 32 * License 1.0 33 */ 34 package fr.paris.lutece.plugins.mylutece.modules.ldapdatabase.authentication.business; 35 36 import fr.paris.lutece.portal.service.plugin.Plugin; 37 import fr.paris.lutece.portal.service.spring.SpringContextService; 38 39 import java.util.Collection; 40 41 42 /** 43 * This class provides instances management methods (create, find, ...) for LdapUser objects 44 */ 45 public final class LdapUserHome 46 { 47 // Static variable pointed at the DAO instance 48 private static ILdapUserDAO _dao = (ILdapUserDAO) SpringContextService.getPluginBean( "ldapdatabase", "ldapDatabaseUserDAO" ); 49 50 /** 51 * Private constructor - this class need not be instantiated 52 */ 53 private LdapUserHome( ) 54 { 55 } 56 57 /** 58 * Creation of an instance of ldapUser 59 * 60 * @param ldapUser The instance of the LdapUser which contains the informations to store 61 * @param plugin The current plugin using this method 62 * @return The instance of LdapUser which has been created with its primary key. 63 */ 64 public static LdapUser create( LdapUser ldapUser, Plugin plugin ) 65 { 66 _dao.insert( ldapUser, plugin ); 67 68 return ldapUser; 69 } 70 71 /** 72 * Update of the ldapUser which is specified in parameter 73 * 74 * @param ldapUser The instance of the LdapUser which contains the data to store 75 * @param plugin The current plugin using this method 76 * @return The instance of the LdapUser which has been updated 77 */ 78 public static LdapUser update( LdapUser ldapUser, Plugin plugin ) 79 { 80 _dao.store( ldapUser, plugin ); 81 82 return ldapUser; 83 } 84 85 /** 86 * Remove the ldapUser whose identifier is specified in parameter 87 * 88 * @param ldapUser The LdapUser object to remove 89 * @param plugin The current plugin using this method 90 */ 91 public static void remove( LdapUser ldapUser, Plugin plugin ) 92 { 93 _dao.delete( ldapUser, plugin ); 94 } 95 96 /////////////////////////////////////////////////////////////////////////// 97 // Finders 98 99 /** 100 * Returns an instance of a LdapUser whose identifier is specified in parameter 101 * 102 * @param nKey The Primary key of the ldapUser 103 * @param plugin The current plugin using this method 104 * @return An instance of LdapUser 105 */ 106 public static LdapUser findByPrimaryKey( int nKey, Plugin plugin ) 107 { 108 return _dao.load( nKey, plugin ); 109 } 110 111 /** 112 * Returns a collection of LdapUser objects 113 * @param plugin The current plugin using this method 114 * @return A collection of LdapUser 115 */ 116 public static Collection findLdapUsersList( Plugin plugin ) 117 { 118 return _dao.selectLdapUserList( plugin ); 119 } 120 121 /** 122 * Returns a collection of LdapUser objects for a guid 123 * @param strLdapGuid The guid of the ldapUser 124 * @param plugin The current plugin using this method 125 * @return A collection of LdapUser 126 */ 127 public static Collection findLdapUsersListForGuid( String strLdapGuid, Plugin plugin ) 128 { 129 return _dao.selectLdapUserListForGuid( strLdapGuid, plugin ); 130 } 131 }