You are viewing a plain text version of this content. The canonical link for it is here.
Posted to server-dev@james.apache.org by no...@apache.org on 2010/06/15 15:45:01 UTC
svn commit: r954882 - in /james/server/trunk: ./ core-function/
core-function/src/main/java/org/apache/james/mailrepository/
core-function/src/main/resources/org/ jcr-store/ spring-deployment/
user-function/ user-function/src/main/java/org/apache/james...
Author: norman
Date: Tue Jun 15 13:45:00 2010
New Revision: 954882
URL: http://svn.apache.org/viewvc?rev=954882&view=rev
Log:
Merge jcr-store to user-function and core-function.
Added:
james/server/trunk/core-function/src/main/java/org/apache/james/mailrepository/JCRMailRepository.java
- copied, changed from r954719, james/server/trunk/jcr-store/src/main/java/org/apache/james/jcr/JCRMailRepository.java
james/server/trunk/core-function/src/main/resources/org/
- copied from r954719, james/server/trunk/jcr-store/src/main/resources/org/
james/server/trunk/user-function/src/main/java/org/apache/james/userrepository/JCRUser.java
- copied, changed from r954719, james/server/trunk/jcr-store/src/main/java/org/apache/james/jcr/JCRUser.java
james/server/trunk/user-function/src/main/java/org/apache/james/userrepository/JCRUsersRepository.java
- copied, changed from r954719, james/server/trunk/jcr-store/src/main/java/org/apache/james/jcr/JCRUsersRepository.java
james/server/trunk/user-function/src/test/java/org/apache/james/userrepository/JcrUserRepositoryTest.java
- copied, changed from r954719, james/server/trunk/jcr-store/src/test/java/org/apache/james/jcr/JcrUserRepositoryTest.java
james/server/trunk/user-function/src/test/resources/log4j.properties
- copied unchanged from r954719, james/server/trunk/jcr-store/src/test/resources/log4j.properties
james/server/trunk/user-function/src/test/resources/test-repository.xml
- copied unchanged from r954719, james/server/trunk/jcr-store/src/test/resources/test-repository.xml
Removed:
james/server/trunk/jcr-store/
Modified:
james/server/trunk/core-function/pom.xml
james/server/trunk/pom.xml
james/server/trunk/spring-deployment/pom.xml
james/server/trunk/user-function/pom.xml
Modified: james/server/trunk/core-function/pom.xml
URL: http://svn.apache.org/viewvc/james/server/trunk/core-function/pom.xml?rev=954882&r1=954881&r2=954882&view=diff
==============================================================================
--- james/server/trunk/core-function/pom.xml (original)
+++ james/server/trunk/core-function/pom.xml Tue Jun 15 13:45:00 2010
@@ -75,6 +75,16 @@
<artifactId>jsr250-api</artifactId>
</dependency>
<dependency>
+ <groupId>javax.jcr</groupId>
+ <artifactId>jcr</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.jackrabbit</groupId>
+ <artifactId>jackrabbit-jcr-commons</artifactId>
+ </dependency>
+
+ <!-- Test dependencies -->
+ <dependency>
<groupId>commons-dbcp</groupId>
<artifactId>commons-dbcp</artifactId>
<scope>runtime</scope>
Copied: james/server/trunk/core-function/src/main/java/org/apache/james/mailrepository/JCRMailRepository.java (from r954719, james/server/trunk/jcr-store/src/main/java/org/apache/james/jcr/JCRMailRepository.java)
URL: http://svn.apache.org/viewvc/james/server/trunk/core-function/src/main/java/org/apache/james/mailrepository/JCRMailRepository.java?p2=james/server/trunk/core-function/src/main/java/org/apache/james/mailrepository/JCRMailRepository.java&p1=james/server/trunk/jcr-store/src/main/java/org/apache/james/jcr/JCRMailRepository.java&r1=954719&r2=954882&rev=954882&view=diff
==============================================================================
--- james/server/trunk/jcr-store/src/main/java/org/apache/james/jcr/JCRMailRepository.java (original)
+++ james/server/trunk/core-function/src/main/java/org/apache/james/mailrepository/JCRMailRepository.java Tue Jun 15 13:45:00 2010
@@ -1,4 +1,4 @@
-/*
+/**
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
@@ -14,12 +14,13 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.james.jcr;
+package org.apache.james.mailrepository;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
+import java.io.InputStreamReader;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.io.PipedInputStream;
@@ -33,7 +34,8 @@ import java.util.Date;
import java.util.Iterator;
import java.util.Properties;
-import javax.jcr.Credentials;
+import javax.annotation.PostConstruct;
+import javax.annotation.Resource;
import javax.jcr.Node;
import javax.jcr.NodeIterator;
import javax.jcr.PathNotFoundException;
@@ -43,12 +45,17 @@ import javax.jcr.PropertyType;
import javax.jcr.Repository;
import javax.jcr.RepositoryException;
import javax.jcr.Session;
+import javax.jcr.SimpleCredentials;
import javax.jcr.Value;
import javax.jcr.query.Query;
import javax.jcr.query.QueryManager;
import javax.mail.MessagingException;
import javax.mail.internet.MimeMessage;
+import org.apache.commons.configuration.ConfigurationException;
+import org.apache.commons.configuration.HierarchicalConfiguration;
+import org.apache.commons.logging.Log;
+import org.apache.jackrabbit.commons.cnd.CndImporter;
import org.apache.jackrabbit.util.ISO9075;
import org.apache.jackrabbit.util.Text;
import org.apache.james.core.MailImpl;
@@ -59,39 +66,54 @@ import org.apache.mailet.MailAddress;
/**
* Mail repository that is backed by a JCR content repository.
*/
-public class JCRMailRepository extends AbstractJCRRepository implements MailRepository {
+public class JCRMailRepository extends AbstractMailRepository implements MailRepository {
- /**
- * For setter injection.
- */
- public JCRMailRepository() {
- super("james/mail");
+ private final static String MAIL_PATH = "mailrepository";
+
+
+ private Repository repository;
+ private SimpleCredentials creds;
+ private String workspace;
+
+ private Log logger;
+
+ @Resource(name="jcrRepository")
+ public void setRepository(Repository repository) {
+ this.repository = repository;
}
- /**
- * Maximal constructor for injection.
- * @param repository not null
- * @param credentials login credentials for accessing the repository
- * or null to use default credentials
- * @param workspace name of the workspace used as the mail repository.
- * or null to use default workspace
- * @param path path (relative to root) of the user node within the workspace,
- * or null to use default.
- */
- public JCRMailRepository(Repository repository, Credentials credentials, String workspace, String path) {
- super(repository, credentials, workspace, path);
+ @PostConstruct
+ public void init() throws Exception {
+ // register the nodetype
+ CndImporter.registerNodeTypes(new InputStreamReader(Thread.currentThread().getContextClassLoader()
+ .getResourceAsStream("org/apache/james/imap/jcr/james.cnd")), login());
}
+
+ /*
+ * (non-Javadoc)
+ * @see org.apache.james.mailrepository.AbstractMailRepository#doConfigure(org.apache.commons.configuration.HierarchicalConfiguration)
+ */
+ public void doConfigure(HierarchicalConfiguration config)
+ throws ConfigurationException {
+ this.workspace = config.getString("workspace",null);
+ String username = config.getString("username", null);
+ String password = config.getString("password",null);
+
+ if (username != null && password != null) {
+ this.creds = new SimpleCredentials(username, password.toCharArray());
+ }
+ }
- /**
- * Minimal constructor for injection.
- * @param repository not null
- */
- public JCRMailRepository(Repository repository) {
- super(repository);
+
+ protected String toSafeName(String key) {
+ String name = ISO9075.encode(Text.escapeIllegalJcrChars(key));
+ return name;
}
-
-
-
+
+ private Session login() throws RepositoryException{
+ return repository.login(creds, workspace);
+ }
+
public Iterator<String> list() throws MessagingException {
try {
Session session = login();
@@ -99,7 +121,7 @@ public class JCRMailRepository extends A
Collection<String> keys = new ArrayList<String>();
QueryManager manager = session.getWorkspace().getQueryManager();
Query query = manager.createQuery(
- "/jcr:root/" + path + "//element(*,james:mail)",
+ "/jcr:root/" + MAIL_PATH + "//element(*,james:mail)",
Query.XPATH);
NodeIterator iterator = query.execute().getNodes();
while (iterator.hasNext()) {
@@ -122,7 +144,7 @@ public class JCRMailRepository extends A
String name = toSafeName(key);
QueryManager manager = session.getWorkspace().getQueryManager();
Query query = manager.createQuery(
- "/jcr:root/" + path + "//element(" + name + ",james:mail)",
+ "/jcr:root/" + MAIL_PATH + "//element(" + name + ",james:mail)",
Query.XPATH);
NodeIterator iterator = query.execute().getNodes();
if (iterator.hasNext()) {
@@ -142,108 +164,6 @@ public class JCRMailRepository extends A
}
}
- public void store(Mail mail) throws MessagingException {
- try {
- Session session = login();
- try {
- String name = Text.escapeIllegalJcrChars(mail.getName());
- final String xpath = "/jcr:root/" + path + "//element(" + name + ",james:mail)";
- NodeIterator iterator = query(session, xpath);
- if (iterator.hasNext()) {
- while (iterator.hasNext()) {
- setMail(iterator.nextNode(), mail);
- }
- } else {
- Node parent = session.getRootNode().getNode(path);
- Node node = parent.addNode(name, "james:mail");
- Node resource = node.addNode("jcr:content", "nt:resource");
- resource.setProperty("jcr:mimeType", "message/rfc822");
- setMail(node, mail);
- }
- session.save();
- logger.info("Mail " + mail.getName() + " stored in repository");
- } finally {
- session.logout();
- }
- } catch (IOException e) {
- throw new MessagingException(
- "Unable to store message: " + mail.getName(), e);
- } catch (RepositoryException e) {
- throw new MessagingException(
- "Unable to store message: " + mail.getName(), e);
- }
- }
-
- public void remove(String key) throws MessagingException {
- try {
- Session session = login();
- try {
- String name = ISO9075.encode(Text.escapeIllegalJcrChars(key));
- QueryManager manager = session.getWorkspace().getQueryManager();
- Query query = manager.createQuery(
- "/jcr:root/" + path + "//element(" + name + ",james:mail)",
- Query.XPATH);
- NodeIterator nodes = query.execute().getNodes();
- if (nodes.hasNext()) {
- while (nodes.hasNext()) {
- nodes.nextNode().remove();
- }
- session.save();
- logger.info("Mail " + key + " removed from repository");
- } else {
- logger.warn("Mail " + key + " not found");
- }
- } finally {
- session.logout();
- }
- } catch (RepositoryException e) {
- throw new MessagingException("Unable to remove message: " + key, e);
- }
- }
-
- public void remove(Mail mail) throws MessagingException {
- remove(mail.getName());
- }
-
- public void remove(Collection<Mail> mails) throws MessagingException {
- try {
- Session session = login();
- try {
- QueryManager manager = session.getWorkspace().getQueryManager();
- Iterator<Mail> iterator = mails.iterator();
- while (iterator.hasNext()) {
- Mail mail = iterator.next();
- try {
- String name = ISO9075.encode(
- Text.escapeIllegalJcrChars(mail.getName()));
- Query query = manager.createQuery(
- "/jcr:root/" + path + "//element(" + name + ",james:mail)",
- Query.XPATH);
- NodeIterator nodes = query.execute().getNodes();
- while (nodes.hasNext()) {
- nodes.nextNode().remove();
- }
- } catch (PathNotFoundException e) {
- logger.warn("Mail " + mail.getName() + " not found");
- }
- }
- session.save();
- logger.info("Mail collection removed from repository");
- } finally {
- session.logout();
- }
- } catch (RepositoryException e) {
- throw new MessagingException("Unable to remove messages", e);
- }
- }
-
- public boolean lock(String key) throws MessagingException {
- return false;
- }
-
- public boolean unlock(String key) throws MessagingException {
- return false;
- }
//-------------------------------------------------------------< private >
@@ -631,4 +551,70 @@ public class JCRMailRepository extends A
}
}
+ @Override
+ protected void internalRemove(String key) throws MessagingException {
+ try {
+ Session session = login();
+ try {
+ String name = ISO9075.encode(Text.escapeIllegalJcrChars(key));
+ QueryManager manager = session.getWorkspace().getQueryManager();
+ Query query = manager.createQuery(
+ "/jcr:root/" + MAIL_PATH + "//element(" + name + ",james:mail)",
+ Query.XPATH);
+ NodeIterator nodes = query.execute().getNodes();
+ if (nodes.hasNext()) {
+ while (nodes.hasNext()) {
+ nodes.nextNode().remove();
+ }
+ session.save();
+ logger.info("Mail " + key + " removed from repository");
+ } else {
+ logger.warn("Mail " + key + " not found");
+ }
+ } finally {
+ session.logout();
+ }
+ } catch (RepositoryException e) {
+ throw new MessagingException("Unable to remove message: " + key, e);
+ }
+ }
+
+ @Override
+ protected void internalStore(Mail mail) throws MessagingException,
+ IOException {
+ try {
+ Session session = login();
+ try {
+ String name = Text.escapeIllegalJcrChars(mail.getName());
+ final String xpath = "/jcr:root/" + MAIL_PATH + "//element(" + name + ",james:mail)";
+
+ QueryManager manager = session.getWorkspace().getQueryManager();
+ Query query = manager.createQuery(xpath, Query.XPATH);
+ NodeIterator iterator = query.execute().getNodes();
+
+ if (iterator.hasNext()) {
+ while (iterator.hasNext()) {
+ setMail(iterator.nextNode(), mail);
+ }
+ } else {
+ Node parent = session.getRootNode().getNode(MAIL_PATH);
+ Node node = parent.addNode(name, "james:mail");
+ Node resource = node.addNode("jcr:content", "nt:resource");
+ resource.setProperty("jcr:mimeType", "message/rfc822");
+ setMail(node, mail);
+ }
+ session.save();
+ logger.info("Mail " + mail.getName() + " stored in repository");
+ } finally {
+ session.logout();
+ }
+ } catch (IOException e) {
+ throw new MessagingException(
+ "Unable to store message: " + mail.getName(), e);
+ } catch (RepositoryException e) {
+ throw new MessagingException(
+ "Unable to store message: " + mail.getName(), e);
+ }
+ }
+
}
Modified: james/server/trunk/pom.xml
URL: http://svn.apache.org/viewvc/james/server/trunk/pom.xml?rev=954882&r1=954881&r2=954882&view=diff
==============================================================================
--- james/server/trunk/pom.xml (original)
+++ james/server/trunk/pom.xml Tue Jun 15 13:45:00 2010
@@ -50,7 +50,6 @@
<module>remotemanager</module>
<module>mailets</module>
<module>fetchmail</module>
- <module>jcr-store</module>
<module>spring-deployment</module>
<module>netty-socket</module>
@@ -524,11 +523,6 @@
</dependency>
<dependency>
<groupId>org.apache.james</groupId>
- <artifactId>james-server-jcr-store</artifactId>
- <version>${pom.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.james</groupId>
<artifactId>apache-james-imap-api</artifactId>
<version>${imap.version}</version>
<exclusions>
Modified: james/server/trunk/spring-deployment/pom.xml
URL: http://svn.apache.org/viewvc/james/server/trunk/spring-deployment/pom.xml?rev=954882&r1=954881&r2=954882&view=diff
==============================================================================
--- james/server/trunk/spring-deployment/pom.xml (original)
+++ james/server/trunk/spring-deployment/pom.xml Tue Jun 15 13:45:00 2010
@@ -484,11 +484,6 @@
<scope>runtime</scope>
</dependency>
<dependency>
- <groupId>org.apache.james</groupId>
- <artifactId>james-server-jcr-store</artifactId>
- <scope>runtime</scope>
- </dependency>
- <dependency>
<groupId>org.apache.jackrabbit</groupId>
<artifactId>jackrabbit-core</artifactId>
<scope>compile</scope>
Modified: james/server/trunk/user-function/pom.xml
URL: http://svn.apache.org/viewvc/james/server/trunk/user-function/pom.xml?rev=954882&r1=954881&r2=954882&view=diff
==============================================================================
--- james/server/trunk/user-function/pom.xml (original)
+++ james/server/trunk/user-function/pom.xml Tue Jun 15 13:45:00 2010
@@ -124,7 +124,15 @@
<groupId>org.apache.geronimo.specs</groupId>
<artifactId>geronimo-jpa_2.0_spec</artifactId>
</dependency>
-
+ <dependency>
+ <groupId>javax.jcr</groupId>
+ <artifactId>jcr</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.jackrabbit</groupId>
+ <artifactId>jackrabbit-jcr-commons</artifactId>
+ </dependency>
+
<!-- Test dependencies -->
<dependency>
<groupId>org.apache.james</groupId>
@@ -158,6 +166,21 @@
<artifactId>openjpa</artifactId>
<scope>test</scope>
</dependency>
+ <dependency>
+ <groupId>org.apache.jackrabbit</groupId>
+ <artifactId>jackrabbit-core</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-log4j12</artifactId>
+ <scope>runtime</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-api</artifactId>
+ <scope>runtime</scope>
+ </dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
Copied: james/server/trunk/user-function/src/main/java/org/apache/james/userrepository/JCRUser.java (from r954719, james/server/trunk/jcr-store/src/main/java/org/apache/james/jcr/JCRUser.java)
URL: http://svn.apache.org/viewvc/james/server/trunk/user-function/src/main/java/org/apache/james/userrepository/JCRUser.java?p2=james/server/trunk/user-function/src/main/java/org/apache/james/userrepository/JCRUser.java&p1=james/server/trunk/jcr-store/src/main/java/org/apache/james/jcr/JCRUser.java&r1=954719&r2=954882&rev=954882&view=diff
==============================================================================
--- james/server/trunk/jcr-store/src/main/java/org/apache/james/jcr/JCRUser.java (original)
+++ james/server/trunk/user-function/src/main/java/org/apache/james/userrepository/JCRUser.java Tue Jun 15 13:45:00 2010
@@ -17,7 +17,7 @@
* under the License. *
****************************************************************/
-package org.apache.james.jcr;
+package org.apache.james.userrepository;
import org.apache.jackrabbit.util.Text;
import org.apache.james.api.user.User;
Copied: james/server/trunk/user-function/src/main/java/org/apache/james/userrepository/JCRUsersRepository.java (from r954719, james/server/trunk/jcr-store/src/main/java/org/apache/james/jcr/JCRUsersRepository.java)
URL: http://svn.apache.org/viewvc/james/server/trunk/user-function/src/main/java/org/apache/james/userrepository/JCRUsersRepository.java?p2=james/server/trunk/user-function/src/main/java/org/apache/james/userrepository/JCRUsersRepository.java&p1=james/server/trunk/jcr-store/src/main/java/org/apache/james/jcr/JCRUsersRepository.java&r1=954719&r2=954882&rev=954882&view=diff
==============================================================================
--- james/server/trunk/jcr-store/src/main/java/org/apache/james/jcr/JCRUsersRepository.java (original)
+++ james/server/trunk/user-function/src/main/java/org/apache/james/userrepository/JCRUsersRepository.java Tue Jun 15 13:45:00 2010
@@ -17,60 +17,78 @@
* under the License. *
****************************************************************/
-package org.apache.james.jcr;
+package org.apache.james.userrepository;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;
-import javax.jcr.Credentials;
+import javax.annotation.Resource;
import javax.jcr.Node;
import javax.jcr.NodeIterator;
import javax.jcr.PathNotFoundException;
import javax.jcr.Repository;
import javax.jcr.RepositoryException;
import javax.jcr.Session;
+import javax.jcr.SimpleCredentials;
+import org.apache.commons.configuration.ConfigurationException;
+import org.apache.commons.configuration.HierarchicalConfiguration;
+import org.apache.commons.logging.Log;
+import org.apache.jackrabbit.util.ISO9075;
+import org.apache.jackrabbit.util.Text;
import org.apache.james.api.user.User;
import org.apache.james.api.user.UsersRepository;
+import org.apache.james.lifecycle.Configurable;
+import org.apache.james.lifecycle.LogEnabled;
-public class JCRUsersRepository extends AbstractJCRRepository implements UsersRepository {
+/**
+ * {@link UsersRepository} implementation which stores users to a JCR {@link Repository}
+ *
+ */
+public class JCRUsersRepository implements UsersRepository, Configurable, LogEnabled {
//TODO: Add namespacing
private static final String PASSWD_PROPERTY = "passwd";
private static final String USERNAME_PROPERTY = "username";
-
- /**
- * For setter injection.
- */
- public JCRUsersRepository() {
- super("users");
- }
+ private static final String USERS_PATH = "users";
- /**
- * Maximal constructor for injection.
- * @param repository not null
- * @param credentials login credentials for accessing the repository
- * or null to use default credentials
- * @param workspace name of the workspace used as the mail repository.
- * or null to use default workspace
- * @param path path (relative to root) of the user node within the workspace,
- * or null to use default.
- */
- public JCRUsersRepository(Repository repository, Credentials credentials, String workspace, String path) {
- super(repository, credentials, workspace, path);
+ private Repository repository;
+ private SimpleCredentials creds;
+ private String workspace;
+
+ private Log logger;
+
+ @Resource(name="jcrRepository")
+ public void setRepository(Repository repository) {
+ this.repository = repository;
}
- /**
- * Minimal constructor for injection.
- * @param repository not null
- */
- public JCRUsersRepository(Repository repository) {
- super(repository);
- this.path = "users";
- }
+ /*
+ * (non-Javadoc)
+ * @see org.apache.james.lifecycle.Configurable#configure(org.apache.commons.configuration.HierarchicalConfiguration)
+ */
+ public void configure(HierarchicalConfiguration config)
+ throws ConfigurationException {
+ this.workspace = config.getString("workspace",null);
+ String username = config.getString("username", null);
+ String password = config.getString("password",null);
+
+ if (username != null && password != null) {
+ this.creds = new SimpleCredentials(username, password.toCharArray());
+ }
+ }
+
+
+ /*
+ * (non-Javadoc)
+ * @see org.apache.james.lifecycle.LogEnabled#setLog(org.apache.commons.logging.Log)
+ */
+ public void setLog(Log log) {
+ this.logger = log;
+ }
/**
* Adds a user to the repository with the specified User object.
@@ -78,7 +96,6 @@ public class JCRUsersRepository extends
* @param user the user to be added
*
* @return true if succesful, false otherwise
- * @since James 1.2.2
*
* @deprecated James 2.4 user should be added using username/password
* because specific implementations of UsersRepository will support specific
@@ -113,7 +130,6 @@ public class JCRUsersRepository extends
* @param password the password of the user to add
* @return true if succesful, false otherwise
*
- * @since James 2.3.0
*/
public boolean addUser(String username, String password) {
@@ -121,7 +137,7 @@ public class JCRUsersRepository extends
final Session session = login();
try {
final String name = toSafeName(username);
- final String path = this.path + "/" + name;
+ final String path = USERS_PATH + "/" + name;
final Node rootNode = session.getRootNode();
try {
rootNode.getNode(path);
@@ -132,11 +148,11 @@ public class JCRUsersRepository extends
}
Node parent;
try {
- parent = rootNode.getNode(this.path);
+ parent = rootNode.getNode(USERS_PATH);
} catch (PathNotFoundException e) {
// TODO: Need to consider whether should insist that parent
// TODO: path exists.
- parent = rootNode.addNode(this.path);
+ parent = rootNode.addNode(USERS_PATH);
}
Node node = parent.addNode(name);
@@ -166,7 +182,16 @@ public class JCRUsersRepository extends
return false;
}
-
+
+ protected String toSafeName(String key) {
+ String name = ISO9075.encode(Text.escapeIllegalJcrChars(key));
+ return name;
+ }
+
+ private Session login() throws RepositoryException{
+ return repository.login(creds, workspace);
+ }
+
/**
* Get the user object with the specified user name. Return null if no
* such user.
@@ -174,7 +199,6 @@ public class JCRUsersRepository extends
* @param name the name of the user to retrieve
* @return the user being retrieved, null if the user doesn't exist
*
- * @since James 1.2.2
*/
public User getUserByName(String username) {
User user;
@@ -182,7 +206,7 @@ public class JCRUsersRepository extends
final Session session = login();
try {
final String name = toSafeName(username);
- final String path = this.path + "/" + name;
+ final String path = USERS_PATH + "/" + name;
final Node rootNode = session.getRootNode();
try {
@@ -247,7 +271,7 @@ public class JCRUsersRepository extends
final Session session = login();
try {
final String name = toSafeName(userName);
- final String path = this.path + "/" + name;
+ final String path = USERS_PATH + "/" + name;
final Node rootNode = session.getRootNode();
try {
@@ -282,7 +306,7 @@ public class JCRUsersRepository extends
final Session session = login();
try {
final String name = toSafeName(username);
- final String path = this.path + "/" + name;
+ final String path = USERS_PATH + "/" + name;
try {
session.getRootNode().getNode(path).remove();
session.save();
@@ -311,7 +335,7 @@ public class JCRUsersRepository extends
final Session session = login();
try {
final Node rootNode = session.getRootNode();
- final String path = this.path + "/" + toSafeName(name);
+ final String path = USERS_PATH + "/" + toSafeName(name);
rootNode.getNode(path);
return true;
} finally {
@@ -357,7 +381,7 @@ public class JCRUsersRepository extends
final Session session = login();
try {
final String name = toSafeName(username);
- final String path = this.path + "/" + name;
+ final String path = USERS_PATH + "/" + name;
final Node rootNode = session.getRootNode();
try {
@@ -398,7 +422,7 @@ public class JCRUsersRepository extends
try {
final Node rootNode = session.getRootNode();
try {
- final Node node = rootNode.getNode(path);
+ final Node node = rootNode.getNode(USERS_PATH);
//TODO: Use query
//TODO: Use namespacing to avoid unwanted nodes
NodeIterator it = node.getNodes();
@@ -429,7 +453,7 @@ public class JCRUsersRepository extends
try {
final Node rootNode = session.getRootNode();
try {
- final Node baseNode = rootNode.getNode(path);
+ final Node baseNode = rootNode.getNode(USERS_PATH);
//TODO: Use query
final NodeIterator it = baseNode.getNodes();
while(it.hasNext()) {
@@ -454,4 +478,5 @@ public class JCRUsersRepository extends
}
return userNames.iterator();
}
+
}
Copied: james/server/trunk/user-function/src/test/java/org/apache/james/userrepository/JcrUserRepositoryTest.java (from r954719, james/server/trunk/jcr-store/src/test/java/org/apache/james/jcr/JcrUserRepositoryTest.java)
URL: http://svn.apache.org/viewvc/james/server/trunk/user-function/src/test/java/org/apache/james/userrepository/JcrUserRepositoryTest.java?p2=james/server/trunk/user-function/src/test/java/org/apache/james/userrepository/JcrUserRepositoryTest.java&p1=james/server/trunk/jcr-store/src/test/java/org/apache/james/jcr/JcrUserRepositoryTest.java&r1=954719&r2=954882&rev=954882&view=diff
==============================================================================
--- james/server/trunk/jcr-store/src/test/java/org/apache/james/jcr/JcrUserRepositoryTest.java (original)
+++ james/server/trunk/user-function/src/test/java/org/apache/james/userrepository/JcrUserRepositoryTest.java Tue Jun 15 13:45:00 2010
@@ -17,10 +17,11 @@
* under the License. *
****************************************************************/
-package org.apache.james.jcr;
+package org.apache.james.userrepository;
import java.io.File;
+import org.apache.commons.configuration.DefaultConfigurationBuilder;
import org.apache.commons.logging.impl.SimpleLog;
import org.apache.jackrabbit.core.RepositoryImpl;
import org.apache.jackrabbit.core.config.RepositoryConfig;
@@ -34,7 +35,12 @@ public class JcrUserRepositoryTest exten
private RepositoryImpl repository;
protected UsersRepository getUsersRepository() throws Exception {
- JCRUsersRepository repos = new JCRUsersRepository(repository);
+ JCRUsersRepository repos = new JCRUsersRepository();
+ repos.setRepository(repository);
+ DefaultConfigurationBuilder config = new DefaultConfigurationBuilder();
+ config.addProperty("username", "admin");
+ config.addProperty("password", "test");
+ repos.configure(config);
repos.setLog(new SimpleLog("MockLog"));
return repos;
}
---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org