[dna-commits] DNA SVN: r1461 - in eclipse/trunk: org.jboss.dna.eclipse.jcr.rest.client/src/org/jboss/dna/eclipse/jcr/rest/client and 7 other directories.

dna-commits at lists.jboss.org dna-commits at lists.jboss.org
Fri Dec 18 17:04:49 EST 2009


Author: elvisisking
Date: 2009-12-18 17:04:48 -0500 (Fri, 18 Dec 2009)
New Revision: 1461

Added:
   eclipse/trunk/org.jboss.dna.eclipse.jcr.rest.client/src/org/jboss/dna/eclipse/jcr/rest/client/DnaServer.java
   eclipse/trunk/org.jboss.dna.eclipse.jcr.rest.client/src/org/jboss/dna/eclipse/jcr/rest/client/IServerRegistryListener.java
   eclipse/trunk/org.jboss.dna.eclipse.jcr.rest.client/src/org/jboss/dna/eclipse/jcr/rest/client/ServerManager.java
   eclipse/trunk/org.jboss.dna.eclipse.jcr.rest.client/src/org/jboss/dna/eclipse/jcr/rest/client/ServerRegistryEvent.java
Modified:
   eclipse/trunk/org.jboss.dna.eclipse.jcr.rest.client.feature/feature.properties
   eclipse/trunk/org.jboss.dna.eclipse.jcr.rest.client.feature/feature.xml
   eclipse/trunk/org.jboss.dna.eclipse.jcr.rest.client.updatesite/
   eclipse/trunk/org.jboss.dna.eclipse.jcr.rest.client.updatesite/site.xml
   eclipse/trunk/org.jboss.dna.eclipse.jcr.rest.client/
   eclipse/trunk/org.jboss.dna.eclipse.jcr.rest.client/LEGAL.txt
   eclipse/trunk/org.jboss.dna.eclipse.jcr.rest.client/dna-web-jcr-rest-client-0.7-SNAPSHOT-jar-with-dependencies.jar
   eclipse/trunk/org.jboss.dna.eclipse.jcr.rest.client/dna-web-jcr-rest-client-0.7-SNAPSHOT-sources.jar
   eclipse/trunk/org.jboss.dna.eclipse.jcr.rest.client/plugin.xml
   eclipse/trunk/org.jboss.dna.eclipse.jcr.rest.client/src/org/jboss/dna/eclipse/jcr/rest/client/Activator.java
   eclipse/trunk/org.jboss.dna.eclipse.jcr.rest.client/src/org/jboss/dna/eclipse/jcr/rest/client/DnaResourceHelper.java
   eclipse/trunk/org.jboss.dna.eclipse.jcr.rest.client/src/org/jboss/dna/eclipse/jcr/rest/client/RestClientI18n.java
   eclipse/trunk/org.jboss.dna.eclipse.jcr.rest.client/src/org/jboss/dna/eclipse/jcr/rest/client/RestClientI18n.properties
   eclipse/trunk/org.jboss.dna.eclipse.jcr.rest.client/src/org/jboss/dna/eclipse/jcr/rest/client/Utils.java
   eclipse/trunk/org.jboss.dna.eclipse.jcr.rest.client/src/org/jboss/dna/eclipse/jcr/rest/client/actions/DeleteServerAction.java
   eclipse/trunk/org.jboss.dna.eclipse.jcr.rest.client/src/org/jboss/dna/eclipse/jcr/rest/client/actions/EditServerAction.java
   eclipse/trunk/org.jboss.dna.eclipse.jcr.rest.client/src/org/jboss/dna/eclipse/jcr/rest/client/actions/NewServerAction.java
   eclipse/trunk/org.jboss.dna.eclipse.jcr.rest.client/src/org/jboss/dna/eclipse/jcr/rest/client/actions/ShowPublishedLocationsAction.java
   eclipse/trunk/org.jboss.dna.eclipse.jcr.rest.client/src/org/jboss/dna/eclipse/jcr/rest/client/dialogs/PublishedLocationsDialog.java
   eclipse/trunk/org.jboss.dna.eclipse.jcr.rest.client/src/org/jboss/dna/eclipse/jcr/rest/client/jobs/PublishJob.java
   eclipse/trunk/org.jboss.dna.eclipse.jcr.rest.client/src/org/jboss/dna/eclipse/jcr/rest/client/jobs/ReconnectJob.java
   eclipse/trunk/org.jboss.dna.eclipse.jcr.rest.client/src/org/jboss/dna/eclipse/jcr/rest/client/views/DnaContentProvider.java
   eclipse/trunk/org.jboss.dna.eclipse.jcr.rest.client/src/org/jboss/dna/eclipse/jcr/rest/client/views/ServerView.java
   eclipse/trunk/org.jboss.dna.eclipse.jcr.rest.client/src/org/jboss/dna/eclipse/jcr/rest/client/wizards/PublishPage.java
   eclipse/trunk/org.jboss.dna.eclipse.jcr.rest.client/src/org/jboss/dna/eclipse/jcr/rest/client/wizards/PublishWizard.java
   eclipse/trunk/org.jboss.dna.eclipse.jcr.rest.client/src/org/jboss/dna/eclipse/jcr/rest/client/wizards/ServerPage.java
   eclipse/trunk/org.jboss.dna.eclipse.jcr.rest.client/src/org/jboss/dna/eclipse/jcr/rest/client/wizards/ServerWizard.java
Log:
DNA-598 The DNA REST Server Registry Should Be Moved From The DNA REST Client Maven Project To The Eclipse Plugin: This commit is only the Eclipse plugin part. Moving the registry out of the maven project was a separate commit.The ServerManager is where the registry is maintained. Create DnaServer that extends Server and keeps track of if a server password should be persisted.


Property changes on: eclipse/trunk/org.jboss.dna.eclipse.jcr.rest.client
___________________________________________________________________
Name: svn:ignore
   + bin


