DNA SVN: r1207 - trunk/extensions/dna-connector-store-jpa/src/main/java/org/jboss/dna/connector/store/jpa/model/common.
by dna-commits@lists.jboss.org
Author: rhauch
Date: 2009-09-11 15:05:52 -0400 (Fri, 11 Sep 2009)
New Revision: 1207
Modified:
trunk/extensions/dna-connector-store-jpa/src/main/java/org/jboss/dna/connector/store/jpa/model/common/NamespaceEntity.java
Log:
DNA-515 PA connector reports error when inserting default (and blank) namespace URI into Oracle database
Although the previous change did address the possibility that Oracle will return null, it did not yet change the Hibernate annotations to allow for a null URI value. This change does this.
Modified: trunk/extensions/dna-connector-store-jpa/src/main/java/org/jboss/dna/connector/store/jpa/model/common/NamespaceEntity.java
===================================================================
--- trunk/extensions/dna-connector-store-jpa/src/main/java/org/jboss/dna/connector/store/jpa/model/common/NamespaceEntity.java 2009-09-11 18:57:56 UTC (rev 1206)
+++ trunk/extensions/dna-connector-store-jpa/src/main/java/org/jboss/dna/connector/store/jpa/model/common/NamespaceEntity.java 2009-09-11 19:05:52 UTC (rev 1207)
@@ -54,7 +54,7 @@
@GeneratedValue( strategy = GenerationType.AUTO )
private Long id;
- @Column( name = "URI", nullable = false, unique = false, length = 512, updatable = false )
+ @Column( name = "URI", nullable = true, unique = false, length = 512, updatable = false )
private String uri;
/**
14 years, 8 months
DNA SVN: r1206 - trunk/extensions/dna-connector-store-jpa/src/main/java/org/jboss/dna/connector/store/jpa/util.
by dna-commits@lists.jboss.org
Author: rhauch
Date: 2009-09-11 14:57:56 -0400 (Fri, 11 Sep 2009)
New Revision: 1206
Modified:
trunk/extensions/dna-connector-store-jpa/src/main/java/org/jboss/dna/connector/store/jpa/util/StoreOptionEntity.java
Log:
DNA-520 DNA w/ JPA/Oracle - bad create table DNA_OPTIONS
The unique=true parameter is actually unnecessary since the column is already a primary key since it is annotated with @Id. I guess the Oracle is just pretty strict about this. Removing the parameter didn't seem to cause any other problems.
Modified: trunk/extensions/dna-connector-store-jpa/src/main/java/org/jboss/dna/connector/store/jpa/util/StoreOptionEntity.java
===================================================================
--- trunk/extensions/dna-connector-store-jpa/src/main/java/org/jboss/dna/connector/store/jpa/util/StoreOptionEntity.java 2009-09-10 21:38:13 UTC (rev 1205)
+++ trunk/extensions/dna-connector-store-jpa/src/main/java/org/jboss/dna/connector/store/jpa/util/StoreOptionEntity.java 2009-09-11 18:57:56 UTC (rev 1206)
@@ -47,10 +47,10 @@
public class StoreOptionEntity {
@Id
- @Column( name = "NAME", nullable = false, unique = true, length = 512 )
+ @Column( name = "NAME", nullable = false, length = 512 )
private String name;
- @Column( name = "VALUE", nullable = false, unique = false, length = 512 )
+ @Column( name = "VALUE", nullable = false, length = 512 )
private String value;
/**
14 years, 8 months
DNA SVN: r1205 - in branches/eclipse/dna-web-jcr-rest-client/src: main/java/org/jboss/dna/web/jcr/rest/client/domain and 5 other directories.
by dna-commits@lists.jboss.org
Author: elvisisking
Date: 2009-09-10 17:38:13 -0400 (Thu, 10 Sep 2009)
New Revision: 1205
Modified:
branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/IJcrConstants.java
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/IServerRegistryListener.java
branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/RestClientI18n.java
branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/ServerAuthenticator.java
branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/ServerManager.java
branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/ServerRegistryEvent.java
branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/Status.java
branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/Utils.java
branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/domain/IDnaObject.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/JsonRestClient.java
branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/json/JsonUtils.java
branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/json/RepositoryNode.java
branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/json/ServerNode.java
branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/json/WorkspaceNode.java
branches/eclipse/dna-web-jcr-rest-client/src/test/java/org/jboss/dna/web/jcr/rest/client/MockRestClient.java
branches/eclipse/dna-web-jcr-rest-client/src/test/java/org/jboss/dna/web/jcr/rest/client/RestClientI18nTest.java
branches/eclipse/dna-web-jcr-rest-client/src/test/java/org/jboss/dna/web/jcr/rest/client/ServerManagerTest.java
branches/eclipse/dna-web-jcr-rest-client/src/test/java/org/jboss/dna/web/jcr/rest/client/StatusTest.java
branches/eclipse/dna-web-jcr-rest-client/src/test/java/org/jboss/dna/web/jcr/rest/client/domain/RepositoryTest.java
branches/eclipse/dna-web-jcr-rest-client/src/test/java/org/jboss/dna/web/jcr/rest/client/domain/ServerTest.java
branches/eclipse/dna-web-jcr-rest-client/src/test/java/org/jboss/dna/web/jcr/rest/client/domain/WorkspaceTest.java
branches/eclipse/dna-web-jcr-rest-client/src/test/java/org/jboss/dna/web/jcr/rest/client/json/JsonRestClientTest.java
Log:
Removed @since javadoc tags.
Modified: branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/IJcrConstants.java
===================================================================
--- branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/IJcrConstants.java 2009-09-10 21:16:23 UTC (rev 1204)
+++ branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/IJcrConstants.java 2009-09-10 21:38:13 UTC (rev 1205)
@@ -25,64 +25,46 @@
/**
* The <code>IJcrContants</code> class provides constants for the commonly used JCR types and property identifiers.
- *
- * @since 0.6
*/
public interface IJcrConstants {
/**
* The JCR content property name (<code>jcr:content</code>).
- *
- * @since 0.6
*/
String CONTENT_PROPERTY = "jcr:content"; //$NON-NLS-1$
/**
* The JCR data property name (<code>jcr:data</code>).
- *
- * @since 0.6
*/
String DATA_PROPERTY = "jcr:data/base64/"; //$NON-NLS-1$
/**
* The JCR file node type (<code>nt:file</code>).
- *
- * @since 0.6
*/
String FILE_NODE_TYPE = "nt:file"; //$NON-NLS-1$
/**
* The JCR folder node type (<code>nt:folder</code>).
- *
- * @since 0.6
*/
String FOLDER_NODE_TYPE = "nt:folder"; //$NON-NLS-1$
/**
* The JCR data property name (<code>jcr:lastModified</code>).
- *
- * @since 0.6
*/
String LAST_MODIFIED = "jcr:lastModified"; //$NON-NLS-1$
/**
* The JCR data property name (<code>jcr:lastModified</code>).
- *
- * @since 0.6
*/
String MIME_TYPE = "jcr:mimeType"; //$NON-NLS-1$
/**
* The JCR primary type property name (<code>jcr:primaryType</code>).
- *
- * @since 0.6
*/
String PRIMARY_TYPE_PROPERTY = "jcr:primaryType"; //$NON-NLS-1$
/**
* The JCR resource node type (<code>nt:resource</code>).
- *
- * @since 0.6
*/
String RESOURCE_NODE_TYPE = "nt:resource"; //$NON-NLS-1$
Modified: branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/IRestClient.java
===================================================================
--- branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/IRestClient.java 2009-09-10 21:16:23 UTC (rev 1204)
+++ branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/IRestClient.java 2009-09-10 21:38:13 UTC (rev 1205)
@@ -33,8 +33,6 @@
/**
* The <code>IRestClient</code> interface is the API for all REST clients used by the Eclipse DNA plugin.
- *
- * @since 0.6
*/
public interface IRestClient {
@@ -44,7 +42,6 @@
* @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
*/
Collection<Repository> getRepositories( Server server ) throws Exception;
@@ -54,7 +51,6 @@
* @param workspace the workspace where the file is/could be located (never <code>null</code>)
* @return the workspace URL for the specified file (never <code>null</code>)
* @throws Exception if there is a problem obtaining the URL or if the file is a directory
- * @since 0.6
*/
URL getUrl( File file,
String path,
@@ -66,7 +62,6 @@
* @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
*/
Collection<Workspace> getWorkspaces( Repository repository ) throws Exception;
@@ -77,7 +72,6 @@
* @param path the unencoded path to the folder where the file will be published (never <code>null</code>)
* @param file the resource being published (never <code>null</code>)
* @return a status of the publishing operation outcome (never <code>null</code>)
- * @since 0.6
*/
Status publish( Workspace workspace,
String path,
@@ -91,7 +85,6 @@
* @param path the unencoded path to the folder where the file is published (never <code>null</code>)
* @param file the file being unpublished (never <code>null</code>)
* @return a status of the unpublishing operation outcome (never <code>null</code>)
- * @since 0.6
*/
Status unpublish( Workspace workspace,
String path,
Modified: branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/IServerRegistryListener.java
===================================================================
--- branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/IServerRegistryListener.java 2009-09-10 21:16:23 UTC (rev 1204)
+++ branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/IServerRegistryListener.java 2009-09-10 21:38:13 UTC (rev 1205)
@@ -25,15 +25,12 @@
/**
* The <code>IServerRegistryListener</code> interface defines the API for a server registry listener.
- *
- * @since 0.6
*/
public interface IServerRegistryListener {
/**
* @param event the event being processed (never <code>null</code>)
* @return any errors caught during the processing or <code>null</code>
- * @since 0.6
*/
Exception[] serverRegistryChanged( ServerRegistryEvent event );
Modified: branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/RestClientI18n.java
===================================================================
--- branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/RestClientI18n.java 2009-09-10 21:16:23 UTC (rev 1204)
+++ branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/RestClientI18n.java 2009-09-10 21:38:13 UTC (rev 1205)
@@ -27,8 +27,6 @@
/**
* The <code>RestClientI18n</code> class provides localized messages.
- *
- * @since 0.6
*/
public final class RestClientI18n {
Modified: branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/ServerAuthenticator.java
===================================================================
--- branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/ServerAuthenticator.java 2009-09-10 21:16:23 UTC (rev 1204)
+++ branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/ServerAuthenticator.java 2009-09-10 21:38:13 UTC (rev 1205)
@@ -29,8 +29,6 @@
/**
* The <code>ServerAuthenticator</code> class provides user names and passwords to the HTTP connection.
- *
- * @since 0.6
*/
public class ServerAuthenticator extends Authenticator {
@@ -42,7 +40,6 @@
* {@inheritDoc}
*
* @see java.net.Authenticator#getPasswordAuthentication()
- * @since 0.6
*/
@Override
protected PasswordAuthentication getPasswordAuthentication() {
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-09-10 21:16:23 UTC (rev 1204)
+++ branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/ServerManager.java 2009-09-10 21:38:13 UTC (rev 1205)
@@ -59,8 +59,6 @@
/**
* The <code>ServerManager</code> class managers the creation, deletion, and editing of servers hosting DNA repositories.
- *
- * @since 0.6
*/
@ThreadSafe
public final class ServerManager implements IRestClient {
@@ -71,43 +69,31 @@
/**
* The tag used to persist a server's login password.
- *
- * @since 0.6
*/
private static final String PASSWORD_TAG = "password"; //$NON-NLS-1$
/**
* The file name used when persisting the server registry.
- *
- * @since 0.6
*/
private static final String REGISTRY_FILE = "serverRegistry.xml"; //$NON-NLS-1$
/**
* The tag used when persisting a server.
- *
- * @since 0.6
*/
private static final String SERVER_TAG = "server"; //$NON-NLS-1$
/**
* The server collection tag used when persisting the server registry.
- *
- * @since 0.6
*/
private static final String SERVERS_TAG = "servers"; //$NON-NLS-1$
/**
* The tag used to persist a server's URL.
- *
- * @since 0.6
*/
private static final String URL_TAG = "url"; //$NON-NLS-1$
/**
* The tag used to persist a server's login user.
- *
- * @since 0.6
*/
private static final String USER_TAG = "user"; //$NON-NLS-1$
@@ -120,7 +106,6 @@
* getWorkspaces() operations. Setting a thread variable was a way to do that.
*
* @see ServerAuthenticator
- * @since 0.6
*/
private static ThreadLocal<Server> currentServer = new ThreadLocal<Server>();
@@ -130,7 +115,6 @@
/**
* @return the server set on the current thread or <code>null</code>
- * @since 0.6
*/
public static Server getCurrentServer() {
return ServerManager.currentServer.get();
@@ -142,44 +126,32 @@
/**
* The listeners registered to receive {@link ServerRegistryEvent server registry events}.
- *
- * @since 0.6
*/
private final CopyOnWriteArrayList<IServerRegistryListener> listeners;
/**
* Executes the commands run on the DNA REST server.
- *
- * @since 0.6
*/
private final IRestClient delegate;
/**
* The logger.
- *
- * @since 0.6
*/
private final Logger logger = Logger.getLogger(ServerManager.class);
/**
* The path where the server registry is persisted or <code>null</code> if not persisted.
- *
- * @since 0.6
*/
private final String stateLocationPath;
/**
* The server registry.
- *
- * @since 0.6
*/
@GuardedBy( "serverLock" )
private final List<Server> servers;
/**
* Lock used for when accessing the server registry.
- *
- * @since 0.6
*/
private final ReadWriteLock serverLock = new ReentrantReadWriteLock();
@@ -191,7 +163,6 @@
* @param stateLocationPath the directory where the {@link Server} registry} is persisted (may be <code>null</code> if
* persistence is not desired)
* @param restClient the client that will communicate with the DNA REST server (never <code>null</code>)
- * @since 0.6
*/
public ServerManager( String stateLocationPath,
IRestClient restClient ) {
@@ -211,7 +182,6 @@
*
* @param stateLocationPath the directory where the {@link Server} registry} is persisted (may be <code>null</code> if
* persistence is not desired)
- * @since 0.6
*/
public ServerManager( String stateLocationPath ) {
this(stateLocationPath, new JsonRestClient());
@@ -226,7 +196,6 @@
*
* @param listener the listener being register to receive events (never <code>null</code>)
* @return <code>true</code> if listener was added
- * @since 0.6
*/
public boolean addRegistryListener( IServerRegistryListener listener ) {
CheckArg.isNotNull(listener, "listener"); //$NON-NLS-1$
@@ -245,7 +214,6 @@
*
* @param server the server being added (never <code>null</code>)
* @return a status indicating if the server was added to the registry
- * @since 0.6
*/
public Status addServer( Server server ) {
CheckArg.isNotNull(server, "server"); //$NON-NLS-1$
@@ -273,7 +241,6 @@
/**
* @return an unmodifiable collection of registered servers (never <code>null</code>)
- * @since 0.6
*/
public Collection<Server> getServers() {
try {
@@ -286,7 +253,6 @@
/**
* @return the name of the state file that the server registry is persisted to or <code>null</code>
- * @since 0.6
*/
private String getStateFileName() {
String name = this.stateLocationPath;
@@ -304,7 +270,6 @@
* @see org.jboss.dna.web.jcr.rest.client.IRestClient#getRepositories(org.jboss.dna.web.jcr.rest.client.domain.Server)
* @throws RuntimeException if the server is not registered
* @see #isRegistered(Server)
- * @since 0.6
*/
public Collection<Repository> getRepositories( Server server ) throws Exception {
CheckArg.isNotNull(server, "server"); //$NON-NLS-1$
@@ -330,7 +295,6 @@
*
* @see org.jboss.dna.web.jcr.rest.client.IRestClient#getUrl(java.io.File, java.lang.String,
* org.jboss.dna.web.jcr.rest.client.domain.Workspace)
- * @since 0.6
*/
public URL getUrl( File file,
String path,
@@ -344,7 +308,6 @@
* @see org.jboss.dna.web.jcr.rest.client.IRestClient#getWorkspaces(org.jboss.dna.web.jcr.rest.client.domain.Repository)
* @throws RuntimeException if the server is not registered
* @see #isRegistered(Server)
- * @since 0.6
*/
public Collection<Workspace> getWorkspaces( Repository repository ) throws Exception {
CheckArg.isNotNull(repository, "repository"); //$NON-NLS-1$
@@ -372,7 +335,6 @@
* @param server the server being added
* @param notifyListeners indicates if registry listeners should be notified
* @return a status indicating if the server was added to the registry
- * @since 0.6
*/
private Status internalAddServer( Server server,
boolean notifyListeners ) {
@@ -405,7 +367,6 @@
* @param server the server being removed
* @param notifyListeners indicates if registry listeners should be notified
* @return a status indicating if the specified server was removed from the registry
- * @since 0.6
*/
private Status internalRemoveServer( Server server,
boolean notifyListeners ) {
@@ -443,7 +404,6 @@
* @param server the server being tested (never <code>null</code>)
* @return <code>true</code> if the server has been registered
* @see #addServer(Server)
- * @since 0.6
*/
public boolean isRegistered( Server server ) {
CheckArg.isNotNull(server, "server"); //$NON-NLS-1$
@@ -467,7 +427,6 @@
/**
* @param event the event the registry listeners are to process
* @return any errors thrown by or found by the listeners or <code>null</code> (never empty)
- * @since 0.6
*/
private Exception[] notifyRegistryListeners( ServerRegistryEvent event ) {
Collection<Exception> errors = null;
@@ -502,7 +461,6 @@
/**
* @param errors the errors reported by the registry listeners
* @return a status indicating if registry listeners reported any errors
- * @since 0.6
*/
private Status processRegistryListenerErrors( Exception[] errors ) {
if (errors == null) {
@@ -522,7 +480,6 @@
* @param server the server being pinged (never <code>null</code>)
* @return a status indicating if the server can be connected to
* @see #isRegistered(Server)
- * @since 0.6
*/
public Status ping( Server server ) {
CheckArg.isNotNull(server, "server"); //$NON-NLS-1$
@@ -544,7 +501,6 @@
* @see org.jboss.dna.web.jcr.rest.client.IRestClient#publish(org.jboss.dna.web.jcr.rest.client.domain.Workspace,
* java.lang.String, java.io.File)
* @see #isRegistered(Server)
- * @since 0.6
*/
public Status publish( Workspace workspace,
String path,
@@ -567,7 +523,6 @@
/**
* @param listener the listener being unregistered and will no longer receive events (never <code>null</code>)
* @return <code>true</code> if listener was removed
- * @since 0.6
*/
public boolean removeRegistryListener( IServerRegistryListener listener ) {
CheckArg.isNotNull(listener, "listener"); //$NON-NLS-1$
@@ -577,7 +532,6 @@
/**
* @param server the server being removed (never <code>null</code>)
* @return a status indicating if the specified server was removed from the registry (never <code>null</code>)
- * @since 0.6
*/
public Status removeServer( Server server ) {
CheckArg.isNotNull(server, "server"); //$NON-NLS-1$
@@ -586,7 +540,6 @@
/**
* @return a status indicating if the previous session state was restored successfully
- * @since 0.6
*/
public Status restoreState() {
if (this.stateLocationPath != null) {
@@ -629,7 +582,6 @@
* Saves the {@link Server} registry to the file system.
*
* @return a status indicating if the registry was successfully saved
- * @since 0.6
*/
public Status saveState() {
if ((this.stateLocationPath != null) && !getServers().isEmpty()) {
@@ -678,7 +630,6 @@
/**
* @return <code>true</code> if the state file already exists
- * @since 0.6
*/
private boolean stateFileExists() {
return new File(getStateFileName()).exists();
@@ -692,7 +643,6 @@
* @see org.jboss.dna.web.jcr.rest.client.IRestClient#unpublish(org.jboss.dna.web.jcr.rest.client.domain.Workspace,
* java.lang.String, java.io.File)
* @see #isRegistered(Server)
- * @since 0.6
*/
public Status unpublish( Workspace workspace,
String path,
@@ -718,7 +668,6 @@
* @param previousServerVersion the version of the server being replaced (never <code>null</code>)
* @param newServerVersion the new version of the server being put in the server registry (never <code>null</code>)
* @return a status indicating if the server was updated in the registry (never <code>null</code>)
- * @since 0.6
*/
public Status updateServer( Server previousServerVersion,
Server newServerVersion ) {
Modified: branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/ServerRegistryEvent.java
===================================================================
--- branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/ServerRegistryEvent.java 2009-09-10 21:16:23 UTC (rev 1204)
+++ branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/ServerRegistryEvent.java 2009-09-10 21:38:13 UTC (rev 1205)
@@ -29,8 +29,6 @@
/**
* The <code>ServerRegistryEvent</code> class is the event that is broadcast from the {@link ServerManager server manager} when a
* server is added, removed, or changed.
- *
- * @since 0.6
*/
public final class ServerRegistryEvent {
@@ -40,28 +38,20 @@
/**
* The status severity levels.
- *
- * @since 0.6
*/
private enum Type {
/**
* Indicates that a new server was added to the server registry.
- *
- * @since 0.6
*/
NEW,
/**
* Indicates that a server was removed from the server registry.
- *
- * @since 0.6
*/
REMOVE,
/**
* Indicates that properties of an existing server in the registry has been changed.
- *
- * @since 0.6
*/
UPDATE
}
@@ -75,7 +65,6 @@
* @param newServer the server that was added to the server registry (never <code>null</code>)
* @return the event (never <code>null</code>)
* @see Type#NEW
- * @since 0.6
*/
public static ServerRegistryEvent createNewEvent( ServerManager serverManager,
Server newServer ) {
@@ -89,7 +78,6 @@
* @param removedServer the server removed from the server registry (never <code>null</code>)
* @return the event (never <code>null</code>)
* @see Type#REMOVE
- * @since 0.6
*/
public static ServerRegistryEvent createRemoveEvent( ServerManager serverManager,
Server removedServer ) {
@@ -104,7 +92,6 @@
* @param newServerVersion the updated version of the server (never <code>null</code>)
* @return the event (never <code>null</code>)
* @see Type#UPDATE
- * @since 0.6
*/
public static ServerRegistryEvent createUpdateEvent( ServerManager serverManager,
Server previousServerVersion,
@@ -124,29 +111,21 @@
/**
* The server being added, removed, or updated.
- *
- * @since 0.6
*/
private final Server server;
/**
* The server manager in charge of the server registry the event is associated with.
- *
- * @since 0.6
*/
private final ServerManager serverManager;
/**
* The event type.
- *
- * @since 0.6
*/
private final Type type;
/**
* The server that is replacing an existing server. Will be <code>null</code> for all types except {@link Type#UPDATE update}.
- *
- * @since 0.6
*/
private Server updatedServer;
@@ -158,7 +137,6 @@
* @param serverManager the server manager sourcing this event
* @param type the event type
* @param server the server being added, removed, or updated
- * @since 0.6
*/
private ServerRegistryEvent( ServerManager serverManager,
Type type,
@@ -174,7 +152,6 @@
/**
* @return the added, removed, or the old version of the server that has been updated
- * @since 0.6
*/
public Server getServer() {
return this.server;
@@ -182,7 +159,6 @@
/**
* @return the server manager sourcing this event
- * @since 0.6
*/
public ServerManager getServerManager() {
return this.serverManager;
@@ -192,7 +168,6 @@
* @return the new version of an existing server that has been updated
* @throws UnsupportedOperationException if method is called when the type is not an update
* @see Type#UPDATE
- * @since 0.6
*/
public Server getUpdatedServer() {
if (this.type != Type.UPDATE) {
@@ -205,7 +180,6 @@
/**
* @return <code>true</code> if the event is adding a new server to the registry
* @see Type#NEW
- * @since 0.6
*/
public boolean isNew() {
return (this.type == Type.NEW);
@@ -214,7 +188,6 @@
/**
* @return <code>true</code> if the event is removing a server from the registry
* @see Type#REMOVE
- * @since 0.6
*/
public boolean isRemove() {
return (this.type == Type.REMOVE);
@@ -223,7 +196,6 @@
/**
* @return <code>true</code> if the event is updating properties of an existing server in the registry
* @see Type#UPDATE
- * @since 0.6
*/
public boolean isUpdate() {
return (this.type == Type.UPDATE);
Modified: branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/Status.java
===================================================================
--- branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/Status.java 2009-09-10 21:16:23 UTC (rev 1204)
+++ branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/Status.java 2009-09-10 21:38:13 UTC (rev 1205)
@@ -27,8 +27,6 @@
/**
* The <code>Status</code> class is an outcome that provides an outcome or result of an operation.
- *
- * @since 0.6
*/
@Immutable
public final class Status {
@@ -39,42 +37,30 @@
/**
* The status severity levels.
- *
- * @since 0.6
*/
public enum Severity {
/**
* Indicates an error status.
- *
- * @since 0.6
*/
ERROR,
/**
* Indicates an informational status.
- *
- * @since 0.6
*/
INFO,
/**
* Indicates an OK status.
- *
- * @since 0.6
*/
OK,
/**
* Indicates an unknown status. This is automatically assigned if status is constructed with a <code>null</code> severity.
- *
- * @since 0.6
*/
UNKNOWN,
/**
* Indicates a warning status.
- *
- * @since 0.6
*/
WARNING
}
@@ -83,7 +69,6 @@
* A status with an OK severity and no message and no exception.
*
* @see Severity#OK
- * @since 0.6
*/
public static final Status OK_STATUS = new Status(Severity.OK, null, null);
@@ -93,22 +78,16 @@
/**
* The exception of this status or <code>null</code>.
- *
- * @since 0.6
*/
private final Throwable exception;
/**
* The localized message of this status (can be <code>null</code>).
- *
- * @since 0.6
*/
private final String message;
/**
* The severity level of this status (never <code>null</code>).
- *
- * @since 0.6
*/
private final Severity severity;
@@ -120,7 +99,6 @@
* @param severity the status severity (if <code>null</code> it will be converted to {@link Severity#UNKNOWN}.
* @param message the status message (if <code>null</code> it will be returned as an empty string)
* @param exception the status exception or <code>null</code>
- * @since 0.6
*/
public Status( Severity severity,
String message,
@@ -136,7 +114,6 @@
/**
* @return the status exception (may be <code>null</code>)
- * @since 0.6
*/
public Throwable getException() {
return this.exception;
@@ -144,7 +121,6 @@
/**
* @return the status message (never <code>null</code> but can be empty)
- * @since 0.6
*/
public String getMessage() {
return ((this.message == null) ? "" : this.message); //$NON-NLS-1$
@@ -152,7 +128,6 @@
/**
* @return severity the status severity (never <code>null</code>)
- * @since 0.6
*/
public Severity getSeverity() {
return this.severity;
@@ -160,7 +135,6 @@
/**
* @return <code>true</code> if the status has a severity of {@link Severity#ERROR error}.
- * @since 0.6
*/
public boolean isError() {
return (this.severity == Severity.ERROR);
@@ -168,7 +142,6 @@
/**
* @return <code>true</code> if the status has a severity of {@link Severity#INFO info}.
- * @since 0.6
*/
public boolean isInfo() {
return (this.severity == Severity.INFO);
@@ -176,7 +149,6 @@
/**
* @return <code>true</code> if the status has a severity of {@link Severity#OK OK}.
- * @since 0.6
*/
public boolean isOk() {
return (this.severity == Severity.OK);
@@ -184,7 +156,6 @@
/**
* @return <code>true</code> if the status has a severity of {@link Severity#UNKNOWN unknown}.
- * @since 0.6
*/
public boolean isUnknown() {
return (this.severity == Severity.UNKNOWN);
@@ -192,7 +163,6 @@
/**
* @return <code>true</code> if the status has a severity of {@link Severity#WARNING warning}.
- * @since 0.6
*/
public boolean isWarning() {
return (this.severity == Severity.WARNING);
@@ -202,7 +172,6 @@
* {@inheritDoc}
*
* @see java.lang.Object#toString()
- * @since 0.6
*/
@Override
public String toString() {
Modified: branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/Utils.java
===================================================================
--- branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/Utils.java 2009-09-10 21:16:23 UTC (rev 1204)
+++ branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/Utils.java 2009-09-10 21:38:13 UTC (rev 1205)
@@ -30,8 +30,6 @@
/**
* The <code>Utils</code> class contains common utilities used by this project.
- *
- * @since 0.6
*/
public final class Utils {
@@ -50,7 +48,6 @@
* @param thisObj an object being compared (may be <code>null</code>)
* @param thatObj the other object being compared (may be <code>null</code>)
* @return <code>true</code> if both objects are <code>null</code> or both are not <code>null</code> and equal
- * @since 0.6
*/
public static boolean equivalent( Object thisObj,
Object thatObj ) {
@@ -67,7 +64,6 @@
* @param file the file whose mime type is being requested
* @return the mime type or the default mime type (<code>"application/octet-stream"</code>) if one can't be determined from
* the file extension (never <code>null</code>)
- * @since 0.6
*/
public static String getMimeType( File file ) {
// TODO write test for getMimeType(File)
@@ -88,8 +84,6 @@
/**
* Don't allow construction.
- *
- * @since 0.6
*/
public Utils() {
// nothing to do
Modified: branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/domain/IDnaObject.java
===================================================================
--- branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/domain/IDnaObject.java 2009-09-10 21:16:23 UTC (rev 1204)
+++ branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/domain/IDnaObject.java 2009-09-10 21:38:13 UTC (rev 1205)
@@ -25,20 +25,16 @@
/**
* The <code>IDnaObject</code> class defines a DNA business object.
- *
- * @since 0.6
*/
public interface IDnaObject {
/**
* @return the object name (never <code>null</code>)
- * @since 0.6
*/
String getName();
/**
* @return a description suitable for use in a tooltip (never <code>null</code>)
- * @since 0.6
*/
String getShortDescription();
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-09-10 21:16:23 UTC (rev 1204)
+++ branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/domain/Repository.java 2009-09-10 21:38:13 UTC (rev 1205)
@@ -32,8 +32,6 @@
/**
* The Repository class is the business object for a DNA repository.
- *
- * @since 0.6
*/
@Immutable
public final class Repository implements IDnaObject {
@@ -44,15 +42,11 @@
/**
* The repository name.
- *
- * @since 0.6
*/
private final String name;
/**
* The server where this repository resides.
- *
- * @since 0.6
*/
private final Server server;
@@ -69,7 +63,6 @@
* @param server the server where this repository resides (never <code>null</code>)
* @see RepositoryValidator
* @throws RuntimeException if any of the input parameters are invalid
- * @since 0.6
*/
public Repository( String name,
Server server ) {
@@ -96,7 +89,6 @@
* {@inheritDoc}
*
* @see java.lang.Object#equals(java.lang.Object)
- * @since 0.6
*/
@Override
public boolean equals( Object obj ) {
@@ -112,7 +104,6 @@
* {@inheritDoc}
*
* @see org.jboss.dna.web.jcr.rest.client.domain.IDnaObject#getName()
- * @since 0.6
*/
public String getName() {
return this.name;
@@ -120,7 +111,6 @@
/**
* @return the server where this repository is located (never <code>null</code>)
- * @since 0.6
*/
public Server getServer() {
return this.server;
@@ -130,7 +120,6 @@
* {@inheritDoc}
*
* @see org.jboss.dna.web.jcr.rest.client.domain.IDnaObject#getShortDescription()
- * @since 0.6
*/
public String getShortDescription() {
return RestClientI18n.repositoryShortDescription.text(this.name, this.server.getName());
@@ -140,7 +129,6 @@
* {@inheritDoc}
*
* @see java.lang.Object#hashCode()
- * @since 0.6
*/
@Override
public int hashCode() {
@@ -151,7 +139,6 @@
* {@inheritDoc}
*
* @see java.lang.Object#toString()
- * @since 0.6
*/
@Override
public String toString() {
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-09-10 21:16:23 UTC (rev 1204)
+++ branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/domain/Server.java 2009-09-10 21:38:13 UTC (rev 1205)
@@ -34,8 +34,6 @@
/**
* The <code>Server</code> class is the business object for a server that is hosting one or more DNA repositories.
- *
- * @since 0.6
*/
@Immutable
public final class Server implements IDnaObject {
@@ -46,29 +44,21 @@
/**
* The password to use when logging on to the server.
- *
- * @since 0.6
*/
private final String password;
/**
* Indicates if the password should be stored locally when the server is persisted.
- *
- * @since 0.6
*/
private final boolean persistPassword;
/**
* The server URL.
- *
- * @since 0.6
*/
private final String url;
/**
* The user name to use when logging on to the server.
- *
- * @since 0.6
*/
private final String user;
@@ -85,7 +75,6 @@
* @param persistPassword <code>true</code> if the password should be stored
* @see RepositoryValidator
* @throws RuntimeException if any of the input parameters are invalid
- * @since 0.6
*/
public Server( String url,
String user,
@@ -115,7 +104,6 @@
* {@inheritDoc}
*
* @see java.lang.Object#equals(java.lang.Object)
- * @since 0.6
*/
@Override
public boolean equals( Object obj ) {
@@ -133,7 +121,6 @@
* {@inheritDoc}
*
* @see org.jboss.dna.web.jcr.rest.client.domain.IDnaObject#getName()
- * @since 0.6
*/
public String getName() {
return getUrl();
@@ -141,7 +128,6 @@
/**
* @return the server authentication password
- * @since 0.6
*/
public String getPassword() {
return this.password;
@@ -151,7 +137,6 @@
* {@inheritDoc}
*
* @see org.jboss.dna.web.jcr.rest.client.domain.IDnaObject#getShortDescription()
- * @since 0.6
*/
public String getShortDescription() {
return RestClientI18n.serverShortDescription.text(this.url, this.user);
@@ -159,7 +144,6 @@
/**
* @return the server URL
- * @since 0.6
*/
public String getUrl() {
return this.url;
@@ -167,7 +151,6 @@
/**
* @return the server authentication user
- * @since 0.6
*/
public String getUser() {
return this.user;
@@ -177,7 +160,6 @@
* {@inheritDoc}
*
* @see java.lang.Object#hashCode()
- * @since 0.6
*/
@Override
public int hashCode() {
@@ -195,7 +177,6 @@
/**
* @return persistPassword <code>true</code> if the password is being persisted
- * @since 0.6
*/
public boolean isPasswordBeingPersisted() {
return this.persistPassword;
@@ -205,7 +186,6 @@
* {@inheritDoc}
*
* @see java.lang.Object#toString()
- * @since 0.6
*/
@Override
public String toString() {
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-09-10 21:16:23 UTC (rev 1204)
+++ branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/domain/Workspace.java 2009-09-10 21:38:13 UTC (rev 1205)
@@ -32,8 +32,6 @@
/**
* The <code>Workspace</code> class is the business object for a DNA repository workspace.
- *
- * @since 0.6
*/
@Immutable
public final class Workspace implements IDnaObject {
@@ -44,15 +42,11 @@
/**
* The workspace name.
- *
- * @since 0.6
*/
private final String name;
/**
* The repository where this workspace resides.
- *
- * @since 0.6
*/
private final Repository repository;
@@ -67,7 +61,6 @@
* @param repository the repository where this workspace resides (never <code>null</code>)
* @see WorkspaceValidator
* @throws RuntimeException if any of the input parameters are invalid
- * @since 0.6
*/
public Workspace( String name,
Repository repository ) {
@@ -94,7 +87,6 @@
* {@inheritDoc}
*
* @see java.lang.Object#equals(java.lang.Object)
- * @since 0.6
*/
@Override
public boolean equals( Object obj ) {
@@ -110,7 +102,6 @@
* {@inheritDoc}
*
* @see org.jboss.dna.web.jcr.rest.client.domain.IDnaObject#getName()
- * @since 0.6
*/
public String getName() {
return this.name;
@@ -118,7 +109,6 @@
/**
* @return the repository where this workspace is located (never <code>null</code>)
- * @since 0.6
*/
public Repository getRepository() {
return this.repository;
@@ -126,7 +116,6 @@
/**
* @return the server where this workspace is located (never <code>null</code>)
- * @since 0.6
*/
public Server getServer() {
return this.repository.getServer();
@@ -136,7 +125,6 @@
* {@inheritDoc}
*
* @see org.jboss.dna.web.jcr.rest.client.domain.IDnaObject#getShortDescription()
- * @since 0.6
*/
public String getShortDescription() {
return RestClientI18n.workspaceShortDescription.text(this.name, this.repository.getName());
@@ -146,7 +134,6 @@
* {@inheritDoc}
*
* @see java.lang.Object#hashCode()
- * @since 0.6
*/
@Override
public int hashCode() {
@@ -157,7 +144,6 @@
* {@inheritDoc}
*
* @see java.lang.Object#toString()
- * @since 0.6
*/
@Override
public String toString() {
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-09-10 21:16:23 UTC (rev 1204)
+++ branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/domain/validation/RepositoryValidator.java 2009-09-10 21:38:13 UTC (rev 1205)
@@ -31,8 +31,6 @@
/**
* The <code>RepositoryValidator</code> class provides validation for creating a {@link Repository DNA repository}.
- *
- * @since 0.6
*/
public final class RepositoryValidator {
@@ -43,7 +41,6 @@
/**
* @param name the name being validated
* @return a validation status (never <code>null</code>)
- * @since 0.6
*/
public static Status isNameValid( String name ) {
if ((name == null) || (name.length() == 0)) {
@@ -56,7 +53,6 @@
/**
* @param server the server being validated
* @return a validation status (never <code>null</code>)
- * @since 0.6
*/
public static Status isServerValid( Server server ) {
if (server == null) {
@@ -70,7 +66,6 @@
* @param name the name being validated
* @param server the server being validated
* @return a validation status (never <code>null</code>)
- * @since 0.6
*/
public static Status isValid( String name,
Server server ) {
@@ -89,8 +84,6 @@
/**
* Disallow construction.
- *
- * @since 0.6
*/
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-09-10 21:16:23 UTC (rev 1204)
+++ branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/domain/validation/ServerValidator.java 2009-09-10 21:38:13 UTC (rev 1205)
@@ -32,8 +32,6 @@
/**
* The <code>ServerValidator</code> class provides validation for creating a {@link Server DNA server}.
- *
- * @since 0.6
*/
public final class ServerValidator {
@@ -44,7 +42,6 @@
/**
* @param password the password being validated
* @return a validation status (never <code>null</code>)
- * @since 0.6
*/
public static Status isPasswordValid( String password ) {
return Status.OK_STATUS;
@@ -53,7 +50,6 @@
/**
* @param url the URL being validated
* @return a validation status (never <code>null</code>)
- * @since 0.6
*/
public static Status isUrlValid( String url ) {
if ((url == null) || (url.length() == 0)) {
@@ -72,7 +68,6 @@
/**
* @param user the user being validated
* @return a validation status (never <code>null</code>)
- * @since 0.6
*/
public static Status isUserValid( String user ) {
if ((user == null) || (user.length() == 0)) {
@@ -90,7 +85,6 @@
* @param password the password being validated
* @param persistPassword <code>true</code> if the password should be persisted
* @return a validation status (never <code>null</code>)
- * @since 0.6
*/
public static Status isValid( String url,
String user,
@@ -120,7 +114,6 @@
* @param serverManager the server manager controlling the server registry (may not be <code>null</code>)
* @return a validation status (never <code>null</code>)
* @see #isValid(String, String, String, boolean)
- * @since 0.6
*/
public static Status isValid( String url,
String user,
@@ -147,8 +140,6 @@
/**
* Disallow construction.
- *
- * @since 0.6
*/
private ServerValidator() {
// nothing to do
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-09-10 21:16:23 UTC (rev 1204)
+++ branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/domain/validation/WorkspaceValidator.java 2009-09-10 21:38:13 UTC (rev 1205)
@@ -31,8 +31,6 @@
/**
* The <code>WorkspaceValidator</code> class provides validation for creating a {@link Workspace DNA workspace}.
- *
- * @since 0.6
*/
public final class WorkspaceValidator {
@@ -43,7 +41,6 @@
/**
* @param name the name being validated
* @return a validation status (never <code>null</code>)
- * @since 0.6
*/
public static Status isNameValid( String name ) {
if ((name == null) || (name.length() == 0)) {
@@ -56,7 +53,6 @@
/**
* @param repository the repository being validated
* @return a validation status (never <code>null</code>)
- * @since 0.6
*/
public static Status isRepositoryValid( Repository repository ) {
if (repository == null) {
@@ -70,7 +66,6 @@
* @param name the name being validated
* @param repository the repository being validated
* @return a validation status (never <code>null</code>)
- * @since 0.6
*/
public static Status isValid( String name,
Repository repository ) {
@@ -89,8 +84,6 @@
/**
* Disallow construction.
- *
- * @since 0.6
*/
private WorkspaceValidator() {
// nothing to do
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-09-10 21:16:23 UTC (rev 1204)
+++ branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/json/FileNode.java 2009-09-10 21:38:13 UTC (rev 1205)
@@ -40,8 +40,6 @@
/**
* The <code>FileNode</code> class is responsible for knowing how to create a URL for a file, create a JSON representation of a
* file, and to create the appropriate JCR nodes for a file.
- *
- * @since 0.6
*/
@Immutable
public final class FileNode extends JsonNode {
@@ -52,22 +50,16 @@
/**
* The file on the local file system.
- *
- * @since 0.6
*/
private final File file;
/**
* The folder in the workspace where the file is or will be published or unpublished.
- *
- * @since 0.6
*/
private final String path;
/**
* The workspace where the file is or will be published or unpublished.
- *
- * @since 0.6
*/
private final Workspace workspace;
@@ -80,7 +72,6 @@
* @param path the path in the workspace (never <code>null</code>)
* @param file the file on the local file system (never <code>null</code>)
* @throws Exception if there is a problem constructing the file node
- * @since 0.6
*/
public FileNode( Workspace workspace,
String path,
@@ -131,7 +122,6 @@
* {@inheritDoc}
*
* @see org.jboss.dna.web.jcr.rest.client.json.JsonNode#getContent()
- * @since 0.6
*/
@Override
public byte[] getContent() throws Exception {
@@ -151,7 +141,6 @@
* @return the encoded file contents
* @throws Exception if there is a problem obtaining the contents
* @see #getFileContentsUrl()
- * @since 0.6
*/
String getFileContents( String jsonResponse ) throws Exception {
CheckArg.isNotNull(jsonResponse, "jsonResponse"); //$NON-NLS-1$
@@ -166,7 +155,6 @@
*
* @return the URL that can be used to obtain the encoded file contents from a workspace
* @throws Exception if there is a problem constructing the URL
- * @since 0.6
*/
URL getFileContentsUrl() throws Exception {
StringBuilder url = new StringBuilder(getUrl().toString());
@@ -176,7 +164,6 @@
/**
* @return the path where the file is or will be published or unpublished
- * @since 0.6
*/
public String getPath() {
return this.path;
@@ -186,7 +173,6 @@
* {@inheritDoc}
*
* @see org.jboss.dna.web.jcr.rest.client.json.JsonNode#getUrl()
- * @since 0.6
*/
@Override
public URL getUrl() throws Exception {
@@ -201,7 +187,6 @@
/**
* @return the base 64 encoded file content
* @throws Exception if there is a problem reading the file
- * @since 0.6
*/
String readFile() throws Exception {
return Base64.encode(new FileInputStream(this.file.getAbsoluteFile()));
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-09-10 21:16:23 UTC (rev 1204)
+++ branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/json/FolderNode.java 2009-09-10 21:38:13 UTC (rev 1205)
@@ -33,8 +33,6 @@
/**
* The <code>FolderNode</code> class is responsible for knowing how to create a URL for a folder, create a JSON representation of
* a folder, and create the appropriate JCR nodes for a folder.
- *
- * @since 0.6
*/
@Immutable
public final class FolderNode extends JsonNode {
@@ -45,8 +43,6 @@
/**
* The workspace where the file is being published.
- *
- * @since 0.6
*/
private final Workspace workspace;
@@ -58,7 +54,6 @@
* @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( Workspace workspace,
String fullPath ) throws Exception {
@@ -81,7 +76,6 @@
/**
* @return the full path of folder within the workspace
- * @since 0.6
*/
public String getPath() {
return getId();
@@ -93,7 +87,6 @@
* 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 {
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-09-10 21:16:23 UTC (rev 1204)
+++ branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/json/IJsonConstants.java 2009-09-10 21:38:13 UTC (rev 1205)
@@ -26,67 +26,51 @@
/**
* The <code>IJsonConstants</code> interface provides JSON-specific constants used when JSON as a transport mechanism between the
* REST client and the REST server.
- *
- * @since 0.6
*/
public interface IJsonConstants {
/**
* The HTTP method to use when creating a connection with the REST server.
- *
- * @since 0.6
*/
enum RequestMethod {
/**
* The HTTP DELETE request method.
- *
- * @since 0.6
*/
DELETE,
/**
* The HTTP GET request method.
- *
- * @since 0.6
*/
GET,
/**
* The HTTP POST request method.
- *
- * @since 0.6
*/
POST,
/**
* The HTTP PUT request method.
- *
- * @since 0.6
*/
PUT
}
/**
* The key in the <code>JSONObject</code> whose value is the collection of node children.
- *
- * @since 0.6
*/
String CHILDREN_KEY = "children"; //$NON-NLS-1$
/**
* The key in the <code>JSONObject</code> whose value is the collection of node properties.
- *
- * @since 0.6
*/
String PROPERTIES_KEY = "properties"; //$NON-NLS-1$
/**
- * @since 0.6
+ * The server context added to URLs.
*/
String SERVER_CONTEXT = "/resources"; //$NON-NLS-1$
/**
- * @since 0.6
+ * The workspace context added to the URLs.
*/
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-09-10 21:16:23 UTC (rev 1204)
+++ branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/json/JsonNode.java 2009-09-10 21:38:13 UTC (rev 1205)
@@ -30,8 +30,6 @@
/**
* The <code>JsonNode</code> class defines the API for interacing with JSON objects. Every <code>JsonNode</code> knows how to
* create their URL and create their JCR content.
- *
- * @since 0.6
*/
public abstract class JsonNode extends JSONObject {
@@ -41,8 +39,6 @@
/**
* The node identifier.
- *
- * @since 0.6
*/
private final String id;
@@ -52,7 +48,6 @@
/**
* @param id the node identifier (never <code>null</code>)
- * @since 0.6
*/
protected JsonNode( String id ) {
CheckArg.isNotNull(id, "id"); //$NON-NLS-1$
@@ -66,7 +61,6 @@
/**
* @return the content that gets published
* @throws Exception if there is a problem obtaining the node content
- * @since 0.6
*/
public byte[] getContent() throws Exception {
return super.toString().getBytes();
@@ -74,7 +68,6 @@
/**
* @return a unique identifier for this node
- * @since 0.6
*/
public String getId() {
return this.id;
@@ -83,7 +76,6 @@
/**
* @return an HTTP URL representing this node
* @throws Exception if there is a problem constructing the URL
- * @since 0.6
*/
public abstract URL getUrl() throws Exception;
@@ -91,7 +83,6 @@
* {@inheritDoc}
*
* @see org.codehaus.jettison.json.JSONObject#toString()
- * @since 0.6
*/
@Override
public String toString() {
Modified: branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/json/JsonRestClient.java
===================================================================
--- branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/json/JsonRestClient.java 2009-09-10 21:16:23 UTC (rev 1204)
+++ branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/json/JsonRestClient.java 2009-09-10 21:38:13 UTC (rev 1205)
@@ -43,8 +43,6 @@
/**
* The <code>JsonRestClient</code> class is an implementation of <code>IRestClient</code> that works with the DNA REST server that
* uses JSON as its interface protocol.
- *
- * @since 0.6
*/
public final class JsonRestClient implements IRestClient {
@@ -54,8 +52,6 @@
/**
* The logger.
- *
- * @since 0.6
*/
private final Logger logger = Logger.getLogger(JsonRestClient.class);
@@ -70,7 +66,6 @@
* @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,
@@ -107,7 +102,6 @@
* @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 {
@@ -140,7 +134,6 @@
* @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 {
@@ -180,7 +173,6 @@
* {@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 {
CheckArg.isNotNull(server, "server"); //$NON-NLS-1$
@@ -211,7 +203,6 @@
*
* @see org.jboss.dna.web.jcr.rest.client.IRestClient#getUrl(java.io.File, java.lang.String,
* org.jboss.dna.web.jcr.rest.client.domain.Workspace)
- * @since 0.6
*/
public URL getUrl( File file,
String path,
@@ -232,7 +223,6 @@
* {@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 {
CheckArg.isNotNull(repository, "repository"); //$NON-NLS-1$
@@ -266,7 +256,6 @@
* @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( Server server,
URL url,
@@ -296,7 +285,6 @@
* @param file the file whose workspace contents are being requested
* @return the base 64 encoded file contents or <code>null</code> if file is not found
* @throws Exception if there is a problem obtaining the contents
- * @since 0.6
*/
String getFileContents( Workspace workspace,
String path,
@@ -318,7 +306,6 @@
* @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( Server server,
URL url ) throws Exception {
@@ -343,7 +330,6 @@
* @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
*/
public boolean pathExists( Workspace workspace,
String path,
@@ -357,7 +343,6 @@
*
* @see org.jboss.dna.web.jcr.rest.client.IRestClient#publish(org.jboss.dna.web.jcr.rest.client.domain.Workspace,
* java.lang.String, java.io.File)
- * @since 0.6
*/
public Status publish( Workspace workspace,
String path,
@@ -391,7 +376,6 @@
*
* @see org.jboss.dna.web.jcr.rest.client.IRestClient#unpublish(org.jboss.dna.web.jcr.rest.client.domain.Workspace,
* java.lang.String, java.io.File)
- * @since 0.6
*/
public Status unpublish( Workspace workspace,
String path,
Modified: branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/json/JsonUtils.java
===================================================================
--- branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/json/JsonUtils.java 2009-09-10 21:16:23 UTC (rev 1204)
+++ branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/json/JsonUtils.java 2009-09-10 21:38:13 UTC (rev 1205)
@@ -33,8 +33,6 @@
/**
* The <code>JsonUtils</code> class provides utilities needed to work with the DNA REST server JSON API.
- *
- * @since 0.6
*/
public final class JsonUtils {
@@ -44,8 +42,6 @@
/**
* The default character set being used.
- *
- * @since 0.6
*/
private static final String DEFAULT_CHARSET = "UTF-8"; //$NON-NLS-1$ // TODO need to property drive charset
@@ -57,7 +53,6 @@
* @param text the text being URL decoded (never <code>null</code>)
* @return the decoded text
* @throws UnsupportedEncodingException if the charset is not supported
- * @since 0.6
*/
public static String decode( String text ) throws UnsupportedEncodingException {
CheckArg.isNotNull(text, "text"); //$NON-NLS-1$
@@ -70,7 +65,6 @@
* @param text the text being URL encoded (never <code>null</code>)
* @return the decoded text
* @throws UnsupportedEncodingException if the charset is not supported
- * @since 0.6
*/
public static String encode( String text ) throws UnsupportedEncodingException {
CheckArg.isNotNull(text, "text"); //$NON-NLS-1$
@@ -91,7 +85,6 @@
* @param connection the connection whose input stream is going to be read from (never <code>null</code>)
* @return the data read from the connection input stream (never <code>null</code>)
* @throws IOException if there is a problem reading from the connection
- * @since 0.6
*/
public static String readInputStream( HttpURLConnection connection ) throws IOException {
CheckArg.isNotNull(connection, "connection"); //$NON-NLS-1$
@@ -114,10 +107,9 @@
/**
* Don't allow construction.
- *
- * @since 0.6
*/
private JsonUtils() {
// nothing to do
}
+
}
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-09-10 21:16:23 UTC (rev 1204)
+++ branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/json/RepositoryNode.java 2009-09-10 21:38:13 UTC (rev 1205)
@@ -35,8 +35,6 @@
/**
* The <code>RepositoryNode</code> class is responsible for knowing how to create a URL for a repository and to parse a JSON
* response into {@link Workspace workspace} objects.
- *
- * @since 0.6
*/
public final class RepositoryNode extends JsonNode {
@@ -46,8 +44,6 @@
/**
* The DNA repository.
- *
- * @since 0.6
*/
private final Repository repository;
@@ -57,7 +53,6 @@
/**
* @param repository the DNA repository (never <code>null</code>)
- * @since 0.6
*/
public RepositoryNode( Repository repository ) {
super(repository.getName());
@@ -74,7 +69,6 @@
* 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 {
@@ -90,7 +84,6 @@
* @param jsonResponse the HTTP connection JSON response (never <code>null</code>) containing the workspaces
* @return the workspaces for this repository (never <code>null</code>)
* @throws Exception if there is a problem obtaining the workspaces
- * @since 0.6
*/
@SuppressWarnings( "unchecked" )
public Collection<Workspace> getWorkspaces( String jsonResponse ) throws Exception {
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-09-10 21:16:23 UTC (rev 1204)
+++ branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/json/ServerNode.java 2009-09-10 21:38:13 UTC (rev 1205)
@@ -36,8 +36,6 @@
/**
* The <code>ServerNode</code> class is responsible for knowing how to create a URL for a server, create a URL to obtain a
* server's repositories, and parse a JSON response into {@link Repository repository} objects.
- *
- * @since 0.6
*/
public final class ServerNode extends JsonNode {
@@ -47,15 +45,11 @@
/**
* The logger.
- *
- * @since 0.6
*/
private final Logger logger = Logger.getLogger(ServerNode.class);
/**
* The server containing DNA repositories.
- *
- * @since 0.6
*/
private final Server server;
@@ -65,7 +59,6 @@
/**
* @param server the server containing the repositories (never <code>null</code>)
- * @since 0.6
*/
public ServerNode( Server server ) {
super(server.getName());
@@ -82,7 +75,6 @@
* 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 {
@@ -103,7 +95,6 @@
/**
* @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 {
return new URL(getUrl().toString() + '/');
@@ -113,7 +104,6 @@
* @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
- * @since 0.6
*/
@SuppressWarnings( "unchecked" )
public Collection<Repository> getRepositories( String jsonResponse ) throws Exception {
Modified: branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/json/WorkspaceNode.java
===================================================================
--- branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/json/WorkspaceNode.java 2009-09-10 21:16:23 UTC (rev 1204)
+++ branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/json/WorkspaceNode.java 2009-09-10 21:38:13 UTC (rev 1205)
@@ -29,8 +29,6 @@
/**
* The <code>WorkspaceNode</code> class is responsible for knowing how to create a URL for a {@link Workspace workspace}. The URL
* can be used to publish and unpublish resources.
- *
- * @since 0.6
*/
public class WorkspaceNode extends JsonNode {
@@ -46,7 +44,6 @@
/**
* @param workspace the repository workspace (never <code>null</code>)
- * @since 0.6
*/
public WorkspaceNode( Workspace workspace ) {
super(workspace.getName());
@@ -61,7 +58,6 @@
* {@inheritDoc}
*
* @see org.jboss.dna.web.jcr.rest.client.json.JsonNode#getUrl()
- * @since 0.6
*/
@Override
public URL getUrl() throws Exception {
Modified: branches/eclipse/dna-web-jcr-rest-client/src/test/java/org/jboss/dna/web/jcr/rest/client/MockRestClient.java
===================================================================
--- branches/eclipse/dna-web-jcr-rest-client/src/test/java/org/jboss/dna/web/jcr/rest/client/MockRestClient.java 2009-09-10 21:16:23 UTC (rev 1204)
+++ branches/eclipse/dna-web-jcr-rest-client/src/test/java/org/jboss/dna/web/jcr/rest/client/MockRestClient.java 2009-09-10 21:38:13 UTC (rev 1205)
@@ -32,8 +32,6 @@
/**
* The <code>MockRestExecutor</code> class is a test <code>IRestClient</code> implementation that does nothing.
- *
- * @since 0.6
*/
public final class MockRestClient implements IRestClient {
@@ -45,17 +43,16 @@
* {@inheritDoc}
*
* @see org.jboss.dna.web.jcr.rest.client.IRestClient#getRepositories(org.jboss.dna.web.jcr.rest.client.domain.Server)
- * @since 0.6
*/
public Collection<Repository> getRepositories( Server server ) throws Exception {
return null;
}
-
+
/**
* {@inheritDoc}
- *
- * @see org.jboss.dna.web.jcr.rest.client.IRestClient#getUrl(java.io.File, java.lang.String, org.jboss.dna.web.jcr.rest.client.domain.Workspace)
- * @since 0.6
+ *
+ * @see org.jboss.dna.web.jcr.rest.client.IRestClient#getUrl(java.io.File, java.lang.String,
+ * org.jboss.dna.web.jcr.rest.client.domain.Workspace)
*/
public URL getUrl( File file,
String path,
@@ -67,7 +64,6 @@
* {@inheritDoc}
*
* @see org.jboss.dna.web.jcr.rest.client.IRestClient#getWorkspaces(org.jboss.dna.web.jcr.rest.client.domain.Repository)
- * @since 0.6
*/
public Collection<Workspace> getWorkspaces( Repository repository ) throws Exception {
return null;
@@ -78,7 +74,6 @@
*
* @see org.jboss.dna.web.jcr.rest.client.IRestClient#publish(org.jboss.dna.web.jcr.rest.client.domain.Workspace,
* java.lang.String, java.io.File)
- * @since 0.6
*/
public Status publish( Workspace workspace,
String path,
@@ -91,7 +86,6 @@
*
* @see org.jboss.dna.web.jcr.rest.client.IRestClient#unpublish(org.jboss.dna.web.jcr.rest.client.domain.Workspace,
* java.lang.String, java.io.File)
- * @since 0.6
*/
public Status unpublish( Workspace workspace,
String path,
Modified: branches/eclipse/dna-web-jcr-rest-client/src/test/java/org/jboss/dna/web/jcr/rest/client/RestClientI18nTest.java
===================================================================
--- branches/eclipse/dna-web-jcr-rest-client/src/test/java/org/jboss/dna/web/jcr/rest/client/RestClientI18nTest.java 2009-09-10 21:16:23 UTC (rev 1204)
+++ branches/eclipse/dna-web-jcr-rest-client/src/test/java/org/jboss/dna/web/jcr/rest/client/RestClientI18nTest.java 2009-09-10 21:38:13 UTC (rev 1205)
@@ -26,10 +26,10 @@
import org.jboss.dna.common.AbstractI18nTest;
/**
- * @since 0.6
+ * Test for the I18n file.
*/
public final class RestClientI18nTest extends AbstractI18nTest {
-
+
public RestClientI18nTest() {
super(RestClientI18n.class);
}
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-09-10 21:16:23 UTC (rev 1204)
+++ branches/eclipse/dna-web-jcr-rest-client/src/test/java/org/jboss/dna/web/jcr/rest/client/ServerManagerTest.java 2009-09-10 21:38:13 UTC (rev 1205)
@@ -32,8 +32,6 @@
/**
* The <code>ServerManagerTest</code> class is a test class for the {@link ServerManager server manager} object.
- *
- * @since 0.6
*/
public final class ServerManagerTest {
Modified: branches/eclipse/dna-web-jcr-rest-client/src/test/java/org/jboss/dna/web/jcr/rest/client/StatusTest.java
===================================================================
--- branches/eclipse/dna-web-jcr-rest-client/src/test/java/org/jboss/dna/web/jcr/rest/client/StatusTest.java 2009-09-10 21:16:23 UTC (rev 1204)
+++ branches/eclipse/dna-web-jcr-rest-client/src/test/java/org/jboss/dna/web/jcr/rest/client/StatusTest.java 2009-09-10 21:38:13 UTC (rev 1205)
@@ -32,8 +32,6 @@
/**
* The <code>StatusTest</code> class is a test class for the {@link Status status} object.
- *
- * @since 0.6
*/
public final class StatusTest {
Modified: branches/eclipse/dna-web-jcr-rest-client/src/test/java/org/jboss/dna/web/jcr/rest/client/domain/RepositoryTest.java
===================================================================
--- branches/eclipse/dna-web-jcr-rest-client/src/test/java/org/jboss/dna/web/jcr/rest/client/domain/RepositoryTest.java 2009-09-10 21:16:23 UTC (rev 1204)
+++ branches/eclipse/dna-web-jcr-rest-client/src/test/java/org/jboss/dna/web/jcr/rest/client/domain/RepositoryTest.java 2009-09-10 21:38:13 UTC (rev 1205)
@@ -33,8 +33,6 @@
/**
* The <code>RepositoryTest</code> class is a test class for the {@link Repository repository} object.
- *
- * @since 0.6
*/
public final class RepositoryTest {
Modified: branches/eclipse/dna-web-jcr-rest-client/src/test/java/org/jboss/dna/web/jcr/rest/client/domain/ServerTest.java
===================================================================
--- branches/eclipse/dna-web-jcr-rest-client/src/test/java/org/jboss/dna/web/jcr/rest/client/domain/ServerTest.java 2009-09-10 21:16:23 UTC (rev 1204)
+++ branches/eclipse/dna-web-jcr-rest-client/src/test/java/org/jboss/dna/web/jcr/rest/client/domain/ServerTest.java 2009-09-10 21:38:13 UTC (rev 1205)
@@ -33,8 +33,6 @@
/**
* The <code>ServerTest</code> class is a test class for the {@link Server server} object.
- *
- * @since 0.6
*/
public final class ServerTest {
Modified: branches/eclipse/dna-web-jcr-rest-client/src/test/java/org/jboss/dna/web/jcr/rest/client/domain/WorkspaceTest.java
===================================================================
--- branches/eclipse/dna-web-jcr-rest-client/src/test/java/org/jboss/dna/web/jcr/rest/client/domain/WorkspaceTest.java 2009-09-10 21:16:23 UTC (rev 1204)
+++ branches/eclipse/dna-web-jcr-rest-client/src/test/java/org/jboss/dna/web/jcr/rest/client/domain/WorkspaceTest.java 2009-09-10 21:38:13 UTC (rev 1205)
@@ -33,8 +33,6 @@
/**
* The <code>WorkspaceTest</code> class is a test class for the {@link Workspace workspace} object.
- *
- * @since 0.6
*/
public final class WorkspaceTest {
Modified: branches/eclipse/dna-web-jcr-rest-client/src/test/java/org/jboss/dna/web/jcr/rest/client/json/JsonRestClientTest.java
===================================================================
--- branches/eclipse/dna-web-jcr-rest-client/src/test/java/org/jboss/dna/web/jcr/rest/client/json/JsonRestClientTest.java 2009-09-10 21:16:23 UTC (rev 1204)
+++ branches/eclipse/dna-web-jcr-rest-client/src/test/java/org/jboss/dna/web/jcr/rest/client/json/JsonRestClientTest.java 2009-09-10 21:38:13 UTC (rev 1205)
@@ -46,8 +46,6 @@
* One container: mvn -P cargo-1 clean install assembly:assembly
* <p>
* Two containers: mvn -P cargo-1,cargo-2 clean install assembly:assembly
- *
- * @since 0.6
*/
public final class JsonRestClientTest {
14 years, 8 months
DNA SVN: r1204 - in branches/eclipse/dna-web-jcr-rest-client: src/main/java/org/jboss/dna/web/jcr/rest/client and 9 other directories.
by dna-commits@lists.jboss.org
Author: elvisisking
Date: 2009-09-10 17:16:23 -0400 (Thu, 10 Sep 2009)
New Revision: 1204
Added:
branches/eclipse/dna-web-jcr-rest-client/src/test/resources/myproject/My.Test - Folder/
branches/eclipse/dna-web-jcr-rest-client/src/test/resources/myproject/My.Test - Folder/Test File_.a-*().txt
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/IJcrConstants.java
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/IServerRegistryListener.java
branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/ServerAuthenticator.java
branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/ServerManager.java
branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/ServerRegistryEvent.java
branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/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/json/FileNode.java
branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/json/FolderNode.java
branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/json/JsonNode.java
branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/json/JsonRestClient.java
branches/eclipse/dna-web-jcr-rest-client/src/main/resources/org/jboss/dna/web/jcr/rest/client/RestClientI18n.properties
branches/eclipse/dna-web-jcr-rest-client/src/test/java/org/jboss/dna/web/jcr/rest/client/MockRestClient.java
branches/eclipse/dna-web-jcr-rest-client/src/test/java/org/jboss/dna/web/jcr/rest/client/RestIntegrationTest.java
branches/eclipse/dna-web-jcr-rest-client/src/test/java/org/jboss/dna/web/jcr/rest/client/json/JsonRestClientTest.java
Log:
Fixed problem with bad URLs for file names with non-letters and non-number characters. Uploading of file content (binary and text) now works. Registry listeners now get events after registering for all the registered servers. Added ServerManager to the registry event as the event source. Now using DNA common to calculate hashcodes. Also now calculating mimetype of files instead of defaulting to the same mimetype.
Modified: branches/eclipse/dna-web-jcr-rest-client/pom.xml
===================================================================
--- branches/eclipse/dna-web-jcr-rest-client/pom.xml 2009-09-10 18:53:32 UTC (rev 1203)
+++ branches/eclipse/dna-web-jcr-rest-client/pom.xml 2009-09-10 21:16:23 UTC (rev 1204)
@@ -96,103 +96,216 @@
</plugin>
</plugins>
</reporting>
- <build>
- <pluginManagement>
- <plugins>
- <plugin>
- <artifactId>maven-assembly-plugin</artifactId>
- <configuration>
- <descriptorRefs>
- <descriptorRef>jar-with-dependencies
- </descriptorRef>
- </descriptorRefs>
- </configuration>
- <executions>
- <execution>
- <id>create-project-bundle</id>
- <phase>package</phase>
- <goals>
- <goal>single</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
- </plugins>
- </pluginManagement>
- <plugins>
- <plugin>
- <groupId>org.codehaus.cargo</groupId>
- <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>
+ <profiles>
+ <profile>
+ <id>cargo-1</id>
+ <build>
+ <pluginManagement>
+ <plugins>
+ <plugin>
+ <artifactId>maven-assembly-plugin
+ </artifactId>
+ <configuration>
+ <descriptorRefs>
+ <descriptorRef>jar-with-dependencies
+ </descriptorRef>
+ </descriptorRefs>
+ </configuration>
+ <executions>
+ <execution>
+ <id>create-project-bundle</id>
+ <phase>package</phase>
+ <goals>
+ <goal>single</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </pluginManagement>
+ <plugins>
+ <plugin>
+ <groupId>org.codehaus.cargo</groupId>
+ <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>
+ <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>
+ </profile>
+ <profile>
+ <id>cargo-2</id>
+ <build>
+ <pluginManagement>
+ <plugins>
+ <plugin>
+ <artifactId>maven-assembly-plugin
+ </artifactId>
+ <configuration>
+ <descriptorRefs>
+ <descriptorRef>jar-with-dependencies
+ </descriptorRef>
+ </descriptorRefs>
+ </configuration>
+ <executions>
+ <execution>
+ <id>create-project-bundle</id>
+ <phase>package</phase>
+ <goals>
+ <goal>single</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </pluginManagement>
+ <plugins>
+ <plugin>
+ <groupId>org.codehaus.cargo</groupId>
+ <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>
+ dnauser2:password2:connect,readwrite|unauthorized:password:bogus
+ </cargo.servlet.users>
+ <cargo.servlet.port>8180</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>
+ </profile>
+ </profiles>
</project>
Modified: branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/IJcrConstants.java
===================================================================
--- branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/IJcrConstants.java 2009-09-10 18:53:32 UTC (rev 1203)
+++ branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/IJcrConstants.java 2009-09-10 21:16:23 UTC (rev 1204)
@@ -42,7 +42,7 @@
*
* @since 0.6
*/
- String DATA_PROPERTY = "jcr:data"; //$NON-NLS-1$
+ String DATA_PROPERTY = "jcr:data/base64/"; //$NON-NLS-1$
/**
* The JCR file node type (<code>nt:file</code>).
Modified: branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/IRestClient.java
===================================================================
--- branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/IRestClient.java 2009-09-10 18:53:32 UTC (rev 1203)
+++ branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/IRestClient.java 2009-09-10 21:16:23 UTC (rev 1204)
@@ -24,6 +24,7 @@
package org.jboss.dna.web.jcr.rest.client;
import java.io.File;
+import java.net.URL;
import java.util.Collection;
import org.jboss.dna.web.jcr.rest.client.Status.Severity;
import org.jboss.dna.web.jcr.rest.client.domain.Repository;
@@ -48,6 +49,18 @@
Collection<Repository> getRepositories( Server server ) throws Exception;
/**
+ * @param file the file whose URL is being requested (never <code>null</code>)
+ * @param path the path in the DNA workspace where the file is/could be located (never <code>null</code>)
+ * @param workspace the workspace where the file is/could be located (never <code>null</code>)
+ * @return the workspace URL for the specified file (never <code>null</code>)
+ * @throws Exception if there is a problem obtaining the URL or if the file is a directory
+ * @since 0.6
+ */
+ URL getUrl( File file,
+ String path,
+ Workspace workspace ) throws Exception;
+
+ /**
* Obtains the workspaces defined within the specified DNA respository.
*
* @param repository the repository whose workspaces are being requested (never <code>null</code>)
Modified: branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/IServerRegistryListener.java
===================================================================
--- branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/IServerRegistryListener.java 2009-09-10 18:53:32 UTC (rev 1203)
+++ branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/IServerRegistryListener.java 2009-09-10 21:16:23 UTC (rev 1204)
@@ -31,7 +31,7 @@
public interface IServerRegistryListener {
/**
- * @param event the event being processed
+ * @param event the event being processed (never <code>null</code>)
* @return any errors caught during the processing or <code>null</code>
* @since 0.6
*/
Modified: branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/ServerAuthenticator.java
===================================================================
--- branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/ServerAuthenticator.java 2009-09-10 18:53:32 UTC (rev 1203)
+++ branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/ServerAuthenticator.java 2009-09-10 21:16:23 UTC (rev 1204)
@@ -35,29 +35,6 @@
public class ServerAuthenticator extends Authenticator {
// ===========================================================================================================================
- // Fields
- // ===========================================================================================================================
-
- /**
- * The object managing the server registry.
- *
- * @since 0.6
- */
- private final ServerManager serverManager;
-
- // ===========================================================================================================================
- // Constructors
- // ===========================================================================================================================
-
- /**
- * @param serverManager the server manager manages the server registry
- * @since 0.6
- */
- public ServerAuthenticator( ServerManager serverManager ) {
- this.serverManager = serverManager;
- }
-
- // ===========================================================================================================================
// Methods
// ===========================================================================================================================
@@ -69,8 +46,9 @@
*/
@Override
protected PasswordAuthentication getPasswordAuthentication() {
- Server server = this.serverManager.getCurrentServer();
- return new PasswordAuthentication(server.getUser(), server.getPassword().toCharArray());
+ Server server = ServerManager.getCurrentServer();
+ String password = ((server.getPassword() == null) ? "" : server.getPassword()); //$NON-NLS-1$
+ return new PasswordAuthentication(server.getUser(), password.toCharArray());
}
}
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-09-10 18:53:32 UTC (rev 1203)
+++ branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/ServerManager.java 2009-09-10 21:16:23 UTC (rev 1204)
@@ -26,6 +26,7 @@
import java.io.File;
import java.io.FileOutputStream;
import java.net.Authenticator;
+import java.net.URL;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
@@ -202,7 +203,7 @@
this.listeners = new CopyOnWriteArrayList<IServerRegistryListener>();
// set our authenticator that uses the server registry
- Authenticator.setDefault(new ServerAuthenticator(this));
+ Authenticator.setDefault(new ServerAuthenticator());
}
/**
@@ -221,7 +222,7 @@
// ===========================================================================================================================
/**
- * Listeners already registered will not be added again.
+ * Listeners already registered will not be added again. The new listener will receive events for all existing servers.
*
* @param listener the listener being register to receive events (never <code>null</code>)
* @return <code>true</code> if listener was added
@@ -229,7 +230,14 @@
*/
public boolean addRegistryListener( IServerRegistryListener listener ) {
CheckArg.isNotNull(listener, "listener"); //$NON-NLS-1$
- return this.listeners.addIfAbsent(listener);
+ boolean result = this.listeners.addIfAbsent(listener);
+
+ // inform new listener of registered servers
+ for (Server server : getServers()) {
+ listener.serverRegistryChanged(ServerRegistryEvent.createNewEvent(this, server));
+ }
+
+ return result;
}
/**
@@ -245,6 +253,25 @@
}
/**
+ * @param url the URL of the server being requested (never <code>null</code>)
+ * @param user the user ID of the server being requested (never <code>null</code>)
+ * @return the requested server or <code>null</code> if not found in the registry
+ */
+ public Server findServer( String url,
+ String user ) {
+ CheckArg.isNotNull(url, "url"); //$NON-NLS-1$
+ CheckArg.isNotNull(user, "user"); //$NON-NLS-1$
+
+ for (Server server : getServers()) {
+ if (url.equals(server.getUrl()) && user.equals(server.getUser())) {
+ return server;
+ }
+ }
+
+ return null;
+ }
+
+ /**
* @return an unmodifiable collection of registered servers (never <code>null</code>)
* @since 0.6
*/
@@ -301,6 +328,19 @@
/**
* {@inheritDoc}
*
+ * @see org.jboss.dna.web.jcr.rest.client.IRestClient#getUrl(java.io.File, java.lang.String,
+ * org.jboss.dna.web.jcr.rest.client.domain.Workspace)
+ * @since 0.6
+ */
+ public URL getUrl( File file,
+ String path,
+ Workspace workspace ) throws Exception {
+ return this.delegate.getUrl(file, path, workspace);
+ }
+
+ /**
+ * {@inheritDoc}
+ *
* @see org.jboss.dna.web.jcr.rest.client.IRestClient#getWorkspaces(org.jboss.dna.web.jcr.rest.client.domain.Repository)
* @throws RuntimeException if the server is not registered
* @see #isRegistered(Server)
@@ -350,7 +390,7 @@
if (added) {
if (notifyListeners) {
- Exception[] errors = notifyRegistryListeners(ServerRegistryEvent.createNewEvent(server));
+ Exception[] errors = notifyRegistryListeners(ServerRegistryEvent.createNewEvent(this, server));
return processRegistryListenerErrors(errors);
}
@@ -387,7 +427,7 @@
if (removed) {
if (notifyListeners) {
- Exception[] errors = notifyRegistryListeners(ServerRegistryEvent.createRemoveEvent(server));
+ Exception[] errors = notifyRegistryListeners(ServerRegistryEvent.createRemoveEvent(this, server));
return processRegistryListenerErrors(errors);
}
@@ -696,7 +736,8 @@
if (status.isOk()) {
// all good so notify listeners
- Exception[] errors = notifyRegistryListeners(ServerRegistryEvent.createUpdateEvent(previousServerVersion,
+ Exception[] errors = notifyRegistryListeners(ServerRegistryEvent.createUpdateEvent(this,
+ previousServerVersion,
newServerVersion));
return processRegistryListenerErrors(errors);
}
Modified: branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/ServerRegistryEvent.java
===================================================================
--- branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/ServerRegistryEvent.java 2009-09-10 18:53:32 UTC (rev 1203)
+++ branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/ServerRegistryEvent.java 2009-09-10 21:16:23 UTC (rev 1204)
@@ -71,40 +71,49 @@
// ===========================================================================================================================
/**
+ * @param serverManager the server manager sourcing this event (never <code>null</code>)
* @param newServer the server that was added to the server registry (never <code>null</code>)
* @return the event (never <code>null</code>)
* @see Type#NEW
* @since 0.6
*/
- public static ServerRegistryEvent createNewEvent( Server newServer ) {
+ public static ServerRegistryEvent createNewEvent( ServerManager serverManager,
+ Server newServer ) {
+ CheckArg.isNotNull(serverManager, "serverManager"); //$NON-NLS-1$
CheckArg.isNotNull(newServer, "newServer"); //$NON-NLS-1$
- return new ServerRegistryEvent(Type.NEW, newServer);
+ return new ServerRegistryEvent(serverManager, Type.NEW, newServer);
}
/**
+ * @param serverManager the server manager sourcing this event (never <code>null</code>)
* @param removedServer the server removed from the server registry (never <code>null</code>)
* @return the event (never <code>null</code>)
* @see Type#REMOVE
* @since 0.6
*/
- public static ServerRegistryEvent createRemoveEvent( Server removedServer ) {
+ public static ServerRegistryEvent createRemoveEvent( ServerManager serverManager,
+ Server removedServer ) {
+ CheckArg.isNotNull(serverManager, "serverManager"); //$NON-NLS-1$
CheckArg.isNotNull(removedServer, "removedServer"); //$NON-NLS-1$
- return new ServerRegistryEvent(Type.REMOVE, removedServer);
+ return new ServerRegistryEvent(serverManager, Type.REMOVE, removedServer);
}
/**
+ * @param serverManager the server manager sourcing this event (never <code>null</code>)
* @param previousServerVersion the server being updated (never <code>null</code>)
* @param newServerVersion the updated version of the server (never <code>null</code>)
* @return the event (never <code>null</code>)
* @see Type#UPDATE
* @since 0.6
*/
- public static ServerRegistryEvent createUpdateEvent( Server previousServerVersion,
+ public static ServerRegistryEvent createUpdateEvent( ServerManager serverManager,
+ Server previousServerVersion,
Server newServerVersion ) {
+ CheckArg.isNotNull(serverManager, "serverManager"); //$NON-NLS-1$
CheckArg.isNotNull(previousServerVersion, "previousServerVersion"); //$NON-NLS-1$
CheckArg.isNotNull(newServerVersion, "newServerVersion"); //$NON-NLS-1$
- ServerRegistryEvent event = new ServerRegistryEvent(Type.UPDATE, previousServerVersion);
+ ServerRegistryEvent event = new ServerRegistryEvent(serverManager, Type.UPDATE, previousServerVersion);
event.updatedServer = newServerVersion;
return event;
}
@@ -121,6 +130,13 @@
private final Server server;
/**
+ * The server manager in charge of the server registry the event is associated with.
+ *
+ * @since 0.6
+ */
+ private final ServerManager serverManager;
+
+ /**
* The event type.
*
* @since 0.6
@@ -139,12 +155,15 @@
// ===========================================================================================================================
/**
+ * @param serverManager the server manager sourcing this event
* @param type the event type
* @param server the server being added, removed, or updated
* @since 0.6
*/
- private ServerRegistryEvent( Type type,
+ private ServerRegistryEvent( ServerManager serverManager,
+ Type type,
Server server ) {
+ this.serverManager = serverManager;
this.type = type;
this.server = server;
}
@@ -162,6 +181,14 @@
}
/**
+ * @return the server manager sourcing this event
+ * @since 0.6
+ */
+ public ServerManager getServerManager() {
+ return this.serverManager;
+ }
+
+ /**
* @return the new version of an existing server that has been updated
* @throws UnsupportedOperationException if method is called when the type is not an update
* @see Type#UPDATE
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-09-10 18:53:32 UTC (rev 1203)
+++ branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/domain/Repository.java 2009-09-10 21:16:23 UTC (rev 1204)
@@ -25,6 +25,7 @@
import net.jcip.annotations.Immutable;
import org.jboss.dna.common.util.CheckArg;
+import org.jboss.dna.common.util.HashCode;
import org.jboss.dna.web.jcr.rest.client.RestClientI18n;
import org.jboss.dna.web.jcr.rest.client.Status;
import org.jboss.dna.web.jcr.rest.client.domain.validation.RepositoryValidator;
@@ -143,10 +144,7 @@
*/
@Override
public int hashCode() {
- int hash = 7;
- hash = 31 * hash + this.name.hashCode();
- hash = 31 * hash + this.server.hashCode();
- return hash;
+ return HashCode.compute(this.name, this.server);
}
/**
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-09-10 18:53:32 UTC (rev 1203)
+++ branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/domain/Server.java 2009-09-10 21:16:23 UTC (rev 1204)
@@ -25,6 +25,7 @@
import net.jcip.annotations.Immutable;
import org.jboss.dna.common.util.CheckArg;
+import org.jboss.dna.common.util.HashCode;
import org.jboss.dna.web.jcr.rest.client.RestClientI18n;
import org.jboss.dna.web.jcr.rest.client.Status;
import org.jboss.dna.web.jcr.rest.client.Utils;
@@ -180,20 +181,7 @@
*/
@Override
public int hashCode() {
- int hash = 7;
- hash = 31 * hash + this.url.hashCode();
-
- if (this.user != null) {
- hash = 31 * hash + this.user.hashCode();
- }
-
- if (this.password != null) {
- hash = 31 * hash + this.password.hashCode();
- }
-
- hash = 31 * hash + Boolean.valueOf(this.persistPassword).hashCode();
-
- return hash;
+ return HashCode.compute(this.url, this.user, this.password, this.persistPassword);
}
/**
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-09-10 18:53:32 UTC (rev 1203)
+++ branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/domain/Workspace.java 2009-09-10 21:16:23 UTC (rev 1204)
@@ -25,6 +25,7 @@
import net.jcip.annotations.Immutable;
import org.jboss.dna.common.util.CheckArg;
+import org.jboss.dna.common.util.HashCode;
import org.jboss.dna.web.jcr.rest.client.RestClientI18n;
import org.jboss.dna.web.jcr.rest.client.Status;
import org.jboss.dna.web.jcr.rest.client.domain.validation.WorkspaceValidator;
@@ -149,10 +150,7 @@
*/
@Override
public int hashCode() {
- int hash = 7;
- hash = 31 * hash + this.name.hashCode();
- hash = 31 * hash + this.repository.hashCode();
- return hash;
+ return HashCode.compute(this.name, this.repository);
}
/**
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-09-10 18:53:32 UTC (rev 1203)
+++ branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/json/FileNode.java 2009-09-10 21:16:23 UTC (rev 1204)
@@ -23,21 +23,16 @@
*/
package org.jboss.dna.web.jcr.rest.client.json;
-import java.io.DataInputStream;
-import java.io.EOFException;
import java.io.File;
import java.io.FileInputStream;
-import java.io.IOException;
import java.net.URL;
import java.text.SimpleDateFormat;
-import java.util.ArrayList;
import java.util.Calendar;
-import java.util.List;
import java.util.TimeZone;
import net.jcip.annotations.Immutable;
import org.codehaus.jettison.json.JSONObject;
+import org.jboss.dna.common.util.Base64;
import org.jboss.dna.common.util.CheckArg;
-import org.jboss.dna.common.util.Logger;
import org.jboss.dna.web.jcr.rest.client.IJcrConstants;
import org.jboss.dna.web.jcr.rest.client.Utils;
import org.jboss.dna.web.jcr.rest.client.domain.Workspace;
@@ -125,7 +120,7 @@
properties.put(IJcrConstants.LAST_MODIFIED, formatter.format(lastModified.getTime()));
// add required jcr:mimeType property (just use a default value)
- properties.put(IJcrConstants.MIME_TYPE, "application/octet-stream"); //$NON-NLS-1$
+ properties.put(IJcrConstants.MIME_TYPE, Utils.getMimeType(file));
}
// ===========================================================================================================================
@@ -140,7 +135,6 @@
*/
@Override
public byte[] getContent() throws Exception {
- // TODO need to figure out how to write binary content to JSONObject
// add required jcr:data property (do this lazily only when the content is requested)
JSONObject children = (JSONObject)get(IJsonConstants.CHILDREN_KEY);
JSONObject kid = (JSONObject)children.get(IJcrConstants.CONTENT_PROPERTY);
@@ -151,6 +145,36 @@
}
/**
+ * Note: Currently used for testing only.
+ *
+ * @param jsonResponse the JSON response obtained from performing a GET using the file content URL
+ * @return the encoded file contents
+ * @throws Exception if there is a problem obtaining the contents
+ * @see #getFileContentsUrl()
+ * @since 0.6
+ */
+ String getFileContents( String jsonResponse ) throws Exception {
+ CheckArg.isNotNull(jsonResponse, "jsonResponse"); //$NON-NLS-1$
+ JSONObject contentNode = new JSONObject(jsonResponse);
+ JSONObject props = (JSONObject)contentNode.get(IJsonConstants.PROPERTIES_KEY);
+ String encodedContents = props.getString(IJcrConstants.DATA_PROPERTY);
+ return encodedContents;
+ }
+
+ /**
+ * Note: Currently used for testing only.
+ *
+ * @return the URL that can be used to obtain the encoded file contents from a workspace
+ * @throws Exception if there is a problem constructing the URL
+ * @since 0.6
+ */
+ URL getFileContentsUrl() throws Exception {
+ StringBuilder url = new StringBuilder(getUrl().toString());
+ url.append('/').append(IJcrConstants.CONTENT_PROPERTY);
+ return new URL(url.toString());
+ }
+
+ /**
* @return the path where the file is or will be published or unpublished
* @since 0.6
*/
@@ -175,32 +199,12 @@
}
/**
- * @return the file content
+ * @return the base 64 encoded file content
* @throws Exception if there is a problem reading the file
* @since 0.6
*/
- private Byte[] readFile() throws Exception {
- DataInputStream is = null;
- List<Byte> bytes = new ArrayList<Byte>(1000);
-
- try {
- is = new DataInputStream(new FileInputStream(this.file.getAbsoluteFile()));
-
- while (true) {
- bytes.add(is.readByte());
- }
- } catch (EOFException e) {
- // nothing to do
- } finally {
- if (is != null) {
- try {
- is.close();
- } catch (IOException e) {
- }
- }
- }
-
- return bytes.toArray(new Byte[(bytes.size())]);
+ String readFile() throws Exception {
+ return Base64.encode(new FileInputStream(this.file.getAbsoluteFile()));
}
}
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-09-10 18:53:32 UTC (rev 1203)
+++ branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/json/FolderNode.java 2009-09-10 21:16:23 UTC (rev 1204)
@@ -27,7 +27,6 @@
import net.jcip.annotations.Immutable;
import org.codehaus.jettison.json.JSONObject;
import org.jboss.dna.common.util.CheckArg;
-import org.jboss.dna.common.util.Logger;
import org.jboss.dna.web.jcr.rest.client.IJcrConstants;
import org.jboss.dna.web.jcr.rest.client.domain.Workspace;
@@ -107,12 +106,12 @@
if (!path.startsWith("/")) { //$NON-NLS-1$
path = '/' + path;
}
-
+
// make sure path does NOT end with a '/'
if (path.endsWith("/")) { //$NON-NLS-1$
path = path.substring(0, path.length() - 1);
}
-
+
// path needs to be encoded
url.append(JsonUtils.encode(path));
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-09-10 18:53:32 UTC (rev 1203)
+++ branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/json/JsonNode.java 2009-09-10 21:16:23 UTC (rev 1204)
@@ -69,7 +69,7 @@
* @since 0.6
*/
public byte[] getContent() throws Exception {
- return toString().getBytes();
+ return super.toString().getBytes();
}
/**
@@ -87,4 +87,26 @@
*/
public abstract URL getUrl() throws Exception;
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.codehaus.jettison.json.JSONObject#toString()
+ * @since 0.6
+ */
+ @Override
+ public String toString() {
+ StringBuilder txt = new StringBuilder();
+ txt.append("ID: ").append(getId()); //$NON-NLS-1$
+ txt.append(", URL: "); //$NON-NLS-1$
+
+ try {
+ txt.append(getUrl());
+ } catch (Exception e) {
+ txt.append("exception obtaining URL"); //$NON-NLS-1$
+ }
+
+ txt.append(", content: ").append(super.toString()); //$NON-NLS-1$
+ return txt.toString();
+ }
+
}
Modified: branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/json/JsonRestClient.java
===================================================================
--- branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/json/JsonRestClient.java 2009-09-10 18:53:32 UTC (rev 1203)
+++ branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/json/JsonRestClient.java 2009-09-10 21:16:23 UTC (rev 1204)
@@ -209,6 +209,28 @@
/**
* {@inheritDoc}
*
+ * @see org.jboss.dna.web.jcr.rest.client.IRestClient#getUrl(java.io.File, java.lang.String,
+ * org.jboss.dna.web.jcr.rest.client.domain.Workspace)
+ * @since 0.6
+ */
+ public URL getUrl( File file,
+ String path,
+ Workspace workspace ) throws Exception {
+ CheckArg.isNotNull(file, "file"); //$NON-NLS-1$
+ CheckArg.isNotNull(path, "path"); //$NON-NLS-1$
+ CheckArg.isNotNull(workspace, "workspace"); //$NON-NLS-1$
+
+ // can't be a directory
+ if (file.isDirectory()) {
+ throw new IllegalArgumentException();
+ }
+
+ return new FileNode(workspace, path, file).getUrl();
+ }
+
+ /**
+ * {@inheritDoc}
+ *
* @see org.jboss.dna.web.jcr.rest.client.IRestClient#getWorkspaces(org.jboss.dna.web.jcr.rest.client.domain.Repository)
* @since 0.6
*/
@@ -250,30 +272,63 @@
URL url,
RequestMethod method ) throws Exception {
this.logger.trace("openConnection: url={0}, method={1}", url, method); //$NON-NLS-1$
- HttpURLConnection connection = (HttpURLConnection)url.openConnection();
- connection.setDoOutput(true);
- String encoding = Base64.encodeBytes((server.getUser() + ':' + server.getPassword()).getBytes());
- connection.setRequestProperty("Authorization", "Basic " + encoding); //$NON-NLS-1$ //$NON-NLS-2$
- connection.setRequestMethod(method.toString());
- connection.setRequestProperty("Content-Type", MediaType.APPLICATION_JSON); //$NON-NLS-1$
- connection.setUseCaches(false);
- return connection;
+
+ try {
+ HttpURLConnection connection = (HttpURLConnection)url.openConnection();
+ connection.setDoOutput(true);
+ String encoding = Base64.encodeBytes((server.getUser() + ':' + server.getPassword()).getBytes());
+ connection.setRequestProperty("Authorization", "Basic " + encoding); //$NON-NLS-1$ //$NON-NLS-2$
+ connection.setRequestMethod(method.toString());
+ connection.setRequestProperty("Content-Type", MediaType.APPLICATION_JSON); //$NON-NLS-1$
+ connection.setUseCaches(false);
+ return connection;
+ } catch (Exception e) {
+ this.logger.trace("openConnection: exception:", e); //$NON-NLS-1$
+ throw e;
+ }
}
/**
+ * Note: Currently used for testing only.
+ *
+ * @param workspace the workspace where the file is published
+ * @param path the path in the workspace where the file is published
+ * @param file the file whose workspace contents are being requested
+ * @return the base 64 encoded file contents or <code>null</code> if file is not found
+ * @throws Exception if there is a problem obtaining the contents
+ * @since 0.6
+ */
+ String getFileContents( Workspace workspace,
+ String path,
+ File file ) throws Exception {
+ FileNode fileNode = new FileNode(workspace, path, file);
+ HttpURLConnection connection = openConnection(workspace.getServer(), fileNode.getFileContentsUrl(), RequestMethod.GET);
+ int responseCode = connection.getResponseCode();
+
+ if (responseCode == HttpURLConnection.HTTP_OK) {
+ String result = JsonUtils.readInputStream(connection);
+ return fileNode.getFileContents(result);
+ }
+
+ return null;
+ }
+
+ /**
* @param server the server where the URL will be used (never <code>null</code>)
* @param url the path being checked (never <code>null</code>)
* @return <code>true</code> if the path exists
* @throws Exception if there is a problem checking the existence of the path
* @since 0.6
*/
- protected boolean pathExists( Server server,
- URL url ) throws Exception {
+ private boolean pathExists( Server server,
+ URL url ) throws Exception {
this.logger.trace("pathExists: url={0}", url); //$NON-NLS-1$
HttpURLConnection connection = openConnection(server, url, RequestMethod.GET);
try {
- return (connection.getResponseCode() == HttpURLConnection.HTTP_OK);
+ int responseCode = connection.getResponseCode();
+ this.logger.trace("pathExists: responseCode={0}", responseCode); //$NON-NLS-1$
+ return (responseCode == HttpURLConnection.HTTP_OK);
} finally {
if (connection != null) {
this.logger.trace("pathExists: leaving"); //$NON-NLS-1$
@@ -294,7 +349,6 @@
String path,
File file ) throws Exception {
FileNode fileNode = new FileNode(workspace, path, file);
- this.logger.trace("pathExists: url={0}", fileNode.getUrl()); //$NON-NLS-1$
return pathExists(workspace.getServer(), fileNode.getUrl());
}
@@ -353,6 +407,7 @@
FileNode fileNode = new FileNode(workspace, path, file);
connection = openConnection(workspace.getServer(), fileNode.getUrl(), RequestMethod.DELETE);
int responseCode = connection.getResponseCode();
+ this.logger.trace("responseCode={0}", responseCode); //$NON-NLS-1$
if (responseCode != HttpURLConnection.HTTP_NO_CONTENT) {
// check to see if the file was never published
@@ -363,13 +418,13 @@
// unexpected result
this.logger.error(RestClientI18n.connectionErrorMsg, responseCode, "unpublish"); //$NON-NLS-1$
- String msg = RestClientI18n.unpublishFailedMsg.text(file.getName(), workspace.getName(), path, responseCode);
+ String msg = RestClientI18n.unpublishFailedMsg.text(file.getName(), workspace.getName(), path);
throw new RuntimeException(msg);
}
return Status.OK_STATUS;
} catch (Exception e) {
- String msg = RestClientI18n.publishFailedMsg.text(workspace.getName(), path, file.getAbsolutePath());
+ String msg = RestClientI18n.unpublishFailedMsg.text(file.getAbsolutePath(), workspace.getName(), path);
return new Status(Severity.ERROR, msg, e);
} finally {
if (connection != null) {
Modified: branches/eclipse/dna-web-jcr-rest-client/src/main/resources/org/jboss/dna/web/jcr/rest/client/RestClientI18n.properties
===================================================================
--- branches/eclipse/dna-web-jcr-rest-client/src/main/resources/org/jboss/dna/web/jcr/rest/client/RestClientI18n.properties 2009-09-10 18:53:32 UTC (rev 1203)
+++ branches/eclipse/dna-web-jcr-rest-client/src/main/resources/org/jboss/dna/web/jcr/rest/client/RestClientI18n.properties 2009-09-10 21:16:23 UTC (rev 1204)
@@ -53,11 +53,11 @@
# JsonRestClient messages
-connectionErrorMsg = response code={0}: {1}
+connectionErrorMsg = response code={0} method={1}
createFileFailedMsg = Creating the "{0}" file node in folder "{1}" in workspace "{2}" failed with HTTP response code of "{3}"
createFolderFailedMsg = Creating the "{0}" folder node in workspace "{1}" failed with HTTP response code of "{2}"
getRepositoriesFailedMsg = Obtaining the repositories from server "{0}" failed with HTTP response code of "{1}"
getWorkspacesFailedMsg = Obtaining the workspaces from repository "{0}" at server "{1}" failed with HTTP response code of "{2}"
publishFailedMsg = Publishing file "{0}" to path "{1}" in workspace "{2}" failed.
-unpublishFailedMsg = The file "{0}" could not be unpublished in workspace "{1}" at path "{2}". The HTTP response code was "{3}".
+unpublishFailedMsg = The file "{0}" could not be unpublished in workspace "{1}" at path "{2}".
unpublishNeverPublishedMsg = The file "{0}" could not be unpublished in workspace "{1}" at path "{2}" because it could not be found.
Modified: branches/eclipse/dna-web-jcr-rest-client/src/test/java/org/jboss/dna/web/jcr/rest/client/MockRestClient.java
===================================================================
--- branches/eclipse/dna-web-jcr-rest-client/src/test/java/org/jboss/dna/web/jcr/rest/client/MockRestClient.java 2009-09-10 18:53:32 UTC (rev 1203)
+++ branches/eclipse/dna-web-jcr-rest-client/src/test/java/org/jboss/dna/web/jcr/rest/client/MockRestClient.java 2009-09-10 21:16:23 UTC (rev 1204)
@@ -24,6 +24,7 @@
package org.jboss.dna.web.jcr.rest.client;
import java.io.File;
+import java.net.URL;
import java.util.Collection;
import org.jboss.dna.web.jcr.rest.client.domain.Repository;
import org.jboss.dna.web.jcr.rest.client.domain.Server;
@@ -49,6 +50,18 @@
public Collection<Repository> getRepositories( Server server ) throws Exception {
return null;
}
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.jboss.dna.web.jcr.rest.client.IRestClient#getUrl(java.io.File, java.lang.String, org.jboss.dna.web.jcr.rest.client.domain.Workspace)
+ * @since 0.6
+ */
+ public URL getUrl( File file,
+ String path,
+ Workspace workspace ) throws Exception {
+ return null;
+ }
/**
* {@inheritDoc}
Modified: branches/eclipse/dna-web-jcr-rest-client/src/test/java/org/jboss/dna/web/jcr/rest/client/RestIntegrationTest.java
===================================================================
--- branches/eclipse/dna-web-jcr-rest-client/src/test/java/org/jboss/dna/web/jcr/rest/client/RestIntegrationTest.java 2009-09-10 18:53:32 UTC (rev 1203)
+++ branches/eclipse/dna-web-jcr-rest-client/src/test/java/org/jboss/dna/web/jcr/rest/client/RestIntegrationTest.java 2009-09-10 21:16:23 UTC (rev 1204)
@@ -82,18 +82,23 @@
// ===========================================================================================================================
@Test
+ public void shouldAllowServerPropertiesToChange() {
+ // TODO implement shouldAllowServerPropertiesToChange()
+ }
+
+// @Test
public void shouldGetRepositories() throws Exception {
Collection<Repository> repositories = this.serverManager.getRepositories(SERVER);
assertThat(repositories.size(), is(1));
}
- @Test
+// @Test
public void shouldGetWorkspaces() throws Exception {
Collection<Workspace> workspaces = this.serverManager.getWorkspaces(REPOSITORY);
assertThat(workspaces.size(), is(1));
}
- @Test
+// @Test
public void shouldPublish() throws Exception {
URL textFile = getClass().getResource(FILE_PATH);
assertThat(textFile, is(notNullValue()));
Modified: branches/eclipse/dna-web-jcr-rest-client/src/test/java/org/jboss/dna/web/jcr/rest/client/json/JsonRestClientTest.java
===================================================================
--- branches/eclipse/dna-web-jcr-rest-client/src/test/java/org/jboss/dna/web/jcr/rest/client/json/JsonRestClientTest.java 2009-09-10 18:53:32 UTC (rev 1203)
+++ branches/eclipse/dna-web-jcr-rest-client/src/test/java/org/jboss/dna/web/jcr/rest/client/json/JsonRestClientTest.java 2009-09-10 21:16:23 UTC (rev 1204)
@@ -42,6 +42,10 @@
/**
* The <code>JsonRestClientTest</code> class is a test class for the {@link JsonRestClient JSON REST client} object.
+ * <p>
+ * One container: mvn -P cargo-1 clean install assembly:assembly
+ * <p>
+ * Two containers: mvn -P cargo-1,cargo-2 clean install assembly:assembly
*
* @since 0.6
*/
@@ -65,6 +69,9 @@
private static final String FILE_PATH = WORKSPACE_PATH + "document.txt"; //$NON-NLS-1$
private static final String BINARY_FILE_PATH = WORKSPACE_PATH + "picture.jpg"; //$NON-NLS-1$
+ private static final String WORKSPACE_UNUSUALPATH = "/myproject/My.Test - Folder/"; //$NON-NLS-1$
+ private static final String FILE_UNUSUALPATH = WORKSPACE_UNUSUALPATH + "Test File_.a-*().txt"; //$NON-NLS-1$
+
// ===========================================================================================================================
// Fields
// ===========================================================================================================================
@@ -108,7 +115,14 @@
@Test
public void shouldNotUnpublishNonexistentFile() throws Exception {
File file = new File("bogusfile"); //$NON-NLS-1$
- assertThat(this.restClient.unpublish(WORKSPACE1, WORKSPACE_PATH, file).isInfo(), is(true));
+ Status status = this.restClient.unpublish(WORKSPACE1, WORKSPACE_PATH, file);
+
+ if (status.isError()) {
+ System.err.println(status.getMessage());
+ status.getException().printStackTrace(System.err);
+ }
+
+ assertThat(status.getMessage(), status.isInfo(), is(true));
}
@Test
@@ -118,18 +132,23 @@
// publish
File file = new File(binaryFile.toURI());
- assertThat(this.restClient.publish(WORKSPACE1, WORKSPACE_PATH, file).isOk(), is(true));
+ Status status = this.restClient.publish(WORKSPACE1, WORKSPACE_PATH, file);
+ if (status.isError()) {
+ System.err.println(status.getMessage());
+ status.getException().printStackTrace(System.err);
+ }
+
+ assertThat(status.isOk(), is(true));
+
// confirm it exists in repository
assertThat(((JsonRestClient)this.restClient).pathExists(WORKSPACE1, WORKSPACE_PATH, file), is(true));
- // TODO: get jcr:data and compare
+ // compare file contents to the contents that have been published
+ String expected = new FileNode(WORKSPACE1, WORKSPACE_PATH, file).readFile();
+ String actual = ((JsonRestClient)this.restClient).getFileContents(WORKSPACE1, WORKSPACE_PATH, file);
+ assertThat(actual, is(expected));
}
-
- @Test
- public void shouldPublishFilesHavingNonLettersNonNumbersInName() {
- // TODO implement shouldPublishFilesHavingNonLettersNonNumbersInName test
- }
@Test
public void shouldPublishTextResource() throws Exception {
@@ -139,15 +158,41 @@
// publish
File file = new File(textFile.toURI());
Status status = this.restClient.publish(WORKSPACE1, WORKSPACE_PATH, file);
+
+ if (status.isError()) {
+ System.err.println(status.getMessage());
+ status.getException().printStackTrace(System.err);
+ }
+
assertThat(status.getMessage(), status.isOk(), is(true));
// confirm it exists in repository
assertThat(((JsonRestClient)this.restClient).pathExists(WORKSPACE1, WORKSPACE_PATH, file), is(true));
+
+ // compare file contents to the contents that have been published
+ String expected = new FileNode(WORKSPACE1, WORKSPACE_PATH, file).readFile();
+ String actual = ((JsonRestClient)this.restClient).getFileContents(WORKSPACE1, WORKSPACE_PATH, file);
+ assertThat(actual, is(expected));
}
-
+
@Test
- public void shouldPublishToDirectoriesHavingNonLettersNonNumbersInName() {
- // TODO implement shouldPublishToDirectoriesHavingNonLettersNonNumbersInName test
+ public void shouldPublishResourcesHavingNonLettersNonNumbersInName() throws Exception {
+ URL textFile = getClass().getResource(FILE_UNUSUALPATH);
+ assertThat(textFile, is(notNullValue()));
+
+ // publish
+ File file = new File(textFile.toURI());
+ Status status = this.restClient.publish(WORKSPACE1, WORKSPACE_UNUSUALPATH, file);
+
+ if (status.isError()) {
+ System.err.println(status.getMessage());
+ status.getException().printStackTrace(System.err);
+ }
+
+ assertThat(status.getMessage(), status.isOk(), is(true));
+
+ // confirm it exists in repository
+ assertThat(((JsonRestClient)this.restClient).pathExists(WORKSPACE1, WORKSPACE_UNUSUALPATH, file), is(true));
}
@Test
@@ -157,8 +202,15 @@
URL textFile = getClass().getResource(FILE_PATH);
File file = new File(textFile.toURI());
- assertThat(this.restClient.unpublish(WORKSPACE1, WORKSPACE_PATH, file).isOk(), is(true));
+ Status status = this.restClient.unpublish(WORKSPACE1, WORKSPACE_PATH, file);
+ if (status.isError()) {
+ System.err.println(status.getMessage());
+ status.getException().printStackTrace(System.err);
+ }
+
+ assertThat(status.isOk(), is(true));
+
// confirm it does not exist in repository
assertThat(((JsonRestClient)this.restClient).pathExists(WORKSPACE1, WORKSPACE_PATH, file), is(false));
}
Added: branches/eclipse/dna-web-jcr-rest-client/src/test/resources/myproject/My.Test - Folder/Test File_.a-*().txt
===================================================================
--- branches/eclipse/dna-web-jcr-rest-client/src/test/resources/myproject/My.Test - Folder/Test File_.a-*().txt (rev 0)
+++ branches/eclipse/dna-web-jcr-rest-client/src/test/resources/myproject/My.Test - Folder/Test File_.a-*().txt 2009-09-10 21:16:23 UTC (rev 1204)
@@ -0,0 +1,174 @@
+Help us improve Wikipedia by supporting it financially.
+Registration for Wikimania 2009 is now open. Learn more.
+
+[Hide] [Help us with translations!]
+Percent-encoding
+From Wikipedia, the free encyclopedia
+Jump to: navigation, search
+ This article includes a list of references, related reading or external links, but its sources remain unclear because it lacks inline citations. Please improve this article by introducing more precise citations where appropriate. (April 2008)
+
+ For the urlencode in mediawiki, see Help:Magic words
+
+Percent-encoding, also known as URL encoding, is a mechanism for encoding information in a Uniform Resource Identifier (URI) under certain circumstances. Although it is known as URL encoding it is, in fact, used more generally within the main Uniform Resource Identifier (URI) set, which includes both Uniform Resource Locator (URL) and Uniform Resource Name (URN). As such it is also used in the preparation of data of the "application/x-www-form-urlencoded" media type, as is often used in email messages and the submission of HTML form data in HTTP requests.
+Contents
+[hide]
+
+ * 1 Percent-encoding in a URI
+ o 1.1 Types of URI characters
+ o 1.2 Percent-encoding reserved characters
+ o 1.3 Percent-encoding unreserved characters
+ o 1.4 Percent-encoding arbitrary data
+ + 1.4.1 Binary data
+ + 1.4.2 Character data
+ o 1.5 Current standard
+ o 1.6 Non-standard implementations
+ * 2 The application/x-www-form-urlencoded type
+ * 3 See also
+ * 4 References
+ * 5 External links
+
+[edit] Percent-encoding in a URI
+
+[edit] Types of URI characters
+
+The characters allowed in a URI are either reserved or unreserved. Reserved characters are those characters that sometimes have special meaning, while unreserved characters have no such meaning. Using percent-encoding, characters which otherwise would not be allowed are represented using allowed characters. The sets of reserved and unreserved characters and the circumstances under which certain reserved characters have special meaning have changed slightly with each revision of specifications that govern URIs and URI schemes.
+RFC 3986 section 2.2 Reserved Characters (January 2005) ! * ' ( ) ; : @ & = + $ , / ? % # [ ]
+RFC 3986 section 2.3 Unreserved Characters (January 2005) A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
+a b c d e f g h i j k l m n o p q r s t u v w x y z
+0 1 2 3 4 5 6 7 8 9 - _ . ~
+
+No other characters are allowed in a URI.
+
+[edit] Percent-encoding reserved characters
+
+When a character from the reserved set (a "reserved character") has special meaning (a "reserved purpose") in a certain context, and a URI scheme says that it is necessary to use that character for some other purpose, then the character must be percent-encoded. Percent-encoding a reserved character involves converting the character to its corresponding byte value in ASCII and then representing that value as a pair of hexadecimal digits. The digits, preceded by a percent sign ("%"), are then used in the URI in place of the reserved character. (For a non-ASCII character, it is typically converted to its byte sequence in UTF-8, and then each byte value is represented as above.)
+
+The reserved character "/", for example, if used in the "path" component of a URI, has the special meaning of being a delimiter between path segments. If, according to a given URI scheme, "/" needs to be in a path segment, then the three characters "%2F" or "%2f" must be used in the segment instead of a raw "/".
+Reserved characters after percent-encoding ! * " ' ( ) ; : @ & = + $ , / ? % # [ ]
+%21 %2A %22 %27 %28 %29 %3B %3A %40 %26 %3D %2B %24 %2C %2F %3F %25 %23 %5B %5D
+
+Reserved characters that have no reserved purpose in a particular context may also be percent-encoded but are not semantically different from those that are not.
+
+In the "query" component of a URI, for example, "/" is still considered a reserved character but it normally has no reserved purpose, unless a particular URI scheme says otherwise. The character does not need to be percent-encoded when it has no reserved purpose.
+
+URIs that differ only by whether a reserved character is percent-encoded or appears literally are normally considered not equivalent (denoting the same resource) unless it can be determined that the reserved characters in question have no reserved purpose. This determination is dependent upon the rules established for reserved characters by individual URI schemes.
+
+[edit] Percent-encoding unreserved characters
+
+Characters from the unreserved set can be percent-encoded in the same way as reserved characters. That is, if a scheme calls for an unreserved character to be used in a URI, either the raw character or its percent-encoded equivalent may be used interchangeably.
+
+URIs that differ only by whether an unreserved character is percent-encoded or appears literally are equivalent by definition, but URI processors, in practice, may not always recognize this equivalence. For example, URI consumers shouldn't treat "%41" differently from "A" or "%7E" differently from "~", but some do. For maximum interoperability, URI producers are discouraged from percent-encoding unreserved characters.
+
+[edit] Percent-encoding arbitrary data
+
+Most URI schemes involve the representation of arbitrary data, such as an IP address or file system path, as components of a URI. URI scheme specifications should, but often don't, provide an explicit mapping between URI characters and all possible data values being represented by those characters.
+
+[edit] Binary data
+
+Since the publication of RFC 1738 in 1994 it has been specified that schemes that provide for the representation of binary data in a URI must divide the data into 8-bit bytes and percent-encode each byte in the same manner as above. Byte value 0F (hexadecimal), for example, should be represented by "%0F", but byte value 41 (hexadecimal) can be represented by "A", or "%41". The use of unencoded characters for alphanumeric and unreserved characters is typically preferred as it results in shorter URLs.
+
+[edit] Character data
+
+The procedure for percent-encoding binary data has often been extrapolated, sometimes inappropriately or without being fully specified, to apply to character-based data. In the World Wide Web's formative years, when dealing with data characters in the ASCII repertoire and using their corresponding bytes in ASCII as the basis for determining percent-encoded sequences, this practice was relatively harmless; it was just assumed that characters and bytes mapped one-to-one and were interchangeable. The need to represent characters outside the ASCII range, however, grew quickly and URI schemes and protocols often failed to provide standard rules for preparing character data for inclusion in a URI. Web applications consequently began using different multi-byte, stateful, and other non-ASCII-compatible encodings as the basis for percent-encoding, leading to ambiguities and difficulty interpreting URIs reliably.
+
+For example, many URI schemes and protocols based on RFCs 1738 and 2396 presume that the data characters will be converted to bytes according to some unspecified character encoding before being represented in a URI by unreserved characters or percent-encoded bytes. If the scheme does not allow the URI to provide a hint as to what encoding was used, or if the encoding conflicts with the use of ASCII to percent-encode reserved and unreserved characters, then the URI cannot be reliably interpreted. Some schemes fail to account for encoding at all, and instead just suggest that data characters map directly to URI characters, which leaves it up to implementations to decide whether and how to percent-encode data characters that are in neither the reserved nor unreserved sets.
+
+[edit] Current standard
+
+The generic URI syntax mandates that new URI schemes that provide for the representation of character data in a URI must, in effect, represent characters from the unreserved set without translation, and should convert all other characters to bytes according to UTF-8, and then percent-encode those values. This requirement was introduced in January 2005 with the publication of RFC 3986. URI schemes introduced before this date are not affected.
+
+Not addressed by the current specification is what to do with encoded character data. For example, in computers, character data manifests in encoded form, at some level, and thus could be treated as either binary data or as character data when being mapped to URI characters. Presumably, it is up to the URI scheme specifications to account for this possibility and require one or the other, but in practice, few, if any, actually do.
+
+[edit] Non-standard implementations
+
+There exists a non-standard encoding for Unicode characters: %uxxxx, where xxxx is a Unicode value represented as four hexadecimal digits. This behavior is not specified by any RFC and has been rejected by the W3C. The third edition of ECMA-262 still includes an escape(string) function that uses this syntax, but also an encodeURI(uri) function that converts to UTF-8 and percent-encodes each octet.
+
+[edit] The application/x-www-form-urlencoded type
+
+When data that has been entered into HTML forms is submitted, the form field names and values are encoded and sent to the server in an HTTP request message using method GET or POST, or, historically, via email.[1] The encoding used by default is based on a very early version of the general URI percent-encoding rules, with a number of modifications such as newline normalization and replacing spaces with "+" instead of "%20". The MIME type of data encoded this way is application/x-www-form-urlencoded, and it is currently defined (still in a very outdated manner) in the HTML and XForms specifications. In addition, the CGI specification contains rules for how web servers decode data of this type and make it available to applications.
+
+When sent in an HTTP GET request, application/x-www-form-urlencoded data is included in the query component of the request URI. When sent in an HTTP POST request or via email, the data is placed in the body of the message, and the name of the media type is included in the message's Content-Type header.
+
+[edit] See also
+
+ * Internationalized Resource Identifier
+ * Punycode
+
+[edit] References
+
+ 1. ^ User-agent support for email based HTML form submission, using a 'mailto' URL as the form action, was proposed in RFC 1867 section 5.6, during the HTML 3.2 era. Various web browsers implemented it by invoking a separate email program or using their own rudimentary SMTP capabilities. Although sometimes unreliable, it was briefly popular as a simple way to transmit form data without involving a web server or CGI scripts.
+
+[edit] External links
+
+The following specifications all discuss and define reserved characters, unreserved characters, and percent-encoding, in some form or other:
+
+ * RFC 3986 / STD 66, the current generic URI syntax specification.
+ * RFC 2396 (obsolete) and RFC 2732 together comprised the previous version of the generic URI syntax specification.
+ * RFC 1738 (mostly obsolete) and RFC 1808 (obsolete), which define URLs.
+ * RFC 1630 (obsolete), the first generic URI syntax specification.
+ * W3C Guidelines on Naming and Addressing: URIs, URLs, ...
+ * W3C explanation of UTF-8 in URIs
+ * W3C HTML form content types
+
+Retrieved from "http://en.wikipedia.org/wiki/Percent-encoding"
+Categories: URI scheme | Internet standards | Binary-to-text encoding formats
+Hidden categories: Articles lacking in-text citations from April 2008
+Views
+
+ * Article
+ * Discussion
+ * Edit this page
+ * History
+
+Personal tools
+
+ * Try Beta
+ * 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
+
+ * Česky
+ * Deutsch
+ * 한국어
+ * Magyar
+ * 日本語
+
+Powered by MediaWiki
+Wikimedia Foundation
+
+ * This page was last modified on 5 August 2009 at 16:59.
+ * Text is available under the Creative Commons Attribution-ShareAlike 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/My.Test - Folder/Test File_.a-*().txt
___________________________________________________________________
Name: svn:mime-type
+ text/plain
14 years, 8 months
DNA SVN: r1203 - trunk/dna-jcr/src/main/java/org/jboss/dna/jcr.
by dna-commits@lists.jboss.org
Author: bcarothers
Date: 2009-09-10 14:53:32 -0400 (Thu, 10 Sep 2009)
New Revision: 1203
Modified:
trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/JcrNodeTypeManager.java
Log:
Made class public so that extra node type registration methods are visible.
Modified: trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/JcrNodeTypeManager.java
===================================================================
--- trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/JcrNodeTypeManager.java 2009-09-10 14:35:50 UTC (rev 1202)
+++ trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/JcrNodeTypeManager.java 2009-09-10 18:53:32 UTC (rev 1203)
@@ -59,7 +59,7 @@
* @see RepositoryNodeTypeManager
*/
@Immutable
-class JcrNodeTypeManager implements NodeTypeManager {
+public class JcrNodeTypeManager implements NodeTypeManager {
private final JcrSession session;
private final RepositoryNodeTypeManager repositoryTypeManager;
14 years, 8 months
DNA SVN: r1202 - trunk/dna-jcr/src/main/java/org/jboss/dna/jcr.
by dna-commits@lists.jboss.org
Author: bcarothers
Date: 2009-09-10 10:35:50 -0400 (Thu, 10 Sep 2009)
New Revision: 1202
Modified:
trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/JcrNodeTypeManager.java
Log:
DNA-516 Reference Guide example that defines node types programmatically has several typos
Applied patch that exposes the RTNM registerNodeTypes(JcrNodeTypeSource) method to users through the JcrNodeTypeManager. The JNTM is the class returned by a call to JcrWorkspace.getNodeTypeManager().
Modified: trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/JcrNodeTypeManager.java
===================================================================
--- trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/JcrNodeTypeManager.java 2009-09-10 13:42:41 UTC (rev 1201)
+++ trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/JcrNodeTypeManager.java 2009-09-10 14:35:50 UTC (rev 1202)
@@ -441,6 +441,37 @@
}
/**
+ * Registers the node types from the given {@code JcrNodeTypeSource}. This method is used to register or update a set of node
+ * types with mutual dependencies. Returns an iterator over the resulting {@code NodeType} objects.
+ * <p>
+ * The effect of the method is "all or nothing"; if an error occurs, no node types are registered or updated.
+ * </p>
+ *
+ * @param source the new node types to register
+ * @return the {@code newly created node types}
+ * @throws InvalidNodeTypeDefinitionException if a {@code NodeTypeDefinition} within the collection is invalid
+ * @throws NodeTypeExistsException if {@code allowUpdate} is false and a {@code NodeTypeDefinition} within the collection
+ * specifies a node type name that already exists
+ * @throws UnsupportedRepositoryOperationException if {@code allowUpdate} is true; DNA does not allow updating node types at
+ * this time.
+ * @throws AccessDeniedException if the current session does not have the {@link JcrSession#DNA_REGISTER_TYPE_PERMISSION
+ * register type permission}.
+ * @throws RepositoryException if another error occurs
+ */
+ public NodeTypeIterator registerNodeTypes( JcrNodeTypeSource source )
+ throws InvalidNodeTypeDefinitionException, NodeTypeExistsException, UnsupportedRepositoryOperationException,
+ AccessDeniedException, RepositoryException {
+
+ try {
+ session.checkPermission((Path)null, JcrSession.DNA_REGISTER_TYPE_PERMISSION);
+ } catch (AccessControlException ace) {
+ throw new AccessDeniedException(ace);
+ }
+
+ return new JcrNodeTypeIterator(this.repositoryTypeManager.registerNodeTypes(source));
+ }
+
+ /**
* Allows the collection of node types to be unregistered if they are not referenced by other node types as supertypes,
* default primary types of child nodes, or required primary types of child nodes.
* <p>
14 years, 8 months
DNA SVN: r1201 - in trunk: docs/reference/src/main/docbook/en-US and 1 other directories.
by dna-commits@lists.jboss.org
Author: rhauch
Date: 2009-09-10 09:42:41 -0400 (Thu, 10 Sep 2009)
New Revision: 1201
Modified:
trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/CndNodeTypeSource.java
trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/NodeTemplateNodeTypeSource.java
trunk/docs/reference/src/main/docbook/en-US/content/jcr/jcr.xml
trunk/docs/reference/src/main/docbook/en-US/custom.dtd
Log:
DNA-516 Reference Guide example that defines node types programmatically has several typos
Corrected the faulty sections, and added a bit more detail to the same sections.
Modified: trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/CndNodeTypeSource.java
===================================================================
--- trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/CndNodeTypeSource.java 2009-09-10 01:13:24 UTC (rev 1200)
+++ trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/CndNodeTypeSource.java 2009-09-10 13:42:41 UTC (rev 1201)
@@ -40,7 +40,7 @@
/**
* Class to parse one or more Compact Node Definition (CND) files containing custom node type definitions into a format that can
- * be registered with the {@link RepositoryNodeTypeManager}.
+ * be registered with the {@link JcrNodeTypeManager}.
* <p>
* The class contains methods for determining whether the CND files were parsed successfully and what errors occurred. Typically,
* the class will be used like this:
@@ -55,7 +55,7 @@
* // Report problems
* }
* else {
- * repositoryNodeTypeManager.registerNodeTypes(nodeTypeSource);
+ * jcrNodeTypeManager.registerNodeTypes(nodeTypeSource);
* }
* }
* catch (IOException ioe) {
Modified: trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/NodeTemplateNodeTypeSource.java
===================================================================
--- trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/NodeTemplateNodeTypeSource.java 2009-09-10 01:13:24 UTC (rev 1200)
+++ trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/NodeTemplateNodeTypeSource.java 2009-09-10 13:42:41 UTC (rev 1201)
@@ -48,7 +48,7 @@
/**
* Class to convert one or more {@link NodeTypeTemplate node type templates} containing custom node type definitions into a format
- * that can be registered with the {@link RepositoryNodeTypeManager}.
+ * that can be registered with the {@link JcrNodeTypeManager}.
* <p>
* As the JSR-283 specification mandates that node type templates be the standard basis for custom type registration, the
* {@link RepositoryNodeTypeManager#registerNodeTypes(java.util.Collection, boolean)} method should be used in preference to
Modified: trunk/docs/reference/src/main/docbook/en-US/content/jcr/jcr.xml
===================================================================
--- trunk/docs/reference/src/main/docbook/en-US/content/jcr/jcr.xml 2009-09-10 01:13:24 UTC (rev 1200)
+++ trunk/docs/reference/src/main/docbook/en-US/content/jcr/jcr.xml 2009-09-10 13:42:41 UTC (rev 1201)
@@ -247,60 +247,66 @@
Both type registration mechanisms are supported equally within JBoss DNA, although the CND approach for defining node types is recommended.
<note>
<para>JBoss DNA also supports defining custom node types to load at startup. This is discussed in more detail
- in the next chapter.
+ in the <link linkend="programmatically_configuring_repositories">previous chapter</link>.
</para>
</note>
</para>
<para>
- Although the JSR-283 specification is not yet final, it does provide a useful means of programatically defining JCR node types. JBoss DNA supports a comparable
- node type definition API that implements the functionality from the specification, albeit with classes in an <code>org.jboss.dna.jcr</code> package. The intent
- is to deprecate these classes and replace their usage with the JSR-283 equivalents after JBoss DNA fully supports in the JSR-283 specification in a future release.
+ Although the JSR-283 specification is not yet final, it does provide a useful means of programmatically defining JCR node types. JBoss DNA supports a comparable
+ node type definition API that implements the functionality from the specification, albeit with interfaces in the <code>org.jboss.dna.jcr.nodetype</code> package.
+ The intent is to deprecate these classes and replace their usage with the JSR-283 equivalents when JBoss DNA fully supports
+ the JSR-283 final adopted specification in a future release.
+ </para>
+ <para>
Node types can be defined like so:
<programlisting>
&Session; session = ... ;
-NodeTypeManager nodeTypeManager = session.getWorkspace().getNodeTypeManager();
+// Obtain the DNA-specific node type manager ...
+&JcrNodeTypeManager; nodeTypeManager = (JcrNodeTypeManager) session.getWorkspace().getNodeTypeManager();
+
// Declare a mixin node type named "searchable" (with no namespace)
-NodeTypeTemplate nodeType = nodeTypeManager.createNodeTypeTemplate();
+&NodeTypeTemplate; nodeType = nodeTypeManager.createNodeTypeTemplate();
nodeType.setName("searchable");
nodeType.setMixin(true);
-nodeType.getNodeDefinitionTemplates().add(childNode);
// Add a mandatory child named "source" with a required primary type of "nt:file"
-NodeDefinitionTemplate childNode = nodeTypeManager.createNodeDefinitionTemplate();
+&NodeDefinitionTemplate; childNode = nodeTypeManager.createNodeDefinitionTemplate();
childNode.setName("source");
childNode.setMandatory(true);
-childNode.setRequiredPrimaryTypeNames(new String[] { "nt:file" });
+childNode.setRequiredPrimaryTypes(new String[] { "nt:file" });
childNode.setDefaultPrimaryType("nt:file");
+nodeType.getNodeDefinitionTemplates().add(childNode);
// Add a multi-valued STRING property named "keywords"
-PropertyDefinitionTemplate property = nodeTypeManager.createPropertyDefinitionTemplate();
+&PropertyDefinitionTemplate; property = nodeTypeManager.createPropertyDefinitionTemplate();
property.setName("keywords");
property.setMultiple(true);
property.setRequiredType(PropertyType.STRING);
nodeType.getPropertyDefinitionTemplates().add(property);
// Register the custom node type
-nodeTypeManager.registerNodeType(nodeType);
+nodeTypeManager.registerNodeType(nodeType,false);
</programlisting>
Residual properties and child node definitions can also be defined simply by not calling <code>setName</code> on
the template.
</para>
<para>
Custom node types can be defined more succinctly through the &CND; file format. In fact, this is how JBoss
- DNA defines its built-in node types. An example CND file that declares the same node type as above would be:
+ DNA defines its built-in node types. An example CND file that declares the same node type as above would be:
<programlisting>
[searchable] mixin
- keywords (string) multiple
+ source (nt:file) = nt:file
</programlisting>
- This definition could then be registered with the following code snippet.
+ This definition could then be registered as part of the repository configuration, using the &JcrConfiguration; class
+ (see the <link linkend="programmatically_configuring_repositories">previous chapter</link>). Or, you can also
+ use a Session to declare the node types in a CDN file, but this also requires DNA-specific interfaces and classes:
<programlisting>
-
String pathToCndFileInClassLoader = ...;
-CndNodeTypeSource nodeTypeSource = new CndNodeTypeSource(pathToCndFileInClassLoader);
+&CndNodeTypeSource; nodeTypeSource = new &CndNodeTypeSource;(pathToCndFileInClassLoader);
-for (Problem problem : nodeTypeSource.getProblems()) {
+for (&Problem; problem : nodeTypeSource.getProblems()) {
System.err.println(problem);
}
if (!nodeTypeSource.isValid()) {
@@ -308,9 +314,12 @@
}
&Session; session = ... ;
-NodeTypeManager nodeTypeManager = session.getWorkspace().getNodeTypeManager();
+// Obtain the DNA-specific node type manager ...
+&JcrNodeTypeManager; nodeTypeManager = (JcrNodeTypeManager) session.getWorkspace().getNodeTypeManager();
nodeTypeManager.registerNodeTypes(nodeTypeSource);
</programlisting>
+ The &CndNodeTypeSource; class actually implements the &JcrNodeTypeSource; interface, so other implementations can actually be defined.
+ For more information, see the JavaDoc for &JcrNodeTypeSource;.
<note>
<para> JBoss DNA does not yet support a simple means of unregistering types at this time, so be careful before registering types outside of a
sandboxed environment.
Modified: trunk/docs/reference/src/main/docbook/en-US/custom.dtd
===================================================================
--- trunk/docs/reference/src/main/docbook/en-US/custom.dtd 2009-09-10 01:13:24 UTC (rev 1200)
+++ trunk/docs/reference/src/main/docbook/en-US/custom.dtd 2009-09-10 13:42:41 UTC (rev 1201)
@@ -180,6 +180,13 @@
<!ENTITY JcrRepository "<ulink url='&API;jcr/JcrRepository.html'><classname>JcrRepository</classname></ulink>">
<!ENTITY JcrSession "<ulink url='&API;jcr/JcrSession.html'><classname>JcrSession</classname></ulink>">
<!ENTITY SecurityContextCredentials "<ulink url='&API;jcr/SecurityContextCredentials.html'><classname>SecurityContextCredentials</classname></ulink>">
+<!ENTITY JcrNodeTypeManager "<ulink url='&API;jcr/JcrNodeTypeManager.html'><classname>JcrNodeTypeManager</classname></ulink>">
+<!ENTITY NodeTypeTemplate "<ulink url='&API;jcr/nodetype/NodeTypeTemplate.html'><interface>NodeTypeTemplate</interface></ulink>">
+<!ENTITY PropertyDefinitionTemplate "<ulink url='&API;jcr/nodetype/PropertyDefinitionTemplate.html'><interface>PropertyDefinitionTemplate</interface></ulink>">
+<!ENTITY NodeDefinitionTemplate "<ulink url='&API;jcr/nodetype/NodeDefinitionTemplate.html'><interface>NodeDefinitionTemplate</interface></ulink>">
+<!ENTITY NodeTypeDefinition "<ulink url='&API;jcr/nodetype/NodeTypeDefinition.html'><interface>NodeTypeDefinition</interface></ulink>">
+<!ENTITY JcrNodeTypeSource "<ulink url='&API;jcr/JcrNodeTypeSource.html'><interface>JcrNodeTypeSource</interface></ulink>">
+<!ENTITY CndNodeTypeSource "<ulink url='&API;jcr/CndNodeTypeSource.html'><classname>CndNodeTypeSource</classname></ulink>">
<!-- Types in extensions/ -->
14 years, 8 months
DNA SVN: r1200 - trunk/extensions/dna-web-jcr-rest-war/src/test/java/org/jboss/dna/web/jcr/rest.
by dna-commits@lists.jboss.org
Author: rhauch
Date: 2009-09-09 21:13:24 -0400 (Wed, 09 Sep 2009)
New Revision: 1200
Modified:
trunk/extensions/dna-web-jcr-rest-war/src/test/java/org/jboss/dna/web/jcr/rest/JcrResourcesTest.java
Log:
DNA-513 REST server does not correctly encode binary values
Corrected a (stupidly) wrong import of Base64.
Modified: trunk/extensions/dna-web-jcr-rest-war/src/test/java/org/jboss/dna/web/jcr/rest/JcrResourcesTest.java
===================================================================
--- trunk/extensions/dna-web-jcr-rest-war/src/test/java/org/jboss/dna/web/jcr/rest/JcrResourcesTest.java 2009-09-10 00:02:49 UTC (rev 1199)
+++ trunk/extensions/dna-web-jcr-rest-war/src/test/java/org/jboss/dna/web/jcr/rest/JcrResourcesTest.java 2009-09-10 01:13:24 UTC (rev 1200)
@@ -39,9 +39,9 @@
import javax.ws.rs.core.MediaType;
import org.codehaus.jettison.json.JSONArray;
import org.codehaus.jettison.json.JSONObject;
+import org.jboss.dna.common.util.Base64;
import org.junit.Before;
import org.junit.Test;
-import com.sun.org.apache.xml.internal.security.utils.Base64;
/**
* Test of the DNA JCR REST resource. Note that this test case uses a very low-level API to construct requests and deconstruct the
@@ -791,7 +791,7 @@
connection.setRequestProperty("Content-Type", MediaType.APPLICATION_JSON);
// Base64-encode a value ...
- String encodedValue = Base64.encode("propertyValue".getBytes("UTF-8"));
+ String encodedValue = Base64.encodeBytes("propertyValue".getBytes("UTF-8"));
String payload = "{ \"properties\": {\"jcr:primaryType\": \"nt:unstructured\", \"testProperty/base64/\": \""
+ encodedValue + "\" }}";
@@ -808,7 +808,7 @@
connection.setRequestProperty("Content-Type", MediaType.APPLICATION_JSON);
String otherValue = "someOtherValue";
- payload = "{\"testProperty/base64/\":\"" + Base64.encode(otherValue.getBytes("UTF-8")) + "\"}";
+ payload = "{\"testProperty/base64/\":\"" + Base64.encodeBytes(otherValue.getBytes("UTF-8")) + "\"}";
connection.getOutputStream().write(payload.getBytes());
JSONObject body = new JSONObject(getResponseFor(connection));
14 years, 8 months
DNA SVN: r1199 - trunk/extensions/dna-web-jcr-rest/src/main/java/org/jboss/dna/web/jcr/rest.
by dna-commits@lists.jboss.org
Author: rhauch
Date: 2009-09-09 20:02:49 -0400 (Wed, 09 Sep 2009)
New Revision: 1199
Modified:
trunk/extensions/dna-web-jcr-rest/src/main/java/org/jboss/dna/web/jcr/rest/JcrResources.java
Log:
DNA-513 REST server does not correctly encode binary values
Changed the JcrResources class to have the '/base64/' string in a constant.
Modified: trunk/extensions/dna-web-jcr-rest/src/main/java/org/jboss/dna/web/jcr/rest/JcrResources.java
===================================================================
--- trunk/extensions/dna-web-jcr-rest/src/main/java/org/jboss/dna/web/jcr/rest/JcrResources.java 2009-09-10 00:02:26 UTC (rev 1198)
+++ trunk/extensions/dna-web-jcr-rest/src/main/java/org/jboss/dna/web/jcr/rest/JcrResources.java 2009-09-10 00:02:49 UTC (rev 1199)
@@ -157,6 +157,8 @@
@Path( "/" )
public class JcrResources {
+ private static final String BASE64_ENCODING_SUFFIX = "/base64/";
+
private static final UrlEncoder URL_ENCODER = new UrlEncoder();
private static final String PROPERTIES_HOLDER = "properties";
@@ -352,7 +354,7 @@
valueObject = encoded ? jsonEncodedStringFor(value) : value.getString();
}
String propertyName = property.getName();
- if (encoded) propertyName = propertyName + "/base64/";
+ if (encoded) propertyName = propertyName + BASE64_ENCODING_SUFFIX;
JSONObject jsonProperty = new JSONObject();
jsonProperty.put(propertyName, valueObject);
return jsonProperty;
@@ -414,7 +416,7 @@
break;
}
}
- if (encoded) propName = propName + "/base64/";
+ if (encoded) propName = propName + BASE64_ENCODING_SUFFIX;
JSONArray array = new JSONArray();
for (int i = 0; i < values.length; i++) {
array.put(encoded ? jsonEncodedStringFor(values[i]) : values[i].getString());
@@ -424,7 +426,7 @@
} else {
Value value = prop.getValue();
encoded = value.getType() == PropertyType.BINARY;
- if (encoded) propName = propName + "/base64/";
+ if (encoded) propName = propName + BASE64_ENCODING_SUFFIX;
properties.put(propName, encoded ? jsonEncodedStringFor(value) : value.getString());
}
@@ -605,9 +607,9 @@
String propName,
Object value ) throws RepositoryException, JSONException {
// Are the property values encoded ?
- boolean encoded = propName.endsWith("/base64/");
+ boolean encoded = propName.endsWith(BASE64_ENCODING_SUFFIX);
if (encoded) {
- int newLength = propName.length() - "/base64/".length();
+ int newLength = propName.length() - BASE64_ENCODING_SUFFIX.length();
propName = newLength > 0 ? propName.substring(0, newLength) : "";
}
@@ -767,7 +769,7 @@
Property property = (Property)item;
String propertyName = property.getName();
JSONObject jsonProperty = new JSONObject(requestContent);
- String jsonPropertyName = jsonProperty.has(propertyName) ? propertyName : propertyName + "/base64/";
+ String jsonPropertyName = jsonProperty.has(propertyName) ? propertyName : propertyName + BASE64_ENCODING_SUFFIX;
node = property.getParent();
setPropertyOnNode(node, jsonPropertyName, jsonProperty.get(jsonPropertyName));
}
14 years, 8 months
DNA SVN: r1198 - in trunk: dna-common/src/test/java/org/jboss/dna/common/util and 2 other directories.
by dna-commits@lists.jboss.org
Author: rhauch
Date: 2009-09-09 20:02:26 -0400 (Wed, 09 Sep 2009)
New Revision: 1198
Modified:
trunk/dna-common/src/main/java/org/jboss/dna/common/util/Base64.java
trunk/dna-common/src/test/java/org/jboss/dna/common/util/Base64Test.java
trunk/extensions/dna-web-jcr-rest-war/src/test/java/org/jboss/dna/web/jcr/rest/JcrResourcesTest.java
trunk/extensions/dna-web-jcr-rest/src/main/java/org/jboss/dna/web/jcr/rest/JcrResources.java
Log:
DNA-513 REST server does not correctly encode binary values
The new approach is used, where the JSON representation of a property that has binary values has the property name annotated/suffixed with '/base64/'. Also, the PUT/GET property request and response representations were modified to include the name and the value(s). Previously, the PUT request and GET response only included the value (or values), but this didn't allow the sender to say whether the property values were Base64 encoded. I considered using 'Content-Transfer-Encoding' header (with value of 'base64'), but that pretty much means the entire body is encoded. Works great for PUT/GET with a single property value, but breaks down with an array (since the '[', ',' and ']' characters aren't encoded.
A few test methods were added, and the changes appear to work. However, before committing, I'd like some verification that this patch goes in the right direction.
Modified: trunk/dna-common/src/main/java/org/jboss/dna/common/util/Base64.java
===================================================================
--- trunk/dna-common/src/main/java/org/jboss/dna/common/util/Base64.java 2009-09-09 21:27:02 UTC (rev 1197)
+++ trunk/dna-common/src/main/java/org/jboss/dna/common/util/Base64.java 2009-09-10 00:02:26 UTC (rev 1198)
@@ -671,6 +671,75 @@
}
+ /**
+ * Encodes content of the supplied InputStream into Base64 notation. Does not GZip-compress data.
+ *
+ * @param source The data to convert
+ * @return the encoded bytes
+ */
+ public static String encode( java.io.InputStream source ) {
+ return encode(source, NO_OPTIONS);
+ }
+
+ /**
+ * Encodes the content of the supplied InputStream into Base64 notation.
+ * <p>
+ * Valid options:
+ *
+ * <pre>
+ * GZIP: gzip-compresses object before encoding it.
+ * DONT_BREAK_LINES: don't break lines at 76 characters
+ * <i>Note: Technically, this makes your encoding non-compliant.</i>
+ * </pre>
+ * <p>
+ * Example: <code>encodeBytes( myData, Base64.GZIP )</code> or
+ * <p>
+ * Example: <code>encodeBytes( myData, Base64.GZIP | Base64.DONT_BREAK_LINES )</code>
+ *
+ * @param source The data to convert
+ * @param options Specified options- the alphabet type is pulled from this (standard, url-safe, ordered)
+ * @return the encoded bytes
+ * @see Base64#GZIP
+ * @see Base64#DONT_BREAK_LINES
+ */
+ public static String encode( java.io.InputStream source,
+ int options ) {
+ CheckArg.isNotNull(source, "source");
+ java.io.ByteArrayOutputStream baos = new java.io.ByteArrayOutputStream();
+ Base64.OutputStream b64os = new Base64.OutputStream(baos, ENCODE | options);
+ BufferedInputStream input = new BufferedInputStream(source);
+ java.io.OutputStream output = b64os;
+
+ boolean error = false;
+ try {
+ if ((options & GZIP) == GZIP) {
+ output = new java.util.zip.GZIPOutputStream(output);
+ }
+ int numRead = 0;
+ byte[] buffer = new byte[1024];
+ while ((numRead = input.read(buffer)) > -1) {
+ output.write(buffer, 0, numRead);
+ }
+ output.close();
+ } catch (IOException e) {
+ error = true;
+ throw new SystemFailureException(e); // error using reading from byte array!
+ } finally {
+ try {
+ input.close();
+ } catch (IOException e) {
+ if (!error) new SystemFailureException(e); // error closing input stream
+ }
+ }
+
+ // Return value according to relevant encoding.
+ try {
+ return new String(baos.toByteArray(), PREFERRED_ENCODING);
+ } catch (java.io.UnsupportedEncodingException uue) {
+ return new String(baos.toByteArray());
+ }
+ }
+
/* ******** D E C O D I N G M E T H O D S ******** */
/**
Modified: trunk/dna-common/src/test/java/org/jboss/dna/common/util/Base64Test.java
===================================================================
--- trunk/dna-common/src/test/java/org/jboss/dna/common/util/Base64Test.java 2009-09-09 21:27:02 UTC (rev 1197)
+++ trunk/dna-common/src/test/java/org/jboss/dna/common/util/Base64Test.java 2009-09-10 00:02:26 UTC (rev 1198)
@@ -26,6 +26,9 @@
import static org.hamcrest.core.Is.is;
import static org.hamcrest.core.IsNull.notNullValue;
import static org.junit.Assert.assertThat;
+import java.io.ByteArrayInputStream;
+import java.io.InputStream;
+import java.io.UnsupportedEncodingException;
import org.junit.Test;
/**
@@ -68,6 +71,28 @@
System.out.println();
}
+ @Test
+ public void shouldEncodeStringValue() throws UnsupportedEncodingException {
+ String actualValue = "propertyValue";
+ String encoded = Base64.encodeBytes(actualValue.getBytes("UTF-8"));
+ byte[] decoded = Base64.decode(encoded);
+ String decodedValue = new String(decoded, "UTF-8");
+ assertThat(decodedValue, is(actualValue));
+ }
+
+ @Test
+ public void shouldEncodeStreamableValue() {
+ String actualValue = "propertyValue";
+ byte[] actualBytes = actualValue.getBytes();
+ InputStream actualStream = new ByteArrayInputStream(actualBytes);
+ String encoded = Base64.encode(actualStream);
+ String encoded2 = Base64.encodeBytes(actualBytes);
+ assertThat(encoded, is(encoded2));
+ byte[] decoded = Base64.decode(encoded);
+ String decodedValue = new String(decoded);
+ assertThat(decodedValue, is(actualValue));
+ }
+
@Test( expected = NullPointerException.class )
public void testEncodeNullByteArray() {
Base64.encodeBytes(null);
Modified: trunk/extensions/dna-web-jcr-rest/src/main/java/org/jboss/dna/web/jcr/rest/JcrResources.java
===================================================================
--- trunk/extensions/dna-web-jcr-rest/src/main/java/org/jboss/dna/web/jcr/rest/JcrResources.java 2009-09-09 21:27:02 UTC (rev 1197)
+++ trunk/extensions/dna-web-jcr-rest/src/main/java/org/jboss/dna/web/jcr/rest/JcrResources.java 2009-09-10 00:02:26 UTC (rev 1198)
@@ -23,9 +23,10 @@
*/
package org.jboss.dna.web.jcr.rest;
+import java.io.ByteArrayInputStream;
import java.io.IOException;
+import java.io.InputStream;
import java.util.ArrayList;
-import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
@@ -38,9 +39,11 @@
import javax.jcr.PathNotFoundException;
import javax.jcr.Property;
import javax.jcr.PropertyIterator;
+import javax.jcr.PropertyType;
import javax.jcr.RepositoryException;
import javax.jcr.Session;
import javax.jcr.Value;
+import javax.jcr.ValueFactory;
import javax.jcr.nodetype.NodeType;
import javax.jcr.nodetype.PropertyDefinition;
import javax.servlet.http.HttpServletRequest;
@@ -64,6 +67,7 @@
import org.codehaus.jettison.json.JSONException;
import org.codehaus.jettison.json.JSONObject;
import org.jboss.dna.common.text.UrlEncoder;
+import org.jboss.dna.common.util.Base64;
import org.jboss.dna.web.jcr.rest.model.RepositoryEntry;
import org.jboss.dna.web.jcr.rest.model.WorkspaceEntry;
import org.jboss.resteasy.spi.NotFoundException;
@@ -99,6 +103,55 @@
* <td>ALL</td>
* </tr>
* </table>
+ * <h3>Binary data</h3>
+ * <p>
+ * There are several ways to transfer binary property values, but all involve encoding the binary value into ASCII characters
+ * using a {@link Base64} notation and denoting this by adding annotating the property name with a suffix defining the type of
+ * encoding. Currently, only "base64" encoding is supported.
+ * </p>
+ * <p>
+ * For example, if the "jcr:data" property contains a single binary value of "propertyValue", then the JSON object representing
+ * that property will be:
+ *
+ * <pre>
+ * "jcr:data/base64/" : "cHJvcGVydHlWYWx1ZQ=="
+ * </pre>
+ *
+ * Likewise, if the "jcr:data" property contains two binary values each being "propertyValue", then the JSON object representing
+ * that property will be:
+ *
+ * <pre>
+ * "jcr:data/base64/" : [ "cHJvcGVydHlWYWx1ZQ==", "cHJvcGVydHlWYWx1ZQ==" ]
+ * </pre>
+ *
+ * Note that JCR 1.0.1 does not allow property names to and with a '/' character (among others), while JCR 2.0 does not allow
+ * property names to contain an unescaped or unencoded '/' character. Therefore, the "/{encoding}/" suffix can never appear in a
+ * valid JCR property name, and will always identify an encoded property.
+ * </p>
+ * <p>
+ * Here are the details:
+ * <ul>
+ * <li>Getting a node with <code>GET /resources/{repositoryName}/item/{pathToNode}</code> obtains the JSON object representing the
+ * node, and each property is represented as a nested JSON object where the name is the property name and the value(s) are
+ * represented as either a single string value or an array of string values. If the property has a binary value, then the property
+ * name is appended with "/base64/" and the string representation of each value is encoded in Base64.</li>
+ * <li>Getting a property with <code>GET /resources/{repositoryName}/item/{pathToProperty}</code> allows only the value(s) for the
+ * one property to be included in the response. If any of the values is a binary value, then <i>all</i> of the values will be
+ * encoded in Base64.</li>
+ * <li>Setting a property with <code>PUT /resources/{repositoryName}/item/{pathToProperty}</code> allows setting the property to a
+ * single value, and only that value needs to be included in the body of the request. If the value is binary, the value
+ * <i>must</i> be {@link Base64 encoded} by the client and the "Content-Transfer-Encoding" header must be set to "base64" (case
+ * does not matter). When the request is received, the value is decoded before the property value is updated on the node.</li>
+ * <li>Creating a node with <code>POST /resources/{repositoryName}/item/{pathToNode}</code> requires a request that is structured
+ * in the same way as the response from getting a node: the resulting JSON object represents the node, with nested JSON objects
+ * for the properties and children. If any property of the new node has a binary value, then the name of the property <i>must</i>
+ * be appended with "/base64/" and the string representation of each value are to be encoded in Base64.</li>
+ * <li>Updating a node with <code>PUT /resources/{repositoryName}/item/{pathToNode}</code> requires a request that is structured
+ * in the same way as the response from getting or posting a node: the resulting JSON object represents the node, with nested JSON
+ * objects for the properties and children. If any property of the new node has a binary value, then the name of the property
+ * <i>must</i> be appended with "/base64/" and the string representation of each value are to be encoded in Base64.</li>
+ * </ul>
+ * </p>
*/
@Immutable
@Path( "/" )
@@ -251,33 +304,87 @@
if (item instanceof Node) {
return jsonFor((Node)item, depth).toString();
}
- return jsonFor((Property)item);
+ return jsonFor((Property)item).toString();
}
/**
- * Returns the JSON-encoded version of the given property. If the property is single-valued, the returned string is {@code
- * property.getValue().getString()} encoded as a JSON string. If the property is multi-valued with {@code N} values, this
- * method returns a JSON array containing {@code property.getValues()[N].getString()} for all values of {@code N}.
+ * Returns the JSON-encoded version of the given property. If the property is single-valued, the returned string is the value
+ * of the property encoded as a JSON string, including the name. If the property is multi-valued with {@code N} values, this
+ * method returns a JSON array containing the JSON string for each value.
+ * <p>
+ * Note that if any of the values are binary, then <i>all</i> values will be first encoded as {@link Base64} string values.
+ * However, if no values are binary, then all values will simply be the {@link Value#getString() string} representation of the
+ * value.
+ * </p>
*
* @param property the property to be encoded
* @return the JSON-encoded version of the property
+ * @throws JSONException if there is an error encoding the node
* @throws RepositoryException if an error occurs accessing the property, its values, or its definition.
* @see Property#getDefinition()
* @see PropertyDefinition#isMultiple()
*/
- private String jsonFor( Property property ) throws RepositoryException {
+ private JSONObject jsonFor( Property property ) throws JSONException, RepositoryException {
+ boolean encoded = false;
+ Object valueObject = null;
if (property.getDefinition().isMultiple()) {
Value[] values = property.getValues();
+ for (Value value : values) {
+ if (value.getType() == PropertyType.BINARY) {
+ encoded = true;
+ break;
+ }
+ }
List<String> list = new ArrayList<String>(values.length);
- for (int i = 0; i < values.length; i++) {
- list.add(values[i].getString());
+ if (encoded) {
+ for (Value value : values) {
+ list.add(jsonEncodedStringFor(value));
+ }
+ } else {
+ for (Value value : values) {
+ list.add(value.getString());
+ }
}
- return new JSONArray(list).toString();
+ valueObject = new JSONArray(list);
+ } else {
+ Value value = property.getValue();
+ encoded = value.getType() == PropertyType.BINARY;
+ valueObject = encoded ? jsonEncodedStringFor(value) : value.getString();
}
- return JSONObject.quote(property.getValue().getString());
+ String propertyName = property.getName();
+ if (encoded) propertyName = propertyName + "/base64/";
+ JSONObject jsonProperty = new JSONObject();
+ jsonProperty.put(propertyName, valueObject);
+ return jsonProperty;
}
/**
+ * Return the JSON-compatible string representation of the given property value. If the value is a {@link PropertyType#BINARY
+ * binary} value, then this method returns the Base-64 encoding of that value. Otherwise, it just returns the string
+ * representation of the value.
+ *
+ * @param value the property value; may not be null
+ * @return the string representation of the value
+ * @throws RepositoryException if there is a problem accessing the value
+ */
+ private String jsonEncodedStringFor( Value value ) throws RepositoryException {
+ // Encode the binary value in Base64 ...
+ InputStream stream = value.getStream();
+ try {
+ return Base64.encode(stream);
+ } finally {
+ if (stream != null) {
+ try {
+ stream.close();
+ } catch (IOException e) {
+ // Error accessing the value, so throw this ...
+ throw new RepositoryException(e);
+ }
+ }
+ }
+ }
+
+ /**
* Recursively returns the JSON-encoding of a node and its children to depth {@code toDepth}.
*
* @param node the node to be encoded
@@ -296,16 +403,29 @@
Property prop = iter.nextProperty();
String propName = prop.getName();
+ boolean encoded = false;
+
if (prop.getDefinition().isMultiple()) {
Value[] values = prop.getValues();
+ // Do any of the property values need to be encoded ?
+ for (Value value : values) {
+ if (value.getType() == PropertyType.BINARY) {
+ encoded = true;
+ break;
+ }
+ }
+ if (encoded) propName = propName + "/base64/";
JSONArray array = new JSONArray();
for (int i = 0; i < values.length; i++) {
- array.put(values[i].getString());
+ array.put(encoded ? jsonEncodedStringFor(values[i]) : values[i].getString());
}
properties.put(propName, array);
} else {
- properties.put(propName, prop.getValue().getString());
+ Value value = prop.getValue();
+ encoded = value.getType() == PropertyType.BINARY;
+ if (encoded) propName = propName + "/base64/";
+ properties.put(propName, encoded ? jsonEncodedStringFor(value) : value.getString());
}
}
@@ -454,6 +574,22 @@
return newNode;
}
+ private Value decodeValue( String encodedValue,
+ ValueFactory valueFactory ) throws RepositoryException {
+ byte[] binaryValue = Base64.decode(encodedValue);
+ InputStream stream = new ByteArrayInputStream(binaryValue);
+ try {
+ return valueFactory.createValue(stream);
+ } finally {
+ try {
+ stream.close();
+ } catch (IOException e) {
+ // Error accessing the value, so throw this ...
+ throw new RepositoryException(e);
+ }
+ }
+ }
+
/**
* Sets the named property on the given node. This method expects {@code value} to be either a JSON string or a JSON array of
* JSON strings. If {@code value} is a JSON array, {@code Node#setProperty(String, String[]) the multi-valued property setter}
@@ -468,20 +604,41 @@
private void setPropertyOnNode( Node node,
String propName,
Object value ) throws RepositoryException, JSONException {
- String[] values;
+ // Are the property values encoded ?
+ boolean encoded = propName.endsWith("/base64/");
+ if (encoded) {
+ int newLength = propName.length() - "/base64/".length();
+ propName = newLength > 0 ? propName.substring(0, newLength) : "";
+ }
+
+ Value[] values;
+ ValueFactory valueFactory = node.getSession().getValueFactory();
if (value instanceof JSONArray) {
JSONArray jsonValues = (JSONArray)value;
- values = new String[jsonValues.length()];
+ values = new Value[jsonValues.length()];
for (int i = 0; i < values.length; i++) {
- values[i] = jsonValues.getString(i);
+ String strValue = jsonValues.getString(i);
+ if (encoded) {
+ values[i] = decodeValue(strValue, valueFactory);
+ } else {
+ values[i] = valueFactory.createValue(strValue);
+ }
}
} else {
- values = new String[] {(String)value};
+ String strValue = (String)value;
+ if (encoded) {
+ values = new Value[] {decodeValue(strValue, valueFactory)};
+ } else {
+ values = new Value[] {valueFactory.createValue(strValue)};
+ }
}
if (propName.equals(JcrResources.MIXIN_TYPES_PROPERTY)) {
- Set<String> toBeMixins = new HashSet<String>(Arrays.asList(values));
+ Set<String> toBeMixins = new HashSet<String>();
+ for (Value theValue : values) {
+ toBeMixins.add(theValue.getString());
+ }
Set<String> asIsMixins = new HashSet<String>();
for (NodeType nodeType : node.getMixinNodeTypes()) {
@@ -564,6 +721,7 @@
* @throws UnauthorizedException if the user does not have the access required to create the node at this path
* @throws JSONException if there is an error encoding the node
* @throws RepositoryException if any other error occurs
+ * @throws IOException if there is a problem reading the value
*/
@PUT
@Path( "/{repositoryName}/{workspaceName}/items{path:.*}" )
@@ -572,7 +730,7 @@
@PathParam( "repositoryName" ) String rawRepositoryName,
@PathParam( "workspaceName" ) String rawWorkspaceName,
@PathParam( "path" ) String path,
- String requestContent ) throws UnauthorizedException, JSONException, RepositoryException {
+ String requestContent ) throws UnauthorizedException, JSONException, RepositoryException, IOException {
assert path != null;
assert rawRepositoryName != null;
@@ -603,14 +761,15 @@
} else {
/*
- * The incoming content should be a JSON string or a JSON array. Wrap it into an object so it can be parsed more easily
+ * The incoming content should be a JSON object containing the property name and a value that is either a JSON
+ * string or a JSON array.
*/
-
- JSONObject properties = new JSONObject("{ \"value\": " + requestContent + "}");
Property property = (Property)item;
+ String propertyName = property.getName();
+ JSONObject jsonProperty = new JSONObject(requestContent);
+ String jsonPropertyName = jsonProperty.has(propertyName) ? propertyName : propertyName + "/base64/";
node = property.getParent();
-
- setPropertyOnNode(node, property.getName(), properties.get("value"));
+ setPropertyOnNode(node, jsonPropertyName, jsonProperty.get(jsonPropertyName));
}
node.save();
return jsonFor(node, 0).toString();
Modified: trunk/extensions/dna-web-jcr-rest-war/src/test/java/org/jboss/dna/web/jcr/rest/JcrResourcesTest.java
===================================================================
--- trunk/extensions/dna-web-jcr-rest-war/src/test/java/org/jboss/dna/web/jcr/rest/JcrResourcesTest.java 2009-09-09 21:27:02 UTC (rev 1197)
+++ trunk/extensions/dna-web-jcr-rest-war/src/test/java/org/jboss/dna/web/jcr/rest/JcrResourcesTest.java 2009-09-10 00:02:26 UTC (rev 1198)
@@ -41,12 +41,11 @@
import org.codehaus.jettison.json.JSONObject;
import org.junit.Before;
import org.junit.Test;
+import com.sun.org.apache.xml.internal.security.utils.Base64;
/**
- * Test of the DNA JCR REST resource. Note that this test case uses a very low-level API to construct
- * requests and deconstruct the responses. Users are encouraged to use a higher-level library to communicate
- * with the REST server (e.g., Apache HTTP Commons).
- *
+ * Test of the DNA JCR REST resource. Note that this test case uses a very low-level API to construct requests and deconstruct the
+ * responses. Users are encouraged to use a higher-level library to communicate with the REST server (e.g., Apache HTTP Commons).
*/
public class JcrResourcesTest {
@@ -57,17 +56,17 @@
public void beforeEach() {
// Configured in pom
- final String login ="dnauser";
- final String password ="password";
+ final String login = "dnauser";
+ final String password = "password";
Authenticator.setDefault(new Authenticator() {
@Override
protected PasswordAuthentication getPasswordAuthentication() {
- return new PasswordAuthentication (login, password.toCharArray());
+ return new PasswordAuthentication(login, password.toCharArray());
}
});
}
-
+
private String getResponseFor( HttpURLConnection connection ) throws IOException {
StringBuffer buff = new StringBuffer();
@@ -84,13 +83,13 @@
@Test
public void shouldNotServeContentToUnauthorizedUser() throws Exception {
- final String login ="dnauser";
- final String password ="invalidpassword";
+ final String login = "dnauser";
+ final String password = "invalidpassword";
Authenticator.setDefault(new Authenticator() {
@Override
protected PasswordAuthentication getPasswordAuthentication() {
- return new PasswordAuthentication (login, password.toCharArray());
+ return new PasswordAuthentication(login, password.toCharArray());
}
});
@@ -110,13 +109,13 @@
public void shouldNotServeContentToUserWithoutConnectRole() throws Exception {
// Configured in pom
- final String login ="unauthorizeduser";
- final String password ="password";
+ final String login = "unauthorizeduser";
+ final String password = "password";
Authenticator.setDefault(new Authenticator() {
@Override
protected PasswordAuthentication getPasswordAuthentication() {
- return new PasswordAuthentication (login, password.toCharArray());
+ return new PasswordAuthentication(login, password.toCharArray());
}
});
@@ -323,7 +322,7 @@
connection.setRequestProperty("Content-Type", MediaType.APPLICATION_JSON);
String body = getResponseFor(connection);
- assertThat(body, is("\"dna:system\""));
+ assertThat(body, is("{\"jcr:primaryType\":\"dna:system\"}"));
assertThat(connection.getResponseCode(), is(HttpURLConnection.HTTP_OK));
connection.disconnect();
}
@@ -339,7 +338,7 @@
String payload = "{ \"properties\": {\"jcr:primaryType\": \"nt:unstructured\", \"testProperty\": \"testValue\", \"multiValuedProperty\": [\"value1\", \"value2\"]}}";
connection.getOutputStream().write(payload.getBytes());
-
+
JSONObject body = new JSONObject(getResponseFor(connection));
assertThat(body.length(), is(1));
@@ -355,7 +354,7 @@
assertThat(values.length(), is(2));
assertThat(values.getString(0), is("value1"));
assertThat(values.getString(1), is("value2"));
-
+
assertThat(connection.getResponseCode(), is(HttpURLConnection.HTTP_CREATED));
connection.disconnect();
}
@@ -371,15 +370,15 @@
String payload = "{}";
connection.getOutputStream().write(payload.getBytes());
-
+
JSONObject body = new JSONObject(getResponseFor(connection));
assertThat(body.length(), is(1));
-
+
JSONObject properties = body.getJSONObject("properties");
assertThat(properties, is(notNullValue()));
assertThat(properties.length(), is(1));
assertThat(properties.getString("jcr:primaryType"), is("nt:unstructured"));
-
+
assertThat(connection.getResponseCode(), is(HttpURLConnection.HTTP_CREATED));
connection.disconnect();
}
@@ -395,10 +394,10 @@
String payload = "{ \"properties\": {\"jcr:mixinTypes\": \"mix:referenceable\"}}";
connection.getOutputStream().write(payload.getBytes());
-
+
JSONObject body = new JSONObject(getResponseFor(connection));
assertThat(body.length(), is(1));
-
+
JSONObject properties = body.getJSONObject("properties");
assertThat(properties, is(notNullValue()));
assertThat(properties.length(), is(3));
@@ -409,7 +408,7 @@
assertThat(values, is(notNullValue()));
assertThat(values.length(), is(1));
assertThat(values.getString(0), is("mix:referenceable"));
-
+
assertThat(connection.getResponseCode(), is(HttpURLConnection.HTTP_CREATED));
connection.disconnect();
@@ -423,7 +422,7 @@
body = new JSONObject(getResponseFor(connection));
assertThat(body.length(), is(1));
-
+
properties = body.getJSONObject("properties");
assertThat(properties, is(notNullValue()));
assertThat(properties.length(), is(3));
@@ -434,10 +433,10 @@
assertThat(values, is(notNullValue()));
assertThat(values.length(), is(1));
assertThat(values.getString(0), is("mix:referenceable"));
-
+
assertThat(connection.getResponseCode(), is(HttpURLConnection.HTTP_OK));
connection.disconnect();
-
+
}
@Test
@@ -448,7 +447,7 @@
connection.setDoOutput(true);
connection.setRequestMethod("GET");
connection.setRequestProperty("Content-Type", MediaType.APPLICATION_JSON);
-
+
assertThat(connection.getResponseCode(), is(HttpURLConnection.HTTP_NOT_FOUND));
connection.disconnect();
@@ -465,7 +464,7 @@
String payload = "{ \"properties\": {\"jcr:primaryType\": \"invalidType\", \"testProperty\": \"testValue\", \"multiValuedProperty\": [\"value1\", \"value2\"]}}";
connection.getOutputStream().write(payload.getBytes());
-
+
assertThat(connection.getResponseCode(), is(HttpURLConnection.HTTP_BAD_REQUEST));
connection.disconnect();
@@ -491,7 +490,7 @@
connection.setRequestProperty("Content-Type", MediaType.APPLICATION_JSON);
String payload = "{ \"properties\": {\"jcr:primaryType\": \"nt:unstructured\", \"testProperty\": \"testValue\", \"multiValuedProperty\": [\"value1\", \"value2\"]},"
- + " \"children\": { \"childNode\" : { \"properties\": {\"nestedProperty\": \"nestedValue\"}}}}";
+ + " \"children\": { \"childNode\" : { \"properties\": {\"nestedProperty\": \"nestedValue\"}}}}";
connection.getOutputStream().write(payload.getBytes());
@@ -508,7 +507,7 @@
JSONObject body = new JSONObject(getResponseFor(connection));
assertThat(body.length(), is(2));
-
+
JSONObject properties = body.getJSONObject("properties");
assertThat(properties, is(notNullValue()));
assertThat(properties.length(), is(3));
@@ -521,22 +520,22 @@
assertThat(values.length(), is(2));
assertThat(values.getString(0), is("value1"));
assertThat(values.getString(1), is("value2"));
-
+
JSONObject children = body.getJSONObject("children");
assertThat(children, is(notNullValue()));
assertThat(children.length(), is(1));
-
+
JSONObject child = children.getJSONObject("childNode");
assertThat(child, is(notNullValue()));
assertThat(child.length(), is(1));
-
+
properties = child.getJSONObject("properties");
assertThat(properties, is(notNullValue()));
assertThat(properties.length(), is(2));
// Parent primary type is nt:unstructured, so this should default to nt:unstructured primary type
assertThat(properties.getString("jcr:primaryType"), is("nt:unstructured"));
assertThat(properties.getString("nestedProperty"), is("nestedValue"));
-
+
assertThat(connection.getResponseCode(), is(HttpURLConnection.HTTP_OK));
connection.disconnect();
@@ -552,9 +551,9 @@
connection.setRequestProperty("Content-Type", MediaType.APPLICATION_JSON);
String payload = "{ \"properties\": {\"jcr:primaryType\": \"nt:unstructured\", \"testProperty\": \"testValue\", \"multiValuedProperty\": [\"value1\", \"value2\"]},"
- + " \"children\": { \"childNode\" : { \"properties\": {\"jcr:primaryType\": \"invalidType\"}}}}";
+ + " \"children\": { \"childNode\" : { \"properties\": {\"jcr:primaryType\": \"invalidType\"}}}}";
connection.getOutputStream().write(payload.getBytes());
-
+
assertThat(connection.getResponseCode(), is(HttpURLConnection.HTTP_BAD_REQUEST));
connection.disconnect();
@@ -565,13 +564,13 @@
connection.setDoOutput(true);
connection.setRequestMethod("GET");
connection.setRequestProperty("Content-Type", MediaType.APPLICATION_JSON);
-
+
assertThat(connection.getResponseCode(), is(HttpURLConnection.HTTP_NOT_FOUND));
connection.disconnect();
-
+
}
- @Test
+ @Test
public void shouldNotDeleteNonExistentItem() throws Exception {
URL postUrl = new URL(SERVER_URL + "/dna%3arepository/default/items/invalidItemForDelete");
HttpURLConnection connection = (HttpURLConnection)postUrl.openConnection();
@@ -579,12 +578,12 @@
connection.setDoOutput(true);
connection.setRequestMethod("DELETE");
connection.setRequestProperty("Content-Type", MediaType.APPLICATION_JSON);
-
+
assertThat(connection.getResponseCode(), is(HttpURLConnection.HTTP_NOT_FOUND));
connection.disconnect();
}
- @Test
+ @Test
public void shouldDeleteExtantNode() throws Exception {
// Create the node
@@ -597,7 +596,7 @@
String payload = "{ \"properties\": {\"jcr:primaryType\": \"nt:unstructured\", \"testProperty\": \"testValue\", \"multiValuedProperty\": [\"value1\", \"value2\"]}}";
connection.getOutputStream().write(payload.getBytes());
-
+
JSONObject body = new JSONObject(getResponseFor(connection));
assertThat(body.length(), is(1));
@@ -613,7 +612,7 @@
assertThat(values.length(), is(2));
assertThat(values.getString(0), is("value1"));
assertThat(values.getString(1), is("value2"));
-
+
assertThat(connection.getResponseCode(), is(HttpURLConnection.HTTP_CREATED));
connection.disconnect();
@@ -651,7 +650,7 @@
connection.disconnect();
}
- @Test
+ @Test
public void shouldDeleteExtantProperty() throws Exception {
URL postUrl = new URL(SERVER_URL + "/dna%3arepository/default/items/propertyForDeletion");
HttpURLConnection connection = (HttpURLConnection)postUrl.openConnection();
@@ -662,10 +661,10 @@
String payload = "{ \"properties\": {\"jcr:primaryType\": \"nt:unstructured\", \"testProperty\": \"testValue\", \"multiValuedProperty\": [\"value1\", \"value2\"]}}";
connection.getOutputStream().write(payload.getBytes());
-
+
assertThat(connection.getResponseCode(), is(HttpURLConnection.HTTP_CREATED));
connection.disconnect();
-
+
// Confirm that it exists
postUrl = new URL(SERVER_URL + "/dna%3arepository/default/items/propertyForDeletion");
connection = (HttpURLConnection)postUrl.openConnection();
@@ -723,7 +722,7 @@
assertThat(connection.getResponseCode(), is(HttpURLConnection.HTTP_OK));
connection.disconnect();
-
+
}
@Test
@@ -738,7 +737,7 @@
String payload = "{ \"firstProperty\": \"someValue\" }";
connection.getOutputStream().write(payload.getBytes());
-
+
assertThat(connection.getResponseCode(), is(HttpURLConnection.HTTP_NOT_FOUND));
connection.disconnect();
}
@@ -754,7 +753,7 @@
String payload = "{ \"properties\": {\"jcr:primaryType\": \"nt:unstructured\", \"testProperty\": \"testValue\" }}";
connection.getOutputStream().write(payload.getBytes());
-
+
assertThat(connection.getResponseCode(), is(HttpURLConnection.HTTP_CREATED));
connection.disconnect();
@@ -765,9 +764,9 @@
connection.setRequestMethod("PUT");
connection.setRequestProperty("Content-Type", MediaType.APPLICATION_JSON);
- payload = "\"someOtherValue\"";
+ payload = "{\"testProperty\":\"someOtherValue\"}";
connection.getOutputStream().write(payload.getBytes());
-
+
JSONObject body = new JSONObject(getResponseFor(connection));
assertThat(body.length(), is(1));
@@ -776,15 +775,83 @@
assertThat(properties.length(), is(2));
assertThat(properties.getString("jcr:primaryType"), is("nt:unstructured"));
assertThat(properties.getString("testProperty"), is("someOtherValue"));
-
+
assertThat(connection.getResponseCode(), is(HttpURLConnection.HTTP_OK));
connection.disconnect();
-
+
}
@Test
- public void shouldNotBeAbleToPutPropertiesToNode() throws Exception {
+ public void shouldBeAbleToPutBinaryValueToProperty() throws Exception {
+ URL postUrl = new URL(SERVER_URL + "/dna%3arepository/default/items/nodeForPutBinaryProperty");
+ HttpURLConnection connection = (HttpURLConnection)postUrl.openConnection();
+ connection.setDoOutput(true);
+ connection.setRequestMethod("POST");
+ connection.setRequestProperty("Content-Type", MediaType.APPLICATION_JSON);
+
+ // Base64-encode a value ...
+ String encodedValue = Base64.encode("propertyValue".getBytes("UTF-8"));
+
+ String payload = "{ \"properties\": {\"jcr:primaryType\": \"nt:unstructured\", \"testProperty/base64/\": \""
+ + encodedValue + "\" }}";
+ connection.getOutputStream().write(payload.getBytes());
+
+ assertThat(connection.getResponseCode(), is(HttpURLConnection.HTTP_CREATED));
+ connection.disconnect();
+
+ URL putUrl = new URL(SERVER_URL + "/dna%3arepository/default/items/nodeForPutBinaryProperty/testProperty");
+ connection = (HttpURLConnection)putUrl.openConnection();
+
+ connection.setDoOutput(true);
+ connection.setRequestMethod("PUT");
+ connection.setRequestProperty("Content-Type", MediaType.APPLICATION_JSON);
+
+ String otherValue = "someOtherValue";
+ payload = "{\"testProperty/base64/\":\"" + Base64.encode(otherValue.getBytes("UTF-8")) + "\"}";
+ connection.getOutputStream().write(payload.getBytes());
+
+ JSONObject body = new JSONObject(getResponseFor(connection));
+ assertThat(body.length(), is(1));
+
+ JSONObject properties = body.getJSONObject("properties");
+ assertThat(properties, is(notNullValue()));
+ assertThat(properties.length(), is(2));
+ assertThat(properties.getString("jcr:primaryType"), is("nt:unstructured"));
+ String responseEncodedValue = properties.getString("testProperty/base64/");
+ String decodedValue = new String(Base64.decode(responseEncodedValue), "UTF-8");
+ assertThat(decodedValue, is(otherValue));
+
+ assertThat(connection.getResponseCode(), is(HttpURLConnection.HTTP_OK));
+ connection.disconnect();
+
+ // Try putting a non-binary value ...
+ connection = (HttpURLConnection)putUrl.openConnection();
+
+ connection.setDoOutput(true);
+ connection.setRequestMethod("PUT");
+ connection.setRequestProperty("Content-Type", MediaType.APPLICATION_JSON);
+
+ String anotherValue = "yetAnotherValue";
+ payload = "{\"testProperty\":\"" + anotherValue + "\"}";
+ connection.getOutputStream().write(payload.getBytes());
+
+ body = new JSONObject(getResponseFor(connection));
+ assertThat(body.length(), is(1));
+
+ properties = body.getJSONObject("properties");
+ assertThat(properties, is(notNullValue()));
+ assertThat(properties.length(), is(2));
+ assertThat(properties.getString("jcr:primaryType"), is("nt:unstructured"));
+ assertThat(properties.getString("testProperty"), is(anotherValue));
+
+ assertThat(connection.getResponseCode(), is(HttpURLConnection.HTTP_OK));
+ connection.disconnect();
+ }
+
+ @Test
+ public void shouldBeAbleToPutPropertiesToNode() throws Exception {
+
URL postUrl = new URL(SERVER_URL + "/dna%3arepository/default/items/nodeForPutProperties");
HttpURLConnection connection = (HttpURLConnection)postUrl.openConnection();
@@ -794,7 +861,7 @@
String payload = "{ \"properties\": {\"jcr:primaryType\": \"nt:unstructured\" }}";
connection.getOutputStream().write(payload.getBytes());
-
+
assertThat(connection.getResponseCode(), is(HttpURLConnection.HTTP_CREATED));
connection.disconnect();
@@ -807,7 +874,7 @@
payload = "{\"testProperty\": \"testValue\", \"multiValuedProperty\": [\"value1\", \"value2\"]}";
connection.getOutputStream().write(payload.getBytes());
-
+
JSONObject body = new JSONObject(getResponseFor(connection));
assertThat(body.length(), is(1));
@@ -823,10 +890,10 @@
assertThat(values.length(), is(2));
assertThat(values.getString(0), is("value1"));
assertThat(values.getString(1), is("value2"));
-
+
assertThat(connection.getResponseCode(), is(HttpURLConnection.HTTP_OK));
connection.disconnect();
-
+
}
@Test
@@ -841,7 +908,7 @@
String payload = "{ \"properties\": {\"jcr:primaryType\": \"nt:unstructured\" }}";
connection.getOutputStream().write(payload.getBytes());
-
+
assertThat(connection.getResponseCode(), is(HttpURLConnection.HTTP_CREATED));
connection.disconnect();
@@ -853,7 +920,7 @@
payload = "{\"jcr:mixinTypes\": \"mix:referenceable\"}";
connection.getOutputStream().write(payload.getBytes());
-
+
JSONObject body = new JSONObject(getResponseFor(connection));
assertThat(body.length(), is(1));
@@ -867,7 +934,7 @@
assertThat(mixinTypes.length(), is(1));
assertThat(mixinTypes.getString(0), is("mix:referenceable"));
assertThat(properties.getString("jcr:uuid"), is(notNullValue()));
-
+
assertThat(connection.getResponseCode(), is(HttpURLConnection.HTTP_OK));
connection.disconnect();
@@ -879,7 +946,7 @@
payload = "{\"jcr:mixinTypes\": []}";
connection.getOutputStream().write(payload.getBytes());
-
+
body = new JSONObject(getResponseFor(connection));
assertThat(body.length(), is(1));
14 years, 8 months