1 package org.apache.archiva.redback.users.provider.test;
4 * Licensed to the Apache Software Foundation (ASF) under one
5 * or more contributor license agreements. See the NOTICE file
6 * distributed with this work for additional information
7 * regarding copyright ownership. The ASF licenses this file
8 * to you under the Apache License, Version 2.0 (the
9 * "License"); you may not use this file except in compliance
10 * with the License. You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing,
15 * software distributed under the License is distributed on an
16 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17 * KIND, either express or implied. See the License for the
18 * specific language governing permissions and limitations
22 import org.apache.archiva.redback.users.UserManagerListener;
23 import org.apache.archiva.redback.users.User;
25 import java.util.ArrayList;
26 import java.util.List;
29 * UserManagerEventTracker
31 * @author <a href="mailto:joakim@erdfelt.com">Joakim Erdfelt</a>
34 public class UserManagerEventTracker
35 implements UserManagerListener
37 public long countInit = 0;
39 public Boolean lastDbFreshness;
41 public List<String> addedUsernames = new ArrayList<String>();
43 public List<String> removedUsernames = new ArrayList<String>();
45 public List<String> updatedUsernames = new ArrayList<String>();
47 public void userManagerInit( boolean freshDatabase )
50 lastDbFreshness = Boolean.valueOf( freshDatabase );
53 private void addUniqueUsername( List<String> list, User user )
55 if ( !list.contains( user.getUsername() ) )
57 list.add( user.getUsername() );
61 public void userManagerUserAdded( User user )
63 addUniqueUsername( addedUsernames, user );
66 public void userManagerUserRemoved( User user )
68 addUniqueUsername( removedUsernames, user );
71 public void userManagerUserUpdated( User user )
73 addUniqueUsername( updatedUsernames, user );