Modified: eclipse/trunk/org.jboss.dna.eclipse.jcr.rest.client/LEGAL.txt
===================================================================
--- eclipse/trunk/org.jboss.dna.eclipse.jcr.rest.client/LEGAL.txt	2009-12-18 20:56:07 UTC (rev 1460)
+++ eclipse/trunk/org.jboss.dna.eclipse.jcr.rest.client/LEGAL.txt	2009-12-18 22:04:48 UTC (rev 1461)
@@ -1,6 +1,9 @@
-The DNA REST Eclipse SWT Client (http://www.jboss.org/dna/) is copyright 2000-2009 MetaMatrix, Inc. and Red Hat, Inc.
+The ModeShape Eclipse Feature is copyright 2009-2010 Red Hat, Inc.
 
-This program and the accompanying materials are made available under the terms of the Eclipse Public License v1.0 which is
+Distributed under license by Red Hat, Inc. All rights reserved.
+This program is made available under the terms of the
+Eclipse Public License v1.0 which accompanies this distribution, and is
 available at http://www.eclipse.org/legal/epl-v10.html.
 
-Some portions may be licensed to Red Hat, Inc. under one or more contributor license agreements.
+See the AUTHORS.txt file in the distribution for a full listing of
+individual contributors.

Modified: eclipse/trunk/org.jboss.dna.eclipse.jcr.rest.client/dna-web-jcr-rest-client-0.7-SNAPSHOT-jar-with-dependencies.jar
===================================================================
(Binary files differ)

Modified: eclipse/trunk/org.jboss.dna.eclipse.jcr.rest.client/dna-web-jcr-rest-client-0.7-SNAPSHOT-sources.jar
===================================================================
(Binary files differ)

Modified: eclipse/trunk/org.jboss.dna.eclipse.jcr.rest.client/plugin.xml
===================================================================
--- eclipse/trunk/org.jboss.dna.eclipse.jcr.rest.client/plugin.xml	2009-12-18 20:56:07 UTC (rev 1460)
+++ eclipse/trunk/org.jboss.dna.eclipse.jcr.rest.client/plugin.xml	2009-12-18 22:04:48 UTC (rev 1461)
@@ -28,7 +28,7 @@
                <enablement>
                    <and>
                       <objectClass name="org.eclipse.core.resources.IFile" />
-                      <objectState name="persistentProperty" value="org.jboss.dna.eclipse.jcr.rest.client.publishedIn" />
+                      <objectState name="persistentProperty" value="org.jboss.dna.eclipse.jcr.rest.client.publishedLocations" />
                    </and>
                </enablement>
          </action>

Modified: eclipse/trunk/org.jboss.dna.eclipse.jcr.rest.client/src/org/jboss/dna/eclipse/jcr/rest/client/Activator.java
===================================================================
--- eclipse/trunk/org.jboss.dna.eclipse.jcr.rest.client/src/org/jboss/dna/eclipse/jcr/rest/client/Activator.java	2009-12-18 20:56:07 UTC (rev 1460)
+++ eclipse/trunk/org.jboss.dna.eclipse.jcr.rest.client/src/org/jboss/dna/eclipse/jcr/rest/client/Activator.java	2009-12-18 22:04:48 UTC (rev 1461)
@@ -25,7 +25,6 @@
 
 import java.net.MalformedURLException;
 import java.net.URL;
-import org.apache.log4j.BasicConfigurator;
 import org.eclipse.core.runtime.IStatus;
 import org.eclipse.jface.resource.ImageDescriptor;
 import org.eclipse.jface.resource.ImageRegistry;
@@ -34,7 +33,6 @@
 import org.eclipse.ui.PlatformUI;
 import org.eclipse.ui.plugin.AbstractUIPlugin;
 import org.jboss.dna.common.util.CheckArg;
-import org.jboss.dna.web.jcr.rest.client.ServerManager;
 import org.jboss.dna.web.jcr.rest.client.Status;
 import org.jboss.dna.web.jcr.rest.client.Status.Severity;
 import org.jboss.dna.web.jcr.rest.client.domain.IDnaObject;
@@ -236,7 +234,7 @@
      */
     @Override
     public void start( BundleContext context ) throws Exception {
-        BasicConfigurator.configure();
+//        BasicConfigurator.configure(); // TODO how does logging get configured now
         
         super.start(context);
         plugin = this;

Modified: eclipse/trunk/org.jboss.dna.eclipse.jcr.rest.client/src/org/jboss/dna/eclipse/jcr/rest/client/DnaResourceHelper.java
===================================================================
--- eclipse/trunk/org.jboss.dna.eclipse.jcr.rest.client/src/org/jboss/dna/eclipse/jcr/rest/client/DnaResourceHelper.java	2009-12-18 20:56:07 UTC (rev 1460)
+++ eclipse/trunk/org.jboss.dna.eclipse.jcr.rest.client/src/org/jboss/dna/eclipse/jcr/rest/client/DnaResourceHelper.java	2009-12-18 22:04:48 UTC (rev 1461)
@@ -31,7 +31,6 @@
 import org.eclipse.core.runtime.CoreException;
 import org.eclipse.core.runtime.QualifiedName;
 import org.jboss.dna.common.util.CheckArg;
-import org.jboss.dna.web.jcr.rest.client.ServerManager;
 import org.jboss.dna.web.jcr.rest.client.Status;
 import org.jboss.dna.web.jcr.rest.client.Status.Severity;
 import org.jboss.dna.web.jcr.rest.client.domain.Repository;

Added: eclipse/trunk/org.jboss.dna.eclipse.jcr.rest.client/src/org/jboss/dna/eclipse/jcr/rest/client/DnaServer.java
===================================================================
--- eclipse/trunk/org.jboss.dna.eclipse.jcr.rest.client/src/org/jboss/dna/eclipse/jcr/rest/client/DnaServer.java	                        (rev 0)
+++ eclipse/trunk/org.jboss.dna.eclipse.jcr.rest.client/src/org/jboss/dna/eclipse/jcr/rest/client/DnaServer.java	2009-12-18 22:04:48 UTC (rev 1461)
@@ -0,0 +1,67 @@
+package org.jboss.dna.eclipse.jcr.rest.client;
+
+import net.jcip.annotations.Immutable;
+import org.jboss.dna.web.jcr.rest.client.domain.Server;
+
+/**
+ * The <code>DnaServer</code> class adds the concept of allowing a server's password to be persisted or not.
+ */
+ at Immutable
+public final class DnaServer extends Server {
+
+    // ===========================================================================================================================
+    // Fields
+    // ===========================================================================================================================
+
+    /**
+     * Indicates if the password should be stored locally when the server is persisted.
+     */
+    private final boolean persistPassword;
+
+    // ===========================================================================================================================
+    // Constructors
+    // ===========================================================================================================================
+
+    /**
+     * Constructs a new <code>DnaServer</code>.
+     * 
+     * @param url the server URL (never <code>null</code>)
+     * @param user the server user (never <code>null</code>)
+     * @param password the server password (may be <code>null</code>)
+     * @param persistPassword <code>true</code> if the password should be stored
+     * @throws IllegalArgumentException if URL or user is <code>null</code> or empty
+     */
+    public DnaServer( String url,
+                      String user,
+                      String password,
+                      boolean persistPassword ) {
+        super(url, user, password);
+        this.persistPassword = persistPassword;
+    }
+
+    // ===========================================================================================================================
+    // Methods
+    // ===========================================================================================================================
+
+    /**
+     * {@inheritDoc}
+     *
+     * @see org.jboss.dna.web.jcr.rest.client.domain.Server#equals(java.lang.Object)
+     */
+    @Override
+    public boolean equals( Object obj ) {
+        if (super.equals(obj)) {
+            return (this.persistPassword == ((DnaServer)obj).persistPassword);
+        }
+        
+        return false;
+    }
+
+    /**
+     * @return persistPassword <code>true</code> if the password is being persisted
+     */
+    public boolean isPasswordBeingPersisted() {
+        return this.persistPassword;
+    }
+
+}


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

Added: eclipse/trunk/org.jboss.dna.eclipse.jcr.rest.client/src/org/jboss/dna/eclipse/jcr/rest/client/IServerRegistryListener.java
===================================================================
--- eclipse/trunk/org.jboss.dna.eclipse.jcr.rest.client/src/org/jboss/dna/eclipse/jcr/rest/client/IServerRegistryListener.java	                        (rev 0)
+++ eclipse/trunk/org.jboss.dna.eclipse.jcr.rest.client/src/org/jboss/dna/eclipse/jcr/rest/client/IServerRegistryListener.java	2009-12-18 22:04:48 UTC (rev 1461)
@@ -0,0 +1,37 @@
+/*
+ * JBoss DNA (http://www.jboss.org/dna)
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership.  Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ * See the AUTHORS.txt file in the distribution for a full listing of 
+ * individual contributors.
+ *
+ * JBoss DNA is free software. Unless otherwise indicated, all code in JBoss DNA
+ * is licensed to you under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ * 
+ * JBoss DNA is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.dna.eclipse.jcr.rest.client;
+
+/**
+ * The <code>IServerRegistryListener</code> interface defines the API for a server registry listener.
+ */
+public interface IServerRegistryListener {
+
+    /**
+     * @param event the event being processed (never <code>null</code>)
+     * @return any errors caught during the processing or <code>null</code>
+     */
+    Exception[] serverRegistryChanged( ServerRegistryEvent event );
+
+}


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

Modified: eclipse/trunk/org.jboss.dna.eclipse.jcr.rest.client/src/org/jboss/dna/eclipse/jcr/rest/client/RestClientI18n.java
===================================================================
--- eclipse/trunk/org.jboss.dna.eclipse.jcr.rest.client/src/org/jboss/dna/eclipse/jcr/rest/client/RestClientI18n.java	2009-12-18 20:56:07 UTC (rev 1460)
+++ eclipse/trunk/org.jboss.dna.eclipse.jcr.rest.client/src/org/jboss/dna/eclipse/jcr/rest/client/RestClientI18n.java	2009-12-18 22:04:48 UTC (rev 1461)
@@ -55,8 +55,10 @@
 
     public static I18n editServerActionText;
     public static I18n editServerActionToolTip;
-
+    public static I18n errorDeletingServerRegistryFile;
     public static I18n errorDialogTitle;
+    public static I18n errorRestoringServerRegistry;
+    public static I18n errorSavingServerRegistry;
 
     public static I18n missingImage;
 
@@ -144,8 +146,22 @@
 
     public static I18n reconnectJobTaskName;
 
+    public static I18n serverEmptyUrlMsg;
+    public static I18n serverEmptyUserMsg;
+    public static I18n serverExistsMsg;
+    public static I18n serverInvalidUrlMsg;
+
+    public static I18n serverManagerConnectionEstablishedMsg;
+    public static I18n serverManagerConnectionFailedMsg;
     public static I18n serverManagerGetRepositoriesExceptionMsg;
     public static I18n serverManagerGetWorkspacesExceptionMsg;
+    public static I18n serverManagerRegistryAddUnexpectedError;
+    public static I18n serverManagerRegistryListenerError;
+    public static I18n serverManagerRegistryListenerErrorsOccurred;
+    public static I18n serverManagerRegistryRemoveUnexpectedError;
+    public static I18n serverManagerRegistryUpdateAddError;
+    public static I18n serverManagerRegistryUpdateRemoveError;
+    public static I18n serverManagerUnregisteredServer;
 
     public static I18n serverPageAuthenticationGroupTitle;
     public static I18n serverPageInvalidServerProperties;

Modified: eclipse/trunk/org.jboss.dna.eclipse.jcr.rest.client/src/org/jboss/dna/eclipse/jcr/rest/client/RestClientI18n.properties
===================================================================
--- eclipse/trunk/org.jboss.dna.eclipse.jcr.rest.client/src/org/jboss/dna/eclipse/jcr/rest/client/RestClientI18n.properties	2009-12-18 20:56:07 UTC (rev 1460)
+++ eclipse/trunk/org.jboss.dna.eclipse.jcr.rest.client/src/org/jboss/dna/eclipse/jcr/rest/client/RestClientI18n.properties	2009-12-18 22:04:48 UTC (rev 1461)
@@ -34,9 +34,6 @@
 deleteServerDialogOneServerMsg = Are you sure you want to delete the server with URL of "{0}" and user "{1}?"
 deleteServerDialogTitle = Confirm Delete Server
 
-editServerActionText = Server Properties
-editServerActionToolTip = Edit server properties
-
 dnaConsoleName = DNA
 dnaConsoleProblemCreatingHyperlinkMsg = Unexpected problem creating hyperlink in DNA Console view
 dnaConsoleFilePathNotFoundMsg = A hyperlink could not be created in the DNA Message Console because the file path of "{0}" could not be found.
@@ -47,7 +44,13 @@
 dnaPreferencePageMessage = DNA
 dnaPreferencePageTitle = DNA Preferences
 
+editServerActionText = Server Properties
+editServerActionToolTip = Edit server properties
+
+errorDeletingServerRegistryFile = There was a problem deleting server registry file "{0}"
 errorDialogTitle = Error
+errorRestoringServerRegistry = Error trying to restore the server registry from file "{0}"
+errorSavingServerRegistry = Error trying to save the server registry to "{0}"
 
 missingImage = The following image cannot be found "{0}"
 
@@ -135,11 +138,24 @@
 
 reconnectJobTaskName = Connecting to server "{0}"
 
+serverEmptyUserMsg = The user cannot be empty
+serverEmptyUrlMsg = A server URL cannot be empty
+serverExistsMsg = {0} already exists so it cannot be added
+serverInvalidUrlMsg = The  value "{0}" is not a valid server URL
 serverReconnectActionText = Reconnect
 serverReconnectActionToolTip = Reconnect to the selected server
 
+serverManagerConnectionEstablishedMsg = Connection established.
+serverManagerConnectionFailedMsg = Connection failed. Error Message: {0}
 serverManagerGetRepositoriesExceptionMsg = There was a problem obtaining repositories for the server "{0}."
 serverManagerGetWorkspacesExceptionMsg = There was a problem obtaining workspaces for "{0}."
+serverManagerRegistryAddUnexpectedError = Unexpected error adding server to registry
+serverManagerRegistryListenerError = This error was reported by an IServerRegistryListener
+serverManagerRegistryListenerErrorsOccurred = Errors occurred processing a server registry event. Check error log for more details.
+serverManagerRegistryRemoveUnexpectedError = {0} cannot be removed as it has not been registered
+serverManagerRegistryUpdateAddError = There was an unexpected error updating the server in the registry. The old version of the server was successfully removed. However, the new version was not updated. Detail: {0}
+serverManagerRegistryUpdateRemoveError = There was an unexpected error updating the server in the registry. The server has not been updated in the server registry. Detail: {0}
+serverManagerUnregisteredServer = Server "{0}" is not registered so it's repositories and workspaces cannot be obtained and it cannot be involved in a publishing operation.
 
 serverPageAuthenticationGroupTitle = Authentication
 serverPageInvalidServerProperties = Cannot construct a server because all server properties are not valid

Added: eclipse/trunk/org.jboss.dna.eclipse.jcr.rest.client/src/org/jboss/dna/eclipse/jcr/rest/client/ServerManager.java
===================================================================
--- eclipse/trunk/org.jboss.dna.eclipse.jcr.rest.client/src/org/jboss/dna/eclipse/jcr/rest/client/ServerManager.java	                        (rev 0)
+++ eclipse/trunk/org.jboss.dna.eclipse.jcr.rest.client/src/org/jboss/dna/eclipse/jcr/rest/client/ServerManager.java	2009-12-18 22:04:48 UTC (rev 1461)
@@ -0,0 +1,679 @@
+/*
+ * JBoss DNA (http://www.jboss.org/dna)
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership.  Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ * See the AUTHORS.txt file in the distribution for a full listing of 
+ * individual contributors. 
+ *
+ * JBoss DNA is free software. Unless otherwise indicated, all code in JBoss DNA
+ * is licensed to you under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * JBoss DNA is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.dna.eclipse.jcr.rest.client;
+
+import java.io.File;
+import java.io.FileOutputStream;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.List;
+import java.util.concurrent.CopyOnWriteArrayList;
+import java.util.concurrent.locks.ReadWriteLock;
+import java.util.concurrent.locks.ReentrantReadWriteLock;
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.transform.OutputKeys;
+import javax.xml.transform.Transformer;
+import javax.xml.transform.TransformerFactory;
+import javax.xml.transform.dom.DOMSource;
+import javax.xml.transform.stream.StreamResult;
+import net.jcip.annotations.GuardedBy;
+import net.jcip.annotations.ThreadSafe;
+import org.jboss.dna.common.util.Base64;
+import org.jboss.dna.common.util.CheckArg;
+import org.jboss.dna.common.util.Logger;
+import org.jboss.dna.web.jcr.rest.client.IRestClient;
+import org.jboss.dna.web.jcr.rest.client.Status;
+import org.jboss.dna.web.jcr.rest.client.Status.Severity;
+import org.jboss.dna.web.jcr.rest.client.domain.Repository;
+import org.jboss.dna.web.jcr.rest.client.domain.Server;
+import org.jboss.dna.web.jcr.rest.client.domain.Workspace;
+import org.jboss.dna.web.jcr.rest.client.json.JsonRestClient;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.NamedNodeMap;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+
+/**
+ * The <code>ServerManager</code> class managers the creation, deletion, and editing of servers hosting DNA repositories.
+ */
+ at ThreadSafe
+public final class ServerManager implements IRestClient {
+
+    // ===========================================================================================================================
+    // Constants
+    // ===========================================================================================================================
+
+    /**
+     * The tag used to persist a server's login password.
+     */
+    private static final String PASSWORD_TAG = "password"; //$NON-NLS-1$
+
+    /**
+     * The file name used when persisting the server registry.
+     */
+    private static final String REGISTRY_FILE = "serverRegistry.xml"; //$NON-NLS-1$
+
+    /**
+     * The tag used when persisting a server.
+     */
+    private static final String SERVER_TAG = "server"; //$NON-NLS-1$
+
+    /**
+     * The server collection tag used when persisting the server registry.
+     */
+    private static final String SERVERS_TAG = "servers"; //$NON-NLS-1$
+
+    /**
+     * The tag used to persist a server's URL.
+     */
+    private static final String URL_TAG = "url"; //$NON-NLS-1$
+
+    /**
+     * The tag used to persist a server's login user.
+     */
+    private static final String USER_TAG = "user"; //$NON-NLS-1$
+
+    // ===========================================================================================================================
+    // Fields
+    // ===========================================================================================================================
+
+    /**
+     * The listeners registered to receive {@link ServerRegistryEvent server registry events}.
+     */
+    private final CopyOnWriteArrayList<IServerRegistryListener> listeners;
+
+    /**
+     * Executes the commands run on the DNA REST server.
+     */
+    private final IRestClient delegate;
+
+    /**
+     * The logger.
+     */
+    private final Logger logger = Logger.getLogger(ServerManager.class);
+
+    /**
+     * The path where the server registry is persisted or <code>null</code> if not persisted.
+     */
+    private final String stateLocationPath;
+
+    /**
+     * The server registry.
+     */
+    @GuardedBy( "serverLock" )
+    private final List<Server> servers;
+
+    /**
+     * Lock used for when accessing the server registry.
+     */
+    private final ReadWriteLock serverLock = new ReentrantReadWriteLock();
+
+    // ===========================================================================================================================
+    // Constructors
+    // ===========================================================================================================================
+
+    /**
+     * @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>)
+     */
+    public ServerManager( String stateLocationPath,
+                          IRestClient restClient ) {
+        CheckArg.isNotNull(restClient, "restClient"); //$NON-NLS-1$
+
+        this.servers = new ArrayList<Server>();
+        this.stateLocationPath = stateLocationPath;
+        this.delegate = restClient;
+        this.listeners = new CopyOnWriteArrayList<IServerRegistryListener>();
+    }
+
+    /**
+     * This server manager uses the default REST Client.
+     * 
+     * @param stateLocationPath the directory where the {@link Server} registry is persisted (may be <code>null</code> if
+     *        persistence is not desired)
+     */
+    public ServerManager( String stateLocationPath ) {
+        this(stateLocationPath, new JsonRestClient());
+    }
+
+    // ===========================================================================================================================
+    // Methods
+    // ===========================================================================================================================
+
+    /**
+     * 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
+     */
+    public boolean addRegistryListener( IServerRegistryListener listener ) {
+        CheckArg.isNotNull(listener, "listener"); //$NON-NLS-1$
+        boolean result = this.listeners.addIfAbsent(listener);
+
+        // inform new listener of registered servers
+        for (Server server : getServers()) {
+            listener.serverRegistryChanged(ServerRegistryEvent.createNewEvent(this, server));
+        }
+
+        return result;
+    }
+
+    /**
+     * Registers the specified <code>DnaServer</code>.
+     * 
+     * @param server the server being added (never <code>null</code>)
+     * @return a status indicating if the server was added to the registry
+     */
+    public Status addServer( DnaServer server ) {
+        CheckArg.isNotNull(server, "server"); //$NON-NLS-1$
+        return internalAddServer(server, true);
+    }
+
+    /**
+     * @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>)
+     */
+    public Collection<Server> getServers() {
+        try {
+            this.serverLock.readLock().lock();
+            return Collections.unmodifiableCollection(new ArrayList<Server>(this.servers));
+        } finally {
+            this.serverLock.readLock().unlock();
+        }
+    }
+
+    /**
+     * @return the name of the state file that the server registry is persisted to or <code>null</code>
+     */
+    private String getStateFileName() {
+        String name = this.stateLocationPath;
+
+        if (this.stateLocationPath != null) {
+            name += File.separatorChar + REGISTRY_FILE;
+        }
+
+        return name;
+    }
+
+    /**
+     * {@inheritDoc}
+     * 
+     * @see org.jboss.dna.web.jcr.rest.client.IRestClient#getRepositories(org.jboss.dna.web.jcr.rest.client.domain.Server)
+     * @throws RuntimeException if the server is not registered
+     * @see #isRegistered(Server)
+     */
+    public Collection<Repository> getRepositories( Server server ) throws Exception {
+        CheckArg.isNotNull(server, "server"); //$NON-NLS-1$
+
+        try {
+            this.serverLock.readLock().lock();
+
+            if (isRegistered(server)) {
+                Collection<Repository> repositories = this.delegate.getRepositories(server);
+                return Collections.unmodifiableCollection(new ArrayList<Repository>(repositories));
+            }
+
+            // server must be registered in order to obtain it's repositories
+            throw new RuntimeException(RestClientI18n.serverManagerUnregisteredServer.text(server.getShortDescription()));
+        } finally {
+            this.serverLock.readLock().unlock();
+        }
+    }
+
+    /**
+     * {@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)
+     */
+    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)
+     */
+    public Collection<Workspace> getWorkspaces( Repository repository ) throws Exception {
+        CheckArg.isNotNull(repository, "repository"); //$NON-NLS-1$
+
+        try {
+            this.serverLock.readLock().lock();
+
+            if (isRegistered(repository.getServer())) {
+                Collection<Workspace> workspaces = this.delegate.getWorkspaces(repository);
+                return Collections.unmodifiableCollection(new ArrayList<Workspace>(workspaces));
+            }
+
+            // a repository's server must be registered in order to obtain it's
+            // workspaces
+            String msg = RestClientI18n.serverManagerUnregisteredServer.text(repository.getServer().getShortDescription());
+            throw new RuntimeException(msg);
+        } finally {
+            this.serverLock.readLock().unlock();
+        }
+    }
+
+    /**
+     * Registers the specified <code>Server</code>.
+     * 
+     * @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
+     */
+    private Status internalAddServer( Server server,
+                                      boolean notifyListeners ) {
+        boolean added = false;
+
+        try {
+            this.serverLock.writeLock().lock();
+
+            if (!isRegistered(server)) {
+                added = this.servers.add(server);
+            }
+        } finally {
+            this.serverLock.writeLock().unlock();
+        }
+
+        if (added) {
+            if (notifyListeners) {
+                Exception[] errors = notifyRegistryListeners(ServerRegistryEvent.createNewEvent(this, server));
+                return processRegistryListenerErrors(errors);
+            }
+
+            return Status.OK_STATUS;
+        }
+
+        // server already exists
+        return new Status(Severity.ERROR, RestClientI18n.serverExistsMsg.text(server.getShortDescription()), null);
+    }
+
+    /**
+     * @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
+     */
+    private Status internalRemoveServer( Server server,
+                                         boolean notifyListeners ) {
+        boolean removed = false;
+
+        try {
+            this.serverLock.writeLock().lock();
+
+            // see if registered server has the same key
+            for (Server registeredServer : this.servers) {
+                if (registeredServer.hasSameKey(server)) {
+                    removed = this.servers.remove(registeredServer);
+                    break;
+                }
+            }
+        } finally {
+            this.serverLock.writeLock().unlock();
+        }
+
+        if (removed) {
+            if (notifyListeners) {
+                Exception[] errors = notifyRegistryListeners(ServerRegistryEvent.createRemoveEvent(this, server));
+                return processRegistryListenerErrors(errors);
+            }
+
+            return Status.OK_STATUS;
+        }
+
+        // server could not be removed
+        return new Status(Severity.ERROR,
+                          RestClientI18n.serverManagerRegistryRemoveUnexpectedError.text(server.getShortDescription()), null);
+    }
+
+    /**
+     * @param server the server being tested (never <code>null</code>)
+     * @return <code>true</code> if the server has been registered
+     */
+    public boolean isRegistered( Server server ) {
+        CheckArg.isNotNull(server, "server"); //$NON-NLS-1$
+
+        try {
+            this.serverLock.readLock().lock();
+
+            // check to make sure no other registered server has the same key
+            for (Server registeredServer : this.servers) {
+                if (registeredServer.hasSameKey(server)) {
+                    return true;
+                }
+            }
+
+            return false;
+        } finally {
+            this.serverLock.readLock().unlock();
+        }
+    }
+
+    /**
+     * @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)
+     */
+    private Exception[] notifyRegistryListeners( ServerRegistryEvent event ) {
+        Collection<Exception> errors = null;
+
+        for (IServerRegistryListener l : this.listeners) {
+            try {
+                Exception[] problems = l.serverRegistryChanged(event);
+
+                if ((problems != null) && (problems.length != 0)) {
+                    if (errors == null) {
+                        errors = new ArrayList<Exception>();
+                    }
+
+                    errors.addAll(Arrays.asList(problems));
+                }
+            } catch (Exception e) {
+                if (errors == null) {
+                    errors = new ArrayList<Exception>();
+                }
+
+                errors.add(e);
+            }
+        }
+
+        if ((errors != null) && !errors.isEmpty()) {
+            return errors.toArray(new Exception[errors.size()]);
+        }
+
+        return null;
+    }
+
+    /**
+     * @param errors the errors reported by the registry listeners
+     * @return a status indicating if registry listeners reported any errors
+     */
+    private Status processRegistryListenerErrors( Exception[] errors ) {
+        if (errors == null) {
+            return Status.OK_STATUS;
+        }
+
+        for (Exception error : errors) {
+            this.logger.error(error, RestClientI18n.serverManagerRegistryListenerError);
+        }
+
+        return new Status(Severity.WARNING, RestClientI18n.serverManagerRegistryListenerErrorsOccurred.text(), null);
+    }
+
+    /**
+     * Attempts to connect to the server. The server does <strong>NOT</strong> need to be registered.
+     * 
+     * @param server the server being pinged (never <code>null</code>)
+     * @return a status indicating if the server can be connected to
+     * @see #isRegistered(Server)
+     */
+    public Status ping( Server server ) {
+        CheckArg.isNotNull(server, "server"); //$NON-NLS-1$
+
+        try {
+            this.delegate.getRepositories(server);
+            return new Status(Severity.OK, RestClientI18n.serverManagerConnectionEstablishedMsg.text(), null);
+        } catch (Exception e) {
+            return new Status(Severity.ERROR, RestClientI18n.serverManagerConnectionFailedMsg.text(e), null);
+        }
+    }
+
+    /**
+     * {@inheritDoc}
+     * <p>
+     * Only tries to unpublish if the workspace's {@link Server server} is registered.
+     * 
+     * @see org.jboss.dna.web.jcr.rest.client.IRestClient#publish(org.jboss.dna.web.jcr.rest.client.domain.Workspace,
+     *      java.lang.String, java.io.File)
+     * @see #isRegistered(Server)
+     */
+    public Status publish( Workspace workspace,
+                           String path,
+                           File file ) {
+        CheckArg.isNotNull(workspace, "workspace"); //$NON-NLS-1$
+        CheckArg.isNotNull(path, "path"); //$NON-NLS-1$
+        CheckArg.isNotNull(file, "file"); //$NON-NLS-1$
+
+        Server server = workspace.getServer();
+
+        if (isRegistered(server)) {
+            return this.delegate.publish(workspace, path, file);
+        }
+
+        // server must be registered in order to publish
+        throw new RuntimeException(RestClientI18n.serverManagerUnregisteredServer.text(server.getShortDescription()));
+    }
+
+    /**
+     * @param listener the listener being unregistered and will no longer receive events (never <code>null</code>)
+     * @return <code>true</code> if listener was removed
+     */
+    public boolean removeRegistryListener( IServerRegistryListener listener ) {
+        CheckArg.isNotNull(listener, "listener"); //$NON-NLS-1$
+        return this.listeners.remove(listener);
+    }
+
+    /**
+     * @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>)
+     */
+    public Status removeServer( Server server ) {
+        CheckArg.isNotNull(server, "server"); //$NON-NLS-1$
+        return internalRemoveServer(server, true);
+    }
+
+    /**
+     * @return a status indicating if the previous session state was restored successfully
+     */
+    public Status restoreState() {
+        if (this.stateLocationPath != null) {
+            if (stateFileExists()) {
+                try {
+                    DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
+                    DocumentBuilder docBuilder = factory.newDocumentBuilder();
+                    Document doc = docBuilder.parse(new File(getStateFileName()));
+                    Node root = doc.getDocumentElement();
+                    NodeList servers = root.getChildNodes();
+
+                    for (int size = servers.getLength(), i = 0; i < size; ++i) {
+                        Node server = servers.item(i);
+
+                        if (server.getNodeType() != Node.TEXT_NODE) {
+                            NamedNodeMap attributeMap = server.getAttributes();
+
+                            if (attributeMap == null) continue;
+
+                            Node urlNode = attributeMap.getNamedItem(URL_TAG);
+                            Node userNode = attributeMap.getNamedItem(USER_TAG);
+                            Node passwordNode = attributeMap.getNamedItem(PASSWORD_TAG);
+                            String pswd = ((passwordNode == null) ? null : new String(Base64.decode(passwordNode.getNodeValue()),
+                                                                                      "UTF-8")); //$NON-NLS-1$
+
+                            // add server to registry
+                            addServer(new DnaServer(urlNode.getNodeValue(), userNode.getNodeValue(), pswd, (pswd != null)));
+                        }
+                    }
+                } catch (Exception e) {
+                    return new Status(Severity.ERROR, RestClientI18n.errorRestoringServerRegistry.text(getStateFileName()), e);
+                }
+            }
+        }
+
+        // do nothing of there is no save location or state file does not exist
+        return Status.OK_STATUS;
+    }
+
+    /**
+     * Saves the {@link Server} registry to the file system.
+     * 
+     * @return a status indicating if the registry was successfully saved
+     */
+    public Status saveState() {
+        if ((this.stateLocationPath != null) && !getServers().isEmpty()) {
+            try {
+                DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
+                DocumentBuilder docBuilder = factory.newDocumentBuilder();
+                Document doc = docBuilder.newDocument();
+
+                // create root element
+                Element root = doc.createElement(SERVERS_TAG);
+                doc.appendChild(root);
+
+                for (Server server : getServers()) {
+                    Element serverElement = doc.createElement(SERVER_TAG);
+                    root.appendChild(serverElement);
+
+                    serverElement.setAttribute(URL_TAG, server.getUrl());
+                    serverElement.setAttribute(USER_TAG, server.getUser());
+
+                    if ((server instanceof DnaServer) && ((DnaServer)server).isPasswordBeingPersisted()) {
+                        serverElement.setAttribute(PASSWORD_TAG, Base64.encodeBytes(server.getPassword().getBytes()));
+                    }
+                }
+
+                DOMSource source = new DOMSource(doc);
+                StreamResult resultXML = new StreamResult(new FileOutputStream(getStateFileName()));
+                TransformerFactory transFactory = TransformerFactory.newInstance();
+                Transformer transformer = transFactory.newTransformer();
+                transformer.setOutputProperty(OutputKeys.INDENT, "yes"); //$NON-NLS-1$
+                transformer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "2"); //$NON-NLS-1$ //$NON-NLS-2$
+                transformer.transform(source, resultXML);
+            } catch (Exception e) {
+                return new Status(Severity.ERROR, RestClientI18n.errorSavingServerRegistry.text(getStateFileName()), e);
+            }
+        } else if ((this.stateLocationPath != null) && stateFileExists()) {
+            // delete current registry file since all servers have been deleted
+            try {
+                new File(getStateFileName()).delete();
+            } catch (Exception e) {
+                return new Status(Severity.ERROR, RestClientI18n.errorDeletingServerRegistryFile.text(getStateFileName()), e);
+            }
+        }
+
+        return Status.OK_STATUS;
+    }
+
+    /**
+     * @return <code>true</code> if the state file already exists
+     */
+    private boolean stateFileExists() {
+        return new File(getStateFileName()).exists();
+    }
+
+    /**
+     * {@inheritDoc}
+     * <p>
+     * Only tries to unpublish if the workspace's {@link Server server} is registered.
+     * 
+     * @see org.jboss.dna.web.jcr.rest.client.IRestClient#unpublish(org.jboss.dna.web.jcr.rest.client.domain.Workspace,
+     *      java.lang.String, java.io.File)
+     * @see #isRegistered(Server)
+     */
+    public Status unpublish( Workspace workspace,
+                             String path,
+                             File file ) {
+        CheckArg.isNotNull(workspace, "workspace"); //$NON-NLS-1$
+        CheckArg.isNotNull(path, "path"); //$NON-NLS-1$
+        CheckArg.isNotNull(file, "file"); //$NON-NLS-1$
+
+        Server server = workspace.getServer();
+
+        if (isRegistered(server)) {
+            return this.delegate.unpublish(workspace, path, file);
+        }
+
+        // server must be registered in order to unpublish
+        throw new RuntimeException(RestClientI18n.serverManagerUnregisteredServer.text(server.getShortDescription()));
+    }
+
+    /**
+     * Updates the server registry with a new version of a server.
+     * 
+     * @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>)
+     */
+    public Status updateServer( Server previousServerVersion,
+                                Server newServerVersion ) {
+        CheckArg.isNotNull(previousServerVersion, "previousServerVersion"); //$NON-NLS-1$
+        CheckArg.isNotNull(newServerVersion, "newServerVersion"); //$NON-NLS-1$
+
+        Status status = null;
+
+        try {
+            this.serverLock.writeLock().lock();
+            status = internalRemoveServer(previousServerVersion, false);
+
+            if (status.isOk()) {
+                status = internalAddServer(newServerVersion, false);
+
+                if (status.isOk()) {
+                    // all good so notify listeners
+                    Exception[] errors = notifyRegistryListeners(ServerRegistryEvent.createUpdateEvent(this,
+                                                                                                       previousServerVersion,
+                                                                                                       newServerVersion));
+                    return processRegistryListenerErrors(errors);
+                }
+
+                // unexpected problem adding new version of server to registry
+                return new Status(Severity.ERROR, RestClientI18n.serverManagerRegistryUpdateAddError.text(status.getMessage()),
+                                  status.getException());
+            }
+        } finally {
+            this.serverLock.writeLock().unlock();
+        }
+
+        // unexpected problem removing server from registry
+        return new Status(Severity.ERROR, RestClientI18n.serverManagerRegistryUpdateRemoveError.text(status.getMessage()),
+                          status.getException());
+    }
+
+}


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

