1 package org.apache.archiva.redback.tests;
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.rbac.RBACManagerListener;
23 import org.apache.archiva.redback.rbac.Permission;
24 import org.apache.archiva.redback.rbac.Role;
25 import org.apache.archiva.redback.rbac.UserAssignment;
27 import java.util.ArrayList;
28 import java.util.List;
31 * RbacManagerEventTracker
33 * @author <a href="mailto:joakim@erdfelt.com">Joakim Erdfelt</a>
36 public class RbacManagerEventTracker
37 implements RBACManagerListener
39 public long initCount = 0;
41 public Boolean lastDbFreshness;
43 public List<String> addedRoleNames = new ArrayList<String>();
45 public List<String> removedRoleNames = new ArrayList<String>();
47 public List<String> addedPermissionNames = new ArrayList<String>();
49 public List<String> removedPermissionNames = new ArrayList<String>();
51 public void rbacInit( boolean freshdb )
53 log( "Init - freshdb: " + freshdb );
55 lastDbFreshness = Boolean.valueOf( freshdb );
58 public void rbacPermissionRemoved( Permission permission )
60 log( "Permission Removed: " + permission.getName() );
61 String obj = permission.getName();
62 if ( !removedPermissionNames.contains( obj ) )
64 removedPermissionNames.add( obj );
68 public void rbacPermissionSaved( Permission permission )
70 log( "Permission Saved: " + permission.getName() );
71 String obj = permission.getName();
72 if ( !addedPermissionNames.contains( obj ) )
74 addedPermissionNames.add( obj );
78 public void rbacRoleRemoved( Role role )
80 log( "Role Removed: " + role.getName() );
81 String obj = role.getName();
82 if ( !removedRoleNames.contains( obj ) )
84 removedRoleNames.add( obj );
88 public void rbacRoleSaved( Role role )
90 log( "Role Saved: " + role.getName() );
91 String obj = role.getName();
92 if ( !addedRoleNames.contains( obj ) )
94 addedRoleNames.add( obj );
98 public void rbacUserAssignmentRemoved( UserAssignment userAssignment )
103 public void rbacUserAssignmentSaved( UserAssignment userAssignment )
108 private void log( String msg )
110 System.out.println( "[RBAC Event Tracker] " + msg );