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

dna-commits at lists.jboss.org dna-commits at lists.jboss.org
Wed Jul 29 19:01:57 EDT 2009


Author: elvisisking
Date: 2009-07-29 19:01:57 -0400 (Wed, 29 Jul 2009)
New Revision: 1140

Modified:
   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/Logger.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/Workspace.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/json/JsonRestClientTest.java
Log:
Added assembly build to pom in order to package dependenies into jar. Now doing URL encoding/decoding using JDK classes. Logger now does not throw exception if a logging adapter is not found. Setting URL authenticator before every call to open connection.

Modified: branches/eclipse/dna-web-jcr-rest-client/pom.xml
===================================================================
--- branches/eclipse/dna-web-jcr-rest-client/pom.xml	2009-07-29 22:37:55 UTC (rev 1139)
+++ branches/eclipse/dna-web-jcr-rest-client/pom.xml	2009-07-29 23:01:57 UTC (rev 1140)
@@ -18,16 +18,16 @@
 		those defined in the dependencyManagement section of the parent pom.
 	-->
 	<dependencies>
+		<!-- 
+        Testing (note the scope)
+    -->
 		<dependency>
 			<groupId>org.jboss.dna</groupId>
 			<artifactId>dna-web-jcr-rest-war</artifactId>
 			<type>war</type>
 			<version>${pom.version}</version>
+			<scope>integration-test</scope>
 		</dependency>
-
-		<!-- 
-        Testing (note the scope)
-    -->
 		<dependency>
 			<groupId>junit</groupId>
 			<artifactId>junit</artifactId>
@@ -54,10 +54,12 @@
 		<dependency>
 			<groupId>org.slf4j</groupId>
 			<artifactId>slf4j-log4j12</artifactId>
+			<scope>integration-test</scope>
 		</dependency>
 		<dependency>
 			<groupId>log4j</groupId>
 			<artifactId>log4j</artifactId>
+			<scope>integration-test</scope>
 		</dependency>
 		<!-- 
         Java Concurrency in Practice annotations
@@ -87,6 +89,28 @@
 		</plugins>
 	</reporting>
 	<build>
+		<pluginManagement>
+			<plugins>
+				<plugin>
+					<artifactId>maven-assembly-plugin</artifactId>
+					<configuration>
+						<descriptorRefs>
+							<descriptorRef>jar-with-dependencies
+							</descriptorRef>
+						</descriptorRefs>
+					</configuration>
+					<executions>
+						<execution>
+							<id>create-project-bundle</id>
+							<phase>package</phase>
+							<goals>
+								<goal>single</goal>
+							</goals>
+						</execution>
+					</executions>
+				</plugin>
+			</plugins>
+		</pluginManagement>
 		<plugins>
 			<plugin>
 				<groupId>org.codehaus.cargo</groupId>