Added: eclipse/trunk/org.jboss.dna.eclipse.jcr.rest.client/src/org/jboss/dna/eclipse/jcr/rest/client/ServerRegistryEvent.java
===================================================================
--- eclipse/trunk/org.jboss.dna.eclipse.jcr.rest.client/src/org/jboss/dna/eclipse/jcr/rest/client/ServerRegistryEvent.java	                        (rev 0)
+++ eclipse/trunk/org.jboss.dna.eclipse.jcr.rest.client/src/org/jboss/dna/eclipse/jcr/rest/client/ServerRegistryEvent.java	2009-12-18 22:04:48 UTC (rev 1461)
@@ -0,0 +1,204 @@
+/*
+ * JBoss DNA (http://www.jboss.org/dna)
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership.  Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ * See the AUTHORS.txt file in the distribution for a full listing of 
+ * individual contributors.
+ *
+ * JBoss DNA is free software. Unless otherwise indicated, all code in JBoss DNA
+ * is licensed to you under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ * 
+ * JBoss DNA is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.dna.eclipse.jcr.rest.client;
+
+import org.jboss.dna.common.util.CheckArg;
+import org.jboss.dna.web.jcr.rest.client.domain.Server;
+
+/**
+ * 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.
+ */
+public final class ServerRegistryEvent {
+
+    // ===========================================================================================================================
+    // Constants
+    // ===========================================================================================================================
+
+    /**
+     * The status severity levels.
+     */
+    private enum Type {
+        /**
+         * Indicates that a new server was added to the server registry.
+         */
+        NEW,
+
+        /**
+         * Indicates that a server was removed from the server registry.
+         */
+        REMOVE,
+
+        /**
+         * Indicates that properties of an existing server in the registry has been changed.
+         */
+        UPDATE
+    }
+
+    // ===========================================================================================================================
+    // Class Methods
+    // ===========================================================================================================================
+
+    /**
+     * @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
+     */
+    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(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
+     */
+    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(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
+     */
+    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(serverManager, Type.UPDATE, previousServerVersion);
+        event.updatedServer = newServerVersion;
+        return event;
+    }
+
+    // ===========================================================================================================================
+    // Fields
+    // ===========================================================================================================================
+
+    /**
+     * The server being added, removed, or updated.
+     */
+    private final Server server;
+
+    /**
+     * The server manager in charge of the server registry the event is associated with.
+     */
+    private final ServerManager serverManager;
+
+    /**
+     * The event type.
+     */
+    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}.
+     */
+    private Server updatedServer;
+
+    // ===========================================================================================================================
+    // Constructors
+    // ===========================================================================================================================
+
+    /**
+     * @param serverManager the server manager sourcing this event
+     * @param type the event type
+     * @param server the server being added, removed, or updated
+     */
+    private ServerRegistryEvent( ServerManager serverManager,
+                                 Type type,
+                                 Server server ) {
+        this.serverManager = serverManager;
+        this.type = type;
+        this.server = server;
+    }
+
+    // ===========================================================================================================================
+    // Methods
+    // ===========================================================================================================================
+
+    /**
+     * @return the added, removed, or the old version of the server that has been updated
+     */
+    public Server getServer() {
+        return this.server;
+    }
+
+    /**
+     * @return the server manager sourcing this event
+     */
+    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
+     */
+    public Server getUpdatedServer() {
+        if (this.type != Type.UPDATE) {
+            throw new UnsupportedOperationException();
+        }
+
+        return this.updatedServer;
+    }
+
+    /**
+     * @return <code>true</code> if the event is adding a new server to the registry
+     * @see Type#NEW
+     */
+    public boolean isNew() {
+        return (this.type == Type.NEW);
+    }
+
+    /**
+     * @return <code>true</code> if the event is removing a server from the registry
+     * @see Type#REMOVE
+     */
+    public boolean isRemove() {
+        return (this.type == Type.REMOVE);
+    }
+
+    /**
+     * @return <code>true</code> if the event is updating properties of an existing server in the registry
+     * @see Type#UPDATE
+     */
+    public boolean isUpdate() {
+        return (this.type == Type.UPDATE);
+    }
+
+}


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

