DNA SVN: r1037 - trunk/dna-graph/src/main/java/org/jboss/dna/graph/connector/federation.
by dna-commits@lists.jboss.org
Author: rhauch
Date: 2009-06-11 05:20:03 -0400 (Thu, 11 Jun 2009)
New Revision: 1037
Modified:
trunk/dna-graph/src/main/java/org/jboss/dna/graph/connector/federation/ForkRequestProcessor.java
Log:
DNA-449 Minor correction to the VerifyNodeExistsRequest processing within the federated connector.
Modified: trunk/dna-graph/src/main/java/org/jboss/dna/graph/connector/federation/ForkRequestProcessor.java
===================================================================
--- trunk/dna-graph/src/main/java/org/jboss/dna/graph/connector/federation/ForkRequestProcessor.java 2009-06-11 09:19:29 UTC (rev 1036)
+++ trunk/dna-graph/src/main/java/org/jboss/dna/graph/connector/federation/ForkRequestProcessor.java 2009-06-11 09:20:03 UTC (rev 1037)
@@ -696,9 +696,7 @@
if (projectedNode.isPlaceholder()) {
PlaceholderNode placeholder = projectedNode.asPlaceholder();
// Create a request and set the results ...
- ReadNodeRequest placeholderRequest = new ReadNodeRequest(request.at(), request.inWorkspace());
- placeholderRequest.addChildren(placeholder.children());
- placeholderRequest.addProperties(placeholder.properties().values());
+ VerifyNodeExistsRequest placeholderRequest = new VerifyNodeExistsRequest(request.at(), request.inWorkspace());
placeholderRequest.setActualLocationOfNode(placeholder.location());
federatedRequest.add(placeholderRequest, true, true, null);
} else if (projectedNode.isProxy()) {
14 years, 11 months
DNA SVN: r1036 - in trunk: docs/examples/gettingstarted/repositories/src/main/java/org/jboss/example/dna/repository and 2 other directories.
by dna-commits@lists.jboss.org
Author: rhauch
Date: 2009-06-11 05:19:29 -0400 (Thu, 11 Jun 2009)
New Revision: 1036
Modified:
trunk/dna-graph/src/main/java/org/jboss/dna/graph/connector/federation/ForkRequestProcessor.java
trunk/dna-graph/src/main/java/org/jboss/dna/graph/connector/federation/JoinRequestProcessor.java
trunk/docs/examples/gettingstarted/repositories/src/main/java/org/jboss/example/dna/repository/RepositoryClient.java
trunk/docs/examples/gettingstarted/repositories/src/main/resources/configRepository.xml
trunk/docs/examples/gettingstarted/repositories/src/test/java/org/jboss/example/dna/repository/RepositoryClientTest.java
trunk/docs/examples/gettingstarted/repositories/src/test/java/org/jboss/example/dna/repository/RepositoryClientUsingJcrTest.java
Log:
DNA-449 Additional fixes to get the repository example working. The Federated Connector's fork- and join-processors were not properly handling create requests, so that was fixed.
Modified: trunk/dna-graph/src/main/java/org/jboss/dna/graph/connector/federation/ForkRequestProcessor.java
===================================================================
--- trunk/dna-graph/src/main/java/org/jboss/dna/graph/connector/federation/ForkRequestProcessor.java 2009-06-10 21:23:19 UTC (rev 1035)
+++ trunk/dna-graph/src/main/java/org/jboss/dna/graph/connector/federation/ForkRequestProcessor.java 2009-06-11 09:19:29 UTC (rev 1036)
@@ -50,6 +50,7 @@
import org.jboss.dna.graph.property.DateTime;
import org.jboss.dna.graph.property.Name;
import org.jboss.dna.graph.property.Path;
+import org.jboss.dna.graph.property.PathFactory;
import org.jboss.dna.graph.property.PathNotFoundException;
import org.jboss.dna.graph.property.Property;
import org.jboss.dna.graph.request.CloneWorkspaceRequest;
@@ -70,6 +71,7 @@
import org.jboss.dna.graph.request.ReadNodeRequest;
import org.jboss.dna.graph.request.ReadPropertyRequest;
import org.jboss.dna.graph.request.Request;
+import org.jboss.dna.graph.request.SetPropertyRequest;
import org.jboss.dna.graph.request.UnsupportedRequestException;
import org.jboss.dna.graph.request.UpdatePropertiesRequest;
import org.jboss.dna.graph.request.VerifyNodeExistsRequest;
@@ -933,6 +935,7 @@
FederatedRequest federatedRequest = new FederatedRequest(request);
// Any non-read request should be submitted to the first ProxyNode ...
+ PlaceholderNode placeholder = null;
while (projectedNode != null) {
if (projectedNode.isProxy()) {
ProxyNode proxy = projectedNode.asProxy();
@@ -947,9 +950,48 @@
return;
}
assert projectedNode.isPlaceholder();
+ if (placeholder == null) placeholder = projectedNode.asPlaceholder();
projectedNode = projectedNode.next();
}
- // Unable to perform this create ...
+
+ // At this point, we know the parent node is a placeholder, so we cannot create children.
+ // What we don't know, though, is whether there is an existing child at the desired location.
+ if (placeholder != null) {
+ switch (request.conflictBehavior()) {
+ case UPDATE:
+ case DO_NOT_REPLACE:
+ // See if there is an existing node at the desired location ...
+ Location parent = request.under();
+ if (parent.hasPath()) {
+ PathFactory pathFactory = getExecutionContext().getValueFactories().getPathFactory();
+ Path childPath = pathFactory.create(parent.getPath(), request.named());
+ Location childLocation = Location.create(childPath);
+ projectedNode = project(childLocation, request.inWorkspace(), request, true);
+ if (projectedNode != null) {
+ if (projectedNode.isProxy()) {
+ ProxyNode proxy = projectedNode.asProxy();
+
+ // We know that the parent is a placeholder, so this proxy node must exist, so do a read ...
+ ReadNodeRequest pushDownRequest = new ReadNodeRequest(proxy.location(), proxy.workspaceName());
+ federatedRequest.add(pushDownRequest, proxy.isSameLocationAsOriginal(), false, proxy.projection());
+
+ // Submit the requests for processing and then STOP ...
+ submit(federatedRequest);
+ return;
+ }
+ // The node does exist, so set the location ...
+ assert projectedNode.isPlaceholder();
+ request.setActualLocationOfNode(projectedNode.location());
+ return;
+ }
+ }
+ break;
+ case APPEND:
+ case REPLACE:
+ // Unable to perform this create ...
+ break;
+ }
+ }
String msg = GraphI18n.unableToCreateNodeUnderPlaceholder.text(readable(request.named()),
readable(request.under()),
request.inWorkspace(),
@@ -995,6 +1037,41 @@
/**
* {@inheritDoc}
*
+ * @see org.jboss.dna.graph.request.processor.RequestProcessor#process(org.jboss.dna.graph.request.SetPropertyRequest)
+ */
+ @Override
+ public void process( SetPropertyRequest request ) {
+ // Figure out where this request is projected ...
+ ProjectedNode projectedNode = project(request.on(), request.inWorkspace(), request, true);
+ if (projectedNode == null) return;
+
+ // Create the federated request ...
+ FederatedRequest federatedRequest = new FederatedRequest(request);
+
+ // Any non-read request should be submitted to the first ProxyNode ...
+ while (projectedNode != null) {
+ if (projectedNode.isProxy()) {
+ ProxyNode proxy = projectedNode.asProxy();
+ // Create and submit a request for the projection ...
+ SetPropertyRequest pushDownRequest = new SetPropertyRequest(proxy.location(), proxy.workspaceName(),
+ request.property());
+ federatedRequest.add(pushDownRequest, proxy.isSameLocationAsOriginal(), false, proxy.projection());
+
+ // Submit the requests for processing and then STOP ...
+ submit(federatedRequest);
+ return;
+ }
+ assert projectedNode.isPlaceholder();
+ projectedNode = projectedNode.next();
+ }
+ // Unable to perform this update ...
+ String msg = GraphI18n.unableToUpdatePlaceholder.text(readable(request.on()), request.inWorkspace(), getSourceName());
+ request.setError(new UnsupportedRequestException(msg));
+ }
+
+ /**
+ * {@inheritDoc}
+ *
* @see org.jboss.dna.graph.request.processor.RequestProcessor#process(org.jboss.dna.graph.request.DeleteBranchRequest)
*/
@Override
Modified: trunk/dna-graph/src/main/java/org/jboss/dna/graph/connector/federation/JoinRequestProcessor.java
===================================================================
--- trunk/dna-graph/src/main/java/org/jboss/dna/graph/connector/federation/JoinRequestProcessor.java 2009-06-10 21:23:19 UTC (rev 1035)
+++ trunk/dna-graph/src/main/java/org/jboss/dna/graph/connector/federation/JoinRequestProcessor.java 2009-06-11 09:19:29 UTC (rev 1036)
@@ -61,6 +61,7 @@
import org.jboss.dna.graph.request.ReadNodeRequest;
import org.jboss.dna.graph.request.ReadPropertyRequest;
import org.jboss.dna.graph.request.Request;
+import org.jboss.dna.graph.request.SetPropertyRequest;
import org.jboss.dna.graph.request.UpdatePropertiesRequest;
import org.jboss.dna.graph.request.VerifyNodeExistsRequest;
import org.jboss.dna.graph.request.VerifyWorkspaceRequest;
@@ -678,9 +679,22 @@
public void process( CreateNodeRequest request ) {
ProjectedRequest projected = federatedRequest.getFirstProjectedRequest();
assert !projected.hasNext();
- CreateNodeRequest source = (CreateNodeRequest)projected.getRequest();
- if (checkErrorOrCancel(request, source)) return;
- Location sourceLocation = source.getActualLocationOfNode();
+ Request projectedRequest = projected.getRequest();
+ // Check the error first ...
+ if (checkErrorOrCancel(request, projectedRequest)) return;
+
+ // No error, so project the results back to the federated repository ...
+ Location sourceLocation = null;
+ if (projectedRequest instanceof CreateNodeRequest) {
+ CreateNodeRequest source = (CreateNodeRequest)projectedRequest;
+ sourceLocation = source.getActualLocationOfNode();
+ } else if (projectedRequest instanceof ReadNodeRequest) {
+ // In this case, the original request was to create the node only if it was missing,
+ // but we knew it already exists because the parent was a placeholder and the child
+ // mapped to an existing proxy node. Therefore, record the location...
+ ReadNodeRequest source = (ReadNodeRequest)projectedRequest;
+ sourceLocation = source.getActualLocationOfNode();
+ }
request.setActualLocationOfNode(projectToFederated(request.under(), projected.getProjection(), sourceLocation, request));
}
@@ -702,6 +716,21 @@
/**
* {@inheritDoc}
*
+ * @see org.jboss.dna.graph.request.processor.RequestProcessor#process(org.jboss.dna.graph.request.SetPropertyRequest)
+ */
+ @Override
+ public void process( SetPropertyRequest request ) {
+ ProjectedRequest projected = federatedRequest.getFirstProjectedRequest();
+ assert !projected.hasNext();
+ SetPropertyRequest source = (SetPropertyRequest)projected.getRequest();
+ if (checkErrorOrCancel(request, source)) return;
+ Location sourceLocation = source.getActualLocationOfNode();
+ request.setActualLocationOfNode(projectToFederated(request.on(), projected.getProjection(), sourceLocation, request));
+ }
+
+ /**
+ * {@inheritDoc}
+ *
* @see org.jboss.dna.graph.request.processor.RequestProcessor#process(org.jboss.dna.graph.request.DeleteBranchRequest)
*/
@Override
Modified: trunk/docs/examples/gettingstarted/repositories/src/main/java/org/jboss/example/dna/repository/RepositoryClient.java
===================================================================
--- trunk/docs/examples/gettingstarted/repositories/src/main/java/org/jboss/example/dna/repository/RepositoryClient.java 2009-06-10 21:23:19 UTC (rev 1035)
+++ trunk/docs/examples/gettingstarted/repositories/src/main/java/org/jboss/example/dna/repository/RepositoryClient.java 2009-06-11 09:19:29 UTC (rev 1036)
@@ -62,7 +62,7 @@
public class RepositoryClient {
public static final String INMEMORY_REPOSITORY_SOURCE_CLASSNAME = "org.jboss.dna.connector.inmemory.InMemoryRepositorySource";
- public static final String JAAS_LOGIN_CONTEXT_NAME = "dna-repository-example";
+ public static final String JAAS_LOGIN_CONTEXT_NAME = "dna-jcr";
/**
* @param args
@@ -96,7 +96,7 @@
}
private Api api = Api.JCR;
- private String jaasContextName;
+ private String jaasContextName = JAAS_LOGIN_CONTEXT_NAME;
private UserInterface userInterface;
private LoginContext loginContext;
private JcrEngine engine;
Modified: trunk/docs/examples/gettingstarted/repositories/src/main/resources/configRepository.xml
===================================================================
--- trunk/docs/examples/gettingstarted/repositories/src/main/resources/configRepository.xml 2009-06-10 21:23:19 UTC (rev 1035)
+++ trunk/docs/examples/gettingstarted/repositories/src/main/resources/configRepository.xml 2009-06-11 09:19:29 UTC (rev 1036)
@@ -68,10 +68,18 @@
<dna:projection jcr:name="Aircarft projection" dna:source="Aircraft" dna:workspaceName="workspace2">
<dna:projectionRules>/Vehicles/Aircraft => /Aircraft</dna:projectionRules>
</dna:projection>
+ <!-- Project the 'System' content. Only needed when this source is accessed through JCR. -->
+ <dna:projection jcr:name="System projection" dna:source="System" dna:workspaceName="default">
+ <dna:projectionRules>/jcr:system => /</dna:projectionRules>
+ </dna:projection>
</dna:projections>
</dna:workspace>
</dna:workspaces>
</dna:source>
+ <!--
+ A 'System' source needed for the '/jcr:system' branch of the Vehicles source when it is access through JCR.
+ -->
+ <dna:source jcr:name="System" dna:classname="org.jboss.dna.graph.connector.inmemory.InMemoryRepositorySource" dna:retryLimit="3" dna:defaultWorkspaceName="default"/>
</dna:sources>
<!--
Define the sequencers. This is an optional section. For this example, we're not using any sequencers.
Modified: trunk/docs/examples/gettingstarted/repositories/src/test/java/org/jboss/example/dna/repository/RepositoryClientTest.java
===================================================================
--- trunk/docs/examples/gettingstarted/repositories/src/test/java/org/jboss/example/dna/repository/RepositoryClientTest.java 2009-06-10 21:23:19 UTC (rev 1035)
+++ trunk/docs/examples/gettingstarted/repositories/src/test/java/org/jboss/example/dna/repository/RepositoryClientTest.java 2009-06-11 09:19:29 UTC (rev 1036)
@@ -32,6 +32,9 @@
import java.util.HashMap;
import java.util.List;
import java.util.Map;
+import javax.security.auth.callback.CallbackHandler;
+import org.jboss.dna.graph.JaasSecurityContext;
+import org.jboss.security.config.IDTrustConfiguration;
import org.junit.After;
import org.junit.Before;
import org.junit.Ignore;
@@ -63,6 +66,17 @@
stub(userInterface.getLocationOfRepositoryFiles()).toReturn(new File("src/main/resources").getAbsolutePath());
stub(userInterface.getLocationOfCndFiles()).toReturn(new File("src/main/resources").getAbsolutePath());
stub(userInterface.getRepositoryConfiguration()).toReturn(new File("src/main/resources/configRepository.xml"));
+
+ // Set up the JAAS provider (IDTrust) and a policy file (which defines the "dna-jcr" login config name)
+ IDTrustConfiguration idtrustConfig = new IDTrustConfiguration();
+ try {
+ idtrustConfig.config("security/jaas.conf.xml");
+ } catch (Exception ex) {
+ throw new IllegalStateException(ex);
+ }
+
+ CallbackHandler handler = new JaasSecurityContext.UserPasswordCallbackHandler("jsmith", "secret".toCharArray());
+ stub(userInterface.getCallbackHandler()).toReturn(handler);
}
@After
Modified: trunk/docs/examples/gettingstarted/repositories/src/test/java/org/jboss/example/dna/repository/RepositoryClientUsingJcrTest.java
===================================================================
--- trunk/docs/examples/gettingstarted/repositories/src/test/java/org/jboss/example/dna/repository/RepositoryClientUsingJcrTest.java 2009-06-10 21:23:19 UTC (rev 1035)
+++ trunk/docs/examples/gettingstarted/repositories/src/test/java/org/jboss/example/dna/repository/RepositoryClientUsingJcrTest.java 2009-06-11 09:19:29 UTC (rev 1036)
@@ -24,12 +24,19 @@
package org.jboss.example.dna.repository;
import org.jboss.example.dna.repository.RepositoryClient.Api;
+import org.junit.Before;
/**
* @author Randall Hauch
*/
public class RepositoryClientUsingJcrTest extends RepositoryClientTest {
+ @Before
+ @Override
+ public void beforeEach() {
+ super.beforeEach();
+ }
+
/**
* {@inheritDoc}
*
14 years, 11 months
DNA SVN: r1035 - in trunk: dna-graph/src/main/java/org/jboss/dna/graph/connector/federation and 8 other directories.
by dna-commits@lists.jboss.org
Author: rhauch
Date: 2009-06-10 17:23:19 -0400 (Wed, 10 Jun 2009)
New Revision: 1035
Added:
trunk/docs/examples/gettingstarted/repositories/src/main/resources/vehicles.cnd
Removed:
trunk/dna-graph/src/main/java/org/jboss/dna/graph/connector/federation/FederatedLexicon.java
trunk/docs/examples/gettingstarted/repositories/src/main/resources/virtual.cnd
Modified:
trunk/dna-graph/src/main/java/org/jboss/dna/graph/DnaLexicon.java
trunk/dna-graph/src/main/java/org/jboss/dna/graph/ExecutionContext.java
trunk/dna-graph/src/main/java/org/jboss/dna/graph/Location.java
trunk/dna-graph/src/main/java/org/jboss/dna/graph/connector/federation/BranchedMirrorProjector.java
trunk/dna-graph/src/main/java/org/jboss/dna/graph/connector/federation/FederatedRepositoryConnection.java
trunk/dna-graph/src/main/java/org/jboss/dna/graph/connector/federation/ForkRequestProcessor.java
trunk/dna-graph/src/test/java/org/jboss/dna/graph/connector/federation/AbstractFederatedRepositorySourceIntegrationTest.java
trunk/dna-graph/src/test/java/org/jboss/dna/graph/connector/federation/FederatedRepositorySourceTest.java
trunk/dna-jcr/src/test/resources/config/configRepository.xml
trunk/dna-repository/src/main/java/org/jboss/dna/repository/RepositoryLibrary.java
trunk/docs/examples/gettingstarted/repositories/src/main/java/org/jboss/example/dna/repository/RepositoryClient.java
trunk/docs/examples/gettingstarted/repositories/src/main/resources/aircraft.xml
trunk/docs/examples/gettingstarted/repositories/src/main/resources/cars.xml
trunk/docs/examples/gettingstarted/repositories/src/main/resources/configRepository.xml
trunk/docs/examples/gettingstarted/repositories/src/test/java/org/jboss/example/dna/repository/RepositoryClientTest.java
trunk/docs/gettingstarted/src/main/docbook/en-US/content/downloading_and_running.xml
trunk/docs/gettingstarted/src/main/docbook/en-US/content/repository_example.xml
trunk/docs/gettingstarted/src/main/docbook/en-US/content/using_dna.xml
trunk/docs/reference/src/main/docbook/en-US/content/jcr/configuration.xml
Log:
DNA-449 Federation connector does not find it's configuration when imported using the JcrConfiguration
Quite a few relatively minor tweaks, all related to getting the federated repository source recognizing and reading its configuration.
Modified: trunk/dna-graph/src/main/java/org/jboss/dna/graph/DnaLexicon.java
===================================================================
--- trunk/dna-graph/src/main/java/org/jboss/dna/graph/DnaLexicon.java 2009-06-10 21:22:34 UTC (rev 1034)
+++ trunk/dna-graph/src/main/java/org/jboss/dna/graph/DnaLexicon.java 2009-06-10 21:23:19 UTC (rev 1035)
@@ -47,7 +47,7 @@
public static final Name NAMESPACE_URI = new BasicName(Namespace.URI, "uri");
public static final Name WORKSPACES = new BasicName(Namespace.URI, "workspaces");
- public static final Name SOURCE_NAME = new BasicName(Namespace.URI, "sourceName");
+ public static final Name SOURCE_NAME = new BasicName(Namespace.URI, "source");
public static final Name WORKSPACE_NAME = new BasicName(Namespace.URI, "workspaceName");
public static final Name DEFAULT_WORKSPACE_NAME = new BasicName(Namespace.URI, "defaultWorkspaceName");
public static final Name PROJECTION = new BasicName(Namespace.URI, "projection");
Modified: trunk/dna-graph/src/main/java/org/jboss/dna/graph/ExecutionContext.java
===================================================================
--- trunk/dna-graph/src/main/java/org/jboss/dna/graph/ExecutionContext.java 2009-06-10 21:22:34 UTC (rev 1034)
+++ trunk/dna-graph/src/main/java/org/jboss/dna/graph/ExecutionContext.java 2009-06-10 21:23:19 UTC (rev 1035)
@@ -31,7 +31,6 @@
import org.jboss.dna.common.component.StandardClassLoaderFactory;
import org.jboss.dna.common.util.CheckArg;
import org.jboss.dna.common.util.Logger;
-import org.jboss.dna.graph.connector.federation.FederatedLexicon;
import org.jboss.dna.graph.mimetype.ExtensionBasedMimeTypeDetector;
import org.jboss.dna.graph.mimetype.MimeTypeDetector;
import org.jboss.dna.graph.property.NamespaceRegistry;
@@ -328,7 +327,6 @@
namespaceRegistry.register(JcrMixLexicon.Namespace.PREFIX, JcrMixLexicon.Namespace.URI);
namespaceRegistry.register(JcrNtLexicon.Namespace.PREFIX, JcrNtLexicon.Namespace.URI);
namespaceRegistry.register(DnaLexicon.Namespace.PREFIX, DnaLexicon.Namespace.URI);
- namespaceRegistry.register(FederatedLexicon.Namespace.PREFIX, DnaLexicon.Namespace.URI);
// namespaceRegistry.register("dnadtd", "http://www.jboss.org/dna/dtd/1.0");
// namespaceRegistry.register("dnaxml", "http://www.jboss.org/dna/xml/1.0");
}
Modified: trunk/dna-graph/src/main/java/org/jboss/dna/graph/Location.java
===================================================================
--- trunk/dna-graph/src/main/java/org/jboss/dna/graph/Location.java 2009-06-10 21:22:34 UTC (rev 1034)
+++ trunk/dna-graph/src/main/java/org/jboss/dna/graph/Location.java 2009-06-10 21:23:19 UTC (rev 1035)
@@ -577,7 +577,7 @@
}
sb.append("]");
if (hasPath) {
- sb.append("<");
+ sb.append(">");
}
}
return sb.toString();
Modified: trunk/dna-graph/src/main/java/org/jboss/dna/graph/connector/federation/BranchedMirrorProjector.java
===================================================================
--- trunk/dna-graph/src/main/java/org/jboss/dna/graph/connector/federation/BranchedMirrorProjector.java 2009-06-10 21:22:34 UTC (rev 1034)
+++ trunk/dna-graph/src/main/java/org/jboss/dna/graph/connector/federation/BranchedMirrorProjector.java 2009-06-10 21:23:19 UTC (rev 1035)
@@ -71,13 +71,16 @@
if (firstTopLevelPaths.size() != 1) return null;
List<Path> secondTopLevelPaths = second.getRules().get(0).getTopLevelPathsInRepository(pathFactory);
if (secondTopLevelPaths.size() != 1) return null;
- // We're good, so create the instance ...
Path firstTopLevelPath = firstTopLevelPaths.get(0);
Path secondTopLevelPath = secondTopLevelPaths.get(0);
if (firstTopLevelPath.isRoot()) {
+ // We're good, so create the instance ...
return new BranchedMirrorProjector(context, projections, first, second, secondTopLevelPath,
secondRule.getPathInSource(secondTopLevelPath, pathFactory));
}
+ // the second top-level path must be a root ...
+ if (!secondTopLevelPath.isRoot()) return null;
+ // We're good, so create the instance ...
return new BranchedMirrorProjector(context, projections, second, first, firstTopLevelPath,
firstRule.getPathInSource(firstTopLevelPath, pathFactory));
}
Deleted: trunk/dna-graph/src/main/java/org/jboss/dna/graph/connector/federation/FederatedLexicon.java
===================================================================
--- trunk/dna-graph/src/main/java/org/jboss/dna/graph/connector/federation/FederatedLexicon.java 2009-06-10 21:22:34 UTC (rev 1034)
+++ trunk/dna-graph/src/main/java/org/jboss/dna/graph/connector/federation/FederatedLexicon.java 2009-06-10 21:23:19 UTC (rev 1035)
@@ -1,42 +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.graph.connector.federation;
-
-import org.jboss.dna.graph.DnaLexicon;
-import org.jboss.dna.graph.property.Name;
-import org.jboss.dna.graph.property.basic.BasicName;
-
-/**
- * @author Randall Hauch
- */
-public class FederatedLexicon extends DnaLexicon {
-
- public static final Name WORKSPACES = new BasicName(Namespace.URI, "workspaces");
- public static final Name CACHE = new BasicName(Namespace.URI, "cache");
- public static final Name PROJECTION = new BasicName(Namespace.URI, "projection");
- public static final Name PROJECTIONS = new BasicName(Namespace.URI, "projections");
- public static final Name SOURCE_NAME = new BasicName(Namespace.URI, "sourceName");
- public static final Name WORKSPACE_NAME = new BasicName(Namespace.URI, "workspaceName");
- public static final Name DEFAULT_WORKSPACE_NAME = new BasicName(Namespace.URI, "defaultWorkspaceName");
-}
Modified: trunk/dna-graph/src/main/java/org/jboss/dna/graph/connector/federation/FederatedRepositoryConnection.java
===================================================================
--- trunk/dna-graph/src/main/java/org/jboss/dna/graph/connector/federation/FederatedRepositoryConnection.java 2009-06-10 21:22:34 UTC (rev 1034)
+++ trunk/dna-graph/src/main/java/org/jboss/dna/graph/connector/federation/FederatedRepositoryConnection.java 2009-06-10 21:23:19 UTC (rev 1035)
@@ -156,7 +156,7 @@
// Figure out whether we should asynchronously do the forking ...
boolean synchronousStep1 = shouldProcessSynchronously(request);
- final boolean awaitAllSubtasks = false;
+ final boolean awaitAllSubtasks = true;
// Prepare for trace-level logging ...
if (stopwatch != null) stopwatch.start();
Modified: trunk/dna-graph/src/main/java/org/jboss/dna/graph/connector/federation/ForkRequestProcessor.java
===================================================================
--- trunk/dna-graph/src/main/java/org/jboss/dna/graph/connector/federation/ForkRequestProcessor.java 2009-06-10 21:22:34 UTC (rev 1034)
+++ trunk/dna-graph/src/main/java/org/jboss/dna/graph/connector/federation/ForkRequestProcessor.java 2009-06-10 21:23:19 UTC (rev 1035)
@@ -329,6 +329,7 @@
*/
public String call() throws Exception {
final RepositoryConnection connection = connectionFactory.createConnection(sourceName);
+ assert connection != null;
try {
connection.execute(context, composite);
} finally {
@@ -1129,7 +1130,10 @@
if (projectedFromNode == null) return;
ProjectedNode projectedIntoNode = project(request.into(), request.inWorkspace(), request, true);
if (projectedIntoNode == null) return;
- ProjectedNode projectedBeforeNode = request.before() != null ? project(request.before(), request.inWorkspace(), request, true) : null;
+ ProjectedNode projectedBeforeNode = request.before() != null ? project(request.before(),
+ request.inWorkspace(),
+ request,
+ true) : null;
// Limitation: only able to project the move if the 'from' and 'into' are in the same source & projection ...
while (projectedFromNode != null) {
@@ -1166,8 +1170,9 @@
boolean sameLocation = fromProxy.isSameLocationAsOriginal() && intoProxy.isSameLocationAsOriginal();
// Create the pushed-down request ...
- MoveBranchRequest pushDown = new MoveBranchRequest(fromProxy.location(), intoProxy.location(), beforeProxy.location(), intoProxy.workspaceName(),
- request.desiredName(), request.conflictBehavior());
+ MoveBranchRequest pushDown = new MoveBranchRequest(fromProxy.location(), intoProxy.location(), beforeProxy.location(),
+ intoProxy.workspaceName(), request.desiredName(),
+ request.conflictBehavior());
// Create the federated request ...
FederatedRequest federatedRequest = new FederatedRequest(request);
federatedRequest.add(pushDown, sameLocation, false, fromProxy.projection(), intoProxy.projection());
Modified: trunk/dna-graph/src/test/java/org/jboss/dna/graph/connector/federation/AbstractFederatedRepositorySourceIntegrationTest.java
===================================================================
--- trunk/dna-graph/src/test/java/org/jboss/dna/graph/connector/federation/AbstractFederatedRepositorySourceIntegrationTest.java 2009-06-10 21:22:34 UTC (rev 1034)
+++ trunk/dna-graph/src/test/java/org/jboss/dna/graph/connector/federation/AbstractFederatedRepositorySourceIntegrationTest.java 2009-06-10 21:23:19 UTC (rev 1035)
@@ -33,6 +33,7 @@
import java.util.Map;
import org.jboss.dna.common.statistic.Stopwatch;
import org.jboss.dna.common.util.CheckArg;
+import org.jboss.dna.graph.DnaLexicon;
import org.jboss.dna.graph.ExecutionContext;
import org.jboss.dna.graph.Graph;
import org.jboss.dna.graph.Location;
@@ -180,9 +181,9 @@
config.createIfMissing(wsPath);
config.createIfMissing(wsPath + "/dna:projections");
config.createAt(projectionPath)
- .with(FederatedLexicon.PROJECTION_RULES, (Object[])projectionRules)
- .with(FederatedLexicon.SOURCE_NAME, sourceName)
- .with(FederatedLexicon.WORKSPACE_NAME, workspaceName)
+ .with(DnaLexicon.PROJECTION_RULES, (Object[])projectionRules)
+ .with(DnaLexicon.SOURCE_NAME, sourceName)
+ .with(DnaLexicon.WORKSPACE_NAME, workspaceName)
.and();
// Make sure the source and workspace exist ...
graphFor(sourceName, workspaceName);
Modified: trunk/dna-graph/src/test/java/org/jboss/dna/graph/connector/federation/FederatedRepositorySourceTest.java
===================================================================
--- trunk/dna-graph/src/test/java/org/jboss/dna/graph/connector/federation/FederatedRepositorySourceTest.java 2009-06-10 21:22:34 UTC (rev 1034)
+++ trunk/dna-graph/src/test/java/org/jboss/dna/graph/connector/federation/FederatedRepositorySourceTest.java 2009-06-10 21:23:19 UTC (rev 1035)
@@ -40,6 +40,7 @@
import javax.naming.Reference;
import javax.naming.spi.ObjectFactory;
import javax.security.auth.callback.CallbackHandler;
+import org.jboss.dna.graph.DnaLexicon;
import org.jboss.dna.graph.ExecutionContext;
import org.jboss.dna.graph.Graph;
import org.jboss.dna.graph.Subgraph;
@@ -118,25 +119,25 @@
Graph.Batch batch = configRepository.batch();
batch.create("/a").and();
batch.create("/a/b").and();
- batch.create("/a/b/Test Repository").with(FederatedLexicon.DEFAULT_WORKSPACE_NAME, "fedSpace").and();
+ batch.create("/a/b/Test Repository").with(DnaLexicon.DEFAULT_WORKSPACE_NAME, "fedSpace").and();
batch.create("/a/b/Test Repository/dna:workspaces").and();
batch.create("/a/b/Test Repository/dna:workspaces/fedSpace").and();
batch.create("/a/b/Test Repository/dna:workspaces/fedSpace/dna:cache")
- .with(FederatedLexicon.PROJECTION_RULES, "/ => /")
- .with(FederatedLexicon.SOURCE_NAME, "cache source")
- .with(FederatedLexicon.WORKSPACE_NAME, "cacheSpace")
- .with(FederatedLexicon.TIME_TO_EXPIRE, 100000)
+ .with(DnaLexicon.PROJECTION_RULES, "/ => /")
+ .with(DnaLexicon.SOURCE_NAME, "cache source")
+ .with(DnaLexicon.WORKSPACE_NAME, "cacheSpace")
+ .with(DnaLexicon.TIME_TO_EXPIRE, 100000)
.and();
batch.create("/a/b/Test Repository/dna:workspaces/fedSpace/dna:projections").and();
batch.create("/a/b/Test Repository/dna:workspaces/fedSpace/dna:projections/projection1")
- .with(FederatedLexicon.PROJECTION_RULES, "/ => /s1")
- .with(FederatedLexicon.SOURCE_NAME, "source 1")
- .with(FederatedLexicon.WORKSPACE_NAME, "s1 workspace")
+ .with(DnaLexicon.PROJECTION_RULES, "/ => /s1")
+ .with(DnaLexicon.SOURCE_NAME, "source 1")
+ .with(DnaLexicon.WORKSPACE_NAME, "s1 workspace")
.and();
batch.create("/a/b/Test Repository/dna:workspaces/fedSpace/dna:projections/projection2")
- .with(FederatedLexicon.PROJECTION_RULES, "/ => /s2")
- .with(FederatedLexicon.SOURCE_NAME, "source 2")
- .with(FederatedLexicon.WORKSPACE_NAME, "s2 worskspace")
+ .with(DnaLexicon.PROJECTION_RULES, "/ => /s2")
+ .with(DnaLexicon.SOURCE_NAME, "source 2")
+ .with(DnaLexicon.WORKSPACE_NAME, "s2 worskspace")
.and();
batch.execute();
Modified: trunk/dna-jcr/src/test/resources/config/configRepository.xml
===================================================================
--- trunk/dna-jcr/src/test/resources/config/configRepository.xml 2009-06-10 21:22:34 UTC (rev 1034)
+++ trunk/dna-jcr/src/test/resources/config/configRepository.xml 2009-06-10 21:23:19 UTC (rev 1035)
@@ -66,7 +66,7 @@
</dna:mimeTypeDetectors>
<!-- JCR Repositories. This is required, with a separate repository for each JCR repository instance. -->
<dna:repositories>
- <dna:repository jcr:name="Car Repository" dna:sourceName="Cars">
+ <dna:repository jcr:name="Car Repository" dna:source="Cars">
<dna:options>
<dna:option jcr:name="projectNodeTypes" dna:value="true"/>
<dna:option jcr:name="jaasLoginConfigName" dna:value="dna-jcr"/>
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-06-10 21:22:34 UTC (rev 1034)
+++ trunk/dna-repository/src/main/java/org/jboss/dna/repository/RepositoryLibrary.java 2009-06-10 21:23:19 UTC (rev 1035)
@@ -373,7 +373,7 @@
* @see org.jboss.dna.graph.connector.RepositoryContext#getExecutionContext()
*/
public ExecutionContext getExecutionContext() {
- return getExecutionContext();
+ return RepositoryLibrary.this.getExecutionContext();
}
/**
Modified: trunk/docs/examples/gettingstarted/repositories/src/main/java/org/jboss/example/dna/repository/RepositoryClient.java
===================================================================
--- trunk/docs/examples/gettingstarted/repositories/src/main/java/org/jboss/example/dna/repository/RepositoryClient.java 2009-06-10 21:22:34 UTC (rev 1034)
+++ trunk/docs/examples/gettingstarted/repositories/src/main/java/org/jboss/example/dna/repository/RepositoryClient.java 2009-06-10 21:23:19 UTC (rev 1035)
@@ -99,7 +99,6 @@
private String jaasContextName;
private UserInterface userInterface;
private LoginContext loginContext;
- private ExecutionContext context;
private JcrEngine engine;
/**
@@ -144,9 +143,9 @@
// in the configuration file, but this approach is easy and allows us to define the node types
// using the CND format in one or multiple files.
String locationOfCndFiles = userInterface.getLocationOfCndFiles();
- configuration.repository("aircraft repository").addNodeTypes(locationOfCndFiles + "/aircraft.cnd");
- configuration.repository("car repository").addNodeTypes(locationOfCndFiles + "/cars.cnd");
- configuration.repository("virtual").addNodeTypes(locationOfCndFiles + "/virtual.cnd");
+ configuration.repository("Aircraft").addNodeTypes(locationOfCndFiles + "/aircraft.cnd");
+ configuration.repository("Car").addNodeTypes(locationOfCndFiles + "/cars.cnd");
+ configuration.repository("Vehicles").addNodeTypes(locationOfCndFiles + "/vehicles.cnd");
// Now create the JCR engine ...
engine = configuration.build();
@@ -157,11 +156,9 @@
// populate these repositories here by importing from files. First do the configuration repository ...
String location = this.userInterface.getLocationOfRepositoryFiles();
- // Now import the content for the two in-memory repositories ...
- Graph cars = engine.getGraph("Cars");
- cars.importXmlFrom(location + "/cars.xml").into("/");
- Graph aircraft = engine.getGraph("Aircraft");
- aircraft.importXmlFrom(location + "/aircraft.xml").into("/");
+ // Now import the content for the two in-memory repository sources ...
+ engine.getGraph("Cars").importXmlFrom(location + "/cars.xml").into("/");
+ engine.getGraph("Aircraft").importXmlFrom(location + "/aircraft.xml").into("/");
}
/**
@@ -307,13 +304,12 @@
case DNA: {
try {
// Use the DNA Graph API to read the properties and children of the node ...
- ExecutionContext context = this.context;
+ ExecutionContext context = this.engine.getExecutionContext();
if (loginContext != null) {
JaasSecurityContext security = new JaasSecurityContext(loginContext);
- context = this.context.with(security);
+ context = context.with(security);
}
Graph graph = engine.getGraph(context, sourceName);
- graph.useWorkspace("default");
org.jboss.dna.graph.Node node = graph.getNodeAt(pathToNode);
if (properties != null) {
@@ -351,6 +347,7 @@
String input ) {
if (current == null) current = "/";
if (input == null || input.length() == 0) return current;
+ ExecutionContext context = this.engine.getExecutionContext();
PathFactory factory = context.getValueFactories().getPathFactory();
Path inputPath = factory.create(input);
if (inputPath.isAbsolute()) {
Modified: trunk/docs/examples/gettingstarted/repositories/src/main/resources/aircraft.xml
===================================================================
--- trunk/docs/examples/gettingstarted/repositories/src/main/resources/aircraft.xml 2009-06-10 21:22:34 UTC (rev 1034)
+++ trunk/docs/examples/gettingstarted/repositories/src/main/resources/aircraft.xml 2009-06-10 21:23:19 UTC (rev 1035)
@@ -24,31 +24,33 @@
~ 51 Franklin Street, Fifth Floor
~ Boston, MA 02110-1301 USA
-->
-<Aircraft xmlns:jcr="http://www.jcp.org/jcr/1.0" xmlns:nt="http://www.jcp.org/jcr/nt/1.0" xmlns="http://jboss.org/dna/examples/aircraft/1.0">
- <Business>
- <Aircraft jcr:name="Gulfstream V" maker="Gulfstream" model="G-V" introduced="1995" range="5800nm" cruiseSpeed="488kt" crew="2" emptyWeight="46200lb" url="http://en.wikipedia.org/wiki/Gulfstream_V"/>
- <Aircraft jcr:name="Learjet 45" maker="Learjet" model="LJ45" introduced="1995" numberBuilt="264+" crew="2" emptyWeight="13695lb" range="2120nm" cruiseSpeed="457kt" url="http://en.wikipedia.org/wiki/Learjet_45"/>
+<Aircraft xmlns:jcr="http://www.jcp.org/jcr/1.0"
+ xmlns:nt="http://www.jcp.org/jcr/nt/1.0"
+ xmlns:air="http://jboss.org/dna/examples/aircraft/1.0" jcr:primaryType="nt:unstructured">
+ <Business jcr:primaryType="nt:unstructured">
+ <air:Aircraft jcr:name="Gulfstream V" maker="Gulfstream" model="G-V" introduced="1995" range="5800nm" cruiseSpeed="488kt" crew="2" emptyWeight="46200lb" url="http://en.wikipedia.org/wiki/Gulfstream_V"/>
+ <air:Aircraft jcr:name="Learjet 45" maker="Learjet" model="LJ45" introduced="1995" numberBuilt="264+" crew="2" emptyWeight="13695lb" range="2120nm" cruiseSpeed="457kt" url="http://en.wikipedia.org/wiki/Learjet_45"/>
</Business>
- <Commercial>
- <Aircraft jcr:name="Boeing 777" maker="Boeing" model="777-200LR" introduced="1995" numberBuilt="731+" maxRange="7500nm" emptyWeight="326000lb" cruiseSpeed="560mph" url="http://en.wikipedia.org/wiki/Boeing_777"/>
- <Aircraft jcr:name="Boeing 767" maker="Boeing" model="767-200" introduced="1982" numberBuilt="966+" maxRange="3950nm" emptyWeight="176650lb" cruiseSpeed="530mph" url="http://en.wikipedia.org/wiki/Boeing_767"/>
- <Aircraft jcr:name="Boeing 787" maker="Boeing" model="787-3" introduced="2009" range="3050nm" emptyWeight="223000lb" cruiseSpeed="561mph" url="http://en.wikipedia.org/wiki/Boeing_787"/>
- <Aircraft jcr:name="Boeing 757" maker="Boeing" model="757-200" introduced="1983" numberBuilt="1050" range="3900nm" maxWeight="255000lb" cruiseSpeed="530mph" url="http://en.wikipedia.org/wiki/Boeing_757"/>
- <Aircraft jcr:name="Airbus A380" maker="Airbus" model="A380-800" introduced="2007" numberBuilt="18" range="8200nm" maxWeight="1235000lb" cruiseSpeed="647mph" url="http://en.wikipedia.org/wiki/Airbus_a380"/>
- <Aircraft jcr:name="Airbus A340" maker="Airbus" model="A340-200" introduced="1993" numberBuilt="354" range="8000nm" maxWeight="606300lb" cruiseSpeed="557mph" url="http://en.wikipedia.org/wiki/Airbus_A-340"/>
- <Aircraft jcr:name="Airbus A310" maker="Airbus" model="A310-200" introduced="1983" numberBuilt="255" cruiseSpeed="850km/h" emptyWeight="176312lb" range="3670nm" url="http://en.wikipedia.org/wiki/Airbus_A-310"/>
- <Aircraft jcr:name="Embraer RJ-175" maker="Embraer" model="ERJ170-200" introduced="2004" range="3334km" cruiseSpeed="481kt" emptyWeight="21810kg" url="http://en.wikipedia.org/wiki/EMBRAER_170"/>
+ <Commercial jcr:primaryType="nt:unstructured">
+ <air:Aircraft jcr:name="Boeing 777" maker="Boeing" model="777-200LR" introduced="1995" numberBuilt="731+" maxRange="7500nm" emptyWeight="326000lb" cruiseSpeed="560mph" url="http://en.wikipedia.org/wiki/Boeing_777"/>
+ <air:Aircraft jcr:name="Boeing 767" maker="Boeing" model="767-200" introduced="1982" numberBuilt="966+" maxRange="3950nm" emptyWeight="176650lb" cruiseSpeed="530mph" url="http://en.wikipedia.org/wiki/Boeing_767"/>
+ <air:Aircraft jcr:name="Boeing 787" maker="Boeing" model="787-3" introduced="2009" range="3050nm" emptyWeight="223000lb" cruiseSpeed="561mph" url="http://en.wikipedia.org/wiki/Boeing_787"/>
+ <air:Aircraft jcr:name="Boeing 757" maker="Boeing" model="757-200" introduced="1983" numberBuilt="1050" range="3900nm" maxWeight="255000lb" cruiseSpeed="530mph" url="http://en.wikipedia.org/wiki/Boeing_757"/>
+ <air:Aircraft jcr:name="Airbus A380" maker="Airbus" model="A380-800" introduced="2007" numberBuilt="18" range="8200nm" maxWeight="1235000lb" cruiseSpeed="647mph" url="http://en.wikipedia.org/wiki/Airbus_a380"/>
+ <air:Aircraft jcr:name="Airbus A340" maker="Airbus" model="A340-200" introduced="1993" numberBuilt="354" range="8000nm" maxWeight="606300lb" cruiseSpeed="557mph" url="http://en.wikipedia.org/wiki/Airbus_A-340"/>
+ <air:Aircraft jcr:name="Airbus A310" maker="Airbus" model="A310-200" introduced="1983" numberBuilt="255" cruiseSpeed="850km/h" emptyWeight="176312lb" range="3670nm" url="http://en.wikipedia.org/wiki/Airbus_A-310"/>
+ <air:Aircraft jcr:name="Embraer RJ-175" maker="Embraer" model="ERJ170-200" introduced="2004" range="3334km" cruiseSpeed="481kt" emptyWeight="21810kg" url="http://en.wikipedia.org/wiki/EMBRAER_170"/>
</Commercial>
- <Vintage>
- <Aircraft jcr:name="Fokker Trimotor" maker="Fokker" model="F.VII" introduced="1925" cruiseSpeed="170km/h" emptyWeight="3050kg" crew="2" url="http://en.wikipedia.org/wiki/Fokker_trimotor"/>
- <Aircraft jcr:name="P-38 Lightning" maker="Lockheed" model="P-38" designedBy="Kelly Johnson" introduced="1941" numberBuilt="10037" rateOfClimb="4750ft/min" range="1300mi" emptyWeight="12780lb" crew="1" url="http://en.wikipedia.org/wiki/P-38_Lightning"/>
- <Aircraft jcr:name="A6M Zero" maker="Mitsubishi" model="A6M" designedBy="Jiro Horikoshi" introduced="1940" numberBuilt="11000" crew="1" emptyWeight="3704lb" serviceCeiling="33000ft" maxSpeed="331mph" range="1929mi" rateOfClimb="3100ft/min" url="http://en.wikipedia.org/wiki/A6M_Zero"/>
- <Aircraft jcr:name="Bf 109" maker="Messerschmitt" model="Bf 109" introduced="1937" url="http://en.wikipedia.org/wiki/BF_109"/>
- <Aircraft jcr:name="Wright Flyer" maker="Wright Brothers" introduced="1903" range="852ft" maxSpeed="30mph" emptyWeight="605lb" crew="1"/>
+ <Vintage jcr:primaryType="nt:unstructured">
+ <air:Aircraft jcr:name="Fokker Trimotor" maker="Fokker" model="F.VII" introduced="1925" cruiseSpeed="170km/h" emptyWeight="3050kg" crew="2" url="http://en.wikipedia.org/wiki/Fokker_trimotor"/>
+ <air:Aircraft jcr:name="P-38 Lightning" maker="Lockheed" model="P-38" designedBy="Kelly Johnson" introduced="1941" numberBuilt="10037" rateOfClimb="4750ft/min" range="1300mi" emptyWeight="12780lb" crew="1" url="http://en.wikipedia.org/wiki/P-38_Lightning"/>
+ <air:Aircraft jcr:name="A6M Zero" maker="Mitsubishi" model="A6M" designedBy="Jiro Horikoshi" introduced="1940" numberBuilt="11000" crew="1" emptyWeight="3704lb" serviceCeiling="33000ft" maxSpeed="331mph" range="1929mi" rateOfClimb="3100ft/min" url="http://en.wikipedia.org/wiki/A6M_Zero"/>
+ <air:Aircraft jcr:name="Bf 109" maker="Messerschmitt" model="Bf 109" introduced="1937" url="http://en.wikipedia.org/wiki/BF_109"/>
+ <air:Aircraft jcr:name="Wright Flyer" maker="Wright Brothers" introduced="1903" range="852ft" maxSpeed="30mph" emptyWeight="605lb" crew="1"/>
</Vintage>
- <Homebuilt>
- <Aircraft jcr:name="Long-EZ" maker="Rutan Aircraft Factory" model="61" emptyWeight="760lb" fuelCapacity="200L" maxSpeed="185kt" since="1976" range="1200nm" url="http://en.wikipedia.org/wiki/Rutan_Long-EZ"/>
- <Aircraft jcr:name="Cirrus VK-30" maker="Cirrus Design" model="VK-30" emptyWeight="2400lb" maxLoad="1200lb" maxSpeed="250mph" rateOfClimb="1500ft/min" range="1300mi" url="http://en.wikipedia.org/wiki/Cirrus_VK-30"/>
- <Aircraft jcr:name="Van's RV-4" maker="Van's Aircraft" model="RV-4" introduced="1980" emptyWeight="905lb" maxLoad="500lb" maxSpeed="200mph" rateOfClimb="2450ft/min" range="725mi" url="http://en.wikipedia.org/wiki/Van%27s_Aircraft_RV-4"/>
+ <Homebuilt jcr:primaryType="nt:unstructured">
+ <air:Aircraft jcr:name="Long-EZ" maker="Rutan Aircraft Factory" model="61" emptyWeight="760lb" fuelCapacity="200L" maxSpeed="185kt" since="1976" range="1200nm" url="http://en.wikipedia.org/wiki/Rutan_Long-EZ"/>
+ <air:Aircraft jcr:name="Cirrus VK-30" maker="Cirrus Design" model="VK-30" emptyWeight="2400lb" maxLoad="1200lb" maxSpeed="250mph" rateOfClimb="1500ft/min" range="1300mi" url="http://en.wikipedia.org/wiki/Cirrus_VK-30"/>
+ <air:Aircraft jcr:name="Van's RV-4" maker="Van's Aircraft" model="RV-4" introduced="1980" emptyWeight="905lb" maxLoad="500lb" maxSpeed="200mph" rateOfClimb="2450ft/min" range="725mi" url="http://en.wikipedia.org/wiki/Van%27s_Aircraft_RV-4"/>
</Homebuilt>
</Aircraft>
\ No newline at end of file
Modified: trunk/docs/examples/gettingstarted/repositories/src/main/resources/cars.xml
===================================================================
--- trunk/docs/examples/gettingstarted/repositories/src/main/resources/cars.xml 2009-06-10 21:22:34 UTC (rev 1034)
+++ trunk/docs/examples/gettingstarted/repositories/src/main/resources/cars.xml 2009-06-10 21:23:19 UTC (rev 1035)
@@ -26,25 +26,25 @@
-->
<Cars xmlns:jcr="http://www.jcp.org/jcr/1.0"
xmlns:nt="http://www.jcp.org/jcr/nt/1.0"
- xmlns="http://jboss.org/dna/examples/cars/1.0">
- <Hybrid>
- <Car jcr:name="Toyota Prius" maker="Toyota" model="Prius" year="2008" msrp="$21,500" userRating="4.2" valueRating="5" mpgCity="48" mpgHighway="45"/>
- <Car jcr:name="Toyota Highlander" maker="Toyota" model="Highlander" year="2008" msrp="$34,200" userRating="4" valueRating="5" mpgCity="27" mpgHighway="25"/>
- <Car jcr:name="Nissan Altima" maker="Nissan" model="Altima" year="2008" msrp="$18,260" mpgCity="23" mpgHighway="32"/>
+ xmlns:car="http://jboss.org/dna/examples/cars/1.0" jcr:primaryType="nt:unstructured">
+ <Hybrid jcr:primaryType="nt:unstructured">
+ <car:Car jcr:name="Toyota Prius" maker="Toyota" model="Prius" year="2008" msrp="$21,500" userRating="4.2" valueRating="5" mpgCity="48" mpgHighway="45"/>
+ <car:Car jcr:name="Toyota Highlander" maker="Toyota" model="Highlander" year="2008" msrp="$34,200" userRating="4" valueRating="5" mpgCity="27" mpgHighway="25"/>
+ <car:Car jcr:name="Nissan Altima" maker="Nissan" model="Altima" year="2008" msrp="$18,260" mpgCity="23" mpgHighway="32"/>
</Hybrid>
- <Sports>
- <Car jcr:name="Aston Martin DB9" maker="Aston Martin" model="DB9" year="2008" msrp="$171,600" userRating="5" mpgCity="12" mpgHighway="19" lengthInInches="185.5" wheelbaseInInches="108.0" engine="5,935 cc 5.9 liters V 12"/>
- <Car jcr:name="Infiniti G37" maker="Infiniti" model="G37" year="2008" msrp="$34,900" userRating="3.5" valueRating="4" mpgCity="18" mpgHighway="24" />
+ <Sports jcr:primaryType="nt:unstructured">
+ <car:Car jcr:name="Aston Martin DB9" maker="Aston Martin" model="DB9" year="2008" msrp="$171,600" userRating="5" mpgCity="12" mpgHighway="19" lengthInInches="185.5" wheelbaseInInches="108.0" engine="5,935 cc 5.9 liters V 12"/>
+ <car:Car jcr:name="Infiniti G37" maker="Infiniti" model="G37" year="2008" msrp="$34,900" userRating="3.5" valueRating="4" mpgCity="18" mpgHighway="24" />
</Sports>
- <Luxury>
- <Car jcr:name="Cadillac DTS" maker="Cadillac" model="DTS" year="2008" engine="3.6-liter V6" userRating="0"/>
- <Car jcr:name="Bentley Continental" maker="Bentley" model="Continental" year="2008" msrp="$170,990" mpgCity="10" mpgHighway="17" />
- <Car jcr:name="Lexus IS350" maker="Lexus" model="IS350" year="2008" msrp="$36,305" mpgCity="18" mpgHighway="25" userRating="4" valueRating="5" />
+ <Luxury jcr:primaryType="nt:unstructured">
+ <car:Car jcr:name="Cadillac DTS" maker="Cadillac" model="DTS" year="2008" engine="3.6-liter V6" userRating="0"/>
+ <car:Car jcr:name="Bentley Continental" maker="Bentley" model="Continental" year="2008" msrp="$170,990" mpgCity="10" mpgHighway="17" />
+ <car:Car jcr:name="Lexus IS350" maker="Lexus" model="IS350" year="2008" msrp="$36,305" mpgCity="18" mpgHighway="25" userRating="4" valueRating="5" />
</Luxury>
- <Utility>
- <Car jcr:name="Land Rover LR2" maker="Land Rover" model="LR2" year="2008" msrp="$33,985" userRating="4.5" valueRating="5" mpgCity="16" mpgHighway="23" />
- <Car jcr:name="Land Rover LR3" maker="Land Rover" model="LR3" year="2008" msrp="$48,525" userRating="5" valueRating="2" mpgCity="12" mpgHighway="17" />
- <Car jcr:name="Hummer H3" maker="Hummer" model="H3" year="2008" msrp="$30,595" userRating="3.5" valueRating="4" mpgCity="13" mpgHighway="16" />
- <Car jcr:name="Ford F-150" maker="Ford" model="F-150" year="2008" msrp="$23,910" userRating="4" valueRating="1" mpgCity="14" mpgHighway="20" />
+ <Utility jcr:primaryType="nt:unstructured">
+ <car:Car jcr:name="Land Rover LR2" maker="Land Rover" model="LR2" year="2008" msrp="$33,985" userRating="4.5" valueRating="5" mpgCity="16" mpgHighway="23" />
+ <car:Car jcr:name="Land Rover LR3" maker="Land Rover" model="LR3" year="2008" msrp="$48,525" userRating="5" valueRating="2" mpgCity="12" mpgHighway="17" />
+ <car:Car jcr:name="Hummer H3" maker="Hummer" model="H3" year="2008" msrp="$30,595" userRating="3.5" valueRating="4" mpgCity="13" mpgHighway="16" />
+ <car:Car jcr:name="Ford F-150" maker="Ford" model="F-150" year="2008" msrp="$23,910" userRating="4" valueRating="1" mpgCity="14" mpgHighway="20" />
</Utility>
</Cars>
\ No newline at end of file
Modified: trunk/docs/examples/gettingstarted/repositories/src/main/resources/configRepository.xml
===================================================================
--- trunk/docs/examples/gettingstarted/repositories/src/main/resources/configRepository.xml 2009-06-10 21:22:34 UTC (rev 1034)
+++ trunk/docs/examples/gettingstarted/repositories/src/main/resources/configRepository.xml 2009-06-10 21:23:19 UTC (rev 1035)
@@ -24,7 +24,7 @@
~ 51 Franklin Street, Fifth Floor
~ Boston, MA 02110-1301 USA
-->
-<configuration xmlns="http://www.jboss.org/dna/1.0" xmlns:jcr="http://www.jcp.org/jcr/1.0">
+<configuration xmlns:dna="http://www.jboss.org/dna/1.0" xmlns:jcr="http://www.jcp.org/jcr/1.0">
<!--
Define the sources for the content. These sources are directly accessible using the DNA-specific Graph API.
In fact, this is how the DNA JCR implementation works. You can think of these as being similar to
@@ -50,7 +50,7 @@
under '/Vehicles/Cars', while all the 'Aircraft' content appears under '/Vehicles/Aircraft'.
-->
<dna:source jcr:name="Vehicles">
- <dna:classname>org.jboss.dna.graph.connector.federated.FederatedRepositorySource</dna:classname>
+ <dna:classname>org.jboss.dna.graph.connector.federation.FederatedRepositorySource</dna:classname>
<dna:workspaces>
<!--
Unlike some other repository sources, federated sources have to define all of their workspaces,
@@ -61,11 +61,11 @@
<dna:workspace jcr:name="virtual">
<dna:projections>
<!-- Project the 'Cars' content, starting with the '/Cars' node. -->
- <dna:projection jcr:name="Cars projection" dna:source="Cars" dna:workspace="workspace1">
+ <dna:projection jcr:name="Cars projection" dna:source="Cars" dna:workspaceName="workspace1">
<dna:projectionRules>/Vehicles/Cars => /Cars</dna:projectionRules>
</dna:projection>
<!-- Project the 'Aicraft' content, starting with the '/Aircraft' node. -->
- <dna:projection jcr:name="Aircarft projection" dna:source="Aircraft" dna:workspace="workspace2">
+ <dna:projection jcr:name="Aircarft projection" dna:source="Aircraft" dna:workspaceName="workspace2">
<dna:projectionRules>/Vehicles/Aircraft => /Aircraft</dna:projectionRules>
</dna:projection>
</dna:projections>
@@ -114,15 +114,15 @@
Define a JCR repository that accesses the 'Cars' source directly.
This of course is optional, since we could access the same content through 'vehicles'.
-->
- <dna:repository jcr:name="car repository">
+ <dna:repository jcr:name="Cars">
<!-- Specify the source that should be used for the repository -->
- <source>Cars</source>
+ <dna:source>Cars</dna:source>
<!-- Define the options for the JCR repository, using camelcase version of JcrRepository.Option names -->
- <options jcr:primaryType="dna:options"/>
+ <dna:options jcr:primaryType="dna:options">
<jaasLoginConfigName jcr:primaryType="dna:option" dna:value="dna-jcr"/>
- </options>
+ </dna:options>
<!-- Define any custom node types. Importing CND files via JcrConfiguration is equivalent to specifying here. -->
- <nodeTypes jcr:primaryType="dna:nodeTypes"/>
+ <dna:nodeTypes jcr:primaryType="dna:nodeTypes"/>
<!-- Define any namespaces for this repository, other than those already defined by JCR or DNA -->
<namespaces jcr:primaryType="dna:namespaces">
<car jcr:primaryType="dna:namespace" dna:uri="http://jboss.org/dna/examples/cars/1.0"/>
@@ -132,34 +132,34 @@
Define a JCR repository that accesses the 'Aircraft' source directly.
This of course isn't really necessary for this example, since we could access the same content through 'vehicles'.
-->
- <dna:repository jcr:name="aircraft repository">
+ <dna:repository jcr:name="Aircraft">
<!-- Specify the source that should be used for the repository -->
- <source>Aircraft</source>
+ <dna:source>Aircraft</dna:source>
<!-- Define the options for the JCR repository, using camelcase version of JcrRepository.Option names -->
- <options jcr:primaryType="dna:options"/>
+ <dna:options jcr:primaryType="dna:options">
<jaasLoginConfigName jcr:primaryType="dna:option" dna:value="dna-jcr"/>
- </options>
+ </dna:options>
</dna:repository>
<!--
Define a JCR repository that accesses the 'Vehicles' federated source directly,
which is defined in the sources to be a projection of the 'Cars' and 'Vehicles' content.
-->
<!-- Define a JCR repository that accesses the 'Vehicles' federated source directly -->
- <dna:repository jcr:name="vehicles">
+ <dna:repository jcr:name="Vehicles">
<!-- Specify the source that should be used for the repository -->
- <source>Vehicles</source>
+ <dna:source>Vehicles</dna:source>
<!-- Define the options for the JCR repository, using camelcase version of JcrRepository.Option names -->
- <options jcr:primaryType="dna:options">
+ <dna:options jcr:primaryType="dna:options">
<projectNodeTypes jcr:primaryType="dna:option" dna:value="false"/>
<jaasLoginConfigName jcr:primaryType="dna:option" dna:value="dna-jcr"/>
- </options>
+ </dna:options>
<!-- Define any custom node types. Importing CND files via JcrConfiguration is equivalent to specifying here. -->
- <nodeTypes jcr:primaryType="dna:nodeTypes"/>
+ <dna:nodeTypes jcr:primaryType="dna:nodeTypes"/>
<!-- Define any namespaces for this repository, other than those already defined by JCR, DNA or by imported content. -->
- <namespaces jcr:primaryType="dna:namespaces">
+ <dna:namespaces jcr:primaryType="dna:namespaces">
<car jcr:primaryType="dna:namespace" dna:uri="http://jboss.org/dna/examples/cars/1.0"/>
<air jcr:primaryType="dna:namespace" dna:uri="http://jboss.org/dna/examples/aircraft/1.0"/>
- </namespaces>
+ </dna:namespaces>
</dna:repository>
</dna:repositories>
</configuration>
\ No newline at end of file
Copied: trunk/docs/examples/gettingstarted/repositories/src/main/resources/vehicles.cnd (from rev 1034, trunk/docs/examples/gettingstarted/repositories/src/main/resources/virtual.cnd)
===================================================================
--- trunk/docs/examples/gettingstarted/repositories/src/main/resources/vehicles.cnd (rev 0)
+++ trunk/docs/examples/gettingstarted/repositories/src/main/resources/vehicles.cnd 2009-06-10 21:23:19 UTC (rev 1035)
@@ -0,0 +1,79 @@
+/*
+ * 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.
+ */
+
+//------------------------------------------------------------------------------
+// N A M E S P A C E S
+//------------------------------------------------------------------------------
+<jcr='http://www.jcp.org/jcr/1.0'>
+<nt='http://www.jcp.org/jcr/nt/1.0'>
+<mix='http://www.jcp.org/jcr/mix/1.0'>
+<air='http://jboss.org/dna/examples/aircraft/1.0'>
+<car='http://jboss.org/dna/examples/cars/1.0'>
+
+//------------------------------------------------------------------------------
+// N O D E T Y P E S
+//------------------------------------------------------------------------------
+
+[car:Car] > nt:unstructured
+ - car:maker (string)
+ - car:model (string)
+ - car:year (string) < '(19|20)\d{2}' // any 4 digit number starting with '19' or '20'
+ - car:msrp (string) < '[$]\d{1,3}[,]?\d{3}([.]\d{2})?' // of the form "$X,XXX.ZZ", "$XX,XXX.ZZ" or "$XXX,XXX.ZZ"
+ // where '.ZZ' is optional
+ - car:userRating (long) < '[1,5]' // any value from 1 to 5 (inclusive)
+ - car:valueRating (long) < '[1,5]' // any value from 1 to 5 (inclusive)
+ - car:mpgCity (long) < '(0,]' // any value greater than 0
+ - car:mpgHighway (long) < '(0,]' // any value greater than 0
+ - car:lengthInInches (double) < '(0,]' // any value greater than 0
+ - car:wheelbaseInInches (double) < '(0,]' // any value greater than 0
+ - car:engine (string)
+
+[air:Aircraft] > nt:unstructured
+ - air:maker (string)
+ - air:model (string)
+ - air:designedBy (string)
+ - air:introduced (string) < '(19|20)\d{2}' // any 4 digit number starting with '19' or '20'
+ - air:range (string) // any integer (with optional ',' every 1000s place)
+ < '\d{1,3}(,?\d{3})*\s*(nm|m|km|mi|ft)' // followed by 'nm', 'm', 'km', 'mi', or 'ft'
+ - air:maxSpeed (string) // any integer (with optional ',' every 1000s place)
+ < '\d{1,3}(,?\d{3})*\s*(kt|mph|km/h|kmph)' // followed by 'kt', 'mph', 'km/h' or 'kmph'
+ - air:takeoffSpeed (string) // any integer (with optional ',' every 1000s place)
+ < '\d{1,3}(,?\d{3})*\s*(kt|mph|km/h|kmph)' // followed by 'kt', 'mph', 'km/h' or 'kmph'
+ - air:cruiseSpeed (string) // any integer (with optional ',' every 1000s place)
+ < '\d{1,3}(,?\d{3})*\s*(kt|mph|km/h|kmph)' // followed by 'kt', 'mph', 'km/h' or 'kmph'
+ - air:emptyWeight (string) // any integer (with optional ',' every 1000s place)
+ < '\d{1,3}(,?\d{3})*\s*(lb|kg)' // followed by 'lb' or 'kg'
+ - air:maxWeight (string) // any integer (with optional ',' every 1000s place)
+ < '\d{1,3}(,?\d{3})*\s*(lb|kg)' // followed by 'lb' or 'kg'
+ - air:rateOfClimb (string) // any integer (with optional ',' every 1000s place)
+ < '\d{1,3}(,?\d{3})*\s*(ft|km|m)/(s|min)' // followed by 'ft/s', 'ft/min', 'km/s', 'km/min', 'm/s', or 'm/min'
+ - air:serviceCeiling (string) // any integer (with optional ',' every 1000s place)
+ < '\d{1,3}(,?\d{3})*\s*(nm|m|km|mi|ft)' // followed by 'nm', 'm', 'km', 'mi', or 'ft'
+ - air:fuelCapacity (string) // any integer (with optional ',' every 1000s place)
+ < '\d{1,3}(,?\d{3})*\s*(lb|kg|gal|L)' // followed by 'lb', 'kg', 'gal', or 'L'
+ - air:crew (long) < '[0,)' // any non-negative value
+ - air:numberBuilt (string) // any integer (with optional ',' every 1000s place)
+ < '\d{1,3}(,?\d{3})*\s*[+]?' , // optionally followed by '+'
+ '([<>]\s*)?\d{1,3}(,?\d{3})*' // or prefixed by '<' or '>'
+ - air:url (string)
Deleted: trunk/docs/examples/gettingstarted/repositories/src/main/resources/virtual.cnd
===================================================================
--- trunk/docs/examples/gettingstarted/repositories/src/main/resources/virtual.cnd 2009-06-10 21:22:34 UTC (rev 1034)
+++ trunk/docs/examples/gettingstarted/repositories/src/main/resources/virtual.cnd 2009-06-10 21:23:19 UTC (rev 1035)
@@ -1,79 +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.
- */
-
-//------------------------------------------------------------------------------
-// N A M E S P A C E S
-//------------------------------------------------------------------------------
-<jcr='http://www.jcp.org/jcr/1.0'>
-<nt='http://www.jcp.org/jcr/nt/1.0'>
-<mix='http://www.jcp.org/jcr/mix/1.0'>
-<air='http://jboss.org/dna/examples/aircraft/1.0'>
-<car='http://jboss.org/dna/examples/cars/1.0'>
-
-//------------------------------------------------------------------------------
-// N O D E T Y P E S
-//------------------------------------------------------------------------------
-
-[car:Car] > nt:unstructured
- - car:maker (string)
- - car:model (string)
- - car:year (string) < '(19|20)\d{2}' // any 4 digit number starting with '19' or '20'
- - car:msrp (string) < '[$]\d{1,3}[,]?\d{3}([.]\d{2})?' // of the form "$X,XXX.ZZ", "$XX,XXX.ZZ" or "$XXX,XXX.ZZ"
- // where '.ZZ' is optional
- - car:userRating (long) < '[1,5]' // any value from 1 to 5 (inclusive)
- - car:valueRating (long) < '[1,5]' // any value from 1 to 5 (inclusive)
- - car:mpgCity (long) < '(0,]' // any value greater than 0
- - car:mpgHighway (long) < '(0,]' // any value greater than 0
- - car:lengthInInches (double) < '(0,]' // any value greater than 0
- - car:wheelbaseInInches (double) < '(0,]' // any value greater than 0
- - car:engine (string)
-
-[air:Aircraft] > nt:unstructured
- - air:maker (string)
- - air:model (string)
- - air:designedBy (string)
- - air:introduced (string) < '(19|20)\d{2}' // any 4 digit number starting with '19' or '20'
- - air:range (string) // any integer (with optional ',' every 1000s place)
- < '\d{1,3}(,?\d{3})*\s*(nm|m|km|mi|ft)' // followed by 'nm', 'm', 'km', 'mi', or 'ft'
- - air:maxSpeed (string) // any integer (with optional ',' every 1000s place)
- < '\d{1,3}(,?\d{3})*\s*(kt|mph|km/h|kmph)' // followed by 'kt', 'mph', 'km/h' or 'kmph'
- - air:takeoffSpeed (string) // any integer (with optional ',' every 1000s place)
- < '\d{1,3}(,?\d{3})*\s*(kt|mph|km/h|kmph)' // followed by 'kt', 'mph', 'km/h' or 'kmph'
- - air:cruiseSpeed (string) // any integer (with optional ',' every 1000s place)
- < '\d{1,3}(,?\d{3})*\s*(kt|mph|km/h|kmph)' // followed by 'kt', 'mph', 'km/h' or 'kmph'
- - air:emptyWeight (string) // any integer (with optional ',' every 1000s place)
- < '\d{1,3}(,?\d{3})*\s*(lb|kg)' // followed by 'lb' or 'kg'
- - air:maxWeight (string) // any integer (with optional ',' every 1000s place)
- < '\d{1,3}(,?\d{3})*\s*(lb|kg)' // followed by 'lb' or 'kg'
- - air:rateOfClimb (string) // any integer (with optional ',' every 1000s place)
- < '\d{1,3}(,?\d{3})*\s*(ft|km|m)/(s|min)' // followed by 'ft/s', 'ft/min', 'km/s', 'km/min', 'm/s', or 'm/min'
- - air:serviceCeiling (string) // any integer (with optional ',' every 1000s place)
- < '\d{1,3}(,?\d{3})*\s*(nm|m|km|mi|ft)' // followed by 'nm', 'm', 'km', 'mi', or 'ft'
- - air:fuelCapacity (string) // any integer (with optional ',' every 1000s place)
- < '\d{1,3}(,?\d{3})*\s*(lb|kg|gal|L)' // followed by 'lb', 'kg', 'gal', or 'L'
- - air:crew (long) < '[0,)' // any non-negative value
- - air:numberBuilt (string) // any integer (with optional ',' every 1000s place)
- < '\d{1,3}(,?\d{3})*\s*[+]?' , // optionally followed by '+'
- '([<>]\s*)?\d{1,3}(,?\d{3})*' // or prefixed by '<' or '>'
- - air:url (string)
Modified: trunk/docs/examples/gettingstarted/repositories/src/test/java/org/jboss/example/dna/repository/RepositoryClientTest.java
===================================================================
--- trunk/docs/examples/gettingstarted/repositories/src/test/java/org/jboss/example/dna/repository/RepositoryClientTest.java 2009-06-10 21:22:34 UTC (rev 1034)
+++ trunk/docs/examples/gettingstarted/repositories/src/test/java/org/jboss/example/dna/repository/RepositoryClientTest.java 2009-06-10 21:23:19 UTC (rev 1035)
@@ -34,6 +34,7 @@
import java.util.Map;
import org.junit.After;
import org.junit.Before;
+import org.junit.Ignore;
import org.junit.Test;
import org.mockito.MockitoAnnotations;
import org.mockito.MockitoAnnotations.Mock;
@@ -60,6 +61,8 @@
client.setUserInterface(userInterface);
client.setApi(getApi());
stub(userInterface.getLocationOfRepositoryFiles()).toReturn(new File("src/main/resources").getAbsolutePath());
+ stub(userInterface.getLocationOfCndFiles()).toReturn(new File("src/main/resources").getAbsolutePath());
+ stub(userInterface.getRepositoryConfiguration()).toReturn(new File("src/main/resources/configRepository.xml"));
}
@After
@@ -96,21 +99,22 @@
@Test
public void shouldStartupWithoutError() throws Exception {
client.startRepositories();
- assertThat(client.getNamesOfRepositories(), hasItems("Aircraft", "Cars", "Configuration", "Vehicles", "Cache"));
+ assertThat(client.getNamesOfRepositories(), hasItems("Aircraft", "Car", "Vehicles"));
}
@Test
public void shouldStartupWithoutErrorMoreThanOnce() throws Exception {
client.startRepositories();
- assertThat(client.getNamesOfRepositories(), hasItems("Aircraft", "Cars", "Configuration", "Vehicles", "Cache"));
+ assertThat(client.getNamesOfRepositories(), hasItems("Aircraft", "Car", "Vehicles"));
}
+ @Ignore
@Test
public void shouldHaveContentFromConfigurationRepository() throws Throwable {
client.startRepositories();
getNodeInfo("Configuration", "/jcr:system");
- //assertThat(children, hasItems("dna:sources", "dna:federatedRepositories"));
+ // assertThat(children, hasItems("dna:sources", "dna:federatedRepositories"));
assertThat(properties.containsKey("jcr:primaryType"), is(true));
// assertThat(properties.containsKey("dna:uuid"), is(true));
assertThat(properties.size() >= 1, is(true));
@@ -225,13 +229,13 @@
client.startRepositories();
getNodeInfo("Vehicles", "/");
- //assertThat(children, hasItems("Vehicles", "jcr:system"));
+ // assertThat(children, hasItems("Vehicles", "jcr:system"));
getNodeInfo("Vehicles", "/Vehicles");
assertThat(children, hasItems("Cars", "Aircraft"));
getNodeInfo("Vehicles", "/");
- //assertThat(children, hasItems("Vehicles", "jcr:system"));
+ // assertThat(children, hasItems("Vehicles", "jcr:system"));
getNodeInfo("Vehicles", "/Vehicles/Cars/Hybrid");
assertThat(children, hasItems("Toyota Prius", "Toyota Highlander", "Nissan Altima"));
@@ -252,6 +256,8 @@
assertProperty("wheelbaseInInches", "108.0");
assertProperty("engine", "5,935 cc 5.9 liters V 12");
+ getNodeInfo("Vehicles", "/Vehicles/Aircraft");
+
getNodeInfo("Vehicles", "/Vehicles/Aircraft/Vintage/Wright Flyer");
assertThat(children.size(), is(0));
assertThat(properties.containsKey("jcr:primaryType"), is(true));
@@ -272,10 +278,10 @@
@Test
public void shouldBeAbleToExecuteTestsRepeatedly() throws Throwable {
for (int i = 0; i != 5; ++i) {
- shouldHaveContentFromConfigurationRepository();
+ // shouldHaveContentFromConfigurationRepository();
shouldHaveContentFromCarsRepository();
shouldHaveContentFromAircraftRepository();
- // shouldHaveContentFromVehiclesRepository();
+ shouldHaveContentFromVehiclesRepository();
}
}
}
Modified: trunk/docs/gettingstarted/src/main/docbook/en-US/content/downloading_and_running.xml
===================================================================
--- trunk/docs/gettingstarted/src/main/docbook/en-US/content/downloading_and_running.xml 2009-06-10 21:22:34 UTC (rev 1034)
+++ trunk/docs/gettingstarted/src/main/docbook/en-US/content/downloading_and_running.xml 2009-06-10 21:23:19 UTC (rev 1035)
@@ -224,8 +224,9 @@
</listitem>
<listitem>
<para><emphasis role="strong"><code>aircraft.cnd</code></emphasis>, <emphasis role="strong"><code>cars.cnd</code></emphasis>,
- and <emphasis role="strong"><code>virtual.cnd</code></emphasis> are the CND files used for the three different JCR Repositories
- set up in the example. The <emphasis role="strong"><code>virtual.cnd</code></emphasis> is just a combination of the other two.
+ and <emphasis role="strong"><code>vehicles.cnd</code></emphasis> are the CND files used for the three different JCR Repositories
+ set up in the example. The <emphasis role="strong"><code>vehicles.cnd</code></emphasis> is just a combination of the other two
+ (with duplicates removed).
</para>
</listitem>
<listitem>
Modified: trunk/docs/gettingstarted/src/main/docbook/en-US/content/repository_example.xml
===================================================================
--- trunk/docs/gettingstarted/src/main/docbook/en-US/content/repository_example.xml 2009-06-10 21:22:34 UTC (rev 1034)
+++ trunk/docs/gettingstarted/src/main/docbook/en-US/content/repository_example.xml 2009-06-10 21:23:19 UTC (rev 1035)
@@ -263,9 +263,9 @@
// in the configuration file, but this approach is easy and allows us to define the node types
// using the CND format in one or multiple files.
String locationOfCndFiles = userInterface.getLocationOfCndFiles();
- configuration.repository("aircraft repository").addNodeTypes(locationOfCndFiles + "/aircraft.cnd");
- configuration.repository("car repository").addNodeTypes(locationOfCndFiles + "/cars.cnd");
- configuration.repository("virtual").addNodeTypes(locationOfCndFiles + "/virtual.cnd");
+ configuration.repository("Aircraft").addNodeTypes(locationOfCndFiles + "/aircraft.cnd");
+ configuration.repository("Cars").addNodeTypes(locationOfCndFiles + "/cars.cnd");
+ configuration.repository("Vehicles").addNodeTypes(locationOfCndFiles + "/vehicles.cnd");
// Now create the JCR engine ...
engine = configuration.build();
Modified: trunk/docs/gettingstarted/src/main/docbook/en-US/content/using_dna.xml
===================================================================
--- trunk/docs/gettingstarted/src/main/docbook/en-US/content/using_dna.xml 2009-06-10 21:22:34 UTC (rev 1034)
+++ trunk/docs/gettingstarted/src/main/docbook/en-US/content/using_dna.xml 2009-06-10 21:23:19 UTC (rev 1035)
@@ -179,7 +179,7 @@
This of course is optional, since we could access the same content through 'vehicles'.
-->
<dna:repository jcr:name="car repository" dna:source="Cars">
- <options jcr:primaryType="dna:options"/>
+ <options jcr:primaryType="dna:options">
<jaasLoginConfigName jcr:primaryType="dna:option" dna:value="dna-jcr"/>
</options>
</dna:repository>
Modified: trunk/docs/reference/src/main/docbook/en-US/content/jcr/configuration.xml
===================================================================
--- trunk/docs/reference/src/main/docbook/en-US/content/jcr/configuration.xml 2009-06-10 21:22:34 UTC (rev 1034)
+++ trunk/docs/reference/src/main/docbook/en-US/content/jcr/configuration.xml 2009-06-10 21:23:19 UTC (rev 1035)
@@ -179,7 +179,7 @@
This of course is optional, since we could access the same content through 'vehicles'.
-->
<dna:repository jcr:name="car repository" dna:source="Cars">
- <options jcr:primaryType="dna:options"/>
+ <options jcr:primaryType="dna:options">
<jaasLoginConfigName jcr:primaryType="dna:option" dna:value="dna-jcr"/>
</options>
</dna:repository>
14 years, 11 months
DNA SVN: r1034 - in trunk: dna-graph/src/main/java/org/jboss/dna/graph/connector/federation and 4 other directories.
by dna-commits@lists.jboss.org
Author: rhauch
Date: 2009-06-10 17:22:34 -0400 (Wed, 10 Jun 2009)
New Revision: 1034
Modified:
trunk/dna-graph/src/main/java/org/jboss/dna/graph/connector/RepositoryContext.java
trunk/dna-graph/src/main/java/org/jboss/dna/graph/connector/RepositorySource.java
trunk/dna-graph/src/main/java/org/jboss/dna/graph/connector/federation/FederatedRepositorySource.java
trunk/dna-graph/src/main/resources/org/jboss/dna/graph/GraphI18n.properties
trunk/dna-graph/src/test/java/org/jboss/dna/graph/connector/federation/AbstractFederatedRepositorySourceIntegrationTest.java
trunk/dna-graph/src/test/java/org/jboss/dna/graph/connector/federation/FederatedRepositorySourceTest.java
trunk/dna-graph/src/test/java/org/jboss/dna/graph/connector/test/AbstractConnectorTest.java
trunk/dna-repository/src/main/java/org/jboss/dna/repository/RepositoryLibrary.java
Log:
DNA-449 Federation connector does not find it's configuration when imported using the JcrConfiguration
Change the RepositoryContext to expose a subgraph snapshot of the configuration. This is not only easier to use, but it requires less setup and also prevents the RepositorySource from changing the configuration content. Also added a note to the RepositorySource.initialize(RepositoryContext) method that it may be called whenever the configuration changes.
Modified: trunk/dna-graph/src/main/java/org/jboss/dna/graph/connector/RepositoryContext.java
===================================================================
--- trunk/dna-graph/src/main/java/org/jboss/dna/graph/connector/RepositoryContext.java 2009-06-10 21:22:09 UTC (rev 1033)
+++ trunk/dna-graph/src/main/java/org/jboss/dna/graph/connector/RepositoryContext.java 2009-06-10 21:22:34 UTC (rev 1034)
@@ -24,9 +24,8 @@
package org.jboss.dna.graph.connector;
import org.jboss.dna.graph.ExecutionContext;
-import org.jboss.dna.graph.Graph;
+import org.jboss.dna.graph.Subgraph;
import org.jboss.dna.graph.observe.Observer;
-import org.jboss.dna.graph.property.Path;
/**
* The context for a repository. This interface need not be implemented by a {@link RepositorySource}, as it is normally provided
@@ -58,17 +57,11 @@
Observer getObserver();
/**
- * Get a graph to the configuration content, already configured to the correct workspace.
+ * Get a snapshot of the current configuration for the {@link RepositorySource}. The root of the subgraph will be the node in
+ * the configuration that represents the RepositorySource.
*
- * @return the configuration graph, or null if there is no configuration
+ * @param depth the max depth of the configuration subgraph
+ * @return the configuration snapshot as a subgraph, or null if there is no configuration
*/
- Graph getConfiguration();
-
- /**
- * Get the path within the {@link #getConfiguration() configuration} where the source is represented.
- *
- * @return the path to the {@link RepositorySource}'s configuration element, or null if the source is not defined within the
- * configuration
- */
- Path getPathInConfiguration();
+ Subgraph getConfiguration( int depth );
}
Modified: trunk/dna-graph/src/main/java/org/jboss/dna/graph/connector/RepositorySource.java
===================================================================
--- trunk/dna-graph/src/main/java/org/jboss/dna/graph/connector/RepositorySource.java 2009-06-10 21:22:09 UTC (rev 1033)
+++ trunk/dna-graph/src/main/java/org/jboss/dna/graph/connector/RepositorySource.java 2009-06-10 21:22:34 UTC (rev 1034)
@@ -139,9 +139,13 @@
public interface RepositorySource extends Referenceable, Serializable {
/**
- * Initialize this source to use the supplied {@link RepositoryContext}, from which this source can obtain
- * {@link RepositoryContext#getRepositoryConnectionFactory() connections} to other {@link RepositorySource sources} as well as
- * {@link RepositoryContext#getExecutionContext() execution contexts}.
+ * Initialize this source to use the supplied {@link RepositoryContext}, from which this source can obtain the
+ * {@link RepositoryContext#getConfiguration(int) configuration} defining this source,
+ * {@link RepositoryContext#getRepositoryConnectionFactory() connections} to other {@link RepositorySource sources}, and the
+ * {@link RepositoryContext#getExecutionContext() execution context}.
+ * <p>
+ * This method may be called each time the configuration changes, allowing the source to update itself.
+ * </p>
*
* @param context
* @throws RepositorySourceException
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-06-10 21:22:09 UTC (rev 1033)
+++ trunk/dna-graph/src/main/java/org/jboss/dna/graph/connector/federation/FederatedRepositorySource.java 2009-06-10 21:22:34 UTC (rev 1034)
@@ -43,7 +43,6 @@
import org.jboss.dna.common.util.HashCode;
import org.jboss.dna.graph.DnaLexicon;
import org.jboss.dna.graph.ExecutionContext;
-import org.jboss.dna.graph.Graph;
import org.jboss.dna.graph.GraphI18n;
import org.jboss.dna.graph.Location;
import org.jboss.dna.graph.Node;
@@ -178,12 +177,6 @@
throw new RepositorySourceException(getName(), msg.text("name", name));
}
- // Make sure there is a configuration ...
- if (repositoryContext.getConfiguration() == null) {
- I18n msg = GraphI18n.propertyIsRequiredForFederatedRepositorySource;
- throw new RepositorySourceException(getName(), msg.text("configuration", name));
- }
-
// Load the configuration ...
this.configuration = loadRepository(name, repositoryContext);
}
@@ -279,7 +272,7 @@
}
/**
- * Utility to load the current configuration for this source from the {@link RepositoryContext#getConfiguration()
+ * Utility to load the current configuration for this source from the {@link RepositoryContext#getConfiguration(int)
* configuration repository}. This method may only be called after the source is {@link #initialize(RepositoryContext)
* initialized}.
*
@@ -299,11 +292,6 @@
ProjectionParser projectionParser = ProjectionParser.getInstance();
NamespaceRegistry registry = executionContext.getNamespaceRegistry();
- Graph config = repositoryContext.getConfiguration();
- Path pathOfSource = repositoryContext.getPathInConfiguration();
- assert config != null;
- assert pathOfSource != null;
-
try {
// Read the configuration for the federated repository:
// Level 1: the node representing the federated repository
@@ -312,7 +300,7 @@
// Level 4: the "dna:projections" nodes
// Level 5: a node below "dna:projections" for each projection, with properties for the source name,
// workspace name, cache expiration time, and projection rules
- Subgraph repositories = config.getSubgraphOfDepth(5).at(pathOfSource);
+ Subgraph repositories = repositoryContext.getConfiguration(5);
// Get the name of the default workspace ...
String defaultWorkspaceName = null;
@@ -336,8 +324,8 @@
I18n msg = GraphI18n.requiredNodeDoesNotExistRelativeToNode;
throw new RepositorySourceException(msg.text(DnaLexicon.WORKSPACES.getString(registry),
repositories.getLocation().getPath().getString(registry),
- config.getCurrentWorkspaceName(),
- config.getSourceName()));
+ repositories.getGraph().getCurrentWorkspaceName(),
+ repositories.getGraph().getSourceName()));
}
// Level 3: The workspace nodes ...
@@ -365,8 +353,8 @@
workspaceNode.getLocation()
.getPath()
.getString(registry),
- config.getCurrentWorkspaceName(),
- config.getSourceName()));
+ repositories.getGraph().getCurrentWorkspaceName(),
+ repositories.getGraph().getSourceName()));
}
// Level 5: the projection nodes ...
@@ -394,10 +382,7 @@
throw t; // rethrow
} catch (Throwable t) {
I18n msg = GraphI18n.errorReadingConfigurationForFederatedRepositorySource;
- String configSource = config.getSourceName();
- String configWorkspace = config.getCurrentWorkspaceName();
- String configPath = pathOfSource.getString(registry);
- throw new RepositorySourceException(getName(), msg.text(name, configSource, configWorkspace, configPath), t);
+ throw new RepositorySourceException(getName(), msg.text(name), t);
}
}
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-06-10 21:22:09 UTC (rev 1033)
+++ trunk/dna-graph/src/main/resources/org/jboss/dna/graph/GraphI18n.properties 2009-06-10 21:22:34 UTC (rev 1034)
@@ -87,7 +87,7 @@
namePropertyIsRequiredForFederatedRepositorySource = The "{0}" property is required on each federated repository source
propertyIsRequiredForFederatedRepositorySource = The "{0}" property is required on the "{1}" federated repository source
federatedRepositorySourceMustBeInitialized = The "{0}" federated repository source must be initialized before it can be used
-errorReadingConfigurationForFederatedRepositorySource = Error with the "{0}" federated repository source's configuration at "{3}" in the "{2}" workspace of "{1}"
+errorReadingConfigurationForFederatedRepositorySource = Error with the "{0}" federated repository source's configuration
errorAddingProjectionRuleParseMethod = Error while adding a parsing method for a federation projection rule
requiredNodeDoesNotExistRelativeToNode = The required node "{0}" does not exist relative to "{1}" in "{2}" workspace of the "{3}" repository
unableToObtainConnectionToFederatedSource = Unable to obtain a connection to source "{0}" being federated by the "{1}" workspace of the "{2}" federated repository
Modified: trunk/dna-graph/src/test/java/org/jboss/dna/graph/connector/federation/AbstractFederatedRepositorySourceIntegrationTest.java
===================================================================
--- trunk/dna-graph/src/test/java/org/jboss/dna/graph/connector/federation/AbstractFederatedRepositorySourceIntegrationTest.java 2009-06-10 21:22:09 UTC (rev 1033)
+++ trunk/dna-graph/src/test/java/org/jboss/dna/graph/connector/federation/AbstractFederatedRepositorySourceIntegrationTest.java 2009-06-10 21:22:34 UTC (rev 1034)
@@ -113,15 +113,11 @@
}
@SuppressWarnings( "synthetic-access" )
- public Graph getConfiguration() {
+ public Subgraph getConfiguration( int depth ) {
Graph result = Graph.create(configRepositorySource, context);
result.useWorkspace(configurationWorkspaceName);
- return result;
+ return result.getSubgraphOfDepth(depth).at("/a/b/Test Repository");
}
-
- public Path getPathInConfiguration() {
- return context.getValueFactories().getPathFactory().create("/a/b/Test Repository");
- }
};
// Set up the source ...
@@ -172,7 +168,10 @@
CheckArg.isNotNull(sourceName, "sourceName");
CheckArg.isNotNull(workspaceName, "workspaceName");
CheckArg.isNotEmpty(projectionRules, "projectionRules");
- String configPath = repositoryContext.getPathInConfiguration().getString(context.getNamespaceRegistry());
+ String configPath = repositoryContext.getConfiguration(1)
+ .getLocation()
+ .getPath()
+ .getString(context.getNamespaceRegistry());
assertThat(configPath.endsWith("/"), is(false));
String wsPath = configPath + "/dna:workspaces/" + federatedWorkspace;
String projectionPath = wsPath + "/dna:projections/" + projectionName;
Modified: trunk/dna-graph/src/test/java/org/jboss/dna/graph/connector/federation/FederatedRepositorySourceTest.java
===================================================================
--- trunk/dna-graph/src/test/java/org/jboss/dna/graph/connector/federation/FederatedRepositorySourceTest.java 2009-06-10 21:22:09 UTC (rev 1033)
+++ trunk/dna-graph/src/test/java/org/jboss/dna/graph/connector/federation/FederatedRepositorySourceTest.java 2009-06-10 21:22:34 UTC (rev 1034)
@@ -42,12 +42,12 @@
import javax.security.auth.callback.CallbackHandler;
import org.jboss.dna.graph.ExecutionContext;
import org.jboss.dna.graph.Graph;
+import org.jboss.dna.graph.Subgraph;
import org.jboss.dna.graph.connector.RepositoryConnection;
import org.jboss.dna.graph.connector.RepositoryConnectionFactory;
import org.jboss.dna.graph.connector.RepositoryContext;
import org.jboss.dna.graph.connector.inmemory.InMemoryRepositorySource;
import org.jboss.dna.graph.observe.Observer;
-import org.jboss.dna.graph.property.Path;
import org.junit.Before;
import org.junit.Test;
import org.mockito.ArgumentMatcher;
@@ -100,16 +100,11 @@
}
@SuppressWarnings( "synthetic-access" )
- public Graph getConfiguration() {
+ public Subgraph getConfiguration( int depth ) {
Graph result = Graph.create(configRepositorySource, context);
result.useWorkspace("configSpace");
- return result;
+ return result.getSubgraphOfDepth(depth).at("/a/b/Test Repository");
}
-
- @SuppressWarnings( "synthetic-access" )
- public Path getPathInConfiguration() {
- return context.getValueFactories().getPathFactory().create("/a/b/Test Repository");
- }
};
source = new FederatedRepositorySource();
Modified: trunk/dna-graph/src/test/java/org/jboss/dna/graph/connector/test/AbstractConnectorTest.java
===================================================================
--- trunk/dna-graph/src/test/java/org/jboss/dna/graph/connector/test/AbstractConnectorTest.java 2009-06-10 21:22:09 UTC (rev 1033)
+++ trunk/dna-graph/src/test/java/org/jboss/dna/graph/connector/test/AbstractConnectorTest.java 2009-06-10 21:22:34 UTC (rev 1034)
@@ -133,18 +133,15 @@
return null; // no observers here
}
- public Graph getConfiguration() {
- Graph result = null;
+ public Subgraph getConfiguration( int depth ) {
+ Subgraph result = null;
if (configSource != null) {
- result = Graph.create(configSource, getExecutionContext());
- // use the default workspace
+ Graph config = Graph.create(configSource, getExecutionContext());
+ config.useWorkspace(null); // default workspace
+ result = config.getSubgraphOfDepth(depth).at(source.getName());
}
return result;
}
-
- public Path getPathInConfiguration() {
- return getExecutionContext().getValueFactories().getPathFactory().create(source.getName());
- }
});
// And set up the graph instance ...
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-06-10 21:22:09 UTC (rev 1033)
+++ trunk/dna-repository/src/main/java/org/jboss/dna/repository/RepositoryLibrary.java 2009-06-10 21:22:34 UTC (rev 1034)
@@ -37,6 +37,7 @@
import org.jboss.dna.common.util.CheckArg;
import org.jboss.dna.graph.ExecutionContext;
import org.jboss.dna.graph.Graph;
+import org.jboss.dna.graph.Subgraph;
import org.jboss.dna.graph.connector.RepositoryConnection;
import org.jboss.dna.graph.connector.RepositoryConnectionFactory;
import org.jboss.dna.graph.connector.RepositoryConnectionPool;
@@ -396,30 +397,24 @@
/**
* {@inheritDoc}
*
- * @see org.jboss.dna.graph.connector.RepositoryContext#getConfiguration()
+ * @see org.jboss.dna.graph.connector.RepositoryContext#getConfiguration(int)
*/
- public Graph getConfiguration() {
- Graph result = null;
+ public Subgraph getConfiguration( int depth ) {
+ Subgraph result = null;
RepositorySource configSource = getConfigurationSource();
if (configSource != null) {
- result = Graph.create(configSource, getExecutionContext());
+ Graph config = Graph.create(configSource, getExecutionContext());
String workspaceName = getConfigurationWorkspaceName();
if (workspaceName != null) {
- result.useWorkspace(workspaceName);
+ config.useWorkspace(workspaceName);
}
+ Path configPath = getPathToConfigurationRoot();
+ Path sourcePath = getExecutionContext().getValueFactories().getPathFactory().create(configPath,
+ sourceName);
+ result = config.getSubgraphOfDepth(depth).at(sourcePath);
}
return result;
}
-
- /**
- * {@inheritDoc}
- *
- * @see org.jboss.dna.graph.connector.RepositoryContext#getPathInConfiguration()
- */
- public Path getPathInConfiguration() {
- Path configPath = getPathToConfigurationRoot();
- return getExecutionContext().getValueFactories().getPathFactory().create(configPath, sourceName);
- }
};
source.initialize(repositoryContext);
RepositoryConnectionPool pool = new RepositoryConnectionPool(source);
14 years, 11 months
DNA SVN: r1033 - trunk/docs/reference/src/main/docbook/en-US/content/connectors.
by dna-commits@lists.jboss.org
Author: rhauch
Date: 2009-06-10 17:22:09 -0400 (Wed, 10 Jun 2009)
New Revision: 1033
Modified:
trunk/docs/reference/src/main/docbook/en-US/content/connectors/federation.xml
Log:
DNA-449 Federation connector does not find it's configuration when imported using the JcrConfiguration
Updated the Reference Guide's chapter on the federated connector so that it reflects the (slightly) updated approach. Note that several JavaBean properties are no longer needed, which should make it at least a little easier to configure.
Modified: trunk/docs/reference/src/main/docbook/en-US/content/connectors/federation.xml
===================================================================
--- trunk/docs/reference/src/main/docbook/en-US/content/connectors/federation.xml 2009-06-10 21:22:01 UTC (rev 1032)
+++ trunk/docs/reference/src/main/docbook/en-US/content/connectors/federation.xml 2009-06-10 21:22:09 UTC (rev 1033)
@@ -401,31 +401,21 @@
<title>Configuration</title>
<para>
The federated repository uses other &RepositorySource;s that are to be federated and a &RepositorySource; that is to be used as the
- cache of the unified contents. These are configured in another &RepositorySource; that is treated as a configuration repository.
- The &FederatedRepositorySource; class uses JavaBean properties to define the name of the configuration repository and
- the path to the "<code>dna:federation</code>" node in that configuration repository containing the information about the
- cache and federated sources. This graph structure that is expected at this location is as follows:
+ cache of the unified contents. These are configured in another &RepositorySource; that is treated as a configuration repository,
+ which should contain information about the workspaces and how other sources are projected:
</para>
<programlisting role='xml'><![CDATA[<!-- Define the federation configuration. -->
-<dna:federatedRepository xmlns:dna="http://www.jboss.org/dna"
- xmlns:jcr="http://www.jcp.org/jcr/1.0"
- dna:timeToCache="100000" >
- <dna:workspaces>
- <dna:workspace jcr:name="default">
- <!-- Define how the content in the 'Cache' source is to map to the federated cache -->
- <dna:cache dna:sourceName="Cache" dna:workspaceName="default" dna:projectionRules="/a => /" />
-
- <!-- Define how the content in the two sources maps to the federated/unified repository.
- This example puts the 'Cars' and 'Aircraft' content underneath '/vehicles', but the
- 'Configuration' content (which is defined by this file) will appear under '/'. -->
- <dna:projections>
- <dna:projection jcr:name="Cars" dna:projectionRules="/Vehicles => /" />
- <dna:projection jcr:name="Aircraft" dna:projectionRules="/Vehicles => /" />
- <dna:projection jcr:name="Configuration" dna:projectionRules="/ => /" />
- </dna:projections>
- </dna:workspace>
- </dna:workspaces>
-</dna:federatedRepository>
+<dna:workspaces>
+ <dna:workspace jcr:name="default">
+ <!-- Define how the content in the two sources maps to the federated/unified repository.
+ This example puts the 'Cars' and 'Aircraft' content underneath '/vehicles', but the
+ 'Configuration' content (which is defined by this file) will appear under '/'. -->
+ <dna:projections>
+ <dna:projection jcr:name="Cars" dna:projectionRules="/Vehicles => /" />
+ <dna:projection jcr:name="Aircraft" dna:projectionRules="/Vehicles => /" />
+ </dna:projections>
+ </dna:workspace>
+</dna:workspaces>
]]></programlisting>
<note>
<para>
@@ -440,7 +430,8 @@
<sect1>
<title>Repository Source properties</title>
<para>
- The &FederatedRepositorySource; class provides a number of JavaBean properties that control its behavior:
+ While the majority of the configuration is defined using the configuration source (as discussed above), the &FederatedRepositorySource;
+ class have have a few JavaBean properties:
</para>
<table frame='all'>
<title>&FederatedRepositorySource; properties</title>
@@ -459,23 +450,6 @@
<entry>The name of the repository source, which is used by the &RepositoryService; when obtaining a &RepositoryConnection; by name.</entry>
</row>
<row>
- <entry>configurationSourceName</entry>
- <entry>The name of the &RepositorySource; that should be used as the configuration repository, and in which is defined
- how this federated repository is to be set up and configured.
- This name is supplied to the &RepositoryConnectionFactory; that is provided to this instance when added to the
- &RepositoryLibrary;.</entry>
- </row>
- <row>
- <entry>configurationWorkspaceName</entry>
- <entry>The name of the workspace in the configuration &RepositorySource; with the content defining
- how this federated repository is to be set up and configured.</entry>
- </row>
- <row>
- <entry>configurationSourcePath</entry>
- <entry>The path to the node in the configuration repository below which a "dna:federation" node exists with the
- graph structure describing how this federated repository is to be configured.</entry>
- </row>
- <row>
<entry>retryLimit</entry>
<entry>Optional property that, if used, defines the number of times that any single operation on a &RepositoryConnection; to this source should be retried
following a communication failure. The default value is '0'.</entry>
14 years, 11 months
DNA SVN: r1032 - in trunk: dna-graph/src/main/java/org/jboss/dna/graph/connector/federation and 4 other directories.
by dna-commits@lists.jboss.org
Author: rhauch
Date: 2009-06-10 17:22:01 -0400 (Wed, 10 Jun 2009)
New Revision: 1032
Modified:
trunk/dna-graph/src/main/java/org/jboss/dna/graph/connector/RepositoryContext.java
trunk/dna-graph/src/main/java/org/jboss/dna/graph/connector/federation/FederatedRepositorySource.java
trunk/dna-graph/src/test/java/org/jboss/dna/graph/connector/federation/AbstractFederatedRepositorySourceIntegrationTest.java
trunk/dna-graph/src/test/java/org/jboss/dna/graph/connector/federation/FederatedRepositorySourceTest.java
trunk/dna-graph/src/test/java/org/jboss/dna/graph/connector/test/AbstractConnectorTest.java
trunk/dna-repository/src/main/java/org/jboss/dna/repository/RepositoryLibrary.java
trunk/dna-repository/src/main/java/org/jboss/dna/repository/RepositoryService.java
trunk/dna-repository/src/test/java/org/jboss/dna/repository/sequencer/SequencingServiceTest.java
Log:
DNA-449 Federation connector does not find it's configuration when imported using the JcrConfiguration
Changed how the FederatedRepositorySource is reading its configuration to use the new RepositoryContext approach.
Modified: trunk/dna-graph/src/main/java/org/jboss/dna/graph/connector/RepositoryContext.java
===================================================================
--- trunk/dna-graph/src/main/java/org/jboss/dna/graph/connector/RepositoryContext.java 2009-06-10 21:21:36 UTC (rev 1031)
+++ trunk/dna-graph/src/main/java/org/jboss/dna/graph/connector/RepositoryContext.java 2009-06-10 21:22:01 UTC (rev 1032)
@@ -24,7 +24,9 @@
package org.jboss.dna.graph.connector;
import org.jboss.dna.graph.ExecutionContext;
+import org.jboss.dna.graph.Graph;
import org.jboss.dna.graph.observe.Observer;
+import org.jboss.dna.graph.property.Path;
/**
* The context for a repository. This interface need not be implemented by a {@link RepositorySource}, as it is normally provided
@@ -54,4 +56,19 @@
* @return the observer, or null if the are no listeners and publishing is not required/requested
*/
Observer getObserver();
+
+ /**
+ * Get a graph to the configuration content, already configured to the correct workspace.
+ *
+ * @return the configuration graph, or null if there is no configuration
+ */
+ Graph getConfiguration();
+
+ /**
+ * Get the path within the {@link #getConfiguration() configuration} where the source is represented.
+ *
+ * @return the path to the {@link RepositorySource}'s configuration element, or null if the source is not defined within the
+ * configuration
+ */
+ Path getPathInConfiguration();
}
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-06-10 21:21:36 UTC (rev 1031)
+++ trunk/dna-graph/src/main/java/org/jboss/dna/graph/connector/federation/FederatedRepositorySource.java 2009-06-10 21:22:01 UTC (rev 1032)
@@ -74,24 +74,13 @@
*/
public static final int DEFAULT_RETRY_LIMIT = 0;
- /**
- * The default path to the node defining the configuration for a source.
- */
- public static final String DEFAULT_CONFIGURATION_PATH = "/";
-
protected static final String SOURCE_NAME = "sourceName";
protected static final String RETRY_LIMIT = "retryLimit";
- protected static final String CONFIGURATION_SOURCE_NAME = "configurationSourceName";
- protected static final String CONFIGURATION_PATH = "configurationPath";
- protected static final String CONFIGURATION_WORKSPACE_NAME = "configurationWorkspaceName";
private static final long serialVersionUID = 1L;
private volatile String name;
private volatile int retryLimit;
- private volatile String configurationSourceName;
- private volatile String configurationWorkspaceName;
- private volatile String configurationPath = DEFAULT_CONFIGURATION_PATH;
private volatile RepositorySourceCapabilities capabilities = new RepositorySourceCapabilities(true, true, false, false, true);
private volatile transient FederatedRepository configuration;
private volatile transient RepositoryContext context;
@@ -140,114 +129,6 @@
}
/**
- * Get the name of the {@link RepositorySource} that should be used to create the {@link FederatedRepository federated
- * repository configuration} as the configuration repository.
- * <p>
- * This is a required property.
- * </p>
- *
- * @return the name of the {@link RepositorySource} instance that should be used for the configuration
- * @see #setConfigurationSourceName(String)
- * @see #getConfigurationWorkspaceName()
- * @see #getConfigurationPath()
- */
- public String getConfigurationSourceName() {
- return configurationSourceName;
- }
-
- /**
- * Set the name of the {@link RepositorySource} that should be used to create the {@link FederatedRepository federated
- * repository configuration} as the configuration repository. The instance will be retrieved from the
- * {@link RepositoryConnectionFactory} instance inside the {@link RepositoryContext#getRepositoryConnectionFactory()
- * repository context} supplied during {@link RepositorySource#initialize(RepositoryContext) initialization}.
- * <p>
- * This is a required property.
- * </p>
- *
- * @param sourceName the name of the {@link RepositorySource} instance that should be used for the configuration, or null if
- * the federated repository instance is to be found in JNDI
- * @see #getConfigurationSourceName()
- * @see #setConfigurationPath(String)
- * @see #setConfigurationWorkspaceName(String)
- */
- public synchronized void setConfigurationSourceName( String sourceName ) {
- if (this.configurationSourceName == sourceName || this.configurationSourceName != null
- && this.configurationSourceName.equals(sourceName)) return; // unchanged
- this.configurationSourceName = sourceName;
- changeConfiguration();
- }
-
- /**
- * Get the name of the workspace in the {@link #getConfigurationSourceName() source} containing the configuration content for
- * this source. If this workspace name is null, the default workspace as defined by that source will be used.
- *
- * @return the name of the configuration workspace, or null if the default workspace for the
- * {@link #getConfigurationSourceName() configuration source} should be used
- * @see #getConfigurationSourceName()
- * @see #setConfigurationWorkspaceName(String)
- * @see #getConfigurationPath()
- */
- public String getConfigurationWorkspaceName() {
- return configurationWorkspaceName;
- }
-
- /**
- * Set the name of the workspace in the {@link #getConfigurationSourceName() source} containing the configuration content for
- * this source. If this workspace name is null, the default workspace as defined by that source will be used.
- *
- * @param workspaceName the name of the configuration workspace, or null if the default workspace for the
- * {@link #getConfigurationSourceName() configuration source} should be used
- * @see #setConfigurationSourceName(String)
- * @see #setConfigurationPath(String)
- * @see #getConfigurationWorkspaceName()
- */
- public synchronized void setConfigurationWorkspaceName( String workspaceName ) {
- if (this.configurationWorkspaceName == workspaceName || this.configurationWorkspaceName != null
- && this.configurationWorkspaceName.equals(workspaceName)) return; // unchanged
- this.configurationWorkspaceName = workspaceName;
- changeConfiguration();
- }
-
- /**
- * Get the path in the {@link #getConfigurationWorkspaceName() workspace} of the {@link #getConfigurationSourceName()
- * configuration source} where this source can find the content defining its configuration.
- * <p>
- * This is a required property.
- * </p>
- *
- * @return the string array of projection rules, or null if the projection rules haven't yet been set or if the federated
- * repository instance is to be found in JNDI
- * @see #getConfigurationSourceName()
- * @see #getConfigurationWorkspaceName()
- * @see #setConfigurationPath(String)
- */
- public String getConfigurationPath() {
- return configurationPath;
- }
-
- /**
- * Set the path in the {@link #getConfigurationWorkspaceName() workspace} of the {@link #getConfigurationSourceName()
- * configuration source} where this source can find the content defining its configuration.
- * <p>
- * This is a required property.
- * </p>
- *
- * @param pathInSourceToConfigurationRoot the path within the configuration source to the node that should be the root of the
- * configuration information, or null if the {@link #DEFAULT_CONFIGURATION_PATH default path} should be used
- * @see #getConfigurationPath()
- * @see #setConfigurationSourceName(String)
- * @see #setConfigurationWorkspaceName(String)
- */
- public void setConfigurationPath( String pathInSourceToConfigurationRoot ) {
- if (this.configurationPath == pathInSourceToConfigurationRoot || this.configurationPath != null
- && this.configurationPath.equals(pathInSourceToConfigurationRoot)) return;
- String path = pathInSourceToConfigurationRoot != null ? pathInSourceToConfigurationRoot : DEFAULT_CONFIGURATION_PATH;
- // Ensure one leading slash and one trailing slashes ...
- this.configurationPath = path = ("/" + path).replaceAll("^/+", "/").replaceAll("/+$", "") + "/";
- changeConfiguration();
- }
-
- /**
* {@inheritDoc}
*
* @see org.jboss.dna.graph.connector.RepositorySource#getCapabilities()
@@ -296,16 +177,15 @@
I18n msg = GraphI18n.federatedRepositorySourceMustBeInitialized;
throw new RepositorySourceException(getName(), msg.text("name", name));
}
- String configSource = getConfigurationSourceName();
- String configWorkspace = getConfigurationWorkspaceName();
- String configPath = getConfigurationPath();
- if (configSource == null) {
+
+ // Make sure there is a configuration ...
+ if (repositoryContext.getConfiguration() == null) {
I18n msg = GraphI18n.propertyIsRequiredForFederatedRepositorySource;
- throw new RepositorySourceException(getName(), msg.text("configuration source name", name));
+ throw new RepositorySourceException(getName(), msg.text("configuration", name));
}
// Load the configuration ...
- this.configuration = loadRepository(name, repositoryContext, configSource, configWorkspace, configPath);
+ this.configuration = loadRepository(name, repositoryContext);
}
config = this.configuration;
}
@@ -326,9 +206,6 @@
ref.add(new StringRefAddr(SOURCE_NAME, getName()));
ref.add(new StringRefAddr(RETRY_LIMIT, Integer.toString(getRetryLimit())));
- ref.add(new StringRefAddr(CONFIGURATION_SOURCE_NAME, getConfigurationSourceName()));
- ref.add(new StringRefAddr(CONFIGURATION_WORKSPACE_NAME, getConfigurationWorkspaceName()));
- ref.add(new StringRefAddr(CONFIGURATION_PATH, getConfigurationPath()));
return ref;
}
@@ -356,16 +233,10 @@
}
String sourceName = values.get(SOURCE_NAME);
String retryLimit = values.get(RETRY_LIMIT);
- String configSourceName = values.get(CONFIGURATION_SOURCE_NAME);
- String configSourceWorkspace = values.get(CONFIGURATION_WORKSPACE_NAME);
- String configSourcePath = values.get(CONFIGURATION_PATH);
// Create the source instance ...
FederatedRepositorySource source = new FederatedRepositorySource();
if (sourceName != null) source.setName(sourceName);
- if (configSourceName != null) source.setConfigurationSourceName(configSourceName);
- if (configSourceWorkspace != null) source.setConfigurationWorkspaceName(configSourceWorkspace);
- if (configSourcePath != null) source.setConfigurationPath(configSourcePath);
if (retryLimit != null) source.setRetryLimit(Integer.parseInt(retryLimit));
return source;
}
@@ -408,23 +279,17 @@
}
/**
- * Utility to load the current configuration for this source from the {@link #getConfigurationSourceName() configuration
- * repository}. This method may only be called after the source is {@link #initialize(RepositoryContext) initialized}.
+ * Utility to load the current configuration for this source from the {@link RepositoryContext#getConfiguration()
+ * configuration repository}. This method may only be called after the source is {@link #initialize(RepositoryContext)
+ * initialized}.
*
* @param name the name of the source; may not be null
* @param repositoryContext the repository context; may not be null
- * @param configSource the name of the configuration source; may not be null
- * @param configWorkspace the name of the workspace in the configuration source, or null if the configuration source's default
- * workspace should be used
- * @param configPath the path to the node in the configuration workspace that defines the source; may not be null
* @return the configuration; never null
* @throws RepositorySourceException if there is a problem with the configuration
*/
protected FederatedRepository loadRepository( String name,
- RepositoryContext repositoryContext,
- String configSource,
- String configWorkspace,
- String configPath ) throws RepositorySourceException {
+ RepositoryContext repositoryContext ) throws RepositorySourceException {
// All the required properties have been set ...
ExecutionContext executionContext = repositoryContext.getExecutionContext();
RepositoryConnectionFactory connectionFactory = repositoryContext.getRepositoryConnectionFactory();
@@ -434,14 +299,12 @@
ProjectionParser projectionParser = ProjectionParser.getInstance();
NamespaceRegistry registry = executionContext.getNamespaceRegistry();
- try {
- Graph config = Graph.create(configSource, connectionFactory, executionContext);
- if (configWorkspace != null) {
- configWorkspace = config.useWorkspace(configWorkspace).getName();
- } else {
- configWorkspace = config.getCurrentWorkspaceName();
- }
+ Graph config = repositoryContext.getConfiguration();
+ Path pathOfSource = repositoryContext.getPathInConfiguration();
+ assert config != null;
+ assert pathOfSource != null;
+ try {
// Read the configuration for the federated repository:
// Level 1: the node representing the federated repository
// Level 2: the "dna:workspaces" node
@@ -449,7 +312,7 @@
// Level 4: the "dna:projections" nodes
// Level 5: a node below "dna:projections" for each projection, with properties for the source name,
// workspace name, cache expiration time, and projection rules
- Subgraph repositories = config.getSubgraphOfDepth(5).at(configPath);
+ Subgraph repositories = config.getSubgraphOfDepth(5).at(pathOfSource);
// Get the name of the default workspace ...
String defaultWorkspaceName = null;
@@ -473,8 +336,8 @@
I18n msg = GraphI18n.requiredNodeDoesNotExistRelativeToNode;
throw new RepositorySourceException(msg.text(DnaLexicon.WORKSPACES.getString(registry),
repositories.getLocation().getPath().getString(registry),
- configWorkspace,
- configSource));
+ config.getCurrentWorkspaceName(),
+ config.getSourceName()));
}
// Level 3: The workspace nodes ...
@@ -502,8 +365,8 @@
workspaceNode.getLocation()
.getPath()
.getString(registry),
- configWorkspace,
- configSource));
+ config.getCurrentWorkspaceName(),
+ config.getSourceName()));
}
// Level 5: the projection nodes ...
@@ -531,6 +394,9 @@
throw t; // rethrow
} catch (Throwable t) {
I18n msg = GraphI18n.errorReadingConfigurationForFederatedRepositorySource;
+ String configSource = config.getSourceName();
+ String configWorkspace = config.getCurrentWorkspaceName();
+ String configPath = pathOfSource.getString(registry);
throw new RepositorySourceException(getName(), msg.text(name, configSource, configWorkspace, configPath), t);
}
}
Modified: trunk/dna-graph/src/test/java/org/jboss/dna/graph/connector/federation/AbstractFederatedRepositorySourceIntegrationTest.java
===================================================================
--- trunk/dna-graph/src/test/java/org/jboss/dna/graph/connector/federation/AbstractFederatedRepositorySourceIntegrationTest.java 2009-06-10 21:21:36 UTC (rev 1031)
+++ trunk/dna-graph/src/test/java/org/jboss/dna/graph/connector/federation/AbstractFederatedRepositorySourceIntegrationTest.java 2009-06-10 21:22:01 UTC (rev 1032)
@@ -43,6 +43,7 @@
import org.jboss.dna.graph.connector.RepositoryContext;
import org.jboss.dna.graph.connector.inmemory.InMemoryRepositorySource;
import org.jboss.dna.graph.connector.test.AbstractConnectorTest;
+import org.jboss.dna.graph.observe.Observer;
import org.jboss.dna.graph.property.Name;
import org.jboss.dna.graph.property.Path;
import org.jboss.dna.graph.property.PathNotFoundException;
@@ -72,10 +73,9 @@
protected ExecutionContext context;
private Map<String, InMemoryRepositorySource> sources;
protected Graph federated;
+ private RepositoryContext repositoryContext;
@Mock
private RepositoryConnectionFactory connectionFactory;
- @Mock
- private RepositoryContext repositoryContext;
/**
* @throws java.lang.Exception
@@ -88,16 +88,6 @@
configurationWorkspaceName = "configSpace";
repositoryName = "Test Repository";
- // Set up the source ...
- source = new FederatedRepositorySource();
- source.setName(repositoryName);
- sourceName = "federated source";
- source.setName(sourceName);
- source.setConfigurationSourceName(configurationSourceName);
- source.setConfigurationWorkspaceName(configurationWorkspaceName);
- source.setConfigurationPath("/a/b/Test Repository");
- source.initialize(repositoryContext);
-
// Set up the configuration repository ...
configRepositorySource = new InMemoryRepositorySource();
configRepositorySource.setName("Configuration Repository");
@@ -108,13 +98,44 @@
config.create("/a/b/Test Repository");
config.create("/a/b/Test Repository/dna:workspaces");
+ repositoryContext = new RepositoryContext() {
+ public ExecutionContext getExecutionContext() {
+ return context;
+ }
+
+ public Observer getObserver() {
+ return null;
+ }
+
+ @SuppressWarnings( "synthetic-access" )
+ public RepositoryConnectionFactory getRepositoryConnectionFactory() {
+ return connectionFactory;
+ }
+
+ @SuppressWarnings( "synthetic-access" )
+ public Graph getConfiguration() {
+ Graph result = Graph.create(configRepositorySource, context);
+ result.useWorkspace(configurationWorkspaceName);
+ return result;
+ }
+
+ public Path getPathInConfiguration() {
+ return context.getValueFactories().getPathFactory().create("/a/b/Test Repository");
+ }
+ };
+
+ // Set up the source ...
+ source = new FederatedRepositorySource();
+ source.setName(repositoryName);
+ sourceName = "federated source";
+ source.setName(sourceName);
+ source.initialize(repositoryContext);
+
// Set up the map of sources ...
sources = new HashMap<String, InMemoryRepositorySource>();
// Stub the RepositoryContext and RepositoryConnectionFactory instances ...
configRepositoryConnection = configRepositorySource.getConnection();
- stub(repositoryContext.getExecutionContext()).toReturn(context);
- stub(repositoryContext.getRepositoryConnectionFactory()).toReturn(connectionFactory);
stub(connectionFactory.createConnection(configurationSourceName)).toReturn(configRepositoryConnection);
stub(connectionFactory.createConnection(sourceName)).toAnswer(new Answer<RepositoryConnection>() {
public RepositoryConnection answer( InvocationOnMock invocation ) throws Throwable {
@@ -151,16 +172,19 @@
CheckArg.isNotNull(sourceName, "sourceName");
CheckArg.isNotNull(workspaceName, "workspaceName");
CheckArg.isNotEmpty(projectionRules, "projectionRules");
- assertThat(source.getConfigurationPath().endsWith("/"), is(true));
- String wsPath = source.getConfigurationPath() + "dna:workspaces/" + federatedWorkspace;
+ String configPath = repositoryContext.getPathInConfiguration().getString(context.getNamespaceRegistry());
+ assertThat(configPath.endsWith("/"), is(false));
+ String wsPath = configPath + "/dna:workspaces/" + federatedWorkspace;
String projectionPath = wsPath + "/dna:projections/" + projectionName;
Graph config = Graph.create(configRepositorySource, context);
config.useWorkspace(configurationWorkspaceName);
config.createIfMissing(wsPath);
config.createIfMissing(wsPath + "/dna:projections");
- config.createAt(projectionPath).with(FederatedLexicon.PROJECTION_RULES, (Object[])projectionRules).with(FederatedLexicon.SOURCE_NAME,
- sourceName).with(FederatedLexicon.WORKSPACE_NAME,
- workspaceName).and();
+ config.createAt(projectionPath)
+ .with(FederatedLexicon.PROJECTION_RULES, (Object[])projectionRules)
+ .with(FederatedLexicon.SOURCE_NAME, sourceName)
+ .with(FederatedLexicon.WORKSPACE_NAME, workspaceName)
+ .and();
// Make sure the source and workspace exist ...
graphFor(sourceName, workspaceName);
}
@@ -258,8 +282,10 @@
Path fedPath = fedNode.getLocation().getPath();
Path sourcePath = sourceNode.getLocation().getPath();
if (!fedPath.isRoot() && !sourcePath.isRoot()) {
- assertThat(fedNode.getLocation().getPath().getLastSegment().getName(),
- is(sourceNode.getLocation().getPath().getLastSegment().getName()));
+ assertThat(fedNode.getLocation().getPath().getLastSegment().getName(), is(sourceNode.getLocation()
+ .getPath()
+ .getLastSegment()
+ .getName()));
}
// The children should match ...
List<Path.Segment> fedChildren = new ArrayList<Path.Segment>();
Modified: trunk/dna-graph/src/test/java/org/jboss/dna/graph/connector/federation/FederatedRepositorySourceTest.java
===================================================================
--- trunk/dna-graph/src/test/java/org/jboss/dna/graph/connector/federation/FederatedRepositorySourceTest.java 2009-06-10 21:21:36 UTC (rev 1031)
+++ trunk/dna-graph/src/test/java/org/jboss/dna/graph/connector/federation/FederatedRepositorySourceTest.java 2009-06-10 21:22:01 UTC (rev 1032)
@@ -46,6 +46,8 @@
import org.jboss.dna.graph.connector.RepositoryConnectionFactory;
import org.jboss.dna.graph.connector.RepositoryContext;
import org.jboss.dna.graph.connector.inmemory.InMemoryRepositorySource;
+import org.jboss.dna.graph.observe.Observer;
+import org.jboss.dna.graph.property.Path;
import org.junit.Before;
import org.junit.Test;
import org.mockito.ArgumentMatcher;
@@ -68,7 +70,6 @@
private RepositoryConnection connection;
@Mock
private RepositoryConnectionFactory connectionFactory;
- @Mock
private RepositoryContext repositoryContext;
/**
@@ -80,16 +81,42 @@
context = new ExecutionContext();
configurationSourceName = "configuration";
repositoryName = "Test Repository";
+ configRepositorySource = new InMemoryRepositorySource();
+ configRepositorySource.setName("Configuration Repository");
+
+ repositoryContext = new RepositoryContext() {
+ @SuppressWarnings( "synthetic-access" )
+ public ExecutionContext getExecutionContext() {
+ return context;
+ }
+
+ public Observer getObserver() {
+ return null;
+ }
+
+ @SuppressWarnings( "synthetic-access" )
+ public RepositoryConnectionFactory getRepositoryConnectionFactory() {
+ return connectionFactory;
+ }
+
+ @SuppressWarnings( "synthetic-access" )
+ public Graph getConfiguration() {
+ Graph result = Graph.create(configRepositorySource, context);
+ result.useWorkspace("configSpace");
+ return result;
+ }
+
+ @SuppressWarnings( "synthetic-access" )
+ public Path getPathInConfiguration() {
+ return context.getValueFactories().getPathFactory().create("/a/b/Test Repository");
+ }
+ };
+
source = new FederatedRepositorySource();
source.setName(repositoryName);
sourceName = "federated source";
source.setName(sourceName);
- source.setConfigurationSourceName(configurationSourceName);
- source.setConfigurationWorkspaceName("configSpace");
- source.setConfigurationPath("/a/b/Test Repository");
source.initialize(repositoryContext);
- configRepositorySource = new InMemoryRepositorySource();
- configRepositorySource.setName("Configuration Repository");
Graph configRepository = Graph.create(configRepositorySource, context);
configRepository.createWorkspace().named("configSpace");
@@ -99,24 +126,26 @@
batch.create("/a/b/Test Repository").with(FederatedLexicon.DEFAULT_WORKSPACE_NAME, "fedSpace").and();
batch.create("/a/b/Test Repository/dna:workspaces").and();
batch.create("/a/b/Test Repository/dna:workspaces/fedSpace").and();
- batch.create("/a/b/Test Repository/dna:workspaces/fedSpace/dna:cache").with(FederatedLexicon.PROJECTION_RULES, "/ => /").with(FederatedLexicon.SOURCE_NAME,
- "cache source").with(FederatedLexicon.WORKSPACE_NAME,
- "cacheSpace").with(FederatedLexicon.TIME_TO_EXPIRE,
- 100000).and();
+ batch.create("/a/b/Test Repository/dna:workspaces/fedSpace/dna:cache")
+ .with(FederatedLexicon.PROJECTION_RULES, "/ => /")
+ .with(FederatedLexicon.SOURCE_NAME, "cache source")
+ .with(FederatedLexicon.WORKSPACE_NAME, "cacheSpace")
+ .with(FederatedLexicon.TIME_TO_EXPIRE, 100000)
+ .and();
batch.create("/a/b/Test Repository/dna:workspaces/fedSpace/dna:projections").and();
- batch.create("/a/b/Test Repository/dna:workspaces/fedSpace/dna:projections/projection1").with(FederatedLexicon.PROJECTION_RULES,
- "/ => /s1").with(FederatedLexicon.SOURCE_NAME,
- "source 1").with(FederatedLexicon.WORKSPACE_NAME,
- "s1 workspace").and();
- batch.create("/a/b/Test Repository/dna:workspaces/fedSpace/dna:projections/projection2").with(FederatedLexicon.PROJECTION_RULES,
- "/ => /s2").with(FederatedLexicon.SOURCE_NAME,
- "source 2").with(FederatedLexicon.WORKSPACE_NAME,
- "s2 worskspace").and();
+ batch.create("/a/b/Test Repository/dna:workspaces/fedSpace/dna:projections/projection1")
+ .with(FederatedLexicon.PROJECTION_RULES, "/ => /s1")
+ .with(FederatedLexicon.SOURCE_NAME, "source 1")
+ .with(FederatedLexicon.WORKSPACE_NAME, "s1 workspace")
+ .and();
+ batch.create("/a/b/Test Repository/dna:workspaces/fedSpace/dna:projections/projection2")
+ .with(FederatedLexicon.PROJECTION_RULES, "/ => /s2")
+ .with(FederatedLexicon.SOURCE_NAME, "source 2")
+ .with(FederatedLexicon.WORKSPACE_NAME, "s2 worskspace")
+ .and();
batch.execute();
configRepositoryConnection = configRepositorySource.getConnection();
- stub(repositoryContext.getExecutionContext()).toReturn(context);
- stub(repositoryContext.getRepositoryConnectionFactory()).toReturn(connectionFactory);
stub(connectionFactory.createConnection(configurationSourceName)).toReturn(configRepositoryConnection);
}
@@ -199,8 +228,6 @@
int retryLimit = 100;
source.setRetryLimit(retryLimit);
source.setName("Some source");
- source.setConfigurationSourceName("config source");
- source.setConfigurationPath("/a/b/c");
Reference ref = source.getReference();
assertThat(ref.getClassName(), is(FederatedRepositorySource.class.getName()));
@@ -215,11 +242,6 @@
assertThat((String)refAttributes.remove(FederatedRepositorySource.SOURCE_NAME), is(source.getName()));
assertThat((String)refAttributes.remove(FederatedRepositorySource.RETRY_LIMIT), is(Integer.toString(retryLimit)));
- assertThat((String)refAttributes.remove(FederatedRepositorySource.CONFIGURATION_WORKSPACE_NAME),
- is(source.getConfigurationWorkspaceName()));
- assertThat((String)refAttributes.remove(FederatedRepositorySource.CONFIGURATION_SOURCE_NAME),
- is(source.getConfigurationSourceName()));
- assertThat((String)refAttributes.remove(FederatedRepositorySource.CONFIGURATION_PATH), is("/a/b/c/"));
assertThat(refAttributes.isEmpty(), is(true));
// Recreate the object, use a newly constructed source ...
@@ -232,9 +254,6 @@
assertThat(recoveredSource.getName(), is(source.getName()));
assertThat(recoveredSource.getRetryLimit(), is(source.getRetryLimit()));
- assertThat(recoveredSource.getConfigurationSourceName(), is(source.getConfigurationSourceName()));
- assertThat(recoveredSource.getConfigurationWorkspaceName(), is(source.getConfigurationWorkspaceName()));
- assertThat(recoveredSource.getConfigurationPath(), is(source.getConfigurationPath()));
assertThat(recoveredSource.equals(source), is(true));
assertThat(source.equals(recoveredSource), is(true));
Modified: trunk/dna-graph/src/test/java/org/jboss/dna/graph/connector/test/AbstractConnectorTest.java
===================================================================
--- trunk/dna-graph/src/test/java/org/jboss/dna/graph/connector/test/AbstractConnectorTest.java 2009-06-10 21:21:36 UTC (rev 1031)
+++ trunk/dna-graph/src/test/java/org/jboss/dna/graph/connector/test/AbstractConnectorTest.java 2009-06-10 21:22:01 UTC (rev 1032)
@@ -83,6 +83,7 @@
protected static ExecutionContext context;
protected static RepositorySource source;
protected static Graph graph;
+ protected static RepositorySource configSource;
private static RepositoryConnectionFactory connectionFactory;
private static List<RepositoryConnection> openConnections;
private static boolean running;
@@ -96,6 +97,9 @@
// Set up the execution context ...
context = setUpExecutionContext(new ExecutionContext());
+ // Set up the configuration source ...
+ configSource = setUpConfigurationSource();
+
// Set up the source ...
source = setUpSource();
@@ -128,6 +132,19 @@
public Observer getObserver() {
return null; // no observers here
}
+
+ public Graph getConfiguration() {
+ Graph result = null;
+ if (configSource != null) {
+ result = Graph.create(configSource, getExecutionContext());
+ // use the default workspace
+ }
+ return result;
+ }
+
+ public Path getPathInConfiguration() {
+ return getExecutionContext().getValueFactories().getPathFactory().create(source.getName());
+ }
});
// And set up the graph instance ...
@@ -200,6 +217,17 @@
}
/**
+ * Set up a {@link RepositorySource} that contains the configuration for the source being tested (and any other sources, if
+ * needed). The source's default workspace will be used. This implementation returns null by default.
+ *
+ * @return the configuration source, or null if no configuration is needed
+ * @throws Exception if there is a problem setting up the source
+ */
+ protected RepositorySource setUpConfigurationSource() throws Exception {
+ return null;
+ }
+
+ /**
* Set up a {@link RepositorySource} that should be used for each of the unit tests.
*
* @return the repository source
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-06-10 21:21:36 UTC (rev 1031)
+++ trunk/dna-repository/src/main/java/org/jboss/dna/repository/RepositoryLibrary.java 2009-06-10 21:22:01 UTC (rev 1032)
@@ -36,6 +36,7 @@
import net.jcip.annotations.ThreadSafe;
import org.jboss.dna.common.util.CheckArg;
import org.jboss.dna.graph.ExecutionContext;
+import org.jboss.dna.graph.Graph;
import org.jboss.dna.graph.connector.RepositoryConnection;
import org.jboss.dna.graph.connector.RepositoryConnectionFactory;
import org.jboss.dna.graph.connector.RepositoryConnectionPool;
@@ -46,6 +47,7 @@
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.property.Path;
import org.jboss.dna.repository.service.AbstractServiceAdministrator;
import org.jboss.dna.repository.service.ServiceAdministrator;
@@ -110,49 +112,56 @@
private final CopyOnWriteArrayList<RepositoryConnectionPool> pools = new CopyOnWriteArrayList<RepositoryConnectionPool>();
private RepositoryConnectionFactory delegate;
private final ExecutionContext executionContext;
- private final RepositoryContext repositoryContext;
private final ObservationBus observationBus = new InMemoryObservationBus();
+ private final RepositorySource configurationSource;
+ private final String configurationWorkspaceName;
+ private final Path pathToConfigurationRoot;
/**
* Create a new manager instance.
*
- * @param executionContext the execution context, which can be used used by sources to create other {@link ExecutionContext}
- * instances with different JAAS security contexts
+ * @param configurationSource the {@link RepositorySource} that is the configuration repository
+ * @param configurationWorkspaceName the name of the workspace in the {@link RepositorySource} that is the configuration
+ * repository, or null if the default workspace of the source should be used (if there is one)
+ * @param pathToSourcesConfigurationRoot the path of the node in the configuration source repository that should be treated by
+ * this service as the root of the service's configuration; if null, then "/dna:system" is used
+ * @param context the execution context in which this service should run
* @throws IllegalArgumentException if the <code>executionContextFactory</code> reference is null
*/
- public RepositoryLibrary( final ExecutionContext executionContext ) {
- CheckArg.isNotNull(executionContext, "executionContext");
- this.executionContext = executionContext;
- final ObservationBus observationBus = this.observationBus;
- this.repositoryContext = new RepositoryContext() {
- /**
- * {@inheritDoc}
- *
- * @see org.jboss.dna.graph.connector.RepositoryContext#getExecutionContext()
- */
- public ExecutionContext getExecutionContext() {
- return executionContext;
- }
+ public RepositoryLibrary( RepositorySource configurationSource,
+ String configurationWorkspaceName,
+ Path pathToSourcesConfigurationRoot,
+ final ExecutionContext context ) {
+ CheckArg.isNotNull(configurationSource, "configurationSource");
+ CheckArg.isNotNull(context, "context");
+ CheckArg.isNotNull(pathToSourcesConfigurationRoot, "pathToSourcesConfigurationRoot");
+ this.executionContext = context;
+ this.configurationSource = configurationSource;
+ this.configurationWorkspaceName = configurationWorkspaceName;
+ this.pathToConfigurationRoot = pathToSourcesConfigurationRoot;
+ }
- /**
- * {@inheritDoc}
- *
- * @see org.jboss.dna.graph.connector.RepositoryContext#getRepositoryConnectionFactory()
- */
- public RepositoryConnectionFactory getRepositoryConnectionFactory() {
- return RepositoryLibrary.this;
- }
+ /**
+ * Get the path to the top-level of the configuration root.
+ *
+ * @return pathToConfigurationRoot
+ */
+ protected Path getPathToConfigurationRoot() {
+ return pathToConfigurationRoot;
+ }
- /**
- * {@inheritDoc}
- *
- * @see org.jboss.dna.graph.connector.RepositoryContext#getObserver()
- */
- public Observer getObserver() {
- return observationBus.hasObservers() ? observationBus : null;
- }
+ /**
+ * @return configurationSource
+ */
+ protected RepositorySource getConfigurationSource() {
+ return configurationSource;
+ }
- };
+ /**
+ * @return configurationWorkspaceName
+ */
+ protected String getConfigurationWorkspaceName() {
+ return configurationWorkspaceName;
}
/**
@@ -350,9 +359,68 @@
if (source == null) return false;
try {
this.sourcesLock.writeLock().lock();
+ final String sourceName = source.getName();
for (RepositoryConnectionPool existingPool : this.pools) {
- if (existingPool.getRepositorySource().getName().equals(source.getName())) return false;
+ if (existingPool.getRepositorySource().getName().equals(sourceName)) return false;
}
+ // Create a repository context for this source ...
+ final ObservationBus observationBus = this.observationBus;
+ RepositoryContext repositoryContext = new RepositoryContext() {
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.jboss.dna.graph.connector.RepositoryContext#getExecutionContext()
+ */
+ public ExecutionContext getExecutionContext() {
+ return getExecutionContext();
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.jboss.dna.graph.connector.RepositoryContext#getRepositoryConnectionFactory()
+ */
+ public RepositoryConnectionFactory getRepositoryConnectionFactory() {
+ return RepositoryLibrary.this;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.jboss.dna.graph.connector.RepositoryContext#getObserver()
+ */
+ public Observer getObserver() {
+ return observationBus.hasObservers() ? observationBus : null;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.jboss.dna.graph.connector.RepositoryContext#getConfiguration()
+ */
+ public Graph getConfiguration() {
+ Graph result = null;
+ RepositorySource configSource = getConfigurationSource();
+ if (configSource != null) {
+ result = Graph.create(configSource, getExecutionContext());
+ String workspaceName = getConfigurationWorkspaceName();
+ if (workspaceName != null) {
+ result.useWorkspace(workspaceName);
+ }
+ }
+ return result;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.jboss.dna.graph.connector.RepositoryContext#getPathInConfiguration()
+ */
+ public Path getPathInConfiguration() {
+ Path configPath = getPathToConfigurationRoot();
+ return getExecutionContext().getValueFactories().getPathFactory().create(configPath, sourceName);
+ }
+ };
source.initialize(repositoryContext);
RepositoryConnectionPool pool = new RepositoryConnectionPool(source);
this.pools.add(pool);
Modified: trunk/dna-repository/src/main/java/org/jboss/dna/repository/RepositoryService.java
===================================================================
--- trunk/dna-repository/src/main/java/org/jboss/dna/repository/RepositoryService.java 2009-06-10 21:21:36 UTC (rev 1031)
+++ trunk/dna-repository/src/main/java/org/jboss/dna/repository/RepositoryService.java 2009-06-10 21:22:01 UTC (rev 1032)
@@ -44,6 +44,7 @@
import org.jboss.dna.graph.connector.RepositorySource;
import org.jboss.dna.graph.property.Name;
import org.jboss.dna.graph.property.Path;
+import org.jboss.dna.graph.property.PathFactory;
import org.jboss.dna.graph.property.PathNotFoundException;
import org.jboss.dna.graph.property.Property;
import org.jboss.dna.graph.property.PropertyType;
@@ -124,10 +125,11 @@
ExecutionContext context ) {
CheckArg.isNotNull(configurationSource, "configurationSource");
CheckArg.isNotNull(context, "context");
- if (pathToConfigurationRoot == null) pathToConfigurationRoot = context.getValueFactories()
- .getPathFactory()
- .create("/dna:system");
- this.sources = new RepositoryLibrary(context);
+ PathFactory pathFactory = context.getValueFactories().getPathFactory();
+ if (pathToConfigurationRoot == null) pathToConfigurationRoot = pathFactory.create("/dna:system");
+ Path sourcesPath = pathFactory.create(pathToConfigurationRoot, DnaLexicon.SOURCES);
+
+ this.sources = new RepositoryLibrary(configurationSource, configurationWorkspaceName, sourcesPath, context);
this.sources.addSource(configurationSource);
this.pathToConfigurationRoot = pathToConfigurationRoot;
this.configurationSourceName = configurationSource.getName();
Modified: trunk/dna-repository/src/test/java/org/jboss/dna/repository/sequencer/SequencingServiceTest.java
===================================================================
--- trunk/dna-repository/src/test/java/org/jboss/dna/repository/sequencer/SequencingServiceTest.java 2009-06-10 21:21:36 UTC (rev 1031)
+++ trunk/dna-repository/src/test/java/org/jboss/dna/repository/sequencer/SequencingServiceTest.java 2009-06-10 21:22:01 UTC (rev 1032)
@@ -36,6 +36,7 @@
import org.jboss.dna.graph.ExecutionContext;
import org.jboss.dna.graph.Graph;
import org.jboss.dna.graph.connector.inmemory.InMemoryRepositorySource;
+import org.jboss.dna.graph.property.Path;
import org.jboss.dna.repository.RepositoryLibrary;
import org.jboss.dna.repository.service.ServiceAdministrator;
import org.junit.After;
@@ -59,7 +60,12 @@
@Before
public void beforeEach() {
- sources = new RepositoryLibrary(new ExecutionContext());
+ ExecutionContext context = new ExecutionContext();
+ InMemoryRepositorySource configSource = new InMemoryRepositorySource();
+ configSource.setDefaultWorkspaceName("default");
+ Path configPath = context.getValueFactories().getPathFactory().create("/");
+
+ sources = new RepositoryLibrary(configSource, "default", configPath, context);
InMemoryRepositorySource source = new InMemoryRepositorySource();
source.setName(REPOSITORY_SOURCE_NAME);
sources.addSource(source);
14 years, 11 months
DNA SVN: r1031 - in trunk/dna-repository/src: test/java/org/jboss/dna/repository and 1 other directories.
by dna-commits@lists.jboss.org
Author: rhauch
Date: 2009-06-10 17:21:36 -0400 (Wed, 10 Jun 2009)
New Revision: 1031
Modified:
trunk/dna-repository/src/main/java/org/jboss/dna/repository/RepositoryLibrary.java
trunk/dna-repository/src/main/java/org/jboss/dna/repository/RepositoryService.java
trunk/dna-repository/src/test/java/org/jboss/dna/repository/RepositoryServiceTest.java
trunk/dna-repository/src/test/java/org/jboss/dna/repository/sequencer/SequencingServiceTest.java
Log:
DNA-449 Federation connector does not find it's configuration when imported using the JcrConfiguration
Cleaned up several unused constructors that added quite a bit of complication to the classes.
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-06-10 19:56:53 UTC (rev 1030)
+++ trunk/dna-repository/src/main/java/org/jboss/dna/repository/RepositoryLibrary.java 2009-06-10 21:21:36 UTC (rev 1031)
@@ -115,45 +115,13 @@
/**
* Create a new manager instance.
- */
- public RepositoryLibrary() {
- this(new ExecutionContext(), null);
- }
-
- /**
- * Create a new manager instance.
*
- * @param delegate the connection factory to which this instance should delegate in the event that a source is not found in
- * this manager; may be null if there is no delegate
- */
- public RepositoryLibrary( RepositoryConnectionFactory delegate ) {
- this(new ExecutionContext(), delegate);
- }
-
- /**
- * Create a new manager instance.
- *
* @param executionContext the execution context, which can be used used by sources to create other {@link ExecutionContext}
* instances with different JAAS security contexts
* @throws IllegalArgumentException if the <code>executionContextFactory</code> reference is null
*/
- public RepositoryLibrary( ExecutionContext executionContext ) {
- this(executionContext, null);
- }
-
- /**
- * Create a new manager instance.
- *
- * @param executionContext the execution context, which can be used used by sources to create other {@link ExecutionContext}
- * instances with different JAAS security contexts
- * @param delegate the connection factory to which this instance should delegate in the event that a source is not found in
- * this manager; may be null if there is no delegate
- * @throws IllegalArgumentException if the <code>executionContextFactory</code> reference is null
- */
- public RepositoryLibrary( final ExecutionContext executionContext,
- RepositoryConnectionFactory delegate ) {
+ public RepositoryLibrary( final ExecutionContext executionContext ) {
CheckArg.isNotNull(executionContext, "executionContext");
- this.delegate = delegate;
this.executionContext = executionContext;
final ObservationBus observationBus = this.observationBus;
this.repositoryContext = new RepositoryContext() {
@@ -213,26 +181,6 @@
}
/**
- * Get the delegate connection factory.
- *
- * @return the connection factory to which this instance should delegate in the event that a source is not found in this
- * manager, or null if there is no delegate
- */
- public RepositoryConnectionFactory getDelegate() {
- return delegate;
- }
-
- /**
- * Set the delegate connection factory.
- *
- * @param delegate the connection factory to which this instance should delegate in the event that a source is not found in
- * this manager; may be null if there is no delegate
- */
- public void setDelegate( RepositoryConnectionFactory delegate ) {
- this.delegate = delegate;
- }
-
- /**
* @return administrator
*/
public ServiceAdministrator getAdministrator() {
Modified: trunk/dna-repository/src/main/java/org/jboss/dna/repository/RepositoryService.java
===================================================================
--- trunk/dna-repository/src/main/java/org/jboss/dna/repository/RepositoryService.java 2009-06-10 19:56:53 UTC (rev 1030)
+++ trunk/dna-repository/src/main/java/org/jboss/dna/repository/RepositoryService.java 2009-06-10 21:21:36 UTC (rev 1031)
@@ -107,55 +107,6 @@
private final AtomicBoolean started = new AtomicBoolean(false);
/**
- * Create a service instance, reading the configuration describing new {@link RepositorySource} instances from the source with
- * the supplied name.
- *
- * @param sources the source manager
- * @param configurationSourceName the name of the {@link RepositorySource} that is the configuration repository
- * @param configurationWorkspaceName the name of the workspace in the {@link RepositorySource} that is the configuration
- * repository
- * @param context the execution context in which this service should run
- * @throws IllegalArgumentException if the bootstrap source is null or the execution context is null
- */
- public RepositoryService( RepositoryLibrary sources,
- String configurationSourceName,
- String configurationWorkspaceName,
- ExecutionContext context ) {
- this(sources, configurationSourceName, configurationWorkspaceName, null, context);
- }
-
- /**
- * Create a service instance, reading the configuration describing new {@link RepositorySource} instances from the source with
- * the supplied name and path within the repository.
- *
- * @param sources the source manager
- * @param configurationSourceName the name of the {@link RepositorySource} that is the configuration repository
- * @param configurationWorkspaceName the name of the workspace in the {@link RepositorySource} that is the configuration
- * repository, or null if the default workspace of the source should be used (if there is one)
- * @param pathToConfigurationRoot the path of the node in the configuration source repository that should be treated by this
- * service as the root of the service's configuration; if null, then "/dna:system" is used
- * @param context the execution context in which this service should run
- * @throws IllegalArgumentException if the bootstrap source is null or the execution context is null
- */
- public RepositoryService( RepositoryLibrary sources,
- String configurationSourceName,
- String configurationWorkspaceName,
- Path pathToConfigurationRoot,
- ExecutionContext context ) {
- CheckArg.isNotNull(configurationSourceName, "configurationSourceName");
- CheckArg.isNotNull(sources, "sources");
- CheckArg.isNotNull(context, "context");
- if (pathToConfigurationRoot == null) pathToConfigurationRoot = context.getValueFactories()
- .getPathFactory()
- .create("/dna:system");
- this.sources = sources;
- this.pathToConfigurationRoot = pathToConfigurationRoot;
- this.configurationSourceName = configurationSourceName;
- this.configurationWorkspaceName = configurationWorkspaceName;
- this.context = context;
- }
-
- /**
* Create a service instance, reading the configuration describing new {@link RepositorySource} instances from the supplied
* configuration repository.
*
@@ -176,7 +127,7 @@
if (pathToConfigurationRoot == null) pathToConfigurationRoot = context.getValueFactories()
.getPathFactory()
.create("/dna:system");
- this.sources = new RepositoryLibrary();
+ this.sources = new RepositoryLibrary(context);
this.sources.addSource(configurationSource);
this.pathToConfigurationRoot = pathToConfigurationRoot;
this.configurationSourceName = configurationSource.getName();
Modified: trunk/dna-repository/src/test/java/org/jboss/dna/repository/RepositoryServiceTest.java
===================================================================
--- trunk/dna-repository/src/test/java/org/jboss/dna/repository/RepositoryServiceTest.java 2009-06-10 19:56:53 UTC (rev 1030)
+++ trunk/dna-repository/src/test/java/org/jboss/dna/repository/RepositoryServiceTest.java 2009-06-10 21:21:36 UTC (rev 1031)
@@ -29,14 +29,10 @@
import static org.hamcrest.core.IsNull.nullValue;
import static org.hamcrest.core.IsSame.sameInstance;
import static org.junit.Assert.assertThat;
-import static org.junit.matchers.JUnitMatchers.hasItems;
import static org.mockito.Mockito.stub;
-import static org.mockito.Mockito.times;
-import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.verifyNoMoreInteractions;
import java.util.concurrent.TimeUnit;
import org.jboss.dna.common.util.Logger;
-import org.jboss.dna.connector.federation.FederationException;
import org.jboss.dna.graph.DnaLexicon;
import org.jboss.dna.graph.ExecutionContext;
import org.jboss.dna.graph.Graph;
@@ -80,7 +76,7 @@
RepositoryConnection configRepositoryConnection = configRepositorySource.getConnection();
stub(sources.createConnection(configSourceName)).toReturn(configRepositoryConnection);
root = context.getValueFactories().getPathFactory().createRootPath();
- service = new RepositoryService(sources, configSourceName, configWorkspaceName, context);
+ service = new RepositoryService(configRepositorySource, configWorkspaceName, root, context);
}
@After
@@ -120,66 +116,7 @@
assertThat(service.getAdministrator().getState(), is(ServiceAdministrator.State.TERMINATED));
}
- @Test( expected = FederationException.class )
- public void shouldFailToStartUpIfConfigurationRepositorySourceIsNotFound() throws Exception {
- stub(sources.createConnection(configSourceName)).toReturn(null);
- service.getAdministrator().start();
- }
-
- @Test( expected = FederationException.class )
- public void shouldFailToStartUpIfUnableToConnectToConfigurationRepository() throws Exception {
- stub(sources.createConnection(configSourceName)).toThrow(new UnsupportedOperationException());
- service.getAdministrator().start();
- }
-
@Test
- public void shouldStartUpUsingConfigurationRepositoryThatContainsSomeSources() throws Exception {
- // Use a real source manager for this test ...
- sources = new RepositoryLibrary(sources);
- sources.addSource(configRepositorySource);
- assertThat(sources.getSources(), hasItems((RepositorySource)configRepositorySource));
- assertThat(sources.getSources().size(), is(1));
- service = new RepositoryService(sources, configSourceName, configWorkspaceName, root, context);
-
- // Set up the configuration repository to contain 3 sources ...
- final String className = InMemoryRepositorySource.class.getName();
- configRepository.create("/dna:sources");
- configRepository.create("/dna:sources/source A");
- configRepository.set(DnaLexicon.CLASSNAME).on("/dna:sources/source A").to(className);
- configRepository.set(DnaLexicon.CLASSPATH).on("/dna:sources/source A").to("");
- configRepository.set("retryLimit").on("/dna:sources/source A").to(3);
-
- configRepository.create("/dna:sources/source B");
- configRepository.set(DnaLexicon.CLASSNAME).on("/dna:sources/source B").to(className);
- configRepository.set(DnaLexicon.CLASSPATH).on("/dna:sources/source B").to("");
-
- configRepository.create("/dna:sources/source C");
- configRepository.set(DnaLexicon.CLASSNAME).on("/dna:sources/source C").to(className);
- configRepository.set(DnaLexicon.CLASSPATH).on("/dna:sources/source C").to("");
-
- // Now, start up the service ...
- service.getAdministrator().start();
-
- // and verify that the sources were added to the manager...
- assertThat(sources.getSources().size(), is(4));
- assertThat(sources.getSource("source A"), is(instanceOf(InMemoryRepositorySource.class)));
- assertThat(sources.getSource("source B"), is(instanceOf(InMemoryRepositorySource.class)));
- assertThat(sources.getSource("source C"), is(instanceOf(InMemoryRepositorySource.class)));
-
- InMemoryRepositorySource sourceA = (InMemoryRepositorySource)sources.getSource("source A");
- assertThat(sourceA.getName(), is("source A"));
- assertThat(sourceA.getRetryLimit(), is(3));
-
- InMemoryRepositorySource sourceB = (InMemoryRepositorySource)sources.getSource("source B");
- assertThat(sourceB.getName(), is("source B"));
- assertThat(sourceB.getRetryLimit(), is(InMemoryRepositorySource.DEFAULT_RETRY_LIMIT));
-
- InMemoryRepositorySource sourceC = (InMemoryRepositorySource)sources.getSource("source C");
- assertThat(sourceC.getName(), is("source C"));
- assertThat(sourceC.getRetryLimit(), is(InMemoryRepositorySource.DEFAULT_RETRY_LIMIT));
- }
-
- @Test
public void shouldStartUpUsingConfigurationRepositoryThatContainsNoSources() throws Exception {
// Set up the configuration repository to contain NO sources ...
configRepository.create("/dna:sources");
@@ -187,9 +124,6 @@
// Now, start up the service ...
service.getAdministrator().start();
- // and verify that the configuration source was obtained from the manager ...
- verify(sources, times(2)).createConnection(configSourceName); // once for checking source, second for getting
-
// and verify that the sources were never added to the manager...
verifyNoMoreInteractions(sources);
}
@@ -254,9 +188,8 @@
@Test
public void shouldConfigureRepositorySourceWithSetterThatTakesArrayButWithSingleValues() {
- RepositoryLibrary sources = new RepositoryLibrary(context);
- sources.addSource(configRepositorySource);
- service = new RepositoryService(sources, configSourceName, configWorkspaceName, context);
+ Path configPath = context.getValueFactories().getPathFactory().create("/dna:system");
+ service = new RepositoryService(configRepositorySource, configWorkspaceName, configPath, context);
// Set up the configuration repository ...
configRepository.useWorkspace("default");
Modified: trunk/dna-repository/src/test/java/org/jboss/dna/repository/sequencer/SequencingServiceTest.java
===================================================================
--- trunk/dna-repository/src/test/java/org/jboss/dna/repository/sequencer/SequencingServiceTest.java 2009-06-10 19:56:53 UTC (rev 1030)
+++ trunk/dna-repository/src/test/java/org/jboss/dna/repository/sequencer/SequencingServiceTest.java 2009-06-10 21:21:36 UTC (rev 1031)
@@ -59,7 +59,7 @@
@Before
public void beforeEach() {
- sources = new RepositoryLibrary();
+ sources = new RepositoryLibrary(new ExecutionContext());
InMemoryRepositorySource source = new InMemoryRepositorySource();
source.setName(REPOSITORY_SOURCE_NAME);
sources.addSource(source);
14 years, 11 months
DNA SVN: r1030 - in trunk/extensions: dna-web-jcr-rest-war/src/test/java/org/jboss/dna/web/jcr/rest and 1 other directory.
by dna-commits@lists.jboss.org
Author: bcarothers
Date: 2009-06-10 15:56:53 -0400 (Wed, 10 Jun 2009)
New Revision: 1030
Modified:
trunk/extensions/dna-web-jcr-rest-war/src/test/java/org/jboss/dna/web/jcr/rest/JcrResourcesTest.java
trunk/extensions/dna-web-jcr-rest/src/main/java/org/jboss/dna/web/jcr/rest/JcrResources.java
Log:
DNA-447 Make REST PUT Method Support add/removeMixin Like POST Method
Added check to JcrResources.setPropertyOnNode to handle the special case of the jcr:mixinTypes property and a corresponding test case.
Also added missing node.save() call for PUT handler.
Modified: trunk/extensions/dna-web-jcr-rest/src/main/java/org/jboss/dna/web/jcr/rest/JcrResources.java
===================================================================
--- trunk/extensions/dna-web-jcr-rest/src/main/java/org/jboss/dna/web/jcr/rest/JcrResources.java 2009-06-10 15:01:21 UTC (rev 1029)
+++ trunk/extensions/dna-web-jcr-rest/src/main/java/org/jboss/dna/web/jcr/rest/JcrResources.java 2009-06-10 19:56:53 UTC (rev 1030)
@@ -25,10 +25,13 @@
import java.io.IOException;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.HashMap;
+import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
+import java.util.Set;
import javax.jcr.Item;
import javax.jcr.Node;
import javax.jcr.NodeIterator;
@@ -38,6 +41,7 @@
import javax.jcr.RepositoryException;
import javax.jcr.Session;
import javax.jcr.Value;
+import javax.jcr.nodetype.NodeType;
import javax.jcr.nodetype.PropertyDefinition;
import javax.servlet.http.HttpServletRequest;
import javax.ws.rs.Consumes;
@@ -122,17 +126,17 @@
* @return an active session with the given workspace in the named repository
* @throws RepositoryException if any other error occurs
*/
- private Session getSession( HttpServletRequest request,
+ private Session getSession( HttpServletRequest request,
String rawRepositoryName,
String rawWorkspaceName ) throws NotFoundException, RepositoryException {
assert request != null;
- assert request.getUserPrincipal() != null: "Request must be authorized";
+ assert request.getUserPrincipal() != null : "Request must be authorized";
// Sanity check
if (request.getUserPrincipal() == null) {
throw new UnauthorizedException("Client is not authorized");
}
-
+
return RepositoryFactory.getSession(request, repositoryNameFor(rawRepositoryName), workspaceNameFor(rawWorkspaceName));
}
@@ -177,7 +181,7 @@
public Map<String, WorkspaceEntry> getWorkspaces( @Context HttpServletRequest request,
@PathParam( "repositoryName" ) String rawRepositoryName )
throws RepositoryException, IOException {
-
+
assert request != null;
assert rawRepositoryName != null;
@@ -185,7 +189,7 @@
Session session = getSession(request, rawRepositoryName, null);
rawRepositoryName = URL_ENCODER.encode(rawRepositoryName);
-
+
for (String name : session.getWorkspace().getAccessibleWorkspaceNames()) {
if (name.trim().length() == 0) {
name = EMPTY_WORKSPACE_NAME;
@@ -221,7 +225,7 @@
@GET
@Path( "/{repositoryName}/{workspaceName}/items{path:.*}" )
@Produces( "application/json" )
- public String getItem( @Context HttpServletRequest request,
+ public String getItem( @Context HttpServletRequest request,
@PathParam( "repositoryName" ) String rawRepositoryName,
@PathParam( "workspaceName" ) String rawWorkspaceName,
@PathParam( "path" ) String path,
@@ -464,18 +468,46 @@
private void setPropertyOnNode( Node node,
String propName,
Object value ) throws RepositoryException, JSONException {
+ String[] values;
if (value instanceof JSONArray) {
JSONArray jsonValues = (JSONArray)value;
- String[] values = new String[jsonValues.length()];
+ values = new String[jsonValues.length()];
for (int i = 0; i < values.length; i++) {
values[i] = jsonValues.getString(i);
}
- node.setProperty(propName, values);
} else {
- node.setProperty(propName, (String)value);
+ values = new String[] { (String)value };
}
+ if (propName.equals(JcrResources.MIXIN_TYPES_PROPERTY)) {
+ Set<String> toBeMixins = new HashSet<String>(Arrays.asList(values));
+ Set<String> asIsMixins = new HashSet<String>();
+
+ for (NodeType nodeType : node.getMixinNodeTypes()) {
+ asIsMixins.add(nodeType.getName());
+ }
+
+ Set<String> mixinsToAdd = new HashSet<String>(toBeMixins);
+ mixinsToAdd.removeAll(asIsMixins);
+ asIsMixins.removeAll(toBeMixins);
+
+ for (String nodeType : mixinsToAdd) {
+ node.addMixin(nodeType);
+ }
+
+ for (String nodeType : asIsMixins) {
+ node.removeMixin(nodeType);
+ }
+ } else {
+ if (values.length == 1) {
+ node.setProperty(propName, values[0]);
+
+ }
+ else {
+ node.setProperty(propName, values);
+ }
+ }
}
/**
@@ -581,7 +613,7 @@
setPropertyOnNode(node, property.getName(), properties.get("value"));
}
-
+ node.save();
return jsonFor(node, 0).toString();
}
Modified: trunk/extensions/dna-web-jcr-rest-war/src/test/java/org/jboss/dna/web/jcr/rest/JcrResourcesTest.java
===================================================================
--- trunk/extensions/dna-web-jcr-rest-war/src/test/java/org/jboss/dna/web/jcr/rest/JcrResourcesTest.java 2009-06-10 15:01:21 UTC (rev 1029)
+++ trunk/extensions/dna-web-jcr-rest-war/src/test/java/org/jboss/dna/web/jcr/rest/JcrResourcesTest.java 2009-06-10 19:56:53 UTC (rev 1030)
@@ -825,4 +825,74 @@
connection.disconnect();
}
+
+ @Test
+ public void shouldBeAbleToAddAndRemoveMixinTypes() throws Exception {
+
+ URL postUrl = new URL(SERVER_URL + "/dna%3arepository/default/items/nodeWithNoMixins");
+ HttpURLConnection connection = (HttpURLConnection)postUrl.openConnection();
+
+ connection.setDoOutput(true);
+ connection.setRequestMethod("POST");
+ connection.setRequestProperty("Content-Type", MediaType.APPLICATION_JSON);
+
+ String payload = "{ \"properties\": {\"jcr:primaryType\": \"nt:unstructured\" }}";
+ connection.getOutputStream().write(payload.getBytes());
+
+ assertThat(connection.getResponseCode(), is(HttpURLConnection.HTTP_CREATED));
+ connection.disconnect();
+
+ connection = (HttpURLConnection)postUrl.openConnection();
+
+ connection.setDoOutput(true);
+ connection.setRequestMethod("PUT");
+ connection.setRequestProperty("Content-Type", MediaType.APPLICATION_JSON);
+
+ payload = "{\"jcr:mixinTypes\": \"mix:referenceable\"}";
+ connection.getOutputStream().write(payload.getBytes());
+
+ JSONObject body = new JSONObject(getResponseFor(connection));
+ assertThat(body.length(), is(1));
+
+ JSONObject properties = body.getJSONObject("properties");
+ assertThat(properties, is(notNullValue()));
+
+ assertThat(properties.length(), is(3));
+ assertThat(properties.getString("jcr:primaryType"), is("nt:unstructured"));
+ JSONArray mixinTypes = properties.getJSONArray("jcr:mixinTypes");
+ assertThat(mixinTypes, is(notNullValue()));
+ assertThat(mixinTypes.length(), is(1));
+ assertThat(mixinTypes.getString(0), is("mix:referenceable"));
+ assertThat(properties.getString("jcr:uuid"), is(notNullValue()));
+
+ assertThat(connection.getResponseCode(), is(HttpURLConnection.HTTP_OK));
+ connection.disconnect();
+
+ connection = (HttpURLConnection)postUrl.openConnection();
+
+ connection.setDoOutput(true);
+ connection.setRequestMethod("PUT");
+ connection.setRequestProperty("Content-Type", MediaType.APPLICATION_JSON);
+
+ payload = "{\"jcr:mixinTypes\": []}";
+ connection.getOutputStream().write(payload.getBytes());
+
+ body = new JSONObject(getResponseFor(connection));
+ assertThat(body.length(), is(1));
+
+ properties = body.getJSONObject("properties");
+ assertThat(properties, is(notNullValue()));
+ assertThat(properties.length(), is(2));
+ assertThat(properties.getString("jcr:primaryType"), is("nt:unstructured"));
+
+ // removeMixin doesn't currently null out this value
+ mixinTypes = properties.getJSONArray("jcr:mixinTypes");
+ assertThat(mixinTypes, is(notNullValue()));
+ assertThat(mixinTypes.length(), is(0));
+
+ assertThat(connection.getResponseCode(), is(HttpURLConnection.HTTP_OK));
+ connection.disconnect();
+
+ }
+
}
14 years, 11 months
DNA SVN: r1029 - in trunk/dna-repository/src: test/java/org/jboss/dna/repository/sequencer and 1 other directory.
by dna-commits@lists.jboss.org
Author: rhauch
Date: 2009-06-10 11:01:21 -0400 (Wed, 10 Jun 2009)
New Revision: 1029
Modified:
trunk/dna-repository/src/main/java/org/jboss/dna/repository/sequencer/StreamSequencerAdapter.java
trunk/dna-repository/src/test/java/org/jboss/dna/repository/sequencer/StreamSequencerAdapterTest.java
Log:
DNA-443 Java sequencer is not saving content correctly
Corrected a JavaDoc error and removed unused import in a test case.
Modified: trunk/dna-repository/src/main/java/org/jboss/dna/repository/sequencer/StreamSequencerAdapter.java
===================================================================
--- trunk/dna-repository/src/main/java/org/jboss/dna/repository/sequencer/StreamSequencerAdapter.java 2009-06-10 14:53:55 UTC (rev 1028)
+++ trunk/dna-repository/src/main/java/org/jboss/dna/repository/sequencer/StreamSequencerAdapter.java 2009-06-10 15:01:21 UTC (rev 1029)
@@ -212,7 +212,7 @@
* Save the sequencing output to the supplied node. This method does not need to save the output, as that is done by the
* caller of this method.
*
- * @param outputNode the existing node onto (or below) which the output is to be written; never null
+ * @param nodePath the existing node onto (or below) which the output is to be written; never null
* @param output the (immutable) sequencing output; never null
* @param context the execution context for this sequencing operation; never null
* @param builtPaths a set of the paths that have already been created but not submitted in this batch
@@ -267,7 +267,8 @@
Path path = factories.getPathFactory().create(input.getLocation().getPath());
Set<org.jboss.dna.graph.property.Property> props = new HashSet<org.jboss.dna.graph.property.Property>(
- input.getPropertiesByName().values());
+ input.getPropertiesByName()
+ .values());
props = Collections.unmodifiableSet(props);
String mimeType = getMimeType(context, sequencedProperty, path.getLastSegment().getName().getLocalName());
return new StreamSequencerContext(context.getExecutionContext(), path, props, mimeType, problems);
Modified: trunk/dna-repository/src/test/java/org/jboss/dna/repository/sequencer/StreamSequencerAdapterTest.java
===================================================================
--- trunk/dna-repository/src/test/java/org/jboss/dna/repository/sequencer/StreamSequencerAdapterTest.java 2009-06-10 14:53:55 UTC (rev 1028)
+++ trunk/dna-repository/src/test/java/org/jboss/dna/repository/sequencer/StreamSequencerAdapterTest.java 2009-06-10 15:01:21 UTC (rev 1029)
@@ -37,7 +37,6 @@
import java.util.EnumSet;
import java.util.HashSet;
import java.util.Iterator;
-import java.util.List;
import java.util.Map;
import java.util.Set;
import org.jboss.dna.common.collection.Problems;
@@ -530,16 +529,16 @@
problems);
assertThat(sequencerContext.getMimeType(), is("text/plain"));
}
-
- private Name nameFor(String raw) {
+
+ private Name nameFor( String raw ) {
return context.getValueFactories().getNameFactory().create(raw);
}
-
+
@Test
public void shouldNotCreateExtraNodesWhenSavingOutput() throws Exception {
SequencerOutputMap output = new SequencerOutputMap(context.getValueFactories());
Map<Name, Property> props;
-
+
/*
* Create several output properties and make sure the resulting graph
* does not contain duplicate nodes
@@ -549,38 +548,38 @@
output.setProperty("a/b", "property2", "value2");
output.setProperty("a/b[2]", "property1", "value1");
output.setProperty("a/b[2]/c", "property1", "value1");
-
+
Set<Path> builtPaths = new HashSet<Path>();
sequencer.saveOutput("/", output, seqContext, builtPaths);
seqContext.getDestination().submit();
-
+
Node rootNode = graph.getNodeAt("/");
assertThat(rootNode.getChildren().size(), is(1));
-
+
Node nodeA = graph.getNodeAt("/a");
props = nodeA.getPropertiesByName();
assertThat(nodeA.getChildren().size(), is(2));
- assertThat(props.size(), is(2)); // Need to add one to account for dna:uuid
+ assertThat(props.size(), is(2)); // Need to add one to account for dna:uuid
assertThat(props.get(nameFor("property1")).getFirstValue().toString(), is("value1"));
Node nodeB = graph.getNodeAt("/a/b[1]");
props = nodeB.getPropertiesByName();
-
- assertThat(props.size(), is(3)); // Need to add one to account for dna:uuid
+
+ assertThat(props.size(), is(3)); // Need to add one to account for dna:uuid
assertThat(props.get(nameFor("property1")).getFirstValue().toString(), is("value1"));
assertThat(props.get(nameFor("property2")).getFirstValue().toString(), is("value2"));
Node nodeB2 = graph.getNodeAt("/a/b[2]");
props = nodeB2.getPropertiesByName();
-
- assertThat(props.size(), is(2)); // Need to add one to account for dna:uuid
+
+ assertThat(props.size(), is(2)); // Need to add one to account for dna:uuid
assertThat(props.get(nameFor("property1")).getFirstValue().toString(), is("value1"));
Node nodeC = graph.getNodeAt("/a/b[2]/c");
props = nodeC.getPropertiesByName();
-
- assertThat(props.size(), is(2)); // Need to add one to account for dna:uuid
+
+ assertThat(props.size(), is(2)); // Need to add one to account for dna:uuid
assertThat(props.get(nameFor("property1")).getFirstValue().toString(), is("value1"));
}
14 years, 11 months
DNA SVN: r1028 - in trunk/dna-repository/src: test/java/org/jboss/dna/repository/sequencer and 1 other directory.
by dna-commits@lists.jboss.org
Author: bcarothers
Date: 2009-06-10 10:53:55 -0400 (Wed, 10 Jun 2009)
New Revision: 1028
Modified:
trunk/dna-repository/src/main/java/org/jboss/dna/repository/sequencer/StreamSequencerAdapter.java
trunk/dna-repository/src/test/java/org/jboss/dna/repository/sequencer/StreamSequencerAdapterTest.java
Log:
DNA-443 Java sequencer is not saving content correctly
Applied patch that changes all of the node creation to use the destination instead of doing direct writes to the graph. Had to add an accumulator to keep track of the created paths. This should have a beneficial effect on performance over the use of createIfMissing, since it avoids having to continually read in the nodes at the root of the graph. The patch also adds a new test case to verify that the StreamSequencerAdapter is not creating extra nodes.
Modified: trunk/dna-repository/src/main/java/org/jboss/dna/repository/sequencer/StreamSequencerAdapter.java
===================================================================
--- trunk/dna-repository/src/main/java/org/jboss/dna/repository/sequencer/StreamSequencerAdapter.java 2009-06-10 04:43:17 UTC (rev 1027)
+++ trunk/dna-repository/src/main/java/org/jboss/dna/repository/sequencer/StreamSequencerAdapter.java 2009-06-10 14:53:55 UTC (rev 1028)
@@ -138,6 +138,9 @@
}
}
+ // Accumulator of paths that we've added to the batch but have not yet been submitted to the graph
+ Set<Path> builtPaths = new HashSet<Path>();
+
// Find each output node and save the image metadata there ...
for (RepositoryNodePath outputPath : outputPaths) {
// Get the name of the repository workspace and the path to the output node
@@ -147,11 +150,11 @@
// Find or create the output node in this session ...
context.graph().useWorkspace(repositoryWorkspaceName);
- buildPathTo(nodePath, context);
- Node outputNode = context.graph().getNodeAt(nodePath);
+ buildPathTo(nodePath, context, builtPaths);
+ // Node outputNode = context.graph().getNodeAt(nodePath);
// Now save the image metadata to the output node ...
- saveOutput(outputNode, output, context);
+ saveOutput(nodePath, output, context, builtPaths);
}
context.getDestination().submit();
@@ -162,13 +165,15 @@
*
* @param nodePath the node path to create
* @param context the sequencer context under which it should be created
+ * @param builtPaths a set of the paths that have already been created but not submitted in this batch
*/
private void buildPathTo( String nodePath,
- SequencerContext context ) {
+ SequencerContext context,
+ Set<Path> builtPaths ) {
PathFactory pathFactory = context.getExecutionContext().getValueFactories().getPathFactory();
Path targetPath = pathFactory.create(nodePath);
- buildPathTo(targetPath, context);
+ buildPathTo(targetPath, context, builtPaths);
}
/**
@@ -176,9 +181,11 @@
*
* @param targetPath the node path to create
* @param context the sequencer context under which it should be created
+ * @param builtPaths a set of the paths that have already been created but not submitted in this batch
*/
private void buildPathTo( Path targetPath,
- SequencerContext context ) {
+ SequencerContext context,
+ Set<Path> builtPaths ) {
PathFactory pathFactory = context.getExecutionContext().getValueFactories().getPathFactory();
PropertyFactory propFactory = context.getExecutionContext().getPropertyFactory();
@@ -186,20 +193,19 @@
Path workingPath = pathFactory.createRootPath();
Path.Segment[] segments = targetPath.getSegmentsArray();
int i = 0;
- if (segments.length > 1) {
- Property primaryType = propFactory.create(JcrLexicon.PRIMARY_TYPE, JcrNtLexicon.UNSTRUCTURED);
- for (int max = segments.length - 1; i < max; i++) {
- workingPath = pathFactory.create(workingPath, segments[i]);
-
+ Property primaryType = propFactory.create(JcrLexicon.PRIMARY_TYPE, JcrNtLexicon.UNSTRUCTURED);
+ for (int max = segments.length; i < max; i++) {
+ workingPath = pathFactory.create(workingPath, segments[i]);
+
+ if (!builtPaths.contains(workingPath)) {
try {
context.graph().getNodeAt(workingPath);
+ } catch (PathNotFoundException pnfe) {
+ context.getDestination().create(workingPath, primaryType);
+ builtPaths.add(workingPath);
}
- catch (PathNotFoundException pnfe) {
- context.graph().create(workingPath, primaryType);
- }
}
}
- context.graph().create(targetPath);
}
/**
@@ -209,15 +215,16 @@
* @param outputNode the existing node onto (or below) which the output is to be written; never null
* @param output the (immutable) sequencing output; never null
* @param context the execution context for this sequencing operation; never null
+ * @param builtPaths a set of the paths that have already been created but not submitted in this batch
*/
- protected void saveOutput( Node outputNode,
+ protected void saveOutput( String nodePath,
SequencerOutputMap output,
- SequencerContext context ) {
+ SequencerContext context,
+ Set<Path> builtPaths ) {
if (output.isEmpty()) return;
final PathFactory pathFactory = context.getExecutionContext().getValueFactories().getPathFactory();
final PropertyFactory propertyFactory = context.getExecutionContext().getPropertyFactory();
- // TODO: Is it safe to assume that the location for this node will include a path?
- final Path outputNodePath = pathFactory.create(outputNode.getLocation().getPath());
+ final Path outputNodePath = pathFactory.create(nodePath);
// Iterate over the entries in the output, in Path's natural order (shorter paths first and in lexicographical order by
// prefix and name)
@@ -230,15 +237,15 @@
List<Property> properties = new LinkedList<Property>();
// Set all of the properties on this
for (SequencerOutputMap.PropertyValue property : entry.getPropertyValues()) {
- // String propertyName = property.getName().getString(namespaceRegistry, Path.NO_OP_ENCODER);
properties.add(propertyFactory.create(property.getName(), property.getValue()));
// TODO: Handle reference properties - currently passed in as Paths
}
if (absolutePath.getParent() != null) {
- buildPathTo(absolutePath.getParent(), context);
+ buildPathTo(absolutePath.getParent(), context, builtPaths);
}
- context.graph().create(absolutePath, properties);
+ context.getDestination().create(absolutePath, properties);
+ builtPaths.add(absolutePath);
}
}
@@ -260,8 +267,7 @@
Path path = factories.getPathFactory().create(input.getLocation().getPath());
Set<org.jboss.dna.graph.property.Property> props = new HashSet<org.jboss.dna.graph.property.Property>(
- input.getPropertiesByName()
- .values());
+ input.getPropertiesByName().values());
props = Collections.unmodifiableSet(props);
String mimeType = getMimeType(context, sequencedProperty, path.getLastSegment().getName().getLocalName());
return new StreamSequencerContext(context.getExecutionContext(), path, props, mimeType, problems);
Modified: trunk/dna-repository/src/test/java/org/jboss/dna/repository/sequencer/StreamSequencerAdapterTest.java
===================================================================
--- trunk/dna-repository/src/test/java/org/jboss/dna/repository/sequencer/StreamSequencerAdapterTest.java 2009-06-10 04:43:17 UTC (rev 1027)
+++ trunk/dna-repository/src/test/java/org/jboss/dna/repository/sequencer/StreamSequencerAdapterTest.java 2009-06-10 14:53:55 UTC (rev 1028)
@@ -37,6 +37,8 @@
import java.util.EnumSet;
import java.util.HashSet;
import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
import java.util.Set;
import org.jboss.dna.common.collection.Problems;
import org.jboss.dna.common.collection.SimpleProblems;
@@ -48,6 +50,7 @@
import org.jboss.dna.graph.mimetype.MimeTypeDetectors;
import org.jboss.dna.graph.observe.NetChangeObserver.ChangeType;
import org.jboss.dna.graph.observe.NetChangeObserver.NetChange;
+import org.jboss.dna.graph.property.Name;
import org.jboss.dna.graph.property.Path;
import org.jboss.dna.graph.property.PathNotFoundException;
import org.jboss.dna.graph.property.Property;
@@ -527,7 +530,61 @@
problems);
assertThat(sequencerContext.getMimeType(), is("text/plain"));
}
+
+ private Name nameFor(String raw) {
+ return context.getValueFactories().getNameFactory().create(raw);
+ }
+
+ @Test
+ public void shouldNotCreateExtraNodesWhenSavingOutput() throws Exception {
+ SequencerOutputMap output = new SequencerOutputMap(context.getValueFactories());
+ Map<Name, Property> props;
+
+ /*
+ * Create several output properties and make sure the resulting graph
+ * does not contain duplicate nodes
+ */
+ output.setProperty("a", "property1", "value1");
+ output.setProperty("a/b", "property1", "value1");
+ output.setProperty("a/b", "property2", "value2");
+ output.setProperty("a/b[2]", "property1", "value1");
+ output.setProperty("a/b[2]/c", "property1", "value1");
+
+ Set<Path> builtPaths = new HashSet<Path>();
+ sequencer.saveOutput("/", output, seqContext, builtPaths);
+ seqContext.getDestination().submit();
+
+ Node rootNode = graph.getNodeAt("/");
+ assertThat(rootNode.getChildren().size(), is(1));
+
+ Node nodeA = graph.getNodeAt("/a");
+ props = nodeA.getPropertiesByName();
+ assertThat(nodeA.getChildren().size(), is(2));
+ assertThat(props.size(), is(2)); // Need to add one to account for dna:uuid
+ assertThat(props.get(nameFor("property1")).getFirstValue().toString(), is("value1"));
+
+ Node nodeB = graph.getNodeAt("/a/b[1]");
+ props = nodeB.getPropertiesByName();
+
+ assertThat(props.size(), is(3)); // Need to add one to account for dna:uuid
+ assertThat(props.get(nameFor("property1")).getFirstValue().toString(), is("value1"));
+ assertThat(props.get(nameFor("property2")).getFirstValue().toString(), is("value2"));
+
+ Node nodeB2 = graph.getNodeAt("/a/b[2]");
+ props = nodeB2.getPropertiesByName();
+
+ assertThat(props.size(), is(2)); // Need to add one to account for dna:uuid
+ assertThat(props.get(nameFor("property1")).getFirstValue().toString(), is("value1"));
+
+ Node nodeC = graph.getNodeAt("/a/b[2]/c");
+ props = nodeC.getPropertiesByName();
+
+ assertThat(props.size(), is(2)); // Need to add one to account for dna:uuid
+ assertThat(props.get(nameFor("property1")).getFirstValue().toString(), is("value1"));
+
+ }
+
private void verifyProperty( StreamSequencerContext context,
String name,
Object... values ) {
14 years, 11 months