Author: elvisisking
Date: 2009-07-22 18:41:00 -0400 (Wed, 22 Jul 2009)
New Revision: 1125
Added:
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/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/WorkspaceNode.java
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/resources/myproject/
branches/eclipse/dna-web-jcr-rest-client/src/test/resources/myproject/myfolder/
branches/eclipse/dna-web-jcr-rest-client/src/test/resources/myproject/myfolder/document.txt
branches/eclipse/dna-web-jcr-rest-client/src/test/resources/myproject/myfolder/picture.jpg
Removed:
branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/IRestExecutor.java
branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/json/JsonRestProcessor.java
branches/eclipse/dna-web-jcr-rest-client/src/test/java/org/jboss/dna/web/jcr/rest/client/json/JsonRestProcessorTest.java
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/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/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/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/IJsonConstants.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/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/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
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/resources/log4j.properties
Log:
Mostly getting the URLs correct to talk to REST server. JsonRestClientTest is an
integration test that starts REST server.
Modified: branches/eclipse/dna-web-jcr-rest-client/pom.xml
===================================================================
--- branches/eclipse/dna-web-jcr-rest-client/pom.xml 2009-07-22 17:32:10 UTC (rev 1124)
+++ branches/eclipse/dna-web-jcr-rest-client/pom.xml 2009-07-22 22:41:00 UTC (rev 1125)
@@ -1,76 +1,165 @@
-<project
xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/maven-v4_0_0.xsd">
- <modelVersion>4.0.0</modelVersion>
- <parent>
- <groupId>org.jboss.dna</groupId>
- <artifactId>dna</artifactId>
- <version>0.6-SNAPSHOT</version>
- </parent>
- <!-- The groupId and version values are inherited from parent -->
- <artifactId>dna-web-jcr-rest-client</artifactId>
- <packaging>jar</packaging>
- <name>JBoss DNA JCR REST Client</name>
- <description>JBoss DNA JCR REST client resource publishing</description>
- <
url>http://labs.jboss.org/dna</url>
- <!--
- Define the dependencies. Note that all version and scopes default to those
- defined in the dependencyManagement section of the parent pom.
- -->
- <dependencies>
- <!--
- Testing (note the scope)
+<project
xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.jboss.dna</groupId>
+ <artifactId>dna</artifactId>
+ <version>0.6-SNAPSHOT</version>
+ </parent>
+ <!-- The groupId and version values are inherited from parent -->
+ <artifactId>dna-web-jcr-rest-client</artifactId>
+ <packaging>jar</packaging>
+ <name>JBoss DNA JCR REST Client</name>
+ <description>JBoss DNA JCR REST client resource publishing
+ </description>
+ <
url>http://labs.jboss.org/dna</url>
+ <!--
+ Define the dependencies. Note that all version and scopes default to
+ those defined in the dependencyManagement section of the parent pom.
+ -->
+ <dependencies>
+ <dependency>
+ <groupId>org.jboss.dna</groupId>
+ <artifactId>dna-web-jcr-rest-war</artifactId>
+ <type>war</type>
+ <version>${pom.version}</version>
+ </dependency>
+
+ <!--
+ Testing (note the scope)
-->
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- </dependency>
- <dependency>
- <groupId>org.hamcrest</groupId>
- <artifactId>hamcrest-library</artifactId>
- </dependency>
- <dependency>
- <groupId>org.mockito</groupId>
- <artifactId>mockito-all</artifactId>
- <scope>test</scope>
- </dependency>
- <!--
- Logging (require SLF4J API for compiling, but use Log4J and its SLF4J binding for
testing)
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <scope>integration-test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.hamcrest</groupId>
+ <artifactId>hamcrest-library</artifactId>
+ <scope>integration-test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.mockito</groupId>
+ <artifactId>mockito-all</artifactId>
+ <scope>integration-test</scope>
+ </dependency>
+ <!--
+ Logging (require SLF4J API for compiling, but use Log4J and its SLF4J
+ binding for testing)
+ -->
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-api</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-log4j12</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>log4j</groupId>
+ <artifactId>log4j</artifactId>
+ </dependency>
+ <!--
+ Java Concurrency in Practice annotations
-->
- <dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>slf4j-api</artifactId>
- </dependency>
- <dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>slf4j-log4j12</artifactId>
- </dependency>
- <dependency>
- <groupId>log4j</groupId>
- <artifactId>log4j</artifactId>
- </dependency>
- <!--
- Java Concurrency in Practice annotations
- -->
- <dependency>
- <groupId>net.jcip</groupId>
- <artifactId>jcip-annotations</artifactId>
- </dependency>
- <dependency>
- <groupId>org.jboss.resteasy</groupId>
- <artifactId>resteasy-jaxrs</artifactId>
- <version>1.1.GA</version>
- </dependency>
- <dependency>
- <groupId>org.jboss.resteasy</groupId>
- <artifactId>resteasy-jaxb-provider</artifactId>
- <version>1.1.GA</version>
- </dependency>
- </dependencies>
- <reporting>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-surefire-report-plugin</artifactId>
- </plugin>
- </plugins>
- </reporting>
+ <dependency>
+ <groupId>net.jcip</groupId>
+ <artifactId>jcip-annotations</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.resteasy</groupId>
+ <artifactId>resteasy-jaxrs</artifactId>
+ <version>1.1.GA</version>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.resteasy</groupId>
+ <artifactId>resteasy-jaxb-provider</artifactId>
+ <version>1.1.GA</version>
+ </dependency>
+ </dependencies>
+ <reporting>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-report-plugin
+ </artifactId>
+ </plugin>
+ </plugins>
+ </reporting>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.codehaus.cargo</groupId>
+ <artifactId>cargo-maven2-plugin</artifactId>
+ <!-- >version>1.0.1-SNAPSHOT</version -->
+ <executions>
+ <execution>
+ <id>start-container</id>
+ <phase>pre-integration-test</phase>
+ <goals>
+ <goal>start</goal>
+ </goals>
+ </execution>
+ <execution>
+ <id>stop-container</id>
+ <phase>post-integration-test</phase>
+ <goals>
+ <goal>stop</goal>
+ </goals>
+ </execution>
+ </executions>
+ <configuration>
+ <container>
+ <containerId>${cargo.container}</containerId>
+ <home>${cargo.container.home}</home>
+ </container>
+ <configuration>
+ <properties>
+ <cargo.logging>high</cargo.logging>
+ <cargo.servlet.users>
+ dnauser:password:connect,readwrite|unauthorized:password:bogus
+ </cargo.servlet.users>
+ <cargo.servlet.port>8080</cargo.servlet.port>
+ </properties>
+
+ <deployables>
+ <!-- application to deploy -->
+ <deployable>
+ <groupId>org.jboss.dna</groupId>
+ <artifactId>dna-web-jcr-rest-war</artifactId>
+ <type>war</type>
+ <properties>
+ <context>resources</context>
+ </properties>
+ </deployable>
+ </deployables>
+ </configuration>
+ <wait>false</wait>
+ </configuration>
+ </plugin>
+ <!--
+ Override the default Surefire behavior to run during
+ integration-test phase
+ -->
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <configuration>
+ <skip>true</skip>
+ </configuration>
+ <executions>
+ <execution>
+ <id>surefire-it</id>
+ <phase>integration-test</phase>
+ <goals>
+ <goal>test</goal>
+ </goals>
+ <configuration>
+ <skip>false</skip>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
</project>
Modified:
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-07-22
17:32:10 UTC (rev 1124)
+++
branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/IMessages.java 2009-07-22
22:41:00 UTC (rev 1125)
@@ -76,6 +76,12 @@
String WorkspaceNullRepositoryMsg = "WorkspaceNullRepositoryMsg";
//$NON-NLS-1$
String WorkspaceShortDescription = "WorkspaceShortDescription";
//$NON-NLS-1$
+
+ // JsonRestClient messages
+
+ String CreateFileFailedMsg = "CreateFileFailedMsg"; //$NON-NLS-1$
+
+ String CreateFolderFailedMsg = "CreateFolderFailedMsg"; //$NON-NLS-1$
String GetRepositoriesFailedMsg = "GetRepositoriesFailedMsg";
//$NON-NLS-1$
Copied:
branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/IRestClient.java
(from rev 1113,
branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/IRestExecutor.java)
===================================================================
---
branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/IRestClient.java
(rev 0)
+++
branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/IRestClient.java 2009-07-22
22:41:00 UTC (rev 1125)
@@ -0,0 +1,75 @@
+/*
+ * 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;
+
+/**
+ * @author dan
+ */
+public interface IRestClient {
+
+ /**
+ * @param server the server whose repositories are being requested (never
<code>null</code>)
+ * @return the repositories within the specified server (never
<code>null</code>)
+ * @throws Exception if there is a problem obtaining the repositories
+ * @since 0.6
+ */
+ public abstract Collection<Repository> getRepositories( Server server ) throws
Exception;
+
+ /**
+ * @param repository the repository whose workspaces are being requested (never
<code>null</code>)
+ * @return the workspaces within the specified repository (never
<code>null</code>)
+ * @throws Exception if there is a problem obtaining the workspaces
+ * @since 0.6
+ */
+ public abstract Collection<Workspace> getWorkspaces( Repository repository )
throws Exception;
+
+ /**
+ * @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
+ * @param file the resource being published (never <code>null</code>)
+ * @throws Exception if there is a problem publishing
+ * @since 0.6
+ */
+ public abstract void publish( Workspace workspace,
+ String path,
+ File file ) throws Exception;
+
+ /**
+ * @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 file the file being unpublished (never <code>null</code>)
+ * @throws Exception if there is a problem unpublishing
+ * @since 0.6
+ */
+ public abstract void unpublish( Workspace workspace,
+ String path,
+ File file ) throws Exception;
+
+}
Property changes on:
branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/IRestClient.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Deleted:
branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/IRestExecutor.java
===================================================================
---
branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/IRestExecutor.java 2009-07-22
17:32:10 UTC (rev 1124)
+++
branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/IRestExecutor.java 2009-07-22
22:41:00 UTC (rev 1125)
@@ -1,76 +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;
-
-/**
- * @author dan
- *
- */
-public interface IRestExecutor {
-
- /**
- * @param server the server whose repositories are being requested (never
<code>null</code>)
- * @return the repositories within the specified server (never
<code>null</code>)
- * @throws Exception if there is a problem obtaining the repositories
- * @since 0.6
- */
- public abstract Collection<Repository> getRepositories( Server server ) throws
Exception;
-
- /**
- * @param repository the repository whose workspaces are being requested (never
<code>null</code>)
- * @return the workspaces within the specified repository (never
<code>null</code>)
- * @throws Exception if there is a problem obtaining the workspaces
- * @since 0.6
- */
- public abstract Collection<Workspace> getWorkspaces( Repository repository )
throws Exception;
-
- /**
- * @param repository the repository where the resource will be published
- * @param parentPath the parent path where the file will be published in the
repository
- * @param file the resource being published
- * @throws Exception if there is a problem publishing
- * @since 0.6
- */
- public abstract void publish( Repository repository,
- String parentPath,
- File file ) throws Exception;
-
- /**
- * @param repository the repository where the resource will be unpublished (never
<code>null</code>)
- * @param parentPath the path to the parent folder in the repository (never
<code>null</code>)
- * @param file the file being unpublished (never <code>null</code>)
- * @throws Exception if there is a problem unpublishing
- * @since 0.6
- */
- public abstract void unpublish( Repository repository,
- String parentPath,
- File file ) throws Exception;
-
-}
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-22
17:32:10 UTC (rev 1124)
+++
branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/Logger.java 2009-07-22
22:41:00 UTC (rev 1125)
@@ -37,18 +37,44 @@
//
===========================================================================================================================
/**
- * @param status the status whose message is a {@link MessageFormat} pattern.
+ * @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( Status status,
+ private static String getMessage( Class<?> clazz,
+ String pattern,
Object... arguments ) {
- return MessageFormat.format(status.getMessage(), 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
* @param status the status being logged
* @since 0.6
*/
@@ -58,30 +84,24 @@
if (status.isError() && delegate.isErrorEnabled()) {
if (status.getException() == null) {
- delegate.error(status.getMessage());
+ delegate.error(getMessage(clazz, status.getMessage()));
} else {
- delegate.error(status.getMessage(), status.getException());
+ delegate.error(getMessage(clazz, status.getMessage()),
status.getException());
}
} else if (status.isWarning() && delegate.isWarnEnabled()) {
if (status.getException() == null) {
- delegate.warn(status.getMessage());
+ delegate.warn(getMessage(clazz, status.getMessage()));
} else {
- delegate.warn(status.getMessage(), status.getException());
+ delegate.warn(getMessage(clazz, status.getMessage()),
status.getException());
}
} else if (status.isInfo() && delegate.isInfoEnabled()) {
if (status.getException() == null) {
- delegate.info(status.getMessage());
+ delegate.info(getMessage(clazz, status.getMessage()));
} else {
- delegate.info(status.getMessage(), status.getException());
+ delegate.info(getMessage(clazz, status.getMessage()),
status.getException());
}
} else {
- if (delegate.isTraceEnabled()) {
- if (status.getException() == null) {
- delegate.info(status.getMessage());
- } else {
- delegate.info(status.getMessage(), status.getException());
- }
- }
+ trace(clazz, null, status.getMessage());
}
}
@@ -97,15 +117,15 @@
org.slf4j.Logger delegate = LoggerFactory.getLogger(clazz);
if (status.isError() && delegate.isErrorEnabled()) {
- String msg = getMessage(status, arguments);
+ String msg = getMessage(clazz, status, arguments);
if (status.getException() == null) {
delegate.error(msg);
} else {
- delegate.error(msg);
+ delegate.error(msg, status.getException());
}
} else if (status.isWarning() && delegate.isWarnEnabled()) {
- String msg = getMessage(status, arguments);
+ String msg = getMessage(clazz, status, arguments);
if (status.getException() == null) {
delegate.warn(msg);
@@ -113,7 +133,7 @@
delegate.warn(msg, status.getException());
}
} else if (status.isInfo() && delegate.isInfoEnabled()) {
- String msg = getMessage(status, arguments);
+ String msg = getMessage(clazz, status, arguments);
if (status.getException() == null) {
delegate.info(msg);
@@ -121,18 +141,52 @@
delegate.info(msg, status.getException());
}
} else {
- if (delegate.isTraceEnabled()) {
- String msg = getMessage(status, arguments);
+ trace(clazz, status.getException(), status.getMessage(), arguments);
+ }
+ }
- if (status.getException() == null) {
- delegate.info(msg);
- } else {
- delegate.info(msg, status.getException());
- }
+ /**
+ * @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
+ * @since 0.6
+ */
+ public static void trace( Class<?> clazz,
+ Throwable e,
+ String msg ) {
+ org.slf4j.Logger delegate = LoggerFactory.getLogger(clazz);
+
+ 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
+ * @param e the error being logged or <code>null</code>
+ * @param pattern the {@link MessageFormat} pattern
+ * @param arguments the arguments to be inserted into the pattern
+ * @since 0.6
+ */
+ public static void trace( Class<?> clazz,
+ Throwable e,
+ String pattern,
+ Object... arguments ) {
+ org.slf4j.Logger delegate = LoggerFactory.getLogger(clazz);
+
+ if (delegate.isTraceEnabled()) {
+ if (e == null) {
+ delegate.trace(getMessage(clazz, pattern, arguments));
+ } else {
+ delegate.trace(getMessage(clazz, pattern, arguments), e);
+ }
+ }
+ }
+
//
===========================================================================================================================
// Constructors
//
===========================================================================================================================
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-07-22
17:32:10 UTC (rev 1124)
+++
branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/ServerManager.java 2009-07-22
22:41:00 UTC (rev 1125)
@@ -23,6 +23,7 @@
*/
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.text.MessageFormat;
@@ -60,7 +61,7 @@
* @since 0.6
*/
@ThreadSafe
-public final class ServerManager implements IMessages {
+public final class ServerManager {
//
===========================================================================================================================
// Constants
@@ -124,7 +125,7 @@
*
* @since 0.6
*/
- private final IRestExecutor restExecutor;
+ private final IRestClient restExecutor;
/**
* The path where the server registry is persisted or <code>null</code>
if not persisted.
@@ -159,7 +160,7 @@
* @since 0.6
*/
public ServerManager( String stateLocationPath,
- IRestExecutor restExecutor ) {
+ IRestClient restExecutor ) {
this.servers = new ArrayList<Server>();
this.stateLocationPath = stateLocationPath;
this.restExecutor = restExecutor;
@@ -235,9 +236,9 @@
Collection<Repository> repositories =
this.restExecutor.getRepositories(server);
return Collections.unmodifiableCollection(new
ArrayList<Repository>(repositories));
}
-
+
// server must be registered in order to obtain it's repositories
- String pattern = IMessages.ServerManagerUnregisteredServer;
+ String pattern =
MESSAGES.getString(IMessages.ServerManagerUnregisteredServer);
throw new RuntimeException(MessageFormat.format(pattern,
server.getShortDescription()));
} finally {
this.serverLock.readLock().unlock();
@@ -255,14 +256,14 @@
public Collection<Workspace> getWorkspaces( Repository repository ) throws
Exception {
try {
this.serverLock.readLock().lock();
-
+
if (isRegistered(repository.getServer())) {
Collection<Workspace> workspaces =
this.restExecutor.getWorkspaces(repository);
return Collections.unmodifiableCollection(new
ArrayList<Workspace>(workspaces));
}
-
+
// a repository's server must be registered in order to obtain it's
workspaces
- String pattern = IMessages.ServerManagerUnregisteredServer;
+ String pattern =
MESSAGES.getString(IMessages.ServerManagerUnregisteredServer);
throw new RuntimeException(MessageFormat.format(pattern,
repository.getServer().getShortDescription()));
} finally {
this.serverLock.readLock().unlock();
@@ -301,7 +302,7 @@
}
// server already exists
- String pattern = MESSAGES.getString(ServerExistsMsg);
+ String pattern = MESSAGES.getString(IMessages.ServerExistsMsg);
String msg = MessageFormat.format(pattern, server.getShortDescription());
Status status = new Status(Severity.ERROR, msg, null);
return status;
@@ -341,7 +342,7 @@
}
// server could not be removed
- String pattern = MESSAGES.getString(ServerManagerRegistryRemoveUnexpectedError);
+ String pattern =
MESSAGES.getString(IMessages.ServerManagerRegistryRemoveUnexpectedError);
String msg = MessageFormat.format(pattern, server.getShortDescription());
Status status = new Status(Severity.ERROR, msg, null);
return status;
@@ -416,10 +417,11 @@
}
for (Exception error : errors) {
- Logger.log(getClass(), new Status(Severity.ERROR,
ServerManagerRegistryListenerError, error));
+ Logger.log(getClass(), new Status(Severity.ERROR,
MESSAGES.getString(IMessages.ServerManagerRegistryListenerError),
+ error));
}
- return new Status(Severity.WARNING, ServerManagerRegistryListenerErrorsOccurred,
null);
+ return new Status(Severity.WARNING,
MESSAGES.getString(IMessages.ServerManagerRegistryListenerErrorsOccurred), null);
}
/**
@@ -472,7 +474,7 @@
}
}
} catch (Exception e) {
- String pattern = MESSAGES.getString(ErrorRestoringServerRegistry);
+ String pattern =
MESSAGES.getString(IMessages.ErrorRestoringServerRegistry);
return new Status(Severity.ERROR, MessageFormat.format(pattern,
getStateFileName()), e);
}
}
@@ -519,7 +521,7 @@
transformer.setOutputProperty("{http://xml.apache.org/xslt}indent-am...;,
"2"); //$NON-NLS-1$ //$NON-NLS-2$
transformer.transform(source, resultXML);
} catch (Exception e) {
- String pattern = MESSAGES.getString(ErrorSavingServerRegistry);
+ String pattern =
MESSAGES.getString(IMessages.ErrorSavingServerRegistry);
return new Status(Severity.ERROR, MessageFormat.format(pattern,
getStateFileName()), e);
}
} else if ((this.stateLocationPath != null) && stateFileExists()) {
@@ -527,7 +529,7 @@
try {
new File(getStateFileName()).delete();
} catch (Exception e) {
- String pattern = MESSAGES.getString(ErrorDeletingServerRegistryFile);
+ String pattern =
MESSAGES.getString(IMessages.ErrorDeletingServerRegistryFile);
return new Status(Severity.ERROR, MessageFormat.format(pattern,
getStateFileName()), e);
}
}
@@ -570,7 +572,7 @@
}
// unexpected problem adding new version of server to registry
- String pattern =
MESSAGES.getString(ServerManagerRegistryUpdateAddError);
+ String pattern =
MESSAGES.getString(IMessages.ServerManagerRegistryUpdateAddError);
String msg = MessageFormat.format(pattern, status.getMessage());
status = new Status(Severity.ERROR, msg, status.getException());
return status;
@@ -580,7 +582,7 @@
}
// unexpected problem removing server from registry
- String pattern = MESSAGES.getString(ServerManagerRegistryUpdateRemoveError);
+ String pattern =
MESSAGES.getString(IMessages.ServerManagerRegistryUpdateRemoveError);
String msg = MessageFormat.format(pattern, status.getMessage());
status = new Status(Severity.ERROR, msg, status.getException());
return status;
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-22
17:32:10 UTC (rev 1124)
+++
branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/domain/Repository.java 2009-07-22
22:41:00 UTC (rev 1125)
@@ -23,11 +23,13 @@
*/
package org.jboss.dna.web.jcr.rest.client.domain;
+import static org.jboss.dna.web.jcr.rest.client.IMessages.MESSAGES;
+import static org.jboss.dna.web.jcr.rest.client.IMessages.RepositoryShortDescription;
import java.text.MessageFormat;
import net.jcip.annotations.Immutable;
-import org.jboss.dna.web.jcr.rest.client.IMessages;
import org.jboss.dna.web.jcr.rest.client.Status;
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.
@@ -36,7 +38,7 @@
* @since 0.6
*/
@Immutable
-public final class Repository implements IMessages, IDnaObject {
+public final class Repository implements IDnaObject {
//
===========================================================================================================================
// Fields
@@ -131,7 +133,7 @@
*/
public String getShortDescription() {
String pattern = MESSAGES.getString(RepositoryShortDescription);
- return MessageFormat.format(pattern, this.name,
this.server.getShortDescription());
+ return MessageFormat.format(pattern, JsonUtils.decodeEscaping(this.name),
this.server.getShortDescription());
}
/**
@@ -148,4 +150,15 @@
return hash;
}
+ /**
+ * {@inheritDoc}
+ *
+ * @see java.lang.Object#toString()
+ * @since 0.6
+ */
+ @Override
+ public String toString() {
+ return getShortDescription();
+ }
+
}
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-07-22
17:32:10 UTC (rev 1124)
+++
branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/domain/Server.java 2009-07-22
22:41:00 UTC (rev 1125)
@@ -23,9 +23,10 @@
*/
package org.jboss.dna.web.jcr.rest.client.domain;
+import static org.jboss.dna.web.jcr.rest.client.IMessages.MESSAGES;
+import static org.jboss.dna.web.jcr.rest.client.IMessages.ServerShortDescription;
import java.text.MessageFormat;
import net.jcip.annotations.Immutable;
-import org.jboss.dna.web.jcr.rest.client.IMessages;
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;
@@ -38,7 +39,7 @@
* @since 0.6
*/
@Immutable
-public final class Server implements IMessages, IDnaObject {
+public final class Server implements IDnaObject {
//
===========================================================================================================================
// Fields
@@ -212,4 +213,15 @@
return this.persistPassword;
}
+ /**
+ * {@inheritDoc}
+ *
+ * @see java.lang.Object#toString()
+ * @since 0.6
+ */
+ @Override
+ public String toString() {
+ return 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-22
17:32:10 UTC (rev 1124)
+++
branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/domain/Workspace.java 2009-07-22
22:41:00 UTC (rev 1125)
@@ -23,11 +23,13 @@
*/
package org.jboss.dna.web.jcr.rest.client.domain;
+import static org.jboss.dna.web.jcr.rest.client.IMessages.MESSAGES;
+import static org.jboss.dna.web.jcr.rest.client.IMessages.WorkspaceShortDescription;
import java.text.MessageFormat;
import net.jcip.annotations.Immutable;
-import org.jboss.dna.web.jcr.rest.client.IMessages;
import org.jboss.dna.web.jcr.rest.client.Status;
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.
@@ -36,7 +38,7 @@
* @since 0.6
*/
@Immutable
-public final class Workspace implements IMessages, IDnaObject {
+public final class Workspace implements IDnaObject {
//
===========================================================================================================================
// Fields
@@ -137,7 +139,7 @@
*/
public String getShortDescription() {
String pattern = MESSAGES.getString(WorkspaceShortDescription);
- return MessageFormat.format(pattern, this.name,
this.repository.getShortDescription());
+ return MessageFormat.format(pattern, JsonUtils.decodeEscaping(this.name),
this.repository.getShortDescription());
}
/**
@@ -154,4 +156,15 @@
return hash;
}
+ /**
+ * {@inheritDoc}
+ *
+ * @see java.lang.Object#toString()
+ * @since 0.6
+ */
+ @Override
+ public String toString() {
+ return getShortDescription();
+ }
+
}
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-07-22
17:32:10 UTC (rev 1124)
+++
branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/domain/validation/RepositoryValidator.java 2009-07-22
22:41:00 UTC (rev 1125)
@@ -23,7 +23,9 @@
*/
package org.jboss.dna.web.jcr.rest.client.domain.validation;
-import org.jboss.dna.web.jcr.rest.client.IMessages;
+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.Status;
import org.jboss.dna.web.jcr.rest.client.Status.Severity;
import org.jboss.dna.web.jcr.rest.client.domain.Server;
@@ -32,7 +34,7 @@
* @author Dan Florian
* @since 0.6
*/
-public final class RepositoryValidator implements IMessages {
+public final class RepositoryValidator {
//
===========================================================================================================================
// Class Methods
@@ -93,5 +95,5 @@
private RepositoryValidator() {
// nothing to do
}
-
+
}
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-07-22
17:32:10 UTC (rev 1124)
+++
branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/domain/validation/ServerValidator.java 2009-07-22
22:41:00 UTC (rev 1125)
@@ -23,9 +23,13 @@
*/
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 java.text.MessageFormat;
-import org.jboss.dna.web.jcr.rest.client.IMessages;
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.Status.Severity;
@@ -35,7 +39,7 @@
* @author Dan Florian
* @since 0.6
*/
-public final class ServerValidator implements IMessages {
+public final class ServerValidator {
//
===========================================================================================================================
// Class Methods
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-07-22
17:32:10 UTC (rev 1124)
+++
branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/domain/validation/WorkspaceValidator.java 2009-07-22
22:41:00 UTC (rev 1125)
@@ -23,7 +23,9 @@
*/
package org.jboss.dna.web.jcr.rest.client.domain.validation;
-import org.jboss.dna.web.jcr.rest.client.IMessages;
+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.Status;
import org.jboss.dna.web.jcr.rest.client.Status.Severity;
import org.jboss.dna.web.jcr.rest.client.domain.Repository;
@@ -32,7 +34,7 @@
* @author Dan Florian
* @since 0.6
*/
-public final class WorkspaceValidator implements IMessages {
+public final class WorkspaceValidator {
//
===========================================================================================================================
// Class Methods
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-07-22
17:32:10 UTC (rev 1124)
+++
branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/json/FileNode.java 2009-07-22
22:41:00 UTC (rev 1125)
@@ -34,7 +34,7 @@
import net.jcip.annotations.Immutable;
import org.codehaus.jettison.json.JSONObject;
import org.jboss.dna.web.jcr.rest.client.IJcrConstants;
-import org.jboss.dna.web.jcr.rest.client.domain.Repository;
+import org.jboss.dna.web.jcr.rest.client.domain.Workspace;
/**
* @author Dan Florian
@@ -55,36 +55,37 @@
private final File file;
/**
- * The parent folder in the repository where the file is or will be published or
unpublished.
+ * The folder in the workspace where the file is or will be published or
unpublished.
*
* @since 0.6
*/
- private final String parentPath;
+ private final String path;
/**
- * The repository where the file is or will be being published or unpublished.
+ * The workspace where the file is or will be published or unpublished.
*
* @since 0.6
*/
- private final Repository repository;
+ private final Workspace workspace;
//
===========================================================================================================================
// Constructors
//
===========================================================================================================================
/**
- * @param repository the repository being used
- * @param parentPath the parent path in the repository
+ * @param workspace the workspace being used (never <code>null</code>)
+ * @param path the path in the workspace (never <code>null</code>)
* @param file the file on the local file system
* @throws Exception if there is a problem constructing the file node
+ * @since 0.6
*/
- public FileNode( Repository repository,
- String parentPath,
+ public FileNode( Workspace workspace,
+ String path,
File file ) throws Exception {
super(file.getName());
this.file = file;
- this.parentPath = parentPath;
- this.repository = repository;
+ this.path = path;
+ this.workspace = workspace;
// add properties
JSONObject properties = new JSONObject();
@@ -124,11 +125,11 @@
}
/**
- * @return the parent path where the file is or will be published or unpublished
+ * @return the path where the file is or will be published or unpublished
* @since 0.6
*/
- public String getParentPath() {
- return this.parentPath;
+ public String getPath() {
+ return this.path;
}
/**
@@ -139,13 +140,11 @@
*/
@Override
public URL getUrl() throws Exception {
- StringBuilder url = new StringBuilder(createUrl(this.repository,
this.parentPath).toString());
+ FolderNode folderNode = new FolderNode(this.workspace, getPath());
+ StringBuilder url = new StringBuilder(folderNode.getUrl().toString());
- if (!this.parentPath.endsWith("/")) { //$NON-NLS-1$
- url.append('/');
- }
-
- url.append(this.file.getName());
+ // add file to path
+ url.append('/').append(this.file.getName());
return new URL(url.toString());
}
@@ -169,7 +168,7 @@
}
}
}
-
+
return bytes.toArray(new Byte[(bytes.size())]);
}
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-07-22
17:32:10 UTC (rev 1124)
+++
branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/json/FolderNode.java 2009-07-22
22:41:00 UTC (rev 1125)
@@ -27,7 +27,7 @@
import net.jcip.annotations.Immutable;
import org.codehaus.jettison.json.JSONObject;
import org.jboss.dna.web.jcr.rest.client.IJcrConstants;
-import org.jboss.dna.web.jcr.rest.client.domain.Repository;
+import org.jboss.dna.web.jcr.rest.client.domain.Workspace;
/**
* @author Dan Florian
@@ -41,26 +41,26 @@
//
===========================================================================================================================
/**
- * The repository where the file is being published.
+ * The workspace where the file is being published.
*
* @since 0.6
*/
- private final Repository repository;
+ private final Workspace workspace;
//
===========================================================================================================================
// Constructors
//
===========================================================================================================================
/**
- * @param repository the repository being used
- * @param fullPath the full path of the folder within the repository
+ * @param workspace the workspace being used (never <code>null</code>)
+ * @param fullPath the full path of the folder within the workspace (never
<code>null</code>)
* @throws Exception if there is a problem creating the folder node
* @since 0.6
*/
- public FolderNode( Repository repository,
+ public FolderNode( Workspace workspace,
String fullPath ) throws Exception {
super(fullPath);
- this.repository = repository;
+ this.workspace = workspace;
// add properties
JSONObject properties = new JSONObject();
@@ -73,22 +73,41 @@
//
===========================================================================================================================
/**
- * @return the full path of folder within the repository
+ * @return the full path of folder within the workspace
* @since 0.6
*/
public String getPath() {
return getId();
}
-
+
/**
* {@inheritDoc}
- *
+ * <p>
+ * The URL will NOT end in '/'.
+ *
* @see org.jboss.dna.web.jcr.rest.client.json.JsonNode#getUrl()
* @since 0.6
*/
@Override
public URL getUrl() throws Exception {
- return createUrl(this.repository, getId());
+ WorkspaceNode workspaceNode = new WorkspaceNode(this.workspace);
+ StringBuilder url = new StringBuilder(workspaceNode.getUrl().toString());
+
+ // add folder path
+ String path = getPath();
+
+ if (path.startsWith("/")) { //$NON-NLS-1$
+ url.append(path);
+ } else {
+ url.append('/').append(path);
+ }
+
+ // strip off ending '/'
+ if (path.endsWith("/")) { //$NON-NLS-1$
+ url.setLength(url.length() - 1);
+ }
+
+ return new URL(url.toString());
}
-
+
}
Modified:
branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/json/IJsonConstants.java
===================================================================
---
branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/json/IJsonConstants.java 2009-07-22
17:32:10 UTC (rev 1124)
+++
branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/json/IJsonConstants.java 2009-07-22
22:41:00 UTC (rev 1125)
@@ -72,11 +72,6 @@
String CHILDREN_KEY = "children"; //$NON-NLS-1$
/**
- * @since 0.6
- */
- String REPOSITORY_URL_CONTEXT = "/"; //$NON-NLS-1$
-
- /**
* The key in the <code>JSONObject</code> whose value is the collection
of node properties.
*
* @since 0.6
@@ -88,4 +83,9 @@
*/
String SERVER_CONTEXT = "/resources"; //$NON-NLS-1$
+ /**
+ * @since 0.6
+ */
+ String WORKSPACE_CONTEXT = "/items"; //$NON-NLS-1$
+
}
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-07-22
17:32:10 UTC (rev 1124)
+++
branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/json/JsonNode.java 2009-07-22
22:41:00 UTC (rev 1125)
@@ -25,8 +25,6 @@
import java.net.URL;
import org.codehaus.jettison.json.JSONObject;
-import org.jboss.dna.web.jcr.rest.client.domain.Repository;
-import org.jboss.dna.web.jcr.rest.client.domain.Server;
/**
* @author Dan Florian
@@ -35,51 +33,6 @@
public abstract class JsonNode extends JSONObject {
//
===========================================================================================================================
- // Class Methods
- //
===========================================================================================================================
-
- /**
- * The URL will always end in '/'.
- *
- * @param server the server to use when constructing the URL (never
<code>null</code>)
- * @return the URL (never <code>null</code>)
- * @throws Exception if there is a problem constructing the URL
- * @since 0.6
- */
- public static URL createUrl( Server server ) throws Exception {
- StringBuilder url = new StringBuilder(server.getUrl());
-
- // strip off last '/' if necessary
- if (url.lastIndexOf("/") == (url.length() - 1)) { //$NON-NLS-1$
- url.delete((url.length() - 1), (url.length() - 1));
- }
-
- url.append(IJsonConstants.SERVER_CONTEXT);
- return new URL(url.toString());
- }
-
- /**
- * @param repository the repository to use when constructing the URL
- * @param path the path in the repository to use when constructing the URL
- * @return the URL (never <code>null</code>)
- * @throws Exception if there is a problem constructing the URL
- * @since 0.6
- */
- public static URL createUrl( Repository repository,
- String path ) throws Exception {
- StringBuilder url = new
StringBuilder(createUrl(repository.getServer()).toString());
-
- // add a '/' after server URL if necessary
- if (path.startsWith("/")) { //$NON-NLS-1$
- url.append(path);
- } else {
- url.append('/').append(path);
- }
-
- return new URL(url.toString());
- }
-
- //
===========================================================================================================================
// Fields
//
===========================================================================================================================
Copied:
branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/json/JsonRestClient.java
(from rev 1113,
branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/json/JsonRestProcessor.java)
===================================================================
---
branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/json/JsonRestClient.java
(rev 0)
+++
branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/json/JsonRestClient.java 2009-07-22
22:41:00 UTC (rev 1125)
@@ -0,0 +1,366 @@
+/*
+ * 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.json;
+
+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.MESSAGES;
+import static org.jboss.dna.web.jcr.rest.client.IMessages.UnpublishFailedMsg;
+import java.io.File;
+import java.net.HttpURLConnection;
+import java.net.URL;
+import java.text.MessageFormat;
+import java.util.Collection;
+import javax.ws.rs.core.MediaType;
+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.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.IJsonConstants.RequestMethod;
+
+/**
+ * @author Dan Florian
+ * @since 0.6
+ */
+public final class JsonRestClient implements IRestClient {
+
+ //
===========================================================================================================================
+ // Methods
+ //
===========================================================================================================================
+
+ /**
+ * Creates a file node in the specified repository. Note: All parent folders are
assumed to already exist.
+ *
+ * @param workspace the workspace where the file node is being created
+ * @param path the path in the workspace to the folder where the file node is being
created
+ * @param file the file whose contents will be contained in the file node being
created
+ * @throws Exception if there is a problem creating the file
+ * @since 0.6
+ */
+ private void createFileNode( Workspace workspace,
+ String path,
+ File file ) throws Exception {
+ Logger.trace(JsonRestClient.class,
+ null,
+ "createFileNode: workspace=" + workspace + ",
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);
+
+ try {
+ Logger.trace(JsonRestClient.class, null, "createFileNode: file
node=" + fileNode); //$NON-NLS-1$
+ connection.getOutputStream().write(fileNode.getContent());
+
+ // make sure node was created
+ if (connection.getResponseCode() != HttpURLConnection.HTTP_CREATED) {
+ String pattern = MESSAGES.getString(CreateFileFailedMsg);
+ String msg = MessageFormat.format(pattern,
+ file.getName(),
+ path,
+ workspace.getName(),
+ connection.getResponseCode());
+ throw new RuntimeException(msg);
+ }
+ } finally {
+ if (connection != null) {
+ connection.disconnect();
+ }
+ }
+ }
+
+ /**
+ * Creates a folder node in the specified workspace. Note: All parent folders are
assumed to already exist.
+ *
+ * @param workspace the workspace where the folder node is being created
+ * @param path the folder path in the workspace
+ * @throws Exception if there is a problem creating the folder
+ * @since 0.6
+ */
+ private void createFolderNode( Workspace workspace,
+ String path ) throws Exception {
+ Logger.trace(JsonRestClient.class, null, "createFolderNode: workspace="
+ workspace + ", path=" + path); //$NON-NLS-1$//$NON-NLS-2$
+ FolderNode folderNode = new FolderNode(workspace, path);
+ HttpURLConnection connection = openConnection(folderNode.getUrl(),
RequestMethod.POST);
+
+ try {
+ Logger.trace(JsonRestClient.class, null, "createFolderNode: folder
node=" + folderNode); //$NON-NLS-1$
+ connection.getOutputStream().write(folderNode.getContent());
+
+ // make sure node was created
+ if (connection.getResponseCode() != HttpURLConnection.HTTP_CREATED) {
+ String pattern = MESSAGES.getString(CreateFolderFailedMsg);
+ String msg = MessageFormat.format(pattern, path, workspace.getName(),
connection.getResponseCode());
+ throw new RuntimeException(msg);
+ }
+ } finally {
+ if (connection != null) {
+ connection.disconnect();
+ }
+ }
+ }
+
+ /**
+ * Ensures the specified path exists in the specified workspace. The path must only
contain folder names.
+ *
+ * @param workspace the workspace being checked
+ * @param folderPath the path being checked
+ * @throws Exception if there is a problem ensuring the folder exists
+ * @since 0.6
+ */
+ private void ensureFolderExists( Workspace workspace,
+ String folderPath ) throws Exception {
+ Logger.trace(JsonRestClient.class, null, "ensureFolderExists:
workspace=" + workspace + ", path=" + folderPath);
//$NON-NLS-1$//$NON-NLS-2$
+ FolderNode folderNode = new FolderNode(workspace, folderPath);
+
+ if (!pathExists(folderNode.getUrl())) {
+ StringBuilder path = new StringBuilder();
+
+ for (char c : folderPath.toCharArray()) {
+ if (c == '/') {
+ if (path.length() > 1) {
+ folderNode = new FolderNode(workspace, path.toString());
+
+ if (!pathExists(folderNode.getUrl())) {
+ createFolderNode(workspace, folderNode.getPath());
+ }
+ }
+
+ path.append(c);
+ } else {
+ path.append(c);
+
+ if (path.length() == folderPath.length()) {
+ folderNode = new FolderNode(workspace, path.toString());
+
+ if (!pathExists(folderNode.getUrl())) {
+ createFolderNode(workspace, folderNode.getPath());
+ }
+ }
+ }
+ }
+ }
+ }
+
+ /**
+ * {@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
{
+ Logger.trace(JsonRestClient.class, null, "getRepositories: server=" +
server); //$NON-NLS-1$
+ ServerNode serverNode = new ServerNode(server);
+ HttpURLConnection connection =
openConnection(serverNode.getFindRepositoriesUrl(), RequestMethod.GET);
+
+ try {
+ if (connection.getResponseCode() == HttpURLConnection.HTTP_OK) {
+ return
serverNode.getRepositories(JsonUtils.readInputStream(connection));
+ }
+
+ // not a good response code
+ String pattern = MESSAGES.getString(GetRepositoriesFailedMsg);
+ String msg = MessageFormat.format(pattern, server.getName(),
connection.getResponseCode());
+ throw new RuntimeException(msg);
+ } finally {
+ if (connection != null) {
+ connection.disconnect();
+ }
+ }
+ }
+
+ /**
+ * {@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 {
+ Logger.trace(JsonRestClient.class, null, "getWorkspaces: repository=" +
repository); //$NON-NLS-1$
+ RepositoryNode repositoryNode = new RepositoryNode(repository);
+ HttpURLConnection connection = openConnection(repositoryNode.getUrl(),
RequestMethod.GET);
+
+ try {
+ if (connection.getResponseCode() == HttpURLConnection.HTTP_OK) {
+ return
repositoryNode.getWorkspaces(JsonUtils.readInputStream(connection));
+ }
+
+ // not a good response code
+ String pattern = MESSAGES.getString(GetWorkspacesFailedMsg);
+ String msg = MessageFormat.format(pattern,
+ repository.getName(),
+ repository.getServer().getName(),
+ connection.getResponseCode());
+ throw new RuntimeException(msg);
+ } finally {
+ if (connection != null) {
+ connection.disconnect();
+ }
+ }
+ }
+
+ /**
+ * @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,
+ RequestMethod method ) throws Exception {
+ Logger.trace(JsonRestClient.class, null, "openConnection: url=" + url +
", method=" + method); //$NON-NLS-1$ //$NON-NLS-2$
+ HttpURLConnection connection = (HttpURLConnection)url.openConnection();
+ connection.setDoOutput(true);
+ connection.setRequestMethod(method.toString());
+ connection.setRequestProperty("Content-Type",
MediaType.APPLICATION_JSON); //$NON-NLS-1$
+ return connection;
+ }
+
+ /**
+ * @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 {
+ Logger.trace(JsonRestClient.class, null, "pathExists: url=" + url);
//$NON-NLS-1$
+ HttpURLConnection connection = openConnection(url, RequestMethod.GET);
+
+ try {
+ Logger.trace(JsonRestClient.class, null, "pathExists: response
code=" + connection.getResponseCode()); //$NON-NLS-1$
+ return (connection.getResponseCode() == HttpURLConnection.HTTP_OK);
+ } finally {
+ if (connection != null) {
+ connection.disconnect();
+ }
+ }
+ }
+
+ /**
+ * @param workspace the workspace being checked (never
<code>null</code>)
+ * @param path the path in workspace (never <code>null</code>)
+ * @param file the file being checked (never <code>null</code>)
+ * @return <code>true</code> if the file exists in the workspace at the
specified path
+ * @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 {
+ Logger.trace(JsonRestClient.class,
+ null,
+ "pathExists: workspace=" + workspace + ", path="
+ path + ", file=" + file.getAbsolutePath()); //$NON-NLS-1$ //$NON-NLS-2$
//$NON-NLS-3$
+ FileNode fileNode = new FileNode(workspace, path, file);
+ return pathExists(fileNode.getUrl());
+ }
+
+ /**
+ * {@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 void publish( Workspace workspace,
+ String path,
+ File file ) throws Exception {
+ Logger.trace(JsonRestClient.class,
+ null,
+ "publish: workspace=" + workspace + ", path=" +
path + ", file=" + file.getAbsolutePath()); //$NON-NLS-1$ //$NON-NLS-2$
//$NON-NLS-3$
+
+ // see if file exists at that path
+ if (pathExists(workspace, path, file)) {
+ // must be an update
+ updateFileNode(workspace, path, file);
+ } else {
+ // doesn't exist so make sure the parent path exists
+ ensureFolderExists(workspace, path);
+
+ // publish new file
+ createFileNode(workspace, path, file);
+ }
+ }
+
+ /**
+ * {@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 void unpublish( Workspace workspace,
+ String path,
+ File file ) throws Exception {
+ Logger.trace(JsonRestClient.class,
+ null,
+ "publish: workspace=" + workspace + ", 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.DELETE);
+
+ try {
+ if (connection.getResponseCode() != HttpURLConnection.HTTP_NO_CONTENT) {
+ String pattern = MESSAGES.getString(UnpublishFailedMsg);
+ String msg = MessageFormat.format(pattern,
+ file.getName(),
+ workspace.getName(),
+ path,
+ connection.getResponseCode());
+ throw new RuntimeException(msg);
+ }
+ } finally {
+ if (connection != null) {
+ connection.disconnect();
+ }
+ }
+ }
+
+ /**
+ * Updates a file node in the specified workspace. Note: All parent folders are
assumed to already exist.
+ *
+ * @param workspace the workspace where the file node is being updated
+ * @param path the path to the folder where the file node is being updated
+ * @param file the file whose contents will be contained in the file node being
created
+ * @throws Exception if there is a problem creating the file
+ * @since 0.6
+ */
+ private void updateFileNode( Workspace workspace,
+ String path,
+ File file ) throws Exception {
+ Logger.trace(JsonRestClient.class,
+ null,
+ "updateFileNode: workspace=" + workspace + ",
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.PUT);
+
+ try {
+ connection.getOutputStream().write(fileNode.getContent());
+ } finally {
+ if (connection != null) {
+ connection.disconnect();
+ }
+ }
+ }
+
+}
Property changes on:
branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/json/JsonRestClient.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Deleted:
branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/json/JsonRestProcessor.java
===================================================================
---
branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/json/JsonRestProcessor.java 2009-07-22
17:32:10 UTC (rev 1124)
+++
branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/json/JsonRestProcessor.java 2009-07-22
22:41:00 UTC (rev 1125)
@@ -1,340 +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.json;
-
-import java.io.File;
-import java.io.IOException;
-import java.io.InputStream;
-import java.net.HttpURLConnection;
-import java.net.URL;
-import java.text.MessageFormat;
-import java.util.Collection;
-import javax.ws.rs.core.MediaType;
-import org.jboss.dna.web.jcr.rest.client.IMessages;
-import org.jboss.dna.web.jcr.rest.client.IRestExecutor;
-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.IJsonConstants.RequestMethod;
-
-/**
- * @author Dan Florian
- * @since 0.6
- */
-public final class JsonRestProcessor implements IRestExecutor {
-
- //
===========================================================================================================================
- // Methods
- //
===========================================================================================================================
-
- /**
- * Creates a file node in the specified repository. Note: All parent folders are
assumed to already exist.
- *
- * @param repository the repository where the file node is being created
- * @param parentPath the path to the folder where the file node is being created
- * @param file the file whose contents will be contained in the file node being
created
- * @throws Exception if there is a problem creating the file
- * @since 0.6
- */
- private void createFileNode( Repository repository,
- String parentPath,
- File file ) throws Exception {
- FileNode fileNode = new FileNode(repository, parentPath, file);
- HttpURLConnection connection = openConnection(fileNode.getUrl(),
RequestMethod.POST);
-
- try {
- connection.getOutputStream().write(fileNode.getContent());
- } finally {
- if (connection != null) {
- connection.disconnect();
- }
- }
- }
-
- /**
- * Updates a file node in the specified repository. Note: All parent folders are
assumed to already exist.
- *
- * @param repository the repository where the file node is being updated
- * @param parentPath the path to the folder where the file node is being updated
- * @param file the file whose contents will be contained in the file node being
created
- * @throws Exception if there is a problem creating the file
- * @since 0.6
- */
- private void updateFileNode( Repository repository,
- String parentPath,
- File file ) throws Exception {
- FileNode fileNode = new FileNode(repository, parentPath, file);
- HttpURLConnection connection = openConnection(fileNode.getUrl(),
RequestMethod.PUT);
-
- try {
- connection.getOutputStream().write(fileNode.getContent());
- } finally {
- if (connection != null) {
- connection.disconnect();
- }
- }
- }
-
- /**
- * Creates a folder node in the specified repository. Note: All parent folders are
assumed to already exist.
- *
- * @param repository the repository where the folder node is being created
- * @param path the folder path in the repository
- * @throws Exception if there is a problem creating the folder
- * @since 0.6
- */
- private void createFolderNode( Repository repository,
- String path ) throws Exception {
- FolderNode folderNode = new FolderNode(repository, path);
- HttpURLConnection connection = openConnection(folderNode.getUrl(),
RequestMethod.POST);
-
- try {
- connection.getOutputStream().write(folderNode.getContent());
- } finally {
- if (connection != null) {
- connection.disconnect();
- }
- }
- }
-
- /**
- * Ensures the specified path exists in the specified repository. The path must only
contain folder names.
- *
- * @param repository the repository being checked
- * @param folderPath the path being checked
- * @throws Exception if there is a problem ensuring the folder exists
- * @since 0.6
- */
- private void ensureFolderExists( Repository repository,
- String folderPath ) throws Exception {
- FolderNode folderNode = new FolderNode(repository, folderPath);
-
- if (!pathExists(folderNode.getUrl())) {
- StringBuilder path = new StringBuilder();
-
- for (char c : folderPath.toCharArray()) {
- if (c == '/') {
- if (path.length() > 1) {
- folderNode = new FolderNode(repository, path.toString());
-
- if (!pathExists(folderNode.getUrl())) {
- createFolderNode(repository, folderNode.getPath());
- }
- }
-
- path.append(c);
- } else {
- path.append(c);
-
- if (path.length() == folderPath.length()) {
- folderNode = new FolderNode(repository, path.toString());
-
- if (!pathExists(folderNode.getUrl())) {
- createFolderNode(repository, folderNode.getPath());
- }
- }
- }
- }
- }
- }
-
- /**
- * {@inheritDoc}
- *
- * @see
org.jboss.dna.web.jcr.rest.client.IRestExecutor#getRepositories(org.jboss.dna.web.jcr.rest.client.domain.Server)
- * @since 0.6
- */
- public Collection<Repository> getRepositories( Server server ) throws Exception
{
- ServerNode serverNode = new ServerNode(server);
- HttpURLConnection connection = openConnection(serverNode.getUrl(),
RequestMethod.GET);
-
- try {
- if (connection.getResponseCode() == HttpURLConnection.HTTP_OK) {
- return serverNode.getRepositories(readInputStream(connection));
- }
-
- // not a good response code
- String pattern = IMessages.GetRepositoriesFailedMsg;
- String msg = MessageFormat.format(pattern, server.getName(),
connection.getResponseCode());
- throw new RuntimeException(msg);
- } finally {
- if (connection != null) {
- connection.disconnect();
- }
- }
- }
-
- /**
- * {@inheritDoc}
- *
- * @see
org.jboss.dna.web.jcr.rest.client.IRestExecutor#getWorkspaces(org.jboss.dna.web.jcr.rest.client.domain.Repository)
- * @since 0.6
- */
- public Collection<Workspace> getWorkspaces( Repository repository ) throws
Exception {
- RepositoryNode repositoryNode = new RepositoryNode(repository);
- HttpURLConnection connection = openConnection(repositoryNode.getUrl(),
RequestMethod.GET);
-
- try {
- if (connection.getResponseCode() == HttpURLConnection.HTTP_OK) {
- return repositoryNode.getWorkspaces(readInputStream(connection));
- }
-
- // not a good response code
- String pattern = IMessages.GetWorkspacesFailedMsg;
- String msg = MessageFormat.format(pattern,
- repository.getName(),
- repository.getServer().getName(),
- connection.getResponseCode());
- throw new RuntimeException(msg);
- } finally {
- if (connection != null) {
- connection.disconnect();
- }
- }
- }
-
- /**
- * @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,
- RequestMethod method ) throws Exception {
- HttpURLConnection connection = (HttpURLConnection)url.openConnection();
- connection.setDoOutput(true);
- connection.setRequestMethod(method.toString());
- connection.setRequestProperty("Content-Type",
MediaType.APPLICATION_JSON); //$NON-NLS-1$
- return connection;
- }
-
- /**
- * @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
- */
- private boolean pathExists( URL url ) throws Exception {
- HttpURLConnection connection = openConnection(url, RequestMethod.GET);
-
- try {
- return (connection.getResponseCode() == HttpURLConnection.HTTP_OK);
- } finally {
- if (connection != null) {
- connection.disconnect();
- }
- }
- }
-
- /**
- * @param repository the repository being checked (never
<code>null</code>)
- * @param path the parentPath in repository (never <code>null</code>)
- * @param file the file being checked (never <code>null</code>)
- * @return <code>true</code> if the file exists in the repository at the
specified path
- * @throws Exception if there is a problem checking the existence of the file
- * @since 0.6
- */
- private boolean pathExists( Repository repository,
- String path,
- File file ) throws Exception {
- FileNode fileNode = new FileNode(repository, path, file);
- return pathExists(fileNode.getUrl());
- }
-
- /**
- * {@inheritDoc}
- *
- * @see
org.jboss.dna.web.jcr.rest.client.IRestExecutor#publish(org.jboss.dna.web.jcr.rest.client.domain.Repository,
- * java.lang.String, java.io.File)
- * @since 0.6
- */
- public void publish( Repository repository,
- String parentPath,
- File file ) throws Exception {
- // see if file exists at that path
- if (pathExists(repository, parentPath, file)) {
- // must be an update
- updateFileNode(repository, parentPath, file);
- } else {
- // doesn't exist so make sure the parent path exists
- ensureFolderExists(repository, parentPath);
-
- // publish new file
- createFileNode(repository, parentPath, file);
- }
- }
-
- /**
- * Note: The connection is not disconnected during this method.
- *
- * @param connection the connection whose input stream is going to be read from
- * @return the data read from the connection input stream
- * @throws IOException if there is a problem reading from the connection
- * @since 0.6
- */
- private String readInputStream( HttpURLConnection connection ) throws IOException {
- InputStream stream = connection.getInputStream();
- int bytesRead;
- byte[] bytes = new byte[1024];
- StringBuffer buff = new StringBuffer();
-
- while (-1 != (bytesRead = stream.read(bytes, 0, 1024))) {
- buff.append(new String(bytes, 0, bytesRead));
- }
-
- return buff.toString();
- }
-
- /**
- * {@inheritDoc}
- *
- * @see
org.jboss.dna.web.jcr.rest.client.IRestExecutor#unpublish(org.jboss.dna.web.jcr.rest.client.domain.Repository,
- * java.lang.String, java.io.File)
- * @since 0.6
- */
- public void unpublish( Repository repository,
- String parentPath,
- File file ) throws Exception {
- FileNode fileNode = new FileNode(repository, parentPath, file);
- HttpURLConnection connection = openConnection(fileNode.getUrl(),
RequestMethod.DELETE);
-
- try {
- if (connection.getResponseCode() != HttpURLConnection.HTTP_NO_CONTENT) {
- String pattern = IMessages.UnpublishFailedMsg;
- String msg = MessageFormat.format(pattern,
- file.getName(),
- repository.getName(),
- parentPath,
- connection.getResponseCode());
- throw new RuntimeException(msg);
- }
- } finally {
- if (connection != null) {
- connection.disconnect();
- }
- }
- }
-
-}
Added:
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
(rev 0)
+++
branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/json/JsonUtils.java 2009-07-22
22:41:00 UTC (rev 1125)
@@ -0,0 +1,82 @@
+/*
+ * 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.json;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.HttpURLConnection;
+
+/**
+ * @author Dan Florian
+ * @since 0.6
+ */
+public final class JsonUtils {
+
+ //
===========================================================================================================================
+ // Class Methods
+ //
===========================================================================================================================
+
+ /**
+ * @param text the text whose escape sequences will be replaced with the actual
characters
+ * @return the decoded text
+ * @since 0.6
+ */
+ public static String decodeEscaping( String text ) {
+ return text.replace("%3a", ":"); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ /**
+ * Note: The connection is not disconnected during this method.
+ *
+ * @param connection the connection whose input stream is going to be read from
+ * @return the data read from the connection input stream
+ * @throws IOException if there is a problem reading from the connection
+ * @since 0.6
+ */
+ public static String readInputStream( HttpURLConnection connection ) throws
IOException {
+ InputStream stream = connection.getInputStream();
+ int bytesRead;
+ byte[] bytes = new byte[1024];
+ StringBuffer buff = new StringBuffer();
+
+ while (-1 != (bytesRead = stream.read(bytes, 0, 1024))) {
+ buff.append(new String(bytes, 0, bytesRead));
+ }
+
+ return buff.toString();
+ }
+
+ //
===========================================================================================================================
+ // Constructors
+ //
===========================================================================================================================
+
+ /**
+ * Don't allow construction.
+ *
+ * @since 0.6
+ */
+ private JsonUtils() {
+ // nothing to do
+ }
+}
Property changes on:
branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/json/JsonUtils.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/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-22
17:32:10 UTC (rev 1124)
+++
branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/json/RepositoryNode.java 2009-07-22
22:41:00 UTC (rev 1125)
@@ -53,7 +53,7 @@
//
===========================================================================================================================
/**
- * @param repository the DNA repository
+ * @param repository the DNA repository (never <code>null</code>)
* @since 0.6
*/
public RepositoryNode( Repository repository ) {
@@ -67,13 +67,20 @@
/**
* {@inheritDoc}
+ * <p>
+ * This URL can be used to obtain the workspaces contained in this repository. The
URL will NOT end in '/'.
*
* @see org.jboss.dna.web.jcr.rest.client.json.JsonNode#getUrl()
* @since 0.6
*/
@Override
public URL getUrl() throws Exception {
- return createUrl(this.repository, this.repository.getName());
+ ServerNode serverNode = new ServerNode(this.repository.getServer());
+ StringBuilder url = new StringBuilder(serverNode.getUrl().toString());
+
+ // add repository path
+ url.append('/').append(repository.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/ServerNode.java
===================================================================
---
branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/json/ServerNode.java 2009-07-22
17:32:10 UTC (rev 1124)
+++
branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/json/ServerNode.java 2009-07-22
22:41:00 UTC (rev 1125)
@@ -28,6 +28,7 @@
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.domain.Repository;
import org.jboss.dna.web.jcr.rest.client.domain.Server;
@@ -53,7 +54,7 @@
//
===========================================================================================================================
/**
- * @param server the server containing the repositories
+ * @param server the server containing the repositories (never
<code>null</code>)
* @since 0.6
*/
public ServerNode( Server server ) {
@@ -67,43 +68,35 @@
/**
* {@inheritDoc}
+ * <p>
+ * The URL will NOT end in '/'.
*
* @see org.jboss.dna.web.jcr.rest.client.json.JsonNode#getUrl()
* @since 0.6
*/
@Override
public URL getUrl() throws Exception {
- return createUrl(this.server);
+ StringBuilder url = new StringBuilder(this.server.getUrl());
+
+ // strip off last '/' if necessary
+ if (url.lastIndexOf("/") == (url.length() - 1)) { //$NON-NLS-1$
+ url.delete((url.length() - 1), (url.length() - 1));
+ }
+
+ url.append(IJsonConstants.SERVER_CONTEXT);
+ return new URL(url.toString());
}
/**
- * @return the URL for this server to use when requesting the repositories (never
<code>null</code>)
+ * @return the URL to use when requesting the repositories (never
<code>null</code>)
* @throws Exception if there is a problem obtaining the repositories
* @since 0.6
*/
public URL getFindRepositoriesUrl() throws Exception {
- URL url = createUrl(this.server);
- return new URL(url.toString() + IJsonConstants.REPOSITORY_URL_CONTEXT);
+ return new URL(getUrl().toString() + '/');
}
/**
- * @param repository the repository whose workspaces are being requested (never
<code>null</code>)
- * @return the URL for this server to use when requesting a collection of workspaces
(never <code>null</code>)
- * @throws Exception if there is a problem obtaining the workspaces
- * @since 0.6
- */
- public URL getFindWorkspacesUrl( Repository repository ) throws Exception {
- StringBuilder url = new StringBuilder(createUrl(this.server).toString());
-
- if (!url.toString().endsWith("/")) { //$NON-NLS-1$
- url.append('/');
- }
-
- url.append(repository.getName());
- return new URL(url.toString());
- }
-
- /**
* @param jsonResponse the HTTP connection JSON response (never
<code>null</code>) containing the repositories
* @return the repositories found in the JSON response (never
<code>null</code>)
* @throws Exception if there is a problem obtaining the repositories
@@ -112,12 +105,14 @@
@SuppressWarnings( "unchecked" )
public Collection<Repository> getRepositories( String jsonResponse ) throws
Exception {
Collection<Repository> repositories = new ArrayList<Repository>();
+ Logger.trace(ServerNode.class, null, "getRepositories:jsonResponse=" +
jsonResponse); //$NON-NLS-1$
JSONObject jsonObj = new JSONObject(jsonResponse);
// keys are the repository names
for (Iterator<String> itr = jsonObj.keys(); itr.hasNext();) {
Repository repository = new Repository(itr.next(), this.server);
repositories.add(repository);
+ Logger.trace(ServerNode.class, null, "getRepositories:repository="
+ repository); //$NON-NLS-1$
}
return repositories;
Added:
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
(rev 0)
+++
branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/json/WorkspaceNode.java 2009-07-22
22:41:00 UTC (rev 1125)
@@ -0,0 +1,73 @@
+/*
+ * 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.json;
+
+import java.net.URL;
+import org.jboss.dna.web.jcr.rest.client.domain.Workspace;
+
+/**
+ * @author dan
+ */
+public class WorkspaceNode extends JsonNode {
+
+ //
===========================================================================================================================
+ // Fields
+ //
===========================================================================================================================
+
+ private final Workspace workspace;
+
+ //
===========================================================================================================================
+ // Constructors
+ //
===========================================================================================================================
+
+ /**
+ * @param workspace the repository workspace (never <code>null</code>)
+ * @since 0.6
+ */
+ public WorkspaceNode( Workspace workspace ) {
+ super(workspace.getName());
+ this.workspace = workspace;
+ }
+
+ //
===========================================================================================================================
+ // Methods
+ //
===========================================================================================================================
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.jboss.dna.web.jcr.rest.client.json.JsonNode#getUrl()
+ * @since 0.6
+ */
+ @Override
+ 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);
+ return new URL(url.toString());
+ }
+
+}
Property changes on:
branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/json/WorkspaceNode.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified:
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-07-22
17:32:10 UTC (rev 1124)
+++
branches/eclipse/dna-web-jcr-rest-client/src/main/resources/org/jboss/dna/web/jcr/rest/client/Messages.properties 2009-07-22
22:41:00 UTC (rev 1125)
@@ -47,8 +47,10 @@
WorkspaceNullRepositoryMsg = A workspace repository cannot be null
WorkspaceShortDescription = DNA Repository Workspace: Name: {0}, {1}
-# JsonRestProcessor messages
+# JsonRestClient messages
+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}"
UnpublishFailedMsg = The file "{0}" could not be unpublished in repository
"{1}" at path "{2}". The HTTP response code was "{3}".
Modified:
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-07-22
17:32:10 UTC (rev 1124)
+++
branches/eclipse/dna-web-jcr-rest-client/src/test/java/org/jboss/dna/web/jcr/rest/client/MockRestExecutor.java 2009-07-22
22:41:00 UTC (rev 1125)
@@ -33,22 +33,16 @@
* @author Dan Florian
* @since 0.6
*/
-public final class MockRestExecutor implements IRestExecutor {
+public final class MockRestExecutor implements IRestClient {
//
===========================================================================================================================
- // Constants
- //
===========================================================================================================================
-
-
-
- //
===========================================================================================================================
// Methods
//
===========================================================================================================================
/**
* {@inheritDoc}
- *
- * @see
org.jboss.dna.web.jcr.rest.client.IRestExecutor#getRepositories(org.jboss.dna.web.jcr.rest.client.domain.Server)
+ *
+ * @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
{
@@ -57,8 +51,8 @@
/**
* {@inheritDoc}
- *
- * @see
org.jboss.dna.web.jcr.rest.client.IRestExecutor#getWorkspaces(org.jboss.dna.web.jcr.rest.client.domain.Repository)
+ *
+ * @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 {
@@ -67,23 +61,25 @@
/**
* {@inheritDoc}
- *
- * @see
org.jboss.dna.web.jcr.rest.client.IRestExecutor#publish(org.jboss.dna.web.jcr.rest.client.domain.Repository,
java.lang.String, java.io.File)
+ *
+ * @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 void publish( Repository repository,
- String parentPath,
+ public void publish( Workspace workspace,
+ String path,
File file ) throws Exception {
}
/**
* {@inheritDoc}
- *
- * @see
org.jboss.dna.web.jcr.rest.client.IRestExecutor#unpublish(org.jboss.dna.web.jcr.rest.client.domain.Repository,
java.lang.String, java.io.File)
+ *
+ * @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 void unpublish( Repository repository,
- String parentPath,
+ public void unpublish( Workspace workspace,
+ String path,
File file ) throws Exception {
}
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-07-22
17:32:10 UTC (rev 1124)
+++
branches/eclipse/dna-web-jcr-rest-client/src/test/java/org/jboss/dna/web/jcr/rest/client/ServerManagerTest.java 2009-07-22
22:41:00 UTC (rev 1125)
@@ -34,7 +34,7 @@
* @author Dan Florian
* @since 0.6
*/
-public class ServerManagerTest {
+public final class ServerManagerTest {
//
===========================================================================================================================
// Constants
Copied:
branches/eclipse/dna-web-jcr-rest-client/src/test/java/org/jboss/dna/web/jcr/rest/client/json/JsonRestClientTest.java
(from rev 1113,
branches/eclipse/dna-web-jcr-rest-client/src/test/java/org/jboss/dna/web/jcr/rest/client/json/JsonRestProcessorTest.java)
===================================================================
---
branches/eclipse/dna-web-jcr-rest-client/src/test/java/org/jboss/dna/web/jcr/rest/client/json/JsonRestClientTest.java
(rev 0)
+++
branches/eclipse/dna-web-jcr-rest-client/src/test/java/org/jboss/dna/web/jcr/rest/client/json/JsonRestClientTest.java 2009-07-22
22:41:00 UTC (rev 1125)
@@ -0,0 +1,124 @@
+/*
+ * 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.json;
+
+import static org.hamcrest.core.Is.is;
+import static org.hamcrest.core.IsEqual.equalTo;
+import static org.hamcrest.core.IsNull.notNullValue;
+import static org.junit.Assert.assertThat;
+import java.io.File;
+import java.net.Authenticator;
+import java.net.PasswordAuthentication;
+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.domain.Repository;
+import org.jboss.dna.web.jcr.rest.client.domain.Server;
+import org.jboss.dna.web.jcr.rest.client.domain.Workspace;
+import org.junit.Before;
+import org.junit.Test;
+
+/**
+ * @author Dan Florian
+ * @since 0.6
+ */
+public final class JsonRestClientTest {
+
+ //
===========================================================================================================================
+ // 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%3arepository";
//$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);
+
+ private static final String WORKSPACE_PATH = "/myproject/myfolder/";
//$NON-NLS-1$
+ private static final String FILE_PATH = WORKSPACE_PATH + "document.txt";
//$NON-NLS-1$
+// private static final String BINARY_FILE_PATH = WORKSPACE_PATH +
"picture.txt"; //$NON-NLS-1$
+
+ //
===========================================================================================================================
+ // Fields
+ //
===========================================================================================================================
+
+ private IRestClient restClient;
+
+ //
===========================================================================================================================
+ // Methods
+ //
===========================================================================================================================
+
+ @Before
+ public void beforeEach() {
+ this.restClient = new JsonRestClient();
+
+ Authenticator.setDefault(new Authenticator() {
+ @Override
+ protected PasswordAuthentication getPasswordAuthentication() {
+ return new PasswordAuthentication(USER, PSWD.toCharArray());
+ }
+ });
+ }
+
+ //
===========================================================================================================================
+ // Tests
+ //
===========================================================================================================================
+
+ @Test
+ public void shouldGetRepositories() throws Exception {
+ Collection<Repository> repositories =
this.restClient.getRepositories(SERVER);
+ assertThat(repositories.size(), equalTo(1));
+ assertThat(repositories.iterator().next(), is(REPOSITORY1));
+ }
+
+ @Test
+ public void shouldGetWorkspaces() throws Exception {
+ Collection<Workspace> workspaces =
this.restClient.getWorkspaces(REPOSITORY1);
+ assertThat(workspaces.size(), is(1));
+ assertThat(workspaces.iterator().next(), is(WORKSPACE1));
+ }
+
+ // @Test
+ public void shouldPublishResource() throws Exception {
+ URL textFile = getClass().getResource(FILE_PATH);
+ assertThat(textFile, is(notNullValue()));
+
+ // publish
+ File file = new File(textFile.toURI());
+ this.restClient.publish(WORKSPACE1, WORKSPACE_PATH, file);
+
+ // confirm it exists in repository
+ assertThat(((JsonRestClient)this.restClient).pathExists(WORKSPACE1,
WORKSPACE_PATH, file), is(true));
+ }
+
+ // @Test
+ public void shouldUnpublish() throws Exception {
+ this.restClient.unpublish(WORKSPACE1, WORKSPACE_PATH, new File(FILE_PATH));
+ }
+
+}
Property changes on:
branches/eclipse/dna-web-jcr-rest-client/src/test/java/org/jboss/dna/web/jcr/rest/client/json/JsonRestClientTest.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/json/JsonRestProcessorTest.java
===================================================================
---
branches/eclipse/dna-web-jcr-rest-client/src/test/java/org/jboss/dna/web/jcr/rest/client/json/JsonRestProcessorTest.java 2009-07-22
17:32:10 UTC (rev 1124)
+++
branches/eclipse/dna-web-jcr-rest-client/src/test/java/org/jboss/dna/web/jcr/rest/client/json/JsonRestProcessorTest.java 2009-07-22
22:41:00 UTC (rev 1125)
@@ -1,53 +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.json;
-
-import org.junit.Before;
-
-/**
- * @author Dan Florian
- * @since 0.6
- */
-public final class JsonRestProcessorTest {
-
- //
===========================================================================================================================
- // Fields
- //
===========================================================================================================================
-
-// private IRestExecutor processor;
-
- //
===========================================================================================================================
- // Methods
- //
===========================================================================================================================
-
- @Before
- public void beforeEach() {
- // this.processor = new JsonRestProcessor();
- }
-
- //
===========================================================================================================================
- // Tests
- //
===========================================================================================================================
-
-}
Modified: branches/eclipse/dna-web-jcr-rest-client/src/test/resources/log4j.properties
===================================================================
---
branches/eclipse/dna-web-jcr-rest-client/src/test/resources/log4j.properties 2009-07-22
17:32:10 UTC (rev 1124)
+++
branches/eclipse/dna-web-jcr-rest-client/src/test/resources/log4j.properties 2009-07-22
22:41:00 UTC (rev 1125)
@@ -17,12 +17,4 @@
log4j.appender.testlog-mdc.layout.ConversionPattern=%d{ABSOLUTE} %5p [%X{username}] %m%n
# Root logger option
-log4j.rootLogger=INFO, stdout, testlog, testlog-mdc
-
-# Set up the default logging to be INFO level, then override specific units
-log4j.logger.org.jboss.dna=INFO
-
-# Set up the logging for the LoggerTest test cases (which need this to be explicitly set
rather than inherited)
-log4j.logger.org.jboss.dna.common.util.LoggerTest=INFO
-
-
+log4j.rootLogger=TRACE, stdout, testlog, testlog-mdc
Added:
branches/eclipse/dna-web-jcr-rest-client/src/test/resources/myproject/myfolder/document.txt
===================================================================
---
branches/eclipse/dna-web-jcr-rest-client/src/test/resources/myproject/myfolder/document.txt
(rev 0)
+++
branches/eclipse/dna-web-jcr-rest-client/src/test/resources/myproject/myfolder/document.txt 2009-07-22
22:41:00 UTC (rev 1125)
@@ -0,0 +1,304 @@
+Wikipedia is sustained by people like you. Please donate today.
+Candidates are currently being accepted for the Wikimedia Board of Trustees Election.
Become a candidate.
+ [Hide]
+[Help us with translations!]
+Sledge Hammer!
+From Wikipedia, the free encyclopedia
+Jump to: navigation, search
+ This article does not cite any references or sources. Please help improve this
article by adding citations to reliable sources. Unsourced material may be challenged and
removed. (September 2007)
+ This article may contain original research or unverified claims. Please improve the
article by adding references. See the talk page for details. (September 2007)
+Sledge Hammer!
+
+Sledge Hammer! title screen from 1986 to 1988
+Format Comedy (sitcom)
+Created by Alan Spencer
+Starring David Rasche
+Anne-Marie Martin
+Harrison Page
+Theme music composer Danny Elfman
+Country of origin United States
+No. of seasons 2
+No. of episodes 41
+Production
+Running time 23 minutes (approximate)
+Broadcast
+Original channel ABC
+Original run 23 September 1986 –
+12 February 1988
+External links
+Official website
+
+Sledge Hammer! is a satirical police sitcom produced by New World Television that ran for
two seasons on ABC from 1986 to 1988. The series was created by Alan Spencer and starred
David Rasche as Inspector Sledge Hammer, a preposterous caricature of the standard
"cop on the edge" character, with a name parodied from Mike Hammer.
+Contents
+[hide]
+
+ * 1 Origins
+ * 2 Premise and characters
+ * 3 Sledge humor
+ * 4 Intro and theme music
+ * 5 Ratings and second season
+ * 6 DVD releases
+ * 7 Guest appearances
+ * 8 Episode list
+ o 8.1 Season 1 (1986–1987)
+ o 8.2 Season 2 (1987–1988)
+ * 9 Trivia
+ * 10 External links
+
+[edit] Origins
+
+Inspired by Clint Eastwood's no-nonsense approach to law enforcement in the Dirty
Harry films, teenager Alan Spencer dreamed up the idea of a police officer whose approach
was even more over-the-top, to the point of comical absurdity. At the age of sixteen,
Spencer wrote a screenplay based on this idea. The script and the main character were both
named "Sledge Hammer".
+
+Spencer, who at his young age had already written for various standup comedians such as
Rodney Dangerfield and television shows such as The Facts of Life and One Day at a Time,
was unable to sell the script until the mid-1980s, when the release of the fourth Dirty
Harry movie Sudden Impact and the popularity of NBC's Dirty Harry-inspired action
series Hunter created demand for a satirical police television show. When HBO approached
Leonard B. Stern, former producer of Get Smart, about developing such a show, Stern
recommended Spencer's "Sledge Hammer!" idea.
+
+Spencer quickly reworked his script for a half-hour television format. HBO executives did
not like it, however, and suggested changes that Spencer found unacceptable, such as
casting Dangerfield or Joe Piscopo in the lead role. Surprisingly, last-place ABC was
willing to take a chance on the unorthodox script. ABC insisted that the violence be toned
down for network television and that a laugh track be included (although it should be
noted that some versions, such as that shown by ITV regions in the United Kingdom, do not
have this track), but agreed to cast Spencer's first choice for the lead character,
the classically trained actor David Rasche. Sledge Hammer! entered ABC's fall lineup
in 1986.
+
+Fortuitously, the pilot of Sledge Hammer! was completed just as Peter Gabriel's song
"Sledgehammer" became a huge hit. ABC took advantage of this pleasant
coincidence by using Gabriel's popular tune in television, radio and film
advertisements for the show.
+
+[edit] Premise and characters
+
+Inspector Sledge Hammer of the San Francisco Police Department is a violent, sadistic,
insensitive, yet oddly likable detective. His best friend is a .44 Magnum with a
customized grip featuring a drawing of a sledgehammer. Hammer sleeps and showers with his
gun, and even talks to it. Hammer believes in shooting first and asking questions never.
In the pilot episode, he deals with a sniper on a roof by blowing up the entire building
with a rocket launcher, then turns to the uniformed cops on scene and says "I think I
got 'em"; he also mentions that his favorite charity is "Toy Guns for
Tots". Hammer's father was Jack Hammer, a legendary carnival trick shooter whose
repertoire of shooting tricks included catching a bullet in his teeth, which saved his
son's life in one episode. His mothers name was Armin Hammer.
+
+While purportedly a stickler for law and order, Hammer is rather lax when it comes to
following police regulations. He enjoys roughing up suspected criminals, whom he
frequently refers to as "brain-dead mutants", "yogurt-sucking creeps",
and the like. He is often suspended from duty, and his police file literally requires a
wheelbarrow to transport.
+
+
+Hammer drives a beat-up, bullet-riddled, lime green Dodge St. Regis with an "I ♥
VIOLENCE" bumper sticker. He prefers to wear cheap sports jackets, loud neckties, and
dark sunglasses. He is divorced, and frequently makes jokes at the expense of his ex-wife
(who makes an appearance in the final episode, played by Rasche's real-life wife,
Heather Lupton).
+
+Despite his irresponsibility and utter incompetence, Hammer always ends up getting his
man (or woman), often through sheer luck or brute force. Hammer's unintentionally
ironic motto is "Trust me. I know what I'm doing." (Disaster usually
follows.) Another expression he often utters is "Don't confuse me",
typically in response to any remark that challenges his ridiculously one-dimensional
worldview.
+
+Hammer's partner is the beautiful Detective Dori Doreau (played by Anne-Marie
Martin), who is competent, kind, sensitive, intelligent, and sophisticated—everything
Sledge is not. Doreau is often shocked and offended by Hammer's crass behavior and
obnoxious attitude, but she appears to see some redeeming qualities beneath his gruff
exterior. (Indeed, it becomes apparent with time that she has some romantic feelings for
Sledge.) Hammer's blatant male chauvinism is a running gag in his dialogues with
Doreau:
+
+ Doreau: What, you think all women should be barefoot and pregnant?
+ Hammer: No, I encourage women to wear shoes.
+
+Doreau's cautious and compassionate approach to law enforcement is a crucial
counterpoint to Hammer's reckless and nihilistic quest for justice. Yet Doreau is a
tough, agile cop who can handle a gun and deliver a well-timed karate kick when necessary.
She frequently saves Hammer from the extraordinary predicaments he invariably gets himself
into.
+
+Hammer and Doreau are supervised by the chronically uptight, Pepto-Bismol-guzzling
Captain Trunk, played by Harrison Page. Trunk spends most of his time yelling at Hammer
for his incompetence or complaining about his migraine headaches brought on by
Hammer's antics. If Trunk has any respect or fondness for Hammer, he hides it
extremely well. In one episode ("Miss of the Spider Woman") Hammer is about to
die from snake venom poisoning but is saved at the last minute when Trunk shows up with
the antidote:
+
+ Hammer: How can I ever thank you?
+ Trunk: Don't drink it.
+
+[edit] Sledge humor
+
+Most of the humor in Sledge Hammer! is based on Sledge's callous, simplistic,
narrow-minded worldview and its unfortunate consequences for those around him. Hammer is
like a human tornado, devastating everyone and everything in his path. A camera view of
his apartment shows that one of his favorite wall hangings is a "enemy soldier"
target on his closet door. He blames gun control, feminism, and rock music for many of the
world's ills. One example of such humor:
+
+ Sledge Hammer: Well, Miss, I was in this store when two thugs entered and threatened
the owner with shotguns. At that time I drew my magnum and killed them both. Then I bought
some eggs, milk, and some of those little cocktail weenies.
+ News reporter: Inspector Hammer, was what you did in the store absolutely necessary?
+ Sledge Hammer: Oh yes, I had almost no groceries at all.
+
+Hammer's over-the-top but deadpan antics have ranged from pulling a rocket launcher
from his trunk and firing it at the building where a sniper is stationed, to forcing a
purse-snatcher to beat himself up in order to avoid brutality charges.
+
+Physical comedy is another important element of the show. Through his Jack Tripper-like
clumsiness, Sledge is constantly injuring Captain Trunk with, for example, a stray
billiard ball to the head, a coffin lid dropped on the fingers, or a misguided attempt at
fixing Trunk's sore neck with a little amateur chiropractic adjustment:
+
+ Trunk: (yelling in pain) You sadistic, depraved, bloodthirsty, barbaric...
+ Hammer: Is that why you called me in here? To shower me with compliments?
+
+Another running gag is Sledge's reckless driving; he is continually rear-ending and
backing into things with his beat-up green jalopy.
+
+Sledge Hammer! also features a good deal of self-referential and topical, pop
culture-based humor. For example, in the final episode of the first season, Captain Trunk
tells a busted criminal "Your show's been canceled!"; Sledge replies,
"You talking to me?", an obvious reference to the show's shaky prospects for
a second season. In another episode, Hammer tells a suspect "Every breath you take,
every move you make, I'll be watching you. That's police talk!", alluding to
the 1983 hit song by The Police.
+
+There are numerous references - nearly all of them disparaging - to other popular
television shows of the time, such as ALF, The Cosby Show, Miami Vice, Matlock, Webster,
Moonlighting, Designing Women, Dallas, and Murder, She Wrote. (Particular scorn is
reserved for Mr. Belvedere.)
+
+The show lampoons popular films of the '80s such as RoboCop, Witness, Flashdance, and
Crocodile Dundee, but also alludes to classics such as Casablanca, Cool Hand Luke, Dog Day
Afternoon, and A Clockwork Orange.
+
+[edit] Intro and theme music
+
+The introduction to the show features long, near-sensual closeup shots of Sledge's
.44 Magnum as it rests on a luxurious satin pillow. The show's ominous theme music,
composed by Danny Elfman, plays in the background. Sledge then picks up his gun, spins it
expertly like an Old West gunslinger, and utters his catch phrase ("Trust me, I know
what I'm doing") just before firing into the screen, making a hole in it. The
original version had Sledge firing directly at the viewer, but ABC executives feared this
could be too shocking, possibly even causing heart attacks (and leaving the network
liable)[citation needed]. Thus, Sledge fires into the screen at a slight angle.
+
+[edit] Ratings and second season
+
+Despite critical acclaim, Sledge Hammer! struggled in the ratings. This was due in large
part to its being scheduled in the Friday 9 p.m. timeslot (popularly known as the Friday
night death slot), against CBS's Dallas and NBC's Miami Vice, two of the most
popular shows on television at the time; in one episode, Hammer remarks that it must be
bad to be between a man from Dallas and a man from Miami, an obvious reference to both
shows. In his commentary on the first season DVDs, Alan Spencer remarks that the only
series getting lower ratings than Sledge Hammer! was FOX's The Tracey Ullman Show.
That actually applied to the second season.
+
+In truth, Sledge Hammer! attracted weekly viewership of nineteen million viewers who
followed the show religiously through its many time slot shifts. The fact that the series
appealed to key target demographics also kept it on the schedule. Hammer! would invariably
improve on any time slot the network placed it into.
+
+Because ABC intended to cancel the series, the last episode of the first season ends with
Hammer accidentally destroying the city when he attempts to disarm a stolen nuclear
warhead; just before the explosion Hammer remarks on his infamous phrase "Trust
Me....." . The last scene shows the "Beneath the Planet of the Apes"-style
ruins of the city with Trunk's voice screaming "HAMMMMMMMER!", and a graphic
flashed:
+
+"To Be Continued... Next Season?"
+
+However, this episode got much better than expected ratings, in large part because the
network had moved the show to a better time slot. ABC changed its mind and renewed the
show for a second season.
+
+The first episode of the second season perfunctorily explained that it and following
episodes were set "five years before" the explosion. Bill Bixby (of Incredible
Hulk fame) was brought in to direct numerous episodes. Doreau is Sledge's partner in
the second season, a glaring (and unexplained) inconsistency, as the two are portrayed as
meeting for the first time in the pilot episode, which supposedly takes place years later
(though, it is possible that the explosion takes place five years after the first season
and the second season picks up where the show left off). This is more than likely a spoof
of cop-out endings to season-ending cliffhangers (a notorious example is Dallas's
season opener, where the previous season was revealed to be a dream). In the final moments
of the final episode, Sledge asks Dori to marry him, but then claims he was only kidding.
The viewer is left to imagine what happens next.
+
+The second season suffered from another extremely undesirable time slot (this time
against The Cosby Show), a reduced budget, and lowered filming standard (down to 16 mm
film from the previous season's 35 mm). It was not renewed for a third season.
+
+[edit] DVD releases
+
+Anchor Bay Entertainment has released the entire series on DVD in Region 1. The first
season of Sledge Hammer! was released on DVD on July 27, 2004. The laugh track, which the
network had insisted on including on the pilot and first 12 episodes, is removed on the
DVD version, for which Spencer hired an experienced sound designer. The DVD also includes
an unaired version of the pilot that runs several minutes longer and has a different
ending and different theme music. An earthquake hit while Alan Spencer was recording
commentary for one of the DVDs; the tape kept rolling during the event and was included on
the DVD, leaving viewers wondering whether the earthquake was real. The second season was
released on DVD on April 12, 2005; the commentary on the final episode ended with Spencer,
again, being caught in another earthquake, this time with sound effects and a convenient
cliffhanger.
+DVD Name Ep # Release Date
+Season 1 22 July 27, 2004
+Season 2 19 April 12, 2005
+
+[edit] Guest appearances
+
+Some notable figures who made guest appearances on Sledge Hammer!:
+
+ * Adam Ant ("Icebreaker")
+ * Lewis Arquette ("Witless")
+ * Bill Bixby ("Hammer Hits the Rock") - Bixby also directed a number of
episodes
+ * Bud Cort ("Last of the Red Hot Vampires")
+ * Bill Dana ("Haven't Gun, Will Travel")
+ * John Densmore ("State of Sledge")
+ * Norman Fell ("They Call Me Mr. Trunk")
+ * Conchata Ferrell ("Jagged Sledge")
+ * Dennis Fimple ("They Shoot Hammers, Don't They?")
+ * Sid Haig ("Hammeroid")
+ * Evan Handratthy ("Brother Can You Spare a Crime")
+ * Mark Holton ("The Secret of My Excess")
+ * Clint Howard ("State of Sledge")
+ * Brion James ("If I Had a Little Hammer" and "Model Dearest")
+ * Davy Jones ("Sledge, Rattle & Roll")
+
+
+
+ * Bernie Kopell ("Last of the Red Hot Vampires")
+ * Dan Lauria ("A Clockwork Hammer")
+ * Robin Leach ("The Spa Who Loved Me")
+ * David Leisure ("Hammer Hits the Rock" & "Magnum Farce")
+ * Peter Marshall ("To Live and Die on TV")
+ * Richard Moll ("Hammeroid")
+ * Ronnie Schell ("Hammer Gets Nailed")
+ * Armin Shimerman ("Hammeroid")
+ * Show creator Alan Spencer's hands steal the newspapers in "Under the
Gun"
+ * Don Stark ("Under the Gun" and "Sledgepoo")
+ * Brenda Strong ("Miss of the Spider Woman")
+ * John Vernon ("Under the Gun" - parodying his role in the first Dirty
Harry film)
+ * Ray Walston ("Big Nazi on Campus")
+ * Patrick Wayne ("Brother Can You Spare a Crime")
+ * Duane Whitaker ("Hammer Gets Nailed")
+ * Mary Woronov ("The Spa Who Loved Me")
+
+[edit] Episode list
+
+One episode ("Wild About Hammer") ended with an epilogue that was intentionally
miscolored as a parody of the then-popular colorization trend; ABC received so many
complaints from viewers thinking it was a transmission error that for a time callers to
ABC's switchboard heard a recorded message explaining that it was all a joke.
+
+[edit] Season 1 (1986–1987)
+Sledge Hammer! DVD cover.
+Number Title Original airdate
+1 Under the Gun (Pilot) September 23, 1986
+2 Hammer Gets Nailed September 26, 1986
+3 Witless October 3, 1986
+4 They Shoot Hammers, Don't They? October 17, 1986
+5 Dori Day Afternoon October 24, 1986
+6 To Sledge, with Love October 31, 1986
+7 All Shook Up November 6, 1986
+8 Over My Dead Bodyguard November 13, 1986
+9 Magnum Farce November 22, 1986
+10 If I Had a Little Hammer November 29, 1986
+11 To Live and Die on TV December 13, 1986
+12 Miss of the Spider Woman December 20, 1986
+13 The Old Man and the Sledge January 3, 1987
+14 State of Sledge January 10, 1987
+15 Haven't Gun, Will Travel January 17, 1987
+16 The Color of Hammer January 24, 1987
+17 Brother, Can You Spare a Crime? January 31, 1987
+18 Desperately Seeking Dori February 7, 1987
+19 Sledgepoo February 14, 1987
+20 Comrade Hammer February 21, 1987
+21 Jagged Sledge April 21, 1987
+22 The Spa Who Loved Me April 28, 1987
+
+[edit] Season 2 (1987–1988)
+Number Title Original airdate
+1 A Clockwork Hammer September 17, 1987
+2 Big Nazi on Campus September 24, 1987
+3 Play It Again, Sledge October 1, 1987
+4 Wild About Hammer October 8, 1987
+5 The Death of a Few Salesmen October 15, 1987
+6 Vertical October 29, 1987
+7 Dressed to Call November 5, 1987
+8 Hammer Hits the Rock (a.k.a. Sledge on the Rock) November 12, 1987
+9 Hammeroid November 26, 1987
+10 Last of the Red Hot Vampires November 19, 1987
+11 Sledge in Toyland December 3, 1987
+12 Icebreaker December 10, 1987
+13 They Call Me Mr. Trunk December 17, 1987
+14 Model Dearest January 7, 1988
+15 Sledge, Rattle & Roll January 15, 1988
+16 Suppose They Gave a War & Sledge Came? January 22, 1988
+17 The Secret of My Excess January 29, 1988
+18 It Happened What Night? February 5, 1988
+19 Here's to You, Mrs. Hammer February 12, 1988
+
+[edit] Trivia
+ Lists of miscellaneous information should be avoided. Please relocate any relevant
information into appropriate sections or articles. (June 2007)
+
+ * New World's then-subsidiary Marvel Comics released a short-lived comic book
based upon the series, only publishing two issues.
+ * Al Jean and Mike Reiss, best known for their work on The Simpsons, wrote for the
show and worked as story editors.
+ * The British rock band Jesus Jones sampled Sledge's famous catch phrase in their
song "Trust Me" on their 1991 album Doubt.
+ * The phrase "Hammer time!" was used by Sledge in the episode "State
of Sledge", a full three years before MC Hammer's "U Can't Touch
This" was released in January 1990.
+ * In a later episode, after Sledge's badge is taken, he notes that the next time
he shoots someone he could get arrested. Frank Drebin says the exact same thing in The
Naked Gun, released years later.
+ * David Rasche appeared as the President of the United States in the short-lived 2001
television series DAG. His secret service code-name on the series was Sledge Hammer.
+
+[edit] External links
+Search Wikiquote Wikiquote has a collection of quotations related to: Sledge Hammer!
+
+ * Sledge Hammer! Online - Alan Spencer's official site
+ * Sledge Hammer! at the Internet Movie Database
+ * Sledge Hammer! at
TV.com
+
+Retrieved from "http://en.wikipedia.org/wiki/Sledge_Hammer!"
+Categories: 1980s American television series | 1986 television series debuts | 1988
television series endings | American Broadcasting Company network shows | Crime television
series | American television sitcoms | Television shows set in San Francisco
+Hidden categories: Articles lacking sources from September 2007 | All articles lacking
sources | Articles that may contain original research from September 2007 | All articles
that may contain original research | All articles with unsourced statements | Articles
with unsourced statements from July 2009 | Articles with trivia sections from June 2007
+Views
+
+ * Article
+ * Discussion
+ * Edit this page
+ * History
+
+Personal tools
+
+ * Log in / create account
+
+Navigation
+
+ * Main page
+ * Contents
+ * Featured content
+ * Current events
+ * Random article
+
+Search
+
+Interaction
+
+ * About Wikipedia
+ * Community portal
+ * Recent changes
+ * Contact Wikipedia
+ * Donate to Wikipedia
+ * Help
+
+Toolbox
+
+ * What links here
+ * Related changes
+ * Upload file
+ * Special pages
+ * Printable version
+ * Permanent link
+ * Cite this page
+
+Languages
+
+ * Deutsch
+ * Español
+ * Français
+ * Bahasa Indonesia
+ * Italiano
+ * Nederlands
+ * Português
+ * Русский
+ * Suomi
+ * 中文
+
+Powered by MediaWiki
+Wikimedia Foundation
+
+ * This page was last modified on 7 July 2009 at 14:58.
+ * Text is available under the Creative Commons Attribution/Share-Alike License;
additional terms may apply. See Terms of Use for details.
+ Wikipedia® is a registered trademark of the Wikimedia Foundation, Inc., a
non-profit organization.
+ * Privacy policy
+ * About Wikipedia
+ * Disclaimers
+
Property changes on:
branches/eclipse/dna-web-jcr-rest-client/src/test/resources/myproject/myfolder/document.txt
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
branches/eclipse/dna-web-jcr-rest-client/src/test/resources/myproject/myfolder/picture.jpg
===================================================================
(Binary files differ)
Property changes on:
branches/eclipse/dna-web-jcr-rest-client/src/test/resources/myproject/myfolder/picture.jpg
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream