import org.osgi.service.useradmin.User;
import org.osgi.service.useradmin.UserAdmin;
+import bitronix.tm.resource.ehcache.EhCacheXAResourceProducer;
+
/**
* Aggregates multiple {@link UserDirectory} and integrates them with this node
* system roles.
private Repository repository;
private Session adminSession;
+ private final String cacheName = UserDirectory.class.getName();
+
public NodeUserAdmin(TransactionManager transactionManager,
Repository repository) {
this.repository = repository;
if (userAdmins.get(name) instanceof UserDirectory) {
UserDirectory userDirectory = (UserDirectory) userAdmins
.get(name);
+ try {
+ // FIXME Make it less bitronix dependant
+ EhCacheXAResourceProducer.unregisterXAResource(cacheName,
+ userDirectory.getXaResource());
+ } catch (Exception e) {
+ log.error("Cannot unregister resource from Bitronix", e);
+ }
userDirectory.destroy();
+
}
}
}
//
// USER ADMIN AGGREGATOR
//
- public synchronized void addUserAdmin(String baseDn, UserAdmin userAdmin) {
+ public void addUserAdmin(String baseDn, UserAdmin userAdmin) {
if (userAdmins.containsKey(baseDn))
throw new UserDirectoryException(
"There is already a user admin for " + baseDn);
throw new UserDirectoryException("Badly formatted base DN "
+ baseDn, e);
}
+ if (userAdmin instanceof UserDirectory) {
+ try {
+ // FIXME Make it less bitronix dependant
+ EhCacheXAResourceProducer.registerXAResource(cacheName,
+ ((UserDirectory) userAdmin).getXaResource());
+ } catch (Exception e) {
+ log.error("Cannot register resource to Bitronix", e);
+ }
+ }
}
private UserAdmin findUserAdmin(String name) {
if (uri.startsWith("/") || uri.startsWith("./")
|| uri.startsWith("../"))
u = new File(uri).getCanonicalFile().toURI();
- else if (!uri.contains("/"))
- u = new File(nodeBaseDir, uri).getCanonicalFile()
- .toURI();
- else
+ else if (!uri.contains("/")) {
+ u = new URI(nodeBaseDir.toURI()+ uri);
+ // u = new File(nodeBaseDir, uri).getCanonicalFile()
+ // .toURI();
+ } else
throw new CmsException("Cannot interpret " + uri
+ " as an uri");
} else if (u.getScheme().equals("file")) {