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.
by dna-commits@lists.jboss.org
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.
+ */
+@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.
+ */
+@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>
14 years, 6 months
DNA SVN: r1460 - in trunk/web/dna-web-jcr-rest-client/src: main/java/org/jboss/dna/web/jcr/rest/client/domain and 4 other directories.
by dna-commits@lists.jboss.org
Author: elvisisking
Date: 2009-12-18 15:56:07 -0500 (Fri, 18 Dec 2009)
New Revision: 1460
Removed:
trunk/web/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/IServerRegistryListener.java
trunk/web/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/ServerManager.java
trunk/web/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/ServerRegistryEvent.java
trunk/web/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/domain/validation/
trunk/web/dna-web-jcr-rest-client/src/test/java/org/jboss/dna/web/jcr/rest/client/RestIntegrationTest.java
trunk/web/dna-web-jcr-rest-client/src/test/java/org/jboss/dna/web/jcr/rest/client/ServerManagerTest.java
Modified:
trunk/web/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/RestClientI18n.java
trunk/web/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/domain/Repository.java
trunk/web/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/domain/Server.java
trunk/web/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/domain/Workspace.java
trunk/web/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/package-info.java
trunk/web/dna-web-jcr-rest-client/src/main/resources/org/jboss/dna/web/jcr/rest/client/RestClientI18n.properties
trunk/web/dna-web-jcr-rest-client/src/test/java/org/jboss/dna/web/jcr/rest/client/domain/RepositoryTest.java
trunk/web/dna-web-jcr-rest-client/src/test/java/org/jboss/dna/web/jcr/rest/client/domain/ServerTest.java
trunk/web/dna-web-jcr-rest-client/src/test/java/org/jboss/dna/web/jcr/rest/client/domain/WorkspaceTest.java
trunk/web/dna-web-jcr-rest-client/src/test/java/org/jboss/dna/web/jcr/rest/client/json/JsonRestClientTest.java
Log:
DNA-592 The DNA REST Server Registry Should Be Moved From The DNA REST Client Maven Project To The Eclipse Plugin: This commit is removing the registry from the maven project. Also removed the Server property that indicates if the password should be persisted from session to session. The registry and this server property have both been moved to the Eclipse plugin.
Deleted: trunk/web/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/IServerRegistryListener.java
===================================================================
--- trunk/web/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/IServerRegistryListener.java 2009-12-18 20:48:51 UTC (rev 1459)
+++ trunk/web/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/IServerRegistryListener.java 2009-12-18 20:56:07 UTC (rev 1460)
@@ -1,37 +0,0 @@
-/*
- * JBoss DNA (http://www.jboss.org/dna)
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- * See the AUTHORS.txt file in the distribution for a full listing of
- * individual contributors.
- *
- * JBoss DNA is free software. Unless otherwise indicated, all code in JBoss DNA
- * is licensed to you under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * JBoss DNA is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.dna.web.jcr.rest.client;
-
-/**
- * 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 );
-
-}
Modified: trunk/web/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/RestClientI18n.java
===================================================================
--- trunk/web/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/RestClientI18n.java 2009-12-18 20:48:51 UTC (rev 1459)
+++ trunk/web/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/RestClientI18n.java 2009-12-18 20:56:07 UTC (rev 1460)
@@ -30,54 +30,14 @@
*/
public final class RestClientI18n {
- public static I18n errorDeletingServerRegistryFile;
-
- public static I18n errorRestoringServerRegistry;
-
- public static I18n errorSavingServerRegistry;
-
public static I18n nullArgumentMsg;
- public static I18n repositoryEmptyNameMsg;
-
- public static I18n repositoryNullServerMsg;
-
public static I18n repositoryShortDescription;
- public static I18n serverEmptyUrlMsg;
-
- public static I18n serverEmptyUserMsg;
-
- public static I18n serverExistsMsg;
-
- public static I18n serverInvalidUrlMsg;
-
- public static I18n serverManagerConnectionEstablishedMsg;
-
- public static I18n serverManagerConnectionFailedMsg;
-
- public static I18n serverManagerRegistryAddUnexpectedError;
-
- public static I18n serverManagerRegistryListenerError;
-
- public static I18n serverManagerRegistryListenerErrorsOccurred;
-
- public static I18n serverManagerRegistryRemoveUnexpectedError;
-
- public static I18n serverManagerRegistryUpdateAddError;
-
- public static I18n serverManagerRegistryUpdateRemoveError;
-
- public static I18n serverManagerUnregisteredServer;
-
public static I18n serverShortDescription;
public static I18n unknownHttpRequestMethodMsg;
- public static I18n workspaceEmptyNameMsg;
-
- public static I18n workspaceNullRepositoryMsg;
-
public static I18n workspaceShortDescription;
// JsonRestClient messages
Deleted: trunk/web/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/ServerManager.java
===================================================================
--- trunk/web/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/ServerManager.java 2009-12-18 20:48:51 UTC (rev 1459)
+++ trunk/web/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/ServerManager.java 2009-12-18 20:56:07 UTC (rev 1460)
@@ -1,677 +0,0 @@
-/*
- * JBoss DNA (http://www.jboss.org/dna)
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- * See the AUTHORS.txt file in the distribution for a full listing of
- * individual contributors.
- *
- * JBoss DNA is free software. Unless otherwise indicated, all code in JBoss DNA
- * is licensed to you under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * JBoss DNA is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.dna.web.jcr.rest.client;
-
-import java.io.File;
-import java.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.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.
- */
-@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>Server</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( Server 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
- * @see #addServer(Server)
- */
- 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 Server(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.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());
- }
-
-}
Deleted: trunk/web/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/ServerRegistryEvent.java
===================================================================
--- trunk/web/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/ServerRegistryEvent.java 2009-12-18 20:48:51 UTC (rev 1459)
+++ trunk/web/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/ServerRegistryEvent.java 2009-12-18 20:56:07 UTC (rev 1460)
@@ -1,204 +0,0 @@
-/*
- * JBoss DNA (http://www.jboss.org/dna)
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- * See the AUTHORS.txt file in the distribution for a full listing of
- * individual contributors.
- *
- * JBoss DNA is free software. Unless otherwise indicated, all code in JBoss DNA
- * is licensed to you under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * JBoss DNA is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.dna.web.jcr.rest.client;
-
-import 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);
- }
-
-}
Modified: trunk/web/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/domain/Repository.java
===================================================================
--- trunk/web/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/domain/Repository.java 2009-12-18 20:48:51 UTC (rev 1459)
+++ trunk/web/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/domain/Repository.java 2009-12-18 20:56:07 UTC (rev 1460)
@@ -27,14 +27,12 @@
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;
/**
* The Repository class is the business object for a DNA repository.
*/
@Immutable
-public final class Repository implements IDnaObject {
+public class Repository implements IDnaObject {
// ===========================================================================================================================
// Fields
@@ -50,8 +48,6 @@
*/
private final Server server;
- // TODO root publishing path
-
// ===========================================================================================================================
// Constructors
// ===========================================================================================================================
@@ -61,22 +57,12 @@
*
* @param name the repository name (never <code>null</code>)
* @param server the server where this repository resides (never <code>null</code>)
- * @see RepositoryValidator
- * @throws RuntimeException if any of the input parameters are invalid
+ * @throws IllegalArgumentException if the name or server argument is <code>null</code>
*/
public Repository( String name,
Server server ) {
- CheckArg.isNotNull(name, "name"); //$NON-NLS-1$
- CheckArg.isNotNull(server, "server"); //$NON-NLS-1$
-
- // validate inputs
- Status status = RepositoryValidator.isValid(name, server);
-
- if (status.isError()) {
- throw new RuntimeException(status.getMessage(), status.getException());
- }
-
- // valid so construct
+ CheckArg.isNotNull(name, "name");
+ CheckArg.isNotNull(server, "server");
this.name = name;
this.server = server;
}
@@ -95,7 +81,6 @@
if (this == obj) return true;
if ((obj == null) || (getClass() != obj.getClass())) return false;
- // must have another server
Repository otherRepository = (Repository)obj;
return (this.name.equals(otherRepository.name) && this.server.equals(otherRepository.server));
}
Modified: trunk/web/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/domain/Server.java
===================================================================
--- trunk/web/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/domain/Server.java 2009-12-18 20:48:51 UTC (rev 1459)
+++ trunk/web/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/domain/Server.java 2009-12-18 20:56:07 UTC (rev 1460)
@@ -27,16 +27,13 @@
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;
-import org.jboss.dna.web.jcr.rest.client.domain.validation.RepositoryValidator;
-import org.jboss.dna.web.jcr.rest.client.domain.validation.ServerValidator;
/**
* The <code>Server</code> class is the business object for a server that is hosting one or more DNA repositories.
*/
@Immutable
-public final class Server implements IDnaObject {
+public class Server implements IDnaObject {
// ===========================================================================================================================
// Fields
@@ -48,17 +45,12 @@
private final String password;
/**
- * Indicates if the password should be stored locally when the server is persisted.
+ * The server URL (never <code>null</code>).
*/
- private final boolean persistPassword;
-
- /**
- * The server URL.
- */
private final String url;
/**
- * The user name to use when logging on to the server.
+ * The user name to use when logging on to the server (never <code>null</code>).
*/
private final String user;
@@ -72,28 +64,17 @@
* @param url the server URL (never <code>null</code>)
* @param user the server user (may be <code>null</code>)
* @param password the server password (may be <code>null</code>)
- * @param persistPassword <code>true</code> if the password should be stored
- * @see RepositoryValidator
- * @throws RuntimeException if any of the input parameters are invalid
+ * @throws IllegalArgumentException if the URL or user arguments are <code>null</code>
*/
public Server( String url,
String user,
- String password,
- boolean persistPassword ) {
- CheckArg.isNotNull(url, "url"); //$NON-NLS-1$
+ String password ) {
+ CheckArg.isNotNull(url, "url");
+ CheckArg.isNotNull(user, "user");
- // valid inputs
- Status status = ServerValidator.isValid(url, user, password, persistPassword);
-
- if (status.isError()) {
- throw new RuntimeException(status.getMessage(), status.getException());
- }
-
- // valid so construct
this.url = url;
this.user = user;
this.password = password;
- this.persistPassword = persistPassword;
}
// ===========================================================================================================================
@@ -110,11 +91,9 @@
if (this == obj) return true;
if ((obj == null) || (getClass() != obj.getClass())) return false;
- // must have another server
Server otherServer = (Server)obj;
return Utils.equivalent(this.url, otherServer.url) && Utils.equivalent(this.user, otherServer.user)
- && Utils.equivalent(this.password, otherServer.password)
- && Utils.equivalent(this.persistPassword, otherServer.persistPassword);
+ && Utils.equivalent(this.password, otherServer.password);
}
/**
@@ -143,14 +122,14 @@
}
/**
- * @return the server URL
+ * @return the server URL (never <code>null</code>)
*/
public String getUrl() {
return this.url;
}
/**
- * @return the server authentication user
+ * @return the server authentication user (never <code>null</code>)
*/
public String getUser() {
return this.user;
@@ -163,26 +142,22 @@
*/
@Override
public int hashCode() {
- return HashCode.compute(this.url, this.user, this.password, this.persistPassword);
+ return HashCode.compute(this.url, this.user, this.password);
}
/**
+ * A server has the same identifying properties if their URL and user matches.
+ *
* @param otherServer the server whose key is being compared (never <code>null</code>)
* @return <code>true</code> if the servers have the same key
+ * @throws IllegalArgumentException if the argument is <code>null</code>
*/
public boolean hasSameKey( Server otherServer ) {
- CheckArg.isNotNull(otherServer, "otherServer"); //$NON-NLS-1$
+ CheckArg.isNotNull(otherServer, "otherServer");
return (Utils.equivalent(this.url, otherServer.url) && Utils.equivalent(this.user, otherServer.user));
}
/**
- * @return persistPassword <code>true</code> if the password is being persisted
- */
- public boolean isPasswordBeingPersisted() {
- return this.persistPassword;
- }
-
- /**
* {@inheritDoc}
*
* @see java.lang.Object#toString()
Modified: trunk/web/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/domain/Workspace.java
===================================================================
--- trunk/web/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/domain/Workspace.java 2009-12-18 20:48:51 UTC (rev 1459)
+++ trunk/web/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/domain/Workspace.java 2009-12-18 20:56:07 UTC (rev 1460)
@@ -27,14 +27,12 @@
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;
/**
* The <code>Workspace</code> class is the business object for a DNA repository workspace.
*/
@Immutable
-public final class Workspace implements IDnaObject {
+public class Workspace implements IDnaObject {
// ===========================================================================================================================
// Fields
@@ -59,22 +57,12 @@
*
* @param name the workspace name (never <code>null</code>)
* @param repository the repository where this workspace resides (never <code>null</code>)
- * @see WorkspaceValidator
- * @throws RuntimeException if any of the input parameters are invalid
+ * @throws IllegalArgumentException if any of the arguments are <code>null</code>
*/
public Workspace( String name,
Repository repository ) {
- CheckArg.isNotNull(name, "name"); //$NON-NLS-1$
- CheckArg.isNotNull(repository, "repository"); //$NON-NLS-1$
-
- // validate inputs
- Status status = WorkspaceValidator.isValid(name, repository);
-
- if (status.isError()) {
- throw new RuntimeException(status.getMessage(), status.getException());
- }
-
- // valid so construct
+ CheckArg.isNotNull(name, "name");
+ CheckArg.isNotNull(repository, "repository");
this.name = name;
this.repository = repository;
}
@@ -93,7 +81,6 @@
if (this == obj) return true;
if ((obj == null) || (getClass() != obj.getClass())) return false;
- // must have another server
Workspace otherWorkspace = (Workspace)obj;
return (this.name.equals(otherWorkspace.name) && this.repository.equals(otherWorkspace.repository));
}
Modified: trunk/web/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/package-info.java
===================================================================
--- trunk/web/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/package-info.java 2009-12-18 20:48:51 UTC (rev 1459)
+++ trunk/web/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/package-info.java 2009-12-18 20:56:07 UTC (rev 1460)
@@ -22,12 +22,9 @@
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
/**
- * The JBoss DNA REST Client is a lightweight, non-UI Maven project that interacts with the DNA REST server. A server
- * registry managed by the {@link ServerManager server manager} is used to publish and unpublish files to/from DNA
- * {@link org.jboss.dna.web.jcr.rest.client.domain.Repository repository}
- * {@link org.jboss.dna.web.jcr.rest.client.domain.Workspace workspaces}. When a DNA
- * {@link org.jboss.dna.web.jcr.rest.client.domain.Server server} is added, deleted, or updated in the registry the server manager
- * notifies all registered listeners.
+ * The JBoss DNA REST Client is a lightweight, non-UI Maven project that interacts with the DNA REST server. An {@link IRestClient}
+ * is used to publish and unpublish files to/from DNA {@link org.jboss.dna.web.jcr.rest.client.domain.Repository repository}
+ * {@link org.jboss.dna.web.jcr.rest.client.domain.Workspace workspaces}.
*/
package org.jboss.dna.web.jcr.rest.client;
\ No newline at end of file
Modified: trunk/web/dna-web-jcr-rest-client/src/main/resources/org/jboss/dna/web/jcr/rest/client/RestClientI18n.properties
===================================================================
--- trunk/web/dna-web-jcr-rest-client/src/main/resources/org/jboss/dna/web/jcr/rest/client/RestClientI18n.properties 2009-12-18 20:48:51 UTC (rev 1459)
+++ trunk/web/dna-web-jcr-rest-client/src/main/resources/org/jboss/dna/web/jcr/rest/client/RestClientI18n.properties 2009-12-18 20:56:07 UTC (rev 1460)
@@ -21,36 +21,14 @@
# Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
# 02110-1301 USA, or see the FSF site: http://www.fsf.org.
#
-errorDeletingServerRegistryFile = There was a problem deleting server registry file "{0}"
-errorRestoringServerRegistry = Error trying to restore the server registry from file "{0}"
-errorSavingServerRegistry = Error trying to save the server registry to "{0}"
-
nullArgumentMsg = The argument "{0}" may not be null.
-repositoryEmptyNameMsg = A repository name cannot be empty
-repositoryNullServerMsg = A repository server cannot be null
repositoryShortDescription = DNA Repository - Name: {0}, Server: {1}
-serverEmptyUserMsg = The user cannot be empty
-serverEmptyUrlMsg = A server URL cannot be empty
-serverExistsMsg = {0} already exists so it cannot be added
-serverInvalidUrlMsg = The value "{0}" is not a valid server URL
serverShortDescription = DNA Server - URL: {0} User: {1}
-serverManagerConnectionEstablishedMsg = Connection established.
-serverManagerConnectionFailedMsg = Connection failed. Error Message: {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.
-
unknownHttpRequestMethodMsg = The "{0}" HTTP request method is not valid.
-workspaceEmptyNameMsg = A workspace name cannot be empty
-workspaceNullRepositoryMsg = A workspace repository cannot be null
workspaceShortDescription = DNA Workspace - Name: {0}, Repository: {1}
# JsonRestClient messages
Deleted: trunk/web/dna-web-jcr-rest-client/src/test/java/org/jboss/dna/web/jcr/rest/client/RestIntegrationTest.java
===================================================================
--- trunk/web/dna-web-jcr-rest-client/src/test/java/org/jboss/dna/web/jcr/rest/client/RestIntegrationTest.java 2009-12-18 20:48:51 UTC (rev 1459)
+++ trunk/web/dna-web-jcr-rest-client/src/test/java/org/jboss/dna/web/jcr/rest/client/RestIntegrationTest.java 2009-12-18 20:56:07 UTC (rev 1460)
@@ -1,119 +0,0 @@
-/*
- * JBoss DNA (http://www.jboss.org/dna)
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- * See the AUTHORS.txt file in the distribution for a full listing of
- * individual contributors.
- *
- * JBoss DNA is free software. Unless otherwise indicated, all code in JBoss DNA
- * is licensed to you under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * JBoss DNA is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.dna.web.jcr.rest.client;
-
-import static org.hamcrest.core.Is.is;
-import static org.hamcrest.core.IsNull.notNullValue;
-import static org.junit.Assert.assertThat;
-import java.io.File;
-import java.net.URL;
-import java.util.Collection;
-import org.jboss.dna.web.jcr.rest.client.domain.Repository;
-import org.jboss.dna.web.jcr.rest.client.domain.Server;
-import org.jboss.dna.web.jcr.rest.client.domain.Workspace;
-import org.jboss.dna.web.jcr.rest.client.json.JsonRestClient;
-import org.junit.Before;
-import org.junit.Test;
-
-/**
- *
- */
-public final class RestIntegrationTest {
-
- // ===========================================================================================================================
- // Constants
- // ===========================================================================================================================
-
- // user and password configured in pom
- private static final String PSWD = "password"; //$NON-NLS-1$
- private static final String USER = "dnauser"; //$NON-NLS-1$
-
- private static final Server SERVER = new Server("http://localhost:8080", USER, PSWD, false); //$NON-NLS-1$
- private static final String REPOSITORY_NAME = "dna:repository"; //$NON-NLS-1$
- private static final Repository REPOSITORY = new Repository(REPOSITORY_NAME, SERVER);
- private static final String WORKSPACE_NAME = "default"; //$NON-NLS-1$
- private static final Workspace WORKSPACE = new Workspace(WORKSPACE_NAME, REPOSITORY);
-
- private static final String WORKSPACE_PATH = "/myproject/myfolder/"; //$NON-NLS-1$
- private static final String FILE_PATH = WORKSPACE_PATH + "document.txt"; //$NON-NLS-1$
-
- // ===========================================================================================================================
- // Fields
- // ===========================================================================================================================
-
- private JsonRestClient restClient;
-
- private ServerManager serverManager;
-
- // ===========================================================================================================================
- // Methods
- // ===========================================================================================================================
-
- @Before
- public void beforeEach() {
- this.restClient = new JsonRestClient();
- this.serverManager = new ServerManager(null, this.restClient);
- this.serverManager.addServer(SERVER);
- }
-
- // ===========================================================================================================================
- // Methods
- // ===========================================================================================================================
-
- @Test
- public void shouldAllowServerPropertiesToChange() {
- // TODO implement shouldAllowServerPropertiesToChange()
- }
-
-// @Test
- public void shouldGetRepositories() throws Exception {
- Collection<Repository> repositories = this.serverManager.getRepositories(SERVER);
- assertThat(repositories.size(), is(1));
- }
-
-// @Test
- public void shouldGetWorkspaces() throws Exception {
- Collection<Workspace> workspaces = this.serverManager.getWorkspaces(REPOSITORY);
- assertThat(workspaces.size(), is(1));
- }
-
-// @Test
- public void shouldPublish() throws Exception {
- URL textFile = getClass().getResource(FILE_PATH);
- assertThat(textFile, is(notNullValue()));
-
- // publish
- File file = new File(textFile.toURI());
- assertThat(this.serverManager.publish(WORKSPACE, WORKSPACE_PATH, file).isOk(), is(true));
-
- // confirm it exists in repository
- assertThat((this.restClient).pathExists(WORKSPACE, WORKSPACE_PATH, file), is(true));
- }
-
- @Test
- public void shouldUnpublish() {
- // TODO implement shouldUnpublish()
- }
-
-}
Deleted: trunk/web/dna-web-jcr-rest-client/src/test/java/org/jboss/dna/web/jcr/rest/client/ServerManagerTest.java
===================================================================
--- trunk/web/dna-web-jcr-rest-client/src/test/java/org/jboss/dna/web/jcr/rest/client/ServerManagerTest.java 2009-12-18 20:48:51 UTC (rev 1459)
+++ trunk/web/dna-web-jcr-rest-client/src/test/java/org/jboss/dna/web/jcr/rest/client/ServerManagerTest.java 2009-12-18 20:56:07 UTC (rev 1460)
@@ -1,276 +0,0 @@
-/*
- * JBoss DNA (http://www.jboss.org/dna)
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- * See the AUTHORS.txt file in the distribution for a full listing of
- * individual contributors.
- *
- * JBoss DNA is free software. Unless otherwise indicated, all code in JBoss DNA
- * is licensed to you under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * JBoss DNA is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.dna.web.jcr.rest.client;
-
-import static org.hamcrest.core.Is.is;
-import static org.junit.Assert.assertThat;
-import org.jboss.dna.web.jcr.rest.client.domain.Repository;
-import org.jboss.dna.web.jcr.rest.client.domain.Server;
-import org.junit.Before;
-import org.junit.Test;
-
-/**
- * The <code>ServerManagerTest</code> class is a test class for the {@link ServerManager server manager} object.
- */
-public final class ServerManagerTest {
-
- // ===========================================================================================================================
- // Constants
- // ===========================================================================================================================
-
- private static final String URL1 = "file:/tmp/temp.txt"; //$NON-NLS-1$
- private static final String URL2 = "http:www.redhat.com"; //$NON-NLS-1$
-
- private static final String USER1 = "user1"; //$NON-NLS-1$
- private static final String USER2 = "user2"; //$NON-NLS-1$
-
- private static final String PSWD1 = "pwsd1"; //$NON-NLS-1$
- private static final String PSWD2 = "pwsd2"; //$NON-NLS-1$
-
- private static Server SERVER1 = new Server(URL1, USER1, PSWD1, false);
- private static Server SERVER1_UPDATE = new Server(SERVER1.getUrl(), SERVER1.getUser(), SERVER1.getPassword(),
- SERVER1.isPasswordBeingPersisted());
- private static Server SERVER2 = new Server(URL2, USER2, PSWD2, !SERVER1.isPasswordBeingPersisted());
-
- // ===========================================================================================================================
- // Fields
- // ===========================================================================================================================
-
- private ServerManager serverManager;
-
- // ===========================================================================================================================
- // Methods
- // ===========================================================================================================================
-
- @Before
- public void beforeEach() {
- this.serverManager = new ServerManager(null, new MockRestClient());
- }
-
- // ===========================================================================================================================
- // Tests
- // ===========================================================================================================================
-
- @Test
- public void shouldBeRegisteredIfAdded() {
- this.serverManager.addServer(SERVER1);
- assertThat(this.serverManager.isRegistered(SERVER1), is(true));
- assertThat(this.serverManager.getServers().size(), is(1));
- }
-
- @Test
- public void shouldBeRegisteredIfServerWithSameKeyHasBeenAdded() {
- this.serverManager.addServer(SERVER1);
- assertThat(this.serverManager.isRegistered(new Server(SERVER1.getUrl(), SERVER1.getUser(), PSWD2,
- !SERVER1.isPasswordBeingPersisted())), is(true));
- assertThat(this.serverManager.getServers().size(), is(1));
- }
-
- @Test
- public void shouldDecreaseRegistrySizeWhenServerRemoved() {
- this.serverManager.addServer(SERVER1);
- this.serverManager.addServer(SERVER2);
-
- this.serverManager.removeServer(SERVER1);
- assertThat(this.serverManager.getServers().size(), is(1));
-
- this.serverManager.removeServer(SERVER2);
- assertThat(this.serverManager.getServers().isEmpty(), is(true));
- }
-
- @Test
- public void shouldHaveOkStatusWhenAddingServerSuccessfully() {
- assertThat(this.serverManager.addServer(SERVER1).isOk(), is(true));
- assertThat(this.serverManager.getServers().size(), is(1));
- }
-
- @Test
- public void shouldHaveOkStatusWhenRemovingServerSuccessfully() {
- this.serverManager.addServer(SERVER1);
- assertThat(this.serverManager.removeServer(SERVER1).isOk(), is(true));
- assertThat(this.serverManager.getServers().isEmpty(), is(true));
- }
-
- @Test
- public void shouldHaveOkStatusWhenUpdateServerSuccessfully() {
- this.serverManager.addServer(SERVER1);
- assertThat(this.serverManager.updateServer(SERVER1, SERVER1_UPDATE).isOk(), is(true));
- assertThat(this.serverManager.getServers().size(), is(1));
- }
-
- @Test
- public void shouldIncreaseRegistrySizeWhenServerAdded() {
- this.serverManager.addServer(SERVER1);
- assertThat(this.serverManager.getServers().size(), is(1));
-
- this.serverManager.addServer(SERVER2);
- assertThat(this.serverManager.getServers().size(), is(2));
- }
-
- @Test
- public void shouldNotAddServerIfAlreadyAdded() {
- this.serverManager.addServer(SERVER1);
- assertThat(this.serverManager.addServer(SERVER1).isOk(), is(false));
- assertThat(this.serverManager.getServers().size(), is(1));
- }
-
- @Test
- public void shouldNotAddServerIfKeysMatch() {
- this.serverManager.addServer(SERVER1);
- Status status = this.serverManager.addServer(new Server(SERVER1.getUrl(), SERVER1.getUser(), PSWD2,
- !SERVER1.isPasswordBeingPersisted()));
- assertThat(status.isOk(), is(false));
- assertThat(this.serverManager.getServers().size(), is(1));
- }
-
- @Test
- public void shouldNotBeRegisteredIfNotAdded() {
- this.serverManager.addServer(SERVER1);
- assertThat(this.serverManager.isRegistered(SERVER2), is(false));
- assertThat(this.serverManager.getServers().size(), is(1));
- }
-
- @Test
- public void shouldNotBeRegisteredIfRemoved() {
- this.serverManager.addServer(SERVER1);
- this.serverManager.removeServer(SERVER1);
- assertThat(this.serverManager.isRegistered(SERVER1), is(false));
- assertThat(this.serverManager.getServers().isEmpty(), is(true));
- }
-
- @Test
- public void shouldNotReceiveNotificationIfListenerUnregistered() {
- RegistryListener listener = new RegistryListener();
-
- this.serverManager.addRegistryListener(listener);
- this.serverManager.removeRegistryListener(listener);
- this.serverManager.addServer(SERVER1);
- assertThat(listener.wasNotified(), is(false));
- }
-
- @Test
- public void shouldNotRemoveServerIfNotAdded() {
- assertThat(this.serverManager.removeServer(SERVER1).isOk(), is(false));
- assertThat(this.serverManager.getServers().isEmpty(), is(true));
- }
-
- @Test( expected = RuntimeException.class )
- public void shouldNotObtainRepositoriesForUnregisteredServer() throws Exception {
- this.serverManager.getRepositories(SERVER1);
- }
-
- @Test( expected = RuntimeException.class )
- public void shouldNotObtainWorkspacesForUnregisteredServer() throws Exception {
- Repository repository = new Repository("repo", SERVER1);//$NON-NLS-1$
- this.serverManager.getWorkspaces(repository);
- }
-
- @Test
- public void shouldReceiveOneEventIfRegisteredMoreThanOnce() {
- RegistryListener listener = new RegistryListener();
- this.serverManager.addRegistryListener(listener);
- this.serverManager.addRegistryListener(listener);
-
- this.serverManager.addServer(SERVER1);
- assertThat(listener.wasNotified(), is(true));
- }
-
- @Test
- public void shouldReceiveNotificationIfRegisteredListener() {
- RegistryListener listener = new RegistryListener();
- assertThat(this.serverManager.addRegistryListener(listener), is(true));
-
- this.serverManager.addServer(SERVER1);
- assertThat(listener.wasNotified(), is(true));
- }
-
- @Test
- public void shouldReceiveNewServerEvent() {
- RegistryListener listener = new RegistryListener();
- this.serverManager.addRegistryListener(listener);
-
- this.serverManager.addServer(SERVER1);
- assertThat(listener.getEvent().isNew(), is(true));
- assertThat(listener.getEvent().isRemove(), is(false));
- assertThat(listener.getEvent().isUpdate(), is(false));
- }
-
- @Test
- public void shouldReceiveRemoveServerEvent() {
- this.serverManager.addServer(SERVER1);
-
- RegistryListener listener = new RegistryListener();
- this.serverManager.addRegistryListener(listener);
-
- this.serverManager.removeServer(SERVER1);
- assertThat(listener.getEvent().isRemove(), is(true));
- assertThat(listener.getEvent().isNew(), is(false));
- assertThat(listener.getEvent().isUpdate(), is(false));
- }
-
- @Test
- public void shouldReceiveUpdateServerEvent() {
- this.serverManager.addServer(SERVER1);
-
- RegistryListener listener = new RegistryListener();
- this.serverManager.addRegistryListener(listener);
-
- this.serverManager.updateServer(SERVER1, new Server(SERVER1.getUrl(), SERVER1.getUser(), PSWD2,
- !SERVER1.isPasswordBeingPersisted()));
- assertThat(listener.getEvent().isUpdate(), is(true));
- assertThat(listener.getEvent().isNew(), is(false));
- assertThat(listener.getEvent().isRemove(), is(false));
- }
-
- @Test
- public void shouldRemoveServerIfNotAddedButKeyMatches() {
- this.serverManager.addServer(SERVER1_UPDATE);
- assertThat(this.serverManager.removeServer(SERVER1).isOk(), is(true));
- assertThat(this.serverManager.getServers().isEmpty(), is(true));
- }
-
- // ===========================================================================================================================
- // RegistryListener Inner Class
- // ===========================================================================================================================
-
- class RegistryListener implements IServerRegistryListener {
- boolean[] notified = new boolean[] {false};
- ServerRegistryEvent event = null;
-
- public Exception[] serverRegistryChanged( ServerRegistryEvent event ) {
- notified[0] = !notified[0];
- this.event = event;
- return null;
- }
-
- public ServerRegistryEvent getEvent() {
- return this.event;
- }
-
- public boolean wasNotified() {
- return notified[0];
- }
- }
-
-}
Modified: trunk/web/dna-web-jcr-rest-client/src/test/java/org/jboss/dna/web/jcr/rest/client/domain/RepositoryTest.java
===================================================================
--- trunk/web/dna-web-jcr-rest-client/src/test/java/org/jboss/dna/web/jcr/rest/client/domain/RepositoryTest.java 2009-12-18 20:48:51 UTC (rev 1459)
+++ trunk/web/dna-web-jcr-rest-client/src/test/java/org/jboss/dna/web/jcr/rest/client/domain/RepositoryTest.java 2009-12-18 20:56:07 UTC (rev 1460)
@@ -44,9 +44,9 @@
private static final String NAME2 = "name2"; //$NON-NLS-1$
- private static final Server SERVER1 = new Server("file:/tmp/temp.txt", "user", "pswd", false); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ private static final Server SERVER1 = new Server("file:/tmp/temp.txt", "user", "pswd"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- private static final Server SERVER2 = new Server("http:www.redhat.com", "user", "pswd", false); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ private static final Server SERVER2 = new Server("http:www.redhat.com", "user", "pswd"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
private static final Repository REPOSITORY1 = new Repository(NAME1, SERVER1);
Modified: trunk/web/dna-web-jcr-rest-client/src/test/java/org/jboss/dna/web/jcr/rest/client/domain/ServerTest.java
===================================================================
--- trunk/web/dna-web-jcr-rest-client/src/test/java/org/jboss/dna/web/jcr/rest/client/domain/ServerTest.java 2009-12-18 20:48:51 UTC (rev 1459)
+++ trunk/web/dna-web-jcr-rest-client/src/test/java/org/jboss/dna/web/jcr/rest/client/domain/ServerTest.java 2009-12-18 20:56:07 UTC (rev 1460)
@@ -49,7 +49,7 @@
private static final String PSWD1 = "pwsd1"; //$NON-NLS-1$
private static final String PSWD2 = "pwsd2"; //$NON-NLS-1$
- private static Server SERVER1 = new Server(URL1, USER1, PSWD1, false);
+ private static Server SERVER1 = new Server(URL1, USER1, PSWD1);
// ===========================================================================================================================
// Tests
@@ -57,65 +57,43 @@
@Test
public void shouldBeEqualIfHavingSameProperies() {
- assertThat(SERVER1, equalTo(new Server(SERVER1.getUrl(), SERVER1.getUser(), SERVER1.getPassword(),
- SERVER1.isPasswordBeingPersisted())));
+ assertThat(SERVER1, equalTo(new Server(SERVER1.getUrl(), SERVER1.getUser(), SERVER1.getPassword())));
}
@Test
public void shouldHashToSameValueIfEquals() {
Set<Server> set = new HashSet<Server>();
set.add(SERVER1);
- set.add(new Server(SERVER1.getUrl(), SERVER1.getUser(), SERVER1.getPassword(), SERVER1.isPasswordBeingPersisted()));
+ set.add(new Server(SERVER1.getUrl(), SERVER1.getUser(), SERVER1.getPassword()));
assertThat(set.size(), equalTo(1));
}
@Test( expected = RuntimeException.class )
public void shouldNotAllowNullUrl() {
- new Server(null, USER1, PSWD1, true);
+ new Server(null, USER1, PSWD1);
}
@Test
public void shouldHaveSameKey() {
- assertThat(SERVER1.hasSameKey(new Server(SERVER1.getUrl(), SERVER1.getUser(), SERVER1.getPassword(),
- SERVER1.isPasswordBeingPersisted())), is(true));
+ assertThat(SERVER1.hasSameKey(new Server(SERVER1.getUrl(), SERVER1.getUser(), SERVER1.getPassword())), is(true));
}
@Test
public void shouldNotBeEqualIfPropertiesAreDifferent() {
// different URL
- assertThat(SERVER1, is(not(equalTo(new Server(URL2, SERVER1.getUser(), SERVER1.getPassword(),
- SERVER1.isPasswordBeingPersisted())))));
+ assertThat(SERVER1, is(not(equalTo(new Server(URL2, SERVER1.getUser(), SERVER1.getPassword())))));
// different user
- assertThat(SERVER1, is(not(equalTo(new Server(SERVER1.getUrl(), USER2, SERVER1.getPassword(),
- SERVER1.isPasswordBeingPersisted())))));
+ assertThat(SERVER1, is(not(equalTo(new Server(SERVER1.getUrl(), USER2, SERVER1.getPassword())))));
- // different passord
- assertThat(SERVER1, is(not(equalTo(new Server(SERVER1.getUrl(), SERVER1.getUser(), PSWD2,
- SERVER1.isPasswordBeingPersisted())))));
-
- // different persisted flag
- assertThat(SERVER1, is(not(equalTo(new Server(SERVER1.getUrl(), SERVER1.getUser(), SERVER1.getPassword(),
- !SERVER1.isPasswordBeingPersisted())))));
+ // different password
+ assertThat(SERVER1, is(not(equalTo(new Server(SERVER1.getUrl(), SERVER1.getUser(), PSWD2)))));
}
@Test
public void shouldNotHaveSameKey() {
- assertThat(SERVER1.hasSameKey(new Server(URL2, SERVER1.getUser(), SERVER1.getPassword(),
- SERVER1.isPasswordBeingPersisted())), is(false));
- assertThat(SERVER1.hasSameKey(new Server(SERVER1.getUrl(), USER2, SERVER1.getPassword(),
- SERVER1.isPasswordBeingPersisted())), is(false));
+ assertThat(SERVER1.hasSameKey(new Server(URL2, SERVER1.getUser(), SERVER1.getPassword())), is(false));
+ assertThat(SERVER1.hasSameKey(new Server(SERVER1.getUrl(), USER2, SERVER1.getPassword())), is(false));
}
- @Test
- public void shouldSetPersistPasswordCorrectly() {
- boolean persist = true;
- Server server = new Server(URL1, USER1, PSWD1, persist);
- assertThat(persist, is(server.isPasswordBeingPersisted()));
-
- persist = !persist;
- server = new Server(URL1, USER1, PSWD1, persist);
- assertThat(persist, is(server.isPasswordBeingPersisted()));
- }
-
}
Modified: trunk/web/dna-web-jcr-rest-client/src/test/java/org/jboss/dna/web/jcr/rest/client/domain/WorkspaceTest.java
===================================================================
--- trunk/web/dna-web-jcr-rest-client/src/test/java/org/jboss/dna/web/jcr/rest/client/domain/WorkspaceTest.java 2009-12-18 20:48:51 UTC (rev 1459)
+++ trunk/web/dna-web-jcr-rest-client/src/test/java/org/jboss/dna/web/jcr/rest/client/domain/WorkspaceTest.java 2009-12-18 20:56:07 UTC (rev 1460)
@@ -44,9 +44,9 @@
private static final String NAME2 = "name2"; //$NON-NLS-1$
- private static final Server SERVER1 = new Server("file:/tmp/temp.txt", "user", "pswd", false); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ private static final Server SERVER1 = new Server("file:/tmp/temp.txt", "user", "pswd"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- private static final Server SERVER2 = new Server("http:www.redhat.com", "user", "pswd", false); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ private static final Server SERVER2 = new Server("http:www.redhat.com", "user", "pswd"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
private static final Repository REPOSITORY1 = new Repository(NAME1, SERVER1);
Modified: trunk/web/dna-web-jcr-rest-client/src/test/java/org/jboss/dna/web/jcr/rest/client/json/JsonRestClientTest.java
===================================================================
--- trunk/web/dna-web-jcr-rest-client/src/test/java/org/jboss/dna/web/jcr/rest/client/json/JsonRestClientTest.java 2009-12-18 20:48:51 UTC (rev 1459)
+++ trunk/web/dna-web-jcr-rest-client/src/test/java/org/jboss/dna/web/jcr/rest/client/json/JsonRestClientTest.java 2009-12-18 20:56:07 UTC (rev 1460)
@@ -55,7 +55,7 @@
private static final String PSWD = "password"; //$NON-NLS-1$
private static final String USER = "dnauser"; //$NON-NLS-1$
- private static final Server SERVER = new Server("http://localhost:8080", USER, PSWD, false); //$NON-NLS-1$
+ private static final Server SERVER = new Server("http://localhost:8080", USER, PSWD); //$NON-NLS-1$
private static final String REPOSITORY_NAME = "dna:repository"; //$NON-NLS-1$
private static final Repository REPOSITORY1 = new Repository(REPOSITORY_NAME, SERVER);
private static final String WORKSPACE_NAME = "default"; //$NON-NLS-1$
14 years, 6 months
DNA SVN: r1459 - trunk/dna-jcr/src/main/java/org/jboss/dna/jcr.
by dna-commits@lists.jboss.org
Author: elvisisking
Date: 2009-12-18 15:48:51 -0500 (Fri, 18 Dec 2009)
New Revision: 1459
Modified:
trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/JcrRepository.java
Log:
DNA-598 Shutting down JcrEngine returns, but leaves idle threads running (preventing shutdown of VM) for 60 seconds: The ExecutorService started by the RepositoryObservationManager is now being shutdown when the JcrRepository is closed.
Modified: trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/JcrRepository.java
===================================================================
--- trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/JcrRepository.java 2009-12-18 19:16:43 UTC (rev 1458)
+++ trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/JcrRepository.java 2009-12-18 20:48:51 UTC (rev 1459)
@@ -431,8 +431,7 @@
}
// Initialize the observer, which receives events from all repository sources
- this.repositoryObservationManager = new RepositoryObservationManager();
- repositoryObservable.register(this.repositoryObservationManager);
+ this.repositoryObservationManager = new RepositoryObservationManager(repositoryObservable);
// Set up the system source ...
String systemSourceNameValue = this.options.get(Option.SYSTEM_SOURCE_NAME);
@@ -933,6 +932,8 @@
if (this.federatedSource != null) {
this.federatedSource.close();
}
+
+ this.repositoryObservationManager.shutdown();
}
/**
@@ -1186,8 +1187,14 @@
private final ExecutorService observerService = Executors.newSingleThreadExecutor();
private final CopyOnWriteArrayList<Observer> observers = new CopyOnWriteArrayList<Observer>();
+ private final Observable repositoryObservable;
- protected RepositoryObservationManager() {
+ /**
+ * @param repositoryObservable the repository library observable this observer should register with
+ */
+ protected RepositoryObservationManager(Observable repositoryObservable) {
+ this.repositoryObservable = repositoryObservable;
+ this.repositoryObservable.register(this);
}
/**
@@ -1233,12 +1240,23 @@
}
/**
+ * Must be called to shutdown the service that is used to notify the observers.
+ */
+ void shutdown() {
+ synchronized (this) {
+ this.repositoryObservable.unregister(this);
+ this.observers.clear();
+ this.observerService.shutdown();
+ }
+ }
+
+ /**
* {@inheritDoc}
*
* @see org.jboss.dna.graph.observe.Observable#unregister(org.jboss.dna.graph.observe.Observer)
*/
public boolean unregister( Observer observer ) {
- CheckArg.isNotNull(observer, "observer");
+ if (observer == null) return false;
return this.observers.remove(observer);
}
}
14 years, 6 months
DNA SVN: r1458 - trunk.
by dna-commits@lists.jboss.org
Author: spagop
Date: 2009-12-18 14:16:43 -0500 (Fri, 18 Dec 2009)
New Revision: 1458
Modified:
trunk/pom.xml
Log:
DNA 600 - mvn eclipse:clean eclipse:eclipse doesn't work on dna-connector-store-jpa
Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml 2009-12-18 03:13:27 UTC (rev 1457)
+++ trunk/pom.xml 2009-12-18 19:16:43 UTC (rev 1458)
@@ -728,6 +728,13 @@
</systemProperties>
</configuration>
</plugin>
+
+ <!-- DNA-600 Bug - version 2.7 has a bug -->
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-eclipse-plugin</artifactId>
+ <version>2.6</version>
+ </plugin>
<!--
Build a test-jar for each project, so that src/test/* resources and classes can be used
in other projects. Also customize how the jar files are assembled.
14 years, 6 months
DNA SVN: r1457 - in trunk/extensions/dna-common-jdbc: .settings and 12 other directories.
by dna-commits@lists.jboss.org
Author: rhauch
Date: 2009-12-17 22:13:27 -0500 (Thu, 17 Dec 2009)
New Revision: 1457
Removed:
trunk/extensions/dna-common-jdbc/.classpath
trunk/extensions/dna-common-jdbc/.project
trunk/extensions/dna-common-jdbc/.settings/org.eclipse.jdt.core.prefs
trunk/extensions/dna-common-jdbc/.settings/org.maven.ide.eclipse.prefs
trunk/extensions/dna-common-jdbc/pom.xml
trunk/extensions/dna-common-jdbc/src/main/java/org/jboss/dna/common/jdbc/JdbcMetadataI18n.java
trunk/extensions/dna-common-jdbc/src/main/java/org/jboss/dna/common/jdbc/model/DefaultModelFactory.java
trunk/extensions/dna-common-jdbc/src/main/java/org/jboss/dna/common/jdbc/model/ModelFactory.java
trunk/extensions/dna-common-jdbc/src/main/java/org/jboss/dna/common/jdbc/model/api/Attribute.java
trunk/extensions/dna-common-jdbc/src/main/java/org/jboss/dna/common/jdbc/model/api/BestRowIdentifier.java
trunk/extensions/dna-common-jdbc/src/main/java/org/jboss/dna/common/jdbc/model/api/BestRowIdentifierScopeType.java
trunk/extensions/dna-common-jdbc/src/main/java/org/jboss/dna/common/jdbc/model/api/Catalog.java
trunk/extensions/dna-common-jdbc/src/main/java/org/jboss/dna/common/jdbc/model/api/Column.java
trunk/extensions/dna-common-jdbc/src/main/java/org/jboss/dna/common/jdbc/model/api/ColumnPseudoType.java
trunk/extensions/dna-common-jdbc/src/main/java/org/jboss/dna/common/jdbc/model/api/CoreMetaData.java
trunk/extensions/dna-common-jdbc/src/main/java/org/jboss/dna/common/jdbc/model/api/Database.java
trunk/extensions/dna-common-jdbc/src/main/java/org/jboss/dna/common/jdbc/model/api/DatabaseMetaDataMethodException.java
trunk/extensions/dna-common-jdbc/src/main/java/org/jboss/dna/common/jdbc/model/api/DatabaseNamedObject.java
trunk/extensions/dna-common-jdbc/src/main/java/org/jboss/dna/common/jdbc/model/api/ForeignKey.java
trunk/extensions/dna-common-jdbc/src/main/java/org/jboss/dna/common/jdbc/model/api/ForeignKeyColumn.java
trunk/extensions/dna-common-jdbc/src/main/java/org/jboss/dna/common/jdbc/model/api/Index.java
trunk/extensions/dna-common-jdbc/src/main/java/org/jboss/dna/common/jdbc/model/api/IndexColumn.java
trunk/extensions/dna-common-jdbc/src/main/java/org/jboss/dna/common/jdbc/model/api/IndexType.java
trunk/extensions/dna-common-jdbc/src/main/java/org/jboss/dna/common/jdbc/model/api/KeyColumn.java
trunk/extensions/dna-common-jdbc/src/main/java/org/jboss/dna/common/jdbc/model/api/KeyDeferrabilityType.java
trunk/extensions/dna-common-jdbc/src/main/java/org/jboss/dna/common/jdbc/model/api/KeyModifyRuleType.java
trunk/extensions/dna-common-jdbc/src/main/java/org/jboss/dna/common/jdbc/model/api/NullabilityType.java
trunk/extensions/dna-common-jdbc/src/main/java/org/jboss/dna/common/jdbc/model/api/Parameter.java
trunk/extensions/dna-common-jdbc/src/main/java/org/jboss/dna/common/jdbc/model/api/ParameterIoType.java
trunk/extensions/dna-common-jdbc/src/main/java/org/jboss/dna/common/jdbc/model/api/PrimaryKey.java
trunk/extensions/dna-common-jdbc/src/main/java/org/jboss/dna/common/jdbc/model/api/PrimaryKeyColumn.java
trunk/extensions/dna-common-jdbc/src/main/java/org/jboss/dna/common/jdbc/model/api/Privilege.java
trunk/extensions/dna-common-jdbc/src/main/java/org/jboss/dna/common/jdbc/model/api/PrivilegeType.java
trunk/extensions/dna-common-jdbc/src/main/java/org/jboss/dna/common/jdbc/model/api/Reference.java
trunk/extensions/dna-common-jdbc/src/main/java/org/jboss/dna/common/jdbc/model/api/ResultSetConcurrencyType.java
trunk/extensions/dna-common-jdbc/src/main/java/org/jboss/dna/common/jdbc/model/api/ResultSetHoldabilityType.java
trunk/extensions/dna-common-jdbc/src/main/java/org/jboss/dna/common/jdbc/model/api/ResultSetType.java
trunk/extensions/dna-common-jdbc/src/main/java/org/jboss/dna/common/jdbc/model/api/SQLStateType.java
trunk/extensions/dna-common-jdbc/src/main/java/org/jboss/dna/common/jdbc/model/api/Schema.java
trunk/extensions/dna-common-jdbc/src/main/java/org/jboss/dna/common/jdbc/model/api/SchemaObject.java
trunk/extensions/dna-common-jdbc/src/main/java/org/jboss/dna/common/jdbc/model/api/SearchabilityType.java
trunk/extensions/dna-common-jdbc/src/main/java/org/jboss/dna/common/jdbc/model/api/SortSequenceType.java
trunk/extensions/dna-common-jdbc/src/main/java/org/jboss/dna/common/jdbc/model/api/SqlType.java
trunk/extensions/dna-common-jdbc/src/main/java/org/jboss/dna/common/jdbc/model/api/SqlTypeConversionPair.java
trunk/extensions/dna-common-jdbc/src/main/java/org/jboss/dna/common/jdbc/model/api/SqlTypeInfo.java
trunk/extensions/dna-common-jdbc/src/main/java/org/jboss/dna/common/jdbc/model/api/StoredProcedure.java
trunk/extensions/dna-common-jdbc/src/main/java/org/jboss/dna/common/jdbc/model/api/StoredProcedureResultType.java
trunk/extensions/dna-common-jdbc/src/main/java/org/jboss/dna/common/jdbc/model/api/Table.java
trunk/extensions/dna-common-jdbc/src/main/java/org/jboss/dna/common/jdbc/model/api/TableColumn.java
trunk/extensions/dna-common-jdbc/src/main/java/org/jboss/dna/common/jdbc/model/api/TableType.java
trunk/extensions/dna-common-jdbc/src/main/java/org/jboss/dna/common/jdbc/model/api/TransactionIsolationLevelType.java
trunk/extensions/dna-common-jdbc/src/main/java/org/jboss/dna/common/jdbc/model/api/UserDefinedType.java
trunk/extensions/dna-common-jdbc/src/main/java/org/jboss/dna/common/jdbc/model/spi/AttributeBean.java
trunk/extensions/dna-common-jdbc/src/main/java/org/jboss/dna/common/jdbc/model/spi/BestRowIdentifierBean.java
trunk/extensions/dna-common-jdbc/src/main/java/org/jboss/dna/common/jdbc/model/spi/CatalogBean.java
trunk/extensions/dna-common-jdbc/src/main/java/org/jboss/dna/common/jdbc/model/spi/ColumnBean.java
trunk/extensions/dna-common-jdbc/src/main/java/org/jboss/dna/common/jdbc/model/spi/CoreMetaDataBean.java
trunk/extensions/dna-common-jdbc/src/main/java/org/jboss/dna/common/jdbc/model/spi/DatabaseBean.java
trunk/extensions/dna-common-jdbc/src/main/java/org/jboss/dna/common/jdbc/model/spi/DatabaseNamedObjectBean.java
trunk/extensions/dna-common-jdbc/src/main/java/org/jboss/dna/common/jdbc/model/spi/ForeignKeyBean.java
trunk/extensions/dna-common-jdbc/src/main/java/org/jboss/dna/common/jdbc/model/spi/ForeignKeyColumnBean.java
trunk/extensions/dna-common-jdbc/src/main/java/org/jboss/dna/common/jdbc/model/spi/IndexBean.java
trunk/extensions/dna-common-jdbc/src/main/java/org/jboss/dna/common/jdbc/model/spi/IndexColumnBean.java
trunk/extensions/dna-common-jdbc/src/main/java/org/jboss/dna/common/jdbc/model/spi/KeyColumnBean.java
trunk/extensions/dna-common-jdbc/src/main/java/org/jboss/dna/common/jdbc/model/spi/ParameterBean.java
trunk/extensions/dna-common-jdbc/src/main/java/org/jboss/dna/common/jdbc/model/spi/PrimaryKeyBean.java
trunk/extensions/dna-common-jdbc/src/main/java/org/jboss/dna/common/jdbc/model/spi/PrimaryKeyColumnBean.java
trunk/extensions/dna-common-jdbc/src/main/java/org/jboss/dna/common/jdbc/model/spi/PrivilegeBean.java
trunk/extensions/dna-common-jdbc/src/main/java/org/jboss/dna/common/jdbc/model/spi/ReferenceBean.java
trunk/extensions/dna-common-jdbc/src/main/java/org/jboss/dna/common/jdbc/model/spi/SchemaBean.java
trunk/extensions/dna-common-jdbc/src/main/java/org/jboss/dna/common/jdbc/model/spi/SchemaObjectBean.java
trunk/extensions/dna-common-jdbc/src/main/java/org/jboss/dna/common/jdbc/model/spi/SqlTypeConversionPairBean.java
trunk/extensions/dna-common-jdbc/src/main/java/org/jboss/dna/common/jdbc/model/spi/SqlTypeInfoBean.java
trunk/extensions/dna-common-jdbc/src/main/java/org/jboss/dna/common/jdbc/model/spi/StoredProcedureBean.java
trunk/extensions/dna-common-jdbc/src/main/java/org/jboss/dna/common/jdbc/model/spi/TableBean.java
trunk/extensions/dna-common-jdbc/src/main/java/org/jboss/dna/common/jdbc/model/spi/TableColumnBean.java
trunk/extensions/dna-common-jdbc/src/main/java/org/jboss/dna/common/jdbc/model/spi/TableTypeBean.java
trunk/extensions/dna-common-jdbc/src/main/java/org/jboss/dna/common/jdbc/model/spi/UserDefinedTypeBean.java
trunk/extensions/dna-common-jdbc/src/main/java/org/jboss/dna/common/jdbc/provider/DataSourceDatabaseMetadataProvider.java
trunk/extensions/dna-common-jdbc/src/main/java/org/jboss/dna/common/jdbc/provider/DatabaseMetadataProvider.java
trunk/extensions/dna-common-jdbc/src/main/java/org/jboss/dna/common/jdbc/provider/DefaultDataSourceDatabaseMetadataProvider.java
trunk/extensions/dna-common-jdbc/src/main/java/org/jboss/dna/common/jdbc/provider/DefaultDatabaseMetadataProvider.java
trunk/extensions/dna-common-jdbc/src/main/java/org/jboss/dna/common/jdbc/provider/DefaultDriverDatabaseMetadataProvider.java
trunk/extensions/dna-common-jdbc/src/main/java/org/jboss/dna/common/jdbc/provider/DriverDatabaseMetadataProvider.java
trunk/extensions/dna-common-jdbc/src/main/java/org/jboss/dna/common/jdbc/util/DatabaseUtil.java
trunk/extensions/dna-common-jdbc/src/main/java/org/jboss/dna/graph/sequencers/JdbcSequencer.java
trunk/extensions/dna-common-jdbc/src/main/resources/org/jboss/dna/common/jdbc/JdbcMetadataI18n.properties
trunk/extensions/dna-common-jdbc/src/test/java/org/jboss/dna/common/jdbc/model/ModelFactoryTest.java
trunk/extensions/dna-common-jdbc/src/test/java/org/jboss/dna/common/jdbc/model/spi/AttributeBeanTest.java
trunk/extensions/dna-common-jdbc/src/test/java/org/jboss/dna/common/jdbc/model/spi/BestRowIdentifierBeanTest.java
trunk/extensions/dna-common-jdbc/src/test/java/org/jboss/dna/common/jdbc/model/spi/CatalogBeanTest.java
trunk/extensions/dna-common-jdbc/src/test/java/org/jboss/dna/common/jdbc/model/spi/ColumnBeanTest.java
trunk/extensions/dna-common-jdbc/src/test/java/org/jboss/dna/common/jdbc/model/spi/CoreMetaDataBeanTest.java
trunk/extensions/dna-common-jdbc/src/test/java/org/jboss/dna/common/jdbc/model/spi/DatabaseBeanTest.java
trunk/extensions/dna-common-jdbc/src/test/java/org/jboss/dna/common/jdbc/model/spi/DatabaseNamedObjectBeanTest.java
trunk/extensions/dna-common-jdbc/src/test/java/org/jboss/dna/common/jdbc/model/spi/ForeignKeyBeanTest.java
trunk/extensions/dna-common-jdbc/src/test/java/org/jboss/dna/common/jdbc/model/spi/ForeignKeyColumnBeanTest.java
trunk/extensions/dna-common-jdbc/src/test/java/org/jboss/dna/common/jdbc/model/spi/IndexBeanTest.java
trunk/extensions/dna-common-jdbc/src/test/java/org/jboss/dna/common/jdbc/model/spi/IndexColumnBeanTest.java
trunk/extensions/dna-common-jdbc/src/test/java/org/jboss/dna/common/jdbc/model/spi/KeyColumnBeanTest.java
trunk/extensions/dna-common-jdbc/src/test/java/org/jboss/dna/common/jdbc/model/spi/ParameterBeanTest.java
trunk/extensions/dna-common-jdbc/src/test/java/org/jboss/dna/common/jdbc/model/spi/PrimaryKeyBeanTest.java
trunk/extensions/dna-common-jdbc/src/test/java/org/jboss/dna/common/jdbc/model/spi/PrimaryKeyColumnBeanTest.java
trunk/extensions/dna-common-jdbc/src/test/java/org/jboss/dna/common/jdbc/model/spi/PrivilegeBeanTest.java
trunk/extensions/dna-common-jdbc/src/test/java/org/jboss/dna/common/jdbc/model/spi/ReferenceBeanTest.java
trunk/extensions/dna-common-jdbc/src/test/java/org/jboss/dna/common/jdbc/model/spi/SchemaBeanTest.java
trunk/extensions/dna-common-jdbc/src/test/java/org/jboss/dna/common/jdbc/model/spi/SchemaObjectBeanTest.java
trunk/extensions/dna-common-jdbc/src/test/java/org/jboss/dna/common/jdbc/model/spi/SqlTypeConversionPairBeanTest.java
trunk/extensions/dna-common-jdbc/src/test/java/org/jboss/dna/common/jdbc/model/spi/SqlTypeInfoBeanTest.java
trunk/extensions/dna-common-jdbc/src/test/java/org/jboss/dna/common/jdbc/model/spi/StoredProcedureBeanTest.java
trunk/extensions/dna-common-jdbc/src/test/java/org/jboss/dna/common/jdbc/model/spi/TableBeanTest.java
trunk/extensions/dna-common-jdbc/src/test/java/org/jboss/dna/common/jdbc/model/spi/TableColumnBeanTest.java
trunk/extensions/dna-common-jdbc/src/test/java/org/jboss/dna/common/jdbc/model/spi/TableTypeBeanTest.java
trunk/extensions/dna-common-jdbc/src/test/java/org/jboss/dna/common/jdbc/model/spi/UserDefinedTypeBeanTest.java
trunk/extensions/dna-common-jdbc/src/test/java/org/jboss/dna/common/jdbc/provider/DataSourceDatabaseMetadataProviderTest.java
trunk/extensions/dna-common-jdbc/src/test/java/org/jboss/dna/common/jdbc/provider/DriverDatabaseMetadataProviderTest.java
trunk/extensions/dna-common-jdbc/src/test/java/org/jboss/dna/common/jdbc/util/DatabaseUtilTest.java
Log:
DNA-37 Removed empty files from the 'dna-common-jdbc' project, which is no longer needed
Deleted: trunk/extensions/dna-common-jdbc/.classpath
===================================================================
Deleted: trunk/extensions/dna-common-jdbc/.project
===================================================================
Deleted: trunk/extensions/dna-common-jdbc/.settings/org.eclipse.jdt.core.prefs
===================================================================
Deleted: trunk/extensions/dna-common-jdbc/.settings/org.maven.ide.eclipse.prefs
===================================================================
Deleted: trunk/extensions/dna-common-jdbc/pom.xml
===================================================================
Deleted: trunk/extensions/dna-common-jdbc/src/main/java/org/jboss/dna/common/jdbc/JdbcMetadataI18n.java
===================================================================
Deleted: trunk/extensions/dna-common-jdbc/src/main/java/org/jboss/dna/common/jdbc/model/DefaultModelFactory.java
===================================================================
Deleted: trunk/extensions/dna-common-jdbc/src/main/java/org/jboss/dna/common/jdbc/model/ModelFactory.java
===================================================================
Deleted: trunk/extensions/dna-common-jdbc/src/main/java/org/jboss/dna/common/jdbc/model/api/Attribute.java
===================================================================
Deleted: trunk/extensions/dna-common-jdbc/src/main/java/org/jboss/dna/common/jdbc/model/api/BestRowIdentifier.java
===================================================================
Deleted: trunk/extensions/dna-common-jdbc/src/main/java/org/jboss/dna/common/jdbc/model/api/BestRowIdentifierScopeType.java
===================================================================
Deleted: trunk/extensions/dna-common-jdbc/src/main/java/org/jboss/dna/common/jdbc/model/api/Catalog.java
===================================================================
Deleted: trunk/extensions/dna-common-jdbc/src/main/java/org/jboss/dna/common/jdbc/model/api/Column.java
===================================================================
Deleted: trunk/extensions/dna-common-jdbc/src/main/java/org/jboss/dna/common/jdbc/model/api/ColumnPseudoType.java
===================================================================
Deleted: trunk/extensions/dna-common-jdbc/src/main/java/org/jboss/dna/common/jdbc/model/api/CoreMetaData.java
===================================================================
Deleted: trunk/extensions/dna-common-jdbc/src/main/java/org/jboss/dna/common/jdbc/model/api/Database.java
===================================================================
Deleted: trunk/extensions/dna-common-jdbc/src/main/java/org/jboss/dna/common/jdbc/model/api/DatabaseMetaDataMethodException.java
===================================================================
Deleted: trunk/extensions/dna-common-jdbc/src/main/java/org/jboss/dna/common/jdbc/model/api/DatabaseNamedObject.java
===================================================================
Deleted: trunk/extensions/dna-common-jdbc/src/main/java/org/jboss/dna/common/jdbc/model/api/ForeignKey.java
===================================================================
Deleted: trunk/extensions/dna-common-jdbc/src/main/java/org/jboss/dna/common/jdbc/model/api/ForeignKeyColumn.java
===================================================================
Deleted: trunk/extensions/dna-common-jdbc/src/main/java/org/jboss/dna/common/jdbc/model/api/Index.java
===================================================================
Deleted: trunk/extensions/dna-common-jdbc/src/main/java/org/jboss/dna/common/jdbc/model/api/IndexColumn.java
===================================================================
Deleted: trunk/extensions/dna-common-jdbc/src/main/java/org/jboss/dna/common/jdbc/model/api/IndexType.java
===================================================================
Deleted: trunk/extensions/dna-common-jdbc/src/main/java/org/jboss/dna/common/jdbc/model/api/KeyColumn.java
===================================================================
Deleted: trunk/extensions/dna-common-jdbc/src/main/java/org/jboss/dna/common/jdbc/model/api/KeyDeferrabilityType.java
===================================================================
Deleted: trunk/extensions/dna-common-jdbc/src/main/java/org/jboss/dna/common/jdbc/model/api/KeyModifyRuleType.java
===================================================================
Deleted: trunk/extensions/dna-common-jdbc/src/main/java/org/jboss/dna/common/jdbc/model/api/NullabilityType.java
===================================================================
Deleted: trunk/extensions/dna-common-jdbc/src/main/java/org/jboss/dna/common/jdbc/model/api/Parameter.java
===================================================================
Deleted: trunk/extensions/dna-common-jdbc/src/main/java/org/jboss/dna/common/jdbc/model/api/ParameterIoType.java
===================================================================
Deleted: trunk/extensions/dna-common-jdbc/src/main/java/org/jboss/dna/common/jdbc/model/api/PrimaryKey.java
===================================================================
Deleted: trunk/extensions/dna-common-jdbc/src/main/java/org/jboss/dna/common/jdbc/model/api/PrimaryKeyColumn.java
===================================================================
Deleted: trunk/extensions/dna-common-jdbc/src/main/java/org/jboss/dna/common/jdbc/model/api/Privilege.java
===================================================================
Deleted: trunk/extensions/dna-common-jdbc/src/main/java/org/jboss/dna/common/jdbc/model/api/PrivilegeType.java
===================================================================
Deleted: trunk/extensions/dna-common-jdbc/src/main/java/org/jboss/dna/common/jdbc/model/api/Reference.java
===================================================================
Deleted: trunk/extensions/dna-common-jdbc/src/main/java/org/jboss/dna/common/jdbc/model/api/ResultSetConcurrencyType.java
===================================================================
Deleted: trunk/extensions/dna-common-jdbc/src/main/java/org/jboss/dna/common/jdbc/model/api/ResultSetHoldabilityType.java
===================================================================
Deleted: trunk/extensions/dna-common-jdbc/src/main/java/org/jboss/dna/common/jdbc/model/api/ResultSetType.java
===================================================================
Deleted: trunk/extensions/dna-common-jdbc/src/main/java/org/jboss/dna/common/jdbc/model/api/SQLStateType.java
===================================================================
Deleted: trunk/extensions/dna-common-jdbc/src/main/java/org/jboss/dna/common/jdbc/model/api/Schema.java
===================================================================
Deleted: trunk/extensions/dna-common-jdbc/src/main/java/org/jboss/dna/common/jdbc/model/api/SchemaObject.java
===================================================================
Deleted: trunk/extensions/dna-common-jdbc/src/main/java/org/jboss/dna/common/jdbc/model/api/SearchabilityType.java
===================================================================
Deleted: trunk/extensions/dna-common-jdbc/src/main/java/org/jboss/dna/common/jdbc/model/api/SortSequenceType.java
===================================================================
Deleted: trunk/extensions/dna-common-jdbc/src/main/java/org/jboss/dna/common/jdbc/model/api/SqlType.java
===================================================================
Deleted: trunk/extensions/dna-common-jdbc/src/main/java/org/jboss/dna/common/jdbc/model/api/SqlTypeConversionPair.java
===================================================================
Deleted: trunk/extensions/dna-common-jdbc/src/main/java/org/jboss/dna/common/jdbc/model/api/SqlTypeInfo.java
===================================================================
Deleted: trunk/extensions/dna-common-jdbc/src/main/java/org/jboss/dna/common/jdbc/model/api/StoredProcedure.java
===================================================================
Deleted: trunk/extensions/dna-common-jdbc/src/main/java/org/jboss/dna/common/jdbc/model/api/StoredProcedureResultType.java
===================================================================
Deleted: trunk/extensions/dna-common-jdbc/src/main/java/org/jboss/dna/common/jdbc/model/api/Table.java
===================================================================
Deleted: trunk/extensions/dna-common-jdbc/src/main/java/org/jboss/dna/common/jdbc/model/api/TableColumn.java
===================================================================
Deleted: trunk/extensions/dna-common-jdbc/src/main/java/org/jboss/dna/common/jdbc/model/api/TableType.java
===================================================================
Deleted: trunk/extensions/dna-common-jdbc/src/main/java/org/jboss/dna/common/jdbc/model/api/TransactionIsolationLevelType.java
===================================================================
Deleted: trunk/extensions/dna-common-jdbc/src/main/java/org/jboss/dna/common/jdbc/model/api/UserDefinedType.java
===================================================================
Deleted: trunk/extensions/dna-common-jdbc/src/main/java/org/jboss/dna/common/jdbc/model/spi/AttributeBean.java
===================================================================
Deleted: trunk/extensions/dna-common-jdbc/src/main/java/org/jboss/dna/common/jdbc/model/spi/BestRowIdentifierBean.java
===================================================================
Deleted: trunk/extensions/dna-common-jdbc/src/main/java/org/jboss/dna/common/jdbc/model/spi/CatalogBean.java
===================================================================
Deleted: trunk/extensions/dna-common-jdbc/src/main/java/org/jboss/dna/common/jdbc/model/spi/ColumnBean.java
===================================================================
Deleted: trunk/extensions/dna-common-jdbc/src/main/java/org/jboss/dna/common/jdbc/model/spi/CoreMetaDataBean.java
===================================================================
Deleted: trunk/extensions/dna-common-jdbc/src/main/java/org/jboss/dna/common/jdbc/model/spi/DatabaseBean.java
===================================================================
Deleted: trunk/extensions/dna-common-jdbc/src/main/java/org/jboss/dna/common/jdbc/model/spi/DatabaseNamedObjectBean.java
===================================================================
Deleted: trunk/extensions/dna-common-jdbc/src/main/java/org/jboss/dna/common/jdbc/model/spi/ForeignKeyBean.java
===================================================================
Deleted: trunk/extensions/dna-common-jdbc/src/main/java/org/jboss/dna/common/jdbc/model/spi/ForeignKeyColumnBean.java
===================================================================
Deleted: trunk/extensions/dna-common-jdbc/src/main/java/org/jboss/dna/common/jdbc/model/spi/IndexBean.java
===================================================================
Deleted: trunk/extensions/dna-common-jdbc/src/main/java/org/jboss/dna/common/jdbc/model/spi/IndexColumnBean.java
===================================================================
Deleted: trunk/extensions/dna-common-jdbc/src/main/java/org/jboss/dna/common/jdbc/model/spi/KeyColumnBean.java
===================================================================
Deleted: trunk/extensions/dna-common-jdbc/src/main/java/org/jboss/dna/common/jdbc/model/spi/ParameterBean.java
===================================================================
Deleted: trunk/extensions/dna-common-jdbc/src/main/java/org/jboss/dna/common/jdbc/model/spi/PrimaryKeyBean.java
===================================================================
Deleted: trunk/extensions/dna-common-jdbc/src/main/java/org/jboss/dna/common/jdbc/model/spi/PrimaryKeyColumnBean.java
===================================================================
Deleted: trunk/extensions/dna-common-jdbc/src/main/java/org/jboss/dna/common/jdbc/model/spi/PrivilegeBean.java
===================================================================
Deleted: trunk/extensions/dna-common-jdbc/src/main/java/org/jboss/dna/common/jdbc/model/spi/ReferenceBean.java
===================================================================
Deleted: trunk/extensions/dna-common-jdbc/src/main/java/org/jboss/dna/common/jdbc/model/spi/SchemaBean.java
===================================================================
Deleted: trunk/extensions/dna-common-jdbc/src/main/java/org/jboss/dna/common/jdbc/model/spi/SchemaObjectBean.java
===================================================================
Deleted: trunk/extensions/dna-common-jdbc/src/main/java/org/jboss/dna/common/jdbc/model/spi/SqlTypeConversionPairBean.java
===================================================================
Deleted: trunk/extensions/dna-common-jdbc/src/main/java/org/jboss/dna/common/jdbc/model/spi/SqlTypeInfoBean.java
===================================================================
Deleted: trunk/extensions/dna-common-jdbc/src/main/java/org/jboss/dna/common/jdbc/model/spi/StoredProcedureBean.java
===================================================================
Deleted: trunk/extensions/dna-common-jdbc/src/main/java/org/jboss/dna/common/jdbc/model/spi/TableBean.java
===================================================================
Deleted: trunk/extensions/dna-common-jdbc/src/main/java/org/jboss/dna/common/jdbc/model/spi/TableColumnBean.java
===================================================================
Deleted: trunk/extensions/dna-common-jdbc/src/main/java/org/jboss/dna/common/jdbc/model/spi/TableTypeBean.java
===================================================================
Deleted: trunk/extensions/dna-common-jdbc/src/main/java/org/jboss/dna/common/jdbc/model/spi/UserDefinedTypeBean.java
===================================================================
Deleted: trunk/extensions/dna-common-jdbc/src/main/java/org/jboss/dna/common/jdbc/provider/DataSourceDatabaseMetadataProvider.java
===================================================================
Deleted: trunk/extensions/dna-common-jdbc/src/main/java/org/jboss/dna/common/jdbc/provider/DatabaseMetadataProvider.java
===================================================================
Deleted: trunk/extensions/dna-common-jdbc/src/main/java/org/jboss/dna/common/jdbc/provider/DefaultDataSourceDatabaseMetadataProvider.java
===================================================================
Deleted: trunk/extensions/dna-common-jdbc/src/main/java/org/jboss/dna/common/jdbc/provider/DefaultDatabaseMetadataProvider.java
===================================================================
Deleted: trunk/extensions/dna-common-jdbc/src/main/java/org/jboss/dna/common/jdbc/provider/DefaultDriverDatabaseMetadataProvider.java
===================================================================
Deleted: trunk/extensions/dna-common-jdbc/src/main/java/org/jboss/dna/common/jdbc/provider/DriverDatabaseMetadataProvider.java
===================================================================
Deleted: trunk/extensions/dna-common-jdbc/src/main/java/org/jboss/dna/common/jdbc/util/DatabaseUtil.java
===================================================================
Deleted: trunk/extensions/dna-common-jdbc/src/main/java/org/jboss/dna/graph/sequencers/JdbcSequencer.java
===================================================================
Deleted: trunk/extensions/dna-common-jdbc/src/main/resources/org/jboss/dna/common/jdbc/JdbcMetadataI18n.properties
===================================================================
Deleted: trunk/extensions/dna-common-jdbc/src/test/java/org/jboss/dna/common/jdbc/model/ModelFactoryTest.java
===================================================================
Deleted: trunk/extensions/dna-common-jdbc/src/test/java/org/jboss/dna/common/jdbc/model/spi/AttributeBeanTest.java
===================================================================
Deleted: trunk/extensions/dna-common-jdbc/src/test/java/org/jboss/dna/common/jdbc/model/spi/BestRowIdentifierBeanTest.java
===================================================================
Deleted: trunk/extensions/dna-common-jdbc/src/test/java/org/jboss/dna/common/jdbc/model/spi/CatalogBeanTest.java
===================================================================
Deleted: trunk/extensions/dna-common-jdbc/src/test/java/org/jboss/dna/common/jdbc/model/spi/ColumnBeanTest.java
===================================================================
Deleted: trunk/extensions/dna-common-jdbc/src/test/java/org/jboss/dna/common/jdbc/model/spi/CoreMetaDataBeanTest.java
===================================================================
Deleted: trunk/extensions/dna-common-jdbc/src/test/java/org/jboss/dna/common/jdbc/model/spi/DatabaseBeanTest.java
===================================================================
Deleted: trunk/extensions/dna-common-jdbc/src/test/java/org/jboss/dna/common/jdbc/model/spi/DatabaseNamedObjectBeanTest.java
===================================================================
Deleted: trunk/extensions/dna-common-jdbc/src/test/java/org/jboss/dna/common/jdbc/model/spi/ForeignKeyBeanTest.java
===================================================================
Deleted: trunk/extensions/dna-common-jdbc/src/test/java/org/jboss/dna/common/jdbc/model/spi/ForeignKeyColumnBeanTest.java
===================================================================
Deleted: trunk/extensions/dna-common-jdbc/src/test/java/org/jboss/dna/common/jdbc/model/spi/IndexBeanTest.java
===================================================================
Deleted: trunk/extensions/dna-common-jdbc/src/test/java/org/jboss/dna/common/jdbc/model/spi/IndexColumnBeanTest.java
===================================================================
Deleted: trunk/extensions/dna-common-jdbc/src/test/java/org/jboss/dna/common/jdbc/model/spi/KeyColumnBeanTest.java
===================================================================
Deleted: trunk/extensions/dna-common-jdbc/src/test/java/org/jboss/dna/common/jdbc/model/spi/ParameterBeanTest.java
===================================================================
Deleted: trunk/extensions/dna-common-jdbc/src/test/java/org/jboss/dna/common/jdbc/model/spi/PrimaryKeyBeanTest.java
===================================================================
Deleted: trunk/extensions/dna-common-jdbc/src/test/java/org/jboss/dna/common/jdbc/model/spi/PrimaryKeyColumnBeanTest.java
===================================================================
Deleted: trunk/extensions/dna-common-jdbc/src/test/java/org/jboss/dna/common/jdbc/model/spi/PrivilegeBeanTest.java
===================================================================
Deleted: trunk/extensions/dna-common-jdbc/src/test/java/org/jboss/dna/common/jdbc/model/spi/ReferenceBeanTest.java
===================================================================
Deleted: trunk/extensions/dna-common-jdbc/src/test/java/org/jboss/dna/common/jdbc/model/spi/SchemaBeanTest.java
===================================================================
Deleted: trunk/extensions/dna-common-jdbc/src/test/java/org/jboss/dna/common/jdbc/model/spi/SchemaObjectBeanTest.java
===================================================================
Deleted: trunk/extensions/dna-common-jdbc/src/test/java/org/jboss/dna/common/jdbc/model/spi/SqlTypeConversionPairBeanTest.java
===================================================================
Deleted: trunk/extensions/dna-common-jdbc/src/test/java/org/jboss/dna/common/jdbc/model/spi/SqlTypeInfoBeanTest.java
===================================================================
Deleted: trunk/extensions/dna-common-jdbc/src/test/java/org/jboss/dna/common/jdbc/model/spi/StoredProcedureBeanTest.java
===================================================================
Deleted: trunk/extensions/dna-common-jdbc/src/test/java/org/jboss/dna/common/jdbc/model/spi/TableBeanTest.java
===================================================================
Deleted: trunk/extensions/dna-common-jdbc/src/test/java/org/jboss/dna/common/jdbc/model/spi/TableColumnBeanTest.java
===================================================================
Deleted: trunk/extensions/dna-common-jdbc/src/test/java/org/jboss/dna/common/jdbc/model/spi/TableTypeBeanTest.java
===================================================================
Deleted: trunk/extensions/dna-common-jdbc/src/test/java/org/jboss/dna/common/jdbc/model/spi/UserDefinedTypeBeanTest.java
===================================================================
Deleted: trunk/extensions/dna-common-jdbc/src/test/java/org/jboss/dna/common/jdbc/provider/DataSourceDatabaseMetadataProviderTest.java
===================================================================
Deleted: trunk/extensions/dna-common-jdbc/src/test/java/org/jboss/dna/common/jdbc/provider/DriverDatabaseMetadataProviderTest.java
===================================================================
Deleted: trunk/extensions/dna-common-jdbc/src/test/java/org/jboss/dna/common/jdbc/util/DatabaseUtilTest.java
===================================================================
14 years, 6 months
DNA SVN: r1455 - in trunk: dna-integration-tests/src/test/resources and 2 other directories.
by dna-commits@lists.jboss.org
Author: rhauch
Date: 2009-12-17 20:54:27 -0500 (Thu, 17 Dec 2009)
New Revision: 1455
Modified:
trunk/dna-graph/src/main/java/org/jboss/dna/graph/query/QueryEngine.java
trunk/dna-integration-tests/src/test/resources/log4j.properties
trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/JcrLexicon.java
trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/JcrQueryManager.java
trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/JcrTckTest.java
Log:
DNA-468 Completed more of the integration, including the addition of the mandatory 'jcr:path' and 'jcr:score' so-called 'pseudo-columns' to the results for XPath queries. However, there still are issues with the TCK query-related tests, so they are not enabled at the moment.
Modified: trunk/dna-graph/src/main/java/org/jboss/dna/graph/query/QueryEngine.java
===================================================================
--- trunk/dna-graph/src/main/java/org/jboss/dna/graph/query/QueryEngine.java 2009-12-18 01:53:48 UTC (rev 1454)
+++ trunk/dna-graph/src/main/java/org/jboss/dna/graph/query/QueryEngine.java 2009-12-18 01:54:27 UTC (rev 1455)
@@ -33,6 +33,7 @@
import org.jboss.dna.graph.query.optimize.Optimizer;
import org.jboss.dna.graph.query.optimize.RuleBasedOptimizer;
import org.jboss.dna.graph.query.plan.CanonicalPlanner;
+import org.jboss.dna.graph.query.plan.PlanHints;
import org.jboss.dna.graph.query.plan.PlanNode;
import org.jboss.dna.graph.query.plan.Planner;
import org.jboss.dna.graph.query.plan.PlanNode.Property;
@@ -99,7 +100,7 @@
// Find the query result columns ...
start = System.nanoTime();
- resultColumns = determineQueryResultColumns(optimizedPlan);
+ resultColumns = determineQueryResultColumns(optimizedPlan, context.getHints());
duration = System.nanoTime() - start;
stats = stats.withOptimizationTime(duration);
@@ -118,18 +119,21 @@
return new org.jboss.dna.graph.query.process.QueryResults(resultColumns, stats, context.getProblems());
}
- protected QueryResultColumns determineQueryResultColumns( PlanNode optimizedPlan ) {
+ protected QueryResultColumns determineQueryResultColumns( PlanNode optimizedPlan,
+ PlanHints hints ) {
// Look for which columns to include in the results; this will be defined by the highest PROJECT node ...
PlanNode project = optimizedPlan.findAtOrBelow(Traversal.LEVEL_ORDER, Type.PROJECT);
if (project != null) {
List<Column> columns = project.getPropertyAsList(Property.PROJECT_COLUMNS, Column.class);
// Determine whether to include the full-text search scores in the results ...
- boolean includeFullTextSearchScores = false;
- for (PlanNode select : optimizedPlan.findAllAtOrBelow(Type.SELECT)) {
- Constraint constraint = select.getProperty(Property.SELECT_CRITERIA, Constraint.class);
- if (QueryResultColumns.includeFullTextScores(constraint)) {
- includeFullTextSearchScores = true;
- break;
+ boolean includeFullTextSearchScores = hints.hasFullTextSearch;
+ if (!includeFullTextSearchScores) {
+ for (PlanNode select : optimizedPlan.findAllAtOrBelow(Type.SELECT)) {
+ Constraint constraint = select.getProperty(Property.SELECT_CRITERIA, Constraint.class);
+ if (QueryResultColumns.includeFullTextScores(constraint)) {
+ includeFullTextSearchScores = true;
+ break;
+ }
}
}
return new QueryResultColumns(columns, includeFullTextSearchScores);
Modified: trunk/dna-integration-tests/src/test/resources/log4j.properties
===================================================================
--- trunk/dna-integration-tests/src/test/resources/log4j.properties 2009-12-18 01:53:48 UTC (rev 1454)
+++ trunk/dna-integration-tests/src/test/resources/log4j.properties 2009-12-18 01:54:27 UTC (rev 1455)
@@ -18,7 +18,6 @@
# Set up the default logging to be INFO level, then override specific units
log4j.logger.org.jboss.dna=WARN
log4j.logger.org.junit=DEBUG
-# log4j.logger.org.jboss.dna.tests.integration.jackrabbit.JackrabbitMySqlStressTest=DEBUG
log4j.logger.org.hibernate=WARN
log4j.logger.org.hibernate.pretty.Printer=WARN
log4j.logger.org.hibernate.engine.Collections=WARN
@@ -31,10 +30,4 @@
log4j.logger.org.hibernate.hql.ast=WARN
log4j.logger.org.hibernate.engine.loading.CollectionLoadContext=WARN
-
-# Jackrabbit logging
-log4j.logger.org.apache.jackrabbit=WARN, stdout
-log4j.logger.org.apache.derby=INFO, stdout
-
-
log4j.logger.org.jboss.dna.connector.store=DEBUG
Modified: trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/JcrLexicon.java
===================================================================
--- trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/JcrLexicon.java 2009-12-18 01:53:48 UTC (rev 1454)
+++ trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/JcrLexicon.java 2009-12-18 01:54:27 UTC (rev 1455)
@@ -49,9 +49,13 @@
public static final Name LOCK_OWNER = new BasicName(Namespace.URI, "lockOwner");
public static final Name MERGE_FAILED = new BasicName(Namespace.URI, "mergeFailed");
public static final Name NODE_TYPES = new BasicName(Namespace.URI, "nodeTypes");
+ /** The "jcr:path" pseudo-column used in queries */
+ public static final Name PATH = new BasicName(Namespace.URI, "path");
public static final Name PREDECESSORS = new BasicName(Namespace.URI, "predecessors");
public static final Name ROOT = new BasicName(Namespace.URI, "root");
public static final Name ROOT_VERSION = new BasicName(Namespace.URI, "rootVersion");
+ /** The "jcr:score" pseudo-column used in queries */
+ public static final Name SCORE = new BasicName(Namespace.URI, "score");
public static final Name STATEMENT = new BasicName(Namespace.URI, "statement");
public static final Name SUCCESSORS = new BasicName(Namespace.URI, "successors");
public static final Name SYSTEM = new BasicName(Namespace.URI, "system");
Modified: trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/JcrQueryManager.java
===================================================================
--- trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/JcrQueryManager.java 2009-12-18 01:53:48 UTC (rev 1454)
+++ trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/JcrQueryManager.java 2009-12-18 01:54:27 UTC (rev 1455)
@@ -24,7 +24,9 @@
package org.jboss.dna.jcr;
import java.util.ArrayList;
+import java.util.Collections;
import java.util.Iterator;
+import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Set;
@@ -32,6 +34,7 @@
import javax.jcr.Node;
import javax.jcr.NodeIterator;
import javax.jcr.PathNotFoundException;
+import javax.jcr.PropertyType;
import javax.jcr.RepositoryException;
import javax.jcr.Value;
import javax.jcr.nodetype.ConstraintViolationException;
@@ -48,6 +51,7 @@
import org.jboss.dna.graph.Location;
import org.jboss.dna.graph.property.NamespaceRegistry;
import org.jboss.dna.graph.property.Path;
+import org.jboss.dna.graph.property.ValueFactories;
import org.jboss.dna.graph.query.QueryResults;
import org.jboss.dna.graph.query.QueryResults.Columns;
import org.jboss.dna.graph.query.model.QueryCommand;
@@ -110,7 +114,12 @@
try {
// Parsing must be done now ...
QueryCommand command = parser.parseQuery(expression, typeSystem);
- return new JcrQuery(this.session, expression, parser.getLanguage(), command, storedAtPath);
+ PlanHints hints = new PlanHints();
+ // If using XPath, we need to add a few hints ...
+ if (Query.XPATH.equals(language)) {
+ hints.hasFullTextSearch = true; // requires 'jcr:score' to exist
+ }
+ return new JcrQuery(this.session, expression, parser.getLanguage(), command, hints, storedAtPath);
} catch (ParsingException e) {
// The query is not well-formed and cannot be parsed ...
String reason = e.getMessage();
@@ -268,17 +277,19 @@
* @param statement the original statement as supplied by the client; may not be null
* @param language the language obtained from the {@link QueryParser}; may not be null
* @param query the parsed query representation; may not be null
+ * @param hints any hints that are to be used; may be null if there are no hints
* @param storedAtPath the path at which this query was stored, or null if this is not a stored query
*/
protected JcrQuery( JcrSession session,
String statement,
String language,
QueryCommand query,
+ PlanHints hints,
Path storedAtPath ) {
super(session, statement, language, storedAtPath);
assert query != null;
this.query = query;
- this.hints = null;
+ this.hints = hints;
this.variables = null;
}
@@ -295,6 +306,9 @@
schemata,
hints,
variables);
+ if (Query.XPATH.equals(language)) {
+ return new XPathQueryResult(session, result);
+ }
return new JcrQueryResult(session, result);
}
@@ -336,14 +350,17 @@
}
}
+ protected static final String JCR_SCORE_COLUMN_NAME = "jcr:score";
+ protected static final String JCR_PATH_COLUMN_NAME = "jcr:path";
+
/**
* The results of a query. This is not thread-safe because it relies upon JcrSession, which is not thread-safe. Also, although
* the results of a query never change, the objects returned by the iterators may vary if the session information changes.
*/
@NotThreadSafe
protected static class JcrQueryResult implements QueryResult {
- private final JcrSession session;
- private final QueryResults results;
+ protected final JcrSession session;
+ protected final QueryResults results;
protected JcrQueryResult( JcrSession session,
QueryResults graphResults ) {
@@ -357,14 +374,18 @@
return results;
}
+ public List<String> getColumnNameList() {
+ return results.getColumns().getColumnNames();
+ }
+
/**
* {@inheritDoc}
*
* @see javax.jcr.query.QueryResult#getColumnNames()
*/
public String[] getColumnNames() /*throws RepositoryException*/{
- List<String> names = results.getColumns().getColumnNames();
- return names.toArray(new String[names.size()]);
+ List<String> names = getColumnNameList();
+ return names.toArray(new String[names.size()]); // make a defensive copy ...
}
/**
@@ -491,9 +512,10 @@
*/
@NotThreadSafe
protected static class QueryResultRowIterator implements RowIterator {
- protected final List<String> propertyNames;
+ protected final List<String> columnNames;
private final Iterator<Object[]> tuples;
protected final int locationIndex;
+ protected final int scoreIndex;
protected final JcrSession session;
private long position = 0L;
private final long numRows;
@@ -503,9 +525,10 @@
Iterator<Object[]> tuples,
long numRows ) {
this.tuples = tuples;
- this.propertyNames = columns.getColumnNames();
+ this.columnNames = columns.getColumnNames();
String selectorName = columns.getSelectorNames().get(0);
this.locationIndex = columns.getLocationIndex(selectorName);
+ this.scoreIndex = columns.getFullTextSearchScoreIndexFor(selectorName);
this.session = session;
this.numRows = numRows;
}
@@ -518,49 +541,11 @@
public Row nextRow() {
final Object[] tuple = tuples.next();
++position;
- return new Row() {
- private Node node = null;
- private Value[] values = null;
+ return createRow(tuple);
+ }
- /**
- * {@inheritDoc}
- *
- * @see javax.jcr.query.Row#getValue(java.lang.String)
- */
- public Value getValue( String propertyName ) throws ItemNotFoundException, RepositoryException {
- return node().getProperty(propertyName).getValue();
- }
-
- /**
- * {@inheritDoc}
- *
- * @see javax.jcr.query.Row#getValues()
- */
- public Value[] getValues() throws RepositoryException {
- if (values == null) {
- int i = 0;
- for (String propertyName : propertyNames) {
- values[i++] = node().getProperty(propertyName).getValue();
- }
- }
- return values;
- }
-
- /**
- * Load the node. The properties are <i>always</i> fetched from the session to ensure that any modifications to
- * the nodes within session are always used.
- *
- * @return the node
- * @throws RepositoryException if the node could not be found
- */
- protected final Node node() throws RepositoryException {
- if (node == null) {
- Location location = (Location)tuple[locationIndex];
- node = session.getNode(location.getPath());
- }
- return node;
- }
- };
+ protected Row createRow( final Object[] tuple ) {
+ return new QueryResultRow(this, tuple);
}
/**
@@ -620,4 +605,146 @@
throw new UnsupportedOperationException();
}
}
+
+ protected static class QueryResultRow implements Row {
+ protected final QueryResultRowIterator iterator;
+ protected final Object[] tuple;
+ private Node node = null;
+ private Value[] values = null;
+
+ protected QueryResultRow( QueryResultRowIterator iterator,
+ Object[] tuple ) {
+ this.iterator = iterator;
+ this.tuple = tuple;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see javax.jcr.query.Row#getValue(java.lang.String)
+ */
+ public Value getValue( String columnName ) throws ItemNotFoundException, RepositoryException {
+ return node().getProperty(columnName).getValue();
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see javax.jcr.query.Row#getValues()
+ */
+ public Value[] getValues() throws RepositoryException {
+ if (values == null) {
+ int i = 0;
+ values = new Value[iterator.columnNames.size()];
+ for (String columnName : iterator.columnNames) {
+ values[i++] = getValue(columnName);
+ }
+ }
+ return values;
+ }
+
+ /**
+ * Load the node. The properties are <i>always</i> fetched from the session to ensure that any modifications to the nodes
+ * within session are always used.
+ *
+ * @return the node
+ * @throws RepositoryException if the node could not be found
+ */
+ protected final Node node() throws RepositoryException {
+ if (node == null) {
+ Location location = (Location)tuple[iterator.locationIndex];
+ node = iterator.session.getNode(location.getPath());
+ }
+ return node;
+ }
+ }
+
+ protected static class XPathQueryResult extends JcrQueryResult {
+ private final List<String> columnNames;
+
+ protected XPathQueryResult( JcrSession session,
+ QueryResults graphResults ) {
+ super(session, graphResults);
+ List<String> columnNames = new LinkedList<String>(graphResults.getColumns().getColumnNames());
+ if (graphResults.getColumns().hasFullTextSearchScores() && !columnNames.contains(JCR_SCORE_COLUMN_NAME)) {
+ columnNames.add(0, JCR_SCORE_COLUMN_NAME);
+ }
+ columnNames.add(0, JCR_PATH_COLUMN_NAME);
+ this.columnNames = Collections.unmodifiableList(columnNames);
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.jboss.dna.jcr.JcrQueryManager.JcrQueryResult#getColumnNameList()
+ */
+ @Override
+ public List<String> getColumnNameList() {
+ return columnNames;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.jboss.dna.jcr.JcrQueryManager.JcrQueryResult#getRows()
+ */
+ @Override
+ public RowIterator getRows() {
+ final int numRows = results.getRowCount();
+ final List<Object[]> tuples = results.getTuples();
+ return new XPathQueryResultRowIterator(session, results.getColumns(), tuples.iterator(), numRows);
+ }
+ }
+
+ protected static class XPathQueryResultRowIterator extends QueryResultRowIterator {
+ private final ValueFactories factories;
+ private final SessionCache cache;
+
+ protected XPathQueryResultRowIterator( JcrSession session,
+ Columns columns,
+ Iterator<Object[]> tuples,
+ long numRows ) {
+ super(session, columns, tuples, numRows);
+ factories = session.executionContext.getValueFactories();
+ cache = session.cache();
+ }
+
+ @Override
+ protected Row createRow( final Object[] tuple ) {
+ return new XPathQueryResultRow(this, tuple);
+ }
+
+ protected Value jcrPath( Path path ) {
+ return new JcrValue(factories, cache, PropertyType.PATH, path);
+ }
+
+ protected Value jcrScore( Float score ) {
+ return new JcrValue(factories, cache, PropertyType.DOUBLE, score);
+ }
+ }
+
+ protected static class XPathQueryResultRow extends QueryResultRow {
+ protected XPathQueryResultRow( XPathQueryResultRowIterator iterator,
+ Object[] tuple ) {
+ super(iterator, tuple);
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see javax.jcr.query.Row#getValue(java.lang.String)
+ */
+ @Override
+ public Value getValue( String columnName ) throws ItemNotFoundException, RepositoryException {
+ if (JCR_PATH_COLUMN_NAME.equals(columnName)) {
+ Location location = (Location)tuple[iterator.locationIndex];
+ return ((XPathQueryResultRowIterator)iterator).jcrPath(location.getPath());
+ }
+ if (JCR_SCORE_COLUMN_NAME.equals(columnName)) {
+ Float score = (Float)tuple[iterator.scoreIndex];
+ return ((XPathQueryResultRowIterator)iterator).jcrScore(score);
+ }
+ return super.getValue(columnName);
+ }
+ }
}
Modified: trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/JcrTckTest.java
===================================================================
--- trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/JcrTckTest.java 2009-12-18 01:53:48 UTC (rev 1454)
+++ trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/JcrTckTest.java 2009-12-18 01:54:27 UTC (rev 1455)
@@ -180,7 +180,7 @@
// addTestSuite(org.apache.jackrabbit.test.api.query.XPathPosIndexTest.class);
// addTestSuite(org.apache.jackrabbit.test.api.query.XPathDocOrderTest.class);
// addTestSuite(org.apache.jackrabbit.test.api.query.XPathOrderByTest.class);
- // addTestSuite(org.apache.jackrabbit.test.api.query.XPathJcrPathTest.class);
+ addTestSuite(org.apache.jackrabbit.test.api.query.XPathJcrPathTest.class);
addTestSuite(org.apache.jackrabbit.test.api.query.DerefQueryLevel1Test.class);
addTestSuite(org.apache.jackrabbit.test.api.query.GetLanguageTest.class);
addTestSuite(org.apache.jackrabbit.test.api.query.GetPersistentQueryPathLevel1Test.class);
14 years, 6 months
DNA SVN: r1454 - in trunk: dna-graph/src/main/java/org/jboss/dna/graph/query/model and 4 other directories.
by dna-commits@lists.jboss.org
Author: rhauch
Date: 2009-12-17 20:53:48 -0500 (Thu, 17 Dec 2009)
New Revision: 1454
Modified:
trunk/dna-graph/src/main/java/org/jboss/dna/graph/property/ValueTypeSystem.java
trunk/dna-graph/src/main/java/org/jboss/dna/graph/query/model/TypeSystem.java
trunk/dna-graph/src/main/java/org/jboss/dna/graph/query/process/ProcessingComponent.java
trunk/dna-graph/src/main/java/org/jboss/dna/graph/query/validate/ImmutableSchemata.java
trunk/dna-graph/src/main/java/org/jboss/dna/graph/search/AbstractSearchEngine.java
trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/JcrPropertyDefinition.java
trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/JcrRepository.java
trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/NodeTypeSchemata.java
trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/RepositoryQueryManager.java
Log:
DNA-468 Further integrated the query system by fixing several issues, including how the NodeTypeSchemata creates the IndexRules for the search engine.
Modified: trunk/dna-graph/src/main/java/org/jboss/dna/graph/property/ValueTypeSystem.java
===================================================================
--- trunk/dna-graph/src/main/java/org/jboss/dna/graph/property/ValueTypeSystem.java 2009-12-18 01:53:09 UTC (rev 1453)
+++ trunk/dna-graph/src/main/java/org/jboss/dna/graph/property/ValueTypeSystem.java 2009-12-18 01:53:48 UTC (rev 1454)
@@ -51,6 +51,7 @@
private final TypeFactory<Double> doubleFactory;
private final TypeFactory<?> dateFactory;
private final TypeFactory<?> pathFactory;
+ private final TypeFactory<?> binaryFactory;
/**
* Create a type system using the supplied value factories.
@@ -102,19 +103,7 @@
}
};
this.pathFactory = new Factory<Path>(valueFactories.getPathFactory());
- factories.put(PropertyType.STRING, this.stringFactory);
- factories.put(PropertyType.BOOLEAN, this.booleanFactory);
- factories.put(PropertyType.DATE, this.dateFactory);
- factories.put(PropertyType.DECIMAL, new Factory<BigDecimal>(valueFactories.getDecimalFactory()));
- factories.put(PropertyType.DOUBLE, this.doubleFactory);
- factories.put(PropertyType.LONG, this.longFactory);
- factories.put(PropertyType.NAME, new Factory<Name>(valueFactories.getNameFactory()));
- factories.put(PropertyType.OBJECT, new Factory<Object>(valueFactories.getObjectFactory()));
- factories.put(PropertyType.PATH, this.pathFactory);
- factories.put(PropertyType.REFERENCE, new Factory<Reference>(valueFactories.getReferenceFactory()));
- factories.put(PropertyType.URI, new Factory<URI>(valueFactories.getUriFactory()));
- factories.put(PropertyType.UUID, new Factory<UUID>(valueFactories.getUuidFactory()));
- factories.put(PropertyType.BINARY, new Factory<Binary>(valueFactories.getBinaryFactory()) {
+ this.binaryFactory = new Factory<Binary>(valueFactories.getBinaryFactory()) {
/**
* {@inheritDoc}
*
@@ -137,7 +126,20 @@
Binary binary = this.valueFactory.create(value);
return binary != null ? binary.getSize() : 0;
}
- });
+ };
+ factories.put(PropertyType.STRING, this.stringFactory);
+ factories.put(PropertyType.BOOLEAN, this.booleanFactory);
+ factories.put(PropertyType.DATE, this.dateFactory);
+ factories.put(PropertyType.DECIMAL, new Factory<BigDecimal>(valueFactories.getDecimalFactory()));
+ factories.put(PropertyType.DOUBLE, this.doubleFactory);
+ factories.put(PropertyType.LONG, this.longFactory);
+ factories.put(PropertyType.NAME, new Factory<Name>(valueFactories.getNameFactory()));
+ factories.put(PropertyType.OBJECT, new Factory<Object>(valueFactories.getObjectFactory()));
+ factories.put(PropertyType.PATH, this.pathFactory);
+ factories.put(PropertyType.REFERENCE, new Factory<Reference>(valueFactories.getReferenceFactory()));
+ factories.put(PropertyType.URI, new Factory<URI>(valueFactories.getUriFactory()));
+ factories.put(PropertyType.UUID, new Factory<UUID>(valueFactories.getUuidFactory()));
+ factories.put(PropertyType.BINARY, this.binaryFactory);
this.typeFactoriesByPropertyType = Collections.unmodifiableMap(factories);
Map<String, PropertyType> propertyTypeByName = new HashMap<String, PropertyType>();
for (Map.Entry<PropertyType, TypeFactory<?>> entry : this.typeFactoriesByPropertyType.entrySet()) {
@@ -236,6 +238,15 @@
/**
* {@inheritDoc}
*
+ * @see org.jboss.dna.graph.query.model.TypeSystem#getBinaryFactory()
+ */
+ public TypeFactory<?> getBinaryFactory() {
+ return binaryFactory;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
* @see org.jboss.dna.graph.query.model.TypeSystem#getTypeFactory(java.lang.String)
*/
public TypeFactory<?> getTypeFactory( String typeName ) {
Modified: trunk/dna-graph/src/main/java/org/jboss/dna/graph/query/model/TypeSystem.java
===================================================================
--- trunk/dna-graph/src/main/java/org/jboss/dna/graph/query/model/TypeSystem.java 2009-12-18 01:53:09 UTC (rev 1453)
+++ trunk/dna-graph/src/main/java/org/jboss/dna/graph/query/model/TypeSystem.java 2009-12-18 01:53:48 UTC (rev 1454)
@@ -93,6 +93,13 @@
TypeFactory<?> getPathFactory();
/**
+ * Get the type factory for binary objects.
+ *
+ * @return the binary factory, or null if this type system doesn't support binary objects
+ */
+ TypeFactory<?> getBinaryFactory();
+
+ /**
* Get the name of the type that is used by default.
*
* @return the default type name; never null
Modified: trunk/dna-graph/src/main/java/org/jboss/dna/graph/query/process/ProcessingComponent.java
===================================================================
--- trunk/dna-graph/src/main/java/org/jboss/dna/graph/query/process/ProcessingComponent.java 2009-12-18 01:53:09 UTC (rev 1453)
+++ trunk/dna-graph/src/main/java/org/jboss/dna/graph/query/process/ProcessingComponent.java 2009-12-18 01:53:48 UTC (rev 1454)
@@ -161,13 +161,14 @@
Table table = schemata.getTable(propValue.getSelectorName());
Column schemaColumn = table.getColumn(propertyName);
final String expectedType = schemaColumn.getPropertyType();
+ final TypeFactory<?> typeFactory = typeSystem.getTypeFactory(expectedType);
return new DynamicOperation() {
public String getExpectedType() {
return expectedType;
}
public Object evaluate( Object[] tuple ) {
- return tuple[index];
+ return typeFactory.create(tuple[index]);
}
};
}
@@ -183,9 +184,10 @@
Column schemaColumn = table.getColumn(propertyName);
final String expectedType = schemaColumn.getPropertyType();
final TypeFactory<?> typeFactory = typeSystem.getTypeFactory(expectedType);
+ final TypeFactory<Long> longFactory = typeSystem.getLongFactory();
return new DynamicOperation() {
public String getExpectedType() {
- return typeSystem.getLongFactory().getTypeName(); // length is always LONG
+ return longFactory.getTypeName(); // length is always LONG
}
public Object evaluate( Object[] tuple ) {
@@ -293,11 +295,12 @@
FullTextSearchScore score = (FullTextSearchScore)operand;
String selectorName = score.getSelectorName().getName();
final int index = columns.getFullTextSearchScoreIndexFor(selectorName);
+ final TypeFactory<Double> doubleFactory = typeSystem.getDoubleFactory();
if (index < 0) {
// No full-text search score for this selector, so return 0.0d;
return new DynamicOperation() {
public String getExpectedType() {
- return typeSystem.getDoubleFactory().getTypeName();
+ return doubleFactory.getTypeName();
}
public Object evaluate( Object[] tuple ) {
@@ -307,7 +310,7 @@
}
return new DynamicOperation() {
public String getExpectedType() {
- return typeSystem.getDoubleFactory().getTypeName();
+ return doubleFactory.getTypeName();
}
public Object evaluate( Object[] tuple ) {
Modified: trunk/dna-graph/src/main/java/org/jboss/dna/graph/query/validate/ImmutableSchemata.java
===================================================================
--- trunk/dna-graph/src/main/java/org/jboss/dna/graph/query/validate/ImmutableSchemata.java 2009-12-18 01:53:09 UTC (rev 1453)
+++ trunk/dna-graph/src/main/java/org/jboss/dna/graph/query/validate/ImmutableSchemata.java 2009-12-18 01:53:48 UTC (rev 1454)
@@ -308,7 +308,9 @@
QueryContext queryContext = new QueryContext(schemata, typeSystem);
CanonicalPlanner planner = new CanonicalPlanner();
PlanNode plan = planner.createPlan(queryContext, command);
- if (queryContext.getProblems().hasErrors()) continue;
+ if (queryContext.getProblems().hasErrors()) {
+ continue;
+ }
// Get the columns from the top-level PROJECT ...
PlanNode project = plan.findAtOrBelow(Type.PROJECT);
Modified: trunk/dna-graph/src/main/java/org/jboss/dna/graph/search/AbstractSearchEngine.java
===================================================================
--- trunk/dna-graph/src/main/java/org/jboss/dna/graph/search/AbstractSearchEngine.java 2009-12-18 01:53:09 UTC (rev 1453)
+++ trunk/dna-graph/src/main/java/org/jboss/dna/graph/search/AbstractSearchEngine.java 2009-12-18 01:53:48 UTC (rev 1454)
@@ -53,7 +53,7 @@
public abstract class AbstractSearchEngine<WorkspaceType extends SearchEngineWorkspace, ProcessorType extends SearchEngineProcessor>
implements SearchEngine {
- public static final boolean DEFAULT_VERIFY_WORKSPACE_IN_SOURCE = true;
+ public static final boolean DEFAULT_VERIFY_WORKSPACE_IN_SOURCE = false;
private final boolean verifyWorkspaceInSource;
private final RepositoryConnectionFactory connectionFactory;
Modified: trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/JcrPropertyDefinition.java
===================================================================
--- trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/JcrPropertyDefinition.java 2009-12-18 01:53:09 UTC (rev 1453)
+++ trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/JcrPropertyDefinition.java 2009-12-18 01:53:48 UTC (rev 1454)
@@ -241,6 +241,48 @@
}
/**
+ * Return the minimum value allowed by the constraints, or null if no such minimum value is defined by the definition given
+ * it's required type and constraints. A minimum value can only be found for numeric types, such as {@link PropertyType#DATE
+ * DATE}, {@link PropertyType#LONG LONG}, and {@link PropertyType#DOUBLE DOUBLE}; all other types will return null.
+ *
+ * @return the minimum value, or null if no minimum value could be identified
+ */
+ Object getMinimumValue() {
+ if (requiredType == PropertyType.DATE || requiredType == PropertyType.DOUBLE || requiredType == PropertyType.LONG) {
+ ConstraintChecker checker = this.checker;
+ if (checker == null || checker.getType() != requiredType) {
+ checker = createChecker(context, requiredType, valueConstraints);
+ this.checker = checker;
+ }
+ assert checker instanceof RangeConstraintChecker;
+ RangeConstraintChecker<?> rangeChecker = (RangeConstraintChecker<?>)checker;
+ return rangeChecker.getMinimum(); // may still be null
+ }
+ return null;
+ }
+
+ /**
+ * Return the maximum value allowed by the constraints, or null if no such maximum value is defined by the definition given
+ * it's required type and constraints. A maximum value can only be found for numeric types, such as {@link PropertyType#DATE
+ * DATE}, {@link PropertyType#LONG LONG}, and {@link PropertyType#DOUBLE DOUBLE}; all other types will return null.
+ *
+ * @return the maximum value, or null if no maximum value could be identified
+ */
+ Object getMaximumValue() {
+ if (requiredType == PropertyType.DATE || requiredType == PropertyType.DOUBLE || requiredType == PropertyType.LONG) {
+ ConstraintChecker checker = this.checker;
+ if (checker == null || checker.getType() != requiredType) {
+ checker = createChecker(context, requiredType, valueConstraints);
+ this.checker = checker;
+ }
+ assert checker instanceof RangeConstraintChecker;
+ RangeConstraintChecker<?> rangeChecker = (RangeConstraintChecker<?>)checker;
+ return rangeChecker.getMaximum(); // may still be null
+ }
+ return null;
+ }
+
+ /**
* Returns <code>true</code> if <code>value</code> can be cast to <code>property.getRequiredType()</code> per the type
* conversion rules in section 6.2.6 of the JCR 1.0 specification AND <code>value</code> satisfies the constraints (if any)
* for the property definition. If the property definition has a required type of {@link PropertyType#UNDEFINED}, the cast
@@ -367,6 +409,10 @@
private interface Range<T> {
boolean accepts( T value );
+
+ Comparable<T> getMinimum();
+
+ Comparable<T> getMaximum();
}
/**
@@ -378,6 +424,8 @@
private static abstract class RangeConstraintChecker<T extends Comparable<T>> implements ConstraintChecker {
private final Range<T>[] constraints;
private final ValueFactory<T> valueFactory;
+ private T minimumValue;
+ private T maximumValue;
@SuppressWarnings( "unchecked" )
protected RangeConstraintChecker( String[] valueConstraints,
@@ -394,6 +442,46 @@
protected abstract Comparable<T> parseValue( String s );
+ @SuppressWarnings( "unchecked" )
+ protected T getMinimum() {
+ if (minimumValue == null) {
+ // This is idempotent, so okay to recreate ...
+ Comparable<T> minimum = null;
+ // Go through the value constraints and see which one is the minimum value ...
+ for (Range<T> range : constraints) {
+ T rangeMin = (T)range.getMinimum();
+ if (rangeMin == null) continue;
+ if (minimum == null) {
+ minimum = rangeMin;
+ } else {
+ minimum = minimum.compareTo(rangeMin) > 0 ? rangeMin : minimum;
+ }
+ }
+ minimumValue = (T)minimum;
+ }
+ return minimumValue;
+ }
+
+ @SuppressWarnings( "unchecked" )
+ protected T getMaximum() {
+ if (maximumValue == null) {
+ // This is idempotent, so okay to recreate ...
+ Comparable<T> maximum = null;
+ // Go through the value constraints and see which one is the minimum value ...
+ for (Range<T> range : constraints) {
+ T rangeMax = (T)range.getMaximum();
+ if (rangeMax == null) continue;
+ if (maximum == null) {
+ maximum = rangeMax;
+ } else {
+ maximum = maximum.compareTo(rangeMax) > 0 ? rangeMax : maximum;
+ }
+ }
+ maximumValue = (T)maximum;
+ }
+ return maximumValue;
+ }
+
/**
* Parses one constraint value into a {@link Range} that will accept only values which match the range described by the
* value constraint.
@@ -425,6 +513,24 @@
}
return true;
}
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.jboss.dna.jcr.JcrPropertyDefinition.Range#getMaximum()
+ */
+ public Comparable<T> getMaximum() {
+ return lower;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.jboss.dna.jcr.JcrPropertyDefinition.Range#getMinimum()
+ */
+ public Comparable<T> getMinimum() {
+ return upper;
+ }
};
}
Modified: trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/JcrRepository.java
===================================================================
--- trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/JcrRepository.java 2009-12-18 01:53:09 UTC (rev 1453)
+++ trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/JcrRepository.java 2009-12-18 01:53:48 UTC (rev 1454)
@@ -307,7 +307,7 @@
/**
* The default value for the {@link Option#QUERY_INDEXES_UPDATED_SYNCHRONOUSLY} option is {@value} .
*/
- public static final String QUERY_INDEXES_UPDATED_SYNCHRONOUSLY = Boolean.FALSE.toString();
+ public static final String QUERY_INDEXES_UPDATED_SYNCHRONOUSLY = Boolean.TRUE.toString();
/**
* The default value for the {@link Option#QUERY_INDEX_DIRECTORY} option is {@value} .
@@ -575,13 +575,8 @@
// Otherwise create a repository query manager that maintains its own search engine ...
String indexDirectory = this.options.get(Option.QUERY_INDEX_DIRECTORY);
boolean updateIndexesSynchronously = Boolean.valueOf(this.options.get(Option.QUERY_INDEXES_UPDATED_SYNCHRONOUSLY));
- // At this point in time, we cannot query the federated connector ...
- String sourceToQuery = this.sourceName;
- // But we need to observe the federated source (if there is one) ...
- final String sourceToObserve = federatedSource != null ? federatedSource.getName() : this.sourceName;
- // We actually want to use the federated source to crawl and watch for changes ...
- this.queryManager = new RepositoryQueryManager.SelfContained(executionContext, sourceToQuery, sourceToObserve,
- connectionFactoryWithSystem, repositoryObservable,
+ this.queryManager = new RepositoryQueryManager.SelfContained(executionContext, this.sourceName,
+ connectionFactory, repositoryObservable,
indexDirectory, updateIndexesSynchronously);
}
} else {
Modified: trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/NodeTypeSchemata.java
===================================================================
--- trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/NodeTypeSchemata.java 2009-12-18 01:53:09 UTC (rev 1453)
+++ trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/NodeTypeSchemata.java 2009-12-18 01:53:48 UTC (rev 1454)
@@ -33,6 +33,8 @@
import javax.jcr.nodetype.PropertyDefinition;
import net.jcip.annotations.Immutable;
import net.jcip.annotations.NotThreadSafe;
+import org.apache.lucene.document.Field.Index;
+import org.apache.lucene.document.Field.Store;
import org.jboss.dna.graph.ExecutionContext;
import org.jboss.dna.graph.property.Name;
import org.jboss.dna.graph.property.NameFactory;
@@ -44,6 +46,8 @@
import org.jboss.dna.graph.query.model.TypeSystem;
import org.jboss.dna.graph.query.validate.ImmutableSchemata;
import org.jboss.dna.graph.query.validate.Schemata;
+import org.jboss.dna.search.lucene.IndexRules;
+import org.jboss.dna.search.lucene.LuceneSearchEngine;
import com.google.common.collect.LinkedHashMultimap;
import com.google.common.collect.Multimap;
@@ -62,6 +66,7 @@
private final Iterable<JcrPropertyDefinition> propertyDefinitions;
private final Map<Name, JcrNodeType> nodeTypesByName;
private final Multimap<JcrNodeType, JcrNodeType> subtypesByName = LinkedHashMultimap.create();
+ private final IndexRules indexRules;
NodeTypeSchemata( ExecutionContext context,
Map<Name, JcrNodeType> nodeTypes,
@@ -71,6 +76,11 @@
this.propertyDefinitions = propertyDefinitions;
this.nodeTypesByName = nodeTypes;
+ // Register all the namespace prefixes by URIs ...
+ for (Namespace namespace : context.getNamespaceRegistry().getNamespaces()) {
+ this.prefixesByUris.put(namespace.getNamespaceUri(), namespace.getPrefix());
+ }
+
// Identify the subtypes for each node type, and do this before we build any views ...
for (JcrNodeType nodeType : nodeTypesByName.values()) {
// For each of the supertypes ...
@@ -92,7 +102,8 @@
}
// Create the "ALLNODES" table, which will contain all possible properties ...
- addAllNodesTable(builder, context);
+ IndexRules.Builder indexRulesBuilder = IndexRules.createBuilder(LuceneSearchEngine.DEFAULT_RULES);
+ addAllNodesTable(builder, indexRulesBuilder, context);
// Define a view for each node type ...
for (JcrNodeType nodeType : nodeTypesByName.values()) {
@@ -100,19 +111,24 @@
}
schemata = builder.build();
+ indexRules = indexRulesBuilder.build();
}
+ /**
+ * Get the index rules ...
+ *
+ * @return indexRules
+ */
+ public IndexRules getIndexRules() {
+ return indexRules;
+ }
+
protected JcrNodeType getNodeType( Name nodeTypeName ) {
return nodeTypesByName.get(nodeTypeName);
}
- private void recordName( NamespaceRegistry registry,
- Name name ) {
- String uri = name.getNamespaceUri();
- prefixesByUris.put(uri, registry.getPrefixForNamespaceUri(uri, false));
- }
-
protected final void addAllNodesTable( ImmutableSchemata.Builder builder,
+ IndexRules.Builder indexRuleBuilder,
ExecutionContext context ) {
NamespaceRegistry registry = context.getNamespaceRegistry();
TypeSystem typeSystem = context.getValueFactories().getTypeSystem();
@@ -123,9 +139,8 @@
Set<String> fullTextSearchableNames = new HashSet<String>();
for (JcrPropertyDefinition defn : propertyDefinitions) {
if (defn.isResidual()) continue;
- if (defn.isMultiple()) continue;
+ // if (defn.isMultiple()) continue;
Name name = defn.getInternalName();
- recordName(registry, name);
String columnName = name.getString(registry);
if (first) {
builder.addTable(tableName, columnName);
@@ -145,9 +160,53 @@
if (fullTextSearchable) fullTextSearchableNames.add(columnName);
// Add (or overwrite) the column ...
builder.addColumn(tableName, columnName, type, fullTextSearchable);
+
+ // And build an indexing rule for this type ...
+ if (indexRuleBuilder != null) addIndexRule(indexRuleBuilder, defn, type, typeSystem);
}
}
+ /**
+ * Add an index rule for the given property definition and the type in the {@link TypeSystem}.
+ *
+ * @param builder the index rule builder; never null
+ * @param defn the property definition; never null
+ * @param type the TypeSystem type, which may be a more general type than dictated by the definition, since multiple
+ * definitions with the same name require the index rule to use the common base type; never null
+ * @param typeSystem the type system; never null
+ */
+ protected final void addIndexRule( IndexRules.Builder builder,
+ JcrPropertyDefinition defn,
+ String type,
+ TypeSystem typeSystem ) {
+ Store store = Store.YES;
+ Index index = defn.isFullTextSearchable() ? Index.ANALYZED : Index.NO;
+ if (typeSystem.getStringFactory().getTypeName().equals(type)) {
+ builder.stringField(defn.getInternalName(), store, index);
+ } else if (typeSystem.getDateTimeFactory().getTypeName().equals(type)) {
+ Long minimum = typeSystem.getLongFactory().create(defn.getMinimumValue());
+ Long maximum = typeSystem.getLongFactory().create(defn.getMaximumValue());
+ builder.dateField(defn.getInternalName(), store, index, minimum, maximum);
+ } else if (typeSystem.getLongFactory().getTypeName().equals(type)) {
+ Long minimum = typeSystem.getLongFactory().create(defn.getMinimumValue());
+ Long maximum = typeSystem.getLongFactory().create(defn.getMaximumValue());
+ builder.longField(defn.getInternalName(), store, index, minimum, maximum);
+ } else if (typeSystem.getDoubleFactory().getTypeName().equals(type)) {
+ Double minimum = typeSystem.getDoubleFactory().create(defn.getMinimumValue());
+ Double maximum = typeSystem.getDoubleFactory().create(defn.getMaximumValue());
+ builder.doubleField(defn.getInternalName(), store, index, minimum, maximum);
+ } else if (typeSystem.getBooleanFactory().getTypeName().equals(type)) {
+ builder.booleanField(defn.getInternalName(), store, index);
+ } else if (typeSystem.getBinaryFactory().getTypeName().equals(type)) {
+ store = Store.NO;
+ builder.binaryField(defn.getInternalName(), store, index);
+ } else {
+ // Everything else gets stored as a string ...
+ builder.stringField(defn.getInternalName(), store, index);
+ }
+
+ }
+
protected final void addView( ImmutableSchemata.Builder builder,
ExecutionContext context,
JcrNodeType nodeType ) {
@@ -171,49 +230,68 @@
if (defn.isResidual()) continue;
if (defn.isMultiple()) continue;
Name name = defn.getInternalName();
- recordName(registry, name);
String columnName = name.getString(registry);
if (first) first = false;
else viewDefinition.append(',');
viewDefinition.append('[').append(columnName).append(']');
}
- viewDefinition.append(" FROM ").append(AllNodes.ALL_NODES_NAME).append(" WHERE ");
+ viewDefinition.append(" FROM ").append(AllNodes.ALL_NODES_NAME);
- Collection<JcrNodeType> typeAndSubtypes = subtypesByName.get(nodeType);
- if (nodeType.isMixin()) {
- // Build the list of mixin types ...
- StringBuilder mixinTypes = null;
- for (JcrNodeType thisOrSupertype : typeAndSubtypes) {
- if (!thisOrSupertype.isMixin()) continue;
- if (mixinTypes == null) {
- mixinTypes = new StringBuilder();
- mixinTypes.append('[').append(JcrLexicon.MIXIN_TYPES.getString(registry)).append("] IN (");
+ // The 'nt:base' node type will have every single object in it, so we don't need to add the type criteria ...
+ if (!JcrNtLexicon.BASE.equals(nodeType.getInternalName())) {
+ // The node type is not 'nt:base', which
+ viewDefinition.append(" WHERE ");
+
+ Collection<JcrNodeType> typeAndSubtypes = subtypesByName.get(nodeType);
+ if (nodeType.isMixin()) {
+ // Build the list of mixin types ...
+ StringBuilder mixinTypes = null;
+ int count = 0;
+ for (JcrNodeType thisOrSupertype : typeAndSubtypes) {
+ if (!thisOrSupertype.isMixin()) continue;
+ if (mixinTypes == null) {
+ mixinTypes = new StringBuilder();
+ } else {
+ mixinTypes.append(',');
+ }
+ assert prefixesByUris.containsKey(thisOrSupertype.getInternalName().getNamespaceUri());
+ String name = thisOrSupertype.getInternalName().getString(registry);
+ mixinTypes.append('[').append(name).append(']');
+ ++count;
+ }
+ assert mixinTypes != null; // should at least include itself
+ assert count > 0;
+ viewDefinition.append('[').append(JcrLexicon.MIXIN_TYPES.getString(registry)).append(']');
+ if (count == 1) {
+ viewDefinition.append('=').append(mixinTypes);
} else {
- mixinTypes.append(',');
+ viewDefinition.append(" IN (").append(mixinTypes).append(')');
}
- assert prefixesByUris.containsKey(thisOrSupertype.getInternalName().getNamespaceUri());
- String name = thisOrSupertype.getInternalName().getString(registry);
- mixinTypes.append(name);
- }
- assert mixinTypes != null; // should at least include itself
- viewDefinition.append(mixinTypes);
- } else {
- // Build the list of node type names ...
- StringBuilder primaryTypes = null;
- for (JcrNodeType thisOrSupertype : typeAndSubtypes) {
- if (thisOrSupertype.isMixin()) continue;
- if (primaryTypes == null) {
- primaryTypes = new StringBuilder();
- primaryTypes.append('[').append(JcrLexicon.PRIMARY_TYPE.getString(registry)).append("] IN (");
+ } else {
+ // Build the list of node type names ...
+ StringBuilder primaryTypes = null;
+ int count = 0;
+ for (JcrNodeType thisOrSupertype : typeAndSubtypes) {
+ if (thisOrSupertype.isMixin()) continue;
+ if (primaryTypes == null) {
+ primaryTypes = new StringBuilder();
+ } else {
+ primaryTypes.append(',');
+ }
+ assert prefixesByUris.containsKey(thisOrSupertype.getInternalName().getNamespaceUri());
+ String name = thisOrSupertype.getInternalName().getString(registry);
+ primaryTypes.append('[').append(name).append(']');
+ ++count;
+ }
+ assert primaryTypes != null; // should at least include itself
+ assert count > 0;
+ viewDefinition.append('[').append(JcrLexicon.PRIMARY_TYPE.getString(registry)).append(']');
+ if (count == 1) {
+ viewDefinition.append('=').append(primaryTypes);
} else {
- primaryTypes.append(',');
+ viewDefinition.append(" IN (").append(primaryTypes).append(')');
}
- assert prefixesByUris.containsKey(thisOrSupertype.getInternalName().getNamespaceUri());
- String name = thisOrSupertype.getInternalName().getString(registry);
- primaryTypes.append(name);
}
- assert primaryTypes != null; // should at least include itself
- viewDefinition.append(primaryTypes);
}
// Define the view ...
@@ -298,7 +376,7 @@
this.nameFactory = context.getValueFactories().getNameFactory();
this.builder = ImmutableSchemata.createBuilder(context.getValueFactories().getTypeSystem());
// Add the "AllNodes" table ...
- addAllNodesTable(builder, context);
+ addAllNodesTable(builder, null, context);
this.schemata = builder.build();
}
Modified: trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/RepositoryQueryManager.java
===================================================================
--- trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/RepositoryQueryManager.java 2009-12-18 01:53:09 UTC (rev 1453)
+++ trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/RepositoryQueryManager.java 2009-12-18 01:53:48 UTC (rev 1454)
@@ -141,7 +141,6 @@
SelfContained( ExecutionContext context,
String nameOfSourceToBeSearchable,
- final String observableSource,
RepositoryConnectionFactory connectionFactory,
Observable observable,
String indexDirectory,
@@ -190,15 +189,17 @@
// Set up the search engine ...
org.apache.lucene.analysis.Analyzer analyzer = null;
- searchEngine = new LuceneSearchEngine(nameOfSourceToBeSearchable, connectionFactory, true, configuration, indexRules,
- analyzer);
+ boolean verifyWorkspaces = false;
+ searchEngine = new LuceneSearchEngine(nameOfSourceToBeSearchable, connectionFactory, verifyWorkspaces, configuration,
+ indexRules, analyzer);
// Set up an original source observer to keep the index up to date ...
if (updateIndexesSynchronously) {
this.service = null;
this.searchObserver = new Observer() {
+ @SuppressWarnings( "synthetic-access" )
public void notify( Changes changes ) {
- if (changes.getSourceName().equals(observableSource)) {
+ if (changes.getSourceName().equals(sourceName)) {
process(changes);
}
}
@@ -209,7 +210,7 @@
this.searchObserver = new Observer() {
@SuppressWarnings( "synthetic-access" )
public void notify( final Changes changes ) {
- if (changes.getSourceName().equals(observableSource)) {
+ if (changes.getSourceName().equals(sourceName)) {
service.submit(new Runnable() {
public void run() {
process(changes);
@@ -249,7 +250,6 @@
protected void process( Changes changes ) {
try {
- Logger.getLogger(getClass()).warn(JcrI18n.errorUpdatingQueryIndexes, "JUST KIDDING");
searchEngine.index(context, changes.getChangeRequests());
} catch (RuntimeException e) {
Logger.getLogger(getClass()).error(e, JcrI18n.errorUpdatingQueryIndexes, e.getLocalizedMessage());
14 years, 6 months
DNA SVN: r1453 - in trunk/dna-integration-tests: src/test/java/org/jboss/dna/test/integration/jackrabbit and 1 other directory.
by dna-commits@lists.jboss.org
Author: rhauch
Date: 2009-12-17 20:53:09 -0500 (Thu, 17 Dec 2009)
New Revision: 1453
Removed:
trunk/dna-integration-tests/src/test/java/org/jboss/dna/test/integration/jackrabbit/JackrabbitBasicFunctionTest.java
trunk/dna-integration-tests/src/test/java/org/jboss/dna/test/integration/jackrabbit/JackrabbitDerbyStressTest.java
trunk/dna-integration-tests/src/test/java/org/jboss/dna/test/integration/jackrabbit/JackrabbitInMemoryTest.java
trunk/dna-integration-tests/src/test/java/org/jboss/dna/test/integration/jackrabbit/JackrabbitTestUtil.java
Modified:
trunk/dna-integration-tests/pom.xml
Log:
DNA-468 Removed the integration tests that used Jackrabbit, because Jackrabbit requires an older version of Lucene and pukes with the version we're using. Now all unit and integration tests (including the TCK for the various connectors) all run successfully. BTW, the Jackrabbit tests were really just verifying behavior and were not integrating DNA with Jackrabbit; therefore, it's okay they're gone.
Modified: trunk/dna-integration-tests/pom.xml
===================================================================
--- trunk/dna-integration-tests/pom.xml 2009-12-18 01:52:46 UTC (rev 1452)
+++ trunk/dna-integration-tests/pom.xml 2009-12-18 01:53:09 UTC (rev 1453)
@@ -145,44 +145,11 @@
<artifactId>jcr</artifactId>
<scope>test</scope>
</dependency>
- <!-- Apache Jackrabbit (JCR Implementation) -->
+ <!--
+ JCR TCK unit tests
+ -->
<dependency>
<groupId>org.apache.jackrabbit</groupId>
- <artifactId>jackrabbit-api</artifactId>
- <version>1.4</version>
- <scope>test</scope>
- <!-- Exclude these since they are included in JDK 1.5 -->
- <exclusions>
- <exclusion>
- <groupId>xml-apis</groupId>
- <artifactId>xml-apis</artifactId>
- </exclusion>
- <exclusion>
- <groupId>xerces</groupId>
- <artifactId>xercesImpl</artifactId>
- </exclusion>
- </exclusions>
- </dependency>
- <dependency>
- <groupId>org.apache.jackrabbit</groupId>
- <artifactId>jackrabbit-core</artifactId>
- <version>1.4.5</version>
- <scope>test</scope>
- <!-- Exclude these since they are included in JDK 1.5 -->
- <exclusions>
- <exclusion>
- <groupId>xml-apis</groupId>
- <artifactId>xml-apis</artifactId>
- </exclusion>
- <exclusion>
- <groupId>xerces</groupId>
- <artifactId>xercesImpl</artifactId>
- </exclusion>
- </exclusions>
- </dependency>
-
- <dependency>
- <groupId>org.apache.jackrabbit</groupId>
<artifactId>jackrabbit-jcr-tests</artifactId>
</dependency>
<!--
Deleted: trunk/dna-integration-tests/src/test/java/org/jboss/dna/test/integration/jackrabbit/JackrabbitBasicFunctionTest.java
===================================================================
--- trunk/dna-integration-tests/src/test/java/org/jboss/dna/test/integration/jackrabbit/JackrabbitBasicFunctionTest.java 2009-12-18 01:52:46 UTC (rev 1452)
+++ trunk/dna-integration-tests/src/test/java/org/jboss/dna/test/integration/jackrabbit/JackrabbitBasicFunctionTest.java 2009-12-18 01:53:09 UTC (rev 1453)
@@ -1,216 +0,0 @@
-/*
- * JBoss DNA (http://www.jboss.org/dna)
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- * See the AUTHORS.txt file in the distribution for a full listing of
- * individual contributors.
- *
- * JBoss DNA is free software. Unless otherwise indicated, all code in JBoss DNA
- * is licensed to you under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * JBoss DNA is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.dna.test.integration.jackrabbit;
-
-import static org.junit.Assert.assertNotNull;
-import java.io.FileInputStream;
-import java.util.ArrayList;
-import java.util.List;
-import javax.jcr.ImportUUIDBehavior;
-import javax.jcr.Node;
-import javax.jcr.Repository;
-import javax.jcr.Session;
-import javax.jcr.SimpleCredentials;
-import org.apache.jackrabbit.core.TransientRepository;
-import org.jboss.dna.common.i18n.MockI18n;
-import org.jboss.dna.common.util.FileUtil;
-import org.jboss.dna.common.util.Logger;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-
-public class JackrabbitBasicFunctionTest {
-
- public static final String TESTATA_PATH = "./src/test/resources/";
- public static final String JACKRABBIT_DATA_PATH = "./target/testdata/jackrabbittest/";
- public static final String REPOSITORY_DIRECTORY_PATH = JACKRABBIT_DATA_PATH + "repository";
- public static final String REPOSITORY_CONFIG_PATH = TESTATA_PATH + "jackrabbitDerbyTestRepositoryConfig.xml";
- public static final String DERBY_SYSTEM_HOME = JACKRABBIT_DATA_PATH + "/derby";
-
- private Logger logger;
- private Repository repository;
-
- @Before
- public void beforeEach() throws Exception {
- // Clean up the test data ...
- FileUtil.delete(JACKRABBIT_DATA_PATH);
-
- // Set up Derby and the logger ...
- System.setProperty("derby.system.home", DERBY_SYSTEM_HOME);
- logger = Logger.getLogger(JackrabbitBasicFunctionTest.class);
-
- // Set up the transient repository ...
- this.repository = new TransientRepository(REPOSITORY_CONFIG_PATH, REPOSITORY_DIRECTORY_PATH);
- }
-
- @After
- public void afterEach() {
- // Clean up the test data ...
- FileUtil.delete(JACKRABBIT_DATA_PATH);
- }
-
- @Test
- public void shouldConnectWithAnonymous() throws Exception {
- Session session = null;
- try {
- session = this.repository.login();
- assertNotNull(session);
- String username = session.getUserID();
- String name = repository.getDescriptor(Repository.REP_NAME_DESC);
- logger.info(MockI18n.passthrough, "Logged in as " + username + " to a " + name + " repository");
- } finally {
- if (session != null) session.logout();
- }
- }
-
- @Test
- public void shouldConnectWithSimpleCredentials() throws Exception {
- Session session = null;
- try {
- SimpleCredentials creds = new SimpleCredentials("jsmith", "password".toCharArray());
- session = this.repository.login(creds);
- assertNotNull(session);
- String username = session.getUserID();
- String name = repository.getDescriptor(Repository.REP_NAME_DESC);
- logger.info(MockI18n.passthrough, "Logged in as " + username + " to a " + name + " repository");
- } finally {
- if (session != null) session.logout();
- }
- }
-
- @Test
- public void shouldSupportConcurrentSessionsForDifferentUsers() throws Exception {
- List<Session> sessions = new ArrayList<Session>();
- try {
- for (int i = 0; i != 10; ++i) {
- SimpleCredentials creds = new SimpleCredentials("user" + i, ("secret" + i).toCharArray());
- Session session = this.repository.login(creds);
- assertNotNull(session);
- sessions.add(session);
- logger.info(MockI18n.passthrough, "Logged in as " + session.getUserID());
- }
- } finally {
- while (!sessions.isEmpty()) {
- sessions.remove(0).logout();
- }
- }
- }
-
- @Test( expected = javax.jcr.AccessDeniedException.class )
- public void shouldNotAllowAnonymousUserToCreateContent() throws Exception {
- Session session = null;
- try {
- session = this.repository.login();
- assertNotNull(session);
- Node root = session.getRootNode();
-
- // Store content
- Node hello = root.addNode("hello");
- Node world = hello.addNode("world");
- world.setProperty("message", "Hello, World!");
- session.save(); // Should fail
- } finally {
- if (session != null) session.logout();
- }
- }
-
- @Test
- public void shouldAllowAuthenticatedUserToCreateAndManipulateContent() throws Exception {
- SimpleCredentials creds = new SimpleCredentials("user", "secret".toCharArray());
- Session session = null;
- try {
- session = this.repository.login(creds);
- assertNotNull(session);
- Node root = session.getRootNode();
-
- // Store content
- Node hello = root.addNode("hello");
- Node world = hello.addNode("world");
- world.setProperty("message", "Hello, World!");
- session.save();
-
- // Retrieve content ...
- Node node = root.getNode("hello/world");
- this.logger.info(MockI18n.passthrough, "Node 'hello/world' has path: " + node.getPath());
- this.logger.info(MockI18n.passthrough, "Node 'hello/world' has 'message' property: "
- + node.getProperty("message").getString());
- } finally {
- if (session != null) session.logout();
- }
-
- try {
- session = this.repository.login(creds);
- assertNotNull(session);
- Node root = session.getRootNode();
-
- // Retrieve content
- Node node = root.getNode("hello/world");
- this.logger.info(MockI18n.passthrough, "Node 'hello/world' has path: " + node.getPath());
- this.logger.info(MockI18n.passthrough, "Node 'hello/world' has 'message' property: "
- + node.getProperty("message").getString());
-
- // Remove content
- this.logger.info(MockI18n.passthrough, "Node 'hello' is being removed");
- root.getNode("hello").remove();
- session.save();
- } finally {
- if (session != null) session.logout();
- }
- }
-
- @Test
- public void shouldImportFile() throws Exception {
- SimpleCredentials creds = new SimpleCredentials("user", "secret".toCharArray());
- Session session = null;
- try {
- session = this.repository.login(creds);
- assertNotNull(session);
-
- // Use the root node as a starting point
- Node root = session.getRootNode();
-
- // Import the XML file unless already imported
- if (!root.hasNode("importxml")) {
- System.out.print("Importing xml... ");
- // Create an unstructured node under which to import the XML
- Node node = root.addNode("importxml", "nt:unstructured");
- // Import the file "test.xml" under the created node
- FileInputStream xml = new FileInputStream(TESTATA_PATH + "jcr-import-test.xml");
- try {
- session.importXML(node.getPath(), xml, ImportUUIDBehavior.IMPORT_UUID_CREATE_NEW);
- } finally {
- xml.close();
- }
- // Save the changes to the repository
- session.save();
- System.out.println("done.");
- }
-
- JackrabbitTestUtil.dumpNode(root, System.out, true);
- } finally {
- if (session != null) session.logout();
- }
- }
-
-}
Deleted: trunk/dna-integration-tests/src/test/java/org/jboss/dna/test/integration/jackrabbit/JackrabbitDerbyStressTest.java
===================================================================
--- trunk/dna-integration-tests/src/test/java/org/jboss/dna/test/integration/jackrabbit/JackrabbitDerbyStressTest.java 2009-12-18 01:52:46 UTC (rev 1452)
+++ trunk/dna-integration-tests/src/test/java/org/jboss/dna/test/integration/jackrabbit/JackrabbitDerbyStressTest.java 2009-12-18 01:53:09 UTC (rev 1453)
@@ -1,250 +0,0 @@
-/*
- * JBoss DNA (http://www.jboss.org/dna)
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- * See the AUTHORS.txt file in the distribution for a full listing of
- * individual contributors.
- *
- * JBoss DNA is free software. Unless otherwise indicated, all code in JBoss DNA
- * is licensed to you under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * JBoss DNA is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.dna.test.integration.jackrabbit;
-
-import static org.junit.Assert.assertNotNull;
-import javax.jcr.Node;
-import javax.jcr.Repository;
-import javax.jcr.Session;
-import javax.jcr.SimpleCredentials;
-import org.apache.jackrabbit.core.TransientRepository;
-import org.jboss.dna.common.i18n.MockI18n;
-import org.jboss.dna.common.statistic.HistogramTest;
-import org.jboss.dna.common.statistic.Stopwatch;
-import org.jboss.dna.common.util.FileUtil;
-import org.jboss.dna.common.util.Logger;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Ignore;
-import org.junit.Test;
-
-/**
- * These tests are designed to stress Jackrabbit in a variety of ways. Each test are independent of each other, and therefore each
- * test sets up a brand-new repository.
- */
-public class JackrabbitDerbyStressTest {
-
- public static final String TESTATA_PATH = "./src/test/resources/";
- public static final String JACKRABBIT_DATA_PATH = "./target/testdata/jackrabbittest/";
- public static final String REPOSITORY_DIRECTORY_PATH = JACKRABBIT_DATA_PATH + "repository";
- public static final String REPOSITORY_CONFIG_PATH = TESTATA_PATH + "jackrabbitDerbyTestRepositoryConfig.xml";
- public static final String DERBY_SYSTEM_HOME = JACKRABBIT_DATA_PATH + "/derby";
- public static final String USERNAME = "jsmith";
- public static final char[] PASSWORD = "secret".toCharArray();
-
- private Logger logger;
- private Repository repository;
- private Session session;
- private Stopwatch stopwatch = new Stopwatch();
-
- @Before
- public void beforeEach() throws Exception {
- // Clean up the test data ...
- FileUtil.delete(JACKRABBIT_DATA_PATH);
-
- // Set up Derby and the logger ...
- System.setProperty("derby.system.home", DERBY_SYSTEM_HOME);
- logger = Logger.getLogger(JackrabbitDerbyStressTest.class);
-
- // Set up the transient repository ...
- logger.info(MockI18n.passthrough, "Creating test repository for stress test and logging in with user " + USERNAME);
- this.repository = new TransientRepository(REPOSITORY_CONFIG_PATH, REPOSITORY_DIRECTORY_PATH);
-
- SimpleCredentials creds = new SimpleCredentials(USERNAME, PASSWORD);
- session = this.repository.login(creds);
- assertNotNull(session);
- }
-
- @After
- public void afterEach() {
- try {
- if (session != null) session.logout();
- } finally {
- session = null;
- repository = null;
- logger = null;
- // No matter what, clean up the test data ...
- FileUtil.delete(JACKRABBIT_DATA_PATH);
- }
- }
-
- @Test
- public void shouldCreate100NodesWithNoChildrenAndNoProperties() throws Exception {
- Node rootNode = this.session.getRootNode();
- rootNode.addNode("node"); // don't measure the first one
- for (int i = 0; i != 100; ++i) {
- stopwatch.start();
- rootNode.addNode("node" + i);
- stopwatch.stop();
- }
- rootNode.save();
- HistogramTest.writeHistogramToLog(logger,
- stopwatch.getHistogram(3).setBucketCount(50),
- 80,
- "create 100 nodes with no children and no properties");
- this.logger.info(MockI18n.passthrough, stopwatch.toString());
- }
-
- // NOTE: Most of these tests are @Ignored because they are just used to baseline Jackrabbit
- // and are not needed to verify JBoss DNA in any way
-
- @Ignore
- @Test
- public void shouldCreate1000NodesWithNoChildrenAndNoProperties() throws Exception {
- Node rootNode = this.session.getRootNode();
- rootNode.addNode("node"); // don't measure the first one
- for (int i = 0; i != 1000; ++i) {
- stopwatch.start();
- rootNode.addNode("node" + i);
- stopwatch.stop();
- }
- rootNode.save();
- HistogramTest.writeHistogramToLog(logger,
- stopwatch.getHistogram(1).setBucketCount(50),
- 80,
- "create 1000 nodes with no children and no properties");
- this.logger.info(MockI18n.passthrough, stopwatch.toString());
- }
-
- @Ignore
- @Test
- public void shouldCreate5000NodesWithNoChildrenAndNoProperties() throws Exception {
- Node rootNode = this.session.getRootNode();
- rootNode.addNode("node"); // don't measure the first one
- for (int i = 0; i != 5000; ++i) {
- stopwatch.start();
- rootNode.addNode("node" + i);
- stopwatch.stop();
- }
- rootNode.save();
- HistogramTest.writeHistogramToLog(logger,
- stopwatch.getHistogram(1).setBucketCount(50),
- 80,
- "create 5000 nodes with no children and no properties");
- this.logger.info(MockI18n.passthrough, stopwatch.toString());
- }
-
- @Ignore
- @Test
- public void shouldCreate10000NodesWithNoChildrenAndNoProperties() throws Exception {
- Node rootNode = this.session.getRootNode();
- rootNode.addNode("node"); // don't measure the first one
- for (int i = 0; i != 10000; ++i) {
- stopwatch.start();
- rootNode.addNode("node" + i);
- stopwatch.stop();
- }
- rootNode.save();
- HistogramTest.writeHistogramToLog(logger,
- stopwatch.getHistogram(1).setBucketCount(50),
- 80,
- "create 10000 nodes with no children and no properties");
- this.logger.info(MockI18n.passthrough, stopwatch.toString());
- }
-
- @Test
- public void shouldCreate100NodesWithNoChildrenAndSeveralProperties() throws Exception {
- Node rootNode = this.session.getRootNode();
- rootNode.addNode("node"); // don't measure the first one
- for (int i = 0; i != 100; ++i) {
- stopwatch.start();
- Node child = rootNode.addNode("node" + i);
- child.setProperty("jcr:name", "This is the name of node " + i);
- child.setProperty("jcr:description", "This is the description of node " + i);
- stopwatch.stop();
- }
- rootNode.save();
- HistogramTest.writeHistogramToLog(logger,
- stopwatch.getHistogram(3).setBucketCount(50),
- 80,
- "create 100 nodes with no children and several properties");
- this.logger.info(MockI18n.passthrough, stopwatch.toString());
- }
-
- @Ignore
- @Test
- public void shouldCreate10000NodesWithNoChildrenAndSeveralProperties() throws Exception {
- Node rootNode = this.session.getRootNode();
- rootNode.addNode("node"); // don't measure the first one
- for (int i = 0; i != 10000; ++i) {
- stopwatch.start();
- Node child = rootNode.addNode("node" + i);
- child.setProperty("jcr:name", "This is the name of node " + i);
- child.setProperty("jcr:description", "This is the description of node " + i);
- stopwatch.stop();
- }
- rootNode.save();
- HistogramTest.writeHistogramToLog(logger,
- stopwatch.getHistogram(3).setBucketCount(50),
- 80,
- "create 10000 nodes with no children and several properties");
- this.logger.info(MockI18n.passthrough, stopwatch.toString());
- }
-
- @Ignore
- @Test
- public void shouldCreate50000NodesWithNoChildrenAndSeveralProperties() throws Exception {
- Node rootNode = this.session.getRootNode();
- rootNode.addNode("node"); // don't measure the first one
- for (int i = 0; i != 50000; ++i) {
- stopwatch.start();
- Node child = rootNode.addNode("node" + i);
- child.setProperty("jcr:name", "This is the name of node " + i);
- child.setProperty("jcr:description", "This is the description of node " + i);
- stopwatch.stop();
- }
- rootNode.save();
- HistogramTest.writeHistogramToLog(logger,
- stopwatch.getHistogram(3).setBucketCount(50),
- 80,
- "create 50000 nodes with no children and several properties");
- this.logger.info(MockI18n.passthrough, stopwatch.toString());
- }
-
- @Ignore
- @Test
- public void shouldCreate100000NodesWithNoChildrenAndSeveralProperties() throws Exception {
- Node rootNode = this.session.getRootNode();
- rootNode.addNode("node"); // don't measure the first one
- int index = 0;
- stopwatch.start();
- for (int j = 0; j != 100; ++j) {
- for (int i = 0; i != 1000; ++i) {
- ++index;
- // stopwatch.start();
- Node child = rootNode.addNode("node" + index);
- child.setProperty("jcr:name", "This is the name of node " + index);
- child.setProperty("jcr:description", "This is the description of node " + index);
- // stopwatch.stop();
- }
- rootNode.save();
- }
- stopwatch.stop();
- HistogramTest.writeHistogramToLog(logger,
- stopwatch.getHistogram(3).setBucketCount(50),
- 80,
- "create 100000 nodes (in 100 batches) with no children and several properties");
- this.logger.info(MockI18n.passthrough, stopwatch.toString());
- }
-}
Deleted: trunk/dna-integration-tests/src/test/java/org/jboss/dna/test/integration/jackrabbit/JackrabbitInMemoryTest.java
===================================================================
--- trunk/dna-integration-tests/src/test/java/org/jboss/dna/test/integration/jackrabbit/JackrabbitInMemoryTest.java 2009-12-18 01:52:46 UTC (rev 1452)
+++ trunk/dna-integration-tests/src/test/java/org/jboss/dna/test/integration/jackrabbit/JackrabbitInMemoryTest.java 2009-12-18 01:53:09 UTC (rev 1453)
@@ -1,186 +0,0 @@
-/*
- * JBoss DNA (http://www.jboss.org/dna)
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- * See the AUTHORS.txt file in the distribution for a full listing of
- * individual contributors.
- *
- * JBoss DNA is free software. Unless otherwise indicated, all code in JBoss DNA
- * is licensed to you under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * JBoss DNA is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.dna.test.integration.jackrabbit;
-
-import static org.hamcrest.core.Is.is;
-import static org.hamcrest.core.IsNull.notNullValue;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertThat;
-import javax.jcr.Node;
-import javax.jcr.Repository;
-import javax.jcr.Session;
-import javax.jcr.SimpleCredentials;
-import org.apache.jackrabbit.core.TransientRepository;
-import org.jboss.dna.common.i18n.MockI18n;
-import org.jboss.dna.common.statistic.HistogramTest;
-import org.jboss.dna.common.statistic.Stopwatch;
-import org.jboss.dna.common.util.FileUtil;
-import org.jboss.dna.common.util.Logger;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-
-/**
- * These tests are designed to stress Jackrabbit in a variety of ways, using the in-memory persistence manager. Each test are
- * independent of each other, and therefore each test sets up a brand-new repository.
- */
-public class JackrabbitInMemoryTest {
-
- public static final String TESTATA_PATH = "./src/test/resources/";
- public static final String JACKRABBIT_DATA_PATH = "./target/testdata/jackrabbittest/";
- public static final String REPOSITORY_DIRECTORY_PATH = JACKRABBIT_DATA_PATH + "repository";
- public static final String REPOSITORY_CONFIG_PATH = TESTATA_PATH + "jackrabbitInMemoryTestRepositoryConfig.xml";
- public static final String USERNAME = "jsmith";
- public static final char[] PASSWORD = "secret".toCharArray();
-
- private Logger logger;
- private Repository repository;
- private Session session;
- private Stopwatch nodeStopwatch = new Stopwatch();
- private Stopwatch saveStopwatch = new Stopwatch();
-
- @Before
- public void beforeEach() throws Exception {
- // Clean up the test data ...
- FileUtil.delete(JACKRABBIT_DATA_PATH);
-
- // Set up the logger ...
- logger = Logger.getLogger(JackrabbitInMemoryTest.class);
-
- // Set up the transient repository ...
- logger.info(MockI18n.passthrough, "Creating test repository for stress test and logging in with user " + USERNAME);
- this.repository = new TransientRepository(REPOSITORY_CONFIG_PATH, REPOSITORY_DIRECTORY_PATH);
-
- SimpleCredentials creds = new SimpleCredentials(USERNAME, PASSWORD);
- session = this.repository.login(creds);
- assertNotNull(session);
- }
-
- @After
- public void afterEach() {
- try {
- if (session != null) session.logout();
- } finally {
- session = null;
- // No matter what, clean up the test data ...
- FileUtil.delete(JACKRABBIT_DATA_PATH);
- }
- }
-
- /**
- * Create an evenly distributed tree of nodes, starting with the supplied parent.
- *
- * @param parentNode the parent node of the tree; may not be null
- * @param numberOfChildNodes the number of child nodes to create under the parent
- * @param levelsToCreate the total number of levels in the tree to create
- * @return the total number of child nodes created
- * @throws Exception
- */
- public int createNodes( Node parentNode,
- int numberOfChildNodes,
- int levelsToCreate ) throws Exception {
- int numberCreated = 0;
- for (int i = 0; i < numberOfChildNodes; ++i) {
- nodeStopwatch.start();
- Node child = parentNode.addNode("node" + i);
- child.setProperty("jcr:name", "This is the name of node " + i);
- child.setProperty("jcr:description", "This is the description of node " + i);
- nodeStopwatch.stop();
- // this.logger.debug(" - " + child.getPath());
- ++numberCreated;
- if (levelsToCreate > 1) {
- numberCreated += createNodes(child, numberOfChildNodes, levelsToCreate - 1);
- }
- }
- return numberCreated;
- }
-
- @Test
- public void shouldCreate10NodesWithNoChildrenAndNoProperties() throws Exception {
- Node rootNode = this.session.getRootNode();
- rootNode.addNode("node"); // don't measure the first one
- for (int i = 0; i != 10; ++i) {
- nodeStopwatch.start();
- rootNode.addNode("node" + i);
- nodeStopwatch.stop();
- }
- rootNode.save();
- HistogramTest.writeHistogramToLog(logger,
- nodeStopwatch.getHistogram(3).setBucketCount(50),
- 80,
- "create 100 nodes with no children and no properties");
- this.logger.info(MockI18n.passthrough, nodeStopwatch.toString());
- }
-
- @Test
- public void shouldCreateTreeOfNodes2LevelsDeepWith10ChildrenAtEachNode() throws Exception {
- Node rootNode = this.session.getRootNode();
- Node parent = rootNode.addNode("node"); // don't measure the first one
- int numNodes = this.createNodes(parent, 10, 2);
- saveStopwatch.start();
- rootNode.save();
- saveStopwatch.stop();
-
- HistogramTest.writeHistogramToLog(logger,
- nodeStopwatch.getHistogram(3).setBucketCount(50),
- 80,
- "create tree of " + numNodes + " nodes (2 deep, 10 children at every node)");
- HistogramTest.writeHistogramToLog(logger, saveStopwatch.getHistogram(3).setBucketCount(50), 80, "1 save of 2x10 tree of "
- + numNodes + " nodes");
- this.logger.info(MockI18n.passthrough, "Node operation times: " + nodeStopwatch.toString());
- this.logger.info(MockI18n.passthrough, "Save times: " + saveStopwatch.toString());
- }
-
- @Test
- public void shouldExportSystemBranchToSystemView() throws Exception {
- this.session.exportSystemView("/jcr:system", System.out, true, false);
- }
-
- @Test
- public void shouldExportSystemBranchToDocumentView() throws Exception {
- this.session.exportDocumentView("/jcr:system", System.out, true, false);
- }
-
- @Test
- public void shouldNotHaveNamePropertyForNodes() throws Exception {
- Node node = session.getRootNode().addNode("test");
- assertThat(node, notNullValue());
- assertThat(node.hasProperty("jcr:name"), is(false));
- }
-
- @Test
- public void shouldNotHaveUuidPropertyForNonReferenceableNodes() throws Exception {
- Node node = session.getRootNode().addNode("test");
- assertThat(node, notNullValue());
- assertThat(node.hasProperty("jcr:uuid"), is(false));
- }
-
- @Test
- public void shouldHaveUuidPropertyForReferenceableNodes() throws Exception {
- Node node = session.getRootNode().addNode("test");
- node.addMixin("mix:referenceable");
- assertThat(node, notNullValue());
- assertThat(node.hasProperty("jcr:uuid"), is(true));
- }
-}
Deleted: trunk/dna-integration-tests/src/test/java/org/jboss/dna/test/integration/jackrabbit/JackrabbitTestUtil.java
===================================================================
--- trunk/dna-integration-tests/src/test/java/org/jboss/dna/test/integration/jackrabbit/JackrabbitTestUtil.java 2009-12-18 01:52:46 UTC (rev 1452)
+++ trunk/dna-integration-tests/src/test/java/org/jboss/dna/test/integration/jackrabbit/JackrabbitTestUtil.java 2009-12-18 01:53:09 UTC (rev 1453)
@@ -1,76 +0,0 @@
-/*
- * JBoss DNA (http://www.jboss.org/dna)
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- * See the AUTHORS.txt file in the distribution for a full listing of
- * individual contributors.
- *
- * JBoss DNA is free software. Unless otherwise indicated, all code in JBoss DNA
- * is licensed to you under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * JBoss DNA is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.dna.test.integration.jackrabbit;
-
-import java.io.PrintStream;
-import javax.jcr.Node;
-import javax.jcr.NodeIterator;
-import javax.jcr.Property;
-import javax.jcr.PropertyIterator;
-import javax.jcr.RepositoryException;
-import javax.jcr.Value;
-
-public class JackrabbitTestUtil {
-
- /**
- * Recursively outputs the contents of the given node.
- * @param node
- * @param stream
- * @param recursive
- * @throws RepositoryException
- */
- public static void dumpNode( Node node, PrintStream stream, boolean recursive ) throws RepositoryException {
- // First output the node path
- System.out.println(node.getPath());
- // Skip the virtual (and large!) jcr:system subtree
- if (node.getName().equals("jcr:system")) {
- return;
- }
-
- // Then output the properties
- PropertyIterator properties = node.getProperties();
- while (properties.hasNext()) {
- Property property = properties.nextProperty();
- if (property.getDefinition().isMultiple()) {
- // A multi-valued property, print all values
- Value[] values = property.getValues();
- for (int i = 0; i < values.length; i++) {
- stream.println(property.getPath() + " = " + values[i].getString());
- }
- } else {
- // A single-valued property
- stream.println(property.getPath() + " = " + property.getString());
- }
- }
-
- if (recursive) {
- // Finally output all the child nodes recursively
- NodeIterator nodes = node.getNodes();
- while (nodes.hasNext()) {
- dumpNode(nodes.nextNode(), stream, true);
- }
- }
- }
-
-}
14 years, 6 months
DNA SVN: r1452 - in trunk: dna-graph/src/main/java/org/jboss/dna/graph/observe and 8 other directories.
by dna-commits@lists.jboss.org
Author: rhauch
Date: 2009-12-17 20:52:46 -0500 (Thu, 17 Dec 2009)
New Revision: 1452
Added:
trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/RepositoryQueryManager.java
Modified:
trunk/dna-graph/src/main/java/org/jboss/dna/graph/GraphI18n.java
trunk/dna-graph/src/main/java/org/jboss/dna/graph/observe/ObservationBus.java
trunk/dna-graph/src/main/java/org/jboss/dna/graph/query/process/QueryProcessor.java
trunk/dna-graph/src/main/java/org/jboss/dna/graph/request/CompositeRequestChannel.java
trunk/dna-graph/src/main/resources/org/jboss/dna/graph/GraphI18n.properties
trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/JcrEngine.java
trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/JcrI18n.java
trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/JcrQueryManager.java
trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/JcrRepository.java
trunk/dna-jcr/src/main/resources/org/jboss/dna/jcr/JcrI18n.properties
trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/AbstractJcrAccessTest.java
trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/ImportExportTest.java
trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/JcrConfigurationTest.java
trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/JcrRepositoryTest.java
trunk/dna-repository/src/main/java/org/jboss/dna/repository/RepositoryLibrary.java
trunk/extensions/dna-search-lucene/src/main/java/org/jboss/dna/search/lucene/LuceneSearchEngine.java
Log:
DNA-468 Integrated the search engine into the JcrRepository class. By default, the JcrRepository instances do support executing queries and searches (and thus maintain indexes if the source does not support queries and searches), and the Session.save() calls do not wait for the indexes to be updated with the changes. Also, at this point, all of the previously-passing unit and TCK tests are passing.
Modified: trunk/dna-graph/src/main/java/org/jboss/dna/graph/GraphI18n.java
===================================================================
--- trunk/dna-graph/src/main/java/org/jboss/dna/graph/GraphI18n.java 2009-12-17 20:38:21 UTC (rev 1451)
+++ trunk/dna-graph/src/main/java/org/jboss/dna/graph/GraphI18n.java 2009-12-18 01:52:46 UTC (rev 1452)
@@ -93,6 +93,8 @@
public static I18n nodeAlreadyExistsWithUuid;
public static I18n couldNotAcquireLock;
+ public static I18n errorNotifyingObserver;
+
/* In-Memory Connector */
public static I18n inMemoryNodeDoesNotExist;
public static I18n errorSerializingInMemoryCachePolicyInSource;
Modified: trunk/dna-graph/src/main/java/org/jboss/dna/graph/observe/ObservationBus.java
===================================================================
--- trunk/dna-graph/src/main/java/org/jboss/dna/graph/observe/ObservationBus.java 2009-12-17 20:38:21 UTC (rev 1451)
+++ trunk/dna-graph/src/main/java/org/jboss/dna/graph/observe/ObservationBus.java 2009-12-18 01:52:46 UTC (rev 1452)
@@ -24,6 +24,8 @@
package org.jboss.dna.graph.observe;
import net.jcip.annotations.ThreadSafe;
+import org.jboss.dna.common.util.Logger;
+import org.jboss.dna.graph.GraphI18n;
/**
* A simple {@link Observer} that is itself {@link Observable}. This class essentially multiplexes the events from a single
@@ -32,6 +34,7 @@
@ThreadSafe
public class ObservationBus implements Observable, Observer {
private final ChangeObservers observers = new ChangeObservers();
+ private final Logger logger = Logger.getLogger(getClass());
public ObservationBus() {
}
@@ -63,7 +66,11 @@
public void notify( Changes changes ) {
if (changes != null) {
// Broadcast the changes to the registered observers ...
- observers.broadcast(changes);
+ try {
+ observers.broadcast(changes);
+ } catch (RuntimeException t) {
+ logger.error(t, GraphI18n.errorNotifyingObserver, t.getLocalizedMessage());
+ }
}
}
Modified: trunk/dna-graph/src/main/java/org/jboss/dna/graph/query/process/QueryProcessor.java
===================================================================
--- trunk/dna-graph/src/main/java/org/jboss/dna/graph/query/process/QueryProcessor.java 2009-12-17 20:38:21 UTC (rev 1451)
+++ trunk/dna-graph/src/main/java/org/jboss/dna/graph/query/process/QueryProcessor.java 2009-12-18 01:52:46 UTC (rev 1452)
@@ -88,8 +88,12 @@
if (component != null) {
// Now execute the component ...
- preExecute(context);
- tuples = component.execute();
+ try {
+ preExecute(context);
+ tuples = component.execute();
+ } finally {
+ postExecute(context);
+ }
} else {
// There must have been an error ...
assert context.getProblems().hasErrors();
@@ -114,6 +118,16 @@
}
/**
+ * A method that can be overridden when a hook is required immediately after the top-level {@link ProcessingComponent} is
+ * executed and all processing has been completed, even if there was an error. By default, this method does nothing.
+ *
+ * @param context the context in which the query is being executed; may not be null
+ */
+ protected void postExecute( QueryContext context ) {
+ // do nothing ...
+ }
+
+ /**
* Create an {@link Analyzer} implementation that should be used by the non-access {@link ProcessingComponent}s that evaluate
* criteria. By default, this method returns null, which means that any criteria evaluation will likely be pushed down under
* an {@link Type#ACCESS ACCESS} node (and thus handled by an
Modified: trunk/dna-graph/src/main/java/org/jboss/dna/graph/request/CompositeRequestChannel.java
===================================================================
--- trunk/dna-graph/src/main/java/org/jboss/dna/graph/request/CompositeRequestChannel.java 2009-12-17 20:38:21 UTC (rev 1451)
+++ trunk/dna-graph/src/main/java/org/jboss/dna/graph/request/CompositeRequestChannel.java 2009-12-18 01:52:46 UTC (rev 1452)
@@ -287,8 +287,9 @@
* Mark this source as having no more requests to process.
*/
public void close() {
- this.closed.set(true);
- this.queue.add(new LastRequest());
+ if (this.closed.compareAndSet(false, true)) {
+ this.queue.add(new LastRequest());
+ }
}
/**
Modified: trunk/dna-graph/src/main/resources/org/jboss/dna/graph/GraphI18n.properties
===================================================================
--- trunk/dna-graph/src/main/resources/org/jboss/dna/graph/GraphI18n.properties 2009-12-17 20:38:21 UTC (rev 1451)
+++ trunk/dna-graph/src/main/resources/org/jboss/dna/graph/GraphI18n.properties 2009-12-18 01:52:46 UTC (rev 1452)
@@ -81,6 +81,8 @@
nodeAlreadyExistsWithUuid = A node with UUID "{0}" already exists at path "{1}" in workspace "{2}"
couldNotAcquireLock = Could not acquire lock on the node at "{0}" in workspace "{1}"
+errorNotifyingObserver = Error notifying observer: {0}
+
# In-memory connector
inMemoryNodeDoesNotExist = Could not find an existing node at {0}
errorSerializingInMemoryCachePolicyInSource = Error serializing a {0} instance owned by the {1} in-memory repository
Modified: trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/JcrEngine.java
===================================================================
--- trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/JcrEngine.java 2009-12-17 20:38:21 UTC (rev 1451)
+++ trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/JcrEngine.java 2009-12-18 01:52:46 UTC (rev 1452)
@@ -47,6 +47,7 @@
import org.jboss.dna.graph.Subgraph;
import org.jboss.dna.graph.connector.RepositoryConnectionFactory;
import org.jboss.dna.graph.connector.RepositorySource;
+import org.jboss.dna.graph.connector.RepositorySourceCapabilities;
import org.jboss.dna.graph.property.Name;
import org.jboss.dna.graph.property.Path;
import org.jboss.dna.graph.property.PathFactory;
@@ -148,7 +149,10 @@
}
};
- scheduler.scheduleAtFixedRate(cleanUpTask, 0, LOCK_SWEEP_INTERVAL_IN_MILLIS, TimeUnit.MILLISECONDS);
+ scheduler.scheduleAtFixedRate(cleanUpTask,
+ LOCK_SWEEP_INTERVAL_IN_MILLIS,
+ LOCK_SWEEP_INTERVAL_IN_MILLIS,
+ TimeUnit.MILLISECONDS);
}
/**
@@ -246,9 +250,13 @@
}
String sourceName = context.getValueFactories().getStringFactory().create(property.getFirstValue());
+ // Find the capabilities ...
+ RepositorySource source = getRepositorySource(sourceName);
+ RepositorySourceCapabilities capabilities = source != null ? source.getCapabilities() : null;
// Create the repository ...
JcrRepository repository = new JcrRepository(context, connectionFactory, sourceName,
- getRepositoryService().getRepositoryLibrary(), descriptors, options);
+ getRepositoryService().getRepositoryLibrary(), capabilities, descriptors,
+ options);
// Register all the the node types ...
Node nodeTypesNode = subgraph.getNode(JcrLexicon.NODE_TYPES);
Modified: trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/JcrI18n.java
===================================================================
--- trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/JcrI18n.java 2009-12-17 20:38:21 UTC (rev 1451)
+++ trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/JcrI18n.java 2009-12-18 01:52:46 UTC (rev 1452)
@@ -120,6 +120,7 @@
public static I18n searchIndexDirectoryOptionSpecifiesDirectoryThatCannotBeRead;
public static I18n searchIndexDirectoryOptionSpecifiesDirectoryThatCannotBeWrittenTo;
public static I18n searchIndexDirectoryOptionSpecifiesDirectoryThatCannotBeCreated;
+ public static I18n errorUpdatingQueryIndexes;
// Used in AbstractJcrNode#getAncestor
public static I18n noNegativeDepth;
@@ -140,6 +141,7 @@
public static I18n invalidQueryLanguage;
public static I18n queryCannotBeParsedUsingLanguage;
public static I18n queryInLanguageIsNotValid;
+ public static I18n queryIsDisabledInRepository;
// Type registration messages
public static I18n invalidNodeTypeName;
Modified: trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/JcrQueryManager.java
===================================================================
--- trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/JcrQueryManager.java 2009-12-17 20:38:21 UTC (rev 1451)
+++ trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/JcrQueryManager.java 2009-12-18 01:52:46 UTC (rev 1452)
@@ -26,6 +26,7 @@
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
+import java.util.Map;
import java.util.Set;
import javax.jcr.ItemNotFoundException;
import javax.jcr.Node;
@@ -52,6 +53,7 @@
import org.jboss.dna.graph.query.model.QueryCommand;
import org.jboss.dna.graph.query.model.TypeSystem;
import org.jboss.dna.graph.query.parse.QueryParser;
+import org.jboss.dna.graph.query.plan.PlanHints;
import org.jboss.dna.graph.query.validate.Schemata;
/**
@@ -148,7 +150,9 @@
* @see javax.jcr.query.QueryManager#getSupportedQueryLanguages()
*/
public String[] getSupportedQueryLanguages() {
- return new String[] {Query.XPATH};
+ // Make a defensive copy ...
+ Set<String> languages = session.repository().queryParsers().getLanguages();
+ return languages.toArray(new String[languages.size()]);
}
@NotThreadSafe
@@ -251,6 +255,8 @@
@NotThreadSafe
protected static class JcrQuery extends AbstractQuery {
private final QueryCommand query;
+ private final PlanHints hints;
+ private final Map<String, Object> variables;
/**
* Creates a new JCR {@link Query} by specifying the query statement itself, the language in which the query is stated,
@@ -272,6 +278,8 @@
super(session, statement, language, storedAtPath);
assert query != null;
this.query = query;
+ this.hints = null;
+ this.variables = null;
}
/**
@@ -279,13 +287,14 @@
*
* @see javax.jcr.query.Query#execute()
*/
- public QueryResult execute() {
+ public QueryResult execute() throws RepositoryException {
// Submit immediately to the workspace graph ...
Schemata schemata = session.workspace().nodeTypeManager().schemata();
- QueryResults result = session.workspace().graph().query(query, schemata)
- // .using(variables)
- // .using(hints)
- .execute();
+ QueryResults result = session.repository().queryManager().query(session.workspace(),
+ query,
+ schemata,
+ hints,
+ variables);
return new JcrQueryResult(session, result);
}
@@ -317,9 +326,12 @@
*
* @see javax.jcr.query.Query#execute()
*/
- public QueryResult execute() {
+ public QueryResult execute() throws RepositoryException {
// Submit immediately to the workspace graph ...
- QueryResults result = session.workspace().graph().search(statement, MAXIMUM_RESULTS_FOR_FULL_TEXT_SEARCH_QUERIES, 0);
+ QueryResults result = session.repository().queryManager().search(session.workspace(),
+ statement,
+ MAXIMUM_RESULTS_FOR_FULL_TEXT_SEARCH_QUERIES,
+ 0);
return new JcrQueryResult(session, result);
}
}
Modified: trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/JcrRepository.java
===================================================================
--- trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/JcrRepository.java 2009-12-17 20:38:21 UTC (rev 1451)
+++ trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/JcrRepository.java 2009-12-18 01:52:46 UTC (rev 1452)
@@ -23,7 +23,6 @@
*/
package org.jboss.dna.jcr;
-import java.io.File;
import java.io.IOException;
import java.lang.reflect.Method;
import java.security.AccessControlContext;
@@ -51,17 +50,15 @@
import javax.jcr.RepositoryException;
import javax.jcr.Session;
import javax.jcr.SimpleCredentials;
+import javax.jcr.query.Query;
import javax.security.auth.Subject;
import javax.security.auth.login.Configuration;
import javax.security.auth.login.LoginContext;
import net.jcip.annotations.GuardedBy;
import net.jcip.annotations.Immutable;
import net.jcip.annotations.ThreadSafe;
-import org.apache.lucene.analysis.Analyzer;
import org.jboss.dna.common.i18n.I18n;
import org.jboss.dna.common.text.Inflector;
-import org.jboss.dna.common.text.TextEncoder;
-import org.jboss.dna.common.text.UrlEncoder;
import org.jboss.dna.common.util.CheckArg;
import org.jboss.dna.common.util.Logger;
import org.jboss.dna.graph.ExecutionContext;
@@ -98,12 +95,7 @@
import org.jboss.dna.graph.query.parse.QueryParsers;
import org.jboss.dna.graph.query.parse.SqlQueryParser;
import org.jboss.dna.graph.request.InvalidWorkspaceException;
-import org.jboss.dna.graph.search.SearchableRepositorySource;
import org.jboss.dna.jcr.xpath.XPathQueryParser;
-import org.jboss.dna.search.lucene.IndexRules;
-import org.jboss.dna.search.lucene.LuceneConfiguration;
-import org.jboss.dna.search.lucene.LuceneConfigurations;
-import org.jboss.dna.search.lucene.LuceneSearchEngine;
/**
* Creates JCR {@link Session sessions} to an underlying repository (which may be a federated repository).
@@ -136,7 +128,8 @@
* the workspaces. In production, this needs to be "true" for proper JCR functionality, but in some debugging cases it can be
* set to false to simplify the architecture by removing the federated connector layer.
* <p>
- * This should be changed to 'false' only in advanced situations, and never for production.
+ * This should be changed to 'false' only in advanced situations, and never for production. Note that this also disables query
+ * execution.
* </p>
*/
static final boolean WORKSPACES_SHARE_SYSTEM_BRANCH = true;
@@ -203,15 +196,15 @@
TABLES_INCLUDE_COLUMNS_FOR_INHERITED_PROPERTIES,
/**
- * A boolean flag that specifies whether this repository is expected to provide search and query functionality. If client
- * applications will never perform searches or queries, then maintaining the indexes for these features is an unncessary
- * overhead, and can be disabled. Note that this is merely a hint, and that searches and queries might still work when
- * this is set to 'false'.
+ * A boolean flag that specifies whether this repository is expected to execute searches and queries. If client
+ * applications will never perform searches or queries, then maintaining the query indexes is an unncessary overhead, and
+ * can be disabled. Note that this is merely a hint, and that searches and queries might still work when this is set to
+ * 'false'.
* <p>
- * The default is 'true', meaning that the repository <i>is expected</i> to be searched and queried.
+ * The default is 'true', meaning that clients can execute searches and queries.
* </p>
*/
- SEARCHABLE,
+ QUERY_EXECUTION_ENABLED,
/**
* The system may maintain a set of indexes that improve the performance of searching and querying the content. These size
@@ -221,20 +214,21 @@
* <p>
* If specified, the value must be a valid path to a writable directory on the file system. If the path specifies a
* non-existant location, the repository may attempt to create the missing directories. The path may be absolute or
- * relative to the location where this VM was started.
+ * relative to the location where this VM was started. If the specified location is not a readable and writable directory
+ * (or cannot be created as such), then this will generate an exception when the repository is created.
* </p>
* <p>
* The default value is null, meaning the search indexes may not be stored on the local file system and, if needed, will
* be stored within memory.
* </p>
*/
- SEARCH_INDEX_DIRECTORY,
+ QUERY_INDEX_DIRECTORY,
/**
* A boolean flag that specifies whether updates to the indexes (if used) should be made synchronously, meaning that a
- * call to {@link Session#save()} will not return until the search indexes have been updated. The benefit of synchronous
- * updates is that a search or query performed immediately after a <code>save()</code> will operate upon content that was
- * just changed.
+ * call to {@link Session#save()} will not return until the search indexes have been completely updated. The benefit of
+ * synchronous updates is that a search or query performed immediately after a <code>save()</code> will operate upon
+ * content that was just changed. The downside is that the <code>save()</code> operation will take longer.
* <p>
* With asynchronous updates, however, the only work done during a <code>save()</code> invocation is that required to
* persist the changes in the underlying repository source, while changes to the search indexes are made in a different
@@ -245,7 +239,7 @@
* The default is value 'false', meaning the updates are performed <i>asynchronously</i>.
* </p>
*/
- UPDATE_INDEXES_SYNCHRONOUSLY;
+ QUERY_INDEXES_UPDATED_SYNCHRONOUSLY;
/**
* Determine the option given the option name. This does more than {@link Option#valueOf(String)}, since this method first
@@ -306,19 +300,19 @@
public static final String TABLES_INCLUDE_COLUMNS_FOR_INHERITED_PROPERTIES = Boolean.TRUE.toString();
/**
- * The default value for the {@link Option#SEARCHABLE} option is {@value} .
+ * The default value for the {@link Option#QUERY_EXECUTION_ENABLED} option is {@value} .
*/
- public static final String SEARCHABLE = Boolean.TRUE.toString();
+ public static final String QUERY_EXECUTION_ENABLED = Boolean.TRUE.toString();
/**
- * The default value for the {@link Option#UPDATE_INDEXES_SYNCHRONOUSLY} option is {@value} .
+ * The default value for the {@link Option#QUERY_INDEXES_UPDATED_SYNCHRONOUSLY} option is {@value} .
*/
- public static final String UPDATE_INDEXES_SYNCHRONOUSLY = Boolean.FALSE.toString();
+ public static final String QUERY_INDEXES_UPDATED_SYNCHRONOUSLY = Boolean.FALSE.toString();
/**
- * The default value for the {@link Option#SEARCH_INDEX_DIRECTORY} option is {@value} .
+ * The default value for the {@link Option#QUERY_INDEX_DIRECTORY} option is {@value} .
*/
- public static final String SEARCH_INDEX_DIRECTORY = null;
+ public static final String QUERY_INDEX_DIRECTORY = null;
}
@@ -336,9 +330,9 @@
defaults.put(Option.ANONYMOUS_USER_ROLES, DefaultOption.ANONYMOUS_USER_ROLES);
defaults.put(Option.TABLES_INCLUDE_COLUMNS_FOR_INHERITED_PROPERTIES,
DefaultOption.TABLES_INCLUDE_COLUMNS_FOR_INHERITED_PROPERTIES);
- defaults.put(Option.SEARCHABLE, DefaultOption.SEARCHABLE);
- defaults.put(Option.UPDATE_INDEXES_SYNCHRONOUSLY, DefaultOption.UPDATE_INDEXES_SYNCHRONOUSLY);
- defaults.put(Option.SEARCH_INDEX_DIRECTORY, DefaultOption.SEARCH_INDEX_DIRECTORY);
+ defaults.put(Option.QUERY_EXECUTION_ENABLED, DefaultOption.QUERY_EXECUTION_ENABLED);
+ defaults.put(Option.QUERY_INDEXES_UPDATED_SYNCHRONOUSLY, DefaultOption.QUERY_INDEXES_UPDATED_SYNCHRONOUSLY);
+ defaults.put(Option.QUERY_INDEX_DIRECTORY, DefaultOption.QUERY_INDEX_DIRECTORY);
DEFAULT_OPTIONS = Collections.<Option, String>unmodifiableMap(defaults);
}
@@ -358,8 +352,9 @@
private final NamespaceRegistry persistentRegistry;
private final RepositoryObservationManager repositoryObservationManager;
private final SecurityContext anonymousUserContext;
- private final QueryParsers queryParsers = new QueryParsers(new SqlQueryParser(), new XPathQueryParser(),
- new FullTextSearchParser());
+ private final QueryParsers queryParsers;
+ // Until the federated connector supports queries, we have to use a search engine ...
+ private final RepositoryQueryManager queryManager;
// package-scoped to facilitate testing
final WeakHashMap<JcrSession, Object> activeSessions = new WeakHashMap<JcrSession, Object>();
@@ -372,8 +367,11 @@
* @param connectionFactory the factory for repository connections
* @param repositorySourceName the name of the repository source (in the connection factory) that should be used
* @param repositoryObservable the repository library observable associated with this repository (never <code>null</code>)
+ * @param repositorySourceCapabilities the capabilities of the repository source; may be null if the capabilities are not
+ * known
* @param descriptors the {@link #getDescriptorKeys() descriptors} for this repository; may be <code>null</code>.
* @param options the optional {@link Option settings} for this repository; may be null
+ * @throws RepositoryException if there is a problem setting up this repository
* @throws IllegalArgumentException If <code>executionContext</code>, <code>connectionFactory</code>,
* <code>repositorySourceName</code>, or <code>repositoryObservable</code> is <code>null</code>.
*/
@@ -381,8 +379,9 @@
RepositoryConnectionFactory connectionFactory,
String repositorySourceName,
Observable repositoryObservable,
+ RepositorySourceCapabilities repositorySourceCapabilities,
Map<String, String> descriptors,
- Map<Option, String> options ) {
+ Map<Option, String> options ) throws RepositoryException {
CheckArg.isNotNull(executionContext, "executionContext");
CheckArg.isNotNull(connectionFactory, "connectionFactory");
CheckArg.isNotNull(repositorySourceName, "repositorySourceName");
@@ -482,19 +481,24 @@
InMemoryRepositorySource transientSystemSource = new InMemoryRepositorySource();
transientSystemSource.setName(systemSourceName);
transientSystemSource.setDefaultWorkspaceName(systemWorkspaceName);
- connectionFactoryWithSystem = new ConnectionFactoryWithSystem(connectionFactory, transientSystemSource);
+ connectionFactoryWithSystem = new DelegatingConnectionFactory(connectionFactory, transientSystemSource);
}
+
+ // Set up the query parsers, which we have to have even though queries might be disabled ...
+ this.queryParsers = new QueryParsers(new SqlQueryParser(), new XPathQueryParser(), new FullTextSearchParser());
+ assert this.queryParsers.getParserFor(Query.XPATH) != null;
+
this.systemWorkspaceName = systemWorkspaceName;
this.systemSourceName = systemSourceName;
this.connectionFactory = connectionFactoryWithSystem;
assert this.systemSourceName != null;
assert this.connectionFactory != null;
+ this.sourceName = repositorySourceName;
// Set up the "/jcr:system" branch ...
Graph systemGraph = Graph.create(this.systemSourceName, this.connectionFactory, executionContext);
systemGraph.useWorkspace(systemWorkspaceName);
initializeSystemContent(systemGraph);
- this.sourceName = repositorySourceName;
// Create the namespace registry and corresponding execution context.
// Note that this persistent registry has direct access to the system workspace.
@@ -553,6 +557,37 @@
this.lockManagers = new ConcurrentHashMap<String, WorkspaceLockManager>();
this.locksPath = pathFactory.create(pathFactory.createRootPath(), JcrLexicon.SYSTEM, DnaLexicon.LOCKS);
+ // If the repository is to support searching ...
+ if (Boolean.valueOf(this.options.get(Option.QUERY_EXECUTION_ENABLED)) && WORKSPACES_SHARE_SYSTEM_BRANCH) {
+ // Determine whether the federated source and original source support queries and searches ...
+ RepositorySourceCapabilities fedCapabilities = federatedSource != null ? federatedSource.getCapabilities() : null;
+ final boolean canQuerySource = repositorySourceCapabilities != null
+ && repositorySourceCapabilities.supportsSearches()
+ && repositorySourceCapabilities.supportsQueries();
+ final boolean canQueryFederated = fedCapabilities != null && fedCapabilities.supportsSearches()
+ && fedCapabilities.supportsQueries();
+
+ // We can query the federated source if it supports queries and searches
+ // AND the original source supports queries and searches ...
+ if (canQuerySource && canQueryFederated) {
+ this.queryManager = new RepositoryQueryManager();
+ } else {
+ // Otherwise create a repository query manager that maintains its own search engine ...
+ String indexDirectory = this.options.get(Option.QUERY_INDEX_DIRECTORY);
+ boolean updateIndexesSynchronously = Boolean.valueOf(this.options.get(Option.QUERY_INDEXES_UPDATED_SYNCHRONOUSLY));
+ // At this point in time, we cannot query the federated connector ...
+ String sourceToQuery = this.sourceName;
+ // But we need to observe the federated source (if there is one) ...
+ final String sourceToObserve = federatedSource != null ? federatedSource.getName() : this.sourceName;
+ // We actually want to use the federated source to crawl and watch for changes ...
+ this.queryManager = new RepositoryQueryManager.SelfContained(executionContext, sourceToQuery, sourceToObserve,
+ connectionFactoryWithSystem, repositoryObservable,
+ indexDirectory, updateIndexesSynchronously);
+ }
+ } else {
+ this.queryManager = new RepositoryQueryManager.Disabled();
+ }
+
/*
* Set up the anonymous role, if appropriate
*/
@@ -582,79 +617,6 @@
this.anonymousUserContext = anonymousUserContext;
}
- protected RepositorySource makeSearchable( final RepositorySource source ) throws RepositoryException {
- if (Boolean.valueOf(this.options.get(Option.SEARCHABLE))) {
- // We need to make sure we can search/query the source. See whether the source natively supports it ...
- // Check whether the repository source supports search and query ...
- RepositorySourceCapabilities capabilities = source.getCapabilities();
- if (!capabilities.supportsSearches() || !capabilities.supportsQueries()) {
- // Where should the indexes be stored ...
- String indexDirectory = this.options.get(Option.SEARCH_INDEX_DIRECTORY);
-
- // Define the configuration ...
- TextEncoder encoder = new UrlEncoder();
- LuceneConfiguration configuration = null;
- if (indexDirectory != null) {
- File indexDir = new File(indexDirectory);
- if (indexDir.exists()) {
- // The location does exist ...
- if (!indexDir.isDirectory()) {
- // The path is not a directory ...
- I18n msg = JcrI18n.searchIndexDirectoryOptionSpecifiesFileNotDirectory;
- throw new RepositoryException(msg.text(indexDirectory, sourceName));
- }
- if (!indexDir.canWrite()) {
- // But we cannot write to it ...
- I18n msg = JcrI18n.searchIndexDirectoryOptionSpecifiesDirectoryThatCannotBeWrittenTo;
- throw new RepositoryException(msg.text(indexDirectory, sourceName));
- }
- if (!indexDir.canRead()) {
- // But we cannot write to it ...
- I18n msg = JcrI18n.searchIndexDirectoryOptionSpecifiesDirectoryThatCannotBeRead;
- throw new RepositoryException(msg.text(indexDirectory, sourceName));
- }
- // The directory is usable
- } else {
- // The location doesn't exist,so try to make it ...
- if (!indexDir.mkdirs()) {
- I18n msg = JcrI18n.searchIndexDirectoryOptionSpecifiesDirectoryThatCannotBeCreated;
- throw new RepositoryException(msg.text(indexDirectory, sourceName));
- }
- // We successfully create the dirctory (or directories)
- }
- configuration = LuceneConfigurations.using(indexDir, encoder, encoder);
- } else {
- // Use in-memory as a fall-back ...
- configuration = LuceneConfigurations.inMemory();
- }
- assert configuration != null;
-
- // Set up the indexing rules ...
- IndexRules indexRules = null;
-
- // Create a connection factory that allows us to make connections back to the wrapped source ...
- RepositoryConnectionFactory connectionFactory = new RepositoryConnectionFactory() {
- /**
- * {@inheritDoc}
- *
- * @see org.jboss.dna.graph.connector.RepositoryConnectionFactory#createConnection(java.lang.String)
- */
- public RepositoryConnection createConnection( String sourceName ) throws RepositorySourceException {
- assert source.getName().equals(sourceName);
- return source.getConnection();
- }
- };
-
- // Wrap this with a searchable wrapper ...
- Analyzer analyzer = null;
- LuceneSearchEngine searchEngine = new LuceneSearchEngine(source.getName(), connectionFactory, true,
- configuration, indexRules, analyzer);
- return new SearchableRepositorySource(source, searchEngine);
- }
- }
- return source;
- }
-
protected void initializeSystemContent( Graph systemGraph ) {
// Make sure the "/jcr:system" node exists ...
ExecutionContext context = systemGraph.getContext();
@@ -698,6 +660,15 @@
}
/**
+ * Get the query manager for this repository.
+ *
+ * @return the query manager; never null
+ */
+ RepositoryQueryManager queryManager() {
+ return queryManager;
+ }
+
+ /**
* Returns the repository-level node type manager
*
* @return the repository-level node type manager
@@ -1126,15 +1097,15 @@
}
}
- protected class ConnectionFactoryWithSystem implements RepositoryConnectionFactory {
+ protected class DelegatingConnectionFactory implements RepositoryConnectionFactory {
private final RepositoryConnectionFactory delegate;
- private final RepositorySource system;
+ private final RepositorySource source;
- protected ConnectionFactoryWithSystem( RepositoryConnectionFactory delegate,
+ protected DelegatingConnectionFactory( RepositoryConnectionFactory delegate,
RepositorySource source ) {
assert delegate != null;
this.delegate = delegate;
- this.system = source;
+ this.source = source;
}
/**
@@ -1143,8 +1114,8 @@
* @see org.jboss.dna.graph.connector.RepositoryConnectionFactory#createConnection(java.lang.String)
*/
public RepositoryConnection createConnection( String sourceName ) throws RepositorySourceException {
- if (this.system.getName().equals(sourceName)) {
- return this.system.getConnection();
+ if (this.source.getName().equals(sourceName)) {
+ return this.source.getConnection();
}
return delegate.createConnection(sourceName);
}
Added: trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/RepositoryQueryManager.java
===================================================================
--- trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/RepositoryQueryManager.java (rev 0)
+++ trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/RepositoryQueryManager.java 2009-12-18 01:52:46 UTC (rev 1452)
@@ -0,0 +1,350 @@
+/*
+ * 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.jcr;
+
+import java.io.File;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import javax.jcr.RepositoryException;
+import javax.jcr.query.InvalidQueryException;
+import org.jboss.dna.common.collection.Problems;
+import org.jboss.dna.common.collection.SimpleProblems;
+import org.jboss.dna.common.i18n.I18n;
+import org.jboss.dna.common.text.TextEncoder;
+import org.jboss.dna.common.text.UrlEncoder;
+import org.jboss.dna.common.util.Logger;
+import org.jboss.dna.graph.ExecutionContext;
+import org.jboss.dna.graph.Graph;
+import org.jboss.dna.graph.GraphI18n;
+import org.jboss.dna.graph.connector.RepositoryConnectionFactory;
+import org.jboss.dna.graph.observe.Changes;
+import org.jboss.dna.graph.observe.Observable;
+import org.jboss.dna.graph.observe.Observer;
+import org.jboss.dna.graph.query.QueryContext;
+import org.jboss.dna.graph.query.QueryEngine;
+import org.jboss.dna.graph.query.QueryResults;
+import org.jboss.dna.graph.query.QueryResults.Columns;
+import org.jboss.dna.graph.query.model.QueryCommand;
+import org.jboss.dna.graph.query.model.TypeSystem;
+import org.jboss.dna.graph.query.optimize.Optimizer;
+import org.jboss.dna.graph.query.optimize.RuleBasedOptimizer;
+import org.jboss.dna.graph.query.plan.CanonicalPlanner;
+import org.jboss.dna.graph.query.plan.PlanHints;
+import org.jboss.dna.graph.query.plan.PlanNode;
+import org.jboss.dna.graph.query.plan.Planner;
+import org.jboss.dna.graph.query.process.AbstractAccessComponent;
+import org.jboss.dna.graph.query.process.ProcessingComponent;
+import org.jboss.dna.graph.query.process.Processor;
+import org.jboss.dna.graph.query.process.QueryProcessor;
+import org.jboss.dna.graph.query.process.SelectComponent.Analyzer;
+import org.jboss.dna.graph.query.validate.Schemata;
+import org.jboss.dna.graph.request.AccessQueryRequest;
+import org.jboss.dna.graph.request.processor.RequestProcessor;
+import org.jboss.dna.graph.search.SearchEngine;
+import org.jboss.dna.graph.search.SearchEngineProcessor;
+import org.jboss.dna.search.lucene.IndexRules;
+import org.jboss.dna.search.lucene.LuceneConfiguration;
+import org.jboss.dna.search.lucene.LuceneConfigurations;
+import org.jboss.dna.search.lucene.LuceneSearchEngine;
+
+/**
+ *
+ */
+class RepositoryQueryManager {
+
+ RepositoryQueryManager() {
+ }
+
+ @SuppressWarnings( "unused" )
+ public QueryResults query( JcrWorkspace workspace,
+ QueryCommand query,
+ Schemata schemata,
+ PlanHints hints,
+ Map<String, Object> variables ) throws InvalidQueryException {
+ Graph.BuildQuery builder = workspace.graph().query(query, schemata);
+ if (variables != null) builder.using(variables);
+ if (hints != null) builder.using(hints);
+ return builder.execute();
+ }
+
+ @SuppressWarnings( "unused" )
+ public QueryResults search( JcrWorkspace workspace,
+ String searchExpression,
+ int maxRowCount,
+ int offset ) throws InvalidQueryException {
+ return workspace.graph().search(searchExpression, maxRowCount, offset);
+ }
+
+ static class Disabled extends RepositoryQueryManager {
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.jboss.dna.jcr.RepositoryQueryManager#query(org.jboss.dna.jcr.JcrWorkspace,
+ * org.jboss.dna.graph.query.model.QueryCommand, org.jboss.dna.graph.query.validate.Schemata,
+ * org.jboss.dna.graph.query.plan.PlanHints, java.util.Map)
+ */
+ @Override
+ public QueryResults query( JcrWorkspace workspace,
+ QueryCommand query,
+ Schemata schemata,
+ PlanHints hints,
+ Map<String, Object> variables ) throws InvalidQueryException {
+ throw new InvalidQueryException(JcrI18n.queryIsDisabledInRepository.text(workspace.getSourceName()));
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.jboss.dna.jcr.RepositoryQueryManager#search(org.jboss.dna.jcr.JcrWorkspace, java.lang.String, int, int)
+ */
+ @Override
+ public QueryResults search( JcrWorkspace workspace,
+ String searchExpression,
+ int maxRowCount,
+ int offset ) throws InvalidQueryException {
+ throw new InvalidQueryException(JcrI18n.queryIsDisabledInRepository.text(workspace.getSourceName()));
+ }
+ }
+
+ static class SelfContained extends RepositoryQueryManager {
+ private final ExecutionContext context;
+ private final String sourceName;
+ private final LuceneConfiguration configuration;
+ private final SearchEngine searchEngine;
+ private final Observer searchObserver;
+ private final ExecutorService service;
+ private final QueryEngine queryEngine;
+
+ SelfContained( ExecutionContext context,
+ String nameOfSourceToBeSearchable,
+ final String observableSource,
+ RepositoryConnectionFactory connectionFactory,
+ Observable observable,
+ String indexDirectory,
+ boolean updateIndexesSynchronously ) throws RepositoryException {
+ this.context = context;
+ this.sourceName = nameOfSourceToBeSearchable;
+ // Define the configuration ...
+ TextEncoder encoder = new UrlEncoder();
+ if (indexDirectory != null) {
+ File indexDir = new File(indexDirectory);
+ if (indexDir.exists()) {
+ // The location does exist ...
+ if (!indexDir.isDirectory()) {
+ // The path is not a directory ...
+ I18n msg = JcrI18n.searchIndexDirectoryOptionSpecifiesFileNotDirectory;
+ throw new RepositoryException(msg.text(indexDirectory, sourceName));
+ }
+ if (!indexDir.canWrite()) {
+ // But we cannot write to it ...
+ I18n msg = JcrI18n.searchIndexDirectoryOptionSpecifiesDirectoryThatCannotBeWrittenTo;
+ throw new RepositoryException(msg.text(indexDirectory, sourceName));
+ }
+ if (!indexDir.canRead()) {
+ // But we cannot write to it ...
+ I18n msg = JcrI18n.searchIndexDirectoryOptionSpecifiesDirectoryThatCannotBeRead;
+ throw new RepositoryException(msg.text(indexDirectory, sourceName));
+ }
+ // The directory is usable
+ } else {
+ // The location doesn't exist,so try to make it ...
+ if (!indexDir.mkdirs()) {
+ I18n msg = JcrI18n.searchIndexDirectoryOptionSpecifiesDirectoryThatCannotBeCreated;
+ throw new RepositoryException(msg.text(indexDirectory, sourceName));
+ }
+ // We successfully create the dirctory (or directories)
+ }
+ configuration = LuceneConfigurations.using(indexDir, encoder, encoder);
+ } else {
+ // Use in-memory as a fall-back ...
+ configuration = LuceneConfigurations.inMemory();
+ }
+ assert configuration != null;
+
+ // Set up the indexing rules ...
+ IndexRules indexRules = null;
+
+ // Set up the search engine ...
+ org.apache.lucene.analysis.Analyzer analyzer = null;
+ searchEngine = new LuceneSearchEngine(nameOfSourceToBeSearchable, connectionFactory, true, configuration, indexRules,
+ analyzer);
+
+ // Set up an original source observer to keep the index up to date ...
+ if (updateIndexesSynchronously) {
+ this.service = null;
+ this.searchObserver = new Observer() {
+ public void notify( Changes changes ) {
+ if (changes.getSourceName().equals(observableSource)) {
+ process(changes);
+ }
+ }
+ };
+ } else {
+ // It's asynchronous, so create a single-threaded executor and an observer that enqueues the results
+ this.service = Executors.newCachedThreadPool();
+ this.searchObserver = new Observer() {
+ @SuppressWarnings( "synthetic-access" )
+ public void notify( final Changes changes ) {
+ if (changes.getSourceName().equals(observableSource)) {
+ service.submit(new Runnable() {
+ public void run() {
+ process(changes);
+ }
+ });
+ }
+ }
+ };
+ }
+ observable.register(this.searchObserver);
+
+ // Set up the query engine ...
+ Planner planner = new CanonicalPlanner();
+ Optimizer optimizer = new RuleBasedOptimizer();
+ Processor processor = new QueryProcessor() {
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.jboss.dna.graph.query.process.QueryProcessor#createAccessComponent(org.jboss.dna.graph.query.model.QueryCommand,
+ * org.jboss.dna.graph.query.QueryContext, org.jboss.dna.graph.query.plan.PlanNode,
+ * org.jboss.dna.graph.query.QueryResults.Columns,
+ * org.jboss.dna.graph.query.process.SelectComponent.Analyzer)
+ */
+ @Override
+ protected ProcessingComponent createAccessComponent( QueryCommand originalQuery,
+ QueryContext context,
+ PlanNode accessNode,
+ Columns resultColumns,
+ Analyzer analyzer ) {
+ return new AccessQueryProcessor((GraphQueryContext)context, resultColumns, accessNode);
+ }
+ };
+ this.queryEngine = new QueryEngine(planner, optimizer, processor);
+
+ }
+
+ protected void process( Changes changes ) {
+ try {
+ Logger.getLogger(getClass()).warn(JcrI18n.errorUpdatingQueryIndexes, "JUST KIDDING");
+ searchEngine.index(context, changes.getChangeRequests());
+ } catch (RuntimeException e) {
+ Logger.getLogger(getClass()).error(e, JcrI18n.errorUpdatingQueryIndexes, e.getLocalizedMessage());
+ }
+ }
+
+ @Override
+ public QueryResults query( JcrWorkspace workspace,
+ QueryCommand query,
+ Schemata schemata,
+ PlanHints hints,
+ Map<String, Object> variables ) {
+ TypeSystem typeSystem = workspace.context().getValueFactories().getTypeSystem();
+ SearchEngineProcessor processor = searchEngine.createProcessor(context, null, true);
+ try {
+ QueryContext context = new GraphQueryContext(schemata, typeSystem, hints, new SimpleProblems(), variables,
+ processor, workspace.getName());
+ return queryEngine.execute(context, query);
+ } finally {
+ processor.close();
+ }
+ }
+
+ protected class GraphQueryContext extends QueryContext {
+ private final RequestProcessor processor;
+ private final String workspaceName;
+
+ protected GraphQueryContext( Schemata schemata,
+ TypeSystem typeSystem,
+ PlanHints hints,
+ Problems problems,
+ Map<String, Object> variables,
+ RequestProcessor processor,
+ String workspaceName ) {
+ super(schemata, typeSystem, hints, problems, variables);
+ this.processor = processor;
+ this.workspaceName = workspaceName;
+ }
+
+ /**
+ * @return processor
+ */
+ public RequestProcessor getProcessor() {
+ return processor;
+ }
+
+ /**
+ * @return workspaceName
+ */
+ public String getWorkspaceName() {
+ return workspaceName;
+ }
+ }
+
+ protected static class AccessQueryProcessor extends AbstractAccessComponent {
+ private final AccessQueryRequest accessRequest;
+
+ protected AccessQueryProcessor( GraphQueryContext context,
+ Columns columns,
+ PlanNode accessNode ) {
+ super(context, columns, accessNode);
+ accessRequest = new AccessQueryRequest(context.getWorkspaceName(), sourceName, getColumns(), andedConstraints,
+ limit, context.getSchemata(), context.getVariables());
+ context.getProcessor().process(accessRequest);
+ }
+
+ /**
+ * Get the access query request.
+ *
+ * @return the access query request; never null
+ */
+ public AccessQueryRequest getAccessRequest() {
+ return accessRequest;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.jboss.dna.graph.query.process.ProcessingComponent#execute()
+ */
+ @Override
+ public List<Object[]> execute() {
+ if (accessRequest.getError() != null) {
+ I18n msg = GraphI18n.errorWhilePerformingQuery;
+ getContext().getProblems().addError(accessRequest.getError(),
+ msg,
+ accessNode.getString(),
+ accessRequest.workspace(),
+ sourceName);
+ return emptyTuples();
+ }
+ return accessRequest.getTuples();
+ }
+
+ }
+
+ }
+}
Property changes on: trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/RepositoryQueryManager.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Modified: trunk/dna-jcr/src/main/resources/org/jboss/dna/jcr/JcrI18n.properties
===================================================================
--- trunk/dna-jcr/src/main/resources/org/jboss/dna/jcr/JcrI18n.properties 2009-12-17 20:38:21 UTC (rev 1451)
+++ trunk/dna-jcr/src/main/resources/org/jboss/dna/jcr/JcrI18n.properties 2009-12-18 01:52:46 UTC (rev 1452)
@@ -117,6 +117,7 @@
searchIndexDirectoryOptionSpecifiesDirectoryThatCannotBeRead = The JCR Repository '{1}' option value "{0}" specifies a directory on the local file system that cannot be read
searchIndexDirectoryOptionSpecifiesDirectoryThatCannotBeWrittenTo = The JCR Repository '{1}' option value "{0}" specifies a directory on the local file system that cannot be written
searchIndexDirectoryOptionSpecifiesDirectoryThatCannotBeCreated = = The JCR Repository '{1}' option value "{0}" specifies a non-existant directory on the local file system that cannot be created
+errorUpdatingQueryIndexes = Error updating the query indexes: {0}
noNegativeDepth=Depth parameter ({0}) cannot be negative
tooDeep=Depth parameter ({0}) cannot be greater than the result of getDepth() for this node
@@ -125,6 +126,7 @@
invalidQueryLanguage="{0}" is not a valid query langauge. Supported languages are\: {1}
queryCannotBeParsedUsingLanguage=The {0} query "{1}" is not well-formed: {2}
queryInLanguageIsNotValid=The {0} query "{1}" has one or more errors: {2}
+queryIsDisabledInRepository = The {0} repository does not have queries enabled
invalidNodeTypeName=Node types cannot have a null or empty name
noSuchNodeType=Type named '{0}' does not exist
Modified: trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/AbstractJcrAccessTest.java
===================================================================
--- trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/AbstractJcrAccessTest.java 2009-12-17 20:38:21 UTC (rev 1451)
+++ trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/AbstractJcrAccessTest.java 2009-12-18 01:52:46 UTC (rev 1452)
@@ -83,7 +83,7 @@
}
};
- repository = new JcrRepository(context, connectionFactory, "unused", new MockObservable(), null, null);
+ repository = new JcrRepository(context, connectionFactory, "unused", new MockObservable(), null, null, null);
SecurityContext mockSecurityContext = new MockSecurityContext("testuser",
Collections.singleton(JcrSession.DNA_WRITE_PERMISSION));
Modified: trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/ImportExportTest.java
===================================================================
--- trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/ImportExportTest.java 2009-12-17 20:38:21 UTC (rev 1451)
+++ trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/ImportExportTest.java 2009-12-18 01:52:46 UTC (rev 1452)
@@ -84,7 +84,7 @@
}
};
- repository = new JcrRepository(context, connectionFactory, "unused", new MockObservable(), null, null);
+ repository = new JcrRepository(context, connectionFactory, "unused", new MockObservable(), null, null, null);
SecurityContext mockSecurityContext = new MockSecurityContext("testuser",
Collections.singleton(JcrSession.DNA_WRITE_PERMISSION));
Modified: trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/JcrConfigurationTest.java
===================================================================
--- trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/JcrConfigurationTest.java 2009-12-17 20:38:21 UTC (rev 1451)
+++ trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/JcrConfigurationTest.java 2009-12-18 01:52:46 UTC (rev 1452)
@@ -252,9 +252,9 @@
options.put(Option.ANONYMOUS_USER_ROLES, DefaultOption.ANONYMOUS_USER_ROLES);
options.put(Option.TABLES_INCLUDE_COLUMNS_FOR_INHERITED_PROPERTIES,
DefaultOption.TABLES_INCLUDE_COLUMNS_FOR_INHERITED_PROPERTIES);
- options.put(Option.SEARCHABLE, DefaultOption.SEARCHABLE);
- options.put(Option.SEARCH_INDEX_DIRECTORY, DefaultOption.SEARCH_INDEX_DIRECTORY);
- options.put(Option.UPDATE_INDEXES_SYNCHRONOUSLY, DefaultOption.UPDATE_INDEXES_SYNCHRONOUSLY);
+ options.put(Option.QUERY_EXECUTION_ENABLED, DefaultOption.QUERY_EXECUTION_ENABLED);
+ options.put(Option.QUERY_INDEX_DIRECTORY, DefaultOption.QUERY_INDEX_DIRECTORY);
+ options.put(Option.QUERY_INDEXES_UPDATED_SYNCHRONOUSLY, DefaultOption.QUERY_INDEXES_UPDATED_SYNCHRONOUSLY);
assertThat(repository.getOptions(), is(options));
}
Modified: trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/JcrRepositoryTest.java
===================================================================
--- trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/JcrRepositoryTest.java 2009-12-17 20:38:21 UTC (rev 1451)
+++ trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/JcrRepositoryTest.java 2009-12-18 01:52:46 UTC (rev 1452)
@@ -116,7 +116,7 @@
// Set up the repository ...
descriptors = new HashMap<String, String>();
- repository = new JcrRepository(context, connectionFactory, sourceName, new MockObservable(), descriptors, null);
+ repository = new JcrRepository(context, connectionFactory, sourceName, new MockObservable(), null, descriptors, null);
// Set up the graph that goes directly to the source ...
sourceGraph = Graph.create(source, context);
@@ -143,28 +143,28 @@
}
@Test
- public void shouldAllowNullDescriptors() {
- new JcrRepository(context, connectionFactory, sourceName, new MockObservable(), null, null);
+ public void shouldAllowNullDescriptors() throws Exception {
+ new JcrRepository(context, connectionFactory, sourceName, new MockObservable(), null, null, null);
}
@Test( expected = IllegalArgumentException.class )
public void shouldNotAllowNullExecutionContext() throws Exception {
- new JcrRepository(null, connectionFactory, sourceName, new MockObservable(), descriptors, null);
+ new JcrRepository(null, connectionFactory, sourceName, new MockObservable(), null, descriptors, null);
}
@Test( expected = IllegalArgumentException.class )
public void shouldNotAllowNullConnectionFactories() throws Exception {
- new JcrRepository(context, null, sourceName, new MockObservable(), descriptors, null);
+ new JcrRepository(context, null, sourceName, new MockObservable(), null, descriptors, null);
}
@Test( expected = IllegalArgumentException.class )
public void shouldNotAllowNullObservable() throws Exception {
- new JcrRepository(context, connectionFactory, sourceName, null, null, null);
+ new JcrRepository(context, connectionFactory, sourceName, null, null, null, null);
}
@Test( expected = IllegalArgumentException.class )
public void shouldNotAllowNullSourceName() throws Exception {
- new JcrRepository(context, connectionFactory, null, new MockObservable(), descriptors, null);
+ new JcrRepository(context, connectionFactory, null, new MockObservable(), null, descriptors, null);
}
@Test( expected = IllegalArgumentException.class )
@@ -188,8 +188,9 @@
}
@Test
- public void shouldProvideBuiltInDescriptorsWhenNotSuppliedDescriptors() {
- Repository repository = new JcrRepository(context, connectionFactory, sourceName, new MockObservable(), descriptors, null);
+ public void shouldProvideBuiltInDescriptorsWhenNotSuppliedDescriptors() throws Exception {
+ Repository repository = new JcrRepository(context, connectionFactory, sourceName, new MockObservable(), null,
+ descriptors, null);
testDescriptorKeys(repository);
testDescriptorValues(repository);
}
@@ -205,18 +206,19 @@
}
@Test
- public void shouldHaveDefaultOptionsWhenNotOverridden() {
- JcrRepository repository = new JcrRepository(context, connectionFactory, sourceName, new MockObservable(), descriptors,
- null);
+ public void shouldHaveDefaultOptionsWhenNotOverridden() throws Exception {
+ JcrRepository repository = new JcrRepository(context, connectionFactory, sourceName, new MockObservable(), null,
+ descriptors, null);
assertThat(repository.getOptions().get(JcrRepository.Option.PROJECT_NODE_TYPES),
is(JcrRepository.DefaultOption.PROJECT_NODE_TYPES));
}
@Test
- public void shouldProvideUserSuppliedDescriptors() {
+ public void shouldProvideUserSuppliedDescriptors() throws Exception {
Map<String, String> descriptors = new HashMap<String, String>();
descriptors.put("property", "value");
- Repository repository = new JcrRepository(context, connectionFactory, sourceName, new MockObservable(), descriptors, null);
+ Repository repository = new JcrRepository(context, connectionFactory, sourceName, new MockObservable(), null,
+ descriptors, null);
testDescriptorKeys(repository);
testDescriptorValues(repository);
assertThat(repository.getDescriptor("property"), is("value"));
@@ -254,8 +256,8 @@
public void shouldAllowLoginWithNoCredentialsIfAnonAccessEnabled() throws Exception {
Map<JcrRepository.Option, String> options = new HashMap<JcrRepository.Option, String>();
options.put(JcrRepository.Option.ANONYMOUS_USER_ROLES, JcrSession.DNA_READ_PERMISSION);
- JcrRepository repository = new JcrRepository(context, connectionFactory, sourceName, new MockObservable(), descriptors,
- options);
+ JcrRepository repository = new JcrRepository(context, connectionFactory, sourceName, new MockObservable(), null,
+ descriptors, options);
session = (JcrSession)repository.login();
@@ -492,8 +494,8 @@
// Use a different repository that supports anonymous logins to make this test cleaner
Map<Option, String> options = new HashMap<Option, String>();
options.put(JcrRepository.Option.ANONYMOUS_USER_ROLES, JcrSession.DNA_ADMIN_PERMISSION);
- JcrRepository repository = new JcrRepository(context, connectionFactory, sourceName, new MockObservable(), descriptors,
- options);
+ JcrRepository repository = new JcrRepository(context, connectionFactory, sourceName, new MockObservable(), null,
+ descriptors, options);
Session session;
@@ -518,8 +520,8 @@
// Use a different repository that supports anonymous logins to make this test cleaner
Map<Option, String> options = new HashMap<Option, String>();
options.put(JcrRepository.Option.ANONYMOUS_USER_ROLES, JcrSession.DNA_ADMIN_PERMISSION);
- JcrRepository repository = new JcrRepository(context, connectionFactory, sourceName, new MockObservable(), descriptors,
- options);
+ JcrRepository repository = new JcrRepository(context, connectionFactory, sourceName, new MockObservable(), null,
+ descriptors, options);
String lockedNodeName = "lockedNode";
JcrSession locker = (JcrSession)repository.login();
Modified: trunk/dna-repository/src/main/java/org/jboss/dna/repository/RepositoryLibrary.java
===================================================================
--- trunk/dna-repository/src/main/java/org/jboss/dna/repository/RepositoryLibrary.java 2009-12-17 20:38:21 UTC (rev 1451)
+++ trunk/dna-repository/src/main/java/org/jboss/dna/repository/RepositoryLibrary.java 2009-12-18 01:52:46 UTC (rev 1452)
@@ -253,11 +253,11 @@
}
/**
- * Returns true if this federated repository is in the process of terminating after {@link ServiceAdministrator#shutdown()}
- * has been called on the {@link #getAdministrator() administrator}, but the federated repository has connections that have
- * not yet normally been {@link RepositoryConnection#close() closed}. This method may be useful for debugging. A return of
- * <tt>true</tt> reported a sufficient period after shutdown may indicate that connection users have ignored or suppressed
- * interruption, causing this repository not to properly terminate.
+ * Returns true if this library is in the process of terminating after {@link ServiceAdministrator#shutdown()} has been called
+ * on the {@link #getAdministrator() administrator}, but the library has connections that have not yet normally been
+ * {@link RepositoryConnection#close() closed}. This method may be useful for debugging. A return of <tt>true</tt> reported a
+ * sufficient period after shutdown may indicate that connection users have ignored or suppressed interruption, causing this
+ * repository not to properly terminate.
*
* @return true if terminating but not yet terminated, or false otherwise
* @see #isTerminated()
@@ -275,7 +275,7 @@
}
/**
- * Return true if this federated repository has completed its termination and no longer has any open connections.
+ * Return true if this library has completed its termination and no longer has any open connections.
*
* @return true if terminated, or false otherwise
* @see #isTerminating()
@@ -356,7 +356,7 @@
}
/**
- * Add the supplied federated source. This method returns false if the source is null.
+ * Add the supplied source. This method returns false if the source is null.
*
* @param source the source to add
* @return true if the source is added, or false if the reference is null or if there is already an existing source with the
@@ -367,7 +367,7 @@
}
/**
- * Add the supplied federated source. This method returns false if the source is null.
+ * Add the supplied source. This method returns false if the source is null.
* <p>
* If a source with the same name already exists, it will be replaced only if <code>replaceIfExisting</code> is true. If this
* is the case, then the existing source will be removed from the connection pool, and that pool will be
@@ -463,9 +463,9 @@
}
/**
- * Remove from this federated repository the supplied source (or a source with the same name as that supplied). This call
- * shuts down the connections in the source in an orderly fashion, allowing those connection currently in use to be used and
- * closed normally, but preventing further connections from being used.
+ * Remove from this library the supplied source (or a source with the same name as that supplied). This call shuts down the
+ * connections in the source in an orderly fashion, allowing those connection currently in use to be used and closed normally,
+ * but preventing further connections from being used.
* <p>
* This method can safely be called while the federation repository is in use.
* </p>
@@ -485,8 +485,8 @@
}
/**
- * Remove from this federated repository the source with the supplied name. This call shuts down the connections in the source
- * in an orderly fashion, allowing those connection currently in use to be used and closed normally, but preventing further
+ * Remove from this library the source with the supplied name. This call shuts down the connections in the source in an
+ * orderly fashion, allowing those connection currently in use to be used and closed normally, but preventing further
* connections from being used. However, this method never waits until the connections are all closed, and is equivalent to
* calling <code>removeSource(name,0,TimeUnit.SECONDS)</code>.
*
@@ -511,8 +511,8 @@
}
/**
- * Remove from this federated repository the source with the supplied name. This call shuts down the connections in the source
- * in an orderly fashion, allowing those connection currently in use to be used and closed normally, but preventing further
+ * Remove from this library the source with the supplied name. This call shuts down the connections in the source in an
+ * orderly fashion, allowing those connection currently in use to be used and closed normally, but preventing further
* connections from being used.
*
* @param name the name of the source to be removed
Modified: trunk/extensions/dna-search-lucene/src/main/java/org/jboss/dna/search/lucene/LuceneSearchEngine.java
===================================================================
--- trunk/extensions/dna-search-lucene/src/main/java/org/jboss/dna/search/lucene/LuceneSearchEngine.java 2009-12-17 20:38:21 UTC (rev 1451)
+++ trunk/extensions/dna-search-lucene/src/main/java/org/jboss/dna/search/lucene/LuceneSearchEngine.java 2009-12-18 01:52:46 UTC (rev 1452)
@@ -262,7 +262,7 @@
indexer.index(workspaceWork.workspaceName, location, crawlRequest.depth);
} else if (request instanceof ForwardRequest) {
ForwardRequest forwardRequest = (ForwardRequest)request;
- indexer.process(forwardRequest.changeRequest);
+ indexer.process(forwardRequest.changeRequest.clone());
}
}
}
@@ -292,6 +292,20 @@
public Iterator<WorkspaceWork> iterator() {
return byWorkspaceName.values().iterator();
}
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see java.lang.Object#toString()
+ */
+ @Override
+ public String toString() {
+ StringBuilder sb = new StringBuilder();
+ for (WorkspaceWork work : byWorkspaceName.values()) {
+ sb.append(work.toString()).append('\n');
+ }
+ return sb.toString();
+ }
}
protected static class WorkspaceWork implements Iterable<WorkRequest> {
@@ -425,6 +439,25 @@
}
requestByPath.put(path, new CrawlSubgraph(location, depth));
}
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see java.lang.Object#toString()
+ */
+ @Override
+ public String toString() {
+ StringBuilder sb = new StringBuilder();
+ sb.append(" Workspace: ").append(workspaceName).append('\n');
+ for (Map.Entry<Path, WorkRequest> entry : requestByPath.entrySet()) {
+ sb.append(" ")
+ .append(entry.getKey().getString(context.getNamespaceRegistry()))
+ .append("->")
+ .append(entry.getValue().toString(context))
+ .append('\n');
+ }
+ return sb.toString();
+ }
}
protected static ChangeRequest merge( ExecutionContext context,
@@ -553,6 +586,17 @@
@Immutable
protected static abstract class WorkRequest {
+ public abstract String toString( ExecutionContext context );
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see java.lang.Object#toString()
+ */
+ @Override
+ public String toString() {
+ return toString(new ExecutionContext());
+ }
}
@Immutable
@@ -565,6 +609,11 @@
this.location = location;
this.depth = depth;
}
+
+ @Override
+ public String toString( ExecutionContext context ) {
+ return "Crawl " + location.getPath().getString(context.getNamespaceRegistry());
+ }
}
@Immutable
@@ -574,5 +623,10 @@
protected ForwardRequest( ChangeRequest changeRequest ) {
this.changeRequest = changeRequest;
}
+
+ @Override
+ public String toString( ExecutionContext context ) {
+ return "Forward " + changeRequest;
+ }
}
}
14 years, 6 months
DNA SVN: r1451 - in trunk: dna-graph/src/main/java/org/jboss/dna/graph/connector/federation and 5 other directories.
by dna-commits@lists.jboss.org
Author: rhauch
Date: 2009-12-17 15:38:21 -0500 (Thu, 17 Dec 2009)
New Revision: 1451
Added:
trunk/dna-common/src/main/java/org/jboss/dna/common/util/NamedThreadFactory.java
Modified:
trunk/dna-graph/src/main/java/org/jboss/dna/graph/connector/federation/FederatedRepositorySource.java
trunk/dna-graph/src/main/java/org/jboss/dna/graph/search/SearchEngineIndexer.java
trunk/dna-graph/src/test/java/org/jboss/dna/graph/connector/RepositorySourceLoadHarness.java
trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/JcrEngine.java
trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/JcrRepository.java
trunk/dna-repository/src/main/java/org/jboss/dna/repository/DnaConfiguration.java
trunk/dna-repository/src/main/java/org/jboss/dna/repository/DnaEngine.java
trunk/dna-repository/src/main/java/org/jboss/dna/repository/sequencer/SequencingService.java
Log:
DNA-598 Shutting down JcrEngine returns, but leaves idle threads running (preventing shutdown of VM) for 60 seconds
Fixed the problem with the shutdown leaving idle threads and blocking termination of the VM. After debugging (and using a new NameThreadFactory that creates threads with names beginning with a specified prefix), it's clear now that these extra threads were owned by the Executor used in the FederatedRepositorySource, and this executor was not being shutdown in the FederatedRepositorySource.close() method. The Executor was creating the threads with a timeout of 60sec, which makes sense. Fixing this now properly shuts down the Executor, and this fixes the problem.
Added: trunk/dna-common/src/main/java/org/jboss/dna/common/util/NamedThreadFactory.java
===================================================================
--- trunk/dna-common/src/main/java/org/jboss/dna/common/util/NamedThreadFactory.java (rev 0)
+++ trunk/dna-common/src/main/java/org/jboss/dna/common/util/NamedThreadFactory.java 2009-12-17 20:38:21 UTC (rev 1451)
@@ -0,0 +1,54 @@
+/*
+ * 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.common.util;
+
+import java.util.concurrent.Executors;
+import java.util.concurrent.ThreadFactory;
+import java.util.concurrent.atomic.AtomicInteger;
+
+/**
+ * The thread factory that lets us adjust the names of the threads.
+ *
+ * @see Executors#defaultThreadFactory()
+ */
+public class NamedThreadFactory implements ThreadFactory {
+ static final AtomicInteger poolNumber = new AtomicInteger(1);
+ final ThreadGroup group;
+ final AtomicInteger threadNumber = new AtomicInteger(1);
+ final String namePrefix;
+
+ public NamedThreadFactory( String poolName ) {
+ SecurityManager s = System.getSecurityManager();
+ group = (s != null) ? s.getThreadGroup() : Thread.currentThread().getThreadGroup();
+ namePrefix = (poolName != null && poolName.trim().length() != 0 ? poolName : "pool") + "-" + poolNumber.getAndIncrement()
+ + "-thread-";
+ }
+
+ public Thread newThread( Runnable r ) {
+ Thread t = new Thread(group, r, namePrefix + threadNumber.getAndIncrement(), 0);
+ if (t.isDaemon()) t.setDaemon(false);
+ if (t.getPriority() != Thread.NORM_PRIORITY) t.setPriority(Thread.NORM_PRIORITY);
+ return t;
+ }
+}
Property changes on: trunk/dna-common/src/main/java/org/jboss/dna/common/util/NamedThreadFactory.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Modified: trunk/dna-graph/src/main/java/org/jboss/dna/graph/connector/federation/FederatedRepositorySource.java
===================================================================
--- trunk/dna-graph/src/main/java/org/jboss/dna/graph/connector/federation/FederatedRepositorySource.java 2009-12-16 21:06:41 UTC (rev 1450)
+++ trunk/dna-graph/src/main/java/org/jboss/dna/graph/connector/federation/FederatedRepositorySource.java 2009-12-17 20:38:21 UTC (rev 1451)
@@ -43,6 +43,7 @@
import org.jboss.dna.common.i18n.I18n;
import org.jboss.dna.common.util.CheckArg;
import org.jboss.dna.common.util.HashCode;
+import org.jboss.dna.common.util.NamedThreadFactory;
import org.jboss.dna.graph.DnaLexicon;
import org.jboss.dna.graph.ExecutionContext;
import org.jboss.dna.graph.GraphI18n;
@@ -197,8 +198,13 @@
*/
public void close() {
synchronized (this) {
- // Release the configuration ...
- this.configuration = null;
+ if (this.configuration != null) {
+ // Release the configuration ...
+ if (this.configuration.getExecutor() != null) {
+ this.configuration.getExecutor().shutdown();
+ }
+ this.configuration = null;
+ }
}
}
@@ -390,7 +396,7 @@
}
// Create the ExecutorService ...
- ExecutorService executor = Executors.newCachedThreadPool();
+ ExecutorService executor = Executors.newCachedThreadPool(new NamedThreadFactory(name));
return new FederatedRepository(name, connectionFactory, workspaces, defaultCachePolicy, executor);
} catch (RepositorySourceException t) {
@@ -444,7 +450,7 @@
}
} else {
connectionFactory = context.getRepositoryConnectionFactory();
- executor = Executors.newCachedThreadPool();
+ executor = Executors.newCachedThreadPool(new NamedThreadFactory(name));
}
// Add the new workspace ...
Modified: trunk/dna-graph/src/main/java/org/jboss/dna/graph/search/SearchEngineIndexer.java
===================================================================
--- trunk/dna-graph/src/main/java/org/jboss/dna/graph/search/SearchEngineIndexer.java 2009-12-16 21:06:41 UTC (rev 1450)
+++ trunk/dna-graph/src/main/java/org/jboss/dna/graph/search/SearchEngineIndexer.java 2009-12-17 20:38:21 UTC (rev 1451)
@@ -34,6 +34,7 @@
import org.jboss.dna.common.i18n.I18n;
import org.jboss.dna.common.util.CheckArg;
import org.jboss.dna.common.util.Logger;
+import org.jboss.dna.common.util.NamedThreadFactory;
import org.jboss.dna.graph.ExecutionContext;
import org.jboss.dna.graph.GraphI18n;
import org.jboss.dna.graph.Location;
@@ -71,7 +72,7 @@
private final String sourceName;
private final SearchEngine searchEngine;
private final int maxDepthPerRead = DEFAULT_MAX_DEPTH_PER_READ;
- private final ExecutorService service = Executors.newSingleThreadExecutor();
+ private final ExecutorService service;
private final CompositeRequestChannel channel;
private final SearchEngineProcessor processor;
private boolean closed = false;
@@ -91,8 +92,8 @@
* @throws IllegalArgumentException if the search engine or connection factory references are null
*/
public SearchEngineIndexer( ExecutionContext context,
- SearchEngine searchEngine,
- RepositoryConnectionFactory connectionFactory ) {
+ SearchEngine searchEngine,
+ RepositoryConnectionFactory connectionFactory ) {
CheckArg.isNotNull(context, "context");
CheckArg.isNotNull(searchEngine, "searchEngine");
CheckArg.isNotNull(connectionFactory, "connectionFactory");
@@ -101,6 +102,7 @@
this.sourceName = searchEngine.getSourceName();
this.connectionFactory = connectionFactory;
this.channel = new CompositeRequestChannel(this.sourceName);
+ this.service = Executors.newSingleThreadExecutor(new NamedThreadFactory("search-" + sourceName));
// Start the channel and search engine processor right away (this is why this object must be closed)
this.channel.start(service, this.context, this.connectionFactory);
this.processor = this.searchEngine.createProcessor(this.context, null, false);
@@ -172,7 +174,7 @@
* @throws InvalidWorkspaceException if there is no workspace with the supplied name
*/
public SearchEngineIndexer index( String workspaceName,
- Path path ) {
+ Path path ) {
checkNotClosed();
CheckArg.isNotNull(workspaceName, "workspaceName");
CheckArg.isNotNull(path, "path");
@@ -192,8 +194,8 @@
* @throws InvalidWorkspaceException if there is no workspace with the supplied name
*/
public SearchEngineIndexer index( String workspaceName,
- Path path,
- int depth ) {
+ Path path,
+ int depth ) {
checkNotClosed();
CheckArg.isNotNull(workspaceName, "workspaceName");
CheckArg.isNotNull(path, "path");
@@ -216,7 +218,7 @@
* @throws InvalidWorkspaceException if there is no workspace with the supplied name
*/
public SearchEngineIndexer index( String workspaceName,
- Location location ) {
+ Location location ) {
checkNotClosed();
CheckArg.isNotNull(workspaceName, "workspaceName");
CheckArg.isNotNull(location, "location");
@@ -236,8 +238,8 @@
* @throws InvalidWorkspaceException if there is no workspace with the supplied name
*/
public SearchEngineIndexer index( String workspaceName,
- Location location,
- int depth ) {
+ Location location,
+ int depth ) {
checkNotClosed();
CheckArg.isNotNull(workspaceName, "workspaceName");
CheckArg.isNotNull(location, "location");
Modified: trunk/dna-graph/src/test/java/org/jboss/dna/graph/connector/RepositorySourceLoadHarness.java
===================================================================
--- trunk/dna-graph/src/test/java/org/jboss/dna/graph/connector/RepositorySourceLoadHarness.java 2009-12-16 21:06:41 UTC (rev 1450)
+++ trunk/dna-graph/src/test/java/org/jboss/dna/graph/connector/RepositorySourceLoadHarness.java 2009-12-17 20:38:21 UTC (rev 1451)
@@ -35,6 +35,7 @@
import java.util.concurrent.TimeUnit;
import org.jboss.dna.common.i18n.MockI18n;
import org.jboss.dna.common.util.Logger;
+import org.jboss.dna.common.util.NamedThreadFactory;
import org.jboss.dna.graph.ExecutionContext;
import org.jboss.dna.graph.Location;
import org.jboss.dna.graph.property.basic.RootPath;
@@ -100,7 +101,8 @@
// Create an Executor Service, using a thread factory that makes the first 'n' thread all wait for each other ...
ExecutorService clientPool = null;
if (clients.size() == 1) {
- clientPool = Executors.newSingleThreadExecutor();
+ ThreadFactory threadFactory = new NamedThreadFactory("load");
+ clientPool = Executors.newSingleThreadExecutor(threadFactory);
} else {
final ThreadFactory threadFactory = new TestThreadFactory(clients.size());
clientPool = Executors.newFixedThreadPool(clients.size(), threadFactory);
Modified: trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/JcrEngine.java
===================================================================
--- trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/JcrEngine.java 2009-12-16 21:06:41 UTC (rev 1450)
+++ trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/JcrEngine.java 2009-12-17 20:38:21 UTC (rev 1451)
@@ -114,8 +114,18 @@
@Override
public void shutdown() {
scheduler.shutdown();
+ super.shutdown();
- super.shutdown();
+ try {
+ this.repositoriesLock.lock();
+ // Shut down all of the repositories ...
+ for (JcrRepository repository : repositories.values()) {
+ repository.close();
+ }
+ this.repositories.clear();
+ } finally {
+ this.repositoriesLock.unlock();
+ }
}
@Override
Modified: trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/JcrRepository.java
===================================================================
--- trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/JcrRepository.java 2009-12-16 21:06:41 UTC (rev 1450)
+++ trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/JcrRepository.java 2009-12-17 20:38:21 UTC (rev 1451)
@@ -963,6 +963,12 @@
return session;
}
+ void close() {
+ if (this.federatedSource != null) {
+ this.federatedSource.close();
+ }
+ }
+
/**
* Returns the lock manager for the named workspace (if one already exists) or creates a new lock manager and returns it. This
* method is thread-safe.
Modified: trunk/dna-repository/src/main/java/org/jboss/dna/repository/DnaConfiguration.java
===================================================================
--- trunk/dna-repository/src/main/java/org/jboss/dna/repository/DnaConfiguration.java 2009-12-16 21:06:41 UTC (rev 1450)
+++ trunk/dna-repository/src/main/java/org/jboss/dna/repository/DnaConfiguration.java 2009-12-17 20:38:21 UTC (rev 1451)
@@ -114,10 +114,22 @@
source.setDefaultWorkspaceName(DEFAULT_WORKSPACE_NAME);
// The file was imported successfully, so now create the content information ...
- configurationContent = new ConfigurationDefinition(source, null, null, context, null);
+ configurationContent = new ConfigurationDefinition("dna", source, null, null, context, null);
}
/**
+ * Set the name of this configuration.
+ *
+ * @param name the configuration name; may be null if the default name should be used
+ * @return this configuration
+ */
+ public DnaConfiguration withName( String name ) {
+ if (name != null) name = "dna";
+ configurationContent = configurationContent.with(name);
+ return this;
+ }
+
+ /**
* Load the configuration from a file at the given path.
*
* @param pathToConfigurationFile the path the file containing the configuration information
@@ -260,7 +272,8 @@
graph.importXmlFrom(configurationFileInputStream).skippingRootElement(true).into(pathToParent);
// The file was imported successfully, so now create the content information ...
- configurationContent = new ConfigurationDefinition(source, null, pathToParent, context, null);
+ configurationContent = new ConfigurationDefinition(configurationContent.getName(), source, null, pathToParent, context,
+ null);
return this;
}
@@ -332,7 +345,8 @@
assert parent != null;
// Now create the content information ...
- configurationContent = new ConfigurationDefinition(source, workspaceName, path, context, null);
+ configurationContent = new ConfigurationDefinition(configurationContent.getName(), source, workspaceName, path, context,
+ null);
return this;
}
@@ -1301,6 +1315,7 @@
*/
@Immutable
public static class ConfigurationDefinition {
+ private final String name;
private final ClassLoaderFactory classLoaderFactory;
private final RepositorySource source;
private final Path path;
@@ -1308,11 +1323,14 @@
private final ExecutionContext context;
private Graph graph;
- protected ConfigurationDefinition( RepositorySource source,
+ protected ConfigurationDefinition( String configurationName,
+ RepositorySource source,
String workspace,
Path path,
ExecutionContext context,
ClassLoaderFactory classLoaderFactory ) {
+ assert configurationName != null;
+ this.name = configurationName;
this.source = source;
this.path = path != null ? path : RootPath.INSTANCE;
this.workspace = workspace;
@@ -1321,6 +1339,15 @@
}
/**
+ * Get the name of this configuration.
+ *
+ * @return the configuration's name; never null
+ */
+ public String getName() {
+ return name;
+ }
+
+ /**
* Get the repository source where the configuration content may be found
*
* @return the source for the configuration repository; never null
@@ -1362,13 +1389,24 @@
}
/**
+ * Return a copy of this configuration that uses the supplied name instead of this object's {@link #getPath() path}.
+ *
+ * @param name the desired name for the new configuration; if null, then the name of this configuration is used
+ * @return the new configuration
+ */
+ public ConfigurationDefinition with( String name ) {
+ if (name == null) name = this.name;
+ return new ConfigurationDefinition(name, source, workspace, path, context, classLoaderFactory);
+ }
+
+ /**
* Return a copy of this configuration that uses the supplied path instead of this object's {@link #getPath() path}.
*
* @param path the desired path for the new configuration; if null, then "/" is used
* @return the new configuration
*/
public ConfigurationDefinition with( Path path ) {
- return new ConfigurationDefinition(source, workspace, path, context, classLoaderFactory);
+ return new ConfigurationDefinition(name, source, workspace, path, context, classLoaderFactory);
}
/**
@@ -1379,7 +1417,7 @@
* @return the new configuration
*/
public ConfigurationDefinition withWorkspace( String workspace ) {
- return new ConfigurationDefinition(source, workspace, path, context, classLoaderFactory);
+ return new ConfigurationDefinition(name, source, workspace, path, context, classLoaderFactory);
}
/**
@@ -1390,7 +1428,7 @@
* @return the new configuration
*/
public ConfigurationDefinition with( ClassLoaderFactory classLoaderFactory ) {
- return new ConfigurationDefinition(source, workspace, path, context, classLoaderFactory);
+ return new ConfigurationDefinition(name, source, workspace, path, context, classLoaderFactory);
}
/**
Modified: trunk/dna-repository/src/main/java/org/jboss/dna/repository/DnaEngine.java
===================================================================
--- trunk/dna-repository/src/main/java/org/jboss/dna/repository/DnaEngine.java 2009-12-16 21:06:41 UTC (rev 1450)
+++ trunk/dna-repository/src/main/java/org/jboss/dna/repository/DnaEngine.java 2009-12-17 20:38:21 UTC (rev 1451)
@@ -28,7 +28,8 @@
import java.util.Map;
import java.util.Set;
import java.util.concurrent.ExecutorService;
-import java.util.concurrent.ScheduledThreadPoolExecutor;
+import java.util.concurrent.Executors;
+import java.util.concurrent.ThreadFactory;
import java.util.concurrent.TimeUnit;
import net.jcip.annotations.Immutable;
import org.jboss.dna.common.collection.Problem;
@@ -36,6 +37,7 @@
import org.jboss.dna.common.collection.SimpleProblems;
import org.jboss.dna.common.util.CheckArg;
import org.jboss.dna.common.util.Logger;
+import org.jboss.dna.common.util.NamedThreadFactory;
import org.jboss.dna.graph.ExecutionContext;
import org.jboss.dna.graph.Graph;
import org.jboss.dna.graph.JcrLexicon;
@@ -119,7 +121,8 @@
configurationChangeBus.register(repositoryService);
// Create the sequencing service ...
- executorService = new ScheduledThreadPoolExecutor(10); // Use a magic number for now
+ ThreadFactory threadPoolFactory = new NamedThreadFactory(configuration.getName());
+ executorService = Executors.newScheduledThreadPool(10, threadPoolFactory);
sequencingService = new SequencingService();
sequencingService.setExecutionContext(context);
sequencingService.setExecutorService(executorService);
@@ -292,18 +295,13 @@
* @see #start()
*/
public void shutdown() {
+ // Then terminate the executor service, which may be running background jobs that are not yet completed
+ // and which will prevent new jobs being submitted (to the sequencing service) ...
+ executorService.shutdown();
+
// First, shutdown the sequencing service, which will prevent any additional jobs from going through ...
sequencingService.getAdministrator().shutdown();
- // Then terminate the executor service, which may be running background jobs that are not yet completed ...
- try {
- executorService.awaitTermination(10 * 60, TimeUnit.SECONDS); // No TimeUnit.MINUTES in JDK 5
- } catch (InterruptedException ie) {
- // Reset the thread's status and continue this method ...
- Thread.interrupted();
- }
- executorService.shutdown();
-
// Finally shut down the repository source, which closes all connections ...
repositoryService.getAdministrator().shutdown();
}
Modified: trunk/dna-repository/src/main/java/org/jboss/dna/repository/sequencer/SequencingService.java
===================================================================
--- trunk/dna-repository/src/main/java/org/jboss/dna/repository/sequencer/SequencingService.java 2009-12-16 21:06:41 UTC (rev 1450)
+++ trunk/dna-repository/src/main/java/org/jboss/dna/repository/sequencer/SequencingService.java 2009-12-17 20:38:21 UTC (rev 1451)
@@ -43,6 +43,7 @@
import org.jboss.dna.common.util.CheckArg;
import org.jboss.dna.common.util.HashCode;
import org.jboss.dna.common.util.Logger;
+import org.jboss.dna.common.util.NamedThreadFactory;
import org.jboss.dna.graph.ExecutionContext;
import org.jboss.dna.graph.Graph;
import org.jboss.dna.graph.Node;
@@ -327,7 +328,7 @@
* @return the executor service
*/
protected ExecutorService createDefaultExecutorService() {
- return Executors.newSingleThreadExecutor();
+ return Executors.newSingleThreadExecutor(new NamedThreadFactory("sequencing"));
}
protected void startService() {
14 years, 6 months