[dna-commits] DNA SVN: r1161 - in branches/eclipse/dna-web-jcr-rest-client: src/main/java/org/jboss/dna/web/jcr/rest/client and 6 other directories.

dna-commits at lists.jboss.org dna-commits at lists.jboss.org
Fri Aug 14 12:29:04 EDT 2009


Author: elvisisking
Date: 2009-08-14 12:29:03 -0400 (Fri, 14 Aug 2009)
New Revision: 1161

Added:
   branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/RestClientI18n.java
   branches/eclipse/dna-web-jcr-rest-client/src/main/resources/org/jboss/dna/web/jcr/rest/client/RestClientI18n.properties
   branches/eclipse/dna-web-jcr-rest-client/src/main/resources/org/jboss/dna/web/jcr/rest/client/mime.types
   branches/eclipse/dna-web-jcr-rest-client/src/test/java/org/jboss/dna/web/jcr/rest/client/MockRestClient.java
   branches/eclipse/dna-web-jcr-rest-client/src/test/java/org/jboss/dna/web/jcr/rest/client/RestClientI18nTest.java
   branches/eclipse/dna-web-jcr-rest-client/src/test/java/org/jboss/dna/web/jcr/rest/client/RestIntegrationTest.java
Removed:
   branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/IMessages.java
   branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/Logger.java
   branches/eclipse/dna-web-jcr-rest-client/src/main/resources/org/jboss/dna/web/jcr/rest/client/Messages.properties
   branches/eclipse/dna-web-jcr-rest-client/src/test/java/org/jboss/dna/web/jcr/rest/client/MockRestExecutor.java
Modified:
   branches/eclipse/dna-web-jcr-rest-client/
   branches/eclipse/dna-web-jcr-rest-client/pom.xml
   branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/IRestClient.java
   branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/ServerAuthenticator.java
   branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/ServerManager.java
   branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/ServerRegistryEvent.java
   branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/Status.java
   branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/Utils.java
   branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/domain/Repository.java
   branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/domain/Server.java
   branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/domain/Workspace.java
   branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/domain/validation/RepositoryValidator.java
   branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/domain/validation/ServerValidator.java
   branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/domain/validation/WorkspaceValidator.java
   branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/json/FileNode.java
   branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/json/FolderNode.java
   branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/json/JsonNode.java
   branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/json/JsonRestClient.java
   branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/json/JsonUtils.java
   branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/json/RepositoryNode.java
   branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/json/ServerNode.java
   branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/json/WorkspaceNode.java
   branches/eclipse/dna-web-jcr-rest-client/src/test/java/org/jboss/dna/web/jcr/rest/client/ServerManagerTest.java
   branches/eclipse/dna-web-jcr-rest-client/src/test/java/org/jboss/dna/web/jcr/rest/client/json/JsonRestClientTest.java
Log:
Now using dna-common's logger, I18n, CheckArg, and extension-based mime detector frameworks. Added a ServerAuthenticator that works with ServerManager's server registry for authentication. Added a "ping" method to ServerManager so that the client UI can test a connection before actually creating it. Added "Authorization" request property to the HTTPConnection. Did some work with javadocs.


Property changes on: branches/eclipse/dna-web-jcr-rest-client
___________________________________________________________________
Name: svn:ignore
   + target


Modified: branches/eclipse/dna-web-jcr-rest-client/pom.xml
===================================================================
--- branches/eclipse/dna-web-jcr-rest-client/pom.xml	2009-08-10 21:31:32 UTC (rev 1160)
+++ branches/eclipse/dna-web-jcr-rest-client/pom.xml	2009-08-14 16:29:03 UTC (rev 1161)
@@ -18,11 +18,19 @@
 		those defined in the dependencyManagement section of the parent pom.
 	-->
 	<dependencies>
-		<!-- 
-        Testing (note the scope)
-    -->
 		<dependency>
 			<groupId>org.jboss.dna</groupId>
+			<artifactId>dna-common</artifactId>
+		</dependency>
+		<dependency>
+			<groupId>org.jboss.dna</groupId>
+			<artifactId>dna-common</artifactId>
+			<version>${pom.version}</version>
+			<type>test-jar</type>
+			<scope>test</scope>
+		</dependency>
+		<dependency>
+			<groupId>org.jboss.dna</groupId>
 			<artifactId>dna-web-jcr-rest-war</artifactId>
 			<type>war</type>
 			<version>${pom.version}</version>

Deleted: branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/IMessages.java
===================================================================
--- branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/IMessages.java	2009-08-10 21:31:32 UTC (rev 1160)
+++ branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/IMessages.java	2009-08-14 16:29:03 UTC (rev 1161)
@@ -1,99 +0,0 @@
-/*
- * JBoss DNA (http://www.jboss.org/dna)
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership.  Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- * See the AUTHORS.txt file in the distribution for a full listing of 
- * individual contributors. 
- *
- * JBoss DNA is free software. Unless otherwise indicated, all code in JBoss DNA
- * is licensed to you under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * JBoss DNA is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.dna.web.jcr.rest.client;
-
-import java.util.ResourceBundle;
-
-/**
- * The <code>IMessages</code> interface are the resource bundle keys used in the <code>Messages.properties</code> file.
- * 
- * @since 0.6
- */
-public interface IMessages {
-
-    ResourceBundle MESSAGES = ResourceBundle.getBundle(IMessages.class.getPackage().getName() + ".Messages"); //$NON-NLS-1$
-
-    String ErrorDeletingServerRegistryFile = "ErrorDeletingServerRegistryFile"; //$NON-NLS-1$
-
-    String ErrorRestoringServerRegistry = "ErrorRestoringServerRegistry"; //$NON-NLS-1$
-
-    String ErrorSavingServerRegistry = "ErrorSavingServerRegistry"; //$NON-NLS-1$
-
-    String NullArgumentMsg = "NullArgumentMsg"; //$NON-NLS-1$
-
-    String RepositoryEmptyNameMsg = "RepositoryEmptyNameMsg"; //$NON-NLS-1$
-
-    String RepositoryNullServerMsg = "RepositoryNullServerMsg"; //$NON-NLS-1$
-
-    String RepositoryShortDescription = "RepositoryShortDescription"; //$NON-NLS-1$
-
-    String ServerEmptyUrlMsg = "ServerEmptyUrlMsg"; //$NON-NLS-1$
-
-    String ServerInvalidUrlMsg = "ServerInvalidUrlMsg"; //$NON-NLS-1$
-
-    String ServerEmptyUserMsg = "ServerEmptyUserMsg"; //$NON-NLS-1$
-
-    String ServerExistsMsg = "ServerExistsMsg"; //$NON-NLS-1$
-
-    String ServerManagerRegistryAddUnexpectedError = "ServerManagerRegistryAddUnexpectedError"; //$NON-NLS-1$
-
-    String ServerManagerRegistryListenerError = "ServerManagerRegistryListenerError"; //$NON-NLS-1$
-
-    String ServerManagerRegistryListenerErrorsOccurred = "ServerManagerRegistryListenerErrorsOccurred"; //$NON-NLS-1$
-
-    String ServerManagerRegistryRemoveUnexpectedError = "ServerManagerRegistryRemoveUnexpectedError"; //$NON-NLS-1$
-
-    String ServerManagerRegistryUpdateAddError = "ServerManagerRegistryUpdateAddError"; //$NON-NLS-1$
-
-    String ServerManagerRegistryUpdateRemoveError = "ServerManagerRegistryUpdateRemoveError"; //$NON-NLS-1$
-
-    String ServerManagerUnregisteredServer = "ServerManagerUnregisteredServer"; //$NON-NLS-1$
-
-    String ServerShortDescription = "ServerShortDescription"; //$NON-NLS-1$
-
-    String WorkspaceEmptyNameMsg = "WorkspaceEmptyNameMsg"; //$NON-NLS-1$
-
-    String WorkspaceNullRepositoryMsg = "WorkspaceNullRepositoryMsg"; //$NON-NLS-1$
-
-    String WorkspaceShortDescription = "WorkspaceShortDescription"; //$NON-NLS-1$
-
-    // JsonRestClient messages
-
-    String ConnectionErrorMsg = "ConnectionErrorMsg"; //$NON-NLS-1$
-
-    String CreateFileFailedMsg = "CreateFileFailedMsg"; //$NON-NLS-1$
-
-    String CreateFolderFailedMsg = "CreateFolderFailedMsg"; //$NON-NLS-1$
-
-    String GetRepositoriesFailedMsg = "GetRepositoriesFailedMsg"; //$NON-NLS-1$
-
-    String GetWorkspacesFailedMsg = "GetWorkspacesFailedMsg"; //$NON-NLS-1$
-
-    String PublishFailedMsg = "PublishFailedMsg"; //$NON-NLS-1$
-
-    String UnpublishFailedMsg = "UnpublishFailedMsg"; //$NON-NLS-1$
-
-    String UnpublishNeverPublishedMsg = "UnpublishNeverPublishedMsg"; //$NON-NLS-1$
-
-}

Modified: branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/IRestClient.java
===================================================================
--- branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/IRestClient.java	2009-08-10 21:31:32 UTC (rev 1160)
+++ branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/IRestClient.java	2009-08-14 16:29:03 UTC (rev 1161)
@@ -61,7 +61,7 @@
      * Publishes, or uploads, a local file to the workspace at the specified path.
      * 
      * @param workspace the workspace where the resource will be published (never <code>null</code>)
-     * @param path the path to the folder where the file will be published (never <code>null</code>)
+     * @param path the unencoded path to the folder where the file will be published (never <code>null</code>)
      * @param file the resource being published (never <code>null</code>)
      * @return a status of the publishing operation outcome (never <code>null</code>)
      * @since 0.6