Modified: eclipse/trunk/org.jboss.dna.eclipse.jcr.rest.client/src/org/jboss/dna/eclipse/jcr/rest/client/Utils.java
===================================================================
--- eclipse/trunk/org.jboss.dna.eclipse.jcr.rest.client/src/org/jboss/dna/eclipse/jcr/rest/client/Utils.java	2009-12-18 20:56:07 UTC (rev 1460)
+++ eclipse/trunk/org.jboss.dna.eclipse.jcr.rest.client/src/org/jboss/dna/eclipse/jcr/rest/client/Utils.java	2009-12-18 22:04:48 UTC (rev 1461)
@@ -24,6 +24,7 @@
 package org.jboss.dna.eclipse.jcr.rest.client;
 
 import static org.jboss.dna.eclipse.jcr.rest.client.IUiConstants.PLUGIN_ID;
+import java.net.URL;
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.StringTokenizer;
@@ -209,6 +210,68 @@
         return null;
     }
 
+    /**
+     * @param password the password being validated
+     * @return a validation status (never <code>null</code>)
+     */
+    public static Status isPasswordValid( String password ) {
+        return Status.OK_STATUS;
+    }
+
+    /**
+     * This does not verify that a server with the same primary field values doesn't already exist in the server registry.
+     * 
+     * @param url the URL being validated
+     * @param user the user being validated
+     * @param password the password being validated
+     * @return a validation status (never <code>null</code>)
+     */
+    public static Status isServerValid( String url,
+                                        String user,
+                                        String password ) {
+        Status status = isUrlValid(url);
+
+        if (!status.isError()) {
+            status = isUserValid(user);
+
+            if (!status.isError()) {
+                status = isPasswordValid(password);
+            }
+        }
+
+        return status;
+    }
+
+    /**
+     * @param url the URL being validated
+     * @return a validation status (never <code>null</code>)
+     */
+    public static Status isUrlValid( String url ) {
+        if ((url == null) || (url.length() == 0)) {
+            return new Status(Severity.ERROR, RestClientI18n.serverEmptyUrlMsg.text(), null);
+        }
+
+        try {
+            new URL(url);
+        } catch (Exception e) {
+            return new Status(Severity.ERROR, RestClientI18n.serverInvalidUrlMsg.text(url), e);
+        }
+
+        return Status.OK_STATUS;
+    }
+
+    /**
+     * @param user the user being validated
+     * @return a validation status (never <code>null</code>)
+     */
+    public static Status isUserValid( String user ) {
+        if ((user == null) || (user.length() == 0)) {
+            return new Status(Severity.ERROR, RestClientI18n.serverEmptyUserMsg.text(), null);
+        }
+
+        return Status.OK_STATUS;
+    }
+
     // ===========================================================================================================================
     // Constructors
     // ===========================================================================================================================

