1 package org.codehaus.plexus.redback.users.provider.test;
4 * Copyright 2001-2006 The Codehaus.
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
19 import org.codehaus.plexus.redback.users.User;
20 import org.codehaus.plexus.redback.users.UserManagerListener;
22 import java.util.ArrayList;
23 import java.util.List;
26 * UserManagerEventTracker
28 * @author <a href="mailto:joakim@erdfelt.com">Joakim Erdfelt</a>
31 public class UserManagerEventTracker
32 implements UserManagerListener
34 public long countInit = 0;
36 public Boolean lastDbFreshness;
38 public List<String> addedUsernames = new ArrayList<String>();
40 public List<String> removedUsernames = new ArrayList<String>();
42 public List<String> updatedUsernames = new ArrayList<String>();
44 public void userManagerInit( boolean freshDatabase )
47 lastDbFreshness = Boolean.valueOf( freshDatabase );
50 private void addUniqueUsername( List<String> list, User user )
52 if ( !list.contains( user.getUsername() ) )
54 list.add( user.getUsername() );
58 public void userManagerUserAdded( User user )
60 addUniqueUsername( addedUsernames, user );
63 public void userManagerUserRemoved( User user )
65 addUniqueUsername( removedUsernames, user );
68 public void userManagerUserUpdated( User user )
70 addUniqueUsername( updatedUsernames, user );