@@ -75,7 +75,7 @@
      * the workspace an {@link Severity#INFO info status} is returned.
      * 
      * @param workspace the workspace where the resource will be unpublished (never <code>null</code>)
-     * @param path the path to the folder where the file is published (never <code>null</code>)
+     * @param path the unencoded path to the folder where the file is published (never <code>null</code>)
      * @param file the file being unpublished (never <code>null</code>)
      * @return a status of the unpublishing operation outcome (never <code>null</code>)
      * @since 0.6

Deleted: branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/Logger.java
===================================================================
--- branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/Logger.java	2009-08-10 21:31:32 UTC (rev 1160)
+++ branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/Logger.java	2009-08-14 16:29:03 UTC (rev 1161)
@@ -1,249 +0,0 @@
-/*
- * JBoss DNA (http://www.jboss.org/dna)
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership.  Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- * See the AUTHORS.txt file in the distribution for a full listing of 
- * individual contributors.
- *
- * JBoss DNA is free software. Unless otherwise indicated, all code in JBoss DNA
- * is licensed to you under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- * 
- * JBoss DNA is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.dna.web.jcr.rest.client;
-
-import java.text.MessageFormat;
-import org.slf4j.LoggerFactory;
-
-/**
- * The <code>Logger</code> class provides a basic interface into an Eclipse SLF4J implementation.
- * 
- * @since 0.6
- */
-public final class Logger {
-
-    // ===========================================================================================================================
-    // Class Methods
-    // ===========================================================================================================================
-
-    /**
-     * @param clazz the class whose logger will be used
-     * @param message the localized message
-     * @return the message prepended with the class name and a delimiter
-     * @since 0.6
-     */
-    private static String getMessage( Class<?> clazz,
-                                      String message ) {
-        return (clazz.getSimpleName() + ": " + message); //$NON-NLS-1$
-    }
-
-    /**
-     * @param clazz the class whose logger will be used
-     * @param pattern the {@link MessageFormat} pattern
-     * @param arguments the arguments being inserted into the pattern
-     * @return the message
-     * @since 0.6
-     */
-    private static String getMessage( Class<?> clazz,
-                                      String pattern,
-                                      Object... arguments ) {
-        return getMessage(clazz, MessageFormat.format(pattern, arguments));
-    }
-
-    /**
-     * @param clazz the class whose logger will be used
-     * @param status the status whose message is a {@link MessageFormat} pattern
-     * @param arguments the arguments being inserted into the pattern
-     * @return the message
-     * @since 0.6
-     */
-    private static String getMessage( Class<?> clazz,
-                                      Status status,
-                                      Object... arguments ) {
-        return getMessage(clazz, status.getMessage(), arguments);
-    }
-
-    /**
-     * @param clazz the class whose logger will be used (never <code>null</code>)
-     * @param status the status being logged (never <code>null</code>)
-     * @since 0.6
-     */
-    public static void log( Class<?> clazz,
-                            Status status ) {
-        Utils.nullArgumentCheck("clazz", clazz); //$NON-NLS-1$
-        Utils.nullArgumentCheck("status", status); //$NON-NLS-1$
-
-        org.slf4j.Logger delegate = null;
-
-        try {
-            delegate = LoggerFactory.getLogger(clazz);
-        } catch (Throwable e) {
-            // adapter not found
-            System.err.println(status.getMessage());
-            return;
-        }
-
-        if (status.isError() && delegate.isErrorEnabled()) {
-            if (status.getException() == null) {
-                delegate.error(getMessage(clazz, status.getMessage()));
-            } else {
-                delegate.error(getMessage(clazz, status.getMessage()), status.getException());
-            }
-        } else if (status.isWarning() && delegate.isWarnEnabled()) {
-            if (status.getException() == null) {
-                delegate.warn(getMessage(clazz, status.getMessage()));
-            } else {
-                delegate.warn(getMessage(clazz, status.getMessage()), status.getException());
-            }
-        } else if (status.isInfo() && delegate.isInfoEnabled()) {
-            if (status.getException() == null) {
-                delegate.info(getMessage(clazz, status.getMessage()));
-            } else {
-                delegate.info(getMessage(clazz, status.getMessage()), status.getException());
-            }
-        } else {
-            trace(clazz, null, status.getMessage());
-        }
-    }
-
-    /**
-     * @param clazz the class whose logger will be used (never <code>null</code>)
-     * @param status the status being logged whose message is a {@link MessageFormat} pattern (never <code>null</code>)
-     * @param arguments the arguments to be inserted into the pattern (never <code>null</code>)
-     * @since 0.6
-     */
-    public static void log( Class<?> clazz,
-                            Status status,
-                            Object... arguments ) {
-        Utils.nullArgumentCheck("clazz", clazz); //$NON-NLS-1$
-        Utils.nullArgumentCheck("status", status); //$NON-NLS-1$
-        Utils.nullArgumentCheck("arguments", arguments); //$NON-NLS-1$
-
-        org.slf4j.Logger delegate = null;
-
-        try {
-            delegate = LoggerFactory.getLogger(clazz);
-        } catch (Throwable e) {
-            // adapter not found
-            System.err.println(status.getMessage());
-            return;
-        }
-
-        if (status.isError() && delegate.isErrorEnabled()) {
-            String msg = getMessage(clazz, status, arguments);
-
-            if (status.getException() == null) {
-                delegate.error(msg);
-            } else {
-                delegate.error(msg, status.getException());
-            }
-        } else if (status.isWarning() && delegate.isWarnEnabled()) {
-            String msg = getMessage(clazz, status, arguments);
-
-            if (status.getException() == null) {
-                delegate.warn(msg);
-            } else {
-                delegate.warn(msg, status.getException());
-            }
-        } else if (status.isInfo() && delegate.isInfoEnabled()) {
-            String msg = getMessage(clazz, status, arguments);
-
-            if (status.getException() == null) {
-                delegate.info(msg);
-            } else {
-                delegate.info(msg, status.getException());
-            }
-        } else {
-            trace(clazz, status.getException(), status.getMessage(), arguments);
-        }
-    }
-
-    /**
-     * @param clazz the class whose logger will be used
-     * @param e the error being logged or <code>null</code>
-     * @param msg the message being logged (never <code>null</code>)
-     * @since 0.6
-     */
-    public static void trace( Class<?> clazz,
-                              Throwable e,
-                              String msg ) {
-        Utils.nullArgumentCheck("clazz", clazz); //$NON-NLS-1$
-        Utils.nullArgumentCheck("msg", msg); //$NON-NLS-1$
-
-        org.slf4j.Logger delegate = null;
-
-        try {
-            delegate = LoggerFactory.getLogger(clazz);
-        } catch (Throwable error) {
-            // adapter not found
-            System.err.println(msg);
-            return;
-        }
-
-        if (delegate.isTraceEnabled()) {
-            if (e == null) {
-                delegate.trace(getMessage(clazz, msg));
-            } else {
-                delegate.trace(getMessage(clazz, msg), e);
-            }
-        }
-    }
-
-    /**
-     * @param clazz the class whose logger will be used (never <code>null</code>)
-     * @param e the error being logged or <code>null</code>
-     * @param pattern the {@link MessageFormat} pattern (never <code>null</code>)
-     * @param arguments the arguments to be inserted into the pattern (never <code>null</code>)
-     * @since 0.6
-     */
-    public static void trace( Class<?> clazz,
-                              Throwable e,
-                              String pattern,
-                              Object... arguments ) {
-        Utils.nullArgumentCheck("clazz", clazz); //$NON-NLS-1$
-        Utils.nullArgumentCheck("pattern", pattern); //$NON-NLS-1$
-        Utils.nullArgumentCheck("arguments", arguments); //$NON-NLS-1$
-
-        org.slf4j.Logger delegate = null;
-
-        try {
-            delegate = LoggerFactory.getLogger(clazz);
-        } catch (Throwable error) {
-            // adapter not found
-            System.err.println(MessageFormat.format(pattern, arguments));
-            return;
-        }
-
-        if (delegate.isTraceEnabled()) {
-            if (e == null) {
-                delegate.trace(getMessage(clazz, pattern, arguments));
-            } else {
-                delegate.trace(getMessage(clazz, pattern, arguments), e);
-            }
-        }
-    }
-
-    // ===========================================================================================================================
-    // Constructors
-    // ===========================================================================================================================
-
-    /**
-     * Don't allow construction.
-     * 
-     * @since 0.6
-     */
-    private Logger() {
-        // nothing to do
-    }
-}

Copied: branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/RestClientI18n.java (from rev 1148, branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/IMessages.java)
===================================================================
--- branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/RestClientI18n.java	                        (rev 0)
+++ branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/RestClientI18n.java	2009-08-14 16:29:03 UTC (rev 1161)
@@ -0,0 +1,109 @@
+/*
+ * JBoss DNA (http://www.jboss.org/dna)
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership.  Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ * See the AUTHORS.txt file in the distribution for a full listing of 
+ * individual contributors. 
+ *
+ * JBoss DNA is free software. Unless otherwise indicated, all code in JBoss DNA
+ * is licensed to you under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * JBoss DNA is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.dna.web.jcr.rest.client;
+
+import org.jboss.dna.common.i18n.I18n;
+
+/**
+ * The <code>RestClientI18n</code> class provides localized messages.
+ * 
+ * @since 0.6
+ */
+public final class RestClientI18n {
+
+    public static I18n errorDeletingServerRegistryFile;
+
+    public static I18n errorRestoringServerRegistry;
+
+    public static I18n errorSavingServerRegistry;
+
+    public static I18n nullArgumentMsg;
+
+    public static I18n repositoryEmptyNameMsg;
+
+    public static I18n repositoryNullServerMsg;
+
+    public static I18n repositoryShortDescription;
+
+    public static I18n serverEmptyUrlMsg;
+
+    public static I18n serverEmptyUserMsg;
+
+    public static I18n serverExistsMsg;
+
+    public static I18n serverInvalidUrlMsg;
+
+    public static I18n serverManagerConnectionEstablishedMsg;
+
+    public static I18n serverManagerConnectionFailedMsg;
+
+    public static I18n serverManagerRegistryAddUnexpectedError;
+
+    public static I18n serverManagerRegistryListenerError;
+
+    public static I18n serverManagerRegistryListenerErrorsOccurred;
+
+    public static I18n serverManagerRegistryRemoveUnexpectedError;
+
+    public static I18n serverManagerRegistryUpdateAddError;
+
+    public static I18n serverManagerRegistryUpdateRemoveError;
+
+    public static I18n serverManagerUnregisteredServer;
+
+    public static I18n serverShortDescription;
+
+    public static I18n workspaceEmptyNameMsg;
+
+    public static I18n workspaceNullRepositoryMsg;
+
+    public static I18n workspaceShortDescription;
+
+    // JsonRestClient messages
+
+    public static I18n connectionErrorMsg;
+
+    public static I18n createFileFailedMsg;
+
+    public static I18n createFolderFailedMsg;
+
+    public static I18n getRepositoriesFailedMsg;
+
+    public static I18n getWorkspacesFailedMsg;
+
+    public static I18n publishFailedMsg;
+
+    public static I18n unpublishFailedMsg;
+
+    public static I18n unpublishNeverPublishedMsg;
+
+    static {
+        try {
+            I18n.initialize(RestClientI18n.class);
+        } catch (Exception e) {
+            System.err.println(e);
+        }
+    }
+
+}


Property changes on: branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/RestClientI18n.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Modified: branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/ServerAuthenticator.java
===================================================================
--- branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/ServerAuthenticator.java	2009-08-10 21:31:32 UTC (rev 1160)
+++ branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/ServerAuthenticator.java	2009-08-14 16:29:03 UTC (rev 1161)
@@ -25,8 +25,11 @@
 
 import java.net.Authenticator;
 import java.net.PasswordAuthentication;
+import org.jboss.dna.web.jcr.rest.client.domain.Server;
 
 /**
+ * The <code>ServerAuthenticator</code> class provides user names and passwords to the HTTP connection.
+ * 
  * @since 0.6
  */
 public class ServerAuthenticator extends Authenticator {
@@ -35,12 +38,21 @@
     // Fields
     // ===========================================================================================================================
 
+    /**
+     * The object managing the server registry.
+     * 
+     * @since 0.6
+     */
     private final ServerManager serverManager;
 
     // ===========================================================================================================================
     // Constructors
     // ===========================================================================================================================
 
+    /**
+     * @param serverManager the server manager manages the server registry
+     * @since 0.6
+     */
     public ServerAuthenticator( ServerManager serverManager ) {
         this.serverManager = serverManager;
     }
@@ -57,73 +69,8 @@
      */
     @Override
     protected PasswordAuthentication getPasswordAuthentication() {
-        // URL url = getRequestingURL();
-        return super.getPasswordAuthentication();
+        Server server = this.serverManager.getCurrentServer();
+        return new PasswordAuthentication(server.getUser(), server.getPassword().toCharArray());
     }
 
-    /*    
-        public final class DelegatingAuthenticator extends Authenticator {
-
-            private static DelegatingAuthenticator m_INSTANCE;
-
-            private Map m_authenticators;
-
-            static public DelegatingAuthenticator getInstance() {
-                synchronized (DelegatingAuthenticator.class) {
-                    if (m_INSTANCE == null) {
-                        m_INSTANCE = new DelegatingAuthenticator();
-                        Authenticator.setDefault(m_INSTANCE);
-                    }
-                    return m_INSTANCE;
-                }
-            }
-
-            private DelegatingAuthenticator() {
-                m_authenticators = new HashMap();
-            }
-
-            public void addTransitAuthenticator( TransitAuthenticator authenticator,
-                                                 RequestIdentifier id ) {
-                synchronized (m_authenticators) {
-                    m_authenticators.put(id, authenticator);
-                }
-            }
-
-            public void removeTransitAuthenticator( TransitAuthenticator authenticator ) {
-                synchronized (m_authenticators) {
-                    Iterator list = m_authenticators.values().iterator();
-                    while (list.hasNext()) {
-                        Authenticator item = (Authenticator)list.next();
-                        if (item.equals(authenticator)) {
-                            list.remove();
-                        }
-                    }
-                }
-            }
-
-            protected PasswordAuthentication getPasswordAuthentication() {
-                try {
-                    String host = getRequestingHost();
-                    String protocol = getRequestingProtocol();
-                    String prompt = getRequestingPrompt();
-                    String scheme = getRequestingScheme();
-                    int port = getRequestingPort();
-                    InetAddress addr = getRequestingSite();
-                    if (addr == null) {
-                        addr = InetAddress.getByName(host);
-                    }
-                    RequestIdentifier id = new RequestIdentifier(addr, port, protocol, scheme, prompt);
-                    synchronized (m_authenticators) {
-                        TransitAuthenticator auth = (TransitAuthenticator)m_authenticators.get(id);
-                        if (auth == null) {
-                            return null;
-                        }
-                        return auth.resolvePasswordAuthentication(this);
-                    }
-                } catch (UnknownHostException e) {
-                    return null;
-                }
-            }
-        }
-    */
 }

Modified: branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/ServerManager.java
===================================================================
--- branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/ServerManager.java	2009-08-10 21:31:32 UTC (rev 1160)
+++ branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/ServerManager.java	2009-08-14 16:29:03 UTC (rev 1161)
@@ -23,9 +23,9 @@
  */
 package org.jboss.dna.web.jcr.rest.client;
 
-import static org.jboss.dna.web.jcr.rest.client.IMessages.MESSAGES;
 import java.io.File;
 import java.io.FileOutputStream;
+import java.net.Authenticator;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collection;
@@ -43,6 +43,8 @@
 import javax.xml.transform.stream.StreamResult;
 import net.jcip.annotations.GuardedBy;
 import net.jcip.annotations.ThreadSafe;
+import org.jboss.dna.common.util.CheckArg;
+import org.jboss.dna.common.util.Logger;
 import org.jboss.dna.web.jcr.rest.client.Status.Severity;
 import org.jboss.dna.web.jcr.rest.client.domain.Repository;
 import org.jboss.dna.web.jcr.rest.client.domain.Server;
@@ -109,6 +111,31 @@
     private static final String USER_TAG = "user"; //$NON-NLS-1$
 
     // ===========================================================================================================================
+    // Class Fields
+    // ===========================================================================================================================
+
+    /**
+     * The java.net.Authenticator needs server information to complete the publish, unpublish, getRepositories(), and
+     * getWorkspaces() operations. Setting a thread variable was a way to do that.
+     * 
+     * @see ServerAuthenticator
+     * @since 0.6
+     */
+    private static ThreadLocal<Server> currentServer = new ThreadLocal<Server>();
+
+    // ===========================================================================================================================
+    // Class Methods
+    // ===========================================================================================================================
+
+    /**
+     * @return the server set on the current thread or <code>null</code>
+     * @since 0.6
+     */
+    public static Server getCurrentServer() {
+        return ServerManager.currentServer.get();
+    }
+
+    // ===========================================================================================================================
     // Fields
     // ===========================================================================================================================
 
@@ -127,6 +154,13 @@
     private final IRestClient delegate;
 
     /**
+     * The logger.
+     * 
+     * @since 0.6
+     */
+    private final Logger logger = Logger.getLogger(ServerManager.class);
+
+    /**
      * The path where the server registry is persisted or <code>null</code> if not persisted.
      * 
      * @since 0.6
@@ -155,20 +189,20 @@
     /**
      * @param stateLocationPath the directory where the {@link Server} registry} is persisted (may be <code>null</code> if
      *        persistence is not desired)
-     * @param restExecutor the executor that will communicate with the DNA REST server (never <code>null</code>)
+     * @param restClient the client that will communicate with the DNA REST server (never <code>null</code>)
      * @since 0.6
      */
     public ServerManager( String stateLocationPath,
-                          IRestClient restExecutor ) {
-        Utils.nullArgumentCheck("restExecutor", restExecutor); //$NON-NLS-1$
+                          IRestClient restClient ) {
+        CheckArg.isNotNull(restClient, "restClient"); //$NON-NLS-1$
 
         this.servers = new ArrayList<Server>();
         this.stateLocationPath = stateLocationPath;
-        this.delegate = restExecutor;
+        this.delegate = restClient;
         this.listeners = new CopyOnWriteArrayList<IServerRegistryListener>();
 
-        // TODO set authenticator here
-        // Authenticator.setDefault(new ServerAuthenticator());
+        // set our authenticator that uses the server registry
+        Authenticator.setDefault(new ServerAuthenticator(this));
     }
 
     /**
@@ -194,7 +228,7 @@
      * @since 0.6
      */
     public boolean addRegistryListener( IServerRegistryListener listener ) {
-        Utils.nullArgumentCheck("listener", listener); //$NON-NLS-1$
+        CheckArg.isNotNull(listener, "listener"); //$NON-NLS-1$
         return this.listeners.addIfAbsent(listener);
     }
 
@@ -206,7 +240,7 @@
      * @since 0.6
      */
     public Status addServer( Server server ) {
-        Utils.nullArgumentCheck("server", server); //$NON-NLS-1$
+        CheckArg.isNotNull(server, "server"); //$NON-NLS-1$
         return internalAddServer(server, true);
     }
 
@@ -241,21 +275,24 @@
      * {@inheritDoc}
      * 
      * @see org.jboss.dna.web.jcr.rest.client.IRestClient#getRepositories(org.jboss.dna.web.jcr.rest.client.domain.Server)
+     * @throws RuntimeException if the server is not registered
+     * @see #isRegistered(Server)
      * @since 0.6
      */
     public Collection<Repository> getRepositories( Server server ) throws Exception {
-        Utils.nullArgumentCheck("server", server); //$NON-NLS-1$
+        CheckArg.isNotNull(server, "server"); //$NON-NLS-1$
 
         try {
             this.serverLock.readLock().lock();
 
             if (isRegistered(server)) {
+                ServerManager.currentServer.set(server);
                 Collection<Repository> repositories = this.delegate.getRepositories(server);
                 return Collections.unmodifiableCollection(new ArrayList<Repository>(repositories));
             }
 
             // server must be registered in order to obtain it's repositories
-            throw new RuntimeException(Utils.getMessage(IMessages.ServerManagerUnregisteredServer, server.getShortDescription()));
+            throw new RuntimeException(RestClientI18n.serverManagerUnregisteredServer.text(server.getShortDescription()));
         } finally {
             this.serverLock.readLock().unlock();
         }
@@ -265,22 +302,25 @@
      * {@inheritDoc}
      * 
      * @see org.jboss.dna.web.jcr.rest.client.IRestClient#getWorkspaces(org.jboss.dna.web.jcr.rest.client.domain.Repository)
+     * @throws RuntimeException if the server is not registered
+     * @see #isRegistered(Server)
      * @since 0.6
      */
     public Collection<Workspace> getWorkspaces( Repository repository ) throws Exception {
-        Utils.nullArgumentCheck("repository", repository); //$NON-NLS-1$
+        CheckArg.isNotNull(repository, "repository"); //$NON-NLS-1$
 
         try {
             this.serverLock.readLock().lock();
 
             if (isRegistered(repository.getServer())) {
+                ServerManager.currentServer.set(repository.getServer());
                 Collection<Workspace> workspaces = this.delegate.getWorkspaces(repository);
                 return Collections.unmodifiableCollection(new ArrayList<Workspace>(workspaces));
             }
 
             // a repository's server must be registered in order to obtain it's workspaces
-            throw new RuntimeException(Utils.getMessage(IMessages.ServerManagerUnregisteredServer,
-                                                        repository.getServer().getShortDescription()));
+            String msg = RestClientI18n.serverManagerUnregisteredServer.text(repository.getServer().getShortDescription());
+            throw new RuntimeException(msg);
         } finally {
             this.serverLock.readLock().unlock();
         }
@@ -318,7 +358,7 @@
         }
 
         // server already exists
-        return new Status(Severity.ERROR, Utils.getMessage(IMessages.ServerExistsMsg, server.getShortDescription()), null);
+        return new Status(Severity.ERROR, RestClientI18n.serverExistsMsg.text(server.getShortDescription()), null);
     }
 
     /**
@@ -355,8 +395,8 @@
         }
 
         // server could not be removed
-        return new Status(Severity.ERROR, Utils.getMessage(IMessages.ServerManagerRegistryRemoveUnexpectedError,
-                                                           server.getShortDescription()), null);
+        return new Status(Severity.ERROR,
+                          RestClientI18n.serverManagerRegistryRemoveUnexpectedError.text(server.getShortDescription()), null);
     }
 
     /**
@@ -366,7 +406,7 @@
      * @since 0.6
      */
     public boolean isRegistered( Server server ) {
-        Utils.nullArgumentCheck("server", server); //$NON-NLS-1$
+        CheckArg.isNotNull(server, "server"); //$NON-NLS-1$
 
         try {
             this.serverLock.readLock().lock();
@@ -430,24 +470,58 @@
         }
 
         for (Exception error : errors) {
-            Logger.log(getClass(), new Status(Severity.ERROR, MESSAGES.getString(IMessages.ServerManagerRegistryListenerError),
-                                              error));
+            this.logger.error(error, RestClientI18n.serverManagerRegistryListenerError);
         }
 
-        return new Status(Severity.WARNING, MESSAGES.getString(IMessages.ServerManagerRegistryListenerErrorsOccurred), null);
+        return new Status(Severity.WARNING, RestClientI18n.serverManagerRegistryListenerErrorsOccurred.text(), null);
     }
 
     /**
+     * Attempts to connect to the server. The server does <strong>NOT</strong> need to be registered.
+     * 
+     * @param server the server being pinged (never <code>null</code>)
+     * @return a status indicating if the server can be connected to
+     * @see #isRegistered(Server)
+     * @since 0.6
+     */
+    public Status ping( Server server ) {
+        CheckArg.isNotNull(server, "server"); //$NON-NLS-1$
+
+        try {
+            ServerManager.currentServer.set(server);
+            this.delegate.getRepositories(server);
+            return new Status(Severity.OK, RestClientI18n.serverManagerConnectionEstablishedMsg.text(), null);
+        } catch (Exception e) {
+            return new Status(Severity.ERROR, RestClientI18n.serverManagerConnectionFailedMsg.text(), null);
+        }
+    }
+
+    /**
      * {@inheritDoc}
+     * <p>
+     * Only tries to unpublish if the workspace's {@link Server server} is registered.
      * 
      * @see org.jboss.dna.web.jcr.rest.client.IRestClient#publish(org.jboss.dna.web.jcr.rest.client.domain.Workspace,
      *      java.lang.String, java.io.File)
+     * @see #isRegistered(Server)
      * @since 0.6
      */
     public Status publish( Workspace workspace,
                            String path,
                            File file ) {
-        return this.delegate.publish(workspace, path, file);
+        CheckArg.isNotNull(workspace, "workspace"); //$NON-NLS-1$
+        CheckArg.isNotNull(path, "path"); //$NON-NLS-1$
+        CheckArg.isNotNull(file, "file"); //$NON-NLS-1$
+
+        Server server = workspace.getServer();
+
+        if (isRegistered(server)) {
+            ServerManager.currentServer.set(server);
+            return this.delegate.publish(workspace, path, file);
+        }
+
+        // server must be registered in order to publish
+        throw new RuntimeException(RestClientI18n.serverManagerUnregisteredServer.text(server.getShortDescription()));
     }
 
     /**
@@ -456,7 +530,7 @@
      * @since 0.6
      */
     public boolean removeRegistryListener( IServerRegistryListener listener ) {
-        Utils.nullArgumentCheck("listener", listener); //$NON-NLS-1$
+        CheckArg.isNotNull(listener, "listener"); //$NON-NLS-1$
         return this.listeners.remove(listener);
     }
 
@@ -466,7 +540,7 @@
      * @since 0.6
      */
     public Status removeServer( Server server ) {
-        Utils.nullArgumentCheck("server", server); //$NON-NLS-1$
+        CheckArg.isNotNull(server, "server"); //$NON-NLS-1$
         return internalRemoveServer(server, true);
     }
 
@@ -502,8 +576,7 @@
                         }
                     }
                 } catch (Exception e) {
-                    return new Status(Severity.ERROR,
-                                      Utils.getMessage(IMessages.ErrorRestoringServerRegistry, getStateFileName()), e);
+                    return new Status(Severity.ERROR, RestClientI18n.errorRestoringServerRegistry.text(getStateFileName()), e);
                 }
             }
         }
@@ -549,15 +622,14 @@
                 transformer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "2"); //$NON-NLS-1$ //$NON-NLS-2$
                 transformer.transform(source, resultXML);
             } catch (Exception e) {
-                return new Status(Severity.ERROR, Utils.getMessage(IMessages.ErrorSavingServerRegistry, getStateFileName()), e);
+                return new Status(Severity.ERROR, RestClientI18n.errorSavingServerRegistry.text(getStateFileName()), e);
             }
         } else if ((this.stateLocationPath != null) && stateFileExists()) {
             // delete current registry file since all servers have been deleted
             try {
                 new File(getStateFileName()).delete();
             } catch (Exception e) {
-                return new Status(Severity.ERROR,
-                                  Utils.getMessage(IMessages.ErrorDeletingServerRegistryFile, getStateFileName()), e);
+                return new Status(Severity.ERROR, RestClientI18n.errorDeletingServerRegistryFile.text(getStateFileName()), e);
             }
         }
 
@@ -574,15 +646,30 @@
 
     /**
      * {@inheritDoc}
+     * <p>
+     * Only tries to unpublish if the workspace's {@link Server server} is registered.
      * 
      * @see org.jboss.dna.web.jcr.rest.client.IRestClient#unpublish(org.jboss.dna.web.jcr.rest.client.domain.Workspace,
      *      java.lang.String, java.io.File)
+     * @see #isRegistered(Server)
      * @since 0.6
      */
     public Status unpublish( Workspace workspace,
                              String path,
                              File file ) {
-        return this.delegate.unpublish(workspace, path, file);
+        CheckArg.isNotNull(workspace, "workspace"); //$NON-NLS-1$
+        CheckArg.isNotNull(path, "path"); //$NON-NLS-1$
+        CheckArg.isNotNull(file, "file"); //$NON-NLS-1$
+
+        Server server = workspace.getServer();
+
+        if (isRegistered(server)) {
+            ServerManager.currentServer.set(server);
+            return this.delegate.unpublish(workspace, path, file);
+        }
+
+        // server must be registered in order to unpublish
+        throw new RuntimeException(RestClientI18n.serverManagerUnregisteredServer.text(server.getShortDescription()));
     }
 
     /**
@@ -595,8 +682,8 @@
      */
     public Status updateServer( Server previousServerVersion,
                                 Server newServerVersion ) {
-        Utils.nullArgumentCheck("previousServerVersion", previousServerVersion); //$NON-NLS-1$
-        Utils.nullArgumentCheck("newServerVersion", newServerVersion); //$NON-NLS-1$
+        CheckArg.isNotNull(previousServerVersion, "previousServerVersion"); //$NON-NLS-1$
+        CheckArg.isNotNull(newServerVersion, "newServerVersion"); //$NON-NLS-1$
 
         Status status = null;
 
@@ -615,16 +702,15 @@
                 }
 
                 // unexpected problem adding new version of server to registry
-                return new Status(Severity.ERROR, Utils.getMessage(IMessages.ServerManagerRegistryUpdateAddError,
-                                                                   status.getMessage()), status.getException());
+                return new Status(Severity.ERROR, RestClientI18n.serverManagerRegistryUpdateAddError.text(status.getMessage()),
+                                  status.getException());
             }
         } finally {
             this.serverLock.writeLock().unlock();
         }
 
         // unexpected problem removing server from registry
-        return new Status(Severity.ERROR,
-                          Utils.getMessage(IMessages.ServerManagerRegistryUpdateRemoveError, status.getMessage()),
+        return new Status(Severity.ERROR, RestClientI18n.serverManagerRegistryUpdateRemoveError.text(status.getMessage()),
                           status.getException());
     }
 

Modified: branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/ServerRegistryEvent.java
===================================================================
--- branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/ServerRegistryEvent.java	2009-08-10 21:31:32 UTC (rev 1160)
+++ branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/ServerRegistryEvent.java	2009-08-14 16:29:03 UTC (rev 1161)
@@ -23,6 +23,7 @@
  */
 package org.jboss.dna.web.jcr.rest.client;
 
+import org.jboss.dna.common.util.CheckArg;
 import org.jboss.dna.web.jcr.rest.client.domain.Server;
 
 /**
@@ -76,7 +77,7 @@
      * @since 0.6
      */
     public static ServerRegistryEvent createNewEvent( Server newServer ) {
-        Utils.nullArgumentCheck("newServer", newServer); //$NON-NLS-1$
+        CheckArg.isNotNull(newServer, "newServer"); //$NON-NLS-1$
         return new ServerRegistryEvent(Type.NEW, newServer);
     }
 
@@ -87,7 +88,7 @@
      * @since 0.6
      */
     public static ServerRegistryEvent createRemoveEvent( Server removedServer ) {
-        Utils.nullArgumentCheck("removedServer", removedServer); //$NON-NLS-1$
+        CheckArg.isNotNull(removedServer, "removedServer"); //$NON-NLS-1$
         return new ServerRegistryEvent(Type.REMOVE, removedServer);
     }
 