Modified: 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-07-29 22:37:55 UTC (rev 1139)
+++ branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/Logger.java	2009-07-29 23:01:57 UTC (rev 1140)
@@ -80,7 +80,14 @@
      */
     public static void log( Class<?> clazz,
                             Status status ) {
-        org.slf4j.Logger delegate = LoggerFactory.getLogger(clazz);
+        org.slf4j.Logger delegate = null;
+        
+        try {
+            delegate = LoggerFactory.getLogger(clazz);
+        } catch (Throwable e) {
+            // adapter not found
+            return;
+        }
 
         if (status.isError() && delegate.isErrorEnabled()) {
             if (status.getException() == null) {
@@ -114,7 +121,14 @@
     public static void log( Class<?> clazz,
                             Status status,
                             Object... arguments ) {
-        org.slf4j.Logger delegate = LoggerFactory.getLogger(clazz);
+        org.slf4j.Logger delegate = null;
+        
+        try {
+            delegate = LoggerFactory.getLogger(clazz);
+        } catch (Throwable e) {
+            // adapter not found
+            return;
+        }
 
         if (status.isError() && delegate.isErrorEnabled()) {
             String msg = getMessage(clazz, status, arguments);
@@ -154,7 +168,14 @@
     public static void trace( Class<?> clazz,
                               Throwable e,
                               String msg ) {
-        org.slf4j.Logger delegate = LoggerFactory.getLogger(clazz);
+        org.slf4j.Logger delegate = null;
+        
+        try {
+            delegate = LoggerFactory.getLogger(clazz);
+        } catch (Throwable error) {
+            // adapter not found
+            return;
+        }
 
         if (delegate.isTraceEnabled()) {
             if (e == null) {
@@ -176,7 +197,14 @@
                               Throwable e,
                               String pattern,
                               Object... arguments ) {
-        org.slf4j.Logger delegate = LoggerFactory.getLogger(clazz);
+        org.slf4j.Logger delegate = null;
+        
+        try {
+            delegate = LoggerFactory.getLogger(clazz);
+        } catch (Throwable error) {
+            // adapter not found
+            return;
+        }
 
         if (delegate.isTraceEnabled()) {
             if (e == null) {

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-07-29 22:37:55 UTC (rev 1139)
+++ branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/domain/Repository.java	2009-07-29 23:01:57 UTC (rev 1140)
@@ -28,7 +28,6 @@
 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;
-import org.jboss.dna.web.jcr.rest.client.json.JsonUtils;
 
 /**
  * The Repository class is the business object for a DNA repository.
@@ -134,9 +133,7 @@
      * @since 0.6
      */
     public String getShortDescription() {
-        return Utils.getMessage(RepositoryShortDescription,
-                                JsonUtils.decodeEscaping(this.name),
-                                this.server.getShortDescription());
+        return Utils.getMessage(RepositoryShortDescription, this.name, this.server.getShortDescription());
     }
 
     /**

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-07-29 22:37:55 UTC (rev 1139)
+++ branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/domain/Workspace.java	2009-07-29 23:01:57 UTC (rev 1140)
@@ -28,7 +28,6 @@
 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;
-import org.jboss.dna.web.jcr.rest.client.json.JsonUtils;
 
 /**
  * The Workspace class is the business object for a DNA repository workspace.
@@ -140,9 +139,7 @@
      * @since 0.6
      */
     public String getShortDescription() {
-        return Utils.getMessage(WorkspaceShortDescription,
-                                JsonUtils.decodeEscaping(this.name),
-                                this.repository.getShortDescription());
+        return Utils.getMessage(WorkspaceShortDescription, this.name, this.repository.getShortDescription());
     }
 
     /**

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-07-29 22:37:55 UTC (rev 1139)
+++ branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/json/JsonRestClient.java	2009-07-29 23:01:57 UTC (rev 1140)
@@ -30,9 +30,11 @@
 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.io.IOException;
+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;
@@ -72,7 +74,7 @@
                      null,
                      "createFileNode: workspace=" + workspace.getName() + ", path=" + path + ", file=" + file.getAbsolutePath()); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
         FileNode fileNode = new FileNode(workspace, path, file);
-        HttpURLConnection connection = openConnection(fileNode.getUrl(), RequestMethod.POST);
+        HttpURLConnection connection = openConnection(workspace.getServer(), fileNode.getUrl(), RequestMethod.POST);
 
         try {
             Logger.trace(JsonRestClient.class, null, "createFileNode: create node=" + fileNode); //$NON-NLS-1$
@@ -96,7 +98,7 @@
             }
         } finally {
             if (connection != null) {
-                Logger.trace(JsonRestClient.class, null, "createFileNode: " + connection.getResponseMessage()); //$NON-NLS-1$
+                Logger.trace(JsonRestClient.class, null, "createFileNode: leaving"); //$NON-NLS-1$
                 connection.disconnect();
             }
         }
@@ -114,7 +116,7 @@
                                    String path ) throws Exception {
         Logger.trace(JsonRestClient.class, null, "createFolderNode: workspace=" + workspace.getName() + ", path=" + path); //$NON-NLS-1$//$NON-NLS-2$
         FolderNode folderNode = new FolderNode(workspace, path);
-        HttpURLConnection connection = openConnection(folderNode.getUrl(), RequestMethod.POST);
+        HttpURLConnection connection = openConnection(workspace.getServer(), folderNode.getUrl(), RequestMethod.POST);
 
         try {
             Logger.trace(JsonRestClient.class, null, "createFolderNode: create node=" + folderNode); //$NON-NLS-1$
@@ -134,7 +136,7 @@
             }
         } finally {
             if (connection != null) {
-                Logger.trace(JsonRestClient.class, null, "createFolderNode: " + connection.getResponseMessage()); //$NON-NLS-1$
+                Logger.trace(JsonRestClient.class, null, "createFolderNode: leaving"); //$NON-NLS-1$
                 connection.disconnect();
             }
         }
@@ -153,7 +155,7 @@
         Logger.trace(JsonRestClient.class, null, "ensureFolderExists: workspace=" + workspace.getName() + ", path=" + folderPath); //$NON-NLS-1$//$NON-NLS-2$
         FolderNode folderNode = new FolderNode(workspace, folderPath);
 
-        if (!pathExists(folderNode.getUrl())) {
+        if (!pathExists(workspace.getServer(), folderNode.getUrl())) {
             StringBuilder path = new StringBuilder();
 
             for (char c : folderPath.toCharArray()) {
@@ -161,7 +163,7 @@
                     if (path.length() > 1) {
                         folderNode = new FolderNode(workspace, path.toString());
 
-                        if (!pathExists(folderNode.getUrl())) {
+                        if (!pathExists(workspace.getServer(), folderNode.getUrl())) {
                             createFolderNode(workspace, folderNode.getPath());
                         }
                     }
@@ -173,7 +175,7 @@
                     if (path.length() == folderPath.length()) {
                         folderNode = new FolderNode(workspace, path.toString());
 
-                        if (!pathExists(folderNode.getUrl())) {
+                        if (!pathExists(workspace.getServer(), folderNode.getUrl())) {
                             createFolderNode(workspace, folderNode.getPath());
                         }
                     }
@@ -193,7 +195,7 @@
         Logger.trace(JsonRestClient.class, null, "getRepositories: server=" + server); //$NON-NLS-1$
 
         ServerNode serverNode = new ServerNode(server);
-        HttpURLConnection connection = openConnection(serverNode.getFindRepositoriesUrl(), RequestMethod.GET);
+        HttpURLConnection connection = openConnection(server, serverNode.getFindRepositoriesUrl(), RequestMethod.GET);
 
         try {
             if (connection.getResponseCode() == HttpURLConnection.HTTP_OK) {
@@ -211,7 +213,7 @@
             throw new RuntimeException(msg);
         } finally {
             if (connection != null) {
-                Logger.trace(JsonRestClient.class, null, "getRepositories: " + connection.getResponseMessage()); //$NON-NLS-1$
+                Logger.trace(JsonRestClient.class, null, "getRepositories: leaving"); //$NON-NLS-1$
                 connection.disconnect();
             }
         }
@@ -228,7 +230,7 @@
         Logger.trace(JsonRestClient.class, null, "getWorkspaces: repository=" + repository); //$NON-NLS-1$
 
         RepositoryNode repositoryNode = new RepositoryNode(repository);
-        HttpURLConnection connection = openConnection(repositoryNode.getUrl(), RequestMethod.GET);
+        HttpURLConnection connection = openConnection(repository.getServer(), repositoryNode.getUrl(), RequestMethod.GET);
 
         try {
             if (connection.getResponseCode() == HttpURLConnection.HTTP_OK) {
@@ -249,22 +251,25 @@
             throw new RuntimeException(msg);
         } finally {
             if (connection != null) {
-                Logger.trace(JsonRestClient.class, null, "getWorkspaces: " + connection.getResponseMessage()); //$NON-NLS-1$
+                Logger.trace(JsonRestClient.class, null, "getWorkspaces: leaving"); //$NON-NLS-1$
                 connection.disconnect();
             }
         }
     }
 
     /**
+     * @param server the server where the connection will be established
      * @param url the URL where the connection will be established
      * @param method the request method
      * @return the open connection which <strong>MUST</strong> be disconnected
      * @throws Exception if there is a problem establishing the connection
      * @since 0.6
      */
-    private HttpURLConnection openConnection( URL url,
+    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());
         HttpURLConnection connection = (HttpURLConnection)url.openConnection();
         connection.setDoOutput(true);
         connection.setRequestMethod(method.toString());
@@ -273,20 +278,22 @@
     }
 
     /**
+     * @param server the server where the URL will be used (never <code>null</code>)
      * @param url the path being checked (never <code>null</code>)
      * @return <code>true</code> if the path exists
      * @throws Exception if there is a problem checking the existence of the path
      * @since 0.6
      */
-    protected boolean pathExists( URL url ) throws Exception {
+    protected boolean pathExists( Server server,
+                                  URL url ) throws Exception {
         Logger.trace(JsonRestClient.class, null, "pathExists: url=" + url); //$NON-NLS-1$
-        HttpURLConnection connection = openConnection(url, RequestMethod.GET);
+        HttpURLConnection connection = openConnection(server, url, RequestMethod.GET);
 
         try {
             return (connection.getResponseCode() == HttpURLConnection.HTTP_OK);
         } finally {
             if (connection != null) {
-                Logger.trace(JsonRestClient.class, null, "pathExists: " + connection.getResponseMessage()); //$NON-NLS-1$
+                Logger.trace(JsonRestClient.class, null, "pathExists: leaving"); //$NON-NLS-1$
                 connection.disconnect();
             }
         }
@@ -304,7 +311,7 @@
                                   String path,
                                   File file ) throws Exception {
         FileNode fileNode = new FileNode(workspace, path, file);
-        return pathExists(fileNode.getUrl());
+        return pathExists(workspace.getServer(), fileNode.getUrl());
     }
 
     /**
@@ -345,6 +352,19 @@
         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}
      * 
@@ -366,13 +386,13 @@
 
         try {
             FileNode fileNode = new FileNode(workspace, path, file);
-            connection = openConnection(fileNode.getUrl(), RequestMethod.DELETE);
+            connection = openConnection(workspace.getServer(), fileNode.getUrl(), RequestMethod.DELETE);
             int responseCode = connection.getResponseCode();
 
             if (responseCode != HttpURLConnection.HTTP_NO_CONTENT) {
                 // check to see if the file was never published
-                if (!pathExists(fileNode.getUrl())) {
-                    return new Status(Severity.INFO, Utils.getMessage(PublishFailedMsg,
+                if (!pathExists(workspace.getServer(), fileNode.getUrl())) {
+                    return new Status(Severity.INFO, Utils.getMessage(UnpublishNeverPublishedMsg,
                                                                       file.getAbsolutePath(),
                                                                       workspace.getName(),
                                                                       path), null);
@@ -395,12 +415,7 @@
                                                                file.getAbsolutePath()), e);
         } finally {
             if (connection != null) {
-                try {
-                    Logger.trace(JsonRestClient.class, null, "unpublish: " + connection.getResponseMessage()); //$NON-NLS-1$
-                } catch (IOException e) {
-                    Logger.log(JsonRestClient.class, new Status(Severity.ERROR, null, e));
-                }
-
+                Logger.trace(JsonRestClient.class, null, "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-07-29 22:37:55 UTC (rev 1139)
+++ branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/json/JsonUtils.java	2009-07-29 23:01:57 UTC (rev 1140)
@@ -25,7 +25,10 @@
 
 import java.io.IOException;
 import java.io.InputStream;
+import java.io.UnsupportedEncodingException;
 import java.net.HttpURLConnection;
+import java.net.URLDecoder;
+import java.net.URLEncoder;
 import org.jboss.dna.web.jcr.rest.client.Utils;
 
 /**
@@ -37,18 +40,41 @@
     // ===========================================================================================================================
     // Class Methods
     // ===========================================================================================================================
+    
+    /**
+     * The default character set being used.
+     * 
+     * @since 0.6
+     */
+    private static final String DEFAULT_CHARSET = "UTF-8"; //$NON-NLS-1$ // TODO need to property drive charset
 
+    // ===========================================================================================================================
+    // Class Methods
+    // ===========================================================================================================================
+
     /**
      * @param text the text whose escape sequences will be replaced with the actual characters (never <code>null</code>)
      * @return the decoded text
+     * @throws UnsupportedEncodingException 
      * @since 0.6
      */
-    public static String decodeEscaping( String text ) {
+    public static String decodeEscaping( String text ) throws UnsupportedEncodingException {
         Utils.nullArgumentCheck("text", text); //$NON-NLS-1$
-        return text.replace("%3a", ":"); //$NON-NLS-1$ //$NON-NLS-2$
+        return URLDecoder.decode(text, DEFAULT_CHARSET);
     }
 
     /**
+     * @param text the text whose escape sequences will be replaced with the actual characters (never <code>null</code>)
+     * @return the decoded text
+     * @throws UnsupportedEncodingException 
+     * @since 0.6
+     */
+    public static String encodeEscaping( String text ) throws UnsupportedEncodingException {
+        Utils.nullArgumentCheck("text", text); //$NON-NLS-1$
+        return URLEncoder.encode(text, DEFAULT_CHARSET);
+    }
+
+    /**
      * Note: The connection is not disconnected during this method.
      * 
      * @param connection the connection whose input stream is going to be read from (never <code>null</code>)

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-07-29 22:37:55 UTC (rev 1139)
+++ branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/json/RepositoryNode.java	2009-07-29 23:01:57 UTC (rev 1140)
@@ -80,7 +80,7 @@
         StringBuilder url = new StringBuilder(serverNode.getUrl().toString());
 
         // add repository path
-        url.append('/').append(repository.getName());
+        url.append('/').append(JsonUtils.encodeEscaping(repository.getName()));
         return new URL(url.toString());
     }
 
@@ -98,7 +98,8 @@
 
         // keys are the repository names
         for (Iterator<String> itr = jsonObj.keys(); itr.hasNext();) {
-            Workspace workspace = new Workspace(itr.next(), this.repository);
+            String name = JsonUtils.decodeEscaping(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-07-29 22:37:55 UTC (rev 1139)
+++ branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/json/ServerNode.java	2009-07-29 23:01:57 UTC (rev 1140)
@@ -112,7 +112,8 @@
 
         // keys are the repository names
         for (Iterator<String> itr = jsonObj.keys(); itr.hasNext();) {
-            Repository repository = new Repository(itr.next(), this.server);
+            String name = JsonUtils.decodeEscaping(itr.next());
+            Repository repository = new Repository(name, this.server);
             repositories.add(repository);
             Logger.trace(ServerNode.class, null, "getRepositories: adding repository=" + repository); //$NON-NLS-1$
         }

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-07-29 22:37:55 UTC (rev 1139)
+++ branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/json/WorkspaceNode.java	2009-07-29 23:01:57 UTC (rev 1140)
@@ -64,9 +64,9 @@
     public URL getUrl() throws Exception {
         RepositoryNode repositoryNode = new RepositoryNode(this.workspace.getRepository());
         StringBuilder url = new StringBuilder(repositoryNode.getUrl().toString());
-        
+
         // add workspace path
-        url.append('/').append(workspace.getName()).append(IJsonConstants.WORKSPACE_CONTEXT);
+        url.append('/').append(JsonUtils.encodeEscaping(workspace.getName())).append(IJsonConstants.WORKSPACE_CONTEXT);
         return new URL(url.toString());
     }
 

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-07-29 22:37:55 UTC (rev 1139)
+++ branches/eclipse/dna-web-jcr-rest-client/src/test/java/org/jboss/dna/web/jcr/rest/client/json/JsonRestClientTest.java	2009-07-29 23:01:57 UTC (rev 1140)
@@ -54,7 +54,7 @@
     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%3arepository"; //$NON-NLS-1$
+    private static final String REPOSITORY_NAME = "dna:repository"; //$NON-NLS-1$
     private static final Repository REPOSITORY1 = new Repository(REPOSITORY_NAME, SERVER);
     private static final String WORKSPACE_NAME = "default"; //$NON-NLS-1$
     private static final Workspace WORKSPACE1 = new Workspace(WORKSPACE_NAME, REPOSITORY1);



More information about the dna-commits mailing list