public Session getProviderSession(JCRStoreProvider provider) throws RepositoryException { if (sessions.get(provider) == null) { Session s = null; if (credentials instanceof SimpleCredentials) { SimpleCredentials simpleCredentials = (SimpleCredentials) credentials; JahiaLoginModule.Token t = JahiaLoginModule.getToken( simpleCredentials.getUserID(), new String(simpleCredentials.getPassword())); s = provider.getSession(credentials, workspace.getName()); credentials = JahiaLoginModule.getCredentials( simpleCredentials.getUserID(), t != null ? t.deniedPath : null); } else { s = provider.getSession(credentials, workspace.getName()); } sessions.put(provider, s); for (String token : tokens) { s.addLockToken(token); } NamespaceRegistry namespaceRegistryWrapper = getWorkspace().getNamespaceRegistry(); NamespaceRegistry providerNamespaceRegistry = s.getWorkspace().getNamespaceRegistry(); if (providerNamespaceRegistry != null) { for (String prefix : namespaceRegistryWrapper.getPrefixes()) { try { providerNamespaceRegistry.getURI(prefix); } catch (NamespaceException ne) { providerNamespaceRegistry.registerNamespace( prefix, namespaceRegistryWrapper.getURI(prefix)); } } } for (String prefix : prefixToNs.keySet()) { s.setNamespacePrefix(prefix, prefixToNs.get(prefix)); } } return sessions.get(provider); }
/** * Adds the specified lock token to the wrapped sessions. Holding a lock token makes the <code> * Session</code> the owner of the lock specified by that particular lock token. * * @param token a lock token (a string). * @deprecated As of JCR 2.0, {@link LockManager#addLockToken(String)} should be used instead. */ public void addLockToken(String token) { tokens.add(token); for (Session session : sessions.values()) { session.addLockToken(token); } }