Modified: eclipse/trunk/org.jboss.dna.eclipse.jcr.rest.client/src/org/jboss/dna/eclipse/jcr/rest/client/actions/DeleteServerAction.java
===================================================================
--- eclipse/trunk/org.jboss.dna.eclipse.jcr.rest.client/src/org/jboss/dna/eclipse/jcr/rest/client/actions/DeleteServerAction.java	2009-12-18 20:56:07 UTC (rev 1460)
+++ eclipse/trunk/org.jboss.dna.eclipse.jcr.rest.client/src/org/jboss/dna/eclipse/jcr/rest/client/actions/DeleteServerAction.java	2009-12-18 22:04:48 UTC (rev 1461)
@@ -34,8 +34,8 @@
 import org.eclipse.ui.actions.BaseSelectionListenerAction;
 import org.jboss.dna.eclipse.jcr.rest.client.Activator;
 import org.jboss.dna.eclipse.jcr.rest.client.RestClientI18n;
+import org.jboss.dna.eclipse.jcr.rest.client.ServerManager;
 import org.jboss.dna.eclipse.jcr.rest.client.dialogs.DeleteServerDialog;
-import org.jboss.dna.web.jcr.rest.client.ServerManager;
 import org.jboss.dna.web.jcr.rest.client.Status;
 import org.jboss.dna.web.jcr.rest.client.domain.Server;
 

