/*
- * Copyright (C) 2007-2012 Mathieu Baudier
+ * Copyright (C) 2007-2012 Argeo GmbH
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
protected Principal getOrCreatePrincipal(Session session,
String principalName) throws RepositoryException {
UserManager um = ((JackrabbitSession) session).getUserManager();
- Authorizable authorizable = um.getAuthorizable(principalName);
- if (authorizable == null) {
- groupPrefixes: for (String groupPrefix : groupPrefixes) {
- if (principalName.startsWith(groupPrefix)) {
- authorizable = um.createGroup(principalName);
- log.info("Created group " + principalName);
- break groupPrefixes;
+ synchronized (um) {
+ Authorizable authorizable = um.getAuthorizable(principalName);
+ if (authorizable == null) {
+ groupPrefixes: for (String groupPrefix : groupPrefixes) {
+ if (principalName.startsWith(groupPrefix)) {
+ authorizable = um.createGroup(principalName);
+ log.info("Created group " + principalName);
+ break groupPrefixes;
+ }
}
+ if (authorizable == null)
+ throw new ArgeoException("Authorizable " + principalName
+ + " not found");
}
- if (authorizable == null)
- throw new ArgeoException("Authorizable " + principalName
- + " not found");
+ return authorizable.getPrincipal();
}
- return authorizable.getPrincipal();
}
public void setGroupPrefixes(List<String> groupsToCreate) {