@@ -100,8 +101,8 @@
      */
     public static ServerRegistryEvent createUpdateEvent( Server previousServerVersion,
                                                          Server newServerVersion ) {
-        Utils.nullArgumentCheck("previousServerVersion", previousServerVersion); //$NON-NLS-1$
-        Utils.nullArgumentCheck("newServerVersion", newServerVersion); //$NON-NLS-1$
+        CheckArg.isNotNull(previousServerVersion, "previousServerVersion"); //$NON-NLS-1$
+        CheckArg.isNotNull(newServerVersion, "newServerVersion"); //$NON-NLS-1$
 
         ServerRegistryEvent event = new ServerRegistryEvent(Type.UPDATE, previousServerVersion);
         event.updatedServer = newServerVersion;

Modified: branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/Status.java
===================================================================
--- branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/Status.java	2009-08-10 21:31:32 UTC (rev 1160)
+++ branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/Status.java	2009-08-14 16:29:03 UTC (rev 1161)
@@ -96,21 +96,21 @@
      * 
      * @since 0.6
      */
-    protected final Throwable exception;
+    private final Throwable exception;
 
     /**
      * The localized message of this status (can be <code>null</code>).
      * 
      * @since 0.6
      */
-    protected final String message;
+    private final String message;
 
     /**
      * The severity level of this status (never <code>null</code>).
      * 
      * @since 0.6
      */
-    protected final Severity severity;
+    private final Severity severity;
 
     // ===========================================================================================================================
     // Constructors

Modified: branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/Utils.java
===================================================================
--- branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/Utils.java	2009-08-10 21:31:32 UTC (rev 1160)
+++ branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/Utils.java	2009-08-14 16:29:03 UTC (rev 1161)
@@ -23,9 +23,10 @@
  */
 package org.jboss.dna.web.jcr.rest.client;
 
-import static org.jboss.dna.web.jcr.rest.client.IMessages.MESSAGES;
-import static org.jboss.dna.web.jcr.rest.client.IMessages.NullArgumentMsg;
-import java.text.MessageFormat;
+import java.io.File;
+import java.io.InputStream;
+import java.util.Map;
+import org.jboss.dna.common.util.MimeTypeUtil;
 
 /**
  * The <code>Utils</code> class contains common utilities used by this project.
@@ -35,6 +36,13 @@
 public final class Utils {
 
     // ===========================================================================================================================
+    // Class Fields
+    // ===========================================================================================================================
+
+    // utility to detect file mime type by using file extension
+    private static MimeTypeUtil mimeTypeUtils;
+
+    // ===========================================================================================================================
     // Class Methods
     // ===========================================================================================================================
 
@@ -56,30 +64,22 @@
     }
 
     /**
-     * @param key the key of the pattern from the {@link IMessages#MESSAGES} resource bundle (never <code>null</code>)
-     * @param arguments the values being inserted into the pattern
-     * @return the localized text
+     * @param file the file whose mime type is being requested
+     * @return the mime type or the default mime type (<code>"application/octet-stream"</code>) if one can't be determined from
+     *         the file extension (never <code>null</code>)
      * @since 0.6
      */
-    public static String getMessage( String key,
-                                     Object... arguments ) {
-        Utils.nullArgumentCheck("key", key); //$NON-NLS-1$
-        String pattern = MESSAGES.getString(key);
-        return MessageFormat.format(pattern, arguments);
-    }
+    public static String getMimeType( File file ) {
+        // TODO write test for getMimeType(File)
+        if (mimeTypeUtils == null) {
 
-    /**
-     * @param name the argument name
-     * @param value the argument value
-     * @throws IllegalArgumentException if the value is <code>null</code>
-     * @since 0.6
-     */
-    public static void nullArgumentCheck( String name,
-                                          Object value ) throws IllegalArgumentException {
-        if (value == null) {
-            String pattern = MESSAGES.getString(NullArgumentMsg);
-            throw new IllegalArgumentException(MessageFormat.format(pattern, name));
+            InputStream stream = Thread.currentThread().getContextClassLoader().getResourceAsStream("org/jboss/dna/web/jcr/rest/client/mime.types"); //$NON-NLS-1$
+            Map<String, String> customMap = MimeTypeUtil.load(stream, null);
+            mimeTypeUtils = new MimeTypeUtil(customMap, true);
         }
+
+        String mimeType = mimeTypeUtils.mimeTypeOf(file);
+        return ((mimeType == null) ? "application/octet-stream" : mimeType); //$NON-NLS-1$
     }
 
     // ===========================================================================================================================

Modified: branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/domain/Repository.java
===================================================================
--- branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/domain/Repository.java	2009-08-10 21:31:32 UTC (rev 1160)
+++ branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/domain/Repository.java	2009-08-14 16:29:03 UTC (rev 1161)
@@ -23,10 +23,10 @@
  */
 package org.jboss.dna.web.jcr.rest.client.domain;
 
-import static org.jboss.dna.web.jcr.rest.client.IMessages.RepositoryShortDescription;
 import net.jcip.annotations.Immutable;
+import org.jboss.dna.common.util.CheckArg;
+import org.jboss.dna.web.jcr.rest.client.RestClientI18n;
 import org.jboss.dna.web.jcr.rest.client.Status;
-import org.jboss.dna.web.jcr.rest.client.Utils;
 import org.jboss.dna.web.jcr.rest.client.domain.validation.RepositoryValidator;
 
 /**
@@ -72,8 +72,8 @@
      */
     public Repository( String name,
                        Server server ) {
-        Utils.nullArgumentCheck("name", name); //$NON-NLS-1$
-        Utils.nullArgumentCheck("server", server); //$NON-NLS-1$
+        CheckArg.isNotNull(name, "name"); //$NON-NLS-1$
+        CheckArg.isNotNull(server, "server"); //$NON-NLS-1$
 
         // validate inputs
         Status status = RepositoryValidator.isValid(name, server);
@@ -132,7 +132,7 @@
      * @since 0.6
      */
     public String getShortDescription() {
-        return Utils.getMessage(RepositoryShortDescription, this.name, this.server.getName());
+        return RestClientI18n.repositoryShortDescription.text(this.name, this.server.getName());
     }
 
     /**

Modified: branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/domain/Server.java
===================================================================
--- branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/domain/Server.java	2009-08-10 21:31:32 UTC (rev 1160)
+++ branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/domain/Server.java	2009-08-14 16:29:03 UTC (rev 1161)
@@ -23,8 +23,9 @@
  */
 package org.jboss.dna.web.jcr.rest.client.domain;
 
-import static org.jboss.dna.web.jcr.rest.client.IMessages.ServerShortDescription;
 import net.jcip.annotations.Immutable;
+import org.jboss.dna.common.util.CheckArg;
+import org.jboss.dna.web.jcr.rest.client.RestClientI18n;
 import org.jboss.dna.web.jcr.rest.client.Status;
 import org.jboss.dna.web.jcr.rest.client.Utils;
 import org.jboss.dna.web.jcr.rest.client.domain.validation.RepositoryValidator;
@@ -89,7 +90,7 @@
                    String user,
                    String password,
                    boolean persistPassword ) {
-        Utils.nullArgumentCheck("url", url); //$NON-NLS-1$
+        CheckArg.isNotNull(url, "url"); //$NON-NLS-1$
 
         // valid inputs
         Status status = ServerValidator.isValid(url, user, password, persistPassword);
@@ -152,7 +153,7 @@
      * @since 0.6
      */
     public String getShortDescription() {
-        return Utils.getMessage(ServerShortDescription, this.url, this.user);
+        return RestClientI18n.serverShortDescription.text(this.url, this.user);
     }
 
     /**
@@ -200,7 +201,7 @@
      * @return <code>true</code> if the servers have the same key
      */
     public boolean hasSameKey( Server otherServer ) {
-        Utils.nullArgumentCheck("otherServer", otherServer); //$NON-NLS-1$
+        CheckArg.isNotNull(otherServer, "otherServer"); //$NON-NLS-1$
         return (Utils.equivalent(this.url, otherServer.url) && Utils.equivalent(this.user, otherServer.user));
     }
 

Modified: branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/domain/Workspace.java
===================================================================
--- branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/domain/Workspace.java	2009-08-10 21:31:32 UTC (rev 1160)
+++ branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/domain/Workspace.java	2009-08-14 16:29:03 UTC (rev 1161)
@@ -23,10 +23,10 @@
  */
 package org.jboss.dna.web.jcr.rest.client.domain;
 
-import static org.jboss.dna.web.jcr.rest.client.IMessages.WorkspaceShortDescription;
 import net.jcip.annotations.Immutable;
+import org.jboss.dna.common.util.CheckArg;
+import org.jboss.dna.web.jcr.rest.client.RestClientI18n;
 import org.jboss.dna.web.jcr.rest.client.Status;
-import org.jboss.dna.web.jcr.rest.client.Utils;
 import org.jboss.dna.web.jcr.rest.client.domain.validation.WorkspaceValidator;
 
 /**
@@ -70,8 +70,8 @@
      */
     public Workspace( String name,
                       Repository repository ) {
-        Utils.nullArgumentCheck("name", name); //$NON-NLS-1$
-        Utils.nullArgumentCheck("repository", repository); //$NON-NLS-1$
+        CheckArg.isNotNull(name, "name"); //$NON-NLS-1$
+        CheckArg.isNotNull(repository, "repository"); //$NON-NLS-1$
 
         // validate inputs
         Status status = WorkspaceValidator.isValid(name, repository);
@@ -138,7 +138,7 @@
      * @since 0.6
      */
     public String getShortDescription() {
-        return Utils.getMessage(WorkspaceShortDescription, this.name, this.repository.getName());
+        return RestClientI18n.workspaceShortDescription.text(this.name, this.repository.getName());
     }
 
     /**

Modified: branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/domain/validation/RepositoryValidator.java
===================================================================
--- branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/domain/validation/RepositoryValidator.java	2009-08-10 21:31:32 UTC (rev 1160)
+++ branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/domain/validation/RepositoryValidator.java	2009-08-14 16:29:03 UTC (rev 1161)
@@ -23,9 +23,7 @@
  */
 package org.jboss.dna.web.jcr.rest.client.domain.validation;
 
-import static org.jboss.dna.web.jcr.rest.client.IMessages.MESSAGES;
-import static org.jboss.dna.web.jcr.rest.client.IMessages.RepositoryEmptyNameMsg;
-import static org.jboss.dna.web.jcr.rest.client.IMessages.RepositoryNullServerMsg;
+import org.jboss.dna.web.jcr.rest.client.RestClientI18n;
 import org.jboss.dna.web.jcr.rest.client.Status;
 import org.jboss.dna.web.jcr.rest.client.Status.Severity;
 import org.jboss.dna.web.jcr.rest.client.domain.Repository;
@@ -49,7 +47,7 @@
      */
     public static Status isNameValid( String name ) {
         if ((name == null) || (name.length() == 0)) {
-            return new Status(Severity.ERROR, MESSAGES.getString(RepositoryEmptyNameMsg), null);
+            return new Status(Severity.ERROR, RestClientI18n.repositoryEmptyNameMsg.text(), null);
         }
 
         return Status.OK_STATUS;
@@ -62,7 +60,7 @@
      */
     public static Status isServerValid( Server server ) {
         if (server == null) {
-            return new Status(Severity.ERROR, MESSAGES.getString(RepositoryNullServerMsg), null);
+            return new Status(Severity.ERROR, RestClientI18n.repositoryNullServerMsg.text(), null);
         }
 
         return Status.OK_STATUS;

Modified: branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/domain/validation/ServerValidator.java
===================================================================
--- branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/domain/validation/ServerValidator.java	2009-08-10 21:31:32 UTC (rev 1160)
+++ branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/domain/validation/ServerValidator.java	2009-08-14 16:29:03 UTC (rev 1161)
@@ -23,15 +23,10 @@
  */
 package org.jboss.dna.web.jcr.rest.client.domain.validation;
 
-import static org.jboss.dna.web.jcr.rest.client.IMessages.MESSAGES;
-import static org.jboss.dna.web.jcr.rest.client.IMessages.ServerEmptyUrlMsg;
-import static org.jboss.dna.web.jcr.rest.client.IMessages.ServerEmptyUserMsg;
-import static org.jboss.dna.web.jcr.rest.client.IMessages.ServerExistsMsg;
-import static org.jboss.dna.web.jcr.rest.client.IMessages.ServerInvalidUrlMsg;
 import java.net.URL;
+import org.jboss.dna.web.jcr.rest.client.RestClientI18n;
 import org.jboss.dna.web.jcr.rest.client.ServerManager;
 import org.jboss.dna.web.jcr.rest.client.Status;
-import org.jboss.dna.web.jcr.rest.client.Utils;
 import org.jboss.dna.web.jcr.rest.client.Status.Severity;
 import org.jboss.dna.web.jcr.rest.client.domain.Server;
 
@@ -62,13 +57,13 @@
      */
     public static Status isUrlValid( String url ) {
         if ((url == null) || (url.length() == 0)) {
-            return new Status(Severity.ERROR, MESSAGES.getString(ServerEmptyUrlMsg), null);
+            return new Status(Severity.ERROR, RestClientI18n.serverEmptyUrlMsg.text(), null);
         }
 
         try {
             new URL(url);
         } catch (Exception e) {
-            return new Status(Severity.ERROR, Utils.getMessage(ServerInvalidUrlMsg, url), null);
+            return new Status(Severity.ERROR, RestClientI18n.serverInvalidUrlMsg.text(url), null);
         }
 
         return Status.OK_STATUS;
@@ -81,7 +76,7 @@
      */
     public static Status isUserValid( String user ) {
         if ((user == null) || (user.length() == 0)) {
-            return new Status(Severity.ERROR, MESSAGES.getString(ServerEmptyUserMsg), null);
+            return new Status(Severity.ERROR, RestClientI18n.serverEmptyUserMsg.text(), null);
         }
 
         return Status.OK_STATUS;
@@ -139,7 +134,7 @@
             Server newServer = new Server(url, user, password, persistPassword);
 
             if (serverManager.isRegistered(newServer)) {
-                status = new Status(Severity.ERROR, Utils.getMessage(ServerExistsMsg, newServer.getShortDescription()), null);
+                status = new Status(Severity.ERROR, RestClientI18n.serverExistsMsg.text(newServer.getShortDescription()), null);
             }
         }
 

Modified: branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/domain/validation/WorkspaceValidator.java
===================================================================
--- branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/domain/validation/WorkspaceValidator.java	2009-08-10 21:31:32 UTC (rev 1160)
+++ branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/domain/validation/WorkspaceValidator.java	2009-08-14 16:29:03 UTC (rev 1161)
@@ -23,9 +23,7 @@
  */
 package org.jboss.dna.web.jcr.rest.client.domain.validation;
 
-import static org.jboss.dna.web.jcr.rest.client.IMessages.MESSAGES;
-import static org.jboss.dna.web.jcr.rest.client.IMessages.WorkspaceEmptyNameMsg;
-import static org.jboss.dna.web.jcr.rest.client.IMessages.WorkspaceNullRepositoryMsg;
+import org.jboss.dna.web.jcr.rest.client.RestClientI18n;
 import org.jboss.dna.web.jcr.rest.client.Status;
 import org.jboss.dna.web.jcr.rest.client.Status.Severity;
 import org.jboss.dna.web.jcr.rest.client.domain.Repository;
@@ -49,7 +47,7 @@
      */
     public static Status isNameValid( String name ) {
         if ((name == null) || (name.length() == 0)) {
-            return new Status(Severity.ERROR, MESSAGES.getString(WorkspaceEmptyNameMsg), null);
+            return new Status(Severity.ERROR, RestClientI18n.workspaceEmptyNameMsg.text(), null);
         }
 
         return Status.OK_STATUS;
@@ -62,7 +60,7 @@
      */
     public static Status isRepositoryValid( Repository repository ) {
         if (repository == null) {
-            return new Status(Severity.ERROR, MESSAGES.getString(WorkspaceNullRepositoryMsg), null);
+            return new Status(Severity.ERROR, RestClientI18n.workspaceNullRepositoryMsg.text(), null);
         }
 
         return Status.OK_STATUS;

Modified: branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/json/FileNode.java
===================================================================
--- branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/json/FileNode.java	2009-08-10 21:31:32 UTC (rev 1160)
+++ branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/json/FileNode.java	2009-08-14 16:29:03 UTC (rev 1161)
@@ -36,6 +36,8 @@
 import java.util.TimeZone;
 import net.jcip.annotations.Immutable;
 import org.codehaus.jettison.json.JSONObject;
+import org.jboss.dna.common.util.CheckArg;
+import org.jboss.dna.common.util.Logger;
 import org.jboss.dna.web.jcr.rest.client.IJcrConstants;
 import org.jboss.dna.web.jcr.rest.client.Utils;
 import org.jboss.dna.web.jcr.rest.client.domain.Workspace;
@@ -90,8 +92,8 @@
                      File file ) throws Exception {
         super(file.getName());
 
-        Utils.nullArgumentCheck("workspace", workspace); //$NON-NLS-1$
-        Utils.nullArgumentCheck("path", path); //$NON-NLS-1$
+        CheckArg.isNotNull(workspace, "workspace"); //$NON-NLS-1$
+        CheckArg.isNotNull(path, "path"); //$NON-NLS-1$
 
         this.file = file;
         this.path = path;
@@ -167,8 +169,8 @@
         FolderNode folderNode = new FolderNode(this.workspace, getPath());
         StringBuilder url = new StringBuilder(folderNode.getUrl().toString());
 
-        // add file to path
-        url.append('/').append(this.file.getName());
+        // add file to path and encode the name
+        url.append('/').append(JsonUtils.encode(this.file.getName()));
         return new URL(url.toString());
     }
 

Modified: branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/json/FolderNode.java
===================================================================
--- branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/json/FolderNode.java	2009-08-10 21:31:32 UTC (rev 1160)
+++ branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/json/FolderNode.java	2009-08-14 16:29:03 UTC (rev 1161)
@@ -26,8 +26,9 @@
 import java.net.URL;
 import net.jcip.annotations.Immutable;
 import org.codehaus.jettison.json.JSONObject;
+import org.jboss.dna.common.util.CheckArg;
+import org.jboss.dna.common.util.Logger;
 import org.jboss.dna.web.jcr.rest.client.IJcrConstants;
-import org.jboss.dna.web.jcr.rest.client.Utils;
 import org.jboss.dna.web.jcr.rest.client.domain.Workspace;
 
 /**
@@ -64,8 +65,8 @@
                        String fullPath ) throws Exception {
         super(fullPath);
 
-        Utils.nullArgumentCheck("workspace", workspace); //$NON-NLS-1$
-        Utils.nullArgumentCheck("fullPath", fullPath); //$NON-NLS-1$
+        CheckArg.isNotNull(workspace, "workspace"); //$NON-NLS-1$
+        CheckArg.isNotNull(fullPath, "fullPath"); //$NON-NLS-1$
 
         this.workspace = workspace;
 
@@ -100,19 +101,20 @@
         WorkspaceNode workspaceNode = new WorkspaceNode(this.workspace);
         StringBuilder url = new StringBuilder(workspaceNode.getUrl().toString());
 
-        // add folder path
+        // make sure path starts with a '/'
         String path = getPath();
 
-        if (path.startsWith("/")) { //$NON-NLS-1$
-            url.append(path);
-        } else {
-            url.append('/').append(path);
+        if (!path.startsWith("/")) { //$NON-NLS-1$
+            path = '/' + path;
         }
-
-        // strip off ending '/'
+        
+        // make sure path does NOT end with a '/'
         if (path.endsWith("/")) { //$NON-NLS-1$
-            url.setLength(url.length() - 1);
+            path = path.substring(0, path.length() - 1);
         }
+        
+        // path needs to be encoded
+        url.append(JsonUtils.encode(path));
 
         return new URL(url.toString());
     }

Modified: branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/json/JsonNode.java
===================================================================
--- branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/json/JsonNode.java	2009-08-10 21:31:32 UTC (rev 1160)
+++ branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/json/JsonNode.java	2009-08-14 16:29:03 UTC (rev 1161)
@@ -25,7 +25,7 @@
 
 import java.net.URL;
 import org.codehaus.jettison.json.JSONObject;
-import org.jboss.dna.web.jcr.rest.client.Utils;
+import org.jboss.dna.common.util.CheckArg;
 
 /**
  * The <code>JsonNode</code> class defines the API for interacing with JSON objects. Every <code>JsonNode</code> knows how to
@@ -55,7 +55,7 @@
      * @since 0.6
      */
     protected JsonNode( String id ) {
-        Utils.nullArgumentCheck("id", id); //$NON-NLS-1$
+        CheckArg.isNotNull(id, "id"); //$NON-NLS-1$
         this.id = id;
     }
 

Modified: branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/json/JsonRestClient.java
===================================================================
--- branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/json/JsonRestClient.java	2009-08-10 21:31:32 UTC (rev 1160)
+++ branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/json/JsonRestClient.java	2009-08-14 16:29:03 UTC (rev 1161)
@@ -23,25 +23,17 @@
  */
 package org.jboss.dna.web.jcr.rest.client.json;
 
-import static org.jboss.dna.web.jcr.rest.client.IMessages.ConnectionErrorMsg;
-import static org.jboss.dna.web.jcr.rest.client.IMessages.CreateFileFailedMsg;
-import static org.jboss.dna.web.jcr.rest.client.IMessages.CreateFolderFailedMsg;
-import static org.jboss.dna.web.jcr.rest.client.IMessages.GetRepositoriesFailedMsg;
-import static org.jboss.dna.web.jcr.rest.client.IMessages.GetWorkspacesFailedMsg;
-import static org.jboss.dna.web.jcr.rest.client.IMessages.PublishFailedMsg;
-import static org.jboss.dna.web.jcr.rest.client.IMessages.UnpublishFailedMsg;
-import static org.jboss.dna.web.jcr.rest.client.IMessages.UnpublishNeverPublishedMsg;
 import java.io.File;
-import java.net.Authenticator;
 import java.net.HttpURLConnection;
-import java.net.PasswordAuthentication;
 import java.net.URL;
 import java.util.Collection;
 import javax.ws.rs.core.MediaType;
+import org.jboss.dna.common.util.Base64;
+import org.jboss.dna.common.util.CheckArg;
+import org.jboss.dna.common.util.Logger;
 import org.jboss.dna.web.jcr.rest.client.IRestClient;
-import org.jboss.dna.web.jcr.rest.client.Logger;
+import org.jboss.dna.web.jcr.rest.client.RestClientI18n;
 import org.jboss.dna.web.jcr.rest.client.Status;
-import org.jboss.dna.web.jcr.rest.client.Utils;
 import org.jboss.dna.web.jcr.rest.client.Status.Severity;
 import org.jboss.dna.web.jcr.rest.client.domain.Repository;
 import org.jboss.dna.web.jcr.rest.client.domain.Server;
@@ -57,6 +49,17 @@
 public final class JsonRestClient implements IRestClient {
 
     // ===========================================================================================================================
+    // Fields
+    // ===========================================================================================================================
+
+    /**
+     * The logger.
+     * 
+     * @since 0.6
+     */
+    private final Logger logger = Logger.getLogger(JsonRestClient.class);
+
+    // ===========================================================================================================================
     // Methods
     // ===========================================================================================================================
 
@@ -72,35 +75,27 @@
     private void createFileNode( Workspace workspace,
                                  String path,
                                  File file ) throws Exception {
-        Logger.trace(JsonRestClient.class,
-                     null,
-                     "createFileNode: workspace=" + workspace.getName() + ", path=" + path + ", file=" + file.getAbsolutePath()); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+        this.logger.trace("createFileNode: workspace={0}, path={1}, file={2}", workspace.getName(), path, file.getAbsolutePath()); //$NON-NLS-1$
         FileNode fileNode = new FileNode(workspace, path, file);
         HttpURLConnection connection = openConnection(workspace.getServer(), fileNode.getUrl(), RequestMethod.POST);
 
         try {
-            Logger.trace(JsonRestClient.class, null, "createFileNode: create node=" + fileNode); //$NON-NLS-1$
+            this.logger.trace("createFileNode: create node={0}", fileNode); //$NON-NLS-1$
             connection.getOutputStream().write(fileNode.getContent());
 
             // make sure node was created
             if (connection.getResponseCode() != HttpURLConnection.HTTP_CREATED) {
-                // log
-                Status status = new Status(Severity.ERROR, Utils.getMessage(ConnectionErrorMsg,
-                                                                            connection.getResponseCode(),
-                                                                            "createFileNode"), null); //$NON-NLS-1$
-                Logger.log(JsonRestClient.class, status);
-
-                // throw exception
-                String msg = Utils.getMessage(CreateFileFailedMsg,
-                                              file.getName(),
-                                              path,
-                                              workspace.getName(),
-                                              connection.getResponseCode());
+                // node was not created
+                this.logger.error(RestClientI18n.connectionErrorMsg, connection.getResponseCode(), "createFileNode"); //$NON-NLS-1$
+                String msg = RestClientI18n.createFileFailedMsg.text(file.getName(),
+                                                                     path,
+                                                                     workspace.getName(),
+                                                                     connection.getResponseCode());
                 throw new RuntimeException(msg);
             }
         } finally {
             if (connection != null) {
-                Logger.trace(JsonRestClient.class, null, "createFileNode: leaving"); //$NON-NLS-1$
+                this.logger.trace("createFileNode: leaving"); //$NON-NLS-1$
                 connection.disconnect();
             }
         }
@@ -116,29 +111,24 @@
      */
     private void createFolderNode( Workspace workspace,
                                    String path ) throws Exception {
-        Logger.trace(JsonRestClient.class, null, "createFolderNode: workspace=" + workspace.getName() + ", path=" + path); //$NON-NLS-1$//$NON-NLS-2$
+        this.logger.trace("createFolderNode: workspace={0}, path={1}", workspace.getName(), path); //$NON-NLS-1$
         FolderNode folderNode = new FolderNode(workspace, path);
         HttpURLConnection connection = openConnection(workspace.getServer(), folderNode.getUrl(), RequestMethod.POST);
 
         try {
-            Logger.trace(JsonRestClient.class, null, "createFolderNode: create node=" + folderNode); //$NON-NLS-1$
+            this.logger.trace("createFolderNode: create node={0}", folderNode); //$NON-NLS-1$
             connection.getOutputStream().write(folderNode.getContent());
 
             // make sure node was created
             if (connection.getResponseCode() != HttpURLConnection.HTTP_CREATED) {
-                // log
-                Status status = new Status(Severity.ERROR, Utils.getMessage(ConnectionErrorMsg,
-                                                                            connection.getResponseCode(),
-                                                                            "createFolderNode"), null); //$NON-NLS-1$
-                Logger.log(JsonRestClient.class, status);
-
-                // throw exception
-                String msg = Utils.getMessage(CreateFolderFailedMsg, path, workspace.getName(), connection.getResponseCode());
+                // node was not created
+                this.logger.error(RestClientI18n.connectionErrorMsg, connection.getResponseCode(), "createFolderNode"); //$NON-NLS-1$
+                String msg = RestClientI18n.createFolderFailedMsg.text(path, workspace.getName(), connection.getResponseCode());
                 throw new RuntimeException(msg);
             }
         } finally {
             if (connection != null) {
-                Logger.trace(JsonRestClient.class, null, "createFolderNode: leaving"); //$NON-NLS-1$
+                this.logger.trace("createFolderNode: leaving"); //$NON-NLS-1$
                 connection.disconnect();
             }
         }
@@ -154,7 +144,7 @@
      */
     private void ensureFolderExists( Workspace workspace,
                                      String folderPath ) throws Exception {
-        Logger.trace(JsonRestClient.class, null, "ensureFolderExists: workspace=" + workspace.getName() + ", path=" + folderPath); //$NON-NLS-1$//$NON-NLS-2$
+        this.logger.trace("ensureFolderExists: workspace={0}, path={1}", workspace.getName(), folderPath); //$NON-NLS-1$
         FolderNode folderNode = new FolderNode(workspace, folderPath);
 
         if (!pathExists(workspace.getServer(), folderNode.getUrl())) {
@@ -193,8 +183,8 @@
      * @since 0.6
      */
     public Collection<Repository> getRepositories( Server server ) throws Exception {
-        Utils.nullArgumentCheck("server", server); //$NON-NLS-1$
-        Logger.trace(JsonRestClient.class, null, "getRepositories: server=" + server); //$NON-NLS-1$
+        CheckArg.isNotNull(server, "server"); //$NON-NLS-1$
+        this.logger.trace("getRepositories: server={0}", server); //$NON-NLS-1$
 
         ServerNode serverNode = new ServerNode(server);
         HttpURLConnection connection = openConnection(server, serverNode.getFindRepositoriesUrl(), RequestMethod.GET);
@@ -204,18 +194,13 @@
                 return serverNode.getRepositories(JsonUtils.readInputStream(connection));
             }
 
-            // log
-            Status status = new Status(Severity.ERROR, Utils.getMessage(ConnectionErrorMsg,
-                                                                        connection.getResponseCode(),
-                                                                        "getRepositories"), null); //$NON-NLS-1$
-            Logger.log(JsonRestClient.class, status);
-
             // not a good response code
-            String msg = Utils.getMessage(GetRepositoriesFailedMsg, server.getName(), connection.getResponseCode());
+            this.logger.error(RestClientI18n.connectionErrorMsg, connection.getResponseCode(), "getRepositories"); //$NON-NLS-1$
+            String msg = RestClientI18n.getRepositoriesFailedMsg.text(server.getName(), connection.getResponseCode());
             throw new RuntimeException(msg);
         } finally {
             if (connection != null) {
-                Logger.trace(JsonRestClient.class, null, "getRepositories: leaving"); //$NON-NLS-1$
+                this.logger.trace("getRepositories: leaving"); //$NON-NLS-1$
                 connection.disconnect();
             }
         }
@@ -228,8 +213,8 @@
      * @since 0.6
      */
     public Collection<Workspace> getWorkspaces( Repository repository ) throws Exception {
-        Utils.nullArgumentCheck("repository", repository); //$NON-NLS-1$
-        Logger.trace(JsonRestClient.class, null, "getWorkspaces: repository=" + repository); //$NON-NLS-1$
+        CheckArg.isNotNull(repository, "repository"); //$NON-NLS-1$
+        this.logger.trace("getWorkspaces: repository={0}", repository); //$NON-NLS-1$
 
         RepositoryNode repositoryNode = new RepositoryNode(repository);
         HttpURLConnection connection = openConnection(repository.getServer(), repositoryNode.getUrl(), RequestMethod.GET);
@@ -239,21 +224,15 @@
                 return repositoryNode.getWorkspaces(JsonUtils.readInputStream(connection));
             }
 
-            // log
-            Status status = new Status(Severity.ERROR, Utils.getMessage(ConnectionErrorMsg,
-                                                                        connection.getResponseCode(),
-                                                                        "getWorkspaces"), null); //$NON-NLS-1$
-            Logger.log(JsonRestClient.class, status);
-
             // not a good response code
-            String msg = Utils.getMessage(GetWorkspacesFailedMsg,
-                                          repository.getName(),
-                                          repository.getServer().getName(),
-                                          connection.getResponseCode());
+            this.logger.error(RestClientI18n.connectionErrorMsg, connection.getResponseCode(), "getWorkspaces"); //$NON-NLS-1$
+            String msg = RestClientI18n.getWorkspacesFailedMsg.text(repository.getName(),
+                                                                    repository.getServer().getName(),
+                                                                    connection.getResponseCode());
             throw new RuntimeException(msg);
         } finally {
             if (connection != null) {
-                Logger.trace(JsonRestClient.class, null, "getWorkspaces: leaving"); //$NON-NLS-1$
+                this.logger.trace("getWorkspaces: leaving"); //$NON-NLS-1$
                 connection.disconnect();
             }
         }
@@ -270,12 +249,14 @@
     private HttpURLConnection openConnection( Server server,
                                               URL url,
                                               RequestMethod method ) throws Exception {
-        Logger.trace(JsonRestClient.class, null, "openConnection: url=" + url + ", method=" + method); //$NON-NLS-1$ //$NON-NLS-2$
-        setAuthentication(server.getUser(), server.getPassword());
+        this.logger.trace("openConnection: url={0}, method={1}", url, method); //$NON-NLS-1$
         HttpURLConnection connection = (HttpURLConnection)url.openConnection();
         connection.setDoOutput(true);
+        String encoding = Base64.encodeBytes((server.getUser() + ':' + server.getPassword()).getBytes());
+        connection.setRequestProperty("Authorization", "Basic " + encoding); //$NON-NLS-1$ //$NON-NLS-2$
         connection.setRequestMethod(method.toString());
         connection.setRequestProperty("Content-Type", MediaType.APPLICATION_JSON); //$NON-NLS-1$
+        connection.setUseCaches(false);
         return connection;
     }
 
@@ -288,14 +269,14 @@
      */
     protected boolean pathExists( Server server,
                                   URL url ) throws Exception {
-        Logger.trace(JsonRestClient.class, null, "pathExists: url=" + url); //$NON-NLS-1$
+        this.logger.trace("pathExists: url={0}", url); //$NON-NLS-1$
         HttpURLConnection connection = openConnection(server, url, RequestMethod.GET);
 
         try {
             return (connection.getResponseCode() == HttpURLConnection.HTTP_OK);
         } finally {
             if (connection != null) {
-                Logger.trace(JsonRestClient.class, null, "pathExists: leaving"); //$NON-NLS-1$
+                this.logger.trace("pathExists: leaving"); //$NON-NLS-1$
                 connection.disconnect();
             }
         }
@@ -309,10 +290,11 @@
      * @throws Exception if there is a problem checking the existence of the file
      * @since 0.6
      */
-    protected boolean pathExists( Workspace workspace,
-                                  String path,
-                                  File file ) throws Exception {
+    public boolean pathExists( Workspace workspace,
+                               String path,
+                               File file ) throws Exception {
         FileNode fileNode = new FileNode(workspace, path, file);
+        this.logger.trace("pathExists: url={0}", fileNode.getUrl()); //$NON-NLS-1$
         return pathExists(workspace.getServer(), fileNode.getUrl());
     }
 
@@ -326,12 +308,10 @@
     public Status publish( Workspace workspace,
                            String path,
                            File file ) {
-        Utils.nullArgumentCheck("workspace", workspace); //$NON-NLS-1$
-        Utils.nullArgumentCheck("path", path); //$NON-NLS-1$
-        Utils.nullArgumentCheck("file", file); //$NON-NLS-1$
-        Logger.trace(JsonRestClient.class,
-                     null,
-                     "publish: workspace=" + workspace.getName() + ", path=" + path + ", file=" + file.getAbsolutePath()); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+        CheckArg.isNotNull(workspace, "workspace"); //$NON-NLS-1$
+        CheckArg.isNotNull(path, "path"); //$NON-NLS-1$
+        CheckArg.isNotNull(file, "file"); //$NON-NLS-1$
+        this.logger.trace("publish: workspace={0}, path={1}, file={2}", workspace.getName(), path, file.getAbsolutePath()); //$NON-NLS-1$
 
         try {
             // first delete if file exists at that path
@@ -345,28 +325,13 @@
             // publish file
             createFileNode(workspace, path, file);
         } catch (Exception e) {
-            return new Status(Severity.ERROR, Utils.getMessage(PublishFailedMsg,
-                                                               file.getAbsolutePath(),
-                                                               path,
-                                                               workspace.getName()), e);
+            String msg = RestClientI18n.publishFailedMsg.text(file.getAbsolutePath(), path, workspace.getName());
+            return new Status(Severity.ERROR, msg, e);
         }
 
         return Status.OK_STATUS;
     }
 
-    private void setAuthentication( final String user,
-                                    final String password ) {
-        final String pswd = ((password == null) ? "" : password); //$NON-NLS-1$
-
-        // TODO setAuthentication() make authenticator work with multi-threads
-        Authenticator.setDefault(new Authenticator() {
-            @Override
-            protected PasswordAuthentication getPasswordAuthentication() {
-                return new PasswordAuthentication(user, pswd.toCharArray());
-            }
-        });
-    }
-
     /**
      * {@inheritDoc}
      * 
@@ -377,12 +342,10 @@
     public Status unpublish( Workspace workspace,
                              String path,
                              File file ) {
-        Utils.nullArgumentCheck("workspace", workspace); //$NON-NLS-1$
-        Utils.nullArgumentCheck("path", path); //$NON-NLS-1$
-        Utils.nullArgumentCheck("file", file); //$NON-NLS-1$
-        Logger.trace(JsonRestClient.class,
-                     null,
-                     "unpublish: workspace=" + workspace.getName() + ", path=" + path + ", file=" + file.getAbsolutePath()); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+        CheckArg.isNotNull(workspace, "workspace"); //$NON-NLS-1$
+        CheckArg.isNotNull(path, "path"); //$NON-NLS-1$
+        CheckArg.isNotNull(file, "file"); //$NON-NLS-1$
+        this.logger.trace("unpublish: workspace={0}, path={1}, file={2}", workspace.getName(), path, file.getAbsolutePath()); //$NON-NLS-1$
 
         HttpURLConnection connection = null;
 
@@ -394,30 +357,23 @@
             if (responseCode != HttpURLConnection.HTTP_NO_CONTENT) {
                 // check to see if the file was never published
                 if (!pathExists(workspace.getServer(), fileNode.getUrl())) {
-                    return new Status(Severity.INFO, Utils.getMessage(UnpublishNeverPublishedMsg,
-                                                                      file.getAbsolutePath(),
-                                                                      workspace.getName(),
-                                                                      path), null);
+                    String msg = RestClientI18n.unpublishNeverPublishedMsg.text(file.getAbsolutePath(), workspace.getName(), path);
+                    return new Status(Severity.INFO, msg, null);
                 }
 
                 // unexpected result
-                Status status = new Status(Severity.ERROR, Utils.getMessage(ConnectionErrorMsg, responseCode, "unpublish"), null); //$NON-NLS-1$
-                Logger.log(JsonRestClient.class, status);
-
-                // throw exception
-                String msg = Utils.getMessage(UnpublishFailedMsg, file.getName(), workspace.getName(), path, responseCode);
+                this.logger.error(RestClientI18n.connectionErrorMsg, responseCode, "unpublish"); //$NON-NLS-1$
+                String msg = RestClientI18n.unpublishFailedMsg.text(file.getName(), workspace.getName(), path, responseCode);
                 throw new RuntimeException(msg);
             }
 
             return Status.OK_STATUS;
         } catch (Exception e) {
-            return new Status(Severity.ERROR, Utils.getMessage(PublishFailedMsg,
-                                                               workspace.getName(),
-                                                               path,
-                                                               file.getAbsolutePath()), e);
+            String msg = RestClientI18n.publishFailedMsg.text(workspace.getName(), path, file.getAbsolutePath());
+            return new Status(Severity.ERROR, msg, e);
         } finally {
             if (connection != null) {
-                Logger.trace(JsonRestClient.class, null, "unpublish: leaving"); //$NON-NLS-1$
+                this.logger.trace("unpublish: leaving"); //$NON-NLS-1$
                 connection.disconnect();
             }
         }

Modified: branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/json/JsonUtils.java
===================================================================
--- branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/json/JsonUtils.java	2009-08-10 21:31:32 UTC (rev 1160)
+++ branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/json/JsonUtils.java	2009-08-14 16:29:03 UTC (rev 1161)
@@ -29,7 +29,7 @@
 import java.net.HttpURLConnection;
 import java.net.URLDecoder;
 import java.net.URLEncoder;
-import org.jboss.dna.web.jcr.rest.client.Utils;
+import org.jboss.dna.common.util.CheckArg;
 
 /**
  * The <code>JsonUtils</code> class provides utilities needed to work with the DNA REST server JSON API.
@@ -54,25 +54,35 @@
     // ===========================================================================================================================
 
     /**
-     * @param text the text whose escape sequences will be replaced with the actual characters (never <code>null</code>)
+     * @param text the text being URL decoded (never <code>null</code>)
      * @return the decoded text
-     * @throws UnsupportedEncodingException
+     * @throws UnsupportedEncodingException if the charset is not supported
      * @since 0.6
      */
-    public static String decodeEscaping( String text ) throws UnsupportedEncodingException {
-        Utils.nullArgumentCheck("text", text); //$NON-NLS-1$
+    public static String decode( String text ) throws UnsupportedEncodingException {
+        CheckArg.isNotNull(text, "text"); //$NON-NLS-1$
         return URLDecoder.decode(text, DEFAULT_CHARSET);
     }
 
     /**
-     * @param text the text whose escape sequences will be replaced with the actual characters (never <code>null</code>)
+     * Forward slashes ('/') are not encoded.
+     * 
+     * @param text the text being URL encoded (never <code>null</code>)
      * @return the decoded text
-     * @throws UnsupportedEncodingException
+     * @throws UnsupportedEncodingException if the charset is not supported
      * @since 0.6
      */
-    public static String encodeEscaping( String text ) throws UnsupportedEncodingException {
-        Utils.nullArgumentCheck("text", text); //$NON-NLS-1$
-        return URLEncoder.encode(text, DEFAULT_CHARSET);
+    public static String encode( String text ) throws UnsupportedEncodingException {
+        CheckArg.isNotNull(text, "text"); //$NON-NLS-1$
+
+        // don't encode '/' as it needs to stay that way in the URL
+        StringBuilder encoded = new StringBuilder();
+
+        for (char c : text.toCharArray()) {
+            encoded.append((c == '/') ? c : URLEncoder.encode(Character.toString(c), DEFAULT_CHARSET));
+        }
+
+        return encoded.toString();
     }
 
     /**
@@ -84,7 +94,7 @@
      * @since 0.6
      */
     public static String readInputStream( HttpURLConnection connection ) throws IOException {
-        Utils.nullArgumentCheck("connection", connection); //$NON-NLS-1$
+        CheckArg.isNotNull(connection, "connection"); //$NON-NLS-1$
 
         InputStream stream = connection.getInputStream();
         int bytesRead;

Modified: branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/json/RepositoryNode.java
===================================================================
--- branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/json/RepositoryNode.java	2009-08-10 21:31:32 UTC (rev 1160)
+++ branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/json/RepositoryNode.java	2009-08-14 16:29:03 UTC (rev 1161)
@@ -28,7 +28,7 @@
 import java.util.Collection;
 import java.util.Iterator;
 import org.codehaus.jettison.json.JSONObject;
-import org.jboss.dna.web.jcr.rest.client.Utils;
+import org.jboss.dna.common.util.CheckArg;
 import org.jboss.dna.web.jcr.rest.client.domain.Repository;
 import org.jboss.dna.web.jcr.rest.client.domain.Workspace;
 
@@ -82,7 +82,7 @@
         StringBuilder url = new StringBuilder(serverNode.getUrl().toString());
 
         // add repository path
-        url.append('/').append(JsonUtils.encodeEscaping(repository.getName()));
+        url.append('/').append(JsonUtils.encode(repository.getName()));
         return new URL(url.toString());
     }
 
@@ -94,13 +94,13 @@
      */
     @SuppressWarnings( "unchecked" )
     public Collection<Workspace> getWorkspaces( String jsonResponse ) throws Exception {
-        Utils.nullArgumentCheck("jsonResponse", jsonResponse); //$NON-NLS-1$
+        CheckArg.isNotNull(jsonResponse, "jsonResponse"); //$NON-NLS-1$
         Collection<Workspace> workspaces = new ArrayList<Workspace>();
         JSONObject jsonObj = new JSONObject(jsonResponse);
 
         // keys are the repository names
         for (Iterator<String> itr = jsonObj.keys(); itr.hasNext();) {
-            String name = JsonUtils.decodeEscaping(itr.next());
+            String name = JsonUtils.decode(itr.next());
             Workspace workspace = new Workspace(name, this.repository);
             workspaces.add(workspace);
         }

Modified: branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/json/ServerNode.java
===================================================================
--- branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/json/ServerNode.java	2009-08-10 21:31:32 UTC (rev 1160)
+++ branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/json/ServerNode.java	2009-08-14 16:29:03 UTC (rev 1161)
@@ -28,8 +28,8 @@
 import java.util.Collection;
 import java.util.Iterator;
 import org.codehaus.jettison.json.JSONObject;
-import org.jboss.dna.web.jcr.rest.client.Logger;
-import org.jboss.dna.web.jcr.rest.client.Utils;
+import org.jboss.dna.common.util.CheckArg;
+import org.jboss.dna.common.util.Logger;
 import org.jboss.dna.web.jcr.rest.client.domain.Repository;
 import org.jboss.dna.web.jcr.rest.client.domain.Server;
 
@@ -46,6 +46,13 @@
     // ===========================================================================================================================
 
     /**
+     * The logger.
+     * 
+     * @since 0.6
+     */
+    private final Logger logger = Logger.getLogger(ServerNode.class);
+
+    /**
      * The server containing DNA repositories.
      * 
      * @since 0.6
@@ -110,17 +117,17 @@
      */
     @SuppressWarnings( "unchecked" )
     public Collection<Repository> getRepositories( String jsonResponse ) throws Exception {
-        Utils.nullArgumentCheck("jsonResponse", jsonResponse); //$NON-NLS-1$
+        CheckArg.isNotNull(jsonResponse, "jsonResponse"); //$NON-NLS-1$
         Collection<Repository> repositories = new ArrayList<Repository>();
-        Logger.trace(ServerNode.class, null, "getRepositories:jsonResponse=" + jsonResponse); //$NON-NLS-1$
+        this.logger.trace("getRepositories:jsonResponse={0}", jsonResponse); //$NON-NLS-1$
         JSONObject jsonObj = new JSONObject(jsonResponse);
 
         // keys are the repository names
         for (Iterator<String> itr = jsonObj.keys(); itr.hasNext();) {
-            String name = JsonUtils.decodeEscaping(itr.next());
+            String name = JsonUtils.decode(itr.next());
             Repository repository = new Repository(name, this.server);
             repositories.add(repository);
-            Logger.trace(ServerNode.class, null, "getRepositories: adding repository=" + repository); //$NON-NLS-1$
+            this.logger.trace("getRepositories: adding repository={0}", repository); //$NON-NLS-1$
         }
 
         return repositories;

Modified: branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/json/WorkspaceNode.java
===================================================================
--- branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/json/WorkspaceNode.java	2009-08-10 21:31:32 UTC (rev 1160)
+++ branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/json/WorkspaceNode.java	2009-08-14 16:29:03 UTC (rev 1161)
@@ -69,7 +69,7 @@
         StringBuilder url = new StringBuilder(repositoryNode.getUrl().toString());
 
         // add workspace path
-        url.append('/').append(JsonUtils.encodeEscaping(workspace.getName())).append(IJsonConstants.WORKSPACE_CONTEXT);
+        url.append('/').append(JsonUtils.encode(workspace.getName())).append(IJsonConstants.WORKSPACE_CONTEXT);
         return new URL(url.toString());
     }
 

Deleted: branches/eclipse/dna-web-jcr-rest-client/src/main/resources/org/jboss/dna/web/jcr/rest/client/Messages.properties
===================================================================
--- branches/eclipse/dna-web-jcr-rest-client/src/main/resources/org/jboss/dna/web/jcr/rest/client/Messages.properties	2009-08-10 21:31:32 UTC (rev 1160)
+++ branches/eclipse/dna-web-jcr-rest-client/src/main/resources/org/jboss/dna/web/jcr/rest/client/Messages.properties	2009-08-14 16:29:03 UTC (rev 1161)
@@ -1,61 +0,0 @@
-#
-# JBoss DNA (http://www.jboss.org/dna)
-# See the COPYRIGHT.txt file distributed with this work for information
-# regarding copyright ownership.  Some portions may be licensed
-# to Red Hat, Inc. under one or more contributor license agreements.
-# See the AUTHORS.txt file in the distribution for a full listing of 
-# individual contributors. 
-#
-# JBoss DNA is free software. Unless otherwise indicated, all code in JBoss DNA
-# is licensed to you under the terms of the GNU Lesser General Public License as
-# published by the Free Software Foundation; either version 2.1 of
-# the License, or (at your option) any later version.
-#
-# JBoss DNA is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-# Lesser General Public License for more details.
-#
-# You should have received a copy of the GNU Lesser General Public
-# License along with this software; if not, write to the Free
-# Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-# 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-#
-ErrorDeletingServerRegistryFile = There was a problem deleting server registry file "{0}"
-ErrorRestoringServerRegistry = Error trying to restore the server registry from file "{0}"
-ErrorSavingServerRegistry = Error trying to save the server registry to "{0}"
-
-NullArgumentMsg = The argument "{0}" may not be null.
-
-RepositoryEmptyNameMsg = A repository name cannot be empty
-RepositoryNullServerMsg = A repository server cannot be null
-RepositoryShortDescription = DNA Repository - Name: {0}, Server: {1}
-
-ServerEmptyUserMsg = The user cannot be empty
-ServerEmptyUrlMsg = A server URL cannot be empty
-ServerExistsMsg = {0} already exists so it cannot be added
-ServerInvalidUrlMsg = The  value "{0}" is not a valid server URL
-ServerShortDescription = DNA Server - URL: {0} User: {1}
-
-ServerManagerRegistryAddUnexpectedError = Unexpected error adding server to registry
-ServerManagerRegistryListenerError = This error was reported by an IServerRegistryListener
-ServerManagerRegistryListenerErrorsOccurred = Errors occurred processing a server registry event. Check error log for more details.
-ServerManagerRegistryRemoveUnexpectedError = {0} cannot be removed as it has not been registered
-ServerManagerRegistryUpdateAddError = There was an unexpected error updating the server in the registry. The old version of the server was successfully removed. However, the new version was not updated. Detail: {0}
-ServerManagerRegistryUpdateRemoveError = There was an unexpected error updating the server in the registry. The server has not been updated in the server registry. Detail: {0}
-ServerManagerUnregisteredServer = Server "{0}" is not registered so it's repositories and workspaces cannot be obtained.
-
-WorkspaceEmptyNameMsg = A workspace name cannot be empty
-WorkspaceNullRepositoryMsg = A workspace repository cannot be null
-WorkspaceShortDescription = DNA Workspace - Name: {0}, Repository: {1}
-
-# JsonRestClient messages
-
-ConnectionErrorMsg = response code={0}: {1}
-CreateFileFailedMsg = Creating the "{0}" file node in folder "{1}" in workspace "{2}" failed with HTTP response code of "{3}"
-CreateFolderFailedMsg = Creating the "{0}" folder node in workspace "{1}" failed with HTTP response code of "{2}"
-GetRepositoriesFailedMsg = Obtaining the repositories from server "{0}" failed with HTTP response code of "{1}"
-GetWorkspacesFailedMsg = Obtaining the workspaces from repository "{0}" at server "{1}" failed with HTTP response code of "{2}"
-PublishFailedMsg = Publishing file "{0}" to path "{1}" in workspace "{2}" failed.
-UnpublishFailedMsg = The file "{0}" could not be unpublished in workspace "{1}" at path "{2}". The HTTP response code was "{3}".
-UnpublishNeverPublishedMsg = The file "{0}" could not be unpublished in workspace "{1}" at path "{2}" because it could not be found.

Copied: branches/eclipse/dna-web-jcr-rest-client/src/main/resources/org/jboss/dna/web/jcr/rest/client/RestClientI18n.properties (from rev 1148, branches/eclipse/dna-web-jcr-rest-client/src/main/resources/org/jboss/dna/web/jcr/rest/client/Messages.properties)
===================================================================
--- branches/eclipse/dna-web-jcr-rest-client/src/main/resources/org/jboss/dna/web/jcr/rest/client/RestClientI18n.properties	                        (rev 0)
+++ branches/eclipse/dna-web-jcr-rest-client/src/main/resources/org/jboss/dna/web/jcr/rest/client/RestClientI18n.properties	2009-08-14 16:29:03 UTC (rev 1161)
@@ -0,0 +1,63 @@
+#
+# JBoss DNA (http://www.jboss.org/dna)
+# See the COPYRIGHT.txt file distributed with this work for information
+# regarding copyright ownership.  Some portions may be licensed
+# to Red Hat, Inc. under one or more contributor license agreements.
+# See the AUTHORS.txt file in the distribution for a full listing of 
+# individual contributors. 
+#
+# JBoss DNA is free software. Unless otherwise indicated, all code in JBoss DNA
+# is licensed to you under the terms of the GNU Lesser General Public License as
+# published by the Free Software Foundation; either version 2.1 of
+# the License, or (at your option) any later version.
+#
+# JBoss DNA is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this software; if not, write to the Free
+# Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+# 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+#
+errorDeletingServerRegistryFile = There was a problem deleting server registry file "{0}"
+errorRestoringServerRegistry = Error trying to restore the server registry from file "{0}"
+errorSavingServerRegistry = Error trying to save the server registry to "{0}"
+
+nullArgumentMsg = The argument "{0}" may not be null.
+
+repositoryEmptyNameMsg = A repository name cannot be empty
+repositoryNullServerMsg = A repository server cannot be null
+repositoryShortDescription = DNA Repository - Name: {0}, Server: {1}
+
+serverEmptyUserMsg = The user cannot be empty
+serverEmptyUrlMsg = A server URL cannot be empty
+serverExistsMsg = {0} already exists so it cannot be added
+serverInvalidUrlMsg = The  value "{0}" is not a valid server URL
+serverShortDescription = DNA Server - URL: {0} User: {1}
+
+serverManagerConnectionEstablishedMsg = Connection established.
+serverManagerConnectionFailedMsg = Connection failed.
+serverManagerRegistryAddUnexpectedError = Unexpected error adding server to registry
+serverManagerRegistryListenerError = This error was reported by an IServerRegistryListener
+serverManagerRegistryListenerErrorsOccurred = Errors occurred processing a server registry event. Check error log for more details.
+serverManagerRegistryRemoveUnexpectedError = {0} cannot be removed as it has not been registered
+serverManagerRegistryUpdateAddError = There was an unexpected error updating the server in the registry. The old version of the server was successfully removed. However, the new version was not updated. Detail: {0}
+serverManagerRegistryUpdateRemoveError = There was an unexpected error updating the server in the registry. The server has not been updated in the server registry. Detail: {0}
+serverManagerUnregisteredServer = Server "{0}" is not registered so it's repositories and workspaces cannot be obtained and it cannot be involved in a publishing operation.
+
+workspaceEmptyNameMsg = A workspace name cannot be empty
+workspaceNullRepositoryMsg = A workspace repository cannot be null
+workspaceShortDescription = DNA Workspace - Name: {0}, Repository: {1}
+
+# JsonRestClient messages
+
+connectionErrorMsg = response code={0}: {1}
+createFileFailedMsg = Creating the "{0}" file node in folder "{1}" in workspace "{2}" failed with HTTP response code of "{3}"
+createFolderFailedMsg = Creating the "{0}" folder node in workspace "{1}" failed with HTTP response code of "{2}"
+getRepositoriesFailedMsg = Obtaining the repositories from server "{0}" failed with HTTP response code of "{1}"
+getWorkspacesFailedMsg = Obtaining the workspaces from repository "{0}" at server "{1}" failed with HTTP response code of "{2}"
+publishFailedMsg = Publishing file "{0}" to path "{1}" in workspace "{2}" failed.
+unpublishFailedMsg = The file "{0}" could not be unpublished in workspace "{1}" at path "{2}". The HTTP response code was "{3}".
+unpublishNeverPublishedMsg = The file "{0}" could not be unpublished in workspace "{1}" at path "{2}" because it could not be found.


Property changes on: branches/eclipse/dna-web-jcr-rest-client/src/main/resources/org/jboss/dna/web/jcr/rest/client/RestClientI18n.properties
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Added: branches/eclipse/dna-web-jcr-rest-client/src/main/resources/org/jboss/dna/web/jcr/rest/client/mime.types
===================================================================
--- branches/eclipse/dna-web-jcr-rest-client/src/main/resources/org/jboss/dna/web/jcr/rest/client/mime.types	                        (rev 0)
+++ branches/eclipse/dna-web-jcr-rest-client/src/main/resources/org/jboss/dna/web/jcr/rest/client/mime.types	2009-08-14 16:29:03 UTC (rev 1161)
@@ -0,0 +1,9 @@
+# This file defines the Internet media types and extensions.
+# For more information about Internet media types,
+# please read RFC 2045, 2046, 2047, 2048, and 2077.  The Internet media type
+# registry is at <http://www.iana.org/assignments/media-types/>.
+
+# MIME type                 Extensions
+
+text/plain                  classpath debug epf ini lock mappings mf prefs properties readme svn-base
+application/xml             launch project template xsd

Copied: branches/eclipse/dna-web-jcr-rest-client/src/test/java/org/jboss/dna/web/jcr/rest/client/MockRestClient.java (from rev 1159, branches/eclipse/dna-web-jcr-rest-client/src/test/java/org/jboss/dna/web/jcr/rest/client/MockRestExecutor.java)
===================================================================
--- branches/eclipse/dna-web-jcr-rest-client/src/test/java/org/jboss/dna/web/jcr/rest/client/MockRestClient.java	                        (rev 0)
+++ branches/eclipse/dna-web-jcr-rest-client/src/test/java/org/jboss/dna/web/jcr/rest/client/MockRestClient.java	2009-08-14 16:29:03 UTC (rev 1161)
@@ -0,0 +1,89 @@
+/*
+ * JBoss DNA (http://www.jboss.org/dna)
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership.  Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ * See the AUTHORS.txt file in the distribution for a full listing of 
+ * individual contributors.
+ *
+ * JBoss DNA is free software. Unless otherwise indicated, all code in JBoss DNA
+ * is licensed to you under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ * 
+ * JBoss DNA is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.dna.web.jcr.rest.client;
+
+import java.io.File;
+import java.util.Collection;
+import org.jboss.dna.web.jcr.rest.client.domain.Repository;
+import org.jboss.dna.web.jcr.rest.client.domain.Server;
+import org.jboss.dna.web.jcr.rest.client.domain.Workspace;
+
+/**
+ * The <code>MockRestExecutor</code> class is a test <code>IRestClient</code> implementation that does nothing.
+ * 
+ * @since 0.6
+ */
+public final class MockRestClient implements IRestClient {
+
+    // ===========================================================================================================================
+    // Methods
+    // ===========================================================================================================================
+
+    /**
+     * {@inheritDoc}
+     * 
+     * @see org.jboss.dna.web.jcr.rest.client.IRestClient#getRepositories(org.jboss.dna.web.jcr.rest.client.domain.Server)
+     * @since 0.6
+     */
+    public Collection<Repository> getRepositories( Server server ) throws Exception {
+        return null;
+    }
+
+    /**
+     * {@inheritDoc}
+     * 
+     * @see org.jboss.dna.web.jcr.rest.client.IRestClient#getWorkspaces(org.jboss.dna.web.jcr.rest.client.domain.Repository)
+     * @since 0.6
+     */
+    public Collection<Workspace> getWorkspaces( Repository repository ) throws Exception {
+        return null;
+    }
+
+    /**
+     * {@inheritDoc}
+     * 
+     * @see org.jboss.dna.web.jcr.rest.client.IRestClient#publish(org.jboss.dna.web.jcr.rest.client.domain.Workspace,
+     *      java.lang.String, java.io.File)
+     * @since 0.6
+     */
+    public Status publish( Workspace workspace,
+                           String path,
+                           File file ) {
+        return null;
+    }
+
+    /**
+     * {@inheritDoc}
+     * 
+     * @see org.jboss.dna.web.jcr.rest.client.IRestClient#unpublish(org.jboss.dna.web.jcr.rest.client.domain.Workspace,
+     *      java.lang.String, java.io.File)
+     * @since 0.6
+     */
+    public Status unpublish( Workspace workspace,
+                             String path,
+                             File file ) {
+        return null;
+    }
+
+}


Property changes on: branches/eclipse/dna-web-jcr-rest-client/src/test/java/org/jboss/dna/web/jcr/rest/client/MockRestClient.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Deleted: branches/eclipse/dna-web-jcr-rest-client/src/test/java/org/jboss/dna/web/jcr/rest/client/MockRestExecutor.java
===================================================================
--- branches/eclipse/dna-web-jcr-rest-client/src/test/java/org/jboss/dna/web/jcr/rest/client/MockRestExecutor.java	2009-08-10 21:31:32 UTC (rev 1160)
+++ branches/eclipse/dna-web-jcr-rest-client/src/test/java/org/jboss/dna/web/jcr/rest/client/MockRestExecutor.java	2009-08-14 16:29:03 UTC (rev 1161)
@@ -1,89 +0,0 @@
-/*
- * JBoss DNA (http://www.jboss.org/dna)
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership.  Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- * See the AUTHORS.txt file in the distribution for a full listing of 
- * individual contributors.
- *
- * JBoss DNA is free software. Unless otherwise indicated, all code in JBoss DNA
- * is licensed to you under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- * 
- * JBoss DNA is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.dna.web.jcr.rest.client;
-
-import java.io.File;
-import java.util.Collection;
-import org.jboss.dna.web.jcr.rest.client.domain.Repository;
-import org.jboss.dna.web.jcr.rest.client.domain.Server;
-import org.jboss.dna.web.jcr.rest.client.domain.Workspace;
-
-/**
- * The <code>MockRestExecutor</code> class is a test <code>IRestClient</code> implementation that does nothing.
- * 
- * @since 0.6
- */
-public final class MockRestExecutor implements IRestClient {
-
-    // ===========================================================================================================================
-    // Methods
-    // ===========================================================================================================================
-
-    /**
-     * {@inheritDoc}
-     * 
-     * @see org.jboss.dna.web.jcr.rest.client.IRestClient#getRepositories(org.jboss.dna.web.jcr.rest.client.domain.Server)
-     * @since 0.6
-     */
-    public Collection<Repository> getRepositories( Server server ) throws Exception {
-        return null;
-    }
-
-    /**
-     * {@inheritDoc}
-     * 
-     * @see org.jboss.dna.web.jcr.rest.client.IRestClient#getWorkspaces(org.jboss.dna.web.jcr.rest.client.domain.Repository)
-     * @since 0.6
-     */
-    public Collection<Workspace> getWorkspaces( Repository repository ) throws Exception {
-        return null;
-    }
-
-    /**
-     * {@inheritDoc}
-     * 
-     * @see org.jboss.dna.web.jcr.rest.client.IRestClient#publish(org.jboss.dna.web.jcr.rest.client.domain.Workspace,
-     *      java.lang.String, java.io.File)
-     * @since 0.6
-     */
-    public Status publish( Workspace workspace,
-                           String path,
-                           File file ) {
-        return null;
-    }
-
-    /**
-     * {@inheritDoc}
-     * 
-     * @see org.jboss.dna.web.jcr.rest.client.IRestClient#unpublish(org.jboss.dna.web.jcr.rest.client.domain.Workspace,
-     *      java.lang.String, java.io.File)
-     * @since 0.6
-     */
-    public Status unpublish( Workspace workspace,
-                             String path,
-                             File file ) {
-        return null;
-    }
-
-}

Added: branches/eclipse/dna-web-jcr-rest-client/src/test/java/org/jboss/dna/web/jcr/rest/client/RestClientI18nTest.java
===================================================================
--- branches/eclipse/dna-web-jcr-rest-client/src/test/java/org/jboss/dna/web/jcr/rest/client/RestClientI18nTest.java	                        (rev 0)
+++ branches/eclipse/dna-web-jcr-rest-client/src/test/java/org/jboss/dna/web/jcr/rest/client/RestClientI18nTest.java	2009-08-14 16:29:03 UTC (rev 1161)
@@ -0,0 +1,37 @@
+/*
+ * JBoss DNA (http://www.jboss.org/dna)
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership.  Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ * See the AUTHORS.txt file in the distribution for a full listing of 
+ * individual contributors.
+ *
+ * JBoss DNA is free software. Unless otherwise indicated, all code in JBoss DNA
+ * is licensed to you under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ * 
+ * JBoss DNA is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.dna.web.jcr.rest.client;
+
+import org.jboss.dna.common.AbstractI18nTest;
+
+/**
+ * @since 0.6
+ */
+public final class RestClientI18nTest extends AbstractI18nTest {
+    
+    public RestClientI18nTest() {
+        super(RestClientI18n.class);
+    }
+
+}


Property changes on: branches/eclipse/dna-web-jcr-rest-client/src/test/java/org/jboss/dna/web/jcr/rest/client/RestClientI18nTest.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Added: branches/eclipse/dna-web-jcr-rest-client/src/test/java/org/jboss/dna/web/jcr/rest/client/RestIntegrationTest.java
===================================================================
--- branches/eclipse/dna-web-jcr-rest-client/src/test/java/org/jboss/dna/web/jcr/rest/client/RestIntegrationTest.java	                        (rev 0)
+++ branches/eclipse/dna-web-jcr-rest-client/src/test/java/org/jboss/dna/web/jcr/rest/client/RestIntegrationTest.java	2009-08-14 16:29:03 UTC (rev 1161)
@@ -0,0 +1,114 @@
+/*
+ * JBoss DNA (http://www.jboss.org/dna)
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership.  Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ * See the AUTHORS.txt file in the distribution for a full listing of 
+ * individual contributors.
+ *
+ * JBoss DNA is free software. Unless otherwise indicated, all code in JBoss DNA
+ * is licensed to you under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ * 
+ * JBoss DNA is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.dna.web.jcr.rest.client;
+
+import static org.hamcrest.core.Is.is;
+import static org.hamcrest.core.IsNull.notNullValue;
+import static org.junit.Assert.assertThat;
+import java.io.File;
+import java.net.URL;
+import java.util.Collection;
+import org.jboss.dna.web.jcr.rest.client.domain.Repository;
+import org.jboss.dna.web.jcr.rest.client.domain.Server;
+import org.jboss.dna.web.jcr.rest.client.domain.Workspace;
+import org.jboss.dna.web.jcr.rest.client.json.JsonRestClient;
+import org.junit.Before;
+import org.junit.Test;
+
+/**
+ *
+ */
+public final class RestIntegrationTest {
+
+    // ===========================================================================================================================
+    // Constants
+    // ===========================================================================================================================
+
+    // user and password configured in pom
+    private static final String PSWD = "password"; //$NON-NLS-1$
+    private static final String USER = "dnauser"; //$NON-NLS-1$
+
+    private static final Server SERVER = new Server("http://localhost:8080", USER, PSWD, false); //$NON-NLS-1$
+    private static final String REPOSITORY_NAME = "dna:repository"; //$NON-NLS-1$
+    private static final Repository REPOSITORY = new Repository(REPOSITORY_NAME, SERVER);
+    private static final String WORKSPACE_NAME = "default"; //$NON-NLS-1$
+    private static final Workspace WORKSPACE = new Workspace(WORKSPACE_NAME, REPOSITORY);
+
+    private static final String WORKSPACE_PATH = "/myproject/myfolder/"; //$NON-NLS-1$
+    private static final String FILE_PATH = WORKSPACE_PATH + "document.txt"; //$NON-NLS-1$
+
+    // ===========================================================================================================================
+    // Fields
+    // ===========================================================================================================================
+
+    private JsonRestClient restClient;
+
+    private ServerManager serverManager;
+
+    // ===========================================================================================================================
+    // Methods
+    // ===========================================================================================================================
+
+    @Before
+    public void beforeEach() {
+        this.restClient = new JsonRestClient();
+        this.serverManager = new ServerManager(null, this.restClient);
+        this.serverManager.addServer(SERVER);
+    }
+
+    // ===========================================================================================================================
+    // Methods
+    // ===========================================================================================================================
+
+    @Test
+    public void shouldGetRepositories() throws Exception {
+        Collection<Repository> repositories = this.serverManager.getRepositories(SERVER);
+        assertThat(repositories.size(), is(1));
+    }
+
+    @Test
+    public void shouldGetWorkspaces() throws Exception {
+        Collection<Workspace> workspaces = this.serverManager.getWorkspaces(REPOSITORY);
+        assertThat(workspaces.size(), is(1));
+    }
+
+    @Test
+    public void shouldPublish() throws Exception {
+        URL textFile = getClass().getResource(FILE_PATH);
+        assertThat(textFile, is(notNullValue()));
+
+        // publish
+        File file = new File(textFile.toURI());
+        assertThat(this.serverManager.publish(WORKSPACE, WORKSPACE_PATH, file).isOk(), is(true));
+
+        // confirm it exists in repository
+        assertThat((this.restClient).pathExists(WORKSPACE, WORKSPACE_PATH, file), is(true));
+    }
+
+    @Test
+    public void shouldUnpublish() {
+        // TODO implement shouldUnpublish()
+    }
+
+}


Property changes on: branches/eclipse/dna-web-jcr-rest-client/src/test/java/org/jboss/dna/web/jcr/rest/client/RestIntegrationTest.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Modified: branches/eclipse/dna-web-jcr-rest-client/src/test/java/org/jboss/dna/web/jcr/rest/client/ServerManagerTest.java
===================================================================
--- branches/eclipse/dna-web-jcr-rest-client/src/test/java/org/jboss/dna/web/jcr/rest/client/ServerManagerTest.java	2009-08-10 21:31:32 UTC (rev 1160)
+++ branches/eclipse/dna-web-jcr-rest-client/src/test/java/org/jboss/dna/web/jcr/rest/client/ServerManagerTest.java	2009-08-14 16:29:03 UTC (rev 1161)
@@ -67,7 +67,7 @@
 
     @Before
     public void beforeEach() {
-        this.serverManager = new ServerManager(null, new MockRestExecutor());
+        this.serverManager = new ServerManager(null, new MockRestClient());
     }
 
     // ===========================================================================================================================

Modified: branches/eclipse/dna-web-jcr-rest-client/src/test/java/org/jboss/dna/web/jcr/rest/client/json/JsonRestClientTest.java
===================================================================
--- branches/eclipse/dna-web-jcr-rest-client/src/test/java/org/jboss/dna/web/jcr/rest/client/json/JsonRestClientTest.java	2009-08-10 21:31:32 UTC (rev 1160)
+++ branches/eclipse/dna-web-jcr-rest-client/src/test/java/org/jboss/dna/web/jcr/rest/client/json/JsonRestClientTest.java	2009-08-14 16:29:03 UTC (rev 1161)
@@ -33,6 +33,7 @@
 import java.net.URL;
 import java.util.Collection;
 import org.jboss.dna.web.jcr.rest.client.IRestClient;
+import org.jboss.dna.web.jcr.rest.client.Status;
 import org.jboss.dna.web.jcr.rest.client.domain.Repository;
 import org.jboss.dna.web.jcr.rest.client.domain.Server;
 import org.jboss.dna.web.jcr.rest.client.domain.Workspace;
@@ -124,6 +125,11 @@
 
         // TODO: get jcr:data and compare
     }
+    
+    @Test
+    public void shouldPublishFilesHavingNonLettersNonNumbersInName() {
+        // TODO implement shouldPublishFilesHavingNonLettersNonNumbersInName test
+    }
 
     @Test
     public void shouldPublishTextResource() throws Exception {
@@ -132,11 +138,17 @@
 
         // publish
         File file = new File(textFile.toURI());
-        assertThat(this.restClient.publish(WORKSPACE1, WORKSPACE_PATH, file).isOk(), is(true));
+        Status status = this.restClient.publish(WORKSPACE1, WORKSPACE_PATH, file);
+        assertThat(status.getMessage(), status.isOk(), is(true));
 
         // confirm it exists in repository
         assertThat(((JsonRestClient)this.restClient).pathExists(WORKSPACE1, WORKSPACE_PATH, file), is(true));
     }
+    
+    @Test
+    public void shouldPublishToDirectoriesHavingNonLettersNonNumbersInName() {
+        // TODO implement shouldPublishToDirectoriesHavingNonLettersNonNumbersInName test
+    }
 
     @Test
     public void shouldUnpublish() throws Exception {



More information about the dna-commits mailing list