This project has retired. For details please refer to its
Attic page.
ConfigurableUserManager xref
1 package org.apache.archiva.redback.users.configurable;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 import org.apache.archiva.redback.configuration.UserConfiguration;
20 import org.apache.archiva.redback.configuration.UserConfigurationKeys;
21 import org.apache.archiva.redback.users.AbstractUserManager;
22 import org.apache.archiva.redback.users.User;
23 import org.apache.archiva.redback.users.UserManager;
24 import org.apache.archiva.redback.users.UserManagerException;
25 import org.apache.archiva.redback.users.UserNotFoundException;
26 import org.apache.archiva.redback.users.UserQuery;
27 import org.springframework.context.ApplicationContext;
28 import org.springframework.stereotype.Service;
29
30 import javax.annotation.PostConstruct;
31 import javax.inject.Inject;
32 import javax.inject.Named;
33 import java.util.List;
34
35
36
37
38 @Service( "userManager#configurable" )
39 public class ConfigurableUserManager
40 extends AbstractUserManager
41 implements UserManager
42 {
43 @Inject
44 @Named( value = "userConfiguration#default" )
45 private UserConfiguration config;
46
47 @Inject
48 private ApplicationContext applicationContext;
49
50 private UserManager userManagerImpl;
51
52
53 @PostConstruct
54 public void initialize()
55 {
56 String userManagerRole = config.getString( UserConfigurationKeys.USER_MANAGER_IMPL );
57
58 if ( userManagerRole == null )
59 {
60 throw new RuntimeException( "User Manager Configuration Missing: " + UserConfigurationKeys.USER_MANAGER_IMPL
61 + " configuration property" );
62 }
63
64 log.info( "use userManager impl with key: '{}'", userManagerRole );
65
66 userManagerImpl = applicationContext.getBean( "userManager#" + userManagerRole, UserManager.class );
67 }
68
69 public User addUser( User user )
70 throws UserManagerException
71 {
72 return userManagerImpl.addUser( user );
73 }
74
75 public void addUserUnchecked( User user )
76 throws UserManagerException
77 {
78 userManagerImpl.addUserUnchecked( user );
79 }
80
81 public User createUser( String username, String fullName, String emailAddress )
82 throws UserManagerException
83 {
84 return userManagerImpl.createUser( username, fullName, emailAddress );
85 }
86
87 public UserQuery createUserQuery()
88 {
89 return userManagerImpl.createUserQuery();
90 }
91
92 public void deleteUser( String username )
93 throws UserNotFoundException, UserManagerException
94 {
95 userManagerImpl.deleteUser( username );
96 }
97
98 public void eraseDatabase()
99 {
100 userManagerImpl.eraseDatabase();
101 }
102
103 public User findUser( String username )
104 throws UserManagerException, UserNotFoundException
105 {
106 return userManagerImpl.findUser( username );
107 }
108
109 @Override
110 public User getGuestUser()
111 throws UserNotFoundException, UserManagerException
112 {
113 return userManagerImpl.getGuestUser();
114 }
115
116 public List<User> findUsersByEmailKey( String emailKey, boolean orderAscending )
117 throws UserManagerException
118 {
119 return userManagerImpl.findUsersByEmailKey( emailKey, orderAscending );
120 }
121
122 public List<User> findUsersByFullNameKey( String fullNameKey, boolean orderAscending )
123 throws UserManagerException
124 {
125 return userManagerImpl.findUsersByFullNameKey( fullNameKey, orderAscending );
126 }
127
128 public List<User> findUsersByQuery( UserQuery query )
129 throws UserManagerException
130 {
131 return userManagerImpl.findUsersByQuery( query );
132 }
133
134 public List<User> findUsersByUsernameKey( String usernameKey, boolean orderAscending )
135 throws UserManagerException
136 {
137 return userManagerImpl.findUsersByUsernameKey( usernameKey, orderAscending );
138 }
139
140 public String getId()
141 {
142 return "configurable";
143 }
144
145 public List<User> getUsers()
146 throws UserManagerException
147 {
148 return userManagerImpl.getUsers();
149 }
150
151 public List<User> getUsers( boolean orderAscending )
152 throws UserManagerException
153 {
154 return userManagerImpl.getUsers( orderAscending );
155 }
156
157 public boolean isReadOnly()
158 {
159 return userManagerImpl.isReadOnly();
160 }
161
162 public User updateUser( User user )
163 throws UserNotFoundException, UserManagerException
164 {
165 return updateUser( user, false );
166 }
167
168 public User updateUser( User user, boolean passwordChangeRequired )
169 throws UserNotFoundException, UserManagerException
170 {
171 return userManagerImpl.updateUser( user, passwordChangeRequired );
172 }
173
174 public boolean userExists( String userName )
175 throws UserManagerException
176 {
177 return userManagerImpl.userExists( userName );
178 }
179
180 public void setUserManagerImpl( UserManager userManagerImpl )
181 {
182 this.userManagerImpl = userManagerImpl;
183 }
184
185 public String getDescriptionKey()
186 {
187 return "archiva.redback.usermanager.configurable";
188 }
189 }