This project has retired. For details please refer to its Attic page.
UserManagerEventTracker xref
View Javadoc

1   package org.apache.archiva.redback.users.provider.test;
2   
3   /*
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
11   *
12   * http://www.apache.org/licenses/LICENSE-2.0
13   *
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
19   * under the License.
20   */
21  
22  import org.apache.archiva.redback.users.UserManagerListener;
23  import org.apache.archiva.redback.users.User;
24  
25  import java.util.ArrayList;
26  import java.util.List;
27  
28  /**
29   * UserManagerEventTracker 
30   *
31   * @author <a href="mailto:joakim@erdfelt.com">Joakim Erdfelt</a>
32   *
33   */
34  public class UserManagerEventTracker
35      implements UserManagerListener
36  {
37      public long countInit = 0;
38  
39      public Boolean lastDbFreshness;
40  
41      public List<String> addedUsernames = new ArrayList<String>();
42  
43      public List<String> removedUsernames = new ArrayList<String>();
44  
45      public List<String> updatedUsernames = new ArrayList<String>();
46  
47      public void userManagerInit( boolean freshDatabase )
48      {
49          countInit++;
50          lastDbFreshness = Boolean.valueOf( freshDatabase );
51      }
52  
53      private void addUniqueUsername( List<String> list, User user )
54      {
55          if ( !list.contains( user.getUsername() ) )
56          {
57              list.add( user.getUsername() );
58          }
59      }
60  
61      public void userManagerUserAdded( User user )
62      {
63          addUniqueUsername( addedUsernames, user );
64      }
65  
66      public void userManagerUserRemoved( User user )
67      {
68          addUniqueUsername( removedUsernames, user );
69      }
70  
71      public void userManagerUserUpdated( User user )
72      {
73          addUniqueUsername( updatedUsernames, user );
74      }
75  }