Modified: eclipse/trunk/org.jboss.dna.eclipse.jcr.rest.client/src/org/jboss/dna/eclipse/jcr/rest/client/actions/EditServerAction.java
===================================================================
--- eclipse/trunk/org.jboss.dna.eclipse.jcr.rest.client/src/org/jboss/dna/eclipse/jcr/rest/client/actions/EditServerAction.java	2009-12-18 20:56:07 UTC (rev 1460)
+++ eclipse/trunk/org.jboss.dna.eclipse.jcr.rest.client/src/org/jboss/dna/eclipse/jcr/rest/client/actions/EditServerAction.java	2009-12-18 22:04:48 UTC (rev 1461)
@@ -30,13 +30,13 @@
 import org.eclipse.swt.widgets.Shell;
 import org.eclipse.ui.actions.BaseSelectionListenerAction;
 import org.jboss.dna.eclipse.jcr.rest.client.Activator;
+import org.jboss.dna.eclipse.jcr.rest.client.DnaServer;
 import org.jboss.dna.eclipse.jcr.rest.client.RestClientI18n;
+import org.jboss.dna.eclipse.jcr.rest.client.ServerManager;
 import org.jboss.dna.eclipse.jcr.rest.client.wizards.ServerWizard;
-import org.jboss.dna.web.jcr.rest.client.ServerManager;
-import org.jboss.dna.web.jcr.rest.client.domain.Server;
 
 /**
- * The <code>EditServerAction</code> runs a UI that allows {@link Server server} properties to be changed.
+ * The <code>EditServerAction</code> runs a UI that allows {@link DnaServer server} properties to be changed.
  */
 public final class EditServerAction extends BaseSelectionListenerAction {
 
@@ -47,7 +47,7 @@
     /**
      * The selected server being edited.
      */
-    private Server serverBeingEdited;
+    private DnaServer serverBeingEdited;
 
     /**
      * The server manager used to create and edit servers.
@@ -122,8 +122,8 @@
         Object obj = selection.getFirstElement();
 
         // enable if server is selected
-        if (obj instanceof Server) {
-            this.serverBeingEdited = (Server)obj;
+        if (obj instanceof DnaServer) {
+            this.serverBeingEdited = (DnaServer)obj;
             return true;
         }
 

Modified: eclipse/trunk/org.jboss.dna.eclipse.jcr.rest.client/src/org/jboss/dna/eclipse/jcr/rest/client/actions/NewServerAction.java
===================================================================
--- eclipse/trunk/org.jboss.dna.eclipse.jcr.rest.client/src/org/jboss/dna/eclipse/jcr/rest/client/actions/NewServerAction.java	2009-12-18 20:56:07 UTC (rev 1460)
+++ eclipse/trunk/org.jboss.dna.eclipse.jcr.rest.client/src/org/jboss/dna/eclipse/jcr/rest/client/actions/NewServerAction.java	2009-12-18 22:04:48 UTC (rev 1461)
@@ -29,13 +29,13 @@
 import org.eclipse.jface.wizard.WizardDialog;
 import org.eclipse.swt.widgets.Shell;
 import org.jboss.dna.eclipse.jcr.rest.client.Activator;
+import org.jboss.dna.eclipse.jcr.rest.client.DnaServer;
 import org.jboss.dna.eclipse.jcr.rest.client.RestClientI18n;
+import org.jboss.dna.eclipse.jcr.rest.client.ServerManager;
 import org.jboss.dna.eclipse.jcr.rest.client.wizards.ServerWizard;
-import org.jboss.dna.web.jcr.rest.client.ServerManager;
-import org.jboss.dna.web.jcr.rest.client.domain.Server;
 
 /**
- * The <code>NewServerAction</code> runs a UI that allows the user to create a new {@link Server server}.
+ * The <code>NewServerAction</code> runs a UI that allows the user to create a new {@link DnaServer server}.
  */
 public final class NewServerAction extends Action {
 

Modified: eclipse/trunk/org.jboss.dna.eclipse.jcr.rest.client/src/org/jboss/dna/eclipse/jcr/rest/client/actions/ShowPublishedLocationsAction.java
===================================================================
--- eclipse/trunk/org.jboss.dna.eclipse.jcr.rest.client/src/org/jboss/dna/eclipse/jcr/rest/client/actions/ShowPublishedLocationsAction.java	2009-12-18 20:56:07 UTC (rev 1460)
+++ eclipse/trunk/org.jboss.dna.eclipse.jcr.rest.client/src/org/jboss/dna/eclipse/jcr/rest/client/actions/ShowPublishedLocationsAction.java	2009-12-18 22:04:48 UTC (rev 1461)
@@ -37,8 +37,8 @@
 import org.jboss.dna.eclipse.jcr.rest.client.Activator;
 import org.jboss.dna.eclipse.jcr.rest.client.DnaResourceHelper;
 import org.jboss.dna.eclipse.jcr.rest.client.RestClientI18n;
+import org.jboss.dna.eclipse.jcr.rest.client.ServerManager;
 import org.jboss.dna.eclipse.jcr.rest.client.dialogs.PublishedLocationsDialog;
-import org.jboss.dna.web.jcr.rest.client.ServerManager;
 import org.jboss.dna.web.jcr.rest.client.Status;
 import org.jboss.dna.web.jcr.rest.client.Status.Severity;
 import org.jboss.dna.web.jcr.rest.client.domain.Workspace;

Modified: eclipse/trunk/org.jboss.dna.eclipse.jcr.rest.client/src/org/jboss/dna/eclipse/jcr/rest/client/dialogs/PublishedLocationsDialog.java
===================================================================
--- eclipse/trunk/org.jboss.dna.eclipse.jcr.rest.client/src/org/jboss/dna/eclipse/jcr/rest/client/dialogs/PublishedLocationsDialog.java	2009-12-18 20:56:07 UTC (rev 1460)
+++ eclipse/trunk/org.jboss.dna.eclipse.jcr.rest.client/src/org/jboss/dna/eclipse/jcr/rest/client/dialogs/PublishedLocationsDialog.java	2009-12-18 22:04:48 UTC (rev 1461)
@@ -61,8 +61,8 @@
 import org.jboss.dna.common.util.CheckArg;
 import org.jboss.dna.eclipse.jcr.rest.client.Activator;
 import org.jboss.dna.eclipse.jcr.rest.client.RestClientI18n;
+import org.jboss.dna.eclipse.jcr.rest.client.ServerManager;
 import org.jboss.dna.eclipse.jcr.rest.client.Utils;
-import org.jboss.dna.web.jcr.rest.client.ServerManager;
 import org.jboss.dna.web.jcr.rest.client.Status;
 import org.jboss.dna.web.jcr.rest.client.Status.Severity;
 import org.jboss.dna.web.jcr.rest.client.domain.Server;

Modified: eclipse/trunk/org.jboss.dna.eclipse.jcr.rest.client/src/org/jboss/dna/eclipse/jcr/rest/client/jobs/PublishJob.java
===================================================================
--- eclipse/trunk/org.jboss.dna.eclipse.jcr.rest.client/src/org/jboss/dna/eclipse/jcr/rest/client/jobs/PublishJob.java	2009-12-18 20:56:07 UTC (rev 1460)
+++ eclipse/trunk/org.jboss.dna.eclipse.jcr.rest.client/src/org/jboss/dna/eclipse/jcr/rest/client/jobs/PublishJob.java	2009-12-18 22:04:48 UTC (rev 1461)
@@ -37,9 +37,9 @@
 import org.jboss.dna.eclipse.jcr.rest.client.Activator;
 import org.jboss.dna.eclipse.jcr.rest.client.DnaResourceHelper;
 import org.jboss.dna.eclipse.jcr.rest.client.RestClientI18n;
+import org.jboss.dna.eclipse.jcr.rest.client.ServerManager;
 import org.jboss.dna.eclipse.jcr.rest.client.views.DnaContentProvider;
 import org.jboss.dna.eclipse.jcr.rest.client.views.DnaMessageConsole;
-import org.jboss.dna.web.jcr.rest.client.ServerManager;
 import org.jboss.dna.web.jcr.rest.client.Status;
 import org.jboss.dna.web.jcr.rest.client.domain.Workspace;
 

Modified: eclipse/trunk/org.jboss.dna.eclipse.jcr.rest.client/src/org/jboss/dna/eclipse/jcr/rest/client/jobs/ReconnectJob.java
===================================================================
--- eclipse/trunk/org.jboss.dna.eclipse.jcr.rest.client/src/org/jboss/dna/eclipse/jcr/rest/client/jobs/ReconnectJob.java	2009-12-18 20:56:07 UTC (rev 1460)
+++ eclipse/trunk/org.jboss.dna.eclipse.jcr.rest.client/src/org/jboss/dna/eclipse/jcr/rest/client/jobs/ReconnectJob.java	2009-12-18 22:04:48 UTC (rev 1461)
@@ -31,8 +31,8 @@
 import org.eclipse.core.runtime.jobs.Job;
 import org.jboss.dna.eclipse.jcr.rest.client.Activator;
 import org.jboss.dna.eclipse.jcr.rest.client.RestClientI18n;
+import org.jboss.dna.eclipse.jcr.rest.client.ServerManager;
 import org.jboss.dna.eclipse.jcr.rest.client.Utils;
-import org.jboss.dna.web.jcr.rest.client.ServerManager;
 import org.jboss.dna.web.jcr.rest.client.Status;
 import org.jboss.dna.web.jcr.rest.client.domain.Server;
 

Modified: eclipse/trunk/org.jboss.dna.eclipse.jcr.rest.client/src/org/jboss/dna/eclipse/jcr/rest/client/views/DnaContentProvider.java
===================================================================
--- eclipse/trunk/org.jboss.dna.eclipse.jcr.rest.client/src/org/jboss/dna/eclipse/jcr/rest/client/views/DnaContentProvider.java	2009-12-18 20:56:07 UTC (rev 1460)
+++ eclipse/trunk/org.jboss.dna.eclipse.jcr.rest.client/src/org/jboss/dna/eclipse/jcr/rest/client/views/DnaContentProvider.java	2009-12-18 22:04:48 UTC (rev 1461)
@@ -24,11 +24,14 @@
 package org.jboss.dna.eclipse.jcr.rest.client.views;
 
 import static org.jboss.dna.eclipse.jcr.rest.client.IUiConstants.PUBLISHED_OVERLAY_IMAGE;
+
 import java.util.HashMap;
 import java.util.Map;
 import java.util.concurrent.locks.ReadWriteLock;
 import java.util.concurrent.locks.ReentrantReadWriteLock;
+
 import net.jcip.annotations.GuardedBy;
+
 import org.eclipse.core.resources.IFile;
 import org.eclipse.jface.resource.ImageDescriptor;
 import org.eclipse.jface.viewers.ColumnLabelProvider;
@@ -42,11 +45,11 @@
 import org.eclipse.ui.IDecoratorManager;
 import org.jboss.dna.eclipse.jcr.rest.client.Activator;
 import org.jboss.dna.eclipse.jcr.rest.client.DnaResourceHelper;
+import org.jboss.dna.eclipse.jcr.rest.client.IServerRegistryListener;
 import org.jboss.dna.eclipse.jcr.rest.client.RestClientI18n;
+import org.jboss.dna.eclipse.jcr.rest.client.ServerManager;
+import org.jboss.dna.eclipse.jcr.rest.client.ServerRegistryEvent;
 import org.jboss.dna.eclipse.jcr.rest.client.Utils;
-import org.jboss.dna.web.jcr.rest.client.IServerRegistryListener;
-import org.jboss.dna.web.jcr.rest.client.ServerManager;
-import org.jboss.dna.web.jcr.rest.client.ServerRegistryEvent;
 import org.jboss.dna.web.jcr.rest.client.Status;
 import org.jboss.dna.web.jcr.rest.client.Status.Severity;
 import org.jboss.dna.web.jcr.rest.client.domain.IDnaObject;
@@ -400,8 +403,8 @@
 
     /**
      * {@inheritDoc}
-     * 
-     * @see org.jboss.dna.web.jcr.rest.client.IServerRegistryListener#serverRegistryChanged(org.jboss.dna.web.jcr.rest.client.ServerRegistryEvent)
+     *
+     * @see org.jboss.dna.eclipse.jcr.rest.client.IServerRegistryListener#serverRegistryChanged(org.jboss.dna.eclipse.jcr.rest.client.ServerRegistryEvent)
      */
     @Override
     public Exception[] serverRegistryChanged( ServerRegistryEvent event ) {

Modified: eclipse/trunk/org.jboss.dna.eclipse.jcr.rest.client/src/org/jboss/dna/eclipse/jcr/rest/client/views/ServerView.java
===================================================================
--- eclipse/trunk/org.jboss.dna.eclipse.jcr.rest.client/src/org/jboss/dna/eclipse/jcr/rest/client/views/ServerView.java	2009-12-18 20:56:07 UTC (rev 1460)
+++ eclipse/trunk/org.jboss.dna.eclipse.jcr.rest.client/src/org/jboss/dna/eclipse/jcr/rest/client/views/ServerView.java	2009-12-18 22:04:48 UTC (rev 1461)
@@ -50,14 +50,14 @@
 import org.eclipse.ui.help.IWorkbenchHelpSystem;
 import org.eclipse.ui.part.ViewPart;
 import org.jboss.dna.eclipse.jcr.rest.client.Activator;
+import org.jboss.dna.eclipse.jcr.rest.client.IServerRegistryListener;
 import org.jboss.dna.eclipse.jcr.rest.client.RestClientI18n;
+import org.jboss.dna.eclipse.jcr.rest.client.ServerManager;
+import org.jboss.dna.eclipse.jcr.rest.client.ServerRegistryEvent;
 import org.jboss.dna.eclipse.jcr.rest.client.actions.DeleteServerAction;
 import org.jboss.dna.eclipse.jcr.rest.client.actions.EditServerAction;
 import org.jboss.dna.eclipse.jcr.rest.client.actions.NewServerAction;
 import org.jboss.dna.eclipse.jcr.rest.client.actions.ReconnectToServerAction;
-import org.jboss.dna.web.jcr.rest.client.IServerRegistryListener;
-import org.jboss.dna.web.jcr.rest.client.ServerManager;
-import org.jboss.dna.web.jcr.rest.client.ServerRegistryEvent;
 import org.jboss.dna.web.jcr.rest.client.domain.IDnaObject;
 
 /**
@@ -305,8 +305,8 @@
 
     /**
      * {@inheritDoc}
-     * 
-     * @see org.jboss.dna.web.jcr.rest.client.IServerRegistryListener#serverRegistryChanged(org.jboss.dna.web.jcr.rest.client.ServerRegistryEvent)
+     *
+     * @see org.jboss.dna.eclipse.jcr.rest.client.IServerRegistryListener#serverRegistryChanged(org.jboss.dna.eclipse.jcr.rest.client.ServerRegistryEvent)
      */
     @Override
     public Exception[] serverRegistryChanged( ServerRegistryEvent event ) {

Modified: eclipse/trunk/org.jboss.dna.eclipse.jcr.rest.client/src/org/jboss/dna/eclipse/jcr/rest/client/wizards/PublishPage.java
===================================================================
--- eclipse/trunk/org.jboss.dna.eclipse.jcr.rest.client/src/org/jboss/dna/eclipse/jcr/rest/client/wizards/PublishPage.java	2009-12-18 20:56:07 UTC (rev 1460)
+++ eclipse/trunk/org.jboss.dna.eclipse.jcr.rest.client/src/org/jboss/dna/eclipse/jcr/rest/client/wizards/PublishPage.java	2009-12-18 22:04:48 UTC (rev 1461)
@@ -55,13 +55,13 @@
 import org.eclipse.swt.widgets.Label;
 import org.eclipse.ui.help.IWorkbenchHelpSystem;
 import org.jboss.dna.eclipse.jcr.rest.client.Activator;
+import org.jboss.dna.eclipse.jcr.rest.client.IServerRegistryListener;
 import org.jboss.dna.eclipse.jcr.rest.client.RestClientI18n;
+import org.jboss.dna.eclipse.jcr.rest.client.ServerManager;
+import org.jboss.dna.eclipse.jcr.rest.client.ServerRegistryEvent;
 import org.jboss.dna.eclipse.jcr.rest.client.actions.NewServerAction;
 import org.jboss.dna.eclipse.jcr.rest.client.jobs.PublishJob.Type;
 import org.jboss.dna.eclipse.jcr.rest.client.preferences.PublishingFileFilter;
-import org.jboss.dna.web.jcr.rest.client.IServerRegistryListener;
-import org.jboss.dna.web.jcr.rest.client.ServerManager;
-import org.jboss.dna.web.jcr.rest.client.ServerRegistryEvent;
 import org.jboss.dna.web.jcr.rest.client.Status;
 import org.jboss.dna.web.jcr.rest.client.Status.Severity;
 import org.jboss.dna.web.jcr.rest.client.domain.Repository;
@@ -891,8 +891,8 @@
 
     /**
      * {@inheritDoc}
-     * 
-     * @see org.jboss.dna.web.jcr.rest.client.IServerRegistryListener#serverRegistryChanged(org.jboss.dna.web.jcr.rest.client.ServerRegistryEvent)
+     *
+     * @see org.jboss.dna.eclipse.jcr.rest.client.IServerRegistryListener#serverRegistryChanged(org.jboss.dna.eclipse.jcr.rest.client.ServerRegistryEvent)
      */
     @Override
     public Exception[] serverRegistryChanged( ServerRegistryEvent event ) {

Modified: eclipse/trunk/org.jboss.dna.eclipse.jcr.rest.client/src/org/jboss/dna/eclipse/jcr/rest/client/wizards/PublishWizard.java
===================================================================
--- eclipse/trunk/org.jboss.dna.eclipse.jcr.rest.client/src/org/jboss/dna/eclipse/jcr/rest/client/wizards/PublishWizard.java	2009-12-18 20:56:07 UTC (rev 1460)
+++ eclipse/trunk/org.jboss.dna.eclipse.jcr.rest.client/src/org/jboss/dna/eclipse/jcr/rest/client/wizards/PublishWizard.java	2009-12-18 22:04:48 UTC (rev 1461)
@@ -33,9 +33,9 @@
 import org.jboss.dna.common.util.CheckArg;
 import org.jboss.dna.eclipse.jcr.rest.client.Activator;
 import org.jboss.dna.eclipse.jcr.rest.client.RestClientI18n;
+import org.jboss.dna.eclipse.jcr.rest.client.ServerManager;
 import org.jboss.dna.eclipse.jcr.rest.client.jobs.PublishJob;
 import org.jboss.dna.eclipse.jcr.rest.client.jobs.PublishJob.Type;
-import org.jboss.dna.web.jcr.rest.client.ServerManager;
 import org.jboss.dna.web.jcr.rest.client.domain.Workspace;
 
 /**

Modified: eclipse/trunk/org.jboss.dna.eclipse.jcr.rest.client/src/org/jboss/dna/eclipse/jcr/rest/client/wizards/ServerPage.java
===================================================================
--- eclipse/trunk/org.jboss.dna.eclipse.jcr.rest.client/src/org/jboss/dna/eclipse/jcr/rest/client/wizards/ServerPage.java	2009-12-18 20:56:07 UTC (rev 1460)
+++ eclipse/trunk/org.jboss.dna.eclipse.jcr.rest.client/src/org/jboss/dna/eclipse/jcr/rest/client/wizards/ServerPage.java	2009-12-18 22:04:48 UTC (rev 1461)
@@ -46,11 +46,13 @@
 import org.eclipse.swt.widgets.Text;
 import org.eclipse.ui.help.IWorkbenchHelpSystem;
 import org.jboss.dna.eclipse.jcr.rest.client.Activator;
+import org.jboss.dna.eclipse.jcr.rest.client.DnaServer;
 import org.jboss.dna.eclipse.jcr.rest.client.RestClientI18n;
-import org.jboss.dna.web.jcr.rest.client.ServerManager;
+import org.jboss.dna.eclipse.jcr.rest.client.ServerManager;
+import org.jboss.dna.eclipse.jcr.rest.client.Utils;
 import org.jboss.dna.web.jcr.rest.client.Status;
+import org.jboss.dna.web.jcr.rest.client.Status.Severity;
 import org.jboss.dna.web.jcr.rest.client.domain.Server;
-import org.jboss.dna.web.jcr.rest.client.domain.validation.ServerValidator;
 
 /**
  * The <code>ServerPage</code> is used to create or modify a server.
@@ -79,7 +81,7 @@
     /**
      * The server being editor or <code>null</code> if creating a new server.
      */
-    private Server server;
+    private DnaServer server;
 
     /**
      * The current validation status.
@@ -114,7 +116,7 @@
      * 
      * @param server the server being edited
      */
-    public ServerPage( Server server ) {
+    public ServerPage( DnaServer server ) {
         super(ServerPage.class.getSimpleName());
         setTitle(RestClientI18n.serverPageTitle.text());
 
@@ -338,9 +340,9 @@
      * @throws RuntimeException if called when all inputs are not valid
      * @see #isPageComplete()
      */
-    public Server getServer() {
+    public DnaServer getServer() {
         if (!this.status.isError()) {
-            return new Server(this.url, this.user, this.password, this.savePassword);
+            return new DnaServer(this.url, this.user, this.password, this.savePassword);
         }
 
         // should never be called if error status
@@ -478,15 +480,17 @@
      * Validates all inputs and sets the validation status.
      */
     private void validate() {
-        if (this.server == null) {
-            this.status = ServerValidator.isValid(this.url, this.user, this.password, this.savePassword, getServerManager());
-        } else {
-            // make sure all fields are valid without seeing if server exists in registry
-            this.status = ServerValidator.isValid(this.url, this.user, this.password, this.savePassword);
+        this.status = Utils.isServerValid(this.url, this.user, this.password);
 
-            // if server is valid and is different from what we started with validate and check the registry
-            if (this.status.isOk() && !this.server.hasSameKey(getServer())) {
-                this.status = ServerValidator.isValid(this.url, this.user, this.password, this.savePassword, getServerManager());
+        // now check to see if a server is already registered
+        if (this.status.isOk()) {
+            Server changedServer = getServer();
+
+            // don't check if modifying existing server and identifying properties have not changed
+            if (((this.server == null) || !this.server.hasSameKey(changedServer))
+                && getServerManager().isRegistered(changedServer)) {
+                this.status = new Status(Severity.ERROR,
+                                         RestClientI18n.serverExistsMsg.text(changedServer.getShortDescription()), null);
             }
         }
     }

Modified: eclipse/trunk/org.jboss.dna.eclipse.jcr.rest.client/src/org/jboss/dna/eclipse/jcr/rest/client/wizards/ServerWizard.java
===================================================================
--- eclipse/trunk/org.jboss.dna.eclipse.jcr.rest.client/src/org/jboss/dna/eclipse/jcr/rest/client/wizards/ServerWizard.java	2009-12-18 20:56:07 UTC (rev 1460)
+++ eclipse/trunk/org.jboss.dna.eclipse.jcr.rest.client/src/org/jboss/dna/eclipse/jcr/rest/client/wizards/ServerWizard.java	2009-12-18 22:04:48 UTC (rev 1461)
@@ -27,10 +27,10 @@
 import org.eclipse.jface.dialogs.MessageDialog;
 import org.eclipse.jface.wizard.Wizard;
 import org.jboss.dna.eclipse.jcr.rest.client.Activator;
+import org.jboss.dna.eclipse.jcr.rest.client.DnaServer;
 import org.jboss.dna.eclipse.jcr.rest.client.RestClientI18n;
-import org.jboss.dna.web.jcr.rest.client.ServerManager;
+import org.jboss.dna.eclipse.jcr.rest.client.ServerManager;
 import org.jboss.dna.web.jcr.rest.client.Status;
-import org.jboss.dna.web.jcr.rest.client.domain.Server;
 
 /**
  * The <code>ServerWizard</code> is the wizard used to create and edit servers.
@@ -44,7 +44,7 @@
     /**
      * Non-<code>null</code> if the wizard is editing an existing server.
      */
-    private Server existingServer;
+    private DnaServer existingServer;
 
     /**
      * The wizard page containing all the controls that allow editing of server properties.
@@ -80,7 +80,7 @@
      * @param server the server whose properties are being edited (never <code>null</code>)
      */
     public ServerWizard( ServerManager serverManager,
-                         Server server ) {
+                         DnaServer server ) {
         this.page = new ServerPage(server);
         this.serverManager = serverManager;
         this.existingServer = server;
@@ -116,7 +116,7 @@
     @Override
     public boolean performFinish() {
         Status status = Status.OK_STATUS;
-        Server server = this.page.getServer();
+        DnaServer server = this.page.getServer();
 
         if (this.existingServer == null) {
             status = this.serverManager.addServer(server);

Modified: eclipse/trunk/org.jboss.dna.eclipse.jcr.rest.client.feature/feature.properties
===================================================================
--- eclipse/trunk/org.jboss.dna.eclipse.jcr.rest.client.feature/feature.properties	2009-12-18 20:56:07 UTC (rev 1460)
+++ eclipse/trunk/org.jboss.dna.eclipse.jcr.rest.client.feature/feature.properties	2009-12-18 22:04:48 UTC (rev 1461)
@@ -3,18 +3,13 @@
 # See the LEGAL.txt file distributed with this work for information regarding copyright ownership and licensing.
 # 
 # See the AUTHORS.txt file distributed with this work for a full listing of individual contributors.
-copyright = \
-JBoss DNA JCR REST Eclipse Client (http://www.jboss.org/dna/) is copyright of Red Hat, Inc.
+copyright = ModeShape REST Eclipse Client (http://www.modeshape.org) is copyright of Red Hat, Inc.
 
-license = \
-This program and the accompanying materials are made available under the terms of the Eclipse Public License v1.0 which is \
-available at http://www.eclipse.org/legal/epl-v10.html.\
-\n\n\
-Some portions may be licensed to Red Hat, Inc. under one or more contributor license agreements. 
+license = This program is made available under the terms of the Eclipse Public License v1.0 which accompanies this distribution, and is available at http://www.eclipse.org/legal/epl-v10.html.
           
 # Feature Information Page properties
-description = The JBoss DNA JCR REST Eclipse Client provides a resource publishing and unpublishing capability to DNA repositories.
+description = The ModeShape REST Eclipse Client provides a resource publishing and unpublishing capability to ModeShape repositories.
 
 # Feature Overview Page properties
-featureName = JBoss DNA JCR REST Eclipse Client
+featureName = ModeShape JCR REST Eclipse Client
 featureProvider = Red Hat, Inc.
\ No newline at end of file

Modified: eclipse/trunk/org.jboss.dna.eclipse.jcr.rest.client.feature/feature.xml
===================================================================
--- eclipse/trunk/org.jboss.dna.eclipse.jcr.rest.client.feature/feature.xml	2009-12-18 20:56:07 UTC (rev 1460)
+++ eclipse/trunk/org.jboss.dna.eclipse.jcr.rest.client.feature/feature.xml	2009-12-18 22:04:48 UTC (rev 1461)
@@ -2,7 +2,7 @@
 <feature
       id="org.jboss.dna.eclipse.jcr.rest.client.feature"
       label="%featureName"
-      version="1.0.0.v20090930"
+      version="1.0.0.v20091216"
       provider-name="%featureProvider"
       plugin="org.jboss.dna.eclipse.jcr.rest.client"
       image="feature.png">


Property changes on: eclipse/trunk/org.jboss.dna.eclipse.jcr.rest.client.updatesite
___________________________________________________________________
Name: svn:ignore
   + features
plugins
artifacts.xml
content.xml


Modified: eclipse/trunk/org.jboss.dna.eclipse.jcr.rest.client.updatesite/site.xml
===================================================================
--- eclipse/trunk/org.jboss.dna.eclipse.jcr.rest.client.updatesite/site.xml	2009-12-18 20:56:07 UTC (rev 1460)
+++ eclipse/trunk/org.jboss.dna.eclipse.jcr.rest.client.updatesite/site.xml	2009-12-18 22:04:48 UTC (rev 1461)
@@ -1,4 +1,4 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <site>
-   <feature url="features/org.jboss.dna.eclipse.jcr.rest.client.feature_1.0.0.v20090930.jar" id="org.jboss.dna.eclipse.jcr.rest.client.feature" version="1.0.0.v20090930"/>
+   <feature url="features/org.jboss.dna.eclipse.jcr.rest.client.feature_1.0.0.v20091216.jar" id="org.jboss.dna.eclipse.jcr.rest.client.feature" version="1.0.0.v20091216"/>
 </site>



More information about the dna-commits mailing list