DNA SVN: r1121 - trunk.
by dna-commits@lists.jboss.org
Author: rhauch
Date: 2009-07-21 13:58:05 -0400 (Tue, 21 Jul 2009)
New Revision: 1121
Modified:
trunk/pom.xml
Log:
DNA-493 Integration tests should not be run via Maven by default
Changed the list of projects that are always included in every build to exclude the integration, documentation, and example projects. The integration project in particular has started to do more and take longer, and running these tests all the time is not necessary and is negatively impacting developer productivity. As a result, the default build (e.g., 'mvn clean install') now executes more quickly.
The Hudson builds have been changed to make use of these new profiles. The continuous now runs 'mvn clean install -P integration', and the nightly now runs 'mvn clean install -P release'. The TCK compatibility job runs 'mvn clean install -P integration,jcr-tck'.
Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml 2009-07-21 03:19:32 UTC (rev 1120)
+++ trunk/pom.xml 2009-07-21 17:58:05 UTC (rev 1121)
@@ -146,19 +146,25 @@
<module>extensions/dna-connector-jdbc-metadata</module>
<module>extensions/dna-web-jcr-rest</module>
<module>extensions/dna-web-jcr-rest-war</module>
- <module>dna-integration-tests</module>
- <module>docs/examples/gettingstarted</module>
</modules>
<profiles>
<profile>
<id>release</id>
<modules>
+ <module>dna-integration-tests</module>
<module>docs</module>
<module>docs/examples/gettingstarted</module>
</modules>
</profile>
<profile>
+ <id>integration</id>
+ <modules>
+ <module>dna-integration-tests</module>
+ <module>docs/examples/gettingstarted</module>
+ </modules>
+ </profile>
+ <profile>
<id>jcr-tck</id>
<modules>
<module>dna-jcr-tck</module>
@@ -177,6 +183,7 @@
</activation>
<modules>
<module>docs</module>
+ <module>docs/examples/gettingstarted</module>
</modules>
<reporting>
<plugins>
16 years, 9 months
DNA SVN: r1120 - in trunk: dna-jcr/src/test/java/org/jboss/dna/jcr and 2 other directories.
by dna-commits@lists.jboss.org
Author: rhauch
Date: 2009-07-20 23:19:32 -0400 (Mon, 20 Jul 2009)
New Revision: 1120
Modified:
trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/JcrRepository.java
trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/JcrSession.java
trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/JcrWorkspace.java
trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/AbstractJcrAccessTest.java
trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/AbstractSessionTest.java
trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/ImportExportTest.java
trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/JcrRepositoryTest.java
trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/RepositoryNodeTypeManagerTest.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
Log:
DNA-392 All sessions in a repository should share the same /jcr:system content
Initial commit that changed to use the federated connector within a JcrRepository implementation, and that results in all JcrSession and JcrWorkspace instances created by that JcrRepository instance to have the exact same (projected) content for the 'jcr:system' branch. All tests do pass.
Modified: trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/JcrRepository.java
===================================================================
--- trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/JcrRepository.java 2009-07-21 03:17:04 UTC (rev 1119)
+++ trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/JcrRepository.java 2009-07-21 03:19:32 UTC (rev 1120)
@@ -28,9 +28,11 @@
import java.security.AccessControlContext;
import java.security.AccessControlException;
import java.security.AccessController;
+import java.util.ArrayList;
import java.util.Collections;
import java.util.EnumMap;
import java.util.HashMap;
+import java.util.List;
import java.util.Map;
import java.util.Set;
import javax.jcr.Credentials;
@@ -49,8 +51,25 @@
import org.jboss.dna.graph.ExecutionContext;
import org.jboss.dna.graph.Graph;
import org.jboss.dna.graph.JaasSecurityContext;
+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.RepositorySource;
import org.jboss.dna.graph.connector.RepositorySourceException;
+import org.jboss.dna.graph.connector.federation.FederatedRepositorySource;
+import org.jboss.dna.graph.connector.federation.Projection;
+import org.jboss.dna.graph.connector.federation.ProjectionParser;
+import org.jboss.dna.graph.connector.inmemory.InMemoryRepositorySource;
+import org.jboss.dna.graph.observe.Changes;
+import org.jboss.dna.graph.observe.Observer;
+import org.jboss.dna.graph.property.Name;
+import org.jboss.dna.graph.property.NamespaceRegistry;
+import org.jboss.dna.graph.property.Path;
+import org.jboss.dna.graph.property.PathFactory;
+import org.jboss.dna.graph.property.Property;
+import org.jboss.dna.graph.property.PropertyFactory;
+import org.jboss.dna.graph.property.basic.GraphNamespaceRegistry;
import org.jboss.dna.graph.request.InvalidWorkspaceException;
/**
@@ -161,6 +180,11 @@
private final RepositoryConnectionFactory connectionFactory;
private final RepositoryNodeTypeManager repositoryTypeManager;
private final Map<Option, String> options;
+ private final RepositorySource systemSource;
+ private final Projection systemSourceProjection;
+ private final FederatedRepositorySource federatedSource;
+ private final Observer observer;
+ private final NamespaceRegistry persistentRegistry;
/**
* Creates a JCR repository that uses the supplied {@link RepositoryConnectionFactory repository connection factory} to
@@ -198,9 +222,6 @@
CheckArg.isNotNull(executionContext, "executionContext");
CheckArg.isNotNull(connectionFactory, "connectionFactory");
CheckArg.isNotNull(repositorySourceName, "repositorySourceName");
- this.executionContext = executionContext;
- this.connectionFactory = connectionFactory;
- this.sourceName = repositorySourceName;
Map<String, String> modifiableDescriptors;
if (descriptors == null) {
modifiableDescriptors = new HashMap<String, String>();
@@ -234,9 +255,53 @@
modifiableDescriptors.put(Repository.SPEC_VERSION_DESC, "1.0");
this.descriptors = Collections.unmodifiableMap(modifiableDescriptors);
- this.repositoryTypeManager = new RepositoryNodeTypeManager(this.executionContext);
+ // Set up the options ...
+ if (options == null) {
+ this.options = DEFAULT_OPTIONS;
+ } else {
+ // Initialize with defaults, then add supplied options ...
+ EnumMap<Option, String> localOptions = new EnumMap<Option, String>(DEFAULT_OPTIONS);
+ localOptions.putAll(options);
+ this.options = Collections.unmodifiableMap(localOptions);
+ }
+ // Initialize the observer, which receives events from all repository sources ...
+ this.observer = new RepositoryObserver();
+
+ // Create the in-memory repository source that we'll use for the "/jcr:system" branch in this repository.
+ // All workspaces will be set up with a federation connector that projects this system repository into
+ // "/jcr:system", and all other content is projected to the repositories actual source (and workspace).
+ // (The federation connector refers to this configuration as an "offset mirror".)
+ InMemoryRepositorySource systemSource = new InMemoryRepositorySource();
+ String systemWorkspaceName = "jcr:system";
+ String systemSourceName = "jcr:system source";
+ systemSource.setName(systemSourceName);
+ systemSource.setDefaultWorkspaceName(systemWorkspaceName);
+ this.systemSource = systemSource;
+ this.connectionFactory = new ConnectionFactoryWithSystem(connectionFactory, this.systemSource);
+
+ // Set up the "/jcr:system" branch ...
+ Graph systemGraph = Graph.create(this.systemSource, executionContext);
+ systemGraph.useWorkspace(systemWorkspaceName);
+ initializeSystemContent(systemGraph);
+ this.sourceName = repositorySourceName;
+
+ // Create the namespace registry and corresponding execution context.
+ // Note that this persistent registry has direct access to the system workspace.
+ Name uriProperty = DnaLexicon.NAMESPACE_URI;
+ PathFactory pathFactory = executionContext.getValueFactories().getPathFactory();
+ Path systemPath = pathFactory.create(JcrLexicon.SYSTEM);
+ Path namespacesPath = pathFactory.create(systemPath, DnaLexicon.NAMESPACES);
+ PropertyFactory propertyFactory = executionContext.getPropertyFactory();
+ Property namespaceType = propertyFactory.create(JcrLexicon.PRIMARY_TYPE, DnaLexicon.NAMESPACE);
+
+ // Now create the registry implementation ...
+ this.persistentRegistry = new GraphNamespaceRegistry(systemGraph, namespacesPath, uriProperty, namespaceType);
+ this.executionContext = executionContext.with(persistentRegistry);
+
+ // Set up the repository type manager ...
try {
+ this.repositoryTypeManager = new RepositoryNodeTypeManager(this.executionContext);
this.repositoryTypeManager.registerNodeTypes(new CndNodeTypeSource(new String[] {
"/org/jboss/dna/jcr/jsr_170_builtins.cnd", "/org/jboss/dna/jcr/dna_builtins.cnd"}));
} catch (RepositoryException re) {
@@ -246,17 +311,47 @@
ioe.printStackTrace();
throw new IllegalStateException("Could not access node type definition files", ioe);
}
+ if (Boolean.valueOf(this.options.get(Option.PROJECT_NODE_TYPES))) {
+ // Note that the node types are written directly to the system workspace.
+ Path parentOfTypeNodes = pathFactory.create(systemPath, JcrLexicon.NODE_TYPES);
+ this.repositoryTypeManager.projectOnto(systemGraph, parentOfTypeNodes);
+ }
- if (options == null) {
- this.options = DEFAULT_OPTIONS;
- } else {
- // Initialize with defaults, then add supplied options ...
- EnumMap<Option, String> localOptions = new EnumMap<Option, String>(DEFAULT_OPTIONS);
- localOptions.putAll(options);
- this.options = Collections.unmodifiableMap(localOptions);
- }
+ // Create the projection for the system repository ...
+ ProjectionParser projectionParser = ProjectionParser.getInstance();
+ String rule = "/jcr:system => /jcr:system";
+ Projection.Rule[] systemProjectionRules = projectionParser.rulesFromString(this.executionContext, rule);
+ this.systemSourceProjection = new Projection(systemSourceName, systemWorkspaceName, true, systemProjectionRules);
+
+ // Define the federated repository source. Use the same name as the repository, since this federated source
+ // will not be in the connection factory ...
+ this.federatedSource = new FederatedRepositorySource();
+ this.federatedSource.setName("JCR " + repositorySourceName);
+ this.federatedSource.initialize(new FederatedRepositoryContext(this.connectionFactory));
}
+ protected void initializeSystemContent( Graph systemGraph ) {
+ // Make sure the "/jcr:system" node exists ...
+ ExecutionContext context = systemGraph.getContext();
+ PathFactory pathFactory = context.getValueFactories().getPathFactory();
+ Path systemPath = pathFactory.create(pathFactory.createRootPath(), JcrLexicon.SYSTEM);
+ Property systemPrimaryType = context.getPropertyFactory().create(JcrLexicon.PRIMARY_TYPE, DnaLexicon.SYSTEM);
+ systemGraph.create(systemPath, systemPrimaryType).ifAbsent().and();
+
+ // Right now, the other nodes will be created as needed
+ }
+
+ Graph createWorkspaceGraph( String workspaceName ) {
+ Graph graph = Graph.create(this.federatedSource, this.executionContext);
+ graph.useWorkspace(workspaceName);
+ return graph;
+ }
+
+ Graph createSystemGraph() {
+ // The default workspace should be the system workspace ...
+ return Graph.create(this.systemSource, this.executionContext);
+ }
+
/**
* Returns the repository-level node type manager
*
@@ -279,19 +374,32 @@
* Get the name of the repository source that this repository is using.
*
* @return the name of the RepositorySource
- * @see #getConnectionFactory()
*/
String getRepositorySourceName() {
return sourceName;
}
/**
- * Get the connection factory that this repository is using.
+ * @return executionContext
+ */
+ ExecutionContext getExecutionContext() {
+ return executionContext;
+ }
+
+ /**
+ * @return persistentRegistry
+ */
+ NamespaceRegistry getPersistentRegistry() {
+ return persistentRegistry;
+ }
+
+ /**
+ * The observer to which all source events are sent.
*
- * @return the connection factory; never null
+ * @return the current observer, or null if there is no observer
*/
- RepositoryConnectionFactory getConnectionFactory() {
- return this.connectionFactory;
+ Observer getObserver() {
+ return observer;
}
/**
@@ -412,7 +520,8 @@
}
}
- // Ensure valid workspace name
+ // Ensure valid workspace name by talking directly to the source ...
+ boolean isDefault = false;
Graph graph = Graph.create(sourceName, connectionFactory, executionContext);
if (workspaceName == null) {
try {
@@ -421,15 +530,19 @@
} catch (RepositorySourceException e) {
throw new RepositoryException(JcrI18n.errorObtainingDefaultWorkspaceName.text(sourceName, e.getMessage()), e);
}
+ isDefault = true;
} else {
+ // There is a non-null workspace name ...
try {
// Verify that the workspace exists (or can be created) ...
Set<String> workspaces = graph.getWorkspaces();
if (!workspaces.contains(workspaceName)) {
+ // Make sure there isn't a federated workspace ...
+ this.federatedSource.removeWorkspace(workspaceName);
// Per JCR 1.0 6.1.1, if the workspaceName is not recognized, a NoSuchWorkspaceException is thrown
throw new NoSuchWorkspaceException(JcrI18n.workspaceNameIsInvalid.text(sourceName, workspaceName));
}
-
+
graph.useWorkspace(workspaceName);
} catch (InvalidWorkspaceException e) {
throw new NoSuchWorkspaceException(JcrI18n.workspaceNameIsInvalid.text(sourceName, workspaceName), e);
@@ -439,17 +552,28 @@
}
}
+ synchronized (this.federatedSource) {
+ if (!this.federatedSource.hasWorkspace(workspaceName)) {
+ // Add the workspace to the federated source ...
+ ProjectionParser projectionParser = ProjectionParser.getInstance();
+ Projection.Rule[] mirrorRules = projectionParser.rulesFromString(this.executionContext, "/ => /");
+ List<Projection> projections = new ArrayList<Projection>(2);
+ projections.add(new Projection(sourceName, workspaceName, false, mirrorRules));
+ projections.add(this.systemSourceProjection);
+ this.federatedSource.addWorkspace(workspaceName, projections, isDefault);
+ }
+ }
+
// Create the workspace, which will create its own session ...
sessionAttributes = Collections.unmodifiableMap(sessionAttributes);
JcrWorkspace workspace = new JcrWorkspace(this, workspaceName, execContext, sessionAttributes);
-
- JcrSession session = (JcrSession) workspace.getSession();
-
+
+ JcrSession session = (JcrSession)workspace.getSession();
+
// Need to make sure that the user has access to this session
try {
session.checkPermission(workspaceName, null, JcrSession.JCR_READ_PERMISSION);
- }
- catch (AccessControlException ace) {
+ } catch (AccessControlException ace) {
throw new NoSuchWorkspaceException(JcrI18n.workspaceNameIsInvalid.text(sourceName, workspaceName));
}
return session;
@@ -464,4 +588,84 @@
String getName() {
return this.sourceName;
}
+
+ protected class FederatedRepositoryContext implements RepositoryContext {
+ private final RepositoryConnectionFactory connectionFactory;
+
+ protected FederatedRepositoryContext( RepositoryConnectionFactory nonFederatingConnectionFactory ) {
+ this.connectionFactory = nonFederatingConnectionFactory;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.jboss.dna.graph.connector.RepositoryContext#getConfiguration(int)
+ */
+ public Subgraph getConfiguration( int depth ) {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.jboss.dna.graph.connector.RepositoryContext#getExecutionContext()
+ */
+ public ExecutionContext getExecutionContext() {
+ return JcrRepository.this.getExecutionContext();
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.jboss.dna.graph.connector.RepositoryContext#getObserver()
+ */
+ public Observer getObserver() {
+ return JcrRepository.this.getObserver();
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.jboss.dna.graph.connector.RepositoryContext#getRepositoryConnectionFactory()
+ */
+ public RepositoryConnectionFactory getRepositoryConnectionFactory() {
+ return connectionFactory;
+ }
+ }
+
+ protected class ConnectionFactoryWithSystem implements RepositoryConnectionFactory {
+ private final RepositoryConnectionFactory delegate;
+ private final RepositorySource system;
+
+ protected ConnectionFactoryWithSystem( RepositoryConnectionFactory delegate,
+ RepositorySource source ) {
+ assert delegate != null;
+ this.delegate = delegate;
+ this.system = source;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.jboss.dna.graph.connector.RepositoryConnectionFactory#createConnection(java.lang.String)
+ */
+ public RepositoryConnection createConnection( String sourceName ) throws RepositorySourceException {
+ if (this.system.getName().equals(sourceName)) {
+ return this.system.getConnection();
+ }
+ return delegate.createConnection(sourceName);
+ }
+ }
+
+ protected class RepositoryObserver implements Observer {
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.jboss.dna.graph.observe.Observer#notify(org.jboss.dna.graph.observe.Changes)
+ */
+ public void notify( Changes changes ) {
+ // does nothing at the moment, but eventually will fire to all of the listeners on the appropriate sessions
+ }
+ }
+
}
Modified: trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/JcrSession.java
===================================================================
--- trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/JcrSession.java 2009-07-21 03:17:04 UTC (rev 1119)
+++ trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/JcrSession.java 2009-07-21 03:19:32 UTC (rev 1120)
@@ -156,10 +156,7 @@
this.rootPath = this.executionContext.getValueFactories().getPathFactory().createRootPath();
// Set up the graph to use for this session (which uses the session's namespace registry and context) ...
- this.graph = Graph.create(this.repository.getRepositorySourceName(),
- this.repository.getConnectionFactory(),
- this.executionContext);
- this.graph.useWorkspace(workspace.getName());
+ this.graph = repository.createWorkspaceGraph(workspace.getName());
this.cache = new SessionCache(this);
this.isLive = true;
Modified: trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/JcrWorkspace.java
===================================================================
--- trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/JcrWorkspace.java 2009-07-21 03:17:04 UTC (rev 1119)
+++ trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/JcrWorkspace.java 2009-07-21 03:19:32 UTC (rev 1120)
@@ -62,17 +62,13 @@
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.Property;
-import org.jboss.dna.graph.property.PropertyFactory;
import org.jboss.dna.graph.property.ValueFormatException;
-import org.jboss.dna.graph.property.basic.GraphNamespaceRegistry;
import org.jboss.dna.graph.request.InvalidWorkspaceException;
import org.jboss.dna.graph.request.ReadBranchRequest;
import org.jboss.dna.graph.session.GraphSession;
import org.jboss.dna.graph.session.GraphSession.Node;
import org.jboss.dna.jcr.JcrContentHandler.EnclosingSAXException;
import org.jboss.dna.jcr.JcrContentHandler.SaveMode;
-import org.jboss.dna.jcr.JcrRepository.Option;
import org.jboss.dna.jcr.SessionCache.JcrNodePayload;
import org.jboss.dna.jcr.SessionCache.JcrPropertyPayload;
import org.xml.sax.ContentHandler;
@@ -102,8 +98,8 @@
/**
* The reference to the {@link JcrRepository} instance that owns this {@link Workspace} instance. Very few methods on this
- * repository object are used; mainly {@link JcrRepository#getConnectionFactory()} and
- * {@link JcrRepository#getRepositorySourceName()}.
+ * repository object are used; mainly {@link JcrRepository#createWorkspaceGraph(String)},
+ * {@link JcrRepository#getPersistentRegistry()} and {@link JcrRepository#getRepositorySourceName()}.
*/
private final JcrRepository repository;
@@ -149,48 +145,46 @@
this.name = workspaceName;
this.repository = repository;
- // Set up the execution context for this workspace, which should use the namespace registry that persists
- // the namespaces in the graph ...
- Graph namespaceGraph = Graph.create(this.repository.getRepositorySourceName(),
- this.repository.getConnectionFactory(),
- context);
- namespaceGraph.useWorkspace(workspaceName);
+ // // Set up the execution context for this workspace, which should use the namespace registry that persists
+ // // the namespaces in the graph ...
+ // Graph namespaceGraph = Graph.create(this.repository.getRepositorySourceName(),
+ // this.repository.getConnectionFactory(),
+ // context);
+ // namespaceGraph.useWorkspace(workspaceName);
+ //
+ // // Make sure the "/jcr:system" node exists ...
+ // PathFactory pathFactory = context.getValueFactories().getPathFactory();
+ // Path root = pathFactory.createRootPath();
+ // Path systemPath = pathFactory.create(root, JcrLexicon.SYSTEM);
+ // Property systemPrimaryType = context.getPropertyFactory().create(JcrLexicon.PRIMARY_TYPE, DnaLexicon.SYSTEM);
+ // namespaceGraph.create(systemPath, systemPrimaryType).ifAbsent().and();
+ //
+ // Name uriProperty = DnaLexicon.NAMESPACE_URI;
+ // Path namespacesPath = pathFactory.create(systemPath, DnaLexicon.NAMESPACES);
+ // PropertyFactory propertyFactory = context.getPropertyFactory();
+ // Property namespaceType = propertyFactory.create(JcrLexicon.PRIMARY_TYPE, DnaLexicon.NAMESPACE);
+ // org.jboss.dna.graph.property.NamespaceRegistry persistentRegistry = new GraphNamespaceRegistry(namespaceGraph,
+ // namespacesPath,
+ // uriProperty, namespaceType);
+ this.context = context;
- // Make sure the "/jcr:system" node exists ...
- PathFactory pathFactory = context.getValueFactories().getPathFactory();
- Path root = pathFactory.createRootPath();
- Path systemPath = pathFactory.create(root, JcrLexicon.SYSTEM);
- Property systemPrimaryType = context.getPropertyFactory().create(JcrLexicon.PRIMARY_TYPE, DnaLexicon.SYSTEM);
- namespaceGraph.create(systemPath, systemPrimaryType).ifAbsent().and();
+ // Now create a graph for the session ...
+ this.graph = this.repository.createWorkspaceGraph(workspaceName);
- Name uriProperty = DnaLexicon.NAMESPACE_URI;
- Path namespacesPath = pathFactory.create(systemPath, DnaLexicon.NAMESPACES);
- PropertyFactory propertyFactory = context.getPropertyFactory();
- Property namespaceType = propertyFactory.create(JcrLexicon.PRIMARY_TYPE, DnaLexicon.NAMESPACE);
- org.jboss.dna.graph.property.NamespaceRegistry persistentRegistry = new GraphNamespaceRegistry(namespaceGraph,
- namespacesPath,
- uriProperty, namespaceType);
- this.context = context.with(persistentRegistry);
-
- // Now create a graph with this new execution context ...
- this.graph = Graph.create(this.repository.getRepositorySourceName(), this.repository.getConnectionFactory(), this.context);
- this.graph.useWorkspace(workspaceName);
-
// Set up the session for this workspace ...
this.session = new JcrSession(this.repository, this, this.context, sessionAttributes);
// This must be initialized after the session
- RepositoryNodeTypeManager repoTypeManager = repository.getRepositoryTypeManager();
- this.nodeTypeManager = new JcrNodeTypeManager(session, repoTypeManager);
+ this.nodeTypeManager = new JcrNodeTypeManager(session, this.repository.getRepositoryTypeManager());
this.queryManager = new JcrQueryManager(this.session);
- if (Boolean.valueOf(repository.getOptions().get(Option.PROJECT_NODE_TYPES))) {
- Path parentOfTypeNodes = context.getValueFactories().getPathFactory().create(systemPath, JcrLexicon.NODE_TYPES);
- repoTypeManager.projectOnto(this.graph, parentOfTypeNodes);
- }
-
+ // if (Boolean.valueOf(repository.getOptions().get(Option.PROJECT_NODE_TYPES))) {
+ // Path parentOfTypeNodes = context.getValueFactories().getPathFactory().create(systemPath, JcrLexicon.NODE_TYPES);
+ // repoTypeManager.projectOnto(this.graph, parentOfTypeNodes);
+ // }
+ //
// Set up and initialize the persistent JCR namespace registry ...
- this.workspaceRegistry = new JcrNamespaceRegistry(persistentRegistry, this.session);
+ this.workspaceRegistry = new JcrNamespaceRegistry(this.repository.getPersistentRegistry(), this.session);
}
Modified: trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/AbstractJcrAccessTest.java
===================================================================
--- trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/AbstractJcrAccessTest.java 2009-07-21 03:17:04 UTC (rev 1119)
+++ trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/AbstractJcrAccessTest.java 2009-07-21 03:19:32 UTC (rev 1120)
@@ -32,7 +32,6 @@
import javax.jcr.NodeIterator;
import org.jboss.dna.common.statistic.Stopwatch;
import org.jboss.dna.graph.ExecutionContext;
-import org.jboss.dna.graph.Graph;
import org.jboss.dna.graph.MockSecurityContext;
import org.jboss.dna.graph.SecurityContext;
import org.jboss.dna.graph.connector.RepositoryConnection;
@@ -53,7 +52,7 @@
private InMemoryRepositorySource source;
private JcrSession session;
private JcrRepository repository;
-
+
@Before
public void beforeEach() throws Exception {
MockitoAnnotations.initMocks(this);
@@ -70,13 +69,6 @@
// Register the test namespace
context.getNamespaceRegistry().register(TestLexicon.Namespace.PREFIX, TestLexicon.Namespace.URI);
- // Set up the initial content ...
- Graph graph = Graph.create(source, context);
-
- // Make sure the path to the namespaces exists ...
- graph.create("/jcr:system").and(); // .and().create("/jcr:system/dna:namespaces");
- graph.set("jcr:primaryType").on("/jcr:system").to(DnaLexicon.SYSTEM);
-
// Stub out the connection factory ...
RepositoryConnectionFactory connectionFactory = new RepositoryConnectionFactory() {
/**
@@ -92,8 +84,9 @@
repository = new JcrRepository(context, connectionFactory, "unused");
- SecurityContext mockSecurityContext = new MockSecurityContext("testuser", Collections.singleton(JcrSession.DNA_WRITE_PERMISSION));
- session = (JcrSession) repository.login(new SecurityContextCredentials(mockSecurityContext));
+ SecurityContext mockSecurityContext = new MockSecurityContext("testuser",
+ Collections.singleton(JcrSession.DNA_WRITE_PERMISSION));
+ session = (JcrSession)repository.login(new SecurityContextCredentials(mockSecurityContext));
}
@After
@@ -102,34 +95,35 @@
session.logout();
}
}
-
+
protected JcrSession session() {
return this.session;
}
-
- private String getRandomString(int length) {
+
+ private String getRandomString( int length ) {
StringBuffer buff = new StringBuffer(length);
-
+
for (int i = 0; i < length; i++) {
- buff.append((char) ((Math.random() *26) + 'a'));
+ buff.append((char)((Math.random() * 26) + 'a'));
}
-
+
return buff.toString();
}
-
- private int createChildren(Node parent, int numProperties, int width, int depth)
- throws Exception
- {
+
+ private int createChildren( Node parent,
+ int numProperties,
+ int width,
+ int depth ) throws Exception {
if (depth < 1) {
return 0;
-
+
}
int count = width;
-
+
for (int i = 0; i < width; i++) {
Node newNode = parent.addNode(getRandomString(9), "nt:unstructured");
-
+
for (int j = 0; j < numProperties; j++) {
newNode.setProperty(getRandomString(8), getRandomString(16));
}
@@ -138,7 +132,7 @@
}
return count;
}
-
+
protected int createSubgraph( JcrSession session,
String initialPath,
int depth,
@@ -147,9 +141,7 @@
boolean oneBatch,
Stopwatch stopwatch,
PrintStream output,
- String description )
- throws Exception
- {
+ String description ) throws Exception {
// Calculate the number of nodes that we'll created, but subtract 1 since it doesn't create the root
long totalNumber = calculateTotalNumberOfNodesInTree(numberOfChildrenPerNode, depth, false);
if (initialPath == null) initialPath = "";
@@ -160,22 +152,18 @@
if (output != null) output.println(description + " (" + totalNumber + " nodes):");
long totalNumberCreated = 0;
-
+
PathFactory pathFactory = session.getExecutionContext().getValueFactories().getPathFactory();
Node parentNode = session.getNode(pathFactory.create(initialPath));
-
+
if (stopwatch != null) stopwatch.start();
- totalNumberCreated += createChildren(parentNode,
- numberOfPropertiesPerNode,
- numberOfChildrenPerNode,
- depth);
+ totalNumberCreated += createChildren(parentNode, numberOfPropertiesPerNode, numberOfChildrenPerNode, depth);
assertThat(totalNumberCreated, is(totalNumber));
session.save();
-
if (stopwatch != null) {
stopwatch.stop();
if (output != null) {
@@ -187,16 +175,14 @@
}
protected int traverseSubgraph( JcrSession session,
- String initialPath,
- int depth,
- int numberOfChildrenPerNode,
- int numberOfPropertiesPerNode,
- boolean oneBatch,
- Stopwatch stopwatch,
- PrintStream output,
- String description )
- throws Exception
- {
+ String initialPath,
+ int depth,
+ int numberOfChildrenPerNode,
+ int numberOfPropertiesPerNode,
+ boolean oneBatch,
+ Stopwatch stopwatch,
+ PrintStream output,
+ String description ) throws Exception {
// Calculate the number of nodes that we'll created, but subtract 1 since it doesn't create the root
long totalNumber = calculateTotalNumberOfNodesInTree(numberOfChildrenPerNode, depth, false);
if (initialPath == null) initialPath = "";
@@ -207,10 +193,10 @@
if (output != null) output.println(description + " (" + totalNumber + " nodes):");
long totalNumberTraversed = 0;
-
+
PathFactory pathFactory = session.getExecutionContext().getValueFactories().getPathFactory();
Node parentNode = session.getNode(pathFactory.create(initialPath));
-
+
if (stopwatch != null) stopwatch.start();
totalNumberTraversed += traverseChildren(parentNode);
@@ -219,7 +205,6 @@
session.save();
-
if (stopwatch != null) {
stopwatch.stop();
if (output != null) {
@@ -230,20 +215,20 @@
}
- protected int traverseChildren(Node parentNode) throws Exception {
+ protected int traverseChildren( Node parentNode ) throws Exception {
int childCount = 0;
NodeIterator children = parentNode.getNodes();
while (children.hasNext()) {
childCount++;
-
+
childCount += traverseChildren(children.nextNode());
}
-
+
return childCount;
}
-
+
protected String getTotalAndAverageDuration( Stopwatch stopwatch,
long numNodes ) {
long totalDurationInMilliseconds = TimeUnit.NANOSECONDS.toMillis(stopwatch.getTotalDuration().longValue());
@@ -269,7 +254,5 @@
}
return countRoot ? totalNumber : totalNumber - 1;
}
-
-
}
Modified: trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/AbstractSessionTest.java
===================================================================
--- trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/AbstractSessionTest.java 2009-07-21 03:17:04 UTC (rev 1119)
+++ trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/AbstractSessionTest.java 2009-07-21 03:19:32 UTC (rev 1120)
@@ -23,6 +23,7 @@
*/
package org.jboss.dna.jcr;
+import static org.mockito.Matchers.anyString;
import static org.mockito.Mockito.stub;
import java.io.IOException;
import java.util.Collections;
@@ -40,9 +41,12 @@
import org.jboss.dna.graph.connector.RepositorySourceException;
import org.jboss.dna.graph.connector.inmemory.InMemoryRepositorySource;
import org.jboss.dna.graph.property.NamespaceRegistry;
+import org.jboss.dna.graph.property.PathFactory;
import org.jboss.dna.jcr.nodetype.NodeTypeTemplate;
import org.mockito.MockitoAnnotations;
import org.mockito.MockitoAnnotations.Mock;
+import org.mockito.invocation.InvocationOnMock;
+import org.mockito.stubbing.Answer;
/**
* Abstract test class that sets up a working JcrSession environment, albeit with a mocked JcrRepository.
@@ -80,9 +84,18 @@
context = new ExecutionContext();
// Register the test namespace
context.getNamespaceRegistry().register(TestLexicon.Namespace.PREFIX, TestLexicon.Namespace.URI);
+ PathFactory pathFactory = context.getValueFactories().getPathFactory();
// Set up the initial content ...
graph = Graph.create(source, context);
+
+ // Make sure the path to the namespaces exists ...
+ graph.create("/jcr:system").and(); // .and().create("/jcr:system/dna:namespaces");
+ graph.set("jcr:primaryType").on("/jcr:system").to(DnaLexicon.SYSTEM);
+
+ graph.create("/jcr:system/dna:namespaces").and();
+ graph.set("jcr:primaryType").on("/jcr:system/dna:namespaces").to(DnaLexicon.NAMESPACES);
+
initializeContent();
// Stub out the connection factory ...
@@ -112,10 +125,16 @@
ioe.printStackTrace();
throw new IllegalStateException("Could not access node type definition files", ioe);
}
+ this.repoTypeManager.projectOnto(graph, pathFactory.create("/jcr:system/jcr:nodeTypes"));
stub(repository.getRepositoryTypeManager()).toReturn(repoTypeManager);
stub(repository.getRepositorySourceName()).toReturn(repositorySourceName);
- stub(repository.getConnectionFactory()).toReturn(connectionFactory);
+ stub(repository.getPersistentRegistry()).toReturn(context.getNamespaceRegistry());
+ stub(repository.createWorkspaceGraph(anyString())).toAnswer(new Answer<Graph>() {
+ public Graph answer( InvocationOnMock invocation ) throws Throwable {
+ return graph;
+ }
+ });
initializeOptions();
stub(repository.getOptions()).toReturn(options);
Modified: trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/ImportExportTest.java
===================================================================
--- trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/ImportExportTest.java 2009-07-21 03:17:04 UTC (rev 1119)
+++ trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/ImportExportTest.java 2009-07-21 03:19:32 UTC (rev 1120)
@@ -31,7 +31,6 @@
import javax.jcr.ImportUUIDBehavior;
import javax.jcr.Node;
import org.jboss.dna.graph.ExecutionContext;
-import org.jboss.dna.graph.Graph;
import org.jboss.dna.graph.MockSecurityContext;
import org.jboss.dna.graph.SecurityContext;
import org.jboss.dna.graph.connector.RepositoryConnection;
@@ -76,20 +75,8 @@
// Register the test namespace
context.getNamespaceRegistry().register(TestLexicon.Namespace.PREFIX, TestLexicon.Namespace.URI);
- // Set up the initial content ...
- Graph graph = Graph.create(source, context);
-
- // Make sure the path to the namespaces exists ...
- graph.create("/jcr:system").and(); // .and().create("/jcr:system/dna:namespaces");
- graph.set("jcr:primaryType").on("/jcr:system").to(DnaLexicon.SYSTEM);
-
// Stub out the connection factory ...
RepositoryConnectionFactory connectionFactory = new RepositoryConnectionFactory() {
- /**
- * {@inheritDoc}
- *
- * @see org.jboss.dna.graph.connector.RepositoryConnectionFactory#createConnection(java.lang.String)
- */
@SuppressWarnings( "synthetic-access" )
public RepositoryConnection createConnection( String sourceName ) throws RepositorySourceException {
return source.getConnection();
@@ -157,6 +144,7 @@
public void shouldImportExportEscapedXmlCharactersInSystemViewUsingWorkspace() throws Exception {
String testName = "importExportEscapedXmlCharacters";
Node rootNode = session.getRootNode();
+ System.out.println(session);
Node sourceNode = rootNode.addNode(testName + "Source", "nt:unstructured");
Node targetNode = rootNode.addNode(testName + "Target", "nt:unstructured");
Modified: trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/JcrRepositoryTest.java
===================================================================
--- trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/JcrRepositoryTest.java 2009-07-21 03:17:04 UTC (rev 1119)
+++ trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/JcrRepositoryTest.java 2009-07-21 03:19:32 UTC (rev 1120)
@@ -33,6 +33,7 @@
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
+import java.util.UUID;
import javax.jcr.Credentials;
import javax.jcr.Repository;
import javax.jcr.Session;
@@ -42,12 +43,14 @@
import org.jboss.dna.graph.ExecutionContext;
import org.jboss.dna.graph.Graph;
import org.jboss.dna.graph.MockSecurityContext;
+import org.jboss.dna.graph.Node;
import org.jboss.dna.graph.JaasSecurityContext.UserPasswordCallbackHandler;
import org.jboss.dna.graph.connector.RepositoryConnection;
import org.jboss.dna.graph.connector.RepositoryConnectionFactory;
import org.jboss.dna.graph.connector.RepositorySourceException;
import org.jboss.dna.graph.connector.inmemory.InMemoryRepositorySource;
import org.jboss.security.config.IDTrustConfiguration;
+import org.junit.After;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
@@ -55,7 +58,6 @@
import org.mockito.MockitoAnnotations;
/**
- * @author jverhaeg
*/
public class JcrRepositoryTest {
@@ -66,6 +68,9 @@
private Map<String, String> descriptors;
private RepositoryConnectionFactory connectionFactory;
private Credentials credentials;
+ private Graph sourceGraph;
+ private Graph systemGraph;
+ private JcrSession session;
@BeforeClass
public static void beforeClass() {
@@ -106,15 +111,28 @@
}
};
- // Make sure the path to the namespaces exists ...
- Graph graph = Graph.create(source, context);
- graph.create("/jcr:system").and().create("/jcr:system/dna:namespaces");
-
// Set up the repository ...
descriptors = new HashMap<String, String>();
repository = new JcrRepository(context, connectionFactory, sourceName, descriptors, null);
+
+ // Set up the graph that goes directly to the source ...
+ sourceGraph = Graph.create(source, context);
+
+ // Set up the graph that goes directly to the system source ...
+ systemGraph = repository.createSystemGraph();
}
+ @After
+ public void afterEach() {
+ if (session != null) {
+ try {
+ session.logout();
+ } finally {
+ session = null;
+ }
+ }
+ }
+
@Test
public void shouldAllowNullDescriptors() {
new JcrRepository(context, connectionFactory, sourceName, null, null);
@@ -260,6 +278,67 @@
});
}
+ @Test
+ public void shouldHaveRootNode() throws Exception {
+ session = createSession();
+ javax.jcr.Node root = session.getRootNode();
+ String uuid = root.getUUID();
+
+ // Get the root via the direct graph ...
+ Node dnaRoot = sourceGraph.getNodeAt("/");
+ UUID dnaRootUuid = dnaRoot.getLocation().getUuid();
+
+ // They should have the same UUID ...
+ assertThat(uuid, is(dnaRootUuid.toString()));
+
+ // Get the children of the root node ...
+ javax.jcr.NodeIterator iter = root.getNodes();
+ javax.jcr.Node system = iter.nextNode();
+ assertThat(system.getName(), is("jcr:system"));
+
+ // Add a child node ...
+ javax.jcr.Node childA = root.addNode("childA", "nt:unstructured");
+ assertThat(childA, is(notNullValue()));
+ iter = root.getNodes();
+ javax.jcr.Node system2 = iter.nextNode();
+ javax.jcr.Node childA2 = iter.nextNode();
+ assertThat(system2.getName(), is("jcr:system"));
+ assertThat(childA2.getName(), is("childA"));
+ }
+
+ @Test
+ public void shouldHaveSystemBranch() throws Exception {
+ session = createSession();
+ javax.jcr.Node root = session.getRootNode();
+ AbstractJcrNode system = (AbstractJcrNode)root.getNode("jcr:system");
+ UUID uuid = system.location.getUuid();
+
+ for (int i = 0; i != 3; ++i) {
+ // Get the same node via the direct graph ...
+ Node dnaSystem = systemGraph.getNodeAt("/jcr:system");
+ UUID dnaSystemUuid = dnaSystem.getLocation().getUuid();
+
+ // They should have the same UUID ...
+ assertThat(uuid, is(dnaSystemUuid));
+ }
+ }
+
+ protected JcrSession createSession() throws Exception {
+ LoginContext login = new LoginContext("dna-jcr", new UserPasswordCallbackHandler("superuser", "superuser".toCharArray()));
+ login.login();
+
+ Subject subject = login.getSubject();
+ JcrSession session = (JcrSession)Subject.doAsPrivileged(subject, new PrivilegedExceptionAction<Session>() {
+
+ @SuppressWarnings( "synthetic-access" )
+ public Session run() throws Exception {
+ return repository.login();
+ }
+
+ }, AccessController.getContext());
+ return session;
+ }
+
private void testDescriptorKeys( Repository repository ) {
String[] keys = repository.getDescriptorKeys();
assertThat(keys, notNullValue());
Modified: trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/RepositoryNodeTypeManagerTest.java
===================================================================
--- trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/RepositoryNodeTypeManagerTest.java 2009-07-21 03:17:04 UTC (rev 1119)
+++ trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/RepositoryNodeTypeManagerTest.java 2009-07-21 03:19:32 UTC (rev 1120)
@@ -57,20 +57,13 @@
@Before
public void beforeEach() throws Exception {
super.beforeEach();
-
- graph.set("jcr:primaryType").on("/jcr:system/dna:namespaces").to(DnaLexicon.NAMESPACES);
-
}
@Override
protected void initializeContent() {
- // Make sure the path to the namespaces exists ...
- graph.create("/jcr:system").and(); // .and().create("/jcr:system/dna:namespaces");
- graph.set("jcr:primaryType").on("/jcr:system").to(DnaLexicon.SYSTEM);
-
+ super.initializeContent();
graph.create("/a").and().create("/a/b").and().create("/a/b/c").and();
graph.set("jcr:mixinTypes").on("/a").to(JcrMixLexicon.REFERENCEABLE);
-
}
@Override
@@ -78,7 +71,6 @@
// Stub out the repository options ...
options = new EnumMap<JcrRepository.Option, String>(JcrRepository.Option.class);
options.put(JcrRepository.Option.PROJECT_NODE_TYPES, Boolean.TRUE.toString());
-
}
@After
Modified: trunk/docs/examples/gettingstarted/repositories/src/main/resources/configRepository.xml
===================================================================
--- trunk/docs/examples/gettingstarted/repositories/src/main/resources/configRepository.xml 2009-07-21 03:17:04 UTC (rev 1119)
+++ trunk/docs/examples/gettingstarted/repositories/src/main/resources/configRepository.xml 2009-07-21 03:19:32 UTC (rev 1120)
@@ -69,9 +69,9 @@
<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:projection jcr:name="System projection" dna:source="System" dna:workspaceName="default">
<dna:projectionRules>/jcr:system => /</dna:projectionRules>
- </dna:projection>
+ </dna:projection-->
</dna:projections>
</dna:workspace>
</dna:workspaces>
@@ -79,7 +79,7 @@
<!--
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: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-07-21 03:17:04 UTC (rev 1119)
+++ trunk/docs/examples/gettingstarted/repositories/src/test/java/org/jboss/example/dna/repository/RepositoryClientTest.java 2009-07-21 03:19:32 UTC (rev 1120)
@@ -243,6 +243,7 @@
client.startRepositories();
getNodeInfo("Vehicles", "/");
+ // The non-JCR configuration does not have a "jcr:system"
// assertThat(children, hasItems("Vehicles", "jcr:system"));
getNodeInfo("Vehicles", "/Vehicles");
16 years, 9 months
DNA SVN: r1119 - in trunk/dna-graph/src: main/java/org/jboss/dna/graph/connector/federation and 3 other directories.
by dna-commits@lists.jboss.org
Author: rhauch
Date: 2009-07-20 23:17:04 -0400 (Mon, 20 Jul 2009)
New Revision: 1119
Modified:
trunk/dna-graph/src/main/java/org/jboss/dna/graph/Graph.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/FederatedRequest.java
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/dna-graph/src/main/java/org/jboss/dna/graph/connector/federation/NoMoreFederatedRequests.java
trunk/dna-graph/src/main/java/org/jboss/dna/graph/connector/federation/Projection.java
trunk/dna-graph/src/main/java/org/jboss/dna/graph/request/Request.java
trunk/dna-graph/src/main/java/org/jboss/dna/graph/request/processor/RequestProcessor.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/FederatedRepositorySourceUsingMirrorAndBranchProjectionsTest.java
trunk/dna-graph/src/test/java/org/jboss/dna/graph/connector/federation/FederatedRequestTest.java
trunk/dna-graph/src/test/java/org/jboss/dna/graph/connector/federation/ForkRequestProcessorChannelTest.java
Log:
DNA-392 All sessions in a repository should share the same /jcr:system content
A number of issues/bugs were found in the federated connector. These were fixed, and several tests were added. (Subsequent commits will make additional use of the federated connector in the JCR implementation, and these also put the federated connector through additional tests.)
Modified: trunk/dna-graph/src/main/java/org/jboss/dna/graph/Graph.java
===================================================================
--- trunk/dna-graph/src/main/java/org/jboss/dna/graph/Graph.java 2009-07-21 03:14:59 UTC (rev 1118)
+++ trunk/dna-graph/src/main/java/org/jboss/dna/graph/Graph.java 2009-07-21 03:17:04 UTC (rev 1119)
@@ -5451,23 +5451,14 @@
if (request instanceof ReadAllPropertiesRequest) {
ReadAllPropertiesRequest read = (ReadAllPropertiesRequest)request;
DateTime expires = computeExpirationTime(read);
- if (read.getActualLocationOfNode() == null) {
- int x = 0;
- }
getOrCreateNode(read.getActualLocationOfNode(), expires).setProperties(read.getPropertiesByName());
} else if (request instanceof ReadPropertyRequest) {
ReadPropertyRequest read = (ReadPropertyRequest)request;
DateTime expires = computeExpirationTime(read);
- if (read.getActualLocationOfNode() == null) {
- int x = 0;
- }
getOrCreateNode(read.getActualLocationOfNode(), expires).addProperty(read.getProperty());
} else if (request instanceof ReadNodeRequest) {
ReadNodeRequest read = (ReadNodeRequest)request;
DateTime expires = computeExpirationTime(read);
- if (read.getActualLocationOfNode() == null) {
- int x = 0;
- }
BatchResultsNode node = getOrCreateNode(read.getActualLocationOfNode(), expires);
node.setProperties(read.getPropertiesByName());
node.setChildren(read.getChildren());
@@ -5476,17 +5467,11 @@
} else if (request instanceof ReadAllChildrenRequest) {
ReadAllChildrenRequest read = (ReadAllChildrenRequest)request;
DateTime expires = computeExpirationTime(read);
- if (read.getActualLocationOfNode() == null) {
- int x = 0;
- }
getOrCreateNode(read.getActualLocationOfNode(), expires).setChildren(read.getChildren());
} else if (request instanceof ReadBranchRequest) {
ReadBranchRequest read = (ReadBranchRequest)request;
DateTime expires = computeExpirationTime(read);
for (Location location : read) {
- if (location == null) {
- int x = 0;
- }
BatchResultsNode node = getOrCreateNode(location, expires);
node.setProperties(read.getPropertiesFor(location));
node.setChildren(read.getChildren(location));
@@ -5512,9 +5497,6 @@
} else if (request instanceof ReadNodeRequest) {
ReadNodeRequest read = (ReadNodeRequest)request;
DateTime expires = computeExpirationTime(read);
- if (read.getActualLocationOfNode() == null) {
- int x = 0;
- }
BatchResultsNode node = getOrCreateNode(read.getActualLocationOfNode(), expires);
node.setProperties(read.getPropertiesByName());
node.setChildren(read.getChildren());
@@ -5555,9 +5537,6 @@
DateTime expirationTime ) {
BatchResultsNode node = nodes.get(location);
if (node == null) {
- if (location == null) {
- int x = 0;
- }
node = new BatchResultsNode(location, expirationTime);
assert location != null;
assert location.getPath() != null;
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-07-21 03:14:59 UTC (rev 1118)
+++ trunk/dna-graph/src/main/java/org/jboss/dna/graph/connector/federation/FederatedRepositoryConnection.java 2009-07-21 03:17:04 UTC (rev 1119)
@@ -226,6 +226,12 @@
} finally {
join.close();
}
+ if (request instanceof CompositeRequest) {
+ // The composite request will not have any errors set, since the fork/join approach puts the
+ // contained requests into a separate CompositeRequest object for processing.
+ // So, look at the requests for any errors
+ ((CompositeRequest)request).checkForErrors();
+ }
} catch (InterruptedException e) {
abort = true;
request.setError(e);
Modified: trunk/dna-graph/src/main/java/org/jboss/dna/graph/connector/federation/FederatedRequest.java
===================================================================
--- trunk/dna-graph/src/main/java/org/jboss/dna/graph/connector/federation/FederatedRequest.java 2009-07-21 03:14:59 UTC (rev 1118)
+++ trunk/dna-graph/src/main/java/org/jboss/dna/graph/connector/federation/FederatedRequest.java 2009-07-21 03:17:04 UTC (rev 1119)
@@ -33,6 +33,8 @@
*/
@NotThreadSafe
class FederatedRequest {
+ static final CountDownLatch CLOSED_LATCH = new CountDownLatch(0);
+
private final Request original;
private CountDownLatch forkLatch;
private int incompleteCount;
@@ -51,6 +53,7 @@
boolean isComplete,
Projection projection,
Projection secondProjection ) {
+ assert forkLatch == null;
if (!isComplete) ++incompleteCount;
if (first == null) {
if (isSameLocationAsOriginal) {
@@ -72,8 +75,8 @@
}
public void freeze() {
- if (incompleteCount > 0 && forkLatch == null) {
- forkLatch = new CountDownLatch(incompleteCount);
+ if (forkLatch == null) {
+ forkLatch = incompleteCount > 0 ? new CountDownLatch(incompleteCount) : CLOSED_LATCH;
}
}
@@ -86,6 +89,7 @@
}
public CountDownLatch getLatch() {
+ freeze();
return forkLatch;
}
@@ -102,7 +106,6 @@
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("Federated request: ").append(original).append("\n");
- sb.append(" projected to: ").append("\n");
ProjectedRequest projected = first;
while (projected != null) {
sb.append(" - ").append(projected).append("\n");
@@ -128,19 +131,19 @@
this.projection2 = secondProjection;
}
- public Projection getProjection() {
+ public final Projection getProjection() {
return projection;
}
- public Projection getSecondProjection() {
+ public final Projection getSecondProjection() {
return projection2;
}
- public Request getRequest() {
+ public final Request getRequest() {
return request;
}
- public boolean isComplete() {
+ public final boolean isComplete() {
return isComplete;
}
@@ -148,11 +151,11 @@
return false;
}
- public ProjectedRequest next() {
+ public final ProjectedRequest next() {
return next;
}
- public boolean hasNext() {
+ public final boolean hasNext() {
return next != null;
}
@@ -173,6 +176,30 @@
Projection projection ) {
return addNext(request, isComplete, projection, null);
}
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see java.lang.Object#toString()
+ */
+ @Override
+ public String toString() {
+ StringBuilder sb = new StringBuilder();
+ sb.append("Projects to: ");
+ sb.append(request);
+ if (projection != null) {
+ sb.append(" using ");
+ sb.append(projection);
+ if (projection2 != null) {
+ sb.append(" and ");
+ sb.append(projection2);
+ }
+ }
+ if (isComplete) {
+ sb.append(" (complete)");
+ }
+ return sb.toString();
+ }
}
class MirrorRequest extends ProjectedRequest {
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-07-21 03:14:59 UTC (rev 1118)
+++ trunk/dna-graph/src/main/java/org/jboss/dna/graph/connector/federation/ForkRequestProcessor.java 2009-07-21 03:17:04 UTC (rev 1119)
@@ -117,58 +117,6 @@
}
/**
- * A pseudo Request that allows addition of a request that, when processed, will decrement a latch. Since the latch is
- * supplied by the submitter, this is useful when the submitter wishes to block until a particular request is processed. The
- * submitter merely creates a {@link CountDownLatch}, submits their real request wrapped by a BlockedRequest, and calls
- * {@link CountDownLatch#await()} on the latch. When <code>await()</code> returns, the request has been completed.
- *
- * @see ForkRequestProcessor#submit(Request, String, CountDownLatch)
- * @see ForkRequestProcessor#submitAndAwait(Request, String)
- */
- protected static class BlockedRequest extends Request {
- private static final long serialVersionUID = 1L;
- protected final Request original;
- protected final transient CountDownLatch latch;
-
- protected BlockedRequest( Request original,
- CountDownLatch latch ) {
- this.original = original;
- this.latch = latch;
- }
-
- @Override
- public boolean isReadOnly() {
- return original.isReadOnly();
- }
-
- @Override
- public boolean isCancelled() {
- return original.isCancelled();
- }
-
- /**
- * {@inheritDoc}
- *
- * @see org.jboss.dna.graph.request.Request#setError(java.lang.Throwable)
- */
- @Override
- public void setError( Throwable error ) {
- original.setError(error);
- if (this.latch != null) this.latch.countDown();
- }
-
- /**
- * {@inheritDoc}
- *
- * @see org.jboss.dna.graph.request.Request#hasError()
- */
- @Override
- public boolean hasError() {
- return original.hasError();
- }
- }
-
- /**
* Represents the channel for a specific source into which this processor submits the requests for that source. To use, create
* a Channel, {@link Channel#start(ExecutorService, ExecutionContext, RepositoryConnectionFactory) start it}, and then
* {@link Channel#add(Request) add} requests (optionally with a {@link Channel#add(Request, CountDownLatch) latch} or via a
@@ -281,15 +229,9 @@
protected Iterator<Request> createIterator() {
final BlockingQueue<Request> queue = this.queue;
return new Iterator<Request>() {
- private BlockedRequest previousBlocked;
private Request next;
public boolean hasNext() {
- // If the previous request was a blocked request, then we need to decrement its latch ...
- if (previousBlocked != null && previousBlocked.latch != null) {
- previousBlocked.latch.countDown();
- }
-
// If next still has a request, then 'hasNext()' has been called multiple times in a row
if (next != null) return true;
@@ -331,19 +273,12 @@
}
}
}
- // If this request is a blocked request, we need to return the wrapped request and record the blocked request
- if (next instanceof BlockedRequest) {
- previousBlocked = (BlockedRequest)next;
- next = null;
- return previousBlocked.original;
+ if (next == null) {
+ throw new NoSuchElementException();
}
- previousBlocked = null;
- if (next != null) {
- Request result = next;
- next = null;
- return result;
- }
- throw new NoSuchElementException();
+ Request result = next;
+ next = null;
+ return result;
}
public void remove() {
@@ -424,7 +359,8 @@
assert latch != null;
// Submit the request for processing ...
this.allRequests.add(request);
- this.queue.add(new BlockedRequest(request, latch));
+ request.setLatchForFreezing(latch);
+ this.queue.add(request);
return latch;
}
@@ -707,12 +643,13 @@
ProjectedRequest projected = request.getFirstProjectedRequest();
while (projected != null) {
if (!projected.isComplete()) {
+ // Submit to the appropriate source channel for execution ...
submit(projected.getRequest(), projected.getProjection().getSourceName(), request.getLatch());
}
projected = projected.next();
}
}
- // Record this federated request ...
+ // Record this federated request, ready for the join processor ...
this.federatedRequestQueue.add(request);
}
@@ -723,7 +660,7 @@
*/
@Override
protected void completeRequest( Request request ) {
- // Do nothing here, as this is the federated request
+ // Do nothing here, since this is the federated request which will be frozen in the join processor
}
/**
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-07-21 03:14:59 UTC (rev 1118)
+++ trunk/dna-graph/src/main/java/org/jboss/dna/graph/connector/federation/JoinRequestProcessor.java 2009-07-21 03:17:04 UTC (rev 1119)
@@ -47,7 +47,6 @@
import org.jboss.dna.graph.request.CacheableRequest;
import org.jboss.dna.graph.request.CloneBranchRequest;
import org.jboss.dna.graph.request.CloneWorkspaceRequest;
-import org.jboss.dna.graph.request.CompositeRequest;
import org.jboss.dna.graph.request.CopyBranchRequest;
import org.jboss.dna.graph.request.CreateNodeRequest;
import org.jboss.dna.graph.request.CreateWorkspaceRequest;
@@ -107,19 +106,13 @@
*
* @param completedFederatedRequests the collection of {@link FederatedRequest} whose projected requests have already been
* processed; may not be null
- * @return the exception that occurred while processing these requests (analogous to {@link CompositeRequest#getError()} where
- * the composite's requests are these errors), or null if there was none
* @see FederatedRepositoryConnection#execute(ExecutionContext, org.jboss.dna.graph.request.Request)
*/
- public Throwable process( final Iterable<FederatedRequest> completedFederatedRequests ) {
+ public void process( final Iterable<FederatedRequest> completedFederatedRequests ) {
for (FederatedRequest federatedRequest : completedFederatedRequests) {
// No need to await for the forked request, since it will be done
process(federatedRequest);
- if (federatedRequest.original().hasError()) {
- return federatedRequest.original().getError();
- }
}
- return null;
}
/**
@@ -137,6 +130,7 @@
for (;;) {
forked = federatedRequestQueue.take();
if (forked instanceof NoMoreFederatedRequests) return;
+ // Block until this forked request has completed
forked.await();
// Now process ...
process(forked);
Modified: trunk/dna-graph/src/main/java/org/jboss/dna/graph/connector/federation/NoMoreFederatedRequests.java
===================================================================
--- trunk/dna-graph/src/main/java/org/jboss/dna/graph/connector/federation/NoMoreFederatedRequests.java 2009-07-21 03:14:59 UTC (rev 1118)
+++ trunk/dna-graph/src/main/java/org/jboss/dna/graph/connector/federation/NoMoreFederatedRequests.java 2009-07-21 03:17:04 UTC (rev 1119)
@@ -35,6 +35,7 @@
*/
NoMoreFederatedRequests() {
super(null);
+ freeze();
}
}
Modified: trunk/dna-graph/src/main/java/org/jboss/dna/graph/connector/federation/Projection.java
===================================================================
--- trunk/dna-graph/src/main/java/org/jboss/dna/graph/connector/federation/Projection.java 2009-07-21 03:14:59 UTC (rev 1118)
+++ trunk/dna-graph/src/main/java/org/jboss/dna/graph/connector/federation/Projection.java 2009-07-21 03:17:04 UTC (rev 1119)
@@ -475,9 +475,9 @@
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
+ sb.append(this.workspaceName);
+ sb.append('@');
sb.append(this.sourceName);
- sb.append("::");
- sb.append(this.workspaceName);
sb.append(" { ");
boolean first = true;
for (Rule rule : this.getRules()) {
Modified: trunk/dna-graph/src/main/java/org/jboss/dna/graph/request/Request.java
===================================================================
--- trunk/dna-graph/src/main/java/org/jboss/dna/graph/request/Request.java 2009-07-21 03:14:59 UTC (rev 1118)
+++ trunk/dna-graph/src/main/java/org/jboss/dna/graph/request/Request.java 2009-07-21 03:17:04 UTC (rev 1119)
@@ -24,6 +24,7 @@
package org.jboss.dna.graph.request;
import java.io.Serializable;
+import java.util.concurrent.CountDownLatch;
import java.util.concurrent.atomic.AtomicBoolean;
import org.jboss.dna.graph.GraphI18n;
import org.jboss.dna.graph.connector.RepositoryConnection;
@@ -40,10 +41,16 @@
private Throwable error;
private AtomicBoolean cancelled = new AtomicBoolean(false);
private final AtomicBoolean frozen = new AtomicBoolean(false);
+ private transient CountDownLatch freezingLatch = null;
protected Request() {
}
+ public void setLatchForFreezing( CountDownLatch latch ) {
+ checkNotFrozen();
+ this.freezingLatch = latch;
+ }
+
/**
* Set the error for this request.
*
@@ -148,7 +155,11 @@
* Freeze this request to prevent any further modification. This method does nothing if the request is already frozen.
*/
public void freeze() {
- frozen.set(true);
+ if (frozen.compareAndSet(false, true)) {
+ // Was not already frozen, so decrement the latch (atomically)
+ CountDownLatch latch = this.freezingLatch;
+ if (latch != null) latch.countDown();
+ }
}
/**
Modified: trunk/dna-graph/src/main/java/org/jboss/dna/graph/request/processor/RequestProcessor.java
===================================================================
--- trunk/dna-graph/src/main/java/org/jboss/dna/graph/request/processor/RequestProcessor.java 2009-07-21 03:14:59 UTC (rev 1118)
+++ trunk/dna-graph/src/main/java/org/jboss/dna/graph/request/processor/RequestProcessor.java 2009-07-21 03:17:04 UTC (rev 1119)
@@ -262,6 +262,8 @@
} else {
processUnknownRequest(request);
}
+ } catch (RuntimeException e) {
+ request.setError(e);
} finally {
completeRequest(request);
}
@@ -710,9 +712,6 @@
request.setError(update.getError());
}
// Set the actual location ...
- if (update.getActualLocationOfNode() == null) {
- int x = 0;
- }
request.setActualLocationOfNode(update.getActualLocationOfNode());
}
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-07-21 03:14:59 UTC (rev 1118)
+++ trunk/dna-graph/src/test/java/org/jboss/dna/graph/connector/federation/AbstractFederatedRepositorySourceIntegrationTest.java 2009-07-21 03:17:04 UTC (rev 1119)
@@ -32,6 +32,7 @@
import java.util.HashMap;
import java.util.List;
import java.util.Map;
+import java.util.UUID;
import org.jboss.dna.common.statistic.Stopwatch;
import org.jboss.dna.common.util.CheckArg;
import org.jboss.dna.graph.DnaLexicon;
@@ -289,6 +290,12 @@
.getLastSegment()
.getName()));
}
+
+ // The UUID should match ...
+ UUID fedUuid = fedNode.getLocation().getUuid();
+ UUID sourceUuid = sourceNode.getLocation().getUuid();
+ assertThat(fedUuid, is(sourceUuid));
+
// The children should match ...
List<Path.Segment> fedChildren = new ArrayList<Path.Segment>();
List<Path.Segment> sourceChildren = new ArrayList<Path.Segment>();
Modified: trunk/dna-graph/src/test/java/org/jboss/dna/graph/connector/federation/FederatedRepositorySourceUsingMirrorAndBranchProjectionsTest.java
===================================================================
--- trunk/dna-graph/src/test/java/org/jboss/dna/graph/connector/federation/FederatedRepositorySourceUsingMirrorAndBranchProjectionsTest.java 2009-07-21 03:14:59 UTC (rev 1118)
+++ trunk/dna-graph/src/test/java/org/jboss/dna/graph/connector/federation/FederatedRepositorySourceUsingMirrorAndBranchProjectionsTest.java 2009-07-21 03:17:04 UTC (rev 1119)
@@ -24,9 +24,12 @@
package org.jboss.dna.graph.connector.federation;
import static org.hamcrest.core.Is.is;
+import static org.hamcrest.core.IsNull.notNullValue;
import static org.junit.Assert.assertThat;
import java.util.Set;
import org.jboss.dna.graph.Graph;
+import org.jboss.dna.graph.Location;
+import org.jboss.dna.graph.Node;
import org.junit.Before;
import org.junit.Test;
@@ -105,6 +108,44 @@
}
@Test
+ public void shouldReturnRootNodeInMirrorProjection() {
+ // Get the root node of the mirror projection using the actual graph ...
+ Graph mirrorGraph = graphFor(mirrorSourceName, mirrorWorkspaceName);
+ Node mirrorRoot = mirrorGraph.getNodeAt("/");
+ Location mirrorRootLocation = mirrorRoot.getLocation();
+ assertThat(mirrorRootLocation.hasIdProperties(), is(true));
+ assertThat(mirrorRootLocation.getUuid(), is(notNullValue()));
+
+ // Get the same node through the federation source ...
+ Node fedRoot = federated.getNodeAt("/");
+ Location fedRootLocation = fedRoot.getLocation();
+ assertThat(fedRootLocation.hasIdProperties(), is(true));
+ assertThat(fedRootLocation.getUuid(), is(notNullValue()));
+
+ // The UUIDs of the nodes must be the same ...
+ assertThat(fedRootLocation.getUuid(), is(mirrorRootLocation.getUuid()));
+ }
+
+ @Test
+ public void shouldReturnRootNodeInBranchProjection() {
+ // Get the top node of the branch projection using the actual graph ...
+ Graph branchGraph = graphFor(branchSourceName, branchWorkspaceName);
+ Node branchNode = branchGraph.getNodeAt("/Aircraft");
+ Location branchNodeLocation = branchNode.getLocation();
+ assertThat(branchNodeLocation.hasIdProperties(), is(true));
+ assertThat(branchNodeLocation.getUuid(), is(notNullValue()));
+
+ // Get the same node through the federation source ...
+ Node fedNode = federated.getNodeAt("/Aircraft");
+ Location fedNodeLocation = fedNode.getLocation();
+ assertThat(fedNodeLocation.hasIdProperties(), is(true));
+ assertThat(fedNodeLocation.getUuid(), is(notNullValue()));
+
+ // The UUIDs of the nodes must be the same ...
+ assertThat(fedNodeLocation.getUuid(), is(branchNodeLocation.getUuid()));
+ }
+
+ @Test
public void shouldFederateRootNodeFromMirrorAndBranch() {
// The root of the federated repository should have the content from the mirror but should have
// an additional child that is the root of the branch ...
Modified: trunk/dna-graph/src/test/java/org/jboss/dna/graph/connector/federation/FederatedRequestTest.java
===================================================================
--- trunk/dna-graph/src/test/java/org/jboss/dna/graph/connector/federation/FederatedRequestTest.java 2009-07-21 03:14:59 UTC (rev 1118)
+++ trunk/dna-graph/src/test/java/org/jboss/dna/graph/connector/federation/FederatedRequestTest.java 2009-07-21 03:17:04 UTC (rev 1119)
@@ -103,10 +103,9 @@
@Test
public void shouldAddMultipleProjectedRequestsAddedInMethodChain() {
- request.add(projectedRequest[0], false, false, projection[0]).add(projectedRequest[1], false, true, projection[1]).add(projectedRequest[2],
- false,
- false,
- projection[2]);
+ request.add(projectedRequest[0], false, false, projection[0])
+ .add(projectedRequest[1], false, true, projection[1])
+ .add(projectedRequest[2], false, false, projection[2]);
assertThat(request.hasIncompleteRequests(), is(true));
ProjectedRequest first = request.getFirstProjectedRequest();
@@ -134,7 +133,6 @@
@Test
public void shouldCreateCountDownLatchUponFreezeIfNumberOfIncompleteProjectedRequestsIsNonZero() {
request.add(projectedRequest[0], false, false, projection[0]);
- assertThat(request.getLatch(), is(nullValue()));
request.freeze();
assertThat(request.getLatch(), is(notNullValue()));
assertThat(request.getLatch().getCount(), is(1L));
@@ -142,11 +140,10 @@
}
@Test
- public void shouldNotCreateCountDownLatchUponFreezeIfNumberOfIncompleteProjectedRequestsIsZero() {
+ public void shouldUseClosedLatchUponFreezeIfNumberOfIncompleteProjectedRequestsIsZero() {
request.add(projectedRequest[0], false, true, projection[0]);
- assertThat(request.getLatch(), is(nullValue()));
request.freeze();
- assertThat(request.getLatch(), is(nullValue()));
+ assertThat(request.getLatch(), is(sameInstance(FederatedRequest.CLOSED_LATCH)));
assertThat(request.hasIncompleteRequests(), is(false));
}
Modified: trunk/dna-graph/src/test/java/org/jboss/dna/graph/connector/federation/ForkRequestProcessorChannelTest.java
===================================================================
--- trunk/dna-graph/src/test/java/org/jboss/dna/graph/connector/federation/ForkRequestProcessorChannelTest.java 2009-07-21 03:14:59 UTC (rev 1118)
+++ trunk/dna-graph/src/test/java/org/jboss/dna/graph/connector/federation/ForkRequestProcessorChannelTest.java 2009-07-21 03:17:04 UTC (rev 1119)
@@ -27,7 +27,6 @@
import static org.hamcrest.core.IsSame.sameInstance;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.fail;
-import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.stub;
import java.util.ArrayList;
import java.util.Iterator;
@@ -69,10 +68,10 @@
sourceName = "SourceA";
channel = new ForkRequestProcessor.Channel(sourceName);
requests = new ArrayList<Request>();
- requests.add(mock(Request.class));
- requests.add(mock(Request.class));
- requests.add(mock(Request.class));
- requests.add(mock(Request.class));
+ requests.add(new MockRequest());
+ requests.add(new MockRequest());
+ requests.add(new MockRequest());
+ requests.add(new MockRequest());
// Create the mock connection ...
executedRequests = new LinkedList<Request>(); // this is where requests submitted to the connection will go
@@ -85,6 +84,15 @@
executor = Executors.newSingleThreadExecutor();
}
+ protected static class MockRequest extends Request {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public boolean isReadOnly() {
+ return false;
+ }
+ }
+
@Test
public void shouldCreateEmptyIteratorIfDoneCalledBeforeObtainingIterator() {
channel.done();
16 years, 9 months
DNA SVN: r1118 - in trunk/dna-graph/src: main/java/org/jboss/dna/graph/connector/federation and 3 other directories.
by dna-commits@lists.jboss.org
Author: rhauch
Date: 2009-07-20 23:14:59 -0400 (Mon, 20 Jul 2009)
New Revision: 1118
Added:
trunk/dna-graph/src/main/java/org/jboss/dna/graph/request/RequestException.java
Modified:
trunk/dna-graph/src/main/java/org/jboss/dna/graph/Graph.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/FederatedRepositorySource.java
trunk/dna-graph/src/main/java/org/jboss/dna/graph/connector/federation/FederatedWorkspace.java
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/dna-graph/src/main/java/org/jboss/dna/graph/request/CompositeRequest.java
trunk/dna-graph/src/main/java/org/jboss/dna/graph/request/InvalidRequestException.java
trunk/dna-graph/src/main/java/org/jboss/dna/graph/request/InvalidWorkspaceException.java
trunk/dna-graph/src/main/java/org/jboss/dna/graph/request/MoveBranchRequest.java
trunk/dna-graph/src/main/java/org/jboss/dna/graph/request/UnsupportedRequestException.java
trunk/dna-graph/src/main/java/org/jboss/dna/graph/request/processor/RequestProcessor.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/FederatedRepositoryConnectionTest.java
trunk/dna-graph/src/test/java/org/jboss/dna/graph/connector/federation/FederatedRepositorySourceUsingMirrorAndBranchProjectionsTest.java
trunk/dna-graph/src/test/java/org/jboss/dna/graph/connector/federation/ForkRequestProcessorChannelTest.java
Log:
DNA-392 Fixes and improvements to the federated connector.
Modified: trunk/dna-graph/src/main/java/org/jboss/dna/graph/Graph.java
===================================================================
--- trunk/dna-graph/src/main/java/org/jboss/dna/graph/Graph.java 2009-07-20 19:05:35 UTC (rev 1117)
+++ trunk/dna-graph/src/main/java/org/jboss/dna/graph/Graph.java 2009-07-21 03:14:59 UTC (rev 1118)
@@ -5451,14 +5451,23 @@
if (request instanceof ReadAllPropertiesRequest) {
ReadAllPropertiesRequest read = (ReadAllPropertiesRequest)request;
DateTime expires = computeExpirationTime(read);
+ if (read.getActualLocationOfNode() == null) {
+ int x = 0;
+ }
getOrCreateNode(read.getActualLocationOfNode(), expires).setProperties(read.getPropertiesByName());
} else if (request instanceof ReadPropertyRequest) {
ReadPropertyRequest read = (ReadPropertyRequest)request;
DateTime expires = computeExpirationTime(read);
+ if (read.getActualLocationOfNode() == null) {
+ int x = 0;
+ }
getOrCreateNode(read.getActualLocationOfNode(), expires).addProperty(read.getProperty());
} else if (request instanceof ReadNodeRequest) {
ReadNodeRequest read = (ReadNodeRequest)request;
DateTime expires = computeExpirationTime(read);
+ if (read.getActualLocationOfNode() == null) {
+ int x = 0;
+ }
BatchResultsNode node = getOrCreateNode(read.getActualLocationOfNode(), expires);
node.setProperties(read.getPropertiesByName());
node.setChildren(read.getChildren());
@@ -5467,11 +5476,17 @@
} else if (request instanceof ReadAllChildrenRequest) {
ReadAllChildrenRequest read = (ReadAllChildrenRequest)request;
DateTime expires = computeExpirationTime(read);
+ if (read.getActualLocationOfNode() == null) {
+ int x = 0;
+ }
getOrCreateNode(read.getActualLocationOfNode(), expires).setChildren(read.getChildren());
} else if (request instanceof ReadBranchRequest) {
ReadBranchRequest read = (ReadBranchRequest)request;
DateTime expires = computeExpirationTime(read);
for (Location location : read) {
+ if (location == null) {
+ int x = 0;
+ }
BatchResultsNode node = getOrCreateNode(location, expires);
node.setProperties(read.getPropertiesFor(location));
node.setChildren(read.getChildren(location));
@@ -5497,6 +5512,9 @@
} else if (request instanceof ReadNodeRequest) {
ReadNodeRequest read = (ReadNodeRequest)request;
DateTime expires = computeExpirationTime(read);
+ if (read.getActualLocationOfNode() == null) {
+ int x = 0;
+ }
BatchResultsNode node = getOrCreateNode(read.getActualLocationOfNode(), expires);
node.setProperties(read.getPropertiesByName());
node.setChildren(read.getChildren());
@@ -5537,7 +5555,11 @@
DateTime expirationTime ) {
BatchResultsNode node = nodes.get(location);
if (node == null) {
+ if (location == null) {
+ int x = 0;
+ }
node = new BatchResultsNode(location, expirationTime);
+ assert location != null;
assert location.getPath() != null;
nodes.put(location.getPath(), node);
}
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-07-20 19:05:35 UTC (rev 1117)
+++ trunk/dna-graph/src/main/java/org/jboss/dna/graph/connector/federation/BranchedMirrorProjector.java 2009-07-21 03:14:59 UTC (rev 1118)
@@ -120,6 +120,7 @@
public ProjectedNode project( ExecutionContext context,
Location location,
boolean requiresUpdate ) {
+ assert location != null;
if (location.hasPath()) {
Path path = location.getPath();
if (path.isRoot()) {
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-07-20 19:05:35 UTC (rev 1117)
+++ trunk/dna-graph/src/main/java/org/jboss/dna/graph/connector/federation/FederatedRepositoryConnection.java 2009-07-21 03:14:59 UTC (rev 1118)
@@ -134,13 +134,14 @@
}
protected boolean shouldProcessSynchronously( Request request ) {
- if (request instanceof CompositeRequest) {
- CompositeRequest composite = (CompositeRequest)request;
- if (composite.size() == 1) return true;
- return false;
- }
- // Otherwise, its just a single request ...
return true;
+ // if (request instanceof CompositeRequest) {
+ // CompositeRequest composite = (CompositeRequest)request;
+ // if (composite.size() == 1) return true;
+ // return false;
+ // }
+ // // Otherwise, its just a single request ...
+ // return true;
}
/**
@@ -180,7 +181,7 @@
} finally {
fork.close();
}
- if (!awaitAllSubtasks) requests.add(new NoMoreFederatedRequests());
+ requests.add(new NoMoreFederatedRequests());
// At this point, all submitted requests have been processed/forked, so we can continue with
// the join process, starting with the first submitted request. Note that the subtasks may
// still be executing, but as the join process operates on a forked request, it will wait
@@ -195,7 +196,7 @@
} finally {
fork.close();
}
- if (!awaitAllSubtasks) requests.add(new NoMoreFederatedRequests());
+ requests.add(new NoMoreFederatedRequests());
}
});
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-07-20 19:05:35 UTC (rev 1117)
+++ trunk/dna-graph/src/main/java/org/jboss/dna/graph/connector/federation/FederatedRepositorySource.java 2009-07-21 03:14:59 UTC (rev 1118)
@@ -40,6 +40,7 @@
import javax.naming.spi.ObjectFactory;
import net.jcip.annotations.GuardedBy;
import org.jboss.dna.common.i18n.I18n;
+import org.jboss.dna.common.util.CheckArg;
import org.jboss.dna.common.util.HashCode;
import org.jboss.dna.graph.DnaLexicon;
import org.jboss.dna.graph.ExecutionContext;
@@ -387,6 +388,93 @@
}
/**
+ * Add a federated workspace to this source. If a workspace with the supplied name already exists, it will be replaced with
+ * the new one.
+ *
+ * @param workspaceName the name of the new federated workspace
+ * @param projections the projections that should be used in the workspace
+ * @param isDefault true if this workspace should be used as the default workspace, or false otherwise
+ * @return the federated workspace
+ * @throws IllegalArgumentException if the workspace name or the projections reference are null
+ */
+ public synchronized FederatedWorkspace addWorkspace( String workspaceName,
+ Iterable<Projection> projections,
+ boolean isDefault ) {
+ CheckArg.isNotNull(workspaceName, "workspaceName");
+ CheckArg.isNotNull(projections, "projections");
+
+ // Check all the properties of this source ...
+ String name = getName();
+ if (name == null) {
+ I18n msg = GraphI18n.namePropertyIsRequiredForFederatedRepositorySource;
+ throw new RepositorySourceException(getName(), msg.text("name"));
+ }
+ RepositoryContext context = getRepositoryContext();
+ if (context == null) {
+ I18n msg = GraphI18n.federatedRepositorySourceMustBeInitialized;
+ throw new RepositorySourceException(getName(), msg.text("name", name));
+ }
+
+ // Now set up or get the existing components needed by the workspace ...
+ RepositoryConnectionFactory connectionFactory = null;
+ ExecutorService executor = null;
+ LinkedList<FederatedWorkspace> workspaces = new LinkedList<FederatedWorkspace>();
+ CachePolicy defaultCachePolicy = null;
+ if (this.configuration != null) {
+ connectionFactory = this.configuration.getConnectionFactory();
+ executor = this.configuration.getExecutor();
+ defaultCachePolicy = this.configuration.getDefaultCachePolicy();
+ for (String existingWorkspaceName : this.configuration.getWorkspaceNames()) {
+ if (existingWorkspaceName.equals(workspaceName)) continue;
+ workspaces.add(this.configuration.getWorkspace(existingWorkspaceName));
+ }
+ } else {
+ connectionFactory = context.getRepositoryConnectionFactory();
+ executor = Executors.newCachedThreadPool();
+ }
+
+ // Add the new workspace ...
+ FederatedWorkspace newWorkspace = new FederatedWorkspace(context, name, workspaceName, projections, defaultCachePolicy);
+ if (isDefault) {
+ workspaces.addFirst(newWorkspace);
+ } else {
+ workspaces.add(newWorkspace);
+ }
+ // Update the configuration ...
+ this.configuration = new FederatedRepository(name, connectionFactory, workspaces, defaultCachePolicy, executor);
+ return newWorkspace;
+ }
+
+ /**
+ * Remove the named workspace from the repository source.
+ *
+ * @param workspaceName the name of the workspace to remove
+ * @return true if the workspace was removed, or false otherwise
+ * @throws IllegalArgumentException if the workspace name is null
+ */
+ public synchronized boolean removeWorkspace( String workspaceName ) {
+ CheckArg.isNotNull(workspaceName, "workspaceName");
+ if (this.configuration == null) return false;
+ FederatedWorkspace workspace = this.configuration.getWorkspace(workspaceName);
+ if (workspace == null) return false;
+ List<FederatedWorkspace> workspaces = new LinkedList<FederatedWorkspace>();
+ for (String existingWorkspaceName : this.configuration.getWorkspaceNames()) {
+ if (existingWorkspaceName.equals(workspaceName)) continue;
+ workspaces.add(this.configuration.getWorkspace(existingWorkspaceName));
+ }
+ RepositoryConnectionFactory connectionFactory = this.configuration.getConnectionFactory();
+ ExecutorService executor = this.configuration.getExecutor();
+ CachePolicy defaultCachePolicy = this.configuration.getDefaultCachePolicy();
+ this.configuration = new FederatedRepository(name, connectionFactory, workspaces, defaultCachePolicy, executor);
+ return true;
+ }
+
+ public synchronized boolean hasWorkspace( String workspaceName ) {
+ CheckArg.isNotNull(workspaceName, "workspaceName");
+ return this.configuration != null && this.configuration.getWorkspaceNames().contains(workspaceName);
+ }
+
+ /**
* Instantiate the {@link Projection} described by the supplied properties.
*
* @param context the execution context that should be used to read the configuration; may not be null
Modified: trunk/dna-graph/src/main/java/org/jboss/dna/graph/connector/federation/FederatedWorkspace.java
===================================================================
--- trunk/dna-graph/src/main/java/org/jboss/dna/graph/connector/federation/FederatedWorkspace.java 2009-07-20 19:05:35 UTC (rev 1117)
+++ trunk/dna-graph/src/main/java/org/jboss/dna/graph/connector/federation/FederatedWorkspace.java 2009-07-21 03:14:59 UTC (rev 1118)
@@ -71,6 +71,7 @@
CheckArg.isNotNull(repositoryContext, "repositoryContext");
CheckArg.isNotNull(sourceName, "sourceName");
CheckArg.isNotNull(workspaceName, "workspaceName");
+ CheckArg.isNotNull(projections, "projections");
this.repositoryContext = repositoryContext;
this.workspaceName = workspaceName;
this.sourceName = sourceName;
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-07-20 19:05:35 UTC (rev 1117)
+++ trunk/dna-graph/src/main/java/org/jboss/dna/graph/connector/federation/ForkRequestProcessor.java 2009-07-21 03:14:59 UTC (rev 1118)
@@ -72,6 +72,8 @@
import org.jboss.dna.graph.request.ReadBranchRequest;
import org.jboss.dna.graph.request.ReadNodeRequest;
import org.jboss.dna.graph.request.ReadPropertyRequest;
+import org.jboss.dna.graph.request.RemovePropertyRequest;
+import org.jboss.dna.graph.request.RenameNodeRequest;
import org.jboss.dna.graph.request.Request;
import org.jboss.dna.graph.request.SetPropertyRequest;
import org.jboss.dna.graph.request.UnsupportedRequestException;
@@ -118,7 +120,7 @@
* A pseudo Request that allows addition of a request that, when processed, will decrement a latch. Since the latch is
* supplied by the submitter, this is useful when the submitter wishes to block until a particular request is processed. The
* submitter merely creates a {@link CountDownLatch}, submits their real request wrapped by a BlockedRequest, and calls
- * {@link CountDownLatch#await()} on the latch. When <code>await()</code> returns, the first request has been completed.
+ * {@link CountDownLatch#await()} on the latch. When <code>await()</code> returns, the request has been completed.
*
* @see ForkRequestProcessor#submit(Request, String, CountDownLatch)
* @see ForkRequestProcessor#submitAndAwait(Request, String)
@@ -143,6 +145,27 @@
public boolean isCancelled() {
return original.isCancelled();
}
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.jboss.dna.graph.request.Request#setError(java.lang.Throwable)
+ */
+ @Override
+ public void setError( Throwable error ) {
+ original.setError(error);
+ if (this.latch != null) this.latch.countDown();
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.jboss.dna.graph.request.Request#hasError()
+ */
+ @Override
+ public boolean hasError() {
+ return original.hasError();
+ }
}
/**
@@ -172,6 +195,7 @@
protected Future<String> future;
/** Flag that defines whether the channel has processed all requests */
protected final AtomicBoolean done = new AtomicBoolean(false);
+ protected Throwable compositeError = null;
/**
* Create a new channel that operates against the supplied source.
@@ -225,6 +249,27 @@
public void cancel() {
done.set(true);
}
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.jboss.dna.graph.request.Request#setError(java.lang.Throwable)
+ */
+ @Override
+ public void setError( Throwable error ) {
+ compositeError = error;
+ super.setError(error);
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.jboss.dna.graph.request.Request#hasError()
+ */
+ @Override
+ public boolean hasError() {
+ return compositeError != null || super.hasError();
+ }
};
}
@@ -1077,6 +1122,41 @@
/**
* {@inheritDoc}
*
+ * @see org.jboss.dna.graph.request.processor.RequestProcessor#process(org.jboss.dna.graph.request.RemovePropertyRequest)
+ */
+ @Override
+ public void process( RemovePropertyRequest request ) {
+ // Figure out where this request is projected ...
+ ProjectedNode projectedNode = project(request.from(), 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 ...
+ RemovePropertyRequest pushDownRequest = new RemovePropertyRequest(proxy.location(), proxy.workspaceName(),
+ request.propertyName());
+ 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.from()), request.inWorkspace(), getSourceName());
+ request.setError(new UnsupportedRequestException(msg));
+ }
+
+ /**
+ * {@inheritDoc}
+ *
* @see org.jboss.dna.graph.request.processor.RequestProcessor#process(org.jboss.dna.graph.request.UpdatePropertiesRequest)
*/
@Override
@@ -1147,6 +1227,33 @@
/**
* {@inheritDoc}
*
+ * @see org.jboss.dna.graph.request.processor.RequestProcessor#process(org.jboss.dna.graph.request.DeleteChildrenRequest)
+ */
+ @Override
+ public void process( DeleteChildrenRequest request ) {
+ // Figure out where this request is projected ...
+ ProjectedNode projectedNode = project(request.at(), request.inWorkspace(), request, true);
+ if (projectedNode == null) return;
+
+ // Create the federated request ...
+ FederatedRequest federatedRequest = new FederatedRequest(request);
+
+ // A delete should be executed against any ProxyNode that applies ...
+ FederatedWorkspace workspace = getWorkspace(request, request.inWorkspace());
+ boolean submit = deleteBranch(federatedRequest, projectedNode, workspace, getExecutionContext(), false);
+ if (submit) {
+ // Submit the requests for processing and then STOP ...
+ submit(federatedRequest);
+ } else {
+ // Unable to perform this delete ...
+ String msg = GraphI18n.unableToDeletePlaceholder.text(readable(request.at()), 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
@@ -1160,7 +1267,7 @@
// A delete should be executed against any ProxyNode that applies ...
FederatedWorkspace workspace = getWorkspace(request, request.inWorkspace());
- boolean submit = deleteBranch(federatedRequest, projectedNode, workspace, getExecutionContext());
+ boolean submit = deleteBranch(federatedRequest, projectedNode, workspace, getExecutionContext(), true);
if (submit) {
// Submit the requests for processing and then STOP ...
submit(federatedRequest);
@@ -1174,13 +1281,14 @@
protected boolean deleteBranch( FederatedRequest federatedRequest,
ProjectedNode projectedNode,
FederatedWorkspace workspace,
- ExecutionContext context ) {
+ ExecutionContext context,
+ boolean includeParent ) {
boolean submit = false;
while (projectedNode != null) {
if (projectedNode.isProxy()) {
ProxyNode proxy = projectedNode.asProxy();
// Is this proxy represent the top level node of the projection?
- if (proxy.isTopLevelNode()) {
+ if (proxy.isTopLevelNode() || !includeParent) {
// Then we want to delete everything *underneath* the node, but we don't want to delete
// the node itself since it is the node being projected and must exist in order for the
// projection to work.
@@ -1194,17 +1302,19 @@
submit = true;
} else if (projectedNode.isPlaceholder()) {
PlaceholderNode placeholder = projectedNode.asPlaceholder();
- // Create a delete for this placeholder, but mark it completed. This is needed to know
- // which placeholders were being deleted.
- DeleteBranchRequest delete = new DeleteBranchRequest(placeholder.location(), workspace.getName());
- delete.setActualLocationOfNode(placeholder.location());
- federatedRequest.add(delete, true, true, null);
+ if (includeParent) {
+ // Create a delete for this placeholder, but mark it completed. This is needed to know
+ // which placeholders were being deleted.
+ DeleteBranchRequest delete = new DeleteBranchRequest(placeholder.location(), workspace.getName());
+ delete.setActualLocationOfNode(placeholder.location());
+ federatedRequest.add(delete, true, true, null);
+ }
// Create and submit a request for each proxy below this placeholder ...
// For each child of the placeholder node ...
for (ProjectedNode child : placeholder.children()) {
while (child != null && child.isProxy()) {
// Call recursively ...
- submit = deleteBranch(federatedRequest, child.asProxy(), workspace, context);
+ submit = deleteBranch(federatedRequest, child.asProxy(), workspace, context, true);
child = child.next();
}
}
@@ -1341,57 +1451,111 @@
// Figure out where the 'from' is projected ...
ProjectedNode projectedFromNode = project(request.from(), request.inWorkspace(), request, true);
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;
- // Limitation: only able to project the move if the 'from' and 'into' are in the same source & projection ...
- while (projectedFromNode != null) {
- if (projectedFromNode.isProxy()) {
- ProxyNode fromProxy = projectedFromNode.asProxy();
- // Look for a projectedIntoNode that has the same source/projection ...
- while (projectedIntoNode != null) {
- if (projectedIntoNode.isProxy()) {
- // Both are proxies, so compare the projection ...
- ProxyNode intoProxy = projectedIntoNode.asProxy();
- if (fromProxy.projection().getSourceName().equals(intoProxy.projection().getSourceName())) break;
+ boolean sameLocation = true;
+ if (request.into() != null) {
+ // Look at where the node is being moved; it must be within the same source/projection ...
+ ProjectedNode projectedIntoNode = project(request.into(), request.inWorkspace(), request, true);
+ if (projectedIntoNode == null) return;
+ // Limitation: only able to project the move if the 'from' and 'into' are in the same source & projection ...
+ while (projectedFromNode != null) {
+ if (projectedFromNode.isProxy()) {
+ ProxyNode fromProxy = projectedFromNode.asProxy();
+ // Look for a projectedIntoNode that has the same source/projection ...
+ while (projectedIntoNode != null) {
+ if (projectedIntoNode.isProxy()) {
+ // Both are proxies, so compare the projection ...
+ ProxyNode intoProxy = projectedIntoNode.asProxy();
+ if (fromProxy.projection().getSourceName().equals(intoProxy.projection().getSourceName())) break;
+ }
+ projectedIntoNode = projectedIntoNode.next();
}
- projectedIntoNode = projectedIntoNode.next();
+ if (projectedIntoNode != null) break;
}
- if (projectedIntoNode != null) break;
+ projectedFromNode = projectedFromNode.next();
}
- projectedFromNode = projectedFromNode.next();
+ if (projectedFromNode == null || projectedIntoNode == null) {
+ // The move is not done within a single source ...
+ String msg = GraphI18n.moveLimitedToBeWithinSingleSource.text(readable(request.from()),
+ request.inWorkspace(),
+ readable(request.into()),
+ request.inWorkspace(),
+ getSourceName());
+ request.setError(new UnsupportedRequestException(msg));
+ return;
+ }
+
+ ProxyNode fromProxy = projectedFromNode.asProxy();
+ ProxyNode intoProxy = projectedIntoNode.asProxy();
+ ProxyNode beforeProxy = request.before() != null ? projectedBeforeNode.asProxy() : null;
+ assert fromProxy.projection().getSourceName().equals(intoProxy.projection().getSourceName());
+ sameLocation = fromProxy.isSameLocationAsOriginal() && intoProxy.isSameLocationAsOriginal();
+
+ // Create the pushed-down request ...
+ Location beforeProxyLocation = beforeProxy != null ? beforeProxy.location() : null;
+ MoveBranchRequest pushDown = new MoveBranchRequest(fromProxy.location(), intoProxy.location(), beforeProxyLocation,
+ intoProxy.workspaceName(), request.desiredName(),
+ request.conflictBehavior());
+ // Create the federated request ...
+ FederatedRequest federatedRequest = new FederatedRequest(request);
+ federatedRequest.add(pushDown, sameLocation, false, fromProxy.projection(), intoProxy.projection());
+
+ // Submit the requests for processing and then STOP ...
+ submit(federatedRequest);
+ } else {
+ ProxyNode fromProxy = projectedFromNode.asProxy();
+ ProxyNode beforeProxy = request.before() != null ? projectedBeforeNode.asProxy() : null;
+ Location beforeProxyLocation = beforeProxy != null ? beforeProxy.location() : null;
+ MoveBranchRequest pushDown = new MoveBranchRequest(fromProxy.location(), null, beforeProxyLocation,
+ fromProxy.workspaceName(), request.desiredName(),
+ request.conflictBehavior());
+ // Create the federated request ...
+ FederatedRequest federatedRequest = new FederatedRequest(request);
+ federatedRequest.add(pushDown, sameLocation, false, fromProxy.projection());
+
+ // Submit the requests for processing and then STOP ...
+ submit(federatedRequest);
}
- if (projectedFromNode == null || projectedIntoNode == null) {
- // The move is not done within a single source ...
- String msg = GraphI18n.moveLimitedToBeWithinSingleSource.text(readable(request.from()),
- request.inWorkspace(),
- readable(request.into()),
- request.inWorkspace(),
- getSourceName());
- request.setError(new UnsupportedRequestException(msg));
- return;
- }
+ }
- ProxyNode fromProxy = projectedFromNode.asProxy();
- ProxyNode intoProxy = projectedIntoNode.asProxy();
- ProxyNode beforeProxy = request.before() != null ? projectedBeforeNode.asProxy() : null;
- assert fromProxy.projection().getSourceName().equals(intoProxy.projection().getSourceName());
- boolean sameLocation = fromProxy.isSameLocationAsOriginal() && intoProxy.isSameLocationAsOriginal();
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.jboss.dna.graph.request.processor.RequestProcessor#process(org.jboss.dna.graph.request.RenameNodeRequest)
+ */
+ @Override
+ public void process( RenameNodeRequest request ) {
+ // Figure out where the 'at' is projected ...
+ ProjectedNode projectedNode = project(request.at(), request.inWorkspace(), request, true);
+ if (projectedNode == null) return;
- // Create the pushed-down request ...
- 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());
- // Submit the requests for processing and then STOP ...
- submit(federatedRequest);
+ // 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 ...
+ RenameNodeRequest pushDownRequest = new RenameNodeRequest(proxy.location(), proxy.workspaceName(),
+ request.toName());
+ 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.at()), request.inWorkspace(), getSourceName());
+ request.setError(new UnsupportedRequestException(msg));
}
/**
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-07-20 19:05:35 UTC (rev 1117)
+++ trunk/dna-graph/src/main/java/org/jboss/dna/graph/connector/federation/JoinRequestProcessor.java 2009-07-21 03:14:59 UTC (rev 1118)
@@ -47,6 +47,7 @@
import org.jboss.dna.graph.request.CacheableRequest;
import org.jboss.dna.graph.request.CloneBranchRequest;
import org.jboss.dna.graph.request.CloneWorkspaceRequest;
+import org.jboss.dna.graph.request.CompositeRequest;
import org.jboss.dna.graph.request.CopyBranchRequest;
import org.jboss.dna.graph.request.CreateNodeRequest;
import org.jboss.dna.graph.request.CreateWorkspaceRequest;
@@ -61,6 +62,8 @@
import org.jboss.dna.graph.request.ReadBranchRequest;
import org.jboss.dna.graph.request.ReadNodeRequest;
import org.jboss.dna.graph.request.ReadPropertyRequest;
+import org.jboss.dna.graph.request.RemovePropertyRequest;
+import org.jboss.dna.graph.request.RenameNodeRequest;
import org.jboss.dna.graph.request.Request;
import org.jboss.dna.graph.request.SetPropertyRequest;
import org.jboss.dna.graph.request.UpdatePropertiesRequest;
@@ -104,14 +107,19 @@
*
* @param completedFederatedRequests the collection of {@link FederatedRequest} whose projected requests have already been
* processed; may not be null
+ * @return the exception that occurred while processing these requests (analogous to {@link CompositeRequest#getError()} where
+ * the composite's requests are these errors), or null if there was none
* @see FederatedRepositoryConnection#execute(ExecutionContext, org.jboss.dna.graph.request.Request)
*/
- public void process( final Iterable<FederatedRequest> completedFederatedRequests ) {
+ public Throwable process( final Iterable<FederatedRequest> completedFederatedRequests ) {
for (FederatedRequest federatedRequest : completedFederatedRequests) {
// No need to await for the forked request, since it will be done
- this.federatedRequest = federatedRequest;
- process(federatedRequest.original());
+ process(federatedRequest);
+ if (federatedRequest.original().hasError()) {
+ return federatedRequest.original().getError();
+ }
}
+ return null;
}
/**
@@ -130,40 +138,8 @@
forked = federatedRequestQueue.take();
if (forked instanceof NoMoreFederatedRequests) return;
forked.await();
-
- // Determine whether this is a single mirror request ...
- Request original = forked.original();
- ProjectedRequest projectedRequest = forked.getFirstProjectedRequest();
- boolean sameLocation = projectedRequest != null && !projectedRequest.hasNext()
- && projectedRequest.isSameLocation();
-
- // Set the cachable information ...
- if (original instanceof CacheableRequest) {
- CacheableRequest cacheableOriginal = (CacheableRequest)original;
- cacheableOriginal.setCachePolicy(getDefaultCachePolicy());
- while (projectedRequest != null) {
- Request requestToSource = projectedRequest.getRequest();
- if (cacheableOriginal != null) {
- setCacheableInfo(cacheableOriginal, ((CacheableRequest)requestToSource).getCachePolicy());
- }
- projectedRequest = projectedRequest.next();
- }
- }
-
- // Now do the join on this request ...
- if (sameLocation) {
- Request sourceRequest = forked.getFirstProjectedRequest().getRequest();
- if (sourceRequest.hasError()) {
- original.setError(sourceRequest.getError());
- } else if (sourceRequest.isCancelled()) {
- original.cancel();
- }
- mirrorProcessor.setFederatedRequest(forked);
- mirrorProcessor.process(original);
- } else {
- this.federatedRequest = forked;
- process(original);
- }
+ // Now process ...
+ process(forked);
}
} catch (InterruptedException e) {
// This happens when the federated connector has been told to shutdown now, and it shuts down
@@ -180,6 +156,41 @@
}
}
+ protected final void process( FederatedRequest forked ) {
+ // Determine whether this is a single mirror request ...
+ Request original = forked.original();
+ ProjectedRequest projectedRequest = forked.getFirstProjectedRequest();
+ boolean sameLocation = projectedRequest != null && !projectedRequest.hasNext() && projectedRequest.isSameLocation();
+
+ // Set the cachable information ...
+ if (original instanceof CacheableRequest) {
+ CacheableRequest cacheableOriginal = (CacheableRequest)original;
+ cacheableOriginal.setCachePolicy(getDefaultCachePolicy());
+ while (projectedRequest != null) {
+ Request requestToSource = projectedRequest.getRequest();
+ if (cacheableOriginal != null) {
+ setCacheableInfo(cacheableOriginal, ((CacheableRequest)requestToSource).getCachePolicy());
+ }
+ projectedRequest = projectedRequest.next();
+ }
+ }
+
+ // Now do the join on this request ...
+ if (sameLocation) {
+ Request sourceRequest = forked.getFirstProjectedRequest().getRequest();
+ if (sourceRequest.hasError()) {
+ original.setError(sourceRequest.getError());
+ } else if (sourceRequest.isCancelled()) {
+ original.cancel();
+ }
+ mirrorProcessor.setFederatedRequest(forked);
+ mirrorProcessor.process(original);
+ } else {
+ this.federatedRequest = forked;
+ process(original);
+ }
+ }
+
/**
* {@inheritDoc}
*
@@ -850,6 +861,21 @@
/**
* {@inheritDoc}
*
+ * @see org.jboss.dna.graph.request.processor.RequestProcessor#process(org.jboss.dna.graph.request.RemovePropertyRequest)
+ */
+ @Override
+ public void process( RemovePropertyRequest 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.from(), projected.getProjection(), sourceLocation, request));
+ }
+
+ /**
+ * {@inheritDoc}
+ *
* @see org.jboss.dna.graph.request.processor.RequestProcessor#process(org.jboss.dna.graph.request.DeleteBranchRequest)
*/
@Override
@@ -885,6 +911,51 @@
/**
* {@inheritDoc}
*
+ * @see org.jboss.dna.graph.request.processor.RequestProcessor#process(org.jboss.dna.graph.request.DeleteChildrenRequest)
+ */
+ @Override
+ public void process( DeleteChildrenRequest request ) {
+ ProjectedRequest projected = federatedRequest.getFirstProjectedRequest();
+ // Go through the projected requests, and look for the top-most node ...
+ Location highest = null;
+ while (projected != null) {
+ // The projected request should a DeleteChildrenRequest ...
+ Request sourceRequest = projected.getRequest();
+ DeleteChildrenRequest source = (DeleteChildrenRequest)projected.getRequest();
+ Location actual = source.getActualLocationOfNode();
+ if (checkErrorOrCancel(request, sourceRequest)) return;
+ if (!projected.isSameLocation() && projected.getProjection() != null) {
+ actual = projectToFederated(request.at(), projected.getProjection(), actual, request);
+ }
+ if (highest == null) highest = actual;
+ else if (highest.getPath().isDecendantOf(actual.getPath())) highest = actual;
+ projected = projected.next();
+ }
+ assert highest != null;
+ request.setActualLocationOfNode(highest);
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.jboss.dna.graph.request.processor.RequestProcessor#process(org.jboss.dna.graph.request.RenameNodeRequest)
+ */
+ @Override
+ public void process( RenameNodeRequest request ) {
+ ProjectedRequest projected = federatedRequest.getFirstProjectedRequest();
+ assert !projected.hasNext();
+ RenameNodeRequest source = (RenameNodeRequest)projected.getRequest();
+ if (checkErrorOrCancel(request, source)) return;
+ Location locationBefore = source.getActualLocationBefore();
+ Location locationAfter = source.getActualLocationBefore();
+ locationBefore = projectToFederated(request.at(), projected.getProjection(), locationBefore, request);
+ locationAfter = projectToFederated(request.at(), projected.getSecondProjection(), locationAfter, request);
+ request.setActualLocations(locationBefore, locationAfter);
+ }
+
+ /**
+ * {@inheritDoc}
+ *
* @see org.jboss.dna.graph.request.processor.RequestProcessor#process(org.jboss.dna.graph.request.CopyBranchRequest)
*/
@Override
@@ -932,7 +1003,9 @@
Location locationBefore = source.getActualLocationBefore();
Location locationAfter = source.getActualLocationBefore();
locationBefore = projectToFederated(request.from(), projected.getProjection(), locationBefore, request);
- locationAfter = projectToFederated(request.into(), projected.getSecondProjection(), locationAfter, request);
+ Projection afterProjection = projected.getSecondProjection();
+ if (afterProjection == null) projected.getProjection();
+ locationAfter = projectToFederated(request.into(), afterProjection, locationAfter, request);
request.setActualLocations(locationBefore, locationAfter);
}
Modified: trunk/dna-graph/src/main/java/org/jboss/dna/graph/request/CompositeRequest.java
===================================================================
--- trunk/dna-graph/src/main/java/org/jboss/dna/graph/request/CompositeRequest.java 2009-07-20 19:05:35 UTC (rev 1117)
+++ trunk/dna-graph/src/main/java/org/jboss/dna/graph/request/CompositeRequest.java 2009-07-21 03:14:59 UTC (rev 1118)
@@ -31,6 +31,7 @@
import java.util.concurrent.atomic.AtomicBoolean;
import net.jcip.annotations.Immutable;
import org.jboss.dna.common.util.CheckArg;
+import org.jboss.dna.graph.GraphI18n;
/**
* A request that wraps multiple other requests, allowing multiple requests to be treated as a single request.
@@ -258,6 +259,50 @@
}
/**
+ * Check the set of requests for errors. Calling this method will always result in the {@link #getError() existing error}
+ * being reset to a new error or null if there are no errors.
+ */
+ public void checkForErrors() {
+ Throwable firstError = null;
+ LinkedList<Throwable> additionalErrors = null;
+ for (Request request : requests) {
+ if (request.hasError()) {
+ if (firstError == null) {
+ firstError = request.getError();
+ } else {
+ if (additionalErrors == null) additionalErrors = new LinkedList<Throwable>();
+ additionalErrors.add(request.getError());
+ }
+ }
+ }
+ if (firstError != null) {
+ // There is at least one error ...
+ if (additionalErrors == null) {
+ // but only one ...
+ setError(firstError);
+ return;
+ }
+ // More than one ...
+ additionalErrors.addFirst(firstError);
+ // Now build a single composite error message ...
+ StringBuilder str = new StringBuilder();
+ for (Throwable error : additionalErrors) {
+ str.append("\n");
+ str.append("\t" + error.getMessage());
+ }
+ String msg = null;
+ int numberOfErrors = additionalErrors.size();
+ int numberOfRequests = size();
+ if (numberOfRequests == CompositeRequest.UNKNOWN_NUMBER_OF_REQUESTS) {
+ msg = GraphI18n.multipleErrorsWhileExecutingManyRequests.text(numberOfErrors, str.toString());
+ } else {
+ msg = GraphI18n.multipleErrorsWhileExecutingRequests.text(numberOfErrors, numberOfRequests, str.toString());
+ }
+ setError(new RequestException(msg));
+ }
+ }
+
+ /**
* {@inheritDoc}
*
* @see java.lang.Object#equals(java.lang.Object)
Modified: trunk/dna-graph/src/main/java/org/jboss/dna/graph/request/InvalidRequestException.java
===================================================================
--- trunk/dna-graph/src/main/java/org/jboss/dna/graph/request/InvalidRequestException.java 2009-07-20 19:05:35 UTC (rev 1117)
+++ trunk/dna-graph/src/main/java/org/jboss/dna/graph/request/InvalidRequestException.java 2009-07-21 03:14:59 UTC (rev 1118)
@@ -28,7 +28,7 @@
*
* @author Randall Hauch
*/
-public class InvalidRequestException extends RuntimeException {
+public class InvalidRequestException extends RequestException {
/**
*/
Modified: trunk/dna-graph/src/main/java/org/jboss/dna/graph/request/InvalidWorkspaceException.java
===================================================================
--- trunk/dna-graph/src/main/java/org/jboss/dna/graph/request/InvalidWorkspaceException.java 2009-07-20 19:05:35 UTC (rev 1117)
+++ trunk/dna-graph/src/main/java/org/jboss/dna/graph/request/InvalidWorkspaceException.java 2009-07-21 03:14:59 UTC (rev 1118)
@@ -28,7 +28,7 @@
*
* @author Randall Hauch
*/
-public class InvalidWorkspaceException extends RuntimeException {
+public class InvalidWorkspaceException extends RequestException {
/**
*/
@@ -61,7 +61,7 @@
* @param cause
*/
public InvalidWorkspaceException( String message,
- Throwable cause ) {
+ Throwable cause ) {
super(message, cause);
}
Modified: trunk/dna-graph/src/main/java/org/jboss/dna/graph/request/MoveBranchRequest.java
===================================================================
--- trunk/dna-graph/src/main/java/org/jboss/dna/graph/request/MoveBranchRequest.java 2009-07-20 19:05:35 UTC (rev 1117)
+++ trunk/dna-graph/src/main/java/org/jboss/dna/graph/request/MoveBranchRequest.java 2009-07-21 03:14:59 UTC (rev 1118)
@@ -141,7 +141,7 @@
/**
* Get the location defining the parent where the branch is to be placed
*
- * @return the to location; never null
+ * @return the to location; or null if the node is being reordered within the same parent
*/
public Location into() {
return into;
Copied: trunk/dna-graph/src/main/java/org/jboss/dna/graph/request/RequestException.java (from rev 1117, trunk/dna-graph/src/main/java/org/jboss/dna/graph/request/InvalidRequestException.java)
===================================================================
--- trunk/dna-graph/src/main/java/org/jboss/dna/graph/request/RequestException.java (rev 0)
+++ trunk/dna-graph/src/main/java/org/jboss/dna/graph/request/RequestException.java 2009-07-21 03:14:59 UTC (rev 1118)
@@ -0,0 +1,69 @@
+/*
+ * 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.request;
+
+/**
+ * Specifies that the request was invalid and could not be completed.
+ *
+ * @author Randall Hauch
+ */
+public class RequestException extends RuntimeException {
+
+ /**
+ */
+ private static final long serialVersionUID = 1L;
+
+ /**
+ *
+ */
+ public RequestException() {
+ }
+
+ /**
+ * @param message
+ */
+ public RequestException( String message ) {
+ super(message);
+
+ }
+
+ /**
+ * @param cause
+ */
+ public RequestException( Throwable cause ) {
+ super(cause);
+
+ }
+
+ /**
+ * @param message
+ * @param cause
+ */
+ public RequestException( String message,
+ Throwable cause ) {
+ super(message, cause);
+
+ }
+
+}
Modified: trunk/dna-graph/src/main/java/org/jboss/dna/graph/request/UnsupportedRequestException.java
===================================================================
--- trunk/dna-graph/src/main/java/org/jboss/dna/graph/request/UnsupportedRequestException.java 2009-07-20 19:05:35 UTC (rev 1117)
+++ trunk/dna-graph/src/main/java/org/jboss/dna/graph/request/UnsupportedRequestException.java 2009-07-21 03:14:59 UTC (rev 1118)
@@ -28,7 +28,7 @@
*
* @author Randall Hauch
*/
-public class UnsupportedRequestException extends RuntimeException {
+public class UnsupportedRequestException extends RequestException {
/**
*/
Modified: trunk/dna-graph/src/main/java/org/jboss/dna/graph/request/processor/RequestProcessor.java
===================================================================
--- trunk/dna-graph/src/main/java/org/jboss/dna/graph/request/processor/RequestProcessor.java 2009-07-20 19:05:35 UTC (rev 1117)
+++ trunk/dna-graph/src/main/java/org/jboss/dna/graph/request/processor/RequestProcessor.java 2009-07-21 03:14:59 UTC (rev 1118)
@@ -34,7 +34,6 @@
import org.jboss.dna.graph.GraphI18n;
import org.jboss.dna.graph.Location;
import org.jboss.dna.graph.cache.CachePolicy;
-import org.jboss.dna.graph.connector.RepositorySourceException;
import org.jboss.dna.graph.observe.Changes;
import org.jboss.dna.graph.observe.Observer;
import org.jboss.dna.graph.property.DateTime;
@@ -283,39 +282,18 @@
*/
public void process( CompositeRequest request ) {
if (request == null) return;
- int numberOfErrors = 0;
- List<Throwable> errors = null;
+ boolean hasErrors = false;
// Iterate over the requests in this composite, but only iterate once so that
for (Request embedded : request) {
assert embedded != null;
if (embedded.isCancelled()) return;
process(embedded);
- if (embedded.hasError()) {
- if (numberOfErrors == 0) {
- errors = new LinkedList<Throwable>();
- }
- assert errors != null;
- errors.add(embedded.getError());
- ++numberOfErrors;
+ if (!hasErrors && embedded.hasError()) {
+ hasErrors = true;
}
}
- if (numberOfErrors == 0) return;
- assert errors != null;
- if (numberOfErrors == 1) {
- request.setError(errors.get(0));
- } else {
- StringBuilder errorString = new StringBuilder();
- for (Throwable error : errors) {
- errorString.append("\n");
- errorString.append("\t" + error.getMessage());
- }
- String msg = null;
- if (request.size() == CompositeRequest.UNKNOWN_NUMBER_OF_REQUESTS) {
- msg = GraphI18n.multipleErrorsWhileExecutingManyRequests.text(numberOfErrors, errorString.toString());
- } else {
- msg = GraphI18n.multipleErrorsWhileExecutingRequests.text(numberOfErrors, request.size(), errorString.toString());
- }
- request.setError(new RepositorySourceException(getSourceName(), msg));
+ if (hasErrors) {
+ request.checkForErrors();
}
}
@@ -732,6 +710,9 @@
request.setError(update.getError());
}
// Set the actual location ...
+ if (update.getActualLocationOfNode() == null) {
+ int x = 0;
+ }
request.setActualLocationOfNode(update.getActualLocationOfNode());
}
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-07-20 19:05:35 UTC (rev 1117)
+++ trunk/dna-graph/src/test/java/org/jboss/dna/graph/connector/federation/AbstractFederatedRepositorySourceIntegrationTest.java 2009-07-21 03:14:59 UTC (rev 1118)
@@ -24,6 +24,7 @@
package org.jboss.dna.graph.connector.federation;
import static org.hamcrest.core.Is.is;
+import static org.hamcrest.core.IsNull.notNullValue;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.fail;
import static org.mockito.Mockito.stub;
@@ -38,6 +39,7 @@
import org.jboss.dna.graph.Graph;
import org.jboss.dna.graph.Location;
import org.jboss.dna.graph.Node;
+import org.jboss.dna.graph.Results;
import org.jboss.dna.graph.Subgraph;
import org.jboss.dna.graph.connector.RepositoryConnection;
import org.jboss.dna.graph.connector.RepositoryConnectionFactory;
@@ -342,4 +344,15 @@
AbstractConnectorTest.assertEquivalentSubgraphs(fedSubgraph, sourceSubgraph, true, false);
}
}
+
+ protected void assertReadUsingBatch( String... pathsInFederated ) {
+ Graph.Batch batch = federated.batch();
+ for (String pathInFederated : pathsInFederated) {
+ batch.read(pathInFederated).and();
+ }
+ Results results = batch.execute();
+ for (String pathInFederated : pathsInFederated) {
+ assertThat(results.getNode(pathInFederated), is(notNullValue()));
+ }
+ }
}
Modified: trunk/dna-graph/src/test/java/org/jboss/dna/graph/connector/federation/FederatedRepositoryConnectionTest.java
===================================================================
--- trunk/dna-graph/src/test/java/org/jboss/dna/graph/connector/federation/FederatedRepositoryConnectionTest.java 2009-07-20 19:05:35 UTC (rev 1117)
+++ trunk/dna-graph/src/test/java/org/jboss/dna/graph/connector/federation/FederatedRepositoryConnectionTest.java 2009-07-21 03:14:59 UTC (rev 1118)
@@ -34,6 +34,7 @@
import org.jboss.dna.graph.request.CompositeRequest;
import org.jboss.dna.graph.request.Request;
import org.junit.Before;
+import org.junit.Ignore;
import org.junit.Test;
import org.mockito.MockitoAnnotations;
import org.mockito.MockitoAnnotations.Mock;
@@ -92,6 +93,7 @@
assertThat(connection.shouldProcessSynchronously(request), is(true));
}
+ @Ignore
@Test
public void shouldProcessCompositeRequestWithMultipleRequestsAsynchronously() {
CompositeRequest request = mock(CompositeRequest.class);
Modified: trunk/dna-graph/src/test/java/org/jboss/dna/graph/connector/federation/FederatedRepositorySourceUsingMirrorAndBranchProjectionsTest.java
===================================================================
--- trunk/dna-graph/src/test/java/org/jboss/dna/graph/connector/federation/FederatedRepositorySourceUsingMirrorAndBranchProjectionsTest.java 2009-07-20 19:05:35 UTC (rev 1117)
+++ trunk/dna-graph/src/test/java/org/jboss/dna/graph/connector/federation/FederatedRepositorySourceUsingMirrorAndBranchProjectionsTest.java 2009-07-21 03:14:59 UTC (rev 1118)
@@ -138,6 +138,11 @@
}
@Test
+ public void shouldPerformBatchOperationsAgainstFederatedSource() {
+ assertReadUsingBatch("/Aircraft", "/Aircraft/Business", "/Cars");
+ }
+
+ @Test
public void shouldCreateNodeUnderRootInMirrorSource() {
federated.createAt("/Hovercraft").with("prop1", "value1").and();
assertMirrorNode("/Hovercraft");
Modified: trunk/dna-graph/src/test/java/org/jboss/dna/graph/connector/federation/ForkRequestProcessorChannelTest.java
===================================================================
--- trunk/dna-graph/src/test/java/org/jboss/dna/graph/connector/federation/ForkRequestProcessorChannelTest.java 2009-07-20 19:05:35 UTC (rev 1117)
+++ trunk/dna-graph/src/test/java/org/jboss/dna/graph/connector/federation/ForkRequestProcessorChannelTest.java 2009-07-21 03:14:59 UTC (rev 1118)
@@ -33,6 +33,7 @@
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
+import java.util.concurrent.CountDownLatch;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import org.jboss.dna.graph.ExecutionContext;
@@ -153,6 +154,40 @@
assertThat(iter.hasNext(), is(false));
}
+ @Test
+ public void shouldSubmitBlockedRequestsToConnection() throws Exception {
+ // Start the channel ...
+ channel.start(executor, context, connectionFactory);
+
+ // Submit the requests to the channel ...
+ List<CountDownLatch> latches = new ArrayList<CountDownLatch>();
+ for (Request request : requests) {
+ CountDownLatch latch = new CountDownLatch(1);
+ latches.add(latch);
+ channel.add(request, latch);
+ }
+
+ // Mark the channel as done ...
+ channel.done();
+
+ // Wait until the channel has completed ...
+ channel.await();
+
+ // Verify that all of the latches were decremented ...
+ for (CountDownLatch latch : latches) {
+ latch.await();
+ assertThat(latch.getCount(), is(0L));
+ }
+
+ // Verify that all the requests to the channel were processed ...
+ Iterator<Request> iter = executedRequests.iterator();
+ for (Request expected : requests) {
+ assertThat(iter.hasNext(), is(true));
+ assertThat(iter.next(), is(sameInstance(expected)));
+ }
+ assertThat(iter.hasNext(), is(false));
+ }
+
protected static class AddRequestsRunnable implements Runnable {
private final Channel channel;
private final Iterator<Request> requests;
16 years, 9 months
DNA SVN: r1117 - in trunk/dna-repository/src: test/java/org/jboss/dna/repository and 1 other directory.
by dna-commits@lists.jboss.org
Author: bcarothers
Date: 2009-07-20 15:05:35 -0400 (Mon, 20 Jul 2009)
New Revision: 1117
Modified:
trunk/dna-repository/src/main/java/org/jboss/dna/repository/DnaEngine.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
Log:
DNA-483 RepositoryService Doesn't Expose Problems from startService
Committed a patch (DNA-483_take_2.patch) that reuses the existing DnaEngine problems sink instead of adding a new one and setting a precedent that users will have to check problems in many different places.
Modified: trunk/dna-repository/src/main/java/org/jboss/dna/repository/DnaEngine.java
===================================================================
--- trunk/dna-repository/src/main/java/org/jboss/dna/repository/DnaEngine.java 2009-07-20 12:44:32 UTC (rev 1116)
+++ trunk/dna-repository/src/main/java/org/jboss/dna/repository/DnaEngine.java 2009-07-20 19:05:35 UTC (rev 1117)
@@ -106,7 +106,7 @@
Path pathToConfigurationRoot = this.configuration.getPath();
String configWorkspaceName = this.configuration.getWorkspace();
final RepositorySource configSource = this.configuration.getRepositorySource();
- repositoryService = new RepositoryService(configSource, configWorkspaceName, pathToConfigurationRoot, context);
+ repositoryService = new RepositoryService(configSource, configWorkspaceName, pathToConfigurationRoot, context, problems);
// Create the sequencing service ...
executorService = new ScheduledThreadPoolExecutor(10); // Use a magic number for now
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-07-20 12:44:32 UTC (rev 1116)
+++ trunk/dna-repository/src/main/java/org/jboss/dna/repository/RepositoryService.java 2009-07-20 19:05:35 UTC (rev 1117)
@@ -106,6 +106,8 @@
private final Path pathToConfigurationRoot;
private final Administrator administrator = new Administrator();
private final AtomicBoolean started = new AtomicBoolean(false);
+ /** The problem sink used when encountering problems while starting repositories */
+ private final Problems problems;
/**
* Create a service instance, reading the configuration describing new {@link RepositorySource} instances from the supplied
@@ -117,16 +119,19 @@
* @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
+ * @param problems the {@link Problems} instance that this service should use to report problems starting repositories
* @throws IllegalArgumentException if the bootstrap source is null or the execution context is null
*/
public RepositoryService( RepositorySource configurationSource,
String configurationWorkspaceName,
Path pathToConfigurationRoot,
- ExecutionContext context ) {
+ ExecutionContext context,
+ Problems problems ) {
CheckArg.isNotNull(configurationSource, "configurationSource");
CheckArg.isNotNull(context, "context");
PathFactory pathFactory = context.getValueFactories().getPathFactory();
if (pathToConfigurationRoot == null) pathToConfigurationRoot = pathFactory.create("/dna:system");
+ if (problems == null) problems = new SimpleProblems();
Path sourcesPath = pathFactory.create(pathToConfigurationRoot, DnaLexicon.SOURCES);
this.sources = new RepositoryLibrary(configurationSource, configurationWorkspaceName, sourcesPath, context);
@@ -135,6 +140,7 @@
this.configurationSourceName = configurationSource.getName();
this.configurationWorkspaceName = configurationWorkspaceName;
this.context = context;
+ this.problems = problems;
}
/**
@@ -180,9 +186,7 @@
}
protected synchronized void startService() {
- if (this.started.get() == false) {
- Problems problems = new SimpleProblems();
-
+ if (this.started.get() == false) {
// ------------------------------------------------------------------------------------
// Read the configuration ...
// ------------------------------------------------------------------------------------
@@ -207,6 +211,7 @@
} catch (Throwable err) {
throw new FederationException(RepositoryI18n.errorStartingRepositoryService.text(), err);
}
+
this.started.set(true);
}
}
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-07-20 12:44:32 UTC (rev 1116)
+++ trunk/dna-repository/src/test/java/org/jboss/dna/repository/RepositoryServiceTest.java 2009-07-20 19:05:35 UTC (rev 1117)
@@ -32,6 +32,8 @@
import static org.mockito.Mockito.stub;
import static org.mockito.Mockito.verifyNoMoreInteractions;
import java.util.concurrent.TimeUnit;
+import org.jboss.dna.common.collection.Problems;
+import org.jboss.dna.common.collection.SimpleProblems;
import org.jboss.dna.common.util.Logger;
import org.jboss.dna.graph.DnaLexicon;
import org.jboss.dna.graph.ExecutionContext;
@@ -59,6 +61,7 @@
private InMemoryRepositorySource configRepositorySource;
private ExecutionContext context;
private Path root;
+ private Problems problems;
@Mock
private RepositoryLibrary sources;
@@ -76,7 +79,8 @@
RepositoryConnection configRepositoryConnection = configRepositorySource.getConnection();
stub(sources.createConnection(configSourceName)).toReturn(configRepositoryConnection);
root = context.getValueFactories().getPathFactory().createRootPath();
- service = new RepositoryService(configRepositorySource, configWorkspaceName, root, context);
+ problems = new SimpleProblems();
+ service = new RepositoryService(configRepositorySource, configWorkspaceName, root, context, problems);
}
@After
@@ -189,7 +193,7 @@
@Test
public void shouldConfigureRepositorySourceWithSetterThatTakesArrayButWithSingleValues() {
Path configPath = context.getValueFactories().getPathFactory().create("/dna:system");
- service = new RepositoryService(configRepositorySource, configWorkspaceName, configPath, context);
+ service = new RepositoryService(configRepositorySource, configWorkspaceName, configPath, context, problems);
// Set up the configuration repository ...
configRepository.useWorkspace("default");
16 years, 9 months
DNA SVN: r1116 - trunk/dna-jcr/src/test/java/org/jboss/dna/jcr.
by dna-commits@lists.jboss.org
Author: bcarothers
Date: 2009-07-20 08:44:32 -0400 (Mon, 20 Jul 2009)
New Revision: 1116
Modified:
trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/DnaRepositoryStub.java
Log:
Commented out reference to uncommitted patch to fix build.
Modified: trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/DnaRepositoryStub.java
===================================================================
--- trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/DnaRepositoryStub.java 2009-07-20 12:18:58 UTC (rev 1115)
+++ trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/DnaRepositoryStub.java 2009-07-20 12:44:32 UTC (rev 1116)
@@ -94,8 +94,8 @@
JcrEngine engine = configuration.build();
engine.start();
- Problems problems = engine.getRepositoryService().getStartupProblems();
- // Problems problems = engine.getProblems();
+ // Problems problems = engine.getRepositoryService().getStartupProblems();
+ Problems problems = engine.getProblems();
// Print all of the problems from the engine configuration ...
for (Problem problem : problems) {
System.err.println(problem);
16 years, 9 months
DNA SVN: r1115 - in trunk: dna-graph/src/main/java/org/jboss/dna/graph/connector/map and 13 other directories.
by dna-commits@lists.jboss.org
Author: bcarothers
Date: 2009-07-20 08:18:58 -0400 (Mon, 20 Jul 2009)
New Revision: 1115
Added:
trunk/dna-graph/src/main/java/org/jboss/dna/graph/DnaIntLexicon.java
trunk/dna-integration-tests/src/test/java/org/jboss/dna/test/integration/AbstractRepositoryTckTest.java
trunk/dna-integration-tests/src/test/java/org/jboss/dna/test/integration/JpaRepositoryTckTest.java
trunk/dna-integration-tests/src/test/resources/tck/jpa/
trunk/dna-integration-tests/src/test/resources/tck/jpa/configRepository.xml
trunk/dna-integration-tests/src/test/resources/tck/jpa/repositoryOverlay.properties
Modified:
trunk/dna-graph/src/main/java/org/jboss/dna/graph/ExecutionContext.java
trunk/dna-graph/src/main/java/org/jboss/dna/graph/connector/map/AbstractMapWorkspace.java
trunk/dna-graph/src/test/java/org/jboss/dna/graph/connector/test/WritableConnectorTest.java
trunk/dna-integration-tests/pom.xml
trunk/dna-integration-tests/src/test/java/org/jboss/dna/test/integration/InfinispanRepositoryTckTest.java
trunk/dna-integration-tests/src/test/java/org/jboss/dna/test/integration/JBossCacheRepositoryTckTest.java
trunk/dna-integration-tests/src/test/resources/log4j.properties
trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/DnaIntLexicon.java
trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/JcrContentHandler.java
trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/JcrValue.java
trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/SessionCache.java
trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/DnaRepositoryStub.java
trunk/dna-jcr/src/test/resources/repositoryStubImpl.properties
trunk/extensions/dna-connector-store-jpa/src/main/java/org/jboss/dna/connector/store/jpa/JpaSource.java
trunk/extensions/dna-connector-store-jpa/src/main/java/org/jboss/dna/connector/store/jpa/model/basic/BasicRequestProcessor.java
trunk/extensions/dna-connector-store-jpa/src/main/java/org/jboss/dna/connector/store/jpa/model/basic/ChildEntity.java
trunk/extensions/dna-connector-store-jpa/src/main/java/org/jboss/dna/connector/store/jpa/util/Serializer.java
trunk/extensions/dna-connector-store-jpa/src/test/java/org/jboss/dna/connector/store/jpa/JpaConnectorWritingTest.java
trunk/extensions/dna-connector-store-jpa/src/test/java/org/jboss/dna/connector/store/jpa/JpaSourceTest.java
Log:
DNA-486 Add integration test that uses the JPA connector
Applied patch that fixes a number of minor issues with the JPA connector, adds additional testing of the move operation for writable connectors, cleans up the TCK integration tests, and adds a TCK integration test for the JPA connector.
Added: trunk/dna-graph/src/main/java/org/jboss/dna/graph/DnaIntLexicon.java
===================================================================
--- trunk/dna-graph/src/main/java/org/jboss/dna/graph/DnaIntLexicon.java (rev 0)
+++ trunk/dna-graph/src/main/java/org/jboss/dna/graph/DnaIntLexicon.java 2009-07-20 12:18:58 UTC (rev 1115)
@@ -0,0 +1,36 @@
+/*
+ * 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.
+ *
+ * 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;
+
+
+/**
+ * A lexicon of internal and implementation-specific information
+ */
+public class DnaIntLexicon {
+
+ public static class Namespace {
+ public static final String URI = "http://www.jboss.org/dna/internal/1.0";
+ public static final String PREFIX = "dnaint";
+ }
+}
Property changes on: trunk/dna-graph/src/main/java/org/jboss/dna/graph/DnaIntLexicon.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
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-07-17 19:12:26 UTC (rev 1114)
+++ trunk/dna-graph/src/main/java/org/jboss/dna/graph/ExecutionContext.java 2009-07-20 12:18:58 UTC (rev 1115)
@@ -327,6 +327,7 @@
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(DnaIntLexicon.Namespace.PREFIX, DnaIntLexicon.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/connector/map/AbstractMapWorkspace.java
===================================================================
--- trunk/dna-graph/src/main/java/org/jboss/dna/graph/connector/map/AbstractMapWorkspace.java 2009-07-17 19:12:26 UTC (rev 1114)
+++ trunk/dna-graph/src/main/java/org/jboss/dna/graph/connector/map/AbstractMapWorkspace.java 2009-07-20 12:18:58 UTC (rev 1115)
@@ -357,6 +357,13 @@
assert this.getRoot().equals(node) != true;
MapNode oldParent = node.getParent();
Name oldName = node.getName().getName();
+
+ if (this.equals(newAbstractMapWorkspace) && node.getParent().getUuid().equals(newParent.getUuid())
+ && node.equals(beforeNode)) {
+ // Trivial move of a node to its parent before itself
+ return;
+ }
+
if (oldParent != null) {
boolean removed = oldParent.getChildren().remove(node);
assert removed == true;
Modified: trunk/dna-graph/src/test/java/org/jboss/dna/graph/connector/test/WritableConnectorTest.java
===================================================================
--- trunk/dna-graph/src/test/java/org/jboss/dna/graph/connector/test/WritableConnectorTest.java 2009-07-17 19:12:26 UTC (rev 1114)
+++ trunk/dna-graph/src/test/java/org/jboss/dna/graph/connector/test/WritableConnectorTest.java 2009-07-20 12:18:58 UTC (rev 1115)
@@ -1055,6 +1055,46 @@
}
@Test
+ public void shouldMoveNodeBeforeSibling() {
+
+ String initialPath = "";
+ int depth = 1;
+ int numChildrenPerNode = 3;
+ int numPropertiesPerNode = 3;
+ Stopwatch sw = new Stopwatch();
+ boolean batch = true;
+ createSubgraph(graph, initialPath, depth, numChildrenPerNode, numPropertiesPerNode, batch, sw, System.out, null);
+
+ // Move last node to front ...
+ graph.move("/node3").before("/node1");
+
+ assertThat(graph.getChildren().of("/"), hasChildren(segment("node3"), segment("node1"), segment("node2")));
+
+ // Move last node to front ...
+ graph.move("/node3").before("/node1");
+
+ assertThat(graph.getChildren().of("/"), hasChildren(segment("node2"), segment("node3"), segment("node1")));
+
+ }
+
+ @Test
+ public void shouldMoveNodeBeforeSelf() {
+
+ String initialPath = "";
+ int depth = 1;
+ int numChildrenPerNode = 3;
+ int numPropertiesPerNode = 3;
+ Stopwatch sw = new Stopwatch();
+ boolean batch = true;
+ createSubgraph(graph, initialPath, depth, numChildrenPerNode, numPropertiesPerNode, batch, sw, System.out, null);
+
+ // Move node before itself (trivial change) ...
+ graph.move("/node2").before("/node2");
+
+ assertThat(graph.getChildren().of("/"), hasChildren(segment("node1"), segment("node2"), segment("node3")));
+ }
+
+ @Test
public void shouldMoveNodes() {
// Create the tree (at total of 40 nodes, plus the extra 6 added later)...
// /
Modified: trunk/dna-integration-tests/pom.xml
===================================================================
--- trunk/dna-integration-tests/pom.xml 2009-07-17 19:12:26 UTC (rev 1114)
+++ trunk/dna-integration-tests/pom.xml 2009-07-20 12:18:58 UTC (rev 1115)
@@ -75,12 +75,34 @@
<version>${pom.version}</version>
<scope>test</scope>
</dependency>
+
+ <!--
+ JPA Connector Dependencies
+ -->
<dependency>
<groupId>org.jboss.dna</groupId>
<artifactId>dna-connector-store-jpa</artifactId>
<version>${pom.version}</version>
<scope>test</scope>
</dependency>
+ <dependency>
+ <groupId>org.hibernate</groupId>
+ <artifactId>hibernate-entitymanager</artifactId>
+ <version>3.4.0.GA</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.hibernate</groupId>
+ <artifactId>hibernate-c3p0</artifactId>
+ <version>3.3.1.GA</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>hsqldb</groupId>
+ <artifactId>hsqldb</artifactId>
+ <version>1.8.0.2</version>
+ <scope>test</scope>
+ </dependency>
<!--
Logging (require SLF4J API for compiling, but use Log4J and its SLF4J
Added: trunk/dna-integration-tests/src/test/java/org/jboss/dna/test/integration/AbstractRepositoryTckTest.java
===================================================================
--- trunk/dna-integration-tests/src/test/java/org/jboss/dna/test/integration/AbstractRepositoryTckTest.java (rev 0)
+++ trunk/dna-integration-tests/src/test/java/org/jboss/dna/test/integration/AbstractRepositoryTckTest.java 2009-07-20 12:18:58 UTC (rev 1115)
@@ -0,0 +1,80 @@
+/*
+ * JBoss DNA (http://www.jboss.org/dna)
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ * See the AUTHORS.txt file in the distribution for a full listing of
+ * individual contributors.
+ *
+ * JBoss DNA is free software. Unless otherwise indicated, all code in JBoss DNA
+ * is licensed to you under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * JBoss DNA is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.dna.test.integration;
+
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+import org.jboss.dna.jcr.DnaRepositoryStub;
+import org.jboss.dna.jcr.DnaTckTest;
+import org.jboss.dna.jcr.JcrTckTest;
+
+/**
+ * Container for the standard integration test suites that should be run against various read-only and read-write repository
+ * configurations.
+ * <p>
+ * The tests require the repository implementation for the TCK tests to change between runs. This is accomplished by adding a
+ * {@link ChangeRepositoryTestCase trivial test} to the beginning of the suite that
+ * {@link DnaRepositoryStub#setCurrentConfigurationName(String) changes the repository configuration} in the
+ * {@link DnaRepositoryStub}.
+ * </p>
+ */
+public abstract class AbstractRepositoryTckTest {
+
+ public static TestSuite readWriteRepositorySuite( final String name ) {
+ TestSuite suite = new TestSuite("Tests for " + name + "(read-write)");
+ suite.addTest(new ChangeRepositoryTestCase(name));
+ suite.addTest(JcrTckTest.suite());
+ suite.addTestSuite(DnaTckTest.class);
+
+ return suite;
+ }
+
+ public static TestSuite readOnlyRepositorySuite( String name ) {
+ TestSuite suite = new TestSuite("Tests for " + name + "(read-only)");
+ suite.addTest(new ChangeRepositoryTestCase(name));
+ suite.addTest(JcrTckTest.suite());
+ suite.addTestSuite(DnaTckTest.class);
+
+ return suite;
+ }
+
+ /**
+ * Trivial test case that invokes {@link DnaRepositoryStub#setCurrentConfigurationName(String)} to change the currently used
+ * TCK configuration. If this test fails, that is an indication that the configuration is incorrect or that the {@code name}
+ * parameter does not match a valid configuration name.
+ */
+ public static class ChangeRepositoryTestCase extends TestCase {
+ private final String configurationName;
+
+ public ChangeRepositoryTestCase( final String configurationName ) {
+ super("testConfigurationNameChange");
+
+ this.configurationName = configurationName;
+ }
+
+ public void testConfigurationNameChange() {
+ DnaRepositoryStub.setCurrentConfigurationName(configurationName);
+ }
+ }
+}
Property changes on: trunk/dna-integration-tests/src/test/java/org/jboss/dna/test/integration/AbstractRepositoryTckTest.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Modified: trunk/dna-integration-tests/src/test/java/org/jboss/dna/test/integration/InfinispanRepositoryTckTest.java
===================================================================
--- trunk/dna-integration-tests/src/test/java/org/jboss/dna/test/integration/InfinispanRepositoryTckTest.java 2009-07-17 19:12:26 UTC (rev 1114)
+++ trunk/dna-integration-tests/src/test/java/org/jboss/dna/test/integration/InfinispanRepositoryTckTest.java 2009-07-20 12:18:58 UTC (rev 1115)
@@ -24,21 +24,9 @@
package org.jboss.dna.test.integration;
import junit.framework.Test;
-import junit.framework.TestSuite;
-import org.jboss.dna.jcr.DnaRepositoryStub;
-import org.jboss.dna.jcr.DnaTckTest;
-import org.jboss.dna.jcr.JcrTckTest;
-public class InfinispanRepositoryTckTest extends JcrTckTest {
-
- private static final String NAME = "infinispan";
-
+public class InfinispanRepositoryTckTest {
public static Test suite() {
- DnaRepositoryStub.setCurrentConfigurationName(NAME);
- TestSuite suite = new TestSuite("TCK Tests for " + NAME);
- suite.addTest(JcrTckTest.suite());
- suite.addTestSuite(DnaTckTest.class);
-
- return suite;
+ return AbstractRepositoryTckTest.readWriteRepositorySuite("infinispan");
}
}
Modified: trunk/dna-integration-tests/src/test/java/org/jboss/dna/test/integration/JBossCacheRepositoryTckTest.java
===================================================================
--- trunk/dna-integration-tests/src/test/java/org/jboss/dna/test/integration/JBossCacheRepositoryTckTest.java 2009-07-17 19:12:26 UTC (rev 1114)
+++ trunk/dna-integration-tests/src/test/java/org/jboss/dna/test/integration/JBossCacheRepositoryTckTest.java 2009-07-20 12:18:58 UTC (rev 1115)
@@ -24,21 +24,10 @@
package org.jboss.dna.test.integration;
import junit.framework.Test;
-import junit.framework.TestSuite;
-import org.jboss.dna.jcr.DnaRepositoryStub;
-import org.jboss.dna.jcr.DnaTckTest;
-import org.jboss.dna.jcr.JcrTckTest;
-public class JBossCacheRepositoryTckTest extends JcrTckTest {
+public class JBossCacheRepositoryTckTest {
- private static final String NAME = "jbosscache";
-
public static Test suite() {
- DnaRepositoryStub.setCurrentConfigurationName(NAME);
- TestSuite suite = new TestSuite("TCK Tests for " + NAME);
- suite.addTest(JcrTckTest.suite());
- suite.addTestSuite(DnaTckTest.class);
-
- return suite;
+ return AbstractRepositoryTckTest.readWriteRepositorySuite("jbosscache");
}
}
Added: trunk/dna-integration-tests/src/test/java/org/jboss/dna/test/integration/JpaRepositoryTckTest.java
===================================================================
--- trunk/dna-integration-tests/src/test/java/org/jboss/dna/test/integration/JpaRepositoryTckTest.java (rev 0)
+++ trunk/dna-integration-tests/src/test/java/org/jboss/dna/test/integration/JpaRepositoryTckTest.java 2009-07-20 12:18:58 UTC (rev 1115)
@@ -0,0 +1,33 @@
+/*
+ * JBoss DNA (http://www.jboss.org/dna)
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ * See the AUTHORS.txt file in the distribution for a full listing of
+ * individual contributors.
+ *
+ * JBoss DNA is free software. Unless otherwise indicated, all code in JBoss DNA
+ * is licensed to you under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * JBoss DNA is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.dna.test.integration;
+
+import junit.framework.Test;
+
+public class JpaRepositoryTckTest {
+
+ public static Test suite() {
+ return AbstractRepositoryTckTest.readWriteRepositorySuite("jpa");
+ }
+}
Property changes on: trunk/dna-integration-tests/src/test/java/org/jboss/dna/test/integration/JpaRepositoryTckTest.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Modified: trunk/dna-integration-tests/src/test/resources/log4j.properties
===================================================================
--- trunk/dna-integration-tests/src/test/resources/log4j.properties 2009-07-17 19:12:26 UTC (rev 1114)
+++ trunk/dna-integration-tests/src/test/resources/log4j.properties 2009-07-20 12:18:58 UTC (rev 1115)
@@ -9,8 +9,11 @@
# Set up the default logging to be INFO level, then override specific units
log4j.logger.org.jboss.dna=INFO
-log4j.logger.org.jboss.dna.tests.integration.jackrabbit.JackrabbitMySqlStressTest=DEBUG
+log4j.logger.org.junit=DEBUG
+# log4j.logger.org.jboss.dna.tests.integration.jackrabbit.JackrabbitMySqlStressTest=DEBUG
+log4j.logger.org.hibernate=WARN, stdout
+
# Jackrabbit logging
log4j.logger.org.apache.jackrabbit=WARN, stdout
log4j.logger.org.apache.derby=INFO, stdout
Added: trunk/dna-integration-tests/src/test/resources/tck/jpa/configRepository.xml
===================================================================
--- trunk/dna-integration-tests/src/test/resources/tck/jpa/configRepository.xml (rev 0)
+++ trunk/dna-integration-tests/src/test/resources/tck/jpa/configRepository.xml 2009-07-20 12:18:58 UTC (rev 1115)
@@ -0,0 +1,98 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ~ 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 distribution; if not, write to:
+ ~ Free Software Foundation, Inc.
+ ~ 51 Franklin Street, Fifth Floor
+ ~ Boston, MA 02110-1301 USA
+ -->
+<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
+ JDBC DataSource objects, except that they expose graph content via the Graph API instead of records via SQL or JDBC.
+ -->
+ <dna:sources jcr:primaryType="nt:unstructured">
+ <!--
+ The 'JCR' repository is a JBoss Cache source with a single default workspace (though others could be created, too).
+ -->
+ <dna:source jcr:name="Store" dna:classname="org.jboss.dna.connector.store.jpa.JpaSource"
+ dna:dialect="org.hibernate.dialect.HSQLDialect"
+ dna:driverClassName="org.hsqldb.jdbcDriver"
+ dna:username="sa"
+ dna:password=""
+ dna:url="jdbc:hsqldb:."
+ dna:maximumConnectionsInPool="1"
+ dna:referentialIntegrityEnforced="true"
+ dna:largeValueSizeInBytes="150"
+ dna:retryLimit="3"
+ dna:compressData="true"
+ dna:predefinedWorkspaceNames="default"
+ dna:showSql="false"
+ dna:defaultWorkspaceName="default"/>
+ </dna:sources>
+ <!--
+ Define the mime type detectors. This is an optional section. By default, each engine will use the
+ MIME type detector that uses filename extensions. So we wouldn't need to define the same detector again,
+ but this is how you'd define another extension.
+ -->
+ <dna:mimeTypeDetectors>
+ <dna:mimeTypeDetector jcr:name="Detector">
+ <dna:description>Standard extension-based MIME type detector</dna:description>
+ <!--
+ Specify the implementation class (required), as a child element or attribute on parent element.
+ -->
+ <dna:classname>org.jboss.dna.graph.mimetype.ExtensionBasedMimeTypeDetector</dna:classname>
+ <!--
+ Specify the classpath (optional) as an ordered list of 'names', where each name is significant to
+ the classpath factory. For example, a name could be an OSGI identifier or a Maven coordinate,
+ depending upon the classpath factory being used. If there is only one 'name' in the classpath,
+ it may be specified as an attribute on the 'mimeTypeDetector' element. If there is more than one
+ 'name', then they must be specified as child 'classpath' elements. Blank or empty values are ignored.
+ -->
+ <dna:classpath></dna:classpath>
+ </dna:mimeTypeDetector>
+ </dna:mimeTypeDetectors>
+ <!--
+ Define the JCR repositories
+ -->
+ <dna:repositories>
+ <!--
+ Define a JCR repository that accesses the 'JCR' source directly.
+ This of course is optional, since we could access the same content through 'JCR'.
+ -->
+ <dna:repository jcr:name="Test Repository Source">
+ <!-- Specify the source that should be used for the repository -->
+ <dna:source>Store</dna:source>
+ <!-- Define the options for the JCR repository, using camelcase version of JcrRepository.Option names
+-->
+ <dna:options jcr:primaryType="dna:options">
+ <jaasLoginConfigName jcr:primaryType="dna:option" dna:value="dna-jcr"/>
+ <projectNodeTypes jcr:primaryType="dna:option" dna:value="false"/>
+ </dna:options>
+ <!-- Define any namespaces for this repository, other than those already defined by JCR or DNA
+-->
+ <namespaces jcr:primaryType="dna:namespaces">
+ <dnatest jcr:primaryType="dna:namespace" dna:uri="http://jboss.org/dna/test/1.0"/>
+ </namespaces>
+ </dna:repository>
+ </dna:repositories>
+</configuration>
Property changes on: trunk/dna-integration-tests/src/test/resources/tck/jpa/configRepository.xml
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Added: trunk/dna-integration-tests/src/test/resources/tck/jpa/repositoryOverlay.properties
===================================================================
--- trunk/dna-integration-tests/src/test/resources/tck/jpa/repositoryOverlay.properties (rev 0)
+++ trunk/dna-integration-tests/src/test/resources/tck/jpa/repositoryOverlay.properties 2009-07-20 12:18:58 UTC (rev 1115)
@@ -0,0 +1 @@
+# Placeholder for any overlaid properties for this repo configuration
Modified: trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/DnaIntLexicon.java
===================================================================
--- trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/DnaIntLexicon.java 2009-07-17 19:12:26 UTC (rev 1114)
+++ trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/DnaIntLexicon.java 2009-07-20 12:18:58 UTC (rev 1115)
@@ -29,13 +29,7 @@
/**
* A lexicon of internal and implementation-specific information
*/
-public class DnaIntLexicon {
-
- public static class Namespace {
- public static final String URI = "http://www.jboss.org/dna/internal/1.0";
- public static final String PREFIX = "dnaint";
- }
-
+public class DnaIntLexicon extends org.jboss.dna.graph.DnaIntLexicon {
public static final Name NODE_DEFINITON = new BasicName(Namespace.URI, "nodeDefinition");
public static final Name MULTI_VALUED_PROPERTIES = new BasicName(Namespace.URI, "multiValuedProperties");
}
Modified: trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/JcrContentHandler.java
===================================================================
--- trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/JcrContentHandler.java 2009-07-17 19:12:26 UTC (rev 1114)
+++ trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/JcrContentHandler.java 2009-07-20 12:18:58 UTC (rev 1115)
@@ -282,7 +282,7 @@
}
private class SystemViewContentHandler extends DefaultHandler {
- private Stack<AbstractJcrNode> parentStack;
+ private final Stack<AbstractJcrNode> parentStack;
private final String svNameName;
private final String svTypeName;
@@ -292,7 +292,7 @@
private int currentPropType;
private StringBuffer valueBuffer;
- private Map<String, List<Value>> currentProps;
+ private final Map<String, List<Value>> currentProps;
/**
* @param currentNode
@@ -346,6 +346,31 @@
if (rawUuid != null) {
assert rawUuid.size() == 1;
uuid = UUID.fromString(rawUuid.get(0).getString());
+
+ try {
+ // Deal with any existing node ...
+ AbstractJcrNode existingNodeWithUuid = cache().findJcrNode(Location.create(uuid));
+ switch (uuidBehavior) {
+ case ImportUUIDBehavior.IMPORT_UUID_COLLISION_REPLACE_EXISTING:
+ parentNode = existingNodeWithUuid.getParent();
+ existingNodeWithUuid.remove();
+ break;
+ case ImportUUIDBehavior.IMPORT_UUID_CREATE_NEW:
+ uuid = UUID.randomUUID();
+ break;
+ case ImportUUIDBehavior.IMPORT_UUID_COLLISION_REMOVE_EXISTING:
+ if (existingNodeWithUuid.path().isAtOrAbove(parentStack.firstElement().path())) {
+ throw new ConstraintViolationException();
+ }
+ existingNodeWithUuid.remove();
+ break;
+ case ImportUUIDBehavior.IMPORT_UUID_COLLISION_THROW:
+ throw new ItemExistsException();
+ }
+ } catch (ItemNotFoundException e) {
+ // there wasn't an existing item, so just continue
+ }
+
}
String typeName = currentProps.get(primaryTypeName).get(0).getString();
@@ -427,7 +452,7 @@
}
private class DocumentViewContentHandler extends DefaultHandler {
- private Stack<AbstractJcrNode> parentStack;
+ private final Stack<AbstractJcrNode> parentStack;
/**
* @param currentNode
Modified: trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/JcrValue.java
===================================================================
--- trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/JcrValue.java 2009-07-17 19:12:26 UTC (rev 1114)
+++ trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/JcrValue.java 2009-07-20 12:18:58 UTC (rev 1115)
@@ -442,6 +442,11 @@
}
}
+ @Override
+ public String toString() {
+ return (value == null ? "null" : value.toString()) + " (" + PropertyType.nameFromValue(type) + ")";
+ }
+
private enum State {
NEVER_CONSUMED,
INPUT_STREAM_CONSUMED,
Modified: trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/SessionCache.java
===================================================================
--- trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/SessionCache.java 2009-07-17 19:12:26 UTC (rev 1114)
+++ trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/SessionCache.java 2009-07-20 12:18:58 UTC (rev 1115)
@@ -139,7 +139,7 @@
protected final Path rootPath;
protected final Name residualName;
- private GraphSession<JcrNodePayload, JcrPropertyPayload> graphSession;
+ private final GraphSession<JcrNodePayload, JcrPropertyPayload> graphSession;
public SessionCache( JcrSession session ) {
this(session, session.workspace().getName(), session.getExecutionContext(), session.nodeTypeManager(), session.graph());
@@ -1320,6 +1320,7 @@
if (JcrMixLexicon.REFERENCEABLE.equals(mixinCandidateType.getInternalName())) {
// This node is now referenceable, so make sure there is a UUID property ...
UUID uuid = node.getLocation().getUuid();
+ if (uuid == null) uuid = (UUID)node.getLocation().getIdProperty(JcrLexicon.UUID).getFirstValue();
if (uuid == null) uuid = UUID.randomUUID();
JcrValue value = new JcrValue(factories(), SessionCache.this, PropertyType.STRING, uuid);
setProperty(JcrLexicon.UUID, value, false);
Modified: trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/DnaRepositoryStub.java
===================================================================
--- trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/DnaRepositoryStub.java 2009-07-17 19:12:26 UTC (rev 1114)
+++ trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/DnaRepositoryStub.java 2009-07-20 12:18:58 UTC (rev 1115)
@@ -43,8 +43,10 @@
private static String currentConfigurationName = "default";
- private final Properties configProps;
- private final JcrRepository repository;
+ private Properties configProps;
+ private String repositoryConfigurationName;
+ private JcrRepository repository;
+
static {
@@ -62,15 +64,21 @@
public DnaRepositoryStub( Properties env ) {
super(env);
+ configureRepository();
+ }
+
+ private void configureRepository() {
+ repositoryConfigurationName = currentConfigurationName;
+
// Create the in-memory (DNA) repository
JcrConfiguration configuration = new JcrConfiguration();
try {
configProps = new Properties();
- String propsFileName = "/tck/" + currentConfigurationName + "/repositoryOverlay.properties";
+ String propsFileName = "/tck/" + repositoryConfigurationName + "/repositoryOverlay.properties";
InputStream propsStream = getClass().getResourceAsStream(propsFileName);
configProps.load(propsStream);
- String configFileName = "/tck/" + currentConfigurationName + "/configRepository.xml";
+ String configFileName = "/tck/" + repositoryConfigurationName + "/configRepository.xml";
configuration.loadFrom(getClass().getResourceAsStream(configFileName));
// Add the the node types for the source ...
@@ -86,8 +94,8 @@
JcrEngine engine = configuration.build();
engine.start();
- // Problems problems = engine.getRepositoryService().getStartupProblems();
- Problems problems = engine.getProblems();
+ Problems problems = engine.getRepositoryService().getStartupProblems();
+ // Problems problems = engine.getProblems();
// Print all of the problems from the engine configuration ...
for (Problem problem : problems) {
System.err.println(problem);
@@ -96,17 +104,11 @@
throw new IllegalStateException("Problems starting JCR repository");
}
- repository = getAndLoadRepository(engine, REPOSITORY_SOURCE_NAME);
- }
-
- private JcrRepository getAndLoadRepository( JcrEngine engine,
- String repositoryName ) {
-
ExecutionContext executionContext = engine.getExecutionContext();
executionContext.getNamespaceRegistry().register(TestLexicon.Namespace.PREFIX, TestLexicon.Namespace.URI);
try {
- JcrRepository repository = engine.getRepository(REPOSITORY_SOURCE_NAME);
+ repository = engine.getRepository(REPOSITORY_SOURCE_NAME);
// Set up some sample nodes in the graph to match the expected test configuration
Graph graph = Graph.create(repository.getRepositorySourceName(),
@@ -118,7 +120,6 @@
graph.importXmlFrom(xmlStream).into(destinationPath);
graph.createWorkspace().named("otherWorkspace");
- return repository;
} catch (Exception ex) {
// The TCK tries to quash this exception. Print it out to be more obvious.
@@ -126,6 +127,7 @@
throw new IllegalStateException("Failed to initialize the repository with text content.", ex);
}
+
}
public static void setCurrentConfigurationName( String newConfigName ) {
@@ -139,6 +141,9 @@
*/
@Override
public JcrRepository getRepository() {
+ if (!currentConfigurationName.equals(repositoryConfigurationName)) {
+ configureRepository();
+ }
return repository;
}
Modified: trunk/dna-jcr/src/test/resources/repositoryStubImpl.properties
===================================================================
--- trunk/dna-jcr/src/test/resources/repositoryStubImpl.properties 2009-07-17 19:12:26 UTC (rev 1114)
+++ trunk/dna-jcr/src/test/resources/repositoryStubImpl.properties 2009-07-20 12:18:58 UTC (rev 1115)
@@ -14,7 +14,8 @@
javax.jcr.tck.targetFolderName=target
javax.jcr.tck.rootNodeName=rootNode
javax.jcr.tck.propertySkipped=propertySkipped
-javax.jcr.tck.propertyValueMayChange=propertyValueMayChange
+# The spaces on either side of this property are important - DO NOT DELETE THEM
+javax.jcr.tck.propertyValueMayChange= jcr:uuid
javax.jcr.tck.nodeTypesTestNode=nodeTypesTestNode
javax.jcr.tck.mixinTypeTestNode=mixinTypeTestNode
javax.jcr.tck.propertyTypesTestNode=propertyTypesTestNode
Modified: trunk/extensions/dna-connector-store-jpa/src/main/java/org/jboss/dna/connector/store/jpa/JpaSource.java
===================================================================
--- trunk/extensions/dna-connector-store-jpa/src/main/java/org/jboss/dna/connector/store/jpa/JpaSource.java 2009-07-17 19:12:26 UTC (rev 1114)
+++ trunk/extensions/dna-connector-store-jpa/src/main/java/org/jboss/dna/connector/store/jpa/JpaSource.java 2009-07-20 12:18:58 UTC (rev 1115)
@@ -142,6 +142,10 @@
*/
public static final boolean DEFAULT_SUPPORTS_UPDATES = true;
/**
+ * This source does not output executed SQL by default, but this can be overridden by calling {@link #setShowSql(boolean)}.
+ */
+ public static final boolean DEFAULT_SHOW_SQL = false;
+ /**
* This source does support creating workspaces.
*/
public static final boolean DEFAULT_SUPPORTS_CREATING_WORKSPACES = true;
@@ -152,7 +156,7 @@
public static final String DEFAULT_ROOT_NODE_UUID = "1497b6fe-8c7e-4bbb-aaa2-24f3d4942668";
/**
- * The initial {@link #getNameOfDefaultWorkspace() name of the default workspace} is "{@value} ", unless otherwise specified.
+ * The initial {@link #getDefaultWorkspaceName() name of the default workspace} is "{@value} ", unless otherwise specified.
*/
public static final String DEFAULT_NAME_OF_DEFAULT_WORKSPACE = "default";
@@ -192,6 +196,7 @@
private volatile int retryLimit = DEFAULT_RETRY_LIMIT;
private volatile int cacheTimeToLiveInMilliseconds = DEFAULT_CACHE_TIME_TO_LIVE_IN_SECONDS * 1000;
private volatile long largeValueSizeInBytes = DEFAULT_LARGE_VALUE_SIZE_IN_BYTES;
+ private volatile boolean showSql = DEFAULT_SHOW_SQL;
private volatile boolean compressData = DEFAULT_COMPRESS_DATA;
private volatile boolean referentialIntegrityEnforced = DEFAULT_ENFORCE_REFERENTIAL_INTEGRITY;
private volatile String defaultWorkspace = DEFAULT_NAME_OF_DEFAULT_WORKSPACE;
@@ -263,6 +268,24 @@
}
/**
+ * Get whether this source outputs the SQL that it executes
+ *
+ * @return whether this source outputs the SQL that it executes
+ */
+ public boolean getShowSql() {
+ return this.showSql;
+ }
+
+ /**
+ * Sets whether this source should output the SQL that it executes
+ *
+ * @param showSql true if this source should output the SQL that it executes, otherwise false
+ */
+ public synchronized void setShowSql( boolean showSql ) {
+ this.showSql = showSql;
+ }
+
+ /**
* {@inheritDoc}
*
* @see org.jboss.dna.graph.connector.RepositorySource#getRetryLimit()
@@ -324,7 +347,7 @@
*
* @return the name of the workspace that should be used by default, or null if there is no default workspace
*/
- public String getNameOfDefaultWorkspace() {
+ public String getDefaultWorkspaceName() {
return defaultWorkspace;
}
@@ -334,7 +357,7 @@
* @param nameOfDefaultWorkspace the name of the workspace that should be used by default, or null if the
* {@link #DEFAULT_NAME_OF_DEFAULT_WORKSPACE default name} should be used
*/
- public synchronized void setNameOfDefaultWorkspace( String nameOfDefaultWorkspace ) {
+ public synchronized void setDefaultWorkspaceName( String nameOfDefaultWorkspace ) {
this.defaultWorkspace = nameOfDefaultWorkspace != null ? nameOfDefaultWorkspace : DEFAULT_NAME_OF_DEFAULT_WORKSPACE;
}
@@ -733,7 +756,7 @@
ref.add(new StringRefAddr(LARGE_VALUE_SIZE_IN_BYTES, Long.toString(getLargeValueSizeInBytes())));
ref.add(new StringRefAddr(COMPRESS_DATA, Boolean.toString(isCompressData())));
ref.add(new StringRefAddr(ENFORCE_REFERENTIAL_INTEGRITY, Boolean.toString(isReferentialIntegrityEnforced())));
- ref.add(new StringRefAddr(DEFAULT_WORKSPACE, getNameOfDefaultWorkspace()));
+ ref.add(new StringRefAddr(DEFAULT_WORKSPACE, getDefaultWorkspaceName()));
ref.add(new StringRefAddr(ALLOW_CREATING_WORKSPACES, Boolean.toString(isCreatingWorkspacesAllowed())));
String[] workspaceNames = getPredefinedWorkspaceNames();
if (workspaceNames != null && workspaceNames.length != 0) {
@@ -819,7 +842,7 @@
if (largeModelSize != null) source.setLargeValueSizeInBytes(Long.parseLong(largeModelSize));
if (compressData != null) source.setCompressData(Boolean.parseBoolean(compressData));
if (refIntegrity != null) source.setReferentialIntegrityEnforced(Boolean.parseBoolean(refIntegrity));
- if (defaultWorkspace != null) source.setNameOfDefaultWorkspace(defaultWorkspace);
+ if (defaultWorkspace != null) source.setDefaultWorkspaceName(defaultWorkspace);
if (createWorkspaces != null) source.setCreatingWorkspacesAllowed(Boolean.parseBoolean(createWorkspaces));
if (workspaceNames != null && workspaceNames.length != 0) source.setPredefinedWorkspaceNames(workspaceNames);
return source;
@@ -886,7 +909,7 @@
setProperty(configurator, "hibernate.connection.url", this.url);
setProperty(configurator, "hibernate.connection.max_fetch_depth", DEFAULT_MAXIMUM_FETCH_DEPTH);
setProperty(configurator, "hibernate.connection.pool_size", 0); // don't use the built-in pool
- setProperty(configurator, "hibernate.show_sql", "false");
+ setProperty(configurator, "hibernate.show_sql", String.valueOf(this.showSql));
}
entityManagerFactory = configurator.buildEntityManagerFactory();
Modified: trunk/extensions/dna-connector-store-jpa/src/main/java/org/jboss/dna/connector/store/jpa/model/basic/BasicRequestProcessor.java
===================================================================
--- trunk/extensions/dna-connector-store-jpa/src/main/java/org/jboss/dna/connector/store/jpa/model/basic/BasicRequestProcessor.java 2009-07-17 19:12:26 UTC (rev 1114)
+++ trunk/extensions/dna-connector-store-jpa/src/main/java/org/jboss/dna/connector/store/jpa/model/basic/BasicRequestProcessor.java 2009-07-20 12:18:58 UTC (rev 1115)
@@ -76,6 +76,7 @@
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.PropertyFactory;
import org.jboss.dna.graph.property.PropertyType;
import org.jboss.dna.graph.property.Reference;
import org.jboss.dna.graph.property.ReferentialIntegrityException;
@@ -116,6 +117,7 @@
protected final EntityManager entities;
protected final ValueFactory<String> stringFactory;
protected final PathFactory pathFactory;
+ protected final PropertyFactory propertyFactory;
protected final NameFactory nameFactory;
protected final UuidFactory uuidFactory;
protected final Namespaces namespaces;
@@ -138,7 +140,7 @@
REPLACE_EXISTING_NODE,
THROW_EXCEPTION
}
-
+
/**
* @param sourceName
* @param context
@@ -171,6 +173,7 @@
ValueFactories valuesFactory = context.getValueFactories();
this.stringFactory = valuesFactory.getStringFactory();
this.pathFactory = valuesFactory.getPathFactory();
+ this.propertyFactory = context.getPropertyFactory();
this.nameFactory = valuesFactory.getNameFactory();
this.uuidFactory = valuesFactory.getUuidFactory();
this.namespaces = new Namespaces(entityManager);
@@ -460,7 +463,9 @@
actualLocation = actual.location;
// Record the UUID as a property, since it's not stored in the serialized properties...
- request.addProperty(actualLocation.getIdProperty(DnaLexicon.UUID));
+ // This gets pulled from the actual location uuid instead of the property to avoid the
+ // having to add the dna:uuid onto locations that already have a jcr:uuid
+ request.addProperty(propertyFactory.create(DnaLexicon.UUID, UUID.fromString(parentUuidString)));
// Find the properties entity for this node ...
Query query = entities.createNamedQuery("PropertiesEntity.findByUuid");
@@ -828,7 +833,7 @@
// Small optimization ...
final Name propertyName = request.named();
- if (DnaLexicon.UUID.equals(propertyName)) {
+ if (DnaLexicon.UUID.equals(propertyName) || JcrLexicon.UUID.equals(propertyName)) {
try {
// Just get the UUID ...
Location location = request.on();
@@ -918,8 +923,16 @@
boolean compressed = entity.isCompressed();
byte[] originalData = entity.getData();
ByteArrayOutputStream baos = new ByteArrayOutputStream();
- OutputStream os = compressed ? new GZIPOutputStream(baos) : baos;
- ObjectOutputStream oos = new ObjectOutputStream(os);
+ ObjectOutputStream oos;
+ GZIPOutputStream gos = null;
+ if (compressed) {
+ gos = new GZIPOutputStream(baos);
+ oos = new ObjectOutputStream(gos);
+ } else {
+ oos = new ObjectOutputStream(baos);
+ }
+ // OutputStream os = compressed ? new GZIPOutputStream(baos) : baos;
+ // oos = new ObjectOutputStream(os);
int numProps = 0;
LargeValueSerializer largeValues = null;
Map<Name, Property> props = request.properties();
@@ -928,6 +941,7 @@
largeValues = new LargeValueSerializer(entity);
numProps = props.size();
serializer.serializeProperties(oos, numProps, props.values(), largeValues, refs);
+ if (gos != null) gos.finish();
} else {
boolean hadLargeValues = !entity.getLargeValues().isEmpty();
Set<String> largeValueHashesWritten = hadLargeValues ? new HashSet<String>() : null;
@@ -939,6 +953,7 @@
try {
Serializer.ReferenceValues refValues = refs != null ? refs : Serializer.NO_REFERENCES_VALUES;
numProps = serializer.reserializeProperties(ois, oos, props, largeValues, removedValues, refValues);
+ if (gos != null) gos.finish();
} finally {
try {
ois.close();
@@ -946,6 +961,7 @@
oos.close();
}
}
+
// The new large values were recorded and associated with the properties entity during reserialization.
// However, any values no longer used now need to be removed ...
if (hadLargeValues) {
@@ -1806,12 +1822,232 @@
}
}
+ private Location moveNodeToLastChild( WorkspaceEntity workspace,
+ ActualLocation actualFromLocation,
+ ActualLocation actualIntoLocation,
+ Name desiredName ) {
+ long workspaceId = workspace.getId();
+ Path oldPath = actualFromLocation.location.getPath();
+
+ ChildEntity fromEntity = actualFromLocation.childEntity;
+
+ // Now we know that the new parent is not the existing parent ...
+ final int oldIndex = fromEntity.getIndexInParent();
+ final String oldParentUuid = fromEntity.getParentUuidString();
+
+ String toUuidString = actualIntoLocation.uuid;
+
+ // Make sure the child name is set correctly ...
+ String childOldLocalName = fromEntity.getChildName();
+ String childLocalName = null;
+ NamespaceEntity ns = null;
+ Name childName = desiredName;
+ if (childName != null) {
+ childLocalName = desiredName.getLocalName();
+ String childNsUri = childName.getNamespaceUri();
+ ns = namespaces.get(childNsUri, true);
+ } else {
+ childName = oldPath.getLastSegment().getName();
+ childLocalName = fromEntity.getChildName();
+ ns = fromEntity.getChildNamespace();
+ }
+
+ int nextSnsIndex = 1;
+ int nextIndexInParent = 1;
+
+ // Find the largest SNS index in the existing ChildEntity objects with the same name ...
+ Query query = entities.createNamedQuery("ChildEntity.findMaximumSnsIndex");
+ query.setParameter("workspaceId", workspaceId);
+ query.setParameter("parentUuid", toUuidString);
+ query.setParameter("ns", ns.getId());
+ query.setParameter("childName", childLocalName);
+ try {
+ Integer index = (Integer)query.getSingleResult();
+ if (index != null) nextSnsIndex = index.intValue() + 1;
+ } catch (NoResultException e) {
+ }
+
+ // Find the largest child index in the existing ChildEntity objects ...
+ query = entities.createNamedQuery("ChildEntity.findMaximumChildIndex");
+ query.setParameter("workspaceId", workspaceId);
+ query.setParameter("parentUuid", toUuidString);
+ try {
+ Integer index = (Integer)query.getSingleResult();
+ if (index != null) nextIndexInParent = index + 1;
+ } catch (NoResultException e) {
+ }
+
+ fromEntity.setParentUuidString(toUuidString);
+ fromEntity.setChildName(childLocalName);
+ fromEntity.setChildNamespace(ns);
+ fromEntity.setIndexInParent(nextIndexInParent);
+ fromEntity.setSameNameSiblingIndex(nextSnsIndex);
+
+ // Flush the entities to the database ...
+ entities.flush();
+
+ // Determine the new location ...
+ Path newParentPath = actualIntoLocation.location.getPath();
+ Path newPath = pathFactory.create(newParentPath, childName, nextSnsIndex);
+ Location newLocation = actualFromLocation.location.with(newPath);
+
+ // And adjust the SNS index and indexes ...
+ ChildEntity.adjustSnsIndexesAndIndexesAfterRemoving(entities,
+ workspaceId,
+ oldParentUuid,
+ childOldLocalName,
+ ns.getId(),
+ oldIndex);
+
+ // Update the cache ...
+ cache.moveNode(workspaceId, actualFromLocation.location, oldIndex, newLocation);
+
+ return newLocation;
+ }
+
+ @SuppressWarnings( "unchecked" )
+ private Location moveNodeBefore( WorkspaceEntity workspace,
+ ActualLocation actualFromLocation,
+ ActualLocation actualIntoLocation,
+ ActualLocation actualBeforeLocation ) {
+
+ long workspaceId = workspace.getId();
+
+ ChildEntity fromEntity = actualFromLocation.childEntity;
+ assert fromEntity != null;
+
+ Path oldPath = actualFromLocation.location.getPath();
+ String oldParentUuid = fromEntity.getParentUuidString();
+
+ String toUuidString = actualIntoLocation.uuid;
+ Location beforeLocation = actualBeforeLocation.location;
+ ChildEntity beforeEntity = actualBeforeLocation.childEntity;
+
+ /*
+ * getActualLocation (which populates actualBeforeLocation) can return null for the childEntity
+ * if the location was retrieved from the cache. Since we need the beforeEntity, try to force the load.
+ */
+ if (beforeEntity == null) {
+ beforeEntity = findNode(workspaceId, actualBeforeLocation.uuid);
+ }
+
+ assert beforeEntity != null;
+
+ Name childName = oldPath.getLastSegment().getName();
+ String childLocalName = fromEntity.getChildName();
+ NamespaceEntity ns = fromEntity.getChildNamespace();
+
+ boolean sameParent = oldParentUuid.equals(toUuidString);
+
+ if (sameParent) {
+ int oldIndex;
+ if (fromEntity.getIndexInParent() < beforeEntity.getIndexInParent()) {
+ oldIndex = beforeEntity.getIndexInParent();
+
+ int snsCount = ChildEntity.adjustSnsIndexesAndIndexes(entities,
+ workspaceId,
+ fromEntity.getParentUuidString(),
+ fromEntity.getIndexInParent(),
+ beforeEntity.getIndexInParent(),
+ fromEntity.getChildNamespace().getId(),
+ fromEntity.getChildName(),
+ -1);
+
+ fromEntity.setIndexInParent(oldIndex);
+ fromEntity.setSameNameSiblingIndex(fromEntity.getSameNameSiblingIndex() + snsCount);
+ } else {
+ oldIndex = beforeEntity.getIndexInParent();
+
+ int snsCount = ChildEntity.adjustSnsIndexesAndIndexes(entities,
+ workspaceId,
+ fromEntity.getParentUuidString(),
+ beforeEntity.getIndexInParent() - 1,
+ fromEntity.getIndexInParent() - 1,
+ fromEntity.getChildNamespace().getId(),
+ fromEntity.getChildName(),
+ +1);
+
+ fromEntity.setIndexInParent(oldIndex);
+ fromEntity.setSameNameSiblingIndex(fromEntity.getSameNameSiblingIndex() - snsCount);
+
+ }
+
+ Path newPath = pathFactory.create(oldPath.getParent(),
+ pathFactory.createSegment(fromEntity.getChildName(),
+ fromEntity.getSameNameSiblingIndex()));
+ return actualFromLocation.location.with(newPath);
+ }
+
+ int oldIndex = fromEntity.getIndexInParent();
+
+ /*
+ * This is a sub-optimal approach, particularly for inserts to the front
+ * of a long list of child nodes, but it guarantees that we won't have
+ * the JPA-cached entities and the database out of sync.
+ */
+
+ Query query = entities.createNamedQuery("ChildEntity.findAllUnderParent");
+ query.setParameter("workspaceId", workspaceId);
+ query.setParameter("parentUuidString", toUuidString);
+
+ int nextIndexInParent = 0;
+ int nextSnsIndex = 1;
+ try {
+ List<ChildEntity> children = query.getResultList();
+ Path beforePath = beforeLocation.getPath();
+ Path.Segment beforeSegment = beforePath.getLastSegment();
+
+ boolean foundBefore = false;
+ for (ChildEntity child : children) {
+ NamespaceEntity namespace = child.getChildNamespace();
+ if (namespace.getUri().equals(ns.getUri()) && child.getChildName().equals(childLocalName)
+ && child.getSameNameSiblingIndex() == beforeSegment.getIndex()) {
+ foundBefore = true;
+ nextIndexInParent = child.getIndexInParent();
+ nextSnsIndex = beforeSegment.getIndex();
+ }
+
+ if (foundBefore) {
+ child.setIndexInParent(child.getIndexInParent() + 1);
+ if (child.getChildName().equals(childLocalName) && namespace.getUri().equals(ns.getUri())) {
+ child.setSameNameSiblingIndex(child.getSameNameSiblingIndex() + 1);
+ }
+ entities.persist(child);
+ }
+ }
+
+ } catch (NoResultException e) {
+ }
+
+ fromEntity.setParentUuidString(toUuidString);
+ fromEntity.setChildName(childLocalName);
+ fromEntity.setChildNamespace(ns);
+ fromEntity.setIndexInParent(nextIndexInParent);
+ fromEntity.setSameNameSiblingIndex(nextSnsIndex);
+
+ // Flush the entities to the database ...
+ entities.flush();
+
+ // Determine the new location ...
+ Path newParentPath = actualIntoLocation.location.getPath();
+ Path newPath = pathFactory.create(newParentPath, childName, nextSnsIndex);
+ Location oldLocation = actualFromLocation.location;
+ Location newLocation = oldLocation.with(newPath);
+
+ // And adjust the SNS index and indexes ...
+ ChildEntity.adjustSnsIndexesAndIndexesAfterRemoving(entities, workspaceId, oldParentUuid, childLocalName, ns.getId(), -1);
+
+ // Update the cache ...
+ cache.moveNode(workspaceId, oldLocation, oldIndex, newLocation);
+
+ return newLocation;
+ }
+
/**
* {@inheritDoc}
*
* @see org.jboss.dna.graph.request.processor.RequestProcessor#process(org.jboss.dna.graph.request.MoveBranchRequest)
*/
- @SuppressWarnings( "unchecked" )
@Override
public void process( MoveBranchRequest request ) {
logger.trace(request.toString());
@@ -1835,143 +2071,25 @@
throw new InvalidRequestException(msg);
}
- // Find the ChildEntity of the existing 'from' node ...
- ChildEntity fromEntity = actualLocation.childEntity;
- final String oldParentUuid = fromEntity.getParentUuidString();
-
- // Find the actual new location ...
- Location toLocation = request.into();
- Location beforeLocation = request.before();
-
- if (beforeLocation != null) {
- if (beforeLocation.hasPath()) {
- toLocation = Location.create(beforeLocation.getPath().getParent());
- } else {
- ActualLocation actualBeforeLocation = getActualLocation(workspace, beforeLocation);
-
- // Ensure that the beforeLocation has a path - actualBeforeLocation has a path
- beforeLocation = actualBeforeLocation.location;
- toLocation = Location.create(actualBeforeLocation.location.getPath().getParent());
- }
- }
-
- String toUuidString = null;
if (request.hasNoEffect()) {
actualNewLocation = actualOldLocation;
} else {
// We have to proceed as normal ...
- ActualLocation actualIntoLocation = getActualLocation(workspace, toLocation);
- toUuidString = actualIntoLocation.uuid;
- if (!toUuidString.equals(oldParentUuid)) {
- // Now we know that the new parent is not the existing parent ...
- final int oldIndex = fromEntity.getIndexInParent();
- // Make sure the child name is set correctly ...
- String childOldLocalName = fromEntity.getChildName();
- String childLocalName = null;
- NamespaceEntity ns = null;
- Name childName = request.desiredName();
- if (childName != null) {
- childLocalName = request.desiredName().getLocalName();
- String childNsUri = childName.getNamespaceUri();
- ns = namespaces.get(childNsUri, true);
- } else {
- childName = oldPath.getLastSegment().getName();
- childLocalName = fromEntity.getChildName();
- ns = fromEntity.getChildNamespace();
- }
+ Location beforeLocation = request.before();
+ if (beforeLocation == null) {
+ ActualLocation actualIntoLocation = getActualLocation(workspace, request.into());
- int nextSnsIndex = 1;
- int nextIndexInParent = 1;
- if (beforeLocation == null) {
- // Find the largest SNS index in the existing ChildEntity objects with the same name ...
- Query query = entities.createNamedQuery("ChildEntity.findMaximumSnsIndex");
- query.setParameter("workspaceId", workspaceId);
- query.setParameter("parentUuid", toUuidString);
- query.setParameter("ns", ns.getId());
- query.setParameter("childName", childLocalName);
- try {
- Integer index = (Integer)query.getSingleResult();
- if (index != null) nextSnsIndex = index.intValue() + 1;
- } catch (NoResultException e) {
- }
+ actualNewLocation = moveNodeToLastChild(workspace, actualLocation, actualIntoLocation, request.desiredName());
+ } else {
- // Find the largest child index in the existing ChildEntity objects ...
- query = entities.createNamedQuery("ChildEntity.findMaximumChildIndex");
- query.setParameter("workspaceId", workspaceId);
- query.setParameter("parentUuid", toUuidString);
- try {
- Integer index = (Integer)query.getSingleResult();
- if (index != null) nextIndexInParent = index + 1;
- } catch (NoResultException e) {
- }
- } else {
- /*
- * This is a sub-optimal approach, particularly for inserts to the front
- * of a long list of child nodes, but it guarantees that we won't have
- * the JPA-cached entities and the database out of sync.
- */
+ ActualLocation actualBeforeLocation = getActualLocation(workspace, beforeLocation);
+ ActualLocation actualIntoLocation = getActualLocation(workspace,
+ Location.create(beforeLocation.getPath().getParent()));
- Query query = entities.createNamedQuery("ChildEntity.findAllUnderParent");
- query.setParameter("workspaceId", workspaceId);
- query.setParameter("parentUuidString", toUuidString);
- try {
- List<ChildEntity> children = query.getResultList();
- Path beforePath = beforeLocation.getPath();
- Path.Segment beforeSegment = beforePath.getLastSegment();
-
- boolean foundBefore = false;
- for (ChildEntity child : children) {
- NamespaceEntity namespace = child.getChildNamespace();
- if (namespace.getUri().equals(ns.getUri()) && child.getChildName().equals(childLocalName)
- && child.getSameNameSiblingIndex() == beforeSegment.getIndex()) {
- foundBefore = true;
- nextIndexInParent = child.getIndexInParent();
- nextSnsIndex = beforeSegment.getIndex();
- }
-
- if (foundBefore) {
- child.setIndexInParent(child.getIndexInParent() + 1);
- if (child.getChildName().equals(childLocalName) && namespace.getUri().equals(ns.getUri())) {
- child.setSameNameSiblingIndex(child.getSameNameSiblingIndex() + 1);
- }
- entities.persist(child);
- }
- }
-
- } catch (NoResultException e) {
- }
-
- }
-
- fromEntity.setParentUuidString(toUuidString);
- fromEntity.setChildName(childLocalName);
- fromEntity.setChildNamespace(ns);
- fromEntity.setIndexInParent(nextIndexInParent);
- fromEntity.setSameNameSiblingIndex(nextSnsIndex);
-
- // Flush the entities to the database ...
- entities.flush();
-
- // Determine the new location ...
- Path newParentPath = actualIntoLocation.location.getPath();
- Path newPath = pathFactory.create(newParentPath, childName, nextSnsIndex);
- actualNewLocation = actualOldLocation.with(newPath);
-
- // And adjust the SNS index and indexes ...
- ChildEntity.adjustSnsIndexesAndIndexesAfterRemoving(entities,
- workspaceId,
- oldParentUuid,
- childOldLocalName,
- ns.getId(),
- oldIndex);
-
- // Update the cache ...
- cache.moveNode(workspaceId, actualOldLocation, oldIndex, actualNewLocation);
+ actualNewLocation = moveNodeBefore(workspace, actualLocation, actualIntoLocation, actualBeforeLocation);
}
-
}
-
} catch (Throwable e) { // Includes PathNotFoundException
System.err.flush();
System.out.flush();
@@ -2311,7 +2429,7 @@
props.setData(baos.toByteArray());
props.setPropertyCount(numProperties);
-
+
// Record the changes to the references ...
if (refs != null && refs.hasWritten()) {
for (Reference reference : refs.getWritten()) {
@@ -2402,7 +2520,7 @@
// See if the location is already in the cache ...
Location cached = cache.getLocationFor(workspaceId, path);
if (cached != null) {
- return new ActualLocation(cached, cached.getUuid().toString(), null);
+ return new ActualLocation(original, cached.getUuid().toString(), null);
}
}
@@ -2437,7 +2555,7 @@
}
}
Path fullPath = pathFactory.createAbsolutePath(segments);
- Location newLocation = Location.create(fullPath, uuidProperty);
+ Location newLocation = original.with(fullPath);
cache.addNewNode(workspaceId, newLocation);
return new ActualLocation(newLocation, nodeUuidString, originalEntity);
}
@@ -2460,10 +2578,17 @@
if (cachedParent != null) {
// We know the UUID of the parent, so we can find the child a little faster ...
ChildEntity child = findByPathSegment(workspaceId, cachedParent.getUuid().toString(), path.getLastSegment());
+
+ // If there is no matching child, throw an exception
+ if (child == null) {
+ // Could not find the node given the supplied path, so find the lowest path that does exist ...
+ throw new PathNotFoundException(original, cachedParent.getPath(), JpaConnectorI18n.nodeDoesNotExist.text(path));
+ }
+
uuidString = child.getId().getChildUuidString();
Location newLocation = original.with(UUID.fromString(uuidString));
cache.addNewNode(workspaceId, newLocation);
- return new ActualLocation(newLocation, uuidString, child);
+ return new ActualLocation(original, uuidString, child);
}
// We couldn't find the parent, so we need to search by path ...
@@ -2489,6 +2614,18 @@
return new ActualLocation(newLocation, uuidString, child);
}
+ protected ChildEntity findNode( long workspaceId, String uuidString) {
+ Query query = entities.createNamedQuery("ChildEntity.findByChildUuid");
+ query.setParameter("workspaceId", workspaceId);
+ query.setParameter("childUuidString", uuidString);
+ try {
+ // Find the parent of the UUID ...
+ return (ChildEntity)query.getSingleResult();
+ } catch (NoResultException e) {
+ return null;
+ }
+ }
+
/**
* Find the node with the supplied path segment that is a child of the supplied parent.
*
Modified: trunk/extensions/dna-connector-store-jpa/src/main/java/org/jboss/dna/connector/store/jpa/model/basic/ChildEntity.java
===================================================================
--- trunk/extensions/dna-connector-store-jpa/src/main/java/org/jboss/dna/connector/store/jpa/model/basic/ChildEntity.java 2009-07-17 19:12:26 UTC (rev 1114)
+++ trunk/extensions/dna-connector-store-jpa/src/main/java/org/jboss/dna/connector/store/jpa/model/basic/ChildEntity.java 2009-07-20 12:18:58 UTC (rev 1115)
@@ -310,4 +310,38 @@
}
}
+ @SuppressWarnings( "unchecked" )
+ public static int adjustSnsIndexesAndIndexes( EntityManager entities,
+ Long workspaceId,
+ String uuidParent,
+ int afterIndex,
+ int untilIndex,
+ long childNamespaceIndex,
+ String childName,
+ int modifier ) {
+ int snsCount = 0;
+
+ // Decrement the 'indexInParent' index values for all nodes above the previously removed sibling ...
+ Query query = entities.createNamedQuery("ChildEntity.findChildrenAfterIndexUnderParent");
+ query.setParameter("workspaceId", workspaceId);
+ query.setParameter("parentUuidString", uuidParent);
+ query.setParameter("afterIndex", afterIndex);
+
+ int index = afterIndex;
+ for (ChildEntity entity : (List<ChildEntity>)query.getResultList()) {
+ if (++index > untilIndex) {
+ break;
+ }
+
+ // Decrement the index in parent ...
+ entity.setIndexInParent(entity.getIndexInParent() + modifier);
+ if (entity.getChildName().equals(childName) && entity.getChildNamespace().getId() == childNamespaceIndex) {
+ // The name matches, so decrement the SNS index ...
+ entity.setSameNameSiblingIndex(entity.getSameNameSiblingIndex() + modifier);
+ snsCount++;
+ }
+ }
+
+ return snsCount;
+ }
}
Modified: trunk/extensions/dna-connector-store-jpa/src/main/java/org/jboss/dna/connector/store/jpa/util/Serializer.java
===================================================================
--- trunk/extensions/dna-connector-store-jpa/src/main/java/org/jboss/dna/connector/store/jpa/util/Serializer.java 2009-07-17 19:12:26 UTC (rev 1114)
+++ trunk/extensions/dna-connector-store-jpa/src/main/java/org/jboss/dna/connector/store/jpa/util/Serializer.java 2009-07-20 12:18:58 UTC (rev 1115)
@@ -217,7 +217,7 @@
final Name name = property.getName();
if (this.excludeUuidProperty && DnaLexicon.UUID.equals(name)) return false;
// Write the name ...
- stream.writeObject(name.getString());
+ stream.writeObject(name.getString(Path.NO_OP_ENCODER));
// Write the number of values ...
stream.writeInt(property.size());
for (Object value : property) {
@@ -277,7 +277,7 @@
}
} else if (value instanceof Name) {
stream.writeChar('N');
- stream.writeObject(((Name)value).getString());
+ stream.writeObject(((Name)value).getString(Path.NO_OP_ENCODER));
} else if (value instanceof Path) {
stream.writeChar('P');
stream.writeObject(((Path)value).getString());
Modified: trunk/extensions/dna-connector-store-jpa/src/test/java/org/jboss/dna/connector/store/jpa/JpaConnectorWritingTest.java
===================================================================
--- trunk/extensions/dna-connector-store-jpa/src/test/java/org/jboss/dna/connector/store/jpa/JpaConnectorWritingTest.java 2009-07-17 19:12:26 UTC (rev 1114)
+++ trunk/extensions/dna-connector-store-jpa/src/test/java/org/jboss/dna/connector/store/jpa/JpaConnectorWritingTest.java 2009-07-20 12:18:58 UTC (rev 1115)
@@ -57,6 +57,7 @@
source.setMaximumConnectionIdleTimeInSeconds(0);
source.setReferentialIntegrityEnforced(true);
source.setLargeValueSizeInBytes(150);
+ source.setCompressData(true);
return source;
}
Modified: trunk/extensions/dna-connector-store-jpa/src/test/java/org/jboss/dna/connector/store/jpa/JpaSourceTest.java
===================================================================
--- trunk/extensions/dna-connector-store-jpa/src/test/java/org/jboss/dna/connector/store/jpa/JpaSourceTest.java 2009-07-17 19:12:26 UTC (rev 1114)
+++ trunk/extensions/dna-connector-store-jpa/src/test/java/org/jboss/dna/connector/store/jpa/JpaSourceTest.java 2009-07-20 12:18:58 UTC (rev 1115)
@@ -58,7 +58,7 @@
this.source.setNumberOfConnectionsToAcquireAsNeeded(1);
this.source.setMaximumSizeOfStatementCache(100);
this.source.setMaximumConnectionIdleTimeInSeconds(0);
- this.source.setNameOfDefaultWorkspace("default");
+ this.source.setDefaultWorkspaceName("default");
this.source.setCreatingWorkspacesAllowed(true);
}
16 years, 9 months
DNA SVN: r1114 - in branches/eclipse/dna-web-jcr-rest-client/src: main/java/org/jboss/dna/web/jcr/rest/client/domain and 3 other directories.
by dna-commits@lists.jboss.org
Author: elvisisking
Date: 2009-07-17 15:12:26 -0400 (Fri, 17 Jul 2009)
New Revision: 1114
Added:
branches/eclipse/dna-web-jcr-rest-client/src/test/java/org/jboss/dna/web/jcr/rest/client/MockRestExecutor.java
branches/eclipse/dna-web-jcr-rest-client/src/test/java/org/jboss/dna/web/jcr/rest/client/ServerManagerTest.java
branches/eclipse/dna-web-jcr-rest-client/src/test/java/org/jboss/dna/web/jcr/rest/client/StatusTest.java
branches/eclipse/dna-web-jcr-rest-client/src/test/java/org/jboss/dna/web/jcr/rest/client/domain/
branches/eclipse/dna-web-jcr-rest-client/src/test/java/org/jboss/dna/web/jcr/rest/client/domain/RepositoryTest.java
branches/eclipse/dna-web-jcr-rest-client/src/test/java/org/jboss/dna/web/jcr/rest/client/domain/ServerTest.java
branches/eclipse/dna-web-jcr-rest-client/src/test/java/org/jboss/dna/web/jcr/rest/client/domain/WorkspaceTest.java
Modified:
branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/IMessages.java
branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/ServerManager.java
branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/ServerRegistryEvent.java
branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/Status.java
branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/domain/Server.java
branches/eclipse/dna-web-jcr-rest-client/src/main/resources/org/jboss/dna/web/jcr/rest/client/Messages.properties
Log:
Added some tests. Added the concept of a key to the Server domain object which caused a changed to the ServerManager.
Modified: branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/IMessages.java
===================================================================
--- branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/IMessages.java 2009-07-15 20:02:43 UTC (rev 1113)
+++ branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/IMessages.java 2009-07-17 19:12:26 UTC (rev 1114)
@@ -67,6 +67,8 @@
String ServerManagerRegistryUpdateRemoveError = "ServerManagerRegistryUpdateRemoveError"; //$NON-NLS-1$
+ String ServerManagerUnregisteredServer = "ServerManagerUnregisteredServer"; //$NON-NLS-1$
+
String ServerShortDescription = "ServerShortDescription"; //$NON-NLS-1$
String WorkspaceEmptyNameMsg = "WorkspaceEmptyNameMsg"; //$NON-NLS-1$
Modified: branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/ServerManager.java
===================================================================
--- branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/ServerManager.java 2009-07-15 20:02:43 UTC (rev 1113)
+++ branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/ServerManager.java 2009-07-17 19:12:26 UTC (rev 1114)
@@ -119,6 +119,11 @@
*/
private final CopyOnWriteArrayList<IServerRegistryListener> listeners;
+ /**
+ * Executes the commands run on the DNA REST server.
+ *
+ * @since 0.6
+ */
private final IRestExecutor restExecutor;
/**
@@ -217,14 +222,23 @@
/**
* @param server the server whose repositories are being requested
* @return the server repositories (never <code>null</code>)
- * @throws Exception if there is a problem obtaining the repositories
+ * @throws Exception if there is a problem obtaining the repositories or if the server is not registered
+ * @throws RuntimeException if the server is not registered
+ * @see #isRegistered(Server)
* @since 0.6
*/
public Collection<Repository> getRepositories( Server server ) throws Exception {
try {
this.serverLock.readLock().lock();
- Collection<Repository> repositories = this.restExecutor.getRepositories(server);
- return Collections.unmodifiableCollection(new ArrayList<Repository>(repositories));
+
+ if (isRegistered(server)) {
+ Collection<Repository> repositories = this.restExecutor.getRepositories(server);
+ return Collections.unmodifiableCollection(new ArrayList<Repository>(repositories));
+ }
+
+ // server must be registered in order to obtain it's repositories
+ String pattern = IMessages.ServerManagerUnregisteredServer;
+ throw new RuntimeException(MessageFormat.format(pattern, server.getShortDescription()));
} finally {
this.serverLock.readLock().unlock();
}
@@ -234,13 +248,22 @@
* @param repository the repository whose workspaces are being requested
* @return the DNA repository workspaces (never <code>null</code>)
* @throws Exception if there is a problem obtaining the workspaces
+ * @throws RuntimeException if the repository's server is not registered
+ * @see #isRegistered(Server)
* @since 0.6
*/
public Collection<Workspace> getWorkspaces( Repository repository ) throws Exception {
try {
this.serverLock.readLock().lock();
- Collection<Workspace> workspaces = this.restExecutor.getWorkspaces(repository);
- return Collections.unmodifiableCollection(new ArrayList<Workspace>(workspaces));
+
+ if (isRegistered(repository.getServer())) {
+ Collection<Workspace> workspaces = this.restExecutor.getWorkspaces(repository);
+ return Collections.unmodifiableCollection(new ArrayList<Workspace>(workspaces));
+ }
+
+ // a repository's server must be registered in order to obtain it's workspaces
+ String pattern = IMessages.ServerManagerUnregisteredServer;
+ throw new RuntimeException(MessageFormat.format(pattern, repository.getServer().getShortDescription()));
} finally {
this.serverLock.readLock().unlock();
}
@@ -261,7 +284,7 @@
try {
this.serverLock.writeLock().lock();
- if (!this.servers.contains(server)) {
+ if (!isRegistered(server)) {
added = this.servers.add(server);
}
} finally {
@@ -296,14 +319,21 @@
try {
this.serverLock.writeLock().lock();
- removed = this.servers.remove(server);
+
+ // see if registered server has the same key
+ for (Server registeredServer : this.servers) {
+ if (registeredServer.hasSameKey(server)) {
+ removed = this.servers.remove(registeredServer);
+ break;
+ }
+ }
} finally {
this.serverLock.writeLock().unlock();
}
if (removed) {
if (notifyListeners) {
- Exception[] errors = notifyRegistryListeners(ServerRegistryEvent.createNewEvent(server));
+ Exception[] errors = notifyRegistryListeners(ServerRegistryEvent.createRemoveEvent(server));
return processRegistryListenerErrors(errors);
}
@@ -320,12 +350,21 @@
/**
* @param server the server being tested
* @return <code>true</code> if the server has been registered
+ * @see #addServer(Server)
* @since 0.6
*/
public boolean isRegistered( Server server ) {
try {
this.serverLock.readLock().lock();
- return this.servers.contains(server);
+
+ // check to make sure no other registered server has the same key
+ for (Server registeredServer : this.servers) {
+ if (registeredServer.hasSameKey(server)) {
+ return true;
+ }
+ }
+
+ return false;
} finally {
this.serverLock.readLock().unlock();
}
Modified: branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/ServerRegistryEvent.java
===================================================================
--- branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/ServerRegistryEvent.java 2009-07-15 20:02:43 UTC (rev 1113)
+++ branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/ServerRegistryEvent.java 2009-07-17 19:12:26 UTC (rev 1114)
@@ -40,7 +40,7 @@
*
* @since 0.6
*/
- public enum Type {
+ private enum Type {
/**
* Indicates that a new server was added to the server registry.
*
Modified: branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/Status.java
===================================================================
--- branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/Status.java 2009-07-15 20:02:43 UTC (rev 1113)
+++ branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/Status.java 2009-07-17 19:12:26 UTC (rev 1114)
@@ -105,7 +105,7 @@
protected final String message;
/**
- * The severity level of this status.
+ * The severity level of this status (never <code>null</code>).
*
* @since 0.6
*/
@@ -150,16 +150,15 @@
}
/**
- * @return severity the status severity
+ * @return severity the status severity (never <code>null</code>)
* @since 0.6
*/
public Severity getSeverity() {
- return severity;
+ return this.severity;
}
/**
- * @return <code>true</code> if the status is an error
- * @see Severity#ERROR
+ * @return <code>true</code> if the status has a severity of {@link Severity#ERROR error}.
* @since 0.6
*/
public boolean isError() {
@@ -167,8 +166,7 @@
}
/**
- * @return <code>true</code> if the status is an info
- * @see Severity#INFO
+ * @return <code>true</code> if the status has a severity of {@link Severity#INFO info}.
* @since 0.6
*/
public boolean isInfo() {
@@ -176,8 +174,7 @@
}
/**
- * @return <code>true</code> if the status is OK
- * @see Severity#OK
+ * @return <code>true</code> if the status has a severity of {@link Severity#OK OK}.
* @since 0.6
*/
public boolean isOk() {
@@ -185,10 +182,17 @@
}
/**
- * @return <code>true</code> if the status is a warning
- * @see Severity#WARNING
+ * @return <code>true</code> if the status has a severity of {@link Severity#UNKNOWN unknown}.
* @since 0.6
*/
+ public boolean isUnknown() {
+ return (this.severity == Severity.UNKNOWN);
+ }
+
+ /**
+ * @return <code>true</code> if the status has a severity of {@link Severity#WARNING warning}.
+ * @since 0.6
+ */
public boolean isWarning() {
return (this.severity == Severity.WARNING);
}
@@ -202,7 +206,10 @@
@Override
public String toString() {
StringBuilder txt = new StringBuilder("Status "); //$NON-NLS-1$
- txt.append(this.severity.toString()).append(": ").append(getMessage()).append(": ").append(getException()); //$NON-NLS-1$ //$NON-NLS-2$
+ txt.append(this.severity.toString()).append(": "); //$NON-NLS-1$
+ txt.append(getMessage().isEmpty() ? "<no message>" : getMessage()); //$NON-NLS-1$
+ txt.append(" : "); //$NON-NLS-1$
+ txt.append((getException() == null) ? "<no error>" : getException()); //$NON-NLS-1$
return txt.toString();
}
Modified: branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/domain/Server.java
===================================================================
--- branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/domain/Server.java 2009-07-15 20:02:43 UTC (rev 1113)
+++ branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/domain/Server.java 2009-07-17 19:12:26 UTC (rev 1114)
@@ -197,6 +197,14 @@
}
/**
+ * @param otherServer the server whose key is being compared
+ * @return <code>true</code> if the servers have the same key
+ */
+ public boolean hasSameKey( Server otherServer ) {
+ return (Utils.equivalent(this.url, otherServer.url) && Utils.equivalent(this.user, otherServer.user));
+ }
+
+ /**
* @return persistPassword <code>true</code> if the password is being persisted
* @since 0.6
*/
Modified: branches/eclipse/dna-web-jcr-rest-client/src/main/resources/org/jboss/dna/web/jcr/rest/client/Messages.properties
===================================================================
--- branches/eclipse/dna-web-jcr-rest-client/src/main/resources/org/jboss/dna/web/jcr/rest/client/Messages.properties 2009-07-15 20:02:43 UTC (rev 1113)
+++ branches/eclipse/dna-web-jcr-rest-client/src/main/resources/org/jboss/dna/web/jcr/rest/client/Messages.properties 2009-07-17 19:12:26 UTC (rev 1114)
@@ -41,6 +41,7 @@
ServerManagerRegistryRemoveUnexpectedError = {0} cannot be removed as it has not been registered
ServerManagerRegistryUpdateAddError = There was an unexpected error updating the server in the registry. The old version of the server was successfully removed. However, the new version was not updated. Detail: {0}
ServerManagerRegistryUpdateRemoveError = There was an unexpected error updating the server in the registry. The server has not been updated in the server registry. Detail: {0}
+ServerManagerUnregisteredServer = Server "{0}" is not registered so it's repositories and workspaces cannot be obtained.
WorkspaceEmptyNameMsg = A workspace name cannot be empty
WorkspaceNullRepositoryMsg = A workspace repository cannot be null
Added: branches/eclipse/dna-web-jcr-rest-client/src/test/java/org/jboss/dna/web/jcr/rest/client/MockRestExecutor.java
===================================================================
--- branches/eclipse/dna-web-jcr-rest-client/src/test/java/org/jboss/dna/web/jcr/rest/client/MockRestExecutor.java (rev 0)
+++ branches/eclipse/dna-web-jcr-rest-client/src/test/java/org/jboss/dna/web/jcr/rest/client/MockRestExecutor.java 2009-07-17 19:12:26 UTC (rev 1114)
@@ -0,0 +1,90 @@
+/*
+ * JBoss DNA (http://www.jboss.org/dna)
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ * See the AUTHORS.txt file in the distribution for a full listing of
+ * individual contributors.
+ *
+ * JBoss DNA is free software. Unless otherwise indicated, all code in JBoss DNA
+ * is licensed to you under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * JBoss DNA is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.dna.web.jcr.rest.client;
+
+import java.io.File;
+import java.util.Collection;
+import org.jboss.dna.web.jcr.rest.client.domain.Repository;
+import org.jboss.dna.web.jcr.rest.client.domain.Server;
+import org.jboss.dna.web.jcr.rest.client.domain.Workspace;
+
+/**
+ * @author Dan Florian
+ * @since 0.6
+ */
+public final class MockRestExecutor implements IRestExecutor {
+
+ // ===========================================================================================================================
+ // Constants
+ // ===========================================================================================================================
+
+
+
+ // ===========================================================================================================================
+ // Methods
+ // ===========================================================================================================================
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.jboss.dna.web.jcr.rest.client.IRestExecutor#getRepositories(org.jboss.dna.web.jcr.rest.client.domain.Server)
+ * @since 0.6
+ */
+ public Collection<Repository> getRepositories( Server server ) throws Exception {
+ return null;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.jboss.dna.web.jcr.rest.client.IRestExecutor#getWorkspaces(org.jboss.dna.web.jcr.rest.client.domain.Repository)
+ * @since 0.6
+ */
+ public Collection<Workspace> getWorkspaces( Repository repository ) throws Exception {
+ return null;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.jboss.dna.web.jcr.rest.client.IRestExecutor#publish(org.jboss.dna.web.jcr.rest.client.domain.Repository, java.lang.String, java.io.File)
+ * @since 0.6
+ */
+ public void publish( Repository repository,
+ String parentPath,
+ File file ) throws Exception {
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.jboss.dna.web.jcr.rest.client.IRestExecutor#unpublish(org.jboss.dna.web.jcr.rest.client.domain.Repository, java.lang.String, java.io.File)
+ * @since 0.6
+ */
+ public void unpublish( Repository repository,
+ String parentPath,
+ File file ) throws Exception {
+ }
+
+}
Property changes on: branches/eclipse/dna-web-jcr-rest-client/src/test/java/org/jboss/dna/web/jcr/rest/client/MockRestExecutor.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: branches/eclipse/dna-web-jcr-rest-client/src/test/java/org/jboss/dna/web/jcr/rest/client/ServerManagerTest.java
===================================================================
--- branches/eclipse/dna-web-jcr-rest-client/src/test/java/org/jboss/dna/web/jcr/rest/client/ServerManagerTest.java (rev 0)
+++ branches/eclipse/dna-web-jcr-rest-client/src/test/java/org/jboss/dna/web/jcr/rest/client/ServerManagerTest.java 2009-07-17 19:12:26 UTC (rev 1114)
@@ -0,0 +1,277 @@
+/*
+ * JBoss DNA (http://www.jboss.org/dna)
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ * See the AUTHORS.txt file in the distribution for a full listing of
+ * individual contributors.
+ *
+ * JBoss DNA is free software. Unless otherwise indicated, all code in JBoss DNA
+ * is licensed to you under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * JBoss DNA is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.dna.web.jcr.rest.client;
+
+import static org.hamcrest.core.Is.is;
+import static org.junit.Assert.assertThat;
+import org.jboss.dna.web.jcr.rest.client.domain.Repository;
+import org.jboss.dna.web.jcr.rest.client.domain.Server;
+import org.junit.Before;
+import org.junit.Test;
+
+/**
+ * @author Dan Florian
+ * @since 0.6
+ */
+public class ServerManagerTest {
+
+ // ===========================================================================================================================
+ // Constants
+ // ===========================================================================================================================
+
+ private static final String URL1 = "file:/tmp/temp.txt"; //$NON-NLS-1$
+ private static final String URL2 = "http:www.redhat.com"; //$NON-NLS-1$
+
+ private static final String USER1 = "user1"; //$NON-NLS-1$
+ private static final String USER2 = "user2"; //$NON-NLS-1$
+
+ private static final String PSWD1 = "pwsd1"; //$NON-NLS-1$
+ private static final String PSWD2 = "pwsd2"; //$NON-NLS-1$
+
+ private static Server SERVER1 = new Server(URL1, USER1, PSWD1, false);
+ private static Server SERVER1_UPDATE = new Server(SERVER1.getUrl(), SERVER1.getUser(), SERVER1.getPassword(),
+ SERVER1.isPasswordBeingPersisted());
+ private static Server SERVER2 = new Server(URL2, USER2, PSWD2, !SERVER1.isPasswordBeingPersisted());
+
+ // ===========================================================================================================================
+ // Fields
+ // ===========================================================================================================================
+
+ private ServerManager serverManager;
+
+ // ===========================================================================================================================
+ // Methods
+ // ===========================================================================================================================
+
+ @Before
+ public void beforeEach() {
+ this.serverManager = new ServerManager(null, new MockRestExecutor());
+ }
+
+ // ===========================================================================================================================
+ // Tests
+ // ===========================================================================================================================
+
+ @Test
+ public void shouldBeRegisteredIfAdded() {
+ this.serverManager.addServer(SERVER1);
+ assertThat(this.serverManager.isRegistered(SERVER1), is(true));
+ assertThat(this.serverManager.getServers().size(), is(1));
+ }
+
+ @Test
+ public void shouldBeRegisteredIfServerWithSameKeyHasBeenAdded() {
+ this.serverManager.addServer(SERVER1);
+ assertThat(this.serverManager.isRegistered(new Server(SERVER1.getUrl(), SERVER1.getUser(), PSWD2,
+ !SERVER1.isPasswordBeingPersisted())), is(true));
+ assertThat(this.serverManager.getServers().size(), is(1));
+ }
+
+ @Test
+ public void shouldDecreaseRegistrySizeWhenServerRemoved() {
+ this.serverManager.addServer(SERVER1);
+ this.serverManager.addServer(SERVER2);
+
+ this.serverManager.removeServer(SERVER1);
+ assertThat(this.serverManager.getServers().size(), is(1));
+
+ this.serverManager.removeServer(SERVER2);
+ assertThat(this.serverManager.getServers().isEmpty(), is(true));
+ }
+
+ @Test
+ public void shouldHaveOkStatusWhenAddingServerSuccessfully() {
+ assertThat(this.serverManager.addServer(SERVER1).isOk(), is(true));
+ assertThat(this.serverManager.getServers().size(), is(1));
+ }
+
+ @Test
+ public void shouldHaveOkStatusWhenRemovingServerSuccessfully() {
+ this.serverManager.addServer(SERVER1);
+ assertThat(this.serverManager.removeServer(SERVER1).isOk(), is(true));
+ assertThat(this.serverManager.getServers().isEmpty(), is(true));
+ }
+
+ @Test
+ public void shouldHaveOkStatusWhenUpdateServerSuccessfully() {
+ this.serverManager.addServer(SERVER1);
+ assertThat(this.serverManager.updateServer(SERVER1, SERVER1_UPDATE).isOk(), is(true));
+ assertThat(this.serverManager.getServers().size(), is(1));
+ }
+
+ @Test
+ public void shouldIncreaseRegistrySizeWhenServerAdded() {
+ this.serverManager.addServer(SERVER1);
+ assertThat(this.serverManager.getServers().size(), is(1));
+
+ this.serverManager.addServer(SERVER2);
+ assertThat(this.serverManager.getServers().size(), is(2));
+ }
+
+ @Test
+ public void shouldNotAddServerIfAlreadyAdded() {
+ this.serverManager.addServer(SERVER1);
+ assertThat(this.serverManager.addServer(SERVER1).isOk(), is(false));
+ assertThat(this.serverManager.getServers().size(), is(1));
+ }
+
+ @Test
+ public void shouldNotAddServerIfKeysMatch() {
+ this.serverManager.addServer(SERVER1);
+ Status status = this.serverManager.addServer(new Server(SERVER1.getUrl(), SERVER1.getUser(), PSWD2,
+ !SERVER1.isPasswordBeingPersisted()));
+ assertThat(status.isOk(), is(false));
+ assertThat(this.serverManager.getServers().size(), is(1));
+ }
+
+ @Test
+ public void shouldNotBeRegisteredIfNotAdded() {
+ this.serverManager.addServer(SERVER1);
+ assertThat(this.serverManager.isRegistered(SERVER2), is(false));
+ assertThat(this.serverManager.getServers().size(), is(1));
+ }
+
+ @Test
+ public void shouldNotBeRegisteredIfRemoved() {
+ this.serverManager.addServer(SERVER1);
+ this.serverManager.removeServer(SERVER1);
+ assertThat(this.serverManager.isRegistered(SERVER1), is(false));
+ assertThat(this.serverManager.getServers().isEmpty(), is(true));
+ }
+
+ @Test
+ public void shouldNotReceiveNotificationIfListenerUnregistered() {
+ RegistryListener listener = new RegistryListener();
+
+ this.serverManager.addRegistryListener(listener);
+ this.serverManager.removeRegistryListener(listener);
+ this.serverManager.addServer(SERVER1);
+ assertThat(listener.wasNotified(), is(false));
+ }
+
+ @Test
+ public void shouldNotRemoveServerIfNotAdded() {
+ assertThat(this.serverManager.removeServer(SERVER1).isOk(), is(false));
+ assertThat(this.serverManager.getServers().isEmpty(), is(true));
+ }
+
+ @Test( expected = RuntimeException.class )
+ public void shouldNotObtainRepositoriesForUnregisteredServer() throws Exception {
+ this.serverManager.getRepositories(SERVER1);
+ }
+
+ @Test( expected = RuntimeException.class )
+ public void shouldNotObtainWorkspacesForUnregisteredServer() throws Exception {
+ Repository repository = new Repository("repo", SERVER1);//$NON-NLS-1$
+ this.serverManager.getWorkspaces(repository);
+ }
+
+ @Test
+ public void shouldReceiveOneEventIfRegisteredMoreThanOnce() {
+ RegistryListener listener = new RegistryListener();
+ this.serverManager.addRegistryListener(listener);
+ this.serverManager.addRegistryListener(listener);
+
+ this.serverManager.addServer(SERVER1);
+ assertThat(listener.wasNotified(), is(true));
+ }
+
+ @Test
+ public void shouldReceiveNotificationIfRegisteredListener() {
+ RegistryListener listener = new RegistryListener();
+ assertThat(this.serverManager.addRegistryListener(listener), is(true));
+
+ this.serverManager.addServer(SERVER1);
+ assertThat(listener.wasNotified(), is(true));
+ }
+
+ @Test
+ public void shouldReceiveNewServerEvent() {
+ RegistryListener listener = new RegistryListener();
+ this.serverManager.addRegistryListener(listener);
+
+ this.serverManager.addServer(SERVER1);
+ assertThat(listener.getEvent().isNew(), is(true));
+ assertThat(listener.getEvent().isRemove(), is(false));
+ assertThat(listener.getEvent().isUpdate(), is(false));
+ }
+
+ @Test
+ public void shouldReceiveRemoveServerEvent() {
+ this.serverManager.addServer(SERVER1);
+
+ RegistryListener listener = new RegistryListener();
+ this.serverManager.addRegistryListener(listener);
+
+ this.serverManager.removeServer(SERVER1);
+ assertThat(listener.getEvent().isRemove(), is(true));
+ assertThat(listener.getEvent().isNew(), is(false));
+ assertThat(listener.getEvent().isUpdate(), is(false));
+ }
+
+ @Test
+ public void shouldReceiveUpdateServerEvent() {
+ this.serverManager.addServer(SERVER1);
+
+ RegistryListener listener = new RegistryListener();
+ this.serverManager.addRegistryListener(listener);
+
+ this.serverManager.updateServer(SERVER1, new Server(SERVER1.getUrl(), SERVER1.getUser(), PSWD2,
+ !SERVER1.isPasswordBeingPersisted()));
+ assertThat(listener.getEvent().isUpdate(), is(true));
+ assertThat(listener.getEvent().isNew(), is(false));
+ assertThat(listener.getEvent().isRemove(), is(false));
+ }
+
+ @Test
+ public void shouldRemoveServerIfNotAddedButKeyMatches() {
+ this.serverManager.addServer(SERVER1_UPDATE);
+ assertThat(this.serverManager.removeServer(SERVER1).isOk(), is(true));
+ assertThat(this.serverManager.getServers().isEmpty(), is(true));
+ }
+
+ // ===========================================================================================================================
+ // RegistryListener Inner Class
+ // ===========================================================================================================================
+
+ class RegistryListener implements IServerRegistryListener {
+ boolean[] notified = new boolean[] {false};
+ ServerRegistryEvent event = null;
+
+ public Exception[] serverRegistryChanged( ServerRegistryEvent event ) {
+ notified[0] = !notified[0];
+ this.event = event;
+ return null;
+ }
+
+ public ServerRegistryEvent getEvent() {
+ return this.event;
+ }
+
+ public boolean wasNotified() {
+ return notified[0];
+ }
+ }
+
+}
Property changes on: branches/eclipse/dna-web-jcr-rest-client/src/test/java/org/jboss/dna/web/jcr/rest/client/ServerManagerTest.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: branches/eclipse/dna-web-jcr-rest-client/src/test/java/org/jboss/dna/web/jcr/rest/client/StatusTest.java
===================================================================
--- branches/eclipse/dna-web-jcr-rest-client/src/test/java/org/jboss/dna/web/jcr/rest/client/StatusTest.java (rev 0)
+++ branches/eclipse/dna-web-jcr-rest-client/src/test/java/org/jboss/dna/web/jcr/rest/client/StatusTest.java 2009-07-17 19:12:26 UTC (rev 1114)
@@ -0,0 +1,148 @@
+/*
+ * JBoss DNA (http://www.jboss.org/dna)
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ * See the AUTHORS.txt file in the distribution for a full listing of
+ * individual contributors.
+ *
+ * JBoss DNA is free software. Unless otherwise indicated, all code in JBoss DNA
+ * is licensed to you under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * JBoss DNA is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.dna.web.jcr.rest.client;
+
+import static org.hamcrest.core.Is.is;
+import static org.hamcrest.core.IsNot.not;
+import static org.junit.Assert.assertThat;
+import static org.mockito.Matchers.isNull;
+import org.jboss.dna.web.jcr.rest.client.Status.Severity;
+import org.junit.Test;
+
+/**
+ * @author Dan Florian
+ * @since 0.6
+ */
+public final class StatusTest {
+
+ // ===========================================================================================================================
+ // Constants
+ // ===========================================================================================================================
+
+ private static final Status ERROR_STATUS = new Status(Severity.ERROR, null, null);
+
+ private static final Status INFO_STATUS = new Status(Severity.INFO, null, null);
+
+ private static final Status WARNING_STATUS = new Status(Severity.WARNING, null, null);
+
+ private static final Status UNKNOWN_STATUS = new Status(Severity.UNKNOWN, null, null);
+
+ private static final Status NULL_SEVERITY_STATUS = new Status(null, null, null);
+
+ // ===========================================================================================================================
+ // Tests
+ // ===========================================================================================================================
+
+ @Test
+ public void shouldHaveErrorSeverity() {
+ assertThat(ERROR_STATUS.isError(), is(true));
+
+ // make sure other values are false
+ assertThat(ERROR_STATUS.isInfo(), is(false));
+ assertThat(ERROR_STATUS.isOk(), is(false));
+ assertThat(ERROR_STATUS.isUnknown(), is(false));
+ assertThat(ERROR_STATUS.isWarning(), is(false));
+ }
+
+ @Test
+ public void shouldHaveInfoSeverity() {
+ assertThat(INFO_STATUS.isInfo(), is(true));
+
+ // make sure other values are false
+ assertThat(INFO_STATUS.isError(), is(false));
+ assertThat(INFO_STATUS.isOk(), is(false));
+ assertThat(INFO_STATUS.isUnknown(), is(false));
+ assertThat(INFO_STATUS.isWarning(), is(false));
+ }
+
+ @Test
+ public void shouldHaveOkSeverity() {
+ assertThat(Status.OK_STATUS.isOk(), is(true));
+
+ // make sure other values are false
+ assertThat(Status.OK_STATUS.isError(), is(false));
+ assertThat(Status.OK_STATUS.isInfo(), is(false));
+ assertThat(Status.OK_STATUS.isUnknown(), is(false));
+ assertThat(Status.OK_STATUS.isWarning(), is(false));
+ }
+
+ @Test
+ public void shouldHaveUnknownSeverity() {
+ assertThat(UNKNOWN_STATUS.isUnknown(), is(true));
+
+ // make sure other values are false
+ assertThat(UNKNOWN_STATUS.isError(), is(false));
+ assertThat(UNKNOWN_STATUS.isInfo(), is(false));
+ assertThat(UNKNOWN_STATUS.isOk(), is(false));
+ assertThat(UNKNOWN_STATUS.isWarning(), is(false));
+ }
+
+ @Test
+ public void shouldHaveUnknownSeverityWhenNullSeverity() {
+ assertThat(NULL_SEVERITY_STATUS.isUnknown(), is(true));
+
+ // make sure other values are false
+ assertThat(NULL_SEVERITY_STATUS.isError(), is(false));
+ assertThat(NULL_SEVERITY_STATUS.isInfo(), is(false));
+ assertThat(NULL_SEVERITY_STATUS.isOk(), is(false));
+ assertThat(NULL_SEVERITY_STATUS.isWarning(), is(false));
+ }
+
+ @Test
+ public void shouldHaveWarningSeverity() {
+ assertThat(WARNING_STATUS.isWarning(), is(true));
+
+ // make sure other values are false
+ assertThat(WARNING_STATUS.isError(), is(false));
+ assertThat(WARNING_STATUS.isInfo(), is(false));
+ assertThat(WARNING_STATUS.isOk(), is(false));
+ assertThat(WARNING_STATUS.isUnknown(), is(false));
+ }
+
+ @Test
+ public void shouldNotHaveNullMessageWhenConstructedWithNullMessage() {
+ assertThat(new Status(Severity.WARNING, null, null).getMessage(), not(isNull()));
+ }
+
+ @Test
+ public void shouldBeAbleToPrintWithMessageAndNullException() {
+ new Status(Severity.WARNING, "the message goes here", null).toString(); //$NON-NLS-1$
+ }
+
+ @Test
+ public void shouldBeAbleToPrintWithMessageAndException() {
+ new Status(Severity.WARNING, "the message goes here", new RuntimeException("exception message")).toString(); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ @Test
+ public void shouldBeAbleToPrintWithNullMessageAndException() {
+ new Status(Severity.WARNING, null, new RuntimeException("exception message")).toString(); //$NON-NLS-1$
+ }
+
+ @Test
+ public void shouldBeAbleToPrintWithNullMessageAndNullException() {
+ new Status(Severity.WARNING, null, null).toString();
+ }
+
+}
Property changes on: branches/eclipse/dna-web-jcr-rest-client/src/test/java/org/jboss/dna/web/jcr/rest/client/StatusTest.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: branches/eclipse/dna-web-jcr-rest-client/src/test/java/org/jboss/dna/web/jcr/rest/client/domain/RepositoryTest.java
===================================================================
--- branches/eclipse/dna-web-jcr-rest-client/src/test/java/org/jboss/dna/web/jcr/rest/client/domain/RepositoryTest.java (rev 0)
+++ branches/eclipse/dna-web-jcr-rest-client/src/test/java/org/jboss/dna/web/jcr/rest/client/domain/RepositoryTest.java 2009-07-17 19:12:26 UTC (rev 1114)
@@ -0,0 +1,91 @@
+/*
+ * JBoss DNA (http://www.jboss.org/dna)
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ * See the AUTHORS.txt file in the distribution for a full listing of
+ * individual contributors.
+ *
+ * JBoss DNA is free software. Unless otherwise indicated, all code in JBoss DNA
+ * is licensed to you under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * JBoss DNA is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.dna.web.jcr.rest.client.domain;
+
+import static org.hamcrest.core.Is.is;
+import static org.hamcrest.core.IsEqual.equalTo;
+import static org.hamcrest.core.IsNot.not;
+import static org.junit.Assert.assertThat;
+import java.util.HashSet;
+import java.util.Set;
+import org.junit.Test;
+
+/**
+ * @author Dan Florian
+ * @since 0.6
+ */
+public final class RepositoryTest {
+
+ // ===========================================================================================================================
+ // Constants
+ // ===========================================================================================================================
+
+ private static final String NAME1 = "name1"; //$NON-NLS-1$
+
+ private static final String NAME2 = "name2"; //$NON-NLS-1$
+
+ private static final Server SERVER1 = new Server("file:/tmp/temp.txt", "user", "pswd", false); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+
+ private static final Server SERVER2 = new Server("http:www.redhat.com", "user", "pswd", false); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+
+ private static final Repository REPOSITORY1 = new Repository(NAME1, SERVER1);
+
+ // ===========================================================================================================================
+ // Tests
+ // ===========================================================================================================================
+
+ @Test
+ public void shouldBeEqualIfHavingSameProperies() {
+ assertThat(REPOSITORY1, equalTo(new Repository(REPOSITORY1.getName(), REPOSITORY1.getServer())));
+ }
+
+ @Test
+ public void shouldHashToSameValueIfEquals() {
+ Set<Repository> set = new HashSet<Repository>();
+ set.add(REPOSITORY1);
+ set.add(new Repository(REPOSITORY1.getName(), REPOSITORY1.getServer()));
+ assertThat(set.size(), equalTo(1));
+ }
+
+ @Test( expected = RuntimeException.class )
+ public void shouldNotAllowNullName() {
+ new Repository(null, SERVER1);
+ }
+
+ @Test( expected = RuntimeException.class )
+ public void shouldNotAllowNullServer() {
+ new Repository(NAME1, null);
+ }
+
+ @Test
+ public void shouldNotBeEqualIfSameNameButDifferentServers() {
+ assertThat(REPOSITORY1, is(not(equalTo(new Repository(REPOSITORY1.getName(), SERVER2)))));
+ }
+
+ @Test
+ public void shouldNotBeEqualIfSameServerButDifferentName() {
+ assertThat(REPOSITORY1, is(not(equalTo(new Repository(NAME2, REPOSITORY1.getServer())))));
+ }
+
+}
Property changes on: branches/eclipse/dna-web-jcr-rest-client/src/test/java/org/jboss/dna/web/jcr/rest/client/domain/RepositoryTest.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: branches/eclipse/dna-web-jcr-rest-client/src/test/java/org/jboss/dna/web/jcr/rest/client/domain/ServerTest.java
===================================================================
--- branches/eclipse/dna-web-jcr-rest-client/src/test/java/org/jboss/dna/web/jcr/rest/client/domain/ServerTest.java (rev 0)
+++ branches/eclipse/dna-web-jcr-rest-client/src/test/java/org/jboss/dna/web/jcr/rest/client/domain/ServerTest.java 2009-07-17 19:12:26 UTC (rev 1114)
@@ -0,0 +1,122 @@
+/*
+ * JBoss DNA (http://www.jboss.org/dna)
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ * See the AUTHORS.txt file in the distribution for a full listing of
+ * individual contributors.
+ *
+ * JBoss DNA is free software. Unless otherwise indicated, all code in JBoss DNA
+ * is licensed to you under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * JBoss DNA is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.dna.web.jcr.rest.client.domain;
+
+import static org.hamcrest.core.Is.is;
+import static org.hamcrest.core.IsEqual.equalTo;
+import static org.hamcrest.core.IsNot.not;
+import static org.junit.Assert.assertThat;
+import java.util.HashSet;
+import java.util.Set;
+import org.junit.Test;
+
+/**
+ * @author Dan Florian
+ * @since 0.6
+ */
+public final class ServerTest {
+
+ // ===========================================================================================================================
+ // Constants
+ // ===========================================================================================================================
+
+ private static final String URL1 = "file:/tmp/temp.txt"; //$NON-NLS-1$
+ private static final String URL2 = "http:www.redhat.com"; //$NON-NLS-1$
+
+ private static final String USER1 = "user1"; //$NON-NLS-1$
+ private static final String USER2 = "user2"; //$NON-NLS-1$
+
+ private static final String PSWD1 = "pwsd1"; //$NON-NLS-1$
+ private static final String PSWD2 = "pwsd2"; //$NON-NLS-1$
+
+ private static Server SERVER1 = new Server(URL1, USER1, PSWD1, false);
+
+ // ===========================================================================================================================
+ // Tests
+ // ===========================================================================================================================
+
+ @Test
+ public void shouldBeEqualIfHavingSameProperies() {
+ assertThat(SERVER1, equalTo(new Server(SERVER1.getUrl(), SERVER1.getUser(), SERVER1.getPassword(),
+ SERVER1.isPasswordBeingPersisted())));
+ }
+
+ @Test
+ public void shouldHashToSameValueIfEquals() {
+ Set<Server> set = new HashSet<Server>();
+ set.add(SERVER1);
+ set.add(new Server(SERVER1.getUrl(), SERVER1.getUser(), SERVER1.getPassword(), SERVER1.isPasswordBeingPersisted()));
+ assertThat(set.size(), equalTo(1));
+ }
+
+ @Test( expected = RuntimeException.class )
+ public void shouldNotAllowNullUrl() {
+ new Server(null, USER1, PSWD1, true);
+ }
+
+ @Test
+ public void shouldHaveSameKey() {
+ assertThat(SERVER1.hasSameKey(new Server(SERVER1.getUrl(), SERVER1.getUser(), SERVER1.getPassword(),
+ SERVER1.isPasswordBeingPersisted())), is(true));
+ }
+
+ @Test
+ public void shouldNotBeEqualIfPropertiesAreDifferent() {
+ // different URL
+ assertThat(SERVER1, is(not(equalTo(new Server(URL2, SERVER1.getUser(), SERVER1.getPassword(),
+ SERVER1.isPasswordBeingPersisted())))));
+
+ // different user
+ assertThat(SERVER1, is(not(equalTo(new Server(SERVER1.getUrl(), USER2, SERVER1.getPassword(),
+ SERVER1.isPasswordBeingPersisted())))));
+
+ // different passord
+ assertThat(SERVER1, is(not(equalTo(new Server(SERVER1.getUrl(), SERVER1.getUser(), PSWD2,
+ SERVER1.isPasswordBeingPersisted())))));
+
+ // different persisted flag
+ assertThat(SERVER1, is(not(equalTo(new Server(SERVER1.getUrl(), SERVER1.getUser(), SERVER1.getPassword(),
+ !SERVER1.isPasswordBeingPersisted())))));
+ }
+
+ @Test
+ public void shouldNotHaveSameKey() {
+ assertThat(SERVER1.hasSameKey(new Server(URL2, SERVER1.getUser(), SERVER1.getPassword(),
+ SERVER1.isPasswordBeingPersisted())), is(false));
+ assertThat(SERVER1.hasSameKey(new Server(SERVER1.getUrl(), USER2, SERVER1.getPassword(),
+ SERVER1.isPasswordBeingPersisted())), is(false));
+ }
+
+ @Test
+ public void shouldSetPersistPasswordCorrectly() {
+ boolean persist = true;
+ Server server = new Server(URL1, USER1, PSWD1, persist);
+ assertThat(persist, is(server.isPasswordBeingPersisted()));
+
+ persist = !persist;
+ server = new Server(URL1, USER1, PSWD1, persist);
+ assertThat(persist, is(server.isPasswordBeingPersisted()));
+ }
+
+}
Property changes on: branches/eclipse/dna-web-jcr-rest-client/src/test/java/org/jboss/dna/web/jcr/rest/client/domain/ServerTest.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: branches/eclipse/dna-web-jcr-rest-client/src/test/java/org/jboss/dna/web/jcr/rest/client/domain/WorkspaceTest.java
===================================================================
--- branches/eclipse/dna-web-jcr-rest-client/src/test/java/org/jboss/dna/web/jcr/rest/client/domain/WorkspaceTest.java (rev 0)
+++ branches/eclipse/dna-web-jcr-rest-client/src/test/java/org/jboss/dna/web/jcr/rest/client/domain/WorkspaceTest.java 2009-07-17 19:12:26 UTC (rev 1114)
@@ -0,0 +1,95 @@
+/*
+ * JBoss DNA (http://www.jboss.org/dna)
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ * See the AUTHORS.txt file in the distribution for a full listing of
+ * individual contributors.
+ *
+ * JBoss DNA is free software. Unless otherwise indicated, all code in JBoss DNA
+ * is licensed to you under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * JBoss DNA is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.dna.web.jcr.rest.client.domain;
+
+import static org.hamcrest.core.Is.is;
+import static org.hamcrest.core.IsEqual.equalTo;
+import static org.hamcrest.core.IsNot.not;
+import static org.junit.Assert.assertThat;
+import java.util.HashSet;
+import java.util.Set;
+import org.junit.Test;
+
+/**
+ * @author Dan Florian
+ * @since 0.6
+ */
+public final class WorkspaceTest {
+
+ // ===========================================================================================================================
+ // Constants
+ // ===========================================================================================================================
+
+ private static final String NAME1 = "name1"; //$NON-NLS-1$
+
+ private static final String NAME2 = "name2"; //$NON-NLS-1$
+
+ private static final Server SERVER1 = new Server("file:/tmp/temp.txt", "user", "pswd", false); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+
+ private static final Server SERVER2 = new Server("http:www.redhat.com", "user", "pswd", false); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+
+ private static final Repository REPOSITORY1 = new Repository(NAME1, SERVER1);
+
+ private static final Repository REPOSITORY2 = new Repository(NAME2, SERVER2);
+
+ private static final Workspace WORKSPACE1 = new Workspace(NAME1, REPOSITORY1);
+
+ // ===========================================================================================================================
+ // Tests
+ // ===========================================================================================================================
+
+ @Test
+ public void shouldBeEqualIfHavingSameProperies() {
+ assertThat(WORKSPACE1, equalTo(new Workspace(WORKSPACE1.getName(), WORKSPACE1.getRepository())));
+ }
+
+ @Test
+ public void shouldHashToSameValueIfEquals() {
+ Set<Workspace> set = new HashSet<Workspace>();
+ set.add(WORKSPACE1);
+ set.add(new Workspace(WORKSPACE1.getName(), WORKSPACE1.getRepository()));
+ assertThat(set.size(), equalTo(1));
+ }
+
+ @Test( expected = RuntimeException.class )
+ public void shouldNotAllowNullName() {
+ new Workspace(null, REPOSITORY1);
+ }
+
+ @Test( expected = RuntimeException.class )
+ public void shouldNotAllowNullRepository() {
+ new Workspace(NAME1, null);
+ }
+
+ @Test
+ public void shouldNotBeEqualIfSameNameButDifferentRepository() {
+ assertThat(WORKSPACE1, is(not(equalTo(new Workspace(WORKSPACE1.getName(), REPOSITORY2)))));
+ }
+
+ @Test
+ public void shouldNotBeEqualIfSameRepositoryButDifferentName() {
+ assertThat(WORKSPACE1, is(not(equalTo(new Workspace(NAME2, WORKSPACE1.getRepository())))));
+ }
+
+}
Property changes on: branches/eclipse/dna-web-jcr-rest-client/src/test/java/org/jboss/dna/web/jcr/rest/client/domain/WorkspaceTest.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
16 years, 9 months
DNA SVN: r1112 - in trunk: dna-jcr/src/main/java/org/jboss/dna/jcr and 1 other directories.
by dna-commits@lists.jboss.org
Author: rhauch
Date: 2009-07-14 15:07:22 -0400 (Tue, 14 Jul 2009)
New Revision: 1112
Modified:
trunk/dna-graph/src/main/java/org/jboss/dna/graph/session/GraphSession.java
trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/AbstractJcrProperty.java
trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/JcrContentHandler.java
trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/JcrTckTest.java
Log:
DNA-479 Workspace import does not work
Resolved the final issues with the importer. The SessionCache (and GraphSession) save methods were not properly refreshing if there were no changes. Also, the JcrContentHandler was always saving its changes, but should only have been doing that when used against the workspace. Once these were fixed, all of the import TCK unit tests (related to import/export) now run successfully.
Modified: trunk/dna-graph/src/main/java/org/jboss/dna/graph/session/GraphSession.java
===================================================================
--- trunk/dna-graph/src/main/java/org/jboss/dna/graph/session/GraphSession.java 2009-07-14 12:59:48 UTC (rev 1111)
+++ trunk/dna-graph/src/main/java/org/jboss/dna/graph/session/GraphSession.java 2009-07-14 19:07:22 UTC (rev 1112)
@@ -750,13 +750,19 @@
* @throws InvalidStateException if the supplied node is no longer a node within this cache (because it was unloaded)
*/
public void save() throws PathNotFoundException, ValidationException, InvalidStateException {
- if (!operations.isExecuteRequired()) return;
+ if (!operations.isExecuteRequired()) {
+ // Remove all the cached items ...
+ this.root.clearChanges();
+ this.root.unload();
+ return;
+ }
if (!root.isChanged(true)) {
// Then a bunch of changes could have been made and rolled back manually, so recompute the change state ...
root.recomputeChangedBelow();
if (!root.isChanged(true)) {
// If still no changes, then simply do a refresh ...
- refresh(false);
+ this.root.clearChanges();
+ this.root.unload();
return;
}
}
Modified: trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/AbstractJcrProperty.java
===================================================================
--- trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/AbstractJcrProperty.java 2009-07-14 12:59:48 UTC (rev 1111)
+++ trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/AbstractJcrProperty.java 2009-07-14 19:07:22 UTC (rev 1112)
@@ -92,16 +92,10 @@
}
final org.jboss.dna.graph.property.Property property() throws RepositoryException {
- if (propertyInfo() == null) {
- int x = 0;
- }
return propertyInfo().getProperty();
}
JcrValue createValue( Object value ) throws RepositoryException {
- if (value == null) {
- int x = 0;
- }
return new JcrValue(context().getValueFactories(), this.cache, payload().getPropertyType(), value);
}
Modified: trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/JcrContentHandler.java
===================================================================
--- trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/JcrContentHandler.java 2009-07-14 12:59:48 UTC (rev 1111)
+++ trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/JcrContentHandler.java 2009-07-14 19:07:22 UTC (rev 1112)
@@ -83,6 +83,7 @@
private final ValueFactory jcrValueFactory;
private final JcrNodeTypeManager nodeTypes;
private final javax.jcr.NamespaceRegistry jcrNamespaceRegistry;
+ private final SaveMode saveMode;
protected final int uuidBehavior;
protected final String primaryTypeName;
@@ -115,7 +116,8 @@
this.nameFactory = context.getValueFactories().getNameFactory();
this.uuidBehavior = uuidBehavior;
- switch (saveMode) {
+ this.saveMode = saveMode;
+ switch (this.saveMode) {
case SESSION:
cache = session.cache();
break;
@@ -188,10 +190,12 @@
*/
@Override
public void endDocument() throws SAXException {
- try {
- cache.save();
- } catch (RepositoryException e) {
- throw new EnclosingSAXException(e);
+ if (saveMode == SaveMode.WORKSPACE) {
+ try {
+ cache.save();
+ } catch (RepositoryException e) {
+ throw new EnclosingSAXException(e);
+ }
}
super.endDocument();
}
Modified: trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/JcrTckTest.java
===================================================================
--- trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/JcrTckTest.java 2009-07-14 12:59:48 UTC (rev 1111)
+++ trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/JcrTckTest.java 2009-07-14 19:07:22 UTC (rev 1112)
@@ -28,6 +28,7 @@
import org.apache.jackrabbit.test.JCRTestSuite;
import org.apache.jackrabbit.test.api.AddNodeTest;
import org.apache.jackrabbit.test.api.CheckPermissionTest;
+import org.apache.jackrabbit.test.api.DocumentViewImportTest;
import org.apache.jackrabbit.test.api.ImpersonateTest;
import org.apache.jackrabbit.test.api.NamespaceRegistryTest;
import org.apache.jackrabbit.test.api.NodeAddMixinTest;
@@ -40,6 +41,7 @@
import org.apache.jackrabbit.test.api.PropertyItemIsNewTest;
import org.apache.jackrabbit.test.api.PropertyTest;
import org.apache.jackrabbit.test.api.RepositoryLoginTest;
+import org.apache.jackrabbit.test.api.SerializationTest;
import org.apache.jackrabbit.test.api.SetPropertyAssumeTypeTest;
import org.apache.jackrabbit.test.api.SetPropertyBooleanTest;
import org.apache.jackrabbit.test.api.SetPropertyCalendarTest;
@@ -230,8 +232,8 @@
addTestSuite(ImpersonateTest.class);
addTestSuite(CheckPermissionTest.class);
- // dna-466 addTestSuite(DocumentViewImportTest.class);
- // dna-466 addTestSuite(SerializationTest.class);
+ addTestSuite(DocumentViewImportTest.class);
+ addTestSuite(SerializationTest.class);
addTestSuite(ValueFactoryTest.class);
}
16 years, 9 months
DNA SVN: r1111 - in branches/eclipse/dna-web-jcr-rest-client: src and 53 other directories.
by dna-commits@lists.jboss.org
Author: elvisisking
Date: 2009-07-14 08:59:48 -0400 (Tue, 14 Jul 2009)
New Revision: 1111
Added:
branches/eclipse/dna-web-jcr-rest-client/.classpath
branches/eclipse/dna-web-jcr-rest-client/.project
branches/eclipse/dna-web-jcr-rest-client/pom.xml
branches/eclipse/dna-web-jcr-rest-client/src/
branches/eclipse/dna-web-jcr-rest-client/src/main/
branches/eclipse/dna-web-jcr-rest-client/src/main/java/
branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/
branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/
branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/
branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/
branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/
branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/
branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/
branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/IConstants.java
branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/IServerRegistryListener.java
branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/Logger.java
branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/ServerManager.java
branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/ServerRegistryEvent.java
branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/Status.java
branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/Utils.java
branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/domain/
branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/domain/IDnaObject.java
branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/domain/Repository.java
branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/domain/Server.java
branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/domain/Workspace.java
branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/domain/validation/
branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/domain/validation/RepositoryValidator.java
branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/domain/validation/ServerValidator.java
branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/domain/validation/WorkspaceValidator.java
branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/json/
branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/json/GetRepositoriesRequest.java
branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/json/GetWorkspacesRequest.java
branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/json/IsPublishedRequest.java
branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/json/IsServerAliveRequest.java
branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/json/JsonRequestFactory.java
branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/json/JsonRestRequest.java
branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/json/PublishCommand.java
branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/json/PublishRequest.java
branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/json/UnpublishRequest.java
branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/publish/
branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/publish/IRestRequest.java
branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/publish/IRestRequestFactory.java
branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/publish/IRestResponse.java
branches/eclipse/dna-web-jcr-rest-client/src/main/resources/
branches/eclipse/dna-web-jcr-rest-client/src/main/resources/org/
branches/eclipse/dna-web-jcr-rest-client/src/main/resources/org/jboss/
branches/eclipse/dna-web-jcr-rest-client/src/main/resources/org/jboss/dna/
branches/eclipse/dna-web-jcr-rest-client/src/main/resources/org/jboss/dna/web/
branches/eclipse/dna-web-jcr-rest-client/src/main/resources/org/jboss/dna/web/jcr/
branches/eclipse/dna-web-jcr-rest-client/src/main/resources/org/jboss/dna/web/jcr/rest/
branches/eclipse/dna-web-jcr-rest-client/src/main/resources/org/jboss/dna/web/jcr/rest/client/
branches/eclipse/dna-web-jcr-rest-client/src/main/resources/org/jboss/dna/web/jcr/rest/client/Messages.properties
branches/eclipse/dna-web-jcr-rest-client/src/test/
branches/eclipse/dna-web-jcr-rest-client/src/test/java/
branches/eclipse/dna-web-jcr-rest-client/src/test/java/org/
branches/eclipse/dna-web-jcr-rest-client/src/test/java/org/jboss/
branches/eclipse/dna-web-jcr-rest-client/src/test/java/org/jboss/dna/
branches/eclipse/dna-web-jcr-rest-client/src/test/java/org/jboss/dna/web/
branches/eclipse/dna-web-jcr-rest-client/src/test/java/org/jboss/dna/web/jcr/
branches/eclipse/dna-web-jcr-rest-client/src/test/java/org/jboss/dna/web/jcr/rest/
branches/eclipse/dna-web-jcr-rest-client/src/test/java/org/jboss/dna/web/jcr/rest/client/
branches/eclipse/dna-web-jcr-rest-client/src/test/resources/
branches/eclipse/dna-web-jcr-rest-client/src/test/resources/log4j.properties
branches/eclipse/dna-web-jcr-rest-client/src/test/resources/org/
branches/eclipse/dna-web-jcr-rest-client/src/test/resources/org/jboss/
branches/eclipse/dna-web-jcr-rest-client/src/test/resources/org/jboss/dna/
branches/eclipse/dna-web-jcr-rest-client/target/
branches/eclipse/dna-web-jcr-rest-client/target/classes/
branches/eclipse/dna-web-jcr-rest-client/target/classes/org/
branches/eclipse/dna-web-jcr-rest-client/target/classes/org/jboss/
branches/eclipse/dna-web-jcr-rest-client/target/classes/org/jboss/dna/
branches/eclipse/dna-web-jcr-rest-client/target/classes/org/jboss/dna/web/
branches/eclipse/dna-web-jcr-rest-client/target/classes/org/jboss/dna/web/jcr/
branches/eclipse/dna-web-jcr-rest-client/target/classes/org/jboss/dna/web/jcr/rest/
branches/eclipse/dna-web-jcr-rest-client/target/classes/org/jboss/dna/web/jcr/rest/client/
branches/eclipse/dna-web-jcr-rest-client/target/classes/org/jboss/dna/web/jcr/rest/client/IConstants.class
branches/eclipse/dna-web-jcr-rest-client/target/classes/org/jboss/dna/web/jcr/rest/client/IServerRegistryListener.class
branches/eclipse/dna-web-jcr-rest-client/target/classes/org/jboss/dna/web/jcr/rest/client/Logger.class
branches/eclipse/dna-web-jcr-rest-client/target/classes/org/jboss/dna/web/jcr/rest/client/Messages.properties
branches/eclipse/dna-web-jcr-rest-client/target/classes/org/jboss/dna/web/jcr/rest/client/ServerManager.class
branches/eclipse/dna-web-jcr-rest-client/target/classes/org/jboss/dna/web/jcr/rest/client/ServerRegistryEvent$Type.class
branches/eclipse/dna-web-jcr-rest-client/target/classes/org/jboss/dna/web/jcr/rest/client/ServerRegistryEvent.class
branches/eclipse/dna-web-jcr-rest-client/target/classes/org/jboss/dna/web/jcr/rest/client/Status$Severity.class
branches/eclipse/dna-web-jcr-rest-client/target/classes/org/jboss/dna/web/jcr/rest/client/Status.class
branches/eclipse/dna-web-jcr-rest-client/target/classes/org/jboss/dna/web/jcr/rest/client/Utils.class
branches/eclipse/dna-web-jcr-rest-client/target/classes/org/jboss/dna/web/jcr/rest/client/domain/
branches/eclipse/dna-web-jcr-rest-client/target/classes/org/jboss/dna/web/jcr/rest/client/domain/IDnaObject.class
branches/eclipse/dna-web-jcr-rest-client/target/classes/org/jboss/dna/web/jcr/rest/client/domain/Repository.class
branches/eclipse/dna-web-jcr-rest-client/target/classes/org/jboss/dna/web/jcr/rest/client/domain/Server.class
branches/eclipse/dna-web-jcr-rest-client/target/classes/org/jboss/dna/web/jcr/rest/client/domain/Workspace.class
branches/eclipse/dna-web-jcr-rest-client/target/classes/org/jboss/dna/web/jcr/rest/client/domain/validation/
branches/eclipse/dna-web-jcr-rest-client/target/classes/org/jboss/dna/web/jcr/rest/client/domain/validation/RepositoryValidator.class
branches/eclipse/dna-web-jcr-rest-client/target/classes/org/jboss/dna/web/jcr/rest/client/domain/validation/ServerValidator.class
branches/eclipse/dna-web-jcr-rest-client/target/classes/org/jboss/dna/web/jcr/rest/client/domain/validation/WorkspaceValidator.class
branches/eclipse/dna-web-jcr-rest-client/target/classes/org/jboss/dna/web/jcr/rest/client/json/
branches/eclipse/dna-web-jcr-rest-client/target/classes/org/jboss/dna/web/jcr/rest/client/json/GetRepositoriesRequest.class
branches/eclipse/dna-web-jcr-rest-client/target/classes/org/jboss/dna/web/jcr/rest/client/json/GetWorkspacesRequest.class
branches/eclipse/dna-web-jcr-rest-client/target/classes/org/jboss/dna/web/jcr/rest/client/json/IsPublishedRequest.class
branches/eclipse/dna-web-jcr-rest-client/target/classes/org/jboss/dna/web/jcr/rest/client/json/IsServerAliveRequest.class
branches/eclipse/dna-web-jcr-rest-client/target/classes/org/jboss/dna/web/jcr/rest/client/json/JsonRequestFactory.class
branches/eclipse/dna-web-jcr-rest-client/target/classes/org/jboss/dna/web/jcr/rest/client/json/JsonRestRequest$Method.class
branches/eclipse/dna-web-jcr-rest-client/target/classes/org/jboss/dna/web/jcr/rest/client/json/JsonRestRequest.class
branches/eclipse/dna-web-jcr-rest-client/target/classes/org/jboss/dna/web/jcr/rest/client/json/PublishCommand$1.class
branches/eclipse/dna-web-jcr-rest-client/target/classes/org/jboss/dna/web/jcr/rest/client/json/PublishCommand.class
branches/eclipse/dna-web-jcr-rest-client/target/classes/org/jboss/dna/web/jcr/rest/client/json/PublishRequest.class
branches/eclipse/dna-web-jcr-rest-client/target/classes/org/jboss/dna/web/jcr/rest/client/json/UnpublishRequest.class
branches/eclipse/dna-web-jcr-rest-client/target/classes/org/jboss/dna/web/jcr/rest/client/publish/
branches/eclipse/dna-web-jcr-rest-client/target/classes/org/jboss/dna/web/jcr/rest/client/publish/IRestRequest.class
branches/eclipse/dna-web-jcr-rest-client/target/classes/org/jboss/dna/web/jcr/rest/client/publish/IRestRequestFactory.class
branches/eclipse/dna-web-jcr-rest-client/target/classes/org/jboss/dna/web/jcr/rest/client/publish/IRestResponse.class
branches/eclipse/dna-web-jcr-rest-client/target/dna-web-jcr-rest-client-0.6-SNAPSHOT-sources.jar
branches/eclipse/dna-web-jcr-rest-client/target/dna-web-jcr-rest-client-0.6-SNAPSHOT-test-sources.jar
branches/eclipse/dna-web-jcr-rest-client/target/dna-web-jcr-rest-client-0.6-SNAPSHOT-tests.jar
branches/eclipse/dna-web-jcr-rest-client/target/dna-web-jcr-rest-client-0.6-SNAPSHOT.jar
branches/eclipse/dna-web-jcr-rest-client/target/maven-archiver/
branches/eclipse/dna-web-jcr-rest-client/target/maven-archiver/pom.properties
branches/eclipse/dna-web-jcr-rest-client/target/test-classes/
branches/eclipse/dna-web-jcr-rest-client/target/test-classes/log4j.properties
branches/eclipse/dna-web-jcr-rest-client/target/test-classes/org/
branches/eclipse/dna-web-jcr-rest-client/target/test-classes/org/jboss/
branches/eclipse/dna-web-jcr-rest-client/target/test-classes/org/jboss/dna/
branches/eclipse/dna-web-jcr-rest-client/target/test-classes/org/jboss/dna/web/
branches/eclipse/dna-web-jcr-rest-client/target/test-classes/org/jboss/dna/web/jcr/
branches/eclipse/dna-web-jcr-rest-client/target/test-classes/org/jboss/dna/web/jcr/rest/
branches/eclipse/dna-web-jcr-rest-client/target/test-classes/org/jboss/dna/web/jcr/rest/client/
Log:
Initial check-in of incomplet non-UI related code.
Added: branches/eclipse/dna-web-jcr-rest-client/.classpath
===================================================================
--- branches/eclipse/dna-web-jcr-rest-client/.classpath (rev 0)
+++ branches/eclipse/dna-web-jcr-rest-client/.classpath 2009-07-14 12:59:48 UTC (rev 1111)
@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="src" path="src/main/java"/>
+ <classpathentry kind="src" path="src/main/resources"/>
+ <classpathentry kind="src" output="target/test-classes" path="src/test/java"/>
+ <classpathentry kind="src" output="target/test-classes" path="src/test/resources"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
+ <classpathentry kind="con" path="org.maven.ide.eclipse.MAVEN2_CLASSPATH_CONTAINER"/>
+ <classpathentry kind="output" path="target/classes"/>
+</classpath>
Property changes on: branches/eclipse/dna-web-jcr-rest-client/.classpath
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: branches/eclipse/dna-web-jcr-rest-client/.project
===================================================================
--- branches/eclipse/dna-web-jcr-rest-client/.project (rev 0)
+++ branches/eclipse/dna-web-jcr-rest-client/.project 2009-07-14 12:59:48 UTC (rev 1111)
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>dna-web-jcr-rest-client</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.maven.ide.eclipse.maven2Builder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ <nature>org.maven.ide.eclipse.maven2Nature</nature>
+ </natures>
+</projectDescription>
Property changes on: branches/eclipse/dna-web-jcr-rest-client/.project
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: branches/eclipse/dna-web-jcr-rest-client/pom.xml
===================================================================
--- branches/eclipse/dna-web-jcr-rest-client/pom.xml (rev 0)
+++ branches/eclipse/dna-web-jcr-rest-client/pom.xml 2009-07-14 12:59:48 UTC (rev 1111)
@@ -0,0 +1,76 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.jboss.dna</groupId>
+ <artifactId>dna</artifactId>
+ <version>0.6-SNAPSHOT</version>
+ </parent>
+ <!-- The groupId and version values are inherited from parent -->
+ <artifactId>dna-web-jcr-rest-client</artifactId>
+ <packaging>jar</packaging>
+ <name>JBoss DNA JCR REST Client</name>
+ <description>JBoss DNA JCR REST client resource publishing</description>
+ <url>http://labs.jboss.org/dna</url>
+ <!--
+ Define the dependencies. Note that all version and scopes default to those
+ defined in the dependencyManagement section of the parent pom.
+ -->
+ <dependencies>
+ <!--
+ Testing (note the scope)
+ -->
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.hamcrest</groupId>
+ <artifactId>hamcrest-library</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.mockito</groupId>
+ <artifactId>mockito-all</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <!--
+ Logging (require SLF4J API for compiling, but use Log4J and its SLF4J binding for testing)
+ -->
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-api</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-log4j12</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>log4j</groupId>
+ <artifactId>log4j</artifactId>
+ </dependency>
+ <!--
+ Java Concurrency in Practice annotations
+ -->
+ <dependency>
+ <groupId>net.jcip</groupId>
+ <artifactId>jcip-annotations</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.resteasy</groupId>
+ <artifactId>resteasy-jaxrs</artifactId>
+ <version>1.1.GA</version>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.resteasy</groupId>
+ <artifactId>resteasy-jaxb-provider</artifactId>
+ <version>1.1.GA</version>
+ </dependency>
+ </dependencies>
+ <reporting>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-report-plugin</artifactId>
+ </plugin>
+ </plugins>
+ </reporting>
+</project>
Property changes on: branches/eclipse/dna-web-jcr-rest-client/pom.xml
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/IConstants.java
===================================================================
--- branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/IConstants.java (rev 0)
+++ branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/IConstants.java 2009-07-14 12:59:48 UTC (rev 1111)
@@ -0,0 +1,76 @@
+/*
+ * JBoss DNA (http://www.jboss.org/dna)
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ * See the AUTHORS.txt file in the distribution for a full listing of
+ * individual contributors.
+ *
+ * JBoss DNA is free software. Unless otherwise indicated, all code in JBoss DNA
+ * is licensed to you under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * JBoss DNA is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.dna.web.jcr.rest.client;
+
+import java.util.ResourceBundle;
+
+/**
+ * @author Dan Florian
+ * @since 0.6
+ */
+public interface IConstants {
+
+ ResourceBundle MESSAGES = ResourceBundle.getBundle(IConstants.class.getPackage().getName() + ".Messages"); //$NON-NLS-1$
+
+ String ErrorDeletingServerRegistryFile = "ErrorDeletingServerRegistryFile"; //$NON-NLS-1$
+
+ String ErrorRestoringServerRegistry = "ErrorRestoringServerRegistry"; //$NON-NLS-1$
+
+ String ErrorSavingServerRegistry = "ErrorSavingServerRegistry"; //$NON-NLS-1$
+
+ String RepositoryEmptyNameMsg = "RepositoryEmptyNameMsg"; //$NON-NLS-1$
+
+ String RepositoryNullServerMsg = "RepositoryNullServerMsg"; //$NON-NLS-1$
+
+ String RepositoryShortDescription = "RepositoryShortDescription"; //$NON-NLS-1$
+
+ String ServerEmptyUrlMsg = "ServerEmptyUrlMsg"; //$NON-NLS-1$
+
+ String ServerInvalidUrlMsg = "ServerInvalidUrlMsg"; //$NON-NLS-1$
+
+ String ServerEmptyUserMsg = "ServerEmptyUserMsg"; //$NON-NLS-1$
+
+ String ServerExistsMsg = "ServerExistsMsg"; //$NON-NLS-1$
+
+ String ServerManagerRegistryAddUnexpectedError = "ServerManagerRegistryAddUnexpectedError"; //$NON-NLS-1$
+
+ String ServerManagerRegistryListenerError = "ServerManagerRegistryListenerError"; //$NON-NLS-1$
+
+ String ServerManagerRegistryListenerErrorsOccurred = "ServerManagerRegistryListenerErrorsOccurred"; //$NON-NLS-1$
+
+ String ServerManagerRegistryRemoveUnexpectedError = "ServerManagerRegistryRemoveUnexpectedError"; //$NON-NLS-1$
+
+ String ServerManagerRegistryUpdateAddError = "ServerManagerRegistryUpdateAddError"; //$NON-NLS-1$
+
+ String ServerManagerRegistryUpdateRemoveError = "ServerManagerRegistryUpdateRemoveError"; //$NON-NLS-1$
+
+ String ServerShortDescription = "ServerShortDescription"; //$NON-NLS-1$
+
+ String WorkspaceEmptyNameMsg = "WorkspaceEmptyNameMsg"; //$NON-NLS-1$
+
+ String WorkspaceNullRepositoryMsg = "WorkspaceNullRepositoryMsg"; //$NON-NLS-1$
+
+ String WorkspaceShortDescription = "WorkspaceShortDescription"; //$NON-NLS-1$
+
+}
Property changes on: branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/IConstants.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/IServerRegistryListener.java
===================================================================
--- branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/IServerRegistryListener.java (rev 0)
+++ branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/IServerRegistryListener.java 2009-07-14 12:59:48 UTC (rev 1111)
@@ -0,0 +1,39 @@
+/*
+ * JBoss DNA (http://www.jboss.org/dna)
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ * See the AUTHORS.txt file in the distribution for a full listing of
+ * individual contributors.
+ *
+ * JBoss DNA is free software. Unless otherwise indicated, all code in JBoss DNA
+ * is licensed to you under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * JBoss DNA is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.dna.web.jcr.rest.client;
+
+/**
+ * @author Dan Florian
+ * @since 0.6
+ */
+public interface IServerRegistryListener {
+
+ /**
+ * @param event the event being processed
+ * @return any errors caught during the processing or <code>null</code>
+ * @since 0.6
+ */
+ Exception[] serverRegistryChanged( ServerRegistryEvent event );
+
+}
Property changes on: branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/IServerRegistryListener.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/Logger.java
===================================================================
--- branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/Logger.java (rev 0)
+++ branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/Logger.java 2009-07-14 12:59:48 UTC (rev 1111)
@@ -0,0 +1,148 @@
+/*
+ * JBoss DNA (http://www.jboss.org/dna)
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ * See the AUTHORS.txt file in the distribution for a full listing of
+ * individual contributors.
+ *
+ * JBoss DNA is free software. Unless otherwise indicated, all code in JBoss DNA
+ * is licensed to you under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * JBoss DNA is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.dna.web.jcr.rest.client;
+
+import java.text.MessageFormat;
+import org.slf4j.LoggerFactory;
+
+/**
+ * @author Dan Florian
+ * @since 0.6
+ */
+public final class Logger {
+
+ // ===========================================================================================================================
+ // Class Methods
+ // ===========================================================================================================================
+
+ /**
+ * @param status the status whose message is a {@link MessageFormat} pattern.
+ * @param arguments the arguments being inserted into the pattern
+ * @return the message
+ * @since 0.6
+ */
+ private static String getMessage( Status status,
+ Object... arguments ) {
+ return MessageFormat.format(status.getMessage(), arguments);
+ }
+
+ /**
+ * @param clazz the class whose logger will be used
+ * @param status the status being logged
+ * @since 0.6
+ */
+ public static void log( Class<?> clazz,
+ Status status ) {
+ org.slf4j.Logger delegate = LoggerFactory.getLogger(clazz);
+
+ if (status.isError() && delegate.isErrorEnabled()) {
+ if (status.getException() == null) {
+ delegate.error(status.getMessage());
+ } else {
+ delegate.error(status.getMessage(), status.getException());
+ }
+ } else if (status.isWarning() && delegate.isWarnEnabled()) {
+ if (status.getException() == null) {
+ delegate.warn(status.getMessage());
+ } else {
+ delegate.warn(status.getMessage(), status.getException());
+ }
+ } else if (status.isInfo() && delegate.isInfoEnabled()) {
+ if (status.getException() == null) {
+ delegate.info(status.getMessage());
+ } else {
+ delegate.info(status.getMessage(), status.getException());
+ }
+ } else {
+ if (delegate.isTraceEnabled()) {
+ if (status.getException() == null) {
+ delegate.info(status.getMessage());
+ } else {
+ delegate.info(status.getMessage(), status.getException());
+ }
+ }
+ }
+ }
+
+ /**
+ * @param clazz the class whose logger will be used
+ * @param status the status being logged (status message is a {@link MessageFormat} pattern)
+ * @param arguments the arguments to be inserted into the pattern
+ * @since 0.6
+ */
+ public static void log( Class<?> clazz,
+ Status status,
+ Object... arguments ) {
+ org.slf4j.Logger delegate = LoggerFactory.getLogger(clazz);
+
+ if (status.isError() && delegate.isErrorEnabled()) {
+ String msg = getMessage(status, arguments);
+
+ if (status.getException() == null) {
+ delegate.error(msg);
+ } else {
+ delegate.error(msg);
+ }
+ } else if (status.isWarning() && delegate.isWarnEnabled()) {
+ String msg = getMessage(status, arguments);
+
+ if (status.getException() == null) {
+ delegate.warn(msg);
+ } else {
+ delegate.warn(msg, status.getException());
+ }
+ } else if (status.isInfo() && delegate.isInfoEnabled()) {
+ String msg = getMessage(status, arguments);
+
+ if (status.getException() == null) {
+ delegate.info(msg);
+ } else {
+ delegate.info(msg, status.getException());
+ }
+ } else {
+ if (delegate.isTraceEnabled()) {
+ String msg = getMessage(status, arguments);
+
+ if (status.getException() == null) {
+ delegate.info(msg);
+ } else {
+ delegate.info(msg, status.getException());
+ }
+ }
+ }
+ }
+
+ // ===========================================================================================================================
+ // Constructors
+ // ===========================================================================================================================
+
+ /**
+ * Don't allow construction.
+ *
+ * @since 0.6
+ */
+ private Logger() {
+ // nothing to do
+ }
+}
Property changes on: branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/Logger.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/ServerManager.java
===================================================================
--- branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/ServerManager.java (rev 0)
+++ branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/ServerManager.java 2009-07-14 12:59:48 UTC (rev 1111)
@@ -0,0 +1,543 @@
+/*
+ * JBoss DNA (http://www.jboss.org/dna)
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ * See the AUTHORS.txt file in the distribution for a full listing of
+ * individual contributors.
+ *
+ * JBoss DNA is free software. Unless otherwise indicated, all code in JBoss DNA
+ * is licensed to you under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * JBoss DNA is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.dna.web.jcr.rest.client;
+
+import java.io.File;
+import java.io.FileOutputStream;
+import java.text.MessageFormat;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.List;
+import java.util.concurrent.CopyOnWriteArrayList;
+import java.util.concurrent.locks.ReadWriteLock;
+import java.util.concurrent.locks.ReentrantReadWriteLock;
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.transform.OutputKeys;
+import javax.xml.transform.Transformer;
+import javax.xml.transform.TransformerFactory;
+import javax.xml.transform.dom.DOMSource;
+import javax.xml.transform.stream.StreamResult;
+import net.jcip.annotations.GuardedBy;
+import net.jcip.annotations.ThreadSafe;
+import org.jboss.dna.web.jcr.rest.client.Status.Severity;
+import org.jboss.dna.web.jcr.rest.client.domain.Repository;
+import org.jboss.dna.web.jcr.rest.client.domain.Server;
+import org.jboss.dna.web.jcr.rest.client.domain.Workspace;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.NamedNodeMap;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+
+/**
+ * The Server Manager class managers the creation, deletion, and editing of servers.
+ *
+ * @author Dan Florian
+ * @since 0.6
+ */
+@ThreadSafe
+public final class ServerManager implements IConstants {
+
+ // ===========================================================================================================================
+ // Constants
+ // ===========================================================================================================================
+
+ /**
+ * The tag used to persist a server's login password.
+ *
+ * @since 0.6
+ */
+ private static final String PASSWORD_TAG = "password"; //$NON-NLS-1$
+
+ /**
+ * The file name used when persisting the server registry.
+ *
+ * @since 0.6
+ */
+ private static final String REGISTRY_FILE = "serverRegistry.xml"; //$NON-NLS-1$
+
+ /**
+ * The tag used when persisting a server.
+ *
+ * @since 0.6
+ */
+ private static final String SERVER_TAG = "server"; //$NON-NLS-1$
+
+ /**
+ * The server collection tag used when persisting the server registry.
+ *
+ * @since 0.6
+ */
+ private static final String SERVERS_TAG = "servers"; //$NON-NLS-1$
+
+ /**
+ * The tag used to persist a server's URL.
+ *
+ * @since 0.6
+ */
+ private static final String URL_TAG = "url"; //$NON-NLS-1$
+
+ /**
+ * The tag used to persist a server's login user.
+ *
+ * @since 0.6
+ */
+ private static final String USER_TAG = "user"; //$NON-NLS-1$
+
+ // ===========================================================================================================================
+ // Fields
+ // ===========================================================================================================================
+
+ /**
+ * The listeners registered to receive {@link ServerRegistryEvent server registry events}.
+ *
+ * @since 0.6
+ */
+ private final CopyOnWriteArrayList<IServerRegistryListener> listeners;
+
+ /**
+ * The path where the server registry is persisted or <code>null</code> if not persisted.
+ *
+ * @since 0.6
+ */
+ private final String stateLocationPath;
+
+ /**
+ * The server registry.
+ *
+ * @since 0.6
+ */
+ @GuardedBy( "serverLock" )
+ private final List<Server> servers;
+
+ /**
+ * Lock used for when accessing the server registry.
+ *
+ * @since 0.6
+ */
+ private final ReadWriteLock serverLock = new ReentrantReadWriteLock();
+
+ // ===========================================================================================================================
+ // Constructors
+ // ===========================================================================================================================
+
+ /**
+ * @param stateLocationPath the directory where the {@link Server} registry} is persisted (may be <code>null</code> if
+ * persistence is not desired)
+ * @since 0.6
+ */
+ public ServerManager( String stateLocationPath ) {
+ this.servers = new ArrayList<Server>();
+ this.stateLocationPath = stateLocationPath;
+ this.listeners = new CopyOnWriteArrayList<IServerRegistryListener>();
+ }
+
+ // ===========================================================================================================================
+ // Methods
+ // ===========================================================================================================================
+
+ /**
+ * Listeners already registered will not be added again.
+ *
+ * @param listener the listener being register to receive events
+ * @return <code>true</code> if listener was added
+ * @since 0.6
+ */
+ public boolean addRegistryListener( IServerRegistryListener listener ) {
+ return this.listeners.addIfAbsent(listener);
+ }
+
+ /**
+ * Registers the specified <code>Server</code>.
+ *
+ * @param server the server being added
+ * @return a status indicating if the server was added to the registry
+ * @since 0.6
+ */
+ public Status addServer( Server server ) {
+ return internalAddServer(server, true);
+ }
+
+ /**
+ * @return an unmodifiable collection of registered servers (never <code>null</code>)
+ * @since 0.6
+ */
+ public Collection<Server> getServers() {
+ try {
+ this.serverLock.readLock().lock();
+ return Collections.unmodifiableCollection(new ArrayList<Server>(this.servers));
+ } finally {
+ this.serverLock.readLock().unlock();
+ }
+ }
+
+ /**
+ * @return the name of the state file that the server registry is persisted to or <code>null</code>
+ * @since 0.6
+ */
+ private String getStateFileName() {
+ String name = this.stateLocationPath;
+
+ if (this.stateLocationPath != null) {
+ name += File.separatorChar + REGISTRY_FILE;
+ }
+
+ return name;
+ }
+
+ /**
+ * @param server the server whose repositories are being requested
+ * @return the server repositories (never <code>null</code>)
+ * @since 0.6
+ */
+ public Collection<Repository> getRepositories( Server server ) {
+ try {
+ this.serverLock.readLock().lock();
+ // TODO implement getRepositories()
+ return Collections.unmodifiableCollection(new ArrayList<Repository>(/* repositories */));
+ } finally {
+ this.serverLock.readLock().unlock();
+ }
+ }
+
+ /**
+ * @param repository the repository whose workspaces are being requested
+ * @return the DNA repository workspaces (never <code>null</code>)
+ * @since 0.6
+ */
+ public Collection<Workspace> getWorkspaces( Repository repository ) {
+ try {
+ this.serverLock.readLock().lock();
+ // TODO implement getWorkspaces()
+ return Collections.unmodifiableCollection(new ArrayList<Workspace>(/* workspaces */));
+ } finally {
+ this.serverLock.readLock().unlock();
+ }
+ }
+
+ /**
+ * Registers the specified <code>Server</code>.
+ *
+ * @param server the server being added
+ * @param notifyListeners indicates if registry listeners should be notified
+ * @return a status indicating if the server was added to the registry
+ * @since 0.6
+ */
+ private Status internalAddServer( Server server,
+ boolean notifyListeners ) {
+ boolean added = false;
+
+ try {
+ this.serverLock.writeLock().lock();
+
+ if (!this.servers.contains(server)) {
+ added = this.servers.add(server);
+ }
+ } finally {
+ this.serverLock.writeLock().unlock();
+ }
+
+ if (added) {
+ if (notifyListeners) {
+ Exception[] errors = notifyRegistryListeners(ServerRegistryEvent.createNewEvent(server));
+ return processRegistryListenerErrors(errors);
+ }
+
+ return Status.OK_STATUS;
+ }
+
+ // server already exists
+ String pattern = MESSAGES.getString(ServerExistsMsg);
+ String msg = MessageFormat.format(pattern, server.getShortDescription());
+ Status status = new Status(Severity.ERROR, msg, null);
+ return status;
+ }
+
+ /**
+ * @param server the server being removed
+ * @param notifyListeners indicates if registry listeners should be notified
+ * @return a status indicating if the specified server was removed from the registry
+ * @since 0.6
+ */
+ private Status internalRemoveServer( Server server,
+ boolean notifyListeners ) {
+ boolean removed = false;
+
+ try {
+ this.serverLock.writeLock().lock();
+ removed = this.servers.remove(server);
+ } finally {
+ this.serverLock.writeLock().unlock();
+ }
+
+ if (removed) {
+ if (notifyListeners) {
+ Exception[] errors = notifyRegistryListeners(ServerRegistryEvent.createNewEvent(server));
+ return processRegistryListenerErrors(errors);
+ }
+
+ return Status.OK_STATUS;
+ }
+
+ // server could not be removed
+ String pattern = MESSAGES.getString(ServerManagerRegistryRemoveUnexpectedError);
+ String msg = MessageFormat.format(pattern, server.getShortDescription());
+ Status status = new Status(Severity.ERROR, msg, null);
+ return status;
+ }
+
+ /**
+ * @param server the server being tested
+ * @return <code>true</code> if the server has been registered
+ * @since 0.6
+ */
+ public boolean isRegistered( Server server ) {
+ try {
+ this.serverLock.readLock().lock();
+ return this.servers.contains(server);
+ } finally {
+ this.serverLock.readLock().unlock();
+ }
+ }
+
+ /**
+ * @param event the event the registry listeners are to process
+ * @return any errors thrown by or found by the listeners or <code>null</code> (never empty)
+ * @since 0.6
+ */
+ private Exception[] notifyRegistryListeners( ServerRegistryEvent event ) {
+ Collection<Exception> errors = null;
+
+ for (IServerRegistryListener l : this.listeners) {
+ try {
+ Exception[] problems = l.serverRegistryChanged(event);
+
+ if ((problems != null) && (problems.length != 0)) {
+ if (errors == null) {
+ errors = new ArrayList<Exception>();
+ }
+
+ errors.addAll(Arrays.asList(problems));
+ }
+ } catch (Exception e) {
+ if (errors == null) {
+ errors = new ArrayList<Exception>();
+ }
+
+ errors.add(e);
+ }
+ }
+
+ if ((errors != null) && !errors.isEmpty()) {
+ return errors.toArray(new Exception[errors.size()]);
+ }
+
+ return null;
+ }
+
+ /**
+ * @param errors the errors reported by the registry listeners
+ * @return a status indicating if registry listeners reported any errors
+ * @since 0.6
+ */
+ private Status processRegistryListenerErrors( Exception[] errors ) {
+ if (errors == null) {
+ return Status.OK_STATUS;
+ }
+
+ for (Exception error : errors) {
+ Logger.log(getClass(), new Status(Severity.ERROR, ServerManagerRegistryListenerError, error));
+ }
+
+ return new Status(Severity.WARNING, ServerManagerRegistryListenerErrorsOccurred, null);
+ }
+
+ /**
+ * @param listener the listener being unregistered and will no longer receive events
+ * @return <code>true</code> if listener was removed
+ * @since 0.6
+ */
+ public boolean removeRegistryListener( IServerRegistryListener listener ) {
+ return this.listeners.remove(listener);
+ }
+
+ /**
+ * @param server the server being removed
+ * @return a status indicating if the specified server was removed from the registry
+ * @since 0.6
+ */
+ public Status removeServer( Server server ) {
+ return internalRemoveServer(server, true);
+ }
+
+ /**
+ * @return a status indicating if the previous session state was restored successfully
+ * @since 0.6
+ */
+ public Status restoreState() {
+ if (this.stateLocationPath != null) {
+ if (stateFileExists()) {
+ try {
+ DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
+ DocumentBuilder docBuilder = factory.newDocumentBuilder();
+ Document doc = docBuilder.parse(new File(getStateFileName()));
+ Node root = doc.getDocumentElement();
+ NodeList servers = root.getChildNodes();
+
+ for (int size = servers.getLength(), i = 0; i < size; ++i) {
+ Node server = servers.item(i);
+
+ if (server.getNodeType() != Node.TEXT_NODE) {
+ NamedNodeMap attributeMap = server.getAttributes();
+
+ if (attributeMap == null) continue;
+
+ Node urlNode = attributeMap.getNamedItem(URL_TAG);
+ Node userNode = attributeMap.getNamedItem(USER_TAG);
+ Node passwordNode = attributeMap.getNamedItem(PASSWORD_TAG);
+ String pswd = ((passwordNode == null) ? null : (String)passwordNode.getNodeValue());
+
+ // add server to registry
+ addServer(new Server(urlNode.getNodeValue(), userNode.getNodeValue(), pswd, (pswd != null)));
+ }
+ }
+ } catch (Exception e) {
+ String pattern = MESSAGES.getString(ErrorRestoringServerRegistry);
+ return new Status(Severity.ERROR, MessageFormat.format(pattern, getStateFileName()), e);
+ }
+ }
+ }
+
+ // do nothing of there is no save location or state file does not exist
+ return Status.OK_STATUS;
+ }
+
+ /**
+ * Saves the {@link Server} registry to the file system.
+ *
+ * @return a status indicating if the registry was successfully saved
+ * @since 0.6
+ */
+ public Status saveState() {
+ if ((this.stateLocationPath != null) && !getServers().isEmpty()) {
+ try {
+ DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
+ DocumentBuilder docBuilder = factory.newDocumentBuilder();
+ Document doc = docBuilder.newDocument();
+
+ // create root element
+ Element root = doc.createElement(SERVERS_TAG);
+ doc.appendChild(root);
+
+ for (Server server : getServers()) {
+ Element serverElement = doc.createElement(SERVER_TAG);
+ root.appendChild(serverElement);
+
+ serverElement.setAttribute(URL_TAG, server.getUrl());
+ serverElement.setAttribute(USER_TAG, server.getUser());
+
+ if (server.isPasswordBeingPersisted()) {
+ serverElement.setAttribute(PASSWORD_TAG, server.getPassword());
+ }
+ }
+
+ DOMSource source = new DOMSource(doc);
+ StreamResult resultXML = new StreamResult(new FileOutputStream(getStateFileName()));
+ TransformerFactory transFactory = TransformerFactory.newInstance();
+ Transformer transformer = transFactory.newTransformer();
+ transformer.setOutputProperty(OutputKeys.INDENT, "yes"); //$NON-NLS-1$
+ transformer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "2"); //$NON-NLS-1$ //$NON-NLS-2$
+ transformer.transform(source, resultXML);
+ } catch (Exception e) {
+ String pattern = MESSAGES.getString(ErrorSavingServerRegistry);
+ return new Status(Severity.ERROR, MessageFormat.format(pattern, getStateFileName()), e);
+ }
+ } else if ((this.stateLocationPath != null) && stateFileExists()) {
+ // delete current registry file since all servers have been deleted
+ try {
+ new File(getStateFileName()).delete();
+ } catch (Exception e) {
+ String pattern = MESSAGES.getString(ErrorDeletingServerRegistryFile);
+ return new Status(Severity.ERROR, MessageFormat.format(pattern, getStateFileName()), e);
+ }
+ }
+
+ return Status.OK_STATUS;
+ }
+
+ /**
+ * @return <code>true</code> if the state file already exists
+ * @since 0.6
+ */
+ private boolean stateFileExists() {
+ return new File(getStateFileName()).exists();
+ }
+
+ /**
+ * Updates the server registry with a new version of a server.
+ *
+ * @param previousServerVersion the version of the server being replaced
+ * @param newServerVersion the new version of the server being put in the server registry
+ * @return a status indicating if the server was updated in the registry
+ * @since 0.6
+ */
+ public Status updateServer( Server previousServerVersion,
+ Server newServerVersion ) {
+ Status status = null;
+
+ try {
+ this.serverLock.writeLock().lock();
+ status = internalRemoveServer(previousServerVersion, false);
+
+ if (status.isOk()) {
+ status = internalAddServer(newServerVersion, false);
+
+ if (status.isOk()) {
+ // all good so notify listeners
+ Exception[] errors = notifyRegistryListeners(ServerRegistryEvent.createUpdateEvent(previousServerVersion,
+ newServerVersion));
+ return processRegistryListenerErrors(errors);
+ }
+
+ // unexpected problem adding new version of server to registry
+ String pattern = MESSAGES.getString(ServerManagerRegistryUpdateAddError);
+ String msg = MessageFormat.format(pattern, status.getMessage());
+ status = new Status(Severity.ERROR, msg, status.getException());
+ return status;
+ }
+ } finally {
+ this.serverLock.writeLock().unlock();
+ }
+
+ // unexpected problem removing server from registry
+ String pattern = MESSAGES.getString(ServerManagerRegistryUpdateRemoveError);
+ String msg = MessageFormat.format(pattern, status.getMessage());
+ status = new Status(Severity.ERROR, msg, status.getException());
+ return status;
+ }
+
+}
Property changes on: branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/ServerManager.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/ServerRegistryEvent.java
===================================================================
--- branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/ServerRegistryEvent.java (rev 0)
+++ branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/ServerRegistryEvent.java 2009-07-14 12:59:48 UTC (rev 1111)
@@ -0,0 +1,197 @@
+/*
+ * JBoss DNA (http://www.jboss.org/dna)
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ * See the AUTHORS.txt file in the distribution for a full listing of
+ * individual contributors.
+ *
+ * JBoss DNA is free software. Unless otherwise indicated, all code in JBoss DNA
+ * is licensed to you under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * JBoss DNA is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.dna.web.jcr.rest.client;
+
+import org.jboss.dna.web.jcr.rest.client.domain.Server;
+
+/**
+ * @author Dan Florian
+ * @since 0.6
+ */
+public final class ServerRegistryEvent {
+
+ // ===========================================================================================================================
+ // Constants
+ // ===========================================================================================================================
+
+ /**
+ * The status severity levels.
+ *
+ * @since 0.6
+ */
+ public enum Type {
+ /**
+ * Indicates that a new server was added to the server registry.
+ *
+ * @since 0.6
+ */
+ NEW,
+
+ /**
+ * Indicates that a server was removed from the server registry.
+ *
+ * @since 0.6
+ */
+ REMOVE,
+
+ /**
+ * Indicates that properties of an existing server in the registry has been changed.
+ *
+ * @since 0.6
+ */
+ UPDATE
+ }
+
+ // ===========================================================================================================================
+ // Class Methods
+ // ===========================================================================================================================
+
+ /**
+ * @param newServer the server that was added to the server registry
+ * @return the event
+ * @see Type#NEW
+ * @since 0.6
+ */
+ public static ServerRegistryEvent createNewEvent( Server newServer ) {
+ return new ServerRegistryEvent(Type.NEW, newServer);
+ }
+
+ /**
+ * @param removedServer the server removed from the server registry
+ * @return the event
+ * @see Type#REMOVE
+ * @since 0.6
+ */
+ public static ServerRegistryEvent createRemoveEvent( Server removedServer ) {
+ return new ServerRegistryEvent(Type.REMOVE, removedServer);
+ }
+
+ /**
+ * @param previousServerVersion the server being updated (this instance is no longer found in the server registry)
+ * @param newServerVersion the updated version of the server (this is now contained in the server registry)
+ * @return the event
+ * @see Type#UPDATE
+ * @since 0.6
+ */
+ public static ServerRegistryEvent createUpdateEvent( Server previousServerVersion,
+ Server newServerVersion ) {
+ ServerRegistryEvent event = new ServerRegistryEvent(Type.UPDATE, previousServerVersion);
+ event.updatedServer = newServerVersion;
+ return event;
+ }
+
+ // ===========================================================================================================================
+ // Fields
+ // ===========================================================================================================================
+
+ /**
+ * The server being added, removed, or updated.
+ *
+ * @since 0.6
+ */
+ private final Server server;
+
+ /**
+ * The event type.
+ *
+ * @since 0.6
+ */
+ private final Type type;
+
+ /**
+ * The server that is replacing an existing server. Will be <code>null</code> for all types except {@link Type#UPDATE update}.
+ *
+ * @since 0.6
+ */
+ private Server updatedServer;
+
+ // ===========================================================================================================================
+ // Constructors
+ // ===========================================================================================================================
+
+ /**
+ * @param type the event type
+ * @param server the server being added, removed, or updated
+ * @since 0.6
+ */
+ private ServerRegistryEvent( Type type,
+ Server server ) {
+ this.type = type;
+ this.server = server;
+ }
+
+ // ===========================================================================================================================
+ // Methods
+ // ===========================================================================================================================
+
+ /**
+ * @return the added, removed, or the old version of the server that has been updated
+ * @since 0.6
+ */
+ public Server getServer() {
+ return this.server;
+ }
+
+ /**
+ * @return the new version of an existing server that has been updated
+ * @throws UnsupportedOperationException if method is called when the type is not an update
+ * @see Type#UPDATE
+ * @since 0.6
+ */
+ public Server getUpdatedServer() {
+ if (this.type != Type.UPDATE) {
+ throw new UnsupportedOperationException();
+ }
+
+ return this.updatedServer;
+ }
+
+ /**
+ * @return <code>true</code> if the event is adding a new server to the registry
+ * @see Type#NEW
+ * @since 0.6
+ */
+ public boolean isNew() {
+ return (this.type == Type.NEW);
+ }
+
+ /**
+ * @return <code>true</code> if the event is removing a server from the registry
+ * @see Type#REMOVE
+ * @since 0.6
+ */
+ public boolean isRemove() {
+ return (this.type == Type.REMOVE);
+ }
+
+ /**
+ * @return <code>true</code> if the event is updating properties of an existing server in the registry
+ * @see Type#UPDATE
+ * @since 0.6
+ */
+ public boolean isUpdate() {
+ return (this.type == Type.UPDATE);
+ }
+
+}
Property changes on: branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/ServerRegistryEvent.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/Status.java
===================================================================
--- branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/Status.java (rev 0)
+++ branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/Status.java 2009-07-14 12:59:48 UTC (rev 1111)
@@ -0,0 +1,209 @@
+/*
+ * JBoss DNA (http://www.jboss.org/dna)
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ * See the AUTHORS.txt file in the distribution for a full listing of
+ * individual contributors.
+ *
+ * JBoss DNA is free software. Unless otherwise indicated, all code in JBoss DNA
+ * is licensed to you under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * JBoss DNA is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.dna.web.jcr.rest.client;
+
+import net.jcip.annotations.Immutable;
+
+/**
+ * @author Dan Florian
+ * @since 0.6
+ */
+@Immutable
+public class Status {
+
+ // ===========================================================================================================================
+ // Constants
+ // ===========================================================================================================================
+
+ /**
+ * The status severity levels.
+ *
+ * @since 0.6
+ */
+ public enum Severity {
+ /**
+ * Indicates an error status.
+ *
+ * @since 0.6
+ */
+ ERROR,
+
+ /**
+ * Indicates an informational status.
+ *
+ * @since 0.6
+ */
+ INFO,
+
+ /**
+ * Indicates an OK status.
+ *
+ * @since 0.6
+ */
+ OK,
+
+ /**
+ * Indicates an unknown status. This is automatically assigned if status is constructed with a <code>null</code> severity.
+ *
+ * @since 0.6
+ */
+ UNKNOWN,
+
+ /**
+ * Indicates a warning status.
+ *
+ * @since 0.6
+ */
+ WARNING
+ }
+
+ /**
+ * A status with an OK severity and no message and no exception.
+ *
+ * @see Severity#OK
+ * @since 0.6
+ */
+ public static final Status OK_STATUS = new Status(Severity.OK, null, null);
+
+ // ===========================================================================================================================
+ // Fields
+ // ===========================================================================================================================
+
+ /**
+ * The exception of this status or <code>null</code>.
+ *
+ * @since 0.6
+ */
+ protected final Throwable exception;
+
+ /**
+ * The localized message of this status (can be <code>null</code>).
+ *
+ * @since 0.6
+ */
+ protected final String message;
+
+ /**
+ * The severity level of this status.
+ *
+ * @since 0.6
+ */
+ protected final Severity severity;
+
+ // ===========================================================================================================================
+ // Constructors
+ // ===========================================================================================================================
+
+ /**
+ * @param severity the status severity (if <code>null</code> it will be converted to {@link Severity#UNKNOWN}.
+ * @param message the status message (if <code>null</code> it will be returned as an empty string)
+ * @param exception the status exception or <code>null</code>
+ * @since 0.6
+ */
+ public Status( Severity severity,
+ String message,
+ Throwable exception ) {
+ this.severity = ((severity == null) ? Severity.UNKNOWN : severity);
+ this.message = message;
+ this.exception = exception;
+ }
+
+ // ===========================================================================================================================
+ // Methods
+ // ===========================================================================================================================
+
+ /**
+ * @return the status exception (may be <code>null</code>)
+ * @since 0.6
+ */
+ public Throwable getException() {
+ return this.exception;
+ }
+
+ /**
+ * @return the status message (never <code>null</code> but can be empty)
+ * @since 0.6
+ */
+ public String getMessage() {
+ return ((this.message == null) ? "" : this.message); //$NON-NLS-1$
+ }
+
+ /**
+ * @return severity the status severity
+ * @since 0.6
+ */
+ public Severity getSeverity() {
+ return severity;
+ }
+
+ /**
+ * @return <code>true</code> if the status is an error
+ * @see Severity#ERROR
+ * @since 0.6
+ */
+ public boolean isError() {
+ return (this.severity == Severity.ERROR);
+ }
+
+ /**
+ * @return <code>true</code> if the status is an info
+ * @see Severity#INFO
+ * @since 0.6
+ */
+ public boolean isInfo() {
+ return (this.severity == Severity.INFO);
+ }
+
+ /**
+ * @return <code>true</code> if the status is OK
+ * @see Severity#OK
+ * @since 0.6
+ */
+ public boolean isOk() {
+ return (this.severity == Severity.OK);
+ }
+
+ /**
+ * @return <code>true</code> if the status is a warning
+ * @see Severity#WARNING
+ * @since 0.6
+ */
+ public boolean isWarning() {
+ return (this.severity == Severity.WARNING);
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see java.lang.Object#toString()
+ * @since 0.6
+ */
+ @Override
+ public String toString() {
+ StringBuilder txt = new StringBuilder("Status "); //$NON-NLS-1$
+ txt.append(this.severity.toString()).append(": ").append(getMessage()).append(": ").append(getException()); //$NON-NLS-1$ //$NON-NLS-2$
+ return txt.toString();
+ }
+
+}
Property changes on: branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/Status.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/Utils.java
===================================================================
--- branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/Utils.java (rev 0)
+++ branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/Utils.java 2009-07-14 12:59:48 UTC (rev 1111)
@@ -0,0 +1,66 @@
+/*
+ * JBoss DNA (http://www.jboss.org/dna)
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ * See the AUTHORS.txt file in the distribution for a full listing of
+ * individual contributors.
+ *
+ * JBoss DNA is free software. Unless otherwise indicated, all code in JBoss DNA
+ * is licensed to you under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * JBoss DNA is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.dna.web.jcr.rest.client;
+
+/**
+ * @author Dan Florian
+ * @since 0.6
+ */
+public final class Utils {
+
+ // ===========================================================================================================================
+ // Class Methods
+ // ===========================================================================================================================
+
+ /**
+ * @param thisObj an object being compared
+ * @param thatObj the other object being compared
+ * @return <code>true</code> if both objects are null or both are not null and equal
+ * @since 0.6
+ */
+ public static boolean equivalent( Object thisObj,
+ Object thatObj ) {
+ // true if both objects are null
+ if (thisObj == null) {
+ return (thatObj == null);
+ }
+
+ if (thatObj == null) return false;
+ return thisObj.equals(thatObj);
+ }
+
+ // ===========================================================================================================================
+ // Constructors
+ // ===========================================================================================================================
+
+ /**
+ * Don't allow construction.
+ *
+ * @since 0.6
+ */
+ public Utils() {
+ // nothing to do
+ }
+
+}
Property changes on: branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/Utils.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/domain/IDnaObject.java
===================================================================
--- branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/domain/IDnaObject.java (rev 0)
+++ branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/domain/IDnaObject.java 2009-07-14 12:59:48 UTC (rev 1111)
@@ -0,0 +1,46 @@
+/*
+ * JBoss DNA (http://www.jboss.org/dna)
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ * See the AUTHORS.txt file in the distribution for a full listing of
+ * individual contributors.
+ *
+ * JBoss DNA is free software. Unless otherwise indicated, all code in JBoss DNA
+ * is licensed to you under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * JBoss DNA is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.dna.web.jcr.rest.client.domain;
+
+/**
+ * The IDnaObject class defines a business object.
+ *
+ * @author Dan Florian
+ * @since 0.6
+ */
+public interface IDnaObject {
+
+ /**
+ * @return the object name (never <code>null</code>)
+ * @since 0.6
+ */
+ String getName();
+
+ /**
+ * @return a description suitable for use in a tooltip (never <code>null</code>)
+ * @since 0.6
+ */
+ String getShortDescription();
+
+}
Property changes on: branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/domain/IDnaObject.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/domain/Repository.java
===================================================================
--- branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/domain/Repository.java (rev 0)
+++ branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/domain/Repository.java 2009-07-14 12:59:48 UTC (rev 1111)
@@ -0,0 +1,151 @@
+/*
+ * JBoss DNA (http://www.jboss.org/dna)
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ * See the AUTHORS.txt file in the distribution for a full listing of
+ * individual contributors.
+ *
+ * JBoss DNA is free software. Unless otherwise indicated, all code in JBoss DNA
+ * is licensed to you under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * JBoss DNA is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.dna.web.jcr.rest.client.domain;
+
+import java.text.MessageFormat;
+import net.jcip.annotations.Immutable;
+import org.jboss.dna.web.jcr.rest.client.IConstants;
+import org.jboss.dna.web.jcr.rest.client.Status;
+import org.jboss.dna.web.jcr.rest.client.domain.validation.RepositoryValidator;
+
+/**
+ * The Repository class is the business object for a DNA repository.
+ *
+ * @author Dan Florian
+ * @since 0.6
+ */
+@Immutable
+public final class Repository implements IConstants, IDnaObject {
+
+ // ===========================================================================================================================
+ // Fields
+ // ===========================================================================================================================
+
+ /**
+ * The repository name.
+ *
+ * @since 0.6
+ */
+ private final String name;
+
+ /**
+ * The server where this repository resides.
+ *
+ * @since 0.6
+ */
+ private final Server server;
+
+ // TODO root publishing path
+
+ // ===========================================================================================================================
+ // Constructors
+ // ===========================================================================================================================
+
+ /**
+ * Constructs a new <code>Repository</code>.
+ *
+ * @param name the repository name
+ * @param server the server where this repository resides
+ * @see RepositoryValidator
+ * @throws RuntimeException if any of the input parameters are invalid
+ * @since 0.6
+ */
+ public Repository( String name,
+ Server server ) {
+ // validate inputs
+ Status status = RepositoryValidator.isValid(name, server);
+
+ if (status.isError()) {
+ throw new RuntimeException(status.getMessage(), status.getException());
+ }
+
+ // valid so construct
+ this.name = name;
+ this.server = server;
+ }
+
+ // ===========================================================================================================================
+ // Methods
+ // ===========================================================================================================================
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see java.lang.Object#equals(java.lang.Object)
+ * @since 0.6
+ */
+ @Override
+ public boolean equals( Object obj ) {
+ if (this == obj) return true;
+ if ((obj == null) || (getClass() != obj.getClass())) return false;
+
+ // must have another server
+ Repository otherRepository = (Repository)obj;
+ return (this.name.equals(otherRepository.name) && this.server.equals(otherRepository.server));
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.jboss.dna.web.jcr.rest.client.domain.IDnaObject#getName()
+ * @since 0.6
+ */
+ public String getName() {
+ return this.name;
+ }
+
+ /**
+ * @return the server where this repository is located (never <code>null</code>)
+ * @since 0.6
+ */
+ public Server getServer() {
+ return this.server;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.jboss.dna.web.jcr.rest.client.domain.IDnaObject#getShortDescription()
+ * @since 0.6
+ */
+ public String getShortDescription() {
+ String pattern = MESSAGES.getString(RepositoryShortDescription);
+ return MessageFormat.format(pattern, this.name, this.server.getShortDescription());
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see java.lang.Object#hashCode()
+ * @since 0.6
+ */
+ @Override
+ public int hashCode() {
+ int hash = 7;
+ hash = 31 * hash + this.name.hashCode();
+ hash = 31 * hash + this.server.hashCode();
+ return hash;
+ }
+
+}
Property changes on: branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/domain/Repository.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/domain/Server.java
===================================================================
--- branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/domain/Server.java (rev 0)
+++ branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/domain/Server.java 2009-07-14 12:59:48 UTC (rev 1111)
@@ -0,0 +1,207 @@
+/*
+ * JBoss DNA (http://www.jboss.org/dna)
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ * See the AUTHORS.txt file in the distribution for a full listing of
+ * individual contributors.
+ *
+ * JBoss DNA is free software. Unless otherwise indicated, all code in JBoss DNA
+ * is licensed to you under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * JBoss DNA is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.dna.web.jcr.rest.client.domain;
+
+import java.text.MessageFormat;
+import net.jcip.annotations.Immutable;
+import org.jboss.dna.web.jcr.rest.client.IConstants;
+import org.jboss.dna.web.jcr.rest.client.Status;
+import org.jboss.dna.web.jcr.rest.client.Utils;
+import org.jboss.dna.web.jcr.rest.client.domain.validation.RepositoryValidator;
+import org.jboss.dna.web.jcr.rest.client.domain.validation.ServerValidator;
+
+/**
+ * The Server class is the business object for a server that is hosting one or more DNA repositories.
+ *
+ * @author Dan Florian
+ * @since 0.6
+ */
+@Immutable
+public final class Server implements IConstants, IDnaObject {
+
+ // ===========================================================================================================================
+ // Fields
+ // ===========================================================================================================================
+
+ /**
+ * The password to use when logging on to the server.
+ *
+ * @since 0.6
+ */
+ private final String password;
+
+ /**
+ * Indicates if the password should be stored locally when the server is persisted.
+ *
+ * @since 0.6
+ */
+ private final boolean persistPassword;
+
+ /**
+ * The server URL.
+ *
+ * @since 0.6
+ */
+ private final String url;
+
+ /**
+ * The user name to use when logging on to the server.
+ *
+ * @since 0.6
+ */
+ private final String user;
+
+ // ===========================================================================================================================
+ // Constructors
+ // ===========================================================================================================================
+
+ /**
+ * Constructs on new <code>Server</code>.
+ *
+ * @param url the server URL
+ * @param user the server user
+ * @param password the server password
+ * @param persistPassword <code>true</code> if the password should be stored
+ * @see RepositoryValidator
+ * @throws RuntimeException if any of the input parameters are invalid
+ * @since 0.6
+ */
+ public Server( String url,
+ String user,
+ String password,
+ boolean persistPassword ) {
+ // valid inputs
+ Status status = ServerValidator.isValid(url, user, password, persistPassword);
+
+ if (status.isError()) {
+ throw new RuntimeException(status.getMessage(), status.getException());
+ }
+
+ // valid so construct
+ this.url = url;
+ this.user = user;
+ this.password = password;
+ this.persistPassword = persistPassword;
+ }
+
+ // ===========================================================================================================================
+ // Methods
+ // ===========================================================================================================================
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see java.lang.Object#equals(java.lang.Object)
+ * @since 0.6
+ */
+ @Override
+ public boolean equals( Object obj ) {
+ if (this == obj) return true;
+ if ((obj == null) || (getClass() != obj.getClass())) return false;
+
+ // must have another server
+ Server otherServer = (Server)obj;
+ return Utils.equivalent(this.url, otherServer.url) && Utils.equivalent(this.user, otherServer.user)
+ && Utils.equivalent(this.password, otherServer.password)
+ && Utils.equivalent(this.persistPassword, otherServer.persistPassword);
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.jboss.dna.web.jcr.rest.client.domain.IDnaObject#getName()
+ * @since 0.6
+ */
+ public String getName() {
+ return getUrl();
+ }
+
+ /**
+ * @return the server authentication password
+ * @since 0.6
+ */
+ public String getPassword() {
+ return this.password;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.jboss.dna.web.jcr.rest.client.domain.IDnaObject#getShortDescription()
+ * @since 0.6
+ */
+ public String getShortDescription() {
+ String pattern = MESSAGES.getString(ServerShortDescription);
+ return MessageFormat.format(pattern, this.url, this.user);
+ }
+
+ /**
+ * @return the server URL
+ * @since 0.6
+ */
+ public String getUrl() {
+ return this.url;
+ }
+
+ /**
+ * @return the server authentication user
+ * @since 0.6
+ */
+ public String getUser() {
+ return this.user;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see java.lang.Object#hashCode()
+ * @since 0.6
+ */
+ @Override
+ public int hashCode() {
+ int hash = 7;
+ hash = 31 * hash + this.url.hashCode();
+
+ if (this.user != null) {
+ hash = 31 * hash + this.user.hashCode();
+ }
+
+ if (this.password != null) {
+ hash = 31 * hash + this.password.hashCode();
+ }
+
+ hash = 31 * hash + Boolean.valueOf(this.persistPassword).hashCode();
+
+ return hash;
+ }
+
+ /**
+ * @return persistPassword <code>true</code> if the password is being persisted
+ * @since 0.6
+ */
+ public boolean isPasswordBeingPersisted() {
+ return this.persistPassword;
+ }
+
+}
Property changes on: branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/domain/Server.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/domain/Workspace.java
===================================================================
--- branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/domain/Workspace.java (rev 0)
+++ branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/domain/Workspace.java 2009-07-14 12:59:48 UTC (rev 1111)
@@ -0,0 +1,157 @@
+/*
+ * JBoss DNA (http://www.jboss.org/dna)
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ * See the AUTHORS.txt file in the distribution for a full listing of
+ * individual contributors.
+ *
+ * JBoss DNA is free software. Unless otherwise indicated, all code in JBoss DNA
+ * is licensed to you under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * JBoss DNA is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.dna.web.jcr.rest.client.domain;
+
+import java.text.MessageFormat;
+import net.jcip.annotations.Immutable;
+import org.jboss.dna.web.jcr.rest.client.IConstants;
+import org.jboss.dna.web.jcr.rest.client.Status;
+import org.jboss.dna.web.jcr.rest.client.domain.validation.WorkspaceValidator;
+
+/**
+ * The Workspace class is the business object for a DNA repository workspace.
+ *
+ * @author Dan Florian
+ * @since 0.6
+ */
+@Immutable
+public final class Workspace implements IConstants, IDnaObject {
+
+ // ===========================================================================================================================
+ // Fields
+ // ===========================================================================================================================
+
+ /**
+ * The workspace name.
+ *
+ * @since 0.6
+ */
+ private final String name;
+
+ /**
+ * The repository where this workspace resides.
+ *
+ * @since 0.6
+ */
+ private final Repository repository;
+
+ // ===========================================================================================================================
+ // Constructors
+ // ===========================================================================================================================
+
+ /**
+ * Constructs a new <code>Workspace</code>.
+ *
+ * @param name the workspace name
+ * @param repository the repository where this workspace resides
+ * @see WorkspaceValidator
+ * @throws RuntimeException if any of the input parameters are invalid
+ * @since 0.6
+ */
+ public Workspace( String name,
+ Repository repository ) {
+ // validate inputs
+ Status status = WorkspaceValidator.isValid(name, repository);
+
+ if (status.isError()) {
+ throw new RuntimeException(status.getMessage(), status.getException());
+ }
+
+ // valid so construct
+ this.name = name;
+ this.repository = repository;
+ }
+
+ // ===========================================================================================================================
+ // Methods
+ // ===========================================================================================================================
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see java.lang.Object#equals(java.lang.Object)
+ * @since 0.6
+ */
+ @Override
+ public boolean equals( Object obj ) {
+ if (this == obj) return true;
+ if ((obj == null) || (getClass() != obj.getClass())) return false;
+
+ // must have another server
+ Workspace otherWorkspace = (Workspace)obj;
+ return (this.name.equals(otherWorkspace.name) && this.repository.equals(otherWorkspace.repository));
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.jboss.dna.web.jcr.rest.client.domain.IDnaObject#getName()
+ * @since 0.6
+ */
+ public String getName() {
+ return this.name;
+ }
+
+ /**
+ * @return the repository where this workspace is located (never <code>null</code>)
+ * @since 0.6
+ */
+ public Repository getRepository() {
+ return this.repository;
+ }
+
+ /**
+ * @return the server where this workspace is located (never <code>null</code>)
+ * @since 0.6
+ */
+ public Server getServer() {
+ return this.repository.getServer();
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.jboss.dna.web.jcr.rest.client.domain.IDnaObject#getShortDescription()
+ * @since 0.6
+ */
+ public String getShortDescription() {
+ String pattern = MESSAGES.getString(WorkspaceShortDescription);
+ return MessageFormat.format(pattern, this.name, this.repository.getShortDescription());
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see java.lang.Object#hashCode()
+ * @since 0.6
+ */
+ @Override
+ public int hashCode() {
+ int hash = 7;
+ hash = 31 * hash + this.name.hashCode();
+ hash = 31 * hash + this.repository.hashCode();
+ return hash;
+ }
+
+}
Property changes on: branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/domain/Workspace.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/domain/validation/RepositoryValidator.java
===================================================================
--- branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/domain/validation/RepositoryValidator.java (rev 0)
+++ branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/domain/validation/RepositoryValidator.java 2009-07-14 12:59:48 UTC (rev 1111)
@@ -0,0 +1,97 @@
+/*
+ * JBoss DNA (http://www.jboss.org/dna)
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ * See the AUTHORS.txt file in the distribution for a full listing of
+ * individual contributors.
+ *
+ * JBoss DNA is free software. Unless otherwise indicated, all code in JBoss DNA
+ * is licensed to you under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * JBoss DNA is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.dna.web.jcr.rest.client.domain.validation;
+
+import org.jboss.dna.web.jcr.rest.client.IConstants;
+import org.jboss.dna.web.jcr.rest.client.Status;
+import org.jboss.dna.web.jcr.rest.client.Status.Severity;
+import org.jboss.dna.web.jcr.rest.client.domain.Server;
+
+/**
+ * @author Dan Florian
+ * @since 0.6
+ */
+public final class RepositoryValidator implements IConstants {
+
+ // ===========================================================================================================================
+ // Class Methods
+ // ===========================================================================================================================
+
+ /**
+ * @param name the name being validated
+ * @return a validation status (never <code>null</code>)
+ * @since 0.6
+ */
+ public static Status isNameValid( String name ) {
+ if ((name == null) || (name.length() == 0)) {
+ return new Status(Severity.ERROR, MESSAGES.getString(RepositoryEmptyNameMsg), null);
+ }
+
+ return Status.OK_STATUS;
+ }
+
+ /**
+ * @param server the server being validated
+ * @return a validation status (never <code>null</code>)
+ * @since 0.6
+ */
+ public static Status isServerValid( Server server ) {
+ if (server == null) {
+ return new Status(Severity.ERROR, MESSAGES.getString(RepositoryNullServerMsg), null);
+ }
+
+ return Status.OK_STATUS;
+ }
+
+ /**
+ * @param name the name being validated
+ * @param server the server being validated
+ * @return a validation status (never <code>null</code>)
+ * @since 0.6
+ */
+ public static Status isValid( String name,
+ Server server ) {
+ Status status = isNameValid(name);
+
+ if (!status.isError()) {
+ status = isServerValid(server);
+ }
+
+ return status;
+ }
+
+ // ===========================================================================================================================
+ // Constructors
+ // ===========================================================================================================================
+
+ /**
+ * Disallow construction.
+ *
+ * @since 0.6
+ */
+ private RepositoryValidator() {
+ // nothing to do
+ }
+
+}
Property changes on: branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/domain/validation/RepositoryValidator.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/domain/validation/ServerValidator.java
===================================================================
--- branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/domain/validation/ServerValidator.java (rev 0)
+++ branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/domain/validation/ServerValidator.java 2009-07-14 12:59:48 UTC (rev 1111)
@@ -0,0 +1,161 @@
+/*
+ * JBoss DNA (http://www.jboss.org/dna)
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ * See the AUTHORS.txt file in the distribution for a full listing of
+ * individual contributors.
+ *
+ * JBoss DNA is free software. Unless otherwise indicated, all code in JBoss DNA
+ * is licensed to you under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * JBoss DNA is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.dna.web.jcr.rest.client.domain.validation;
+
+import java.net.URL;
+import java.text.MessageFormat;
+import org.jboss.dna.web.jcr.rest.client.IConstants;
+import org.jboss.dna.web.jcr.rest.client.ServerManager;
+import org.jboss.dna.web.jcr.rest.client.Status;
+import org.jboss.dna.web.jcr.rest.client.Status.Severity;
+import org.jboss.dna.web.jcr.rest.client.domain.Server;
+
+/**
+ * @author Dan Florian
+ * @since 0.6
+ */
+public final class ServerValidator implements IConstants {
+
+ // ===========================================================================================================================
+ // Class Methods
+ // ===========================================================================================================================
+
+ /**
+ * @param password the password being validated
+ * @return a validation status (never <code>null</code>)
+ * @since 0.6
+ */
+ public static Status isPasswordValid( String password ) {
+ return Status.OK_STATUS;
+ }
+
+ /**
+ * @param url the URL being validated
+ * @return a validation status (never <code>null</code>)
+ * @since 0.6
+ */
+ public static Status isUrlValid( String url ) {
+ if ((url == null) || (url.length() == 0)) {
+ return new Status(Severity.ERROR, MESSAGES.getString(ServerEmptyUrlMsg), null);
+ }
+
+ try {
+ new URL(url);
+ } catch (Exception e) {
+ String pattern = MESSAGES.getString(ServerInvalidUrlMsg);
+ String msg = MessageFormat.format(pattern, url);
+ return new Status(Severity.ERROR, msg, null);
+ }
+
+ return Status.OK_STATUS;
+ }
+
+ /**
+ * @param user the user being validated
+ * @return a validation status (never <code>null</code>)
+ * @since 0.6
+ */
+ public static Status isUserValid( String user ) {
+ if ((user == null) || (user.length() == 0)) {
+ return new Status(Severity.ERROR, MESSAGES.getString(ServerEmptyUserMsg), null);
+ }
+
+ return Status.OK_STATUS;
+ }
+
+ /**
+ * This does not verify that a server with the same primary field values doesn't already exist.
+ *
+ * @param url the URL being validated
+ * @param user the user being validated
+ * @param password the password being validated
+ * @param persistPassword <code>true</code> if the password should be persisted
+ * @return a validation status (never <code>null</code>)
+ * @since 0.6
+ */
+ public static Status isValid( String url,
+ String user,
+ String password,
+ boolean persistPassword ) {
+ Status status = isUrlValid(url);
+
+ if (!status.isError()) {
+ status = isUserValid(user);
+
+ if (!status.isError()) {
+ status = isPasswordValid(password);
+ }
+ }
+
+ return status;
+ }
+
+ /**
+ * Validates the server properties and makes sure no other exists in the server registry that also has the same primary field
+ * values.
+ *
+ * @param url the URL being validated
+ * @param user the user being validated
+ * @param password the password being validated
+ * @param persistPassword <code>true</code> if the password should be persisted
+ * @param serverManager the server manager controlling the server registry (may not be <code>null</code>)
+ * @return a validation status (never <code>null</code>)
+ * @see #isValid(String, String, String, boolean)
+ * @since 0.6
+ */
+ public static Status isValid( String url,
+ String user,
+ String password,
+ boolean persistPassword,
+ ServerManager serverManager ) {
+ Status status = isValid(url, user, password, persistPassword);
+
+ // make sure a server with the same properties does not exist
+ if (!status.isError()) {
+ Server newServer = new Server(url, user, password, persistPassword);
+
+ if (serverManager.isRegistered(newServer)) {
+ String pattern = MESSAGES.getString(ServerExistsMsg);
+ String msg = MessageFormat.format(pattern, newServer.getShortDescription());
+ status = new Status(Severity.ERROR, msg, null);
+ }
+ }
+
+ return status;
+ }
+
+ // ===========================================================================================================================
+ // Constructors
+ // ===========================================================================================================================
+
+ /**
+ * Disallow construction.
+ *
+ * @since 0.6
+ */
+ private ServerValidator() {
+ // nothing to do
+ }
+
+}
Property changes on: branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/domain/validation/ServerValidator.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/domain/validation/WorkspaceValidator.java
===================================================================
--- branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/domain/validation/WorkspaceValidator.java (rev 0)
+++ branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/domain/validation/WorkspaceValidator.java 2009-07-14 12:59:48 UTC (rev 1111)
@@ -0,0 +1,97 @@
+/*
+ * JBoss DNA (http://www.jboss.org/dna)
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ * See the AUTHORS.txt file in the distribution for a full listing of
+ * individual contributors.
+ *
+ * JBoss DNA is free software. Unless otherwise indicated, all code in JBoss DNA
+ * is licensed to you under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * JBoss DNA is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.dna.web.jcr.rest.client.domain.validation;
+
+import org.jboss.dna.web.jcr.rest.client.IConstants;
+import org.jboss.dna.web.jcr.rest.client.Status;
+import org.jboss.dna.web.jcr.rest.client.Status.Severity;
+import org.jboss.dna.web.jcr.rest.client.domain.Repository;
+
+/**
+ * @author Dan Florian
+ * @since 0.6
+ */
+public final class WorkspaceValidator implements IConstants {
+
+ // ===========================================================================================================================
+ // Class Methods
+ // ===========================================================================================================================
+
+ /**
+ * @param name the name being validated
+ * @return a validation status (never <code>null</code>)
+ * @since 0.6
+ */
+ public static Status isNameValid( String name ) {
+ if ((name == null) || (name.length() == 0)) {
+ return new Status(Severity.ERROR, MESSAGES.getString(WorkspaceEmptyNameMsg), null);
+ }
+
+ return Status.OK_STATUS;
+ }
+
+ /**
+ * @param repository the repository being validated
+ * @return a validation status (never <code>null</code>)
+ * @since 0.6
+ */
+ public static Status isRepositoryValid( Repository repository ) {
+ if (repository == null) {
+ return new Status(Severity.ERROR, MESSAGES.getString(WorkspaceNullRepositoryMsg), null);
+ }
+
+ return Status.OK_STATUS;
+ }
+
+ /**
+ * @param name the name being validated
+ * @param repository the repository being validated
+ * @return a validation status (never <code>null</code>)
+ * @since 0.6
+ */
+ public static Status isValid( String name,
+ Repository repository ) {
+ Status status = isNameValid(name);
+
+ if (!status.isError()) {
+ status = isRepositoryValid(repository);
+ }
+
+ return status;
+ }
+
+ // ===========================================================================================================================
+ // Constructors
+ // ===========================================================================================================================
+
+ /**
+ * Disallow construction.
+ *
+ * @since 0.6
+ */
+ private WorkspaceValidator() {
+ // nothing to do
+ }
+
+}
Property changes on: branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/domain/validation/WorkspaceValidator.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/json/GetRepositoriesRequest.java
===================================================================
--- branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/json/GetRepositoriesRequest.java (rev 0)
+++ branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/json/GetRepositoriesRequest.java 2009-07-14 12:59:48 UTC (rev 1111)
@@ -0,0 +1,85 @@
+/*
+ * JBoss DNA (http://www.jboss.org/dna)
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ * See the AUTHORS.txt file in the distribution for a full listing of
+ * individual contributors.
+ *
+ * JBoss DNA is free software. Unless otherwise indicated, all code in JBoss DNA
+ * is licensed to you under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * JBoss DNA is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.dna.web.jcr.rest.client.json;
+
+import java.net.URL;
+import org.codehaus.jettison.json.JSONObject;
+import org.jboss.dna.web.jcr.rest.client.domain.Server;
+import org.jboss.dna.web.jcr.rest.client.publish.IRestResponse;
+
+/**
+ * @author Dan Florian
+ * @since 0.6
+ */
+public final class GetRepositoriesRequest extends JsonRestRequest {
+
+ // ===========================================================================================================================
+ // Fields
+ // ===========================================================================================================================
+
+ private final Server server;
+
+ // ===========================================================================================================================
+ // Constructors
+ // ===========================================================================================================================
+
+ /**
+ * @param server the server where the request will be made
+ * @since 0.6
+ */
+ public GetRepositoriesRequest( Server server ) {
+ super(Method.GET);
+ this.server = server;
+ }
+
+ // ===========================================================================================================================
+ // Methods
+ // ===========================================================================================================================
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.jboss.dna.web.jcr.rest.client.json.JsonRestRequest#createResponse()
+ * @since 0.6
+ */
+ @Override
+ protected IRestResponse createResponse() throws Exception {
+ // TODO implement createResponse()
+ JSONObject body = getObjectFromConnectionInputStream();
+ return null;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.jboss.dna.web.jcr.rest.client.json.JsonRestRequest#getUrl()
+ * @since 0.6
+ */
+ @Override
+ protected URL getUrl() {
+ // TODO implement getUrl()
+ return null;
+ }
+
+}
Property changes on: branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/json/GetRepositoriesRequest.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/json/GetWorkspacesRequest.java
===================================================================
--- branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/json/GetWorkspacesRequest.java (rev 0)
+++ branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/json/GetWorkspacesRequest.java 2009-07-14 12:59:48 UTC (rev 1111)
@@ -0,0 +1,76 @@
+/*
+ * JBoss DNA (http://www.jboss.org/dna)
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ * See the AUTHORS.txt file in the distribution for a full listing of
+ * individual contributors.
+ *
+ * JBoss DNA is free software. Unless otherwise indicated, all code in JBoss DNA
+ * is licensed to you under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * JBoss DNA is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.dna.web.jcr.rest.client.json;
+
+import java.net.URL;
+import org.jboss.dna.web.jcr.rest.client.domain.Repository;
+import org.jboss.dna.web.jcr.rest.client.publish.IRestResponse;
+
+/**
+ * @author Dan Florian
+ * @since 0.6
+ */
+public final class GetWorkspacesRequest extends JsonRestRequest {
+
+ // ===========================================================================================================================
+ // Constructors
+ // ===========================================================================================================================
+
+ /**
+ * @param repository the repository whose workspaces are being requested
+ * @since 0.6
+ */
+ protected GetWorkspacesRequest( Repository repository ) {
+ super(Method.GET);
+ }
+
+ // ===========================================================================================================================
+ // Methods
+ // ===========================================================================================================================
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.jboss.dna.web.jcr.rest.client.json.JsonRestRequest#createResponse()
+ * @since 0.6
+ */
+ @Override
+ protected IRestResponse createResponse() throws Exception {
+ // TODO implement createResponse()
+ return null;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.jboss.dna.web.jcr.rest.client.json.JsonRestRequest#getUrl()
+ * @since 0.6
+ */
+ @Override
+ protected URL getUrl() {
+ // TODO implement getUrl()
+ return null;
+ }
+
+}
Property changes on: branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/json/GetWorkspacesRequest.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/json/IsPublishedRequest.java
===================================================================
--- branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/json/IsPublishedRequest.java (rev 0)
+++ branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/json/IsPublishedRequest.java 2009-07-14 12:59:48 UTC (rev 1111)
@@ -0,0 +1,99 @@
+/*
+ * JBoss DNA (http://www.jboss.org/dna)
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ * See the AUTHORS.txt file in the distribution for a full listing of
+ * individual contributors.
+ *
+ * JBoss DNA is free software. Unless otherwise indicated, all code in JBoss DNA
+ * is licensed to you under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * JBoss DNA is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.dna.web.jcr.rest.client.json;
+
+import java.io.File;
+import java.net.URL;
+import org.jboss.dna.web.jcr.rest.client.domain.Workspace;
+import org.jboss.dna.web.jcr.rest.client.publish.IRestResponse;
+
+/**
+ * @author Dan Florian
+ * @since 0.6
+ */
+public final class IsPublishedRequest extends JsonRestRequest {
+
+ // ===========================================================================================================================
+ // Fields
+ // ===========================================================================================================================
+
+ /**
+ * The file being checked.
+ *
+ * @since 0.6
+ */
+ private final File file;
+
+ /**
+ * The workspace being checked.
+ *
+ * @since 0.6
+ */
+ private final Workspace workspace;
+
+ // ===========================================================================================================================
+ // Constructors
+ // ===========================================================================================================================
+
+ /**
+ * @param workspace
+ * @param file
+ * @since 0.6
+ */
+ public IsPublishedRequest( Workspace workspace,
+ File file ) {
+ super(Method.GET);
+ this.workspace = workspace;
+ this.file = file;
+ }
+
+ // ===========================================================================================================================
+ // Methods
+ // ===========================================================================================================================
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.jboss.dna.web.jcr.rest.client.json.JsonRestRequest#createResponse()
+ * @since 0.6
+ */
+ @Override
+ protected IRestResponse createResponse() throws Exception {
+ // TODO implement createResponse()
+ return null;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.jboss.dna.web.jcr.rest.client.json.JsonRestRequest#getUrl()
+ * @since 0.6
+ */
+ @Override
+ protected URL getUrl() {
+ // TODO implement getUrl()
+ return null;
+ }
+
+}
Property changes on: branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/json/IsPublishedRequest.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/json/IsServerAliveRequest.java
===================================================================
--- branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/json/IsServerAliveRequest.java (rev 0)
+++ branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/json/IsServerAliveRequest.java 2009-07-14 12:59:48 UTC (rev 1111)
@@ -0,0 +1,88 @@
+/*
+ * JBoss DNA (http://www.jboss.org/dna)
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ * See the AUTHORS.txt file in the distribution for a full listing of
+ * individual contributors.
+ *
+ * JBoss DNA is free software. Unless otherwise indicated, all code in JBoss DNA
+ * is licensed to you under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * JBoss DNA is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.dna.web.jcr.rest.client.json;
+
+import java.net.URL;
+import org.jboss.dna.web.jcr.rest.client.domain.Server;
+import org.jboss.dna.web.jcr.rest.client.publish.IRestResponse;
+
+/**
+ * @author Dan Florian
+ * @since 0.6
+ */
+public final class IsServerAliveRequest extends JsonRestRequest {
+
+ // ===========================================================================================================================
+ // Fields
+ // ===========================================================================================================================
+
+ /**
+ * The server being checked.
+ *
+ * @since 0.6
+ */
+ private final Server server;
+
+ // ===========================================================================================================================
+ // Constructors
+ // ===========================================================================================================================
+
+ /**
+ * @param server the server being checked
+ * @since 0.6
+ */
+ protected IsServerAliveRequest( Server server ) {
+ super(Method.GET);
+ this.server = server;
+ }
+
+ // ===========================================================================================================================
+ // Methods
+ // ===========================================================================================================================
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.jboss.dna.web.jcr.rest.client.json.JsonRestRequest#createResponse()
+ * @since 0.6
+ */
+ @Override
+ protected IRestResponse createResponse() throws Exception {
+ // TODO implement createResponse()
+ return null;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.jboss.dna.web.jcr.rest.client.json.JsonRestRequest#getUrl()
+ * @since 0.6
+ */
+ @Override
+ protected URL getUrl() {
+ // TODO implement getUrl()
+ return null;
+ }
+
+}
Property changes on: branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/json/IsServerAliveRequest.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/json/JsonRequestFactory.java
===================================================================
--- branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/json/JsonRequestFactory.java (rev 0)
+++ branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/json/JsonRequestFactory.java 2009-07-14 12:59:48 UTC (rev 1111)
@@ -0,0 +1,109 @@
+/*
+ * JBoss DNA (http://www.jboss.org/dna)
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ * See the AUTHORS.txt file in the distribution for a full listing of
+ * individual contributors.
+ *
+ * JBoss DNA is free software. Unless otherwise indicated, all code in JBoss DNA
+ * is licensed to you under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * JBoss DNA is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.dna.web.jcr.rest.client.json;
+
+import java.io.File;
+import org.jboss.dna.web.jcr.rest.client.domain.Repository;
+import org.jboss.dna.web.jcr.rest.client.domain.Server;
+import org.jboss.dna.web.jcr.rest.client.domain.Workspace;
+import org.jboss.dna.web.jcr.rest.client.publish.IRestRequest;
+import org.jboss.dna.web.jcr.rest.client.publish.IRestRequestFactory;
+
+/**
+ * @author Dan Florian
+ * @since 0.6
+ */
+public final class JsonRequestFactory implements IRestRequestFactory {
+
+ // ===========================================================================================================================
+ // Methods
+ // ===========================================================================================================================
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.jboss.dna.web.jcr.rest.client.publish.IRestRequestFactory#createGetRepositoriesRequest(org.jboss.dna.web.jcr.rest.client.domain.Server)
+ * @since 0.6
+ */
+ public IRestRequest createGetRepositoriesRequest( Server server ) throws Exception {
+ return new GetRepositoriesRequest(server);
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.jboss.dna.web.jcr.rest.client.publish.IRestRequestFactory#createGetWorkspacesRequest(org.jboss.dna.web.jcr.rest.client.domain.Repository)
+ * @since 0.6
+ */
+ public IRestRequest createGetWorkspacesRequest( Repository repository ) throws Exception {
+ return new GetWorkspacesRequest(repository);
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.jboss.dna.web.jcr.rest.client.publish.IRestRequestFactory#createIsPublishedRequest(org.jboss.dna.web.jcr.rest.client.domain.Workspace,
+ * java.io.File)
+ * @since 0.6
+ */
+ public IRestRequest createIsPublishedRequest( Workspace workspace,
+ File file ) throws Exception {
+ return new IsPublishedRequest(workspace, file);
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.jboss.dna.web.jcr.rest.client.publish.IRestRequestFactory#createIsServerAliveRequest(org.jboss.dna.web.jcr.rest.client.domain.Server)
+ * @since 0.6
+ */
+ public IRestRequest createIsServerAliveRequest( Server server ) throws Exception {
+ return new IsServerAliveRequest(server);
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.jboss.dna.web.jcr.rest.client.publish.IRestRequestFactory#createPublishRequest(org.jboss.dna.web.jcr.rest.client.domain.Workspace,
+ * java.io.File)
+ * @since 0.6
+ */
+ public IRestRequest createPublishRequest( Workspace workspace,
+ File file ) throws Exception {
+ return new PublishRequest(workspace, file);
+ }
+
+ /**
+ * {@inheritDoc}dan
+ *
+ * @see org.jboss.dna.web.jcr.rest.client.publish.IRestRequestFactory#createUnpublishRequest(org.jboss.dna.web.jcr.rest.client.domain.Workspace,
+ * java.io.File)
+ * @since 0.6
+ */
+ public IRestRequest createUnpublishRequest( Workspace workspace,
+ File file ) throws Exception {
+ return new UnpublishRequest(workspace, file);
+ }
+
+}
Property changes on: branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/json/JsonRequestFactory.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/json/JsonRestRequest.java
===================================================================
--- branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/json/JsonRestRequest.java (rev 0)
+++ branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/json/JsonRestRequest.java 2009-07-14 12:59:48 UTC (rev 1111)
@@ -0,0 +1,169 @@
+/*
+ * JBoss DNA (http://www.jboss.org/dna)
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ * See the AUTHORS.txt file in the distribution for a full listing of
+ * individual contributors.
+ *
+ * JBoss DNA is free software. Unless otherwise indicated, all code in JBoss DNA
+ * is licensed to you under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * JBoss DNA is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.dna.web.jcr.rest.client.json;
+
+import java.io.InputStream;
+import java.net.HttpURLConnection;
+import java.net.URL;
+import javax.ws.rs.core.MediaType;
+import org.codehaus.jettison.json.JSONObject;
+import org.jboss.dna.web.jcr.rest.client.publish.IRestRequest;
+import org.jboss.dna.web.jcr.rest.client.publish.IRestResponse;
+
+/**
+ * @author Dan Florian
+ * @since 0.6
+ */
+public abstract class JsonRestRequest implements IRestRequest {
+
+ /**
+ * The HTTP method to use in the request.
+ *
+ * @since 0.6
+ */
+ protected enum Method {
+ /**
+ * @since 0.6
+ */
+ DELETE,
+
+ /**
+ * @since 0.6
+ */
+ GET,
+
+ /**
+ * @since 0.6
+ */
+ POST,
+
+ /**
+ * @since 0.6
+ */
+ PUT
+ }
+
+ // ===========================================================================================================================
+ // Fields
+ // ===========================================================================================================================
+
+ /**
+ * The connection to the URL or <code>null</code> if {@link #execute()} has not been called.
+ *
+ * @since 0.6
+ */
+ private HttpURLConnection connection;
+
+ /**
+ * The HTTP method.
+ *
+ * @since 0.6
+ */
+ private final Method method;
+
+ // ===========================================================================================================================
+ // Constructors
+ // ===========================================================================================================================
+
+ /**
+ * @param method the request method
+ * @since 0.6
+ */
+ protected JsonRestRequest( Method method ) {
+ this.method = method;
+ }
+
+ // ===========================================================================================================================
+ // Methods
+ // ===========================================================================================================================
+
+ /**
+ * @return the response
+ * @throws Exception if there is a problem creating the response
+ * @since 0.6
+ */
+ protected abstract IRestResponse createResponse() throws Exception;
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.jboss.dna.web.jcr.rest.client.publish.IRestRequest#execute()
+ * @throws Exception if connection cannot be established or there is a problem executing the request
+ * @since 0.6
+ */
+ public final IRestResponse execute() throws Exception {
+ URL url = getUrl();
+ this.connection = (HttpURLConnection)url.openConnection();
+ this.connection.setDoOutput(true);
+ this.connection.setRequestMethod(this.method.toString());
+ this.connection.setRequestProperty("Content-Type", MediaType.APPLICATION_JSON);
+
+ IRestResponse response = createResponse();
+ this.connection.disconnect();
+
+ return response;
+ }
+
+ /**
+ * @return the open connection or <code>null</code> if {@link #execute()} has not been called
+ * @since 0.6
+ */
+ protected HttpURLConnection getConnection() {
+ return this.connection;
+ }
+
+ /**
+ * @return the URL where the request will be made (may not be <code>null</code>)
+ * @since 0.6
+ */
+ protected abstract URL getUrl();
+
+ /**
+ * @return the object representing the stream
+ * @throws Exception if connection is <code>null</code> or if a problem reading the stream
+ * @since 0.6
+ */
+ protected JSONObject getObjectFromConnectionInputStream() throws Exception {
+ return new JSONObject(getStringFromConnectionInputStream());
+ }
+
+ /**
+ * @return the connection input stream read as a string
+ * @throws Exception if connection is <code>null</code> or if a problem reading the stream
+ * @since 0.6
+ */
+ protected String getStringFromConnectionInputStream() throws Exception {
+ StringBuffer buff = new StringBuffer();
+ InputStream stream = this.connection.getInputStream();
+ int bytesRead;
+ byte[] bytes = new byte[1024];
+
+ while (-1 != (bytesRead = stream.read(bytes, 0, 1024))) {
+ buff.append(new String(bytes, 0, bytesRead));
+ }
+
+ return buff.toString();
+ }
+
+}
Property changes on: branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/json/JsonRestRequest.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/json/PublishCommand.java
===================================================================
--- branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/json/PublishCommand.java (rev 0)
+++ branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/json/PublishCommand.java 2009-07-14 12:59:48 UTC (rev 1111)
@@ -0,0 +1,109 @@
+/*
+ * JBoss DNA (http://www.jboss.org/dna)
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ * See the AUTHORS.txt file in the distribution for a full listing of
+ * individual contributors.
+ *
+ * JBoss DNA is free software. Unless otherwise indicated, all code in JBoss DNA
+ * is licensed to you under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * JBoss DNA is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.dna.web.jcr.rest.client.json;
+
+import java.io.File;
+import java.net.Authenticator;
+import java.net.HttpURLConnection;
+import java.net.PasswordAuthentication;
+import org.jboss.dna.web.jcr.rest.client.Status;
+import org.jboss.dna.web.jcr.rest.client.domain.Server;
+import org.jboss.dna.web.jcr.rest.client.domain.Workspace;
+
+/**
+ * @author Dan Florian
+ * @since 0.6
+ */
+public class PublishCommand {
+
+ // ===========================================================================================================================
+ // Constants
+ // ===========================================================================================================================
+
+ // private static final String SERVER_CONTEXT = "/resources"; //$NON-NLS-1$
+
+ // ===========================================================================================================================
+ // Class Methods
+ // ===========================================================================================================================
+
+ private static void setAuthenticator( final Server server ) {
+ Authenticator.setDefault(new Authenticator() {
+ @Override
+ protected PasswordAuthentication getPasswordAuthentication() {
+ return new PasswordAuthentication(server.getUser(), server.getPassword().toCharArray());
+ }
+ });
+ }
+
+ // ===========================================================================================================================
+ // Fields
+ // ===========================================================================================================================
+
+ /**
+ * The workspace where the publishing or unpublishing will take place.
+ *
+ * @since 0.6
+ */
+ private final Workspace workspace;
+
+ // ===========================================================================================================================
+ // Constructors
+ // ===========================================================================================================================
+
+ /**
+ * @param workspace the workspace to use when publishing or unpublishing
+ * @since 0.6
+ */
+ public PublishCommand( Workspace workspace ) {
+ this.workspace = workspace;
+ }
+
+ // ===========================================================================================================================
+ // Methods
+ // ===========================================================================================================================
+
+ /**
+ * @param file the file being published
+ * @return a status indicating if the publishing was successful
+ * @since 0.6
+ */
+ public Status publish( File file ) {
+ // TODO implement publish(File)
+ Server server = workspace.getServer();
+ setAuthenticator(server);
+
+ return null;
+ }
+
+ /**
+ * @param file the file being unpublished
+ * @return a status indicating if the unpublishing was successful
+ * @since 0.6
+ */
+ public Status unpublish( File file ) {
+ // TODO implement unpublish(File)
+ return null;
+ }
+
+}
Property changes on: branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/json/PublishCommand.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/json/PublishRequest.java
===================================================================
--- branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/json/PublishRequest.java (rev 0)
+++ branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/json/PublishRequest.java 2009-07-14 12:59:48 UTC (rev 1111)
@@ -0,0 +1,99 @@
+/*
+ * JBoss DNA (http://www.jboss.org/dna)
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ * See the AUTHORS.txt file in the distribution for a full listing of
+ * individual contributors.
+ *
+ * JBoss DNA is free software. Unless otherwise indicated, all code in JBoss DNA
+ * is licensed to you under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * JBoss DNA is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.dna.web.jcr.rest.client.json;
+
+import java.io.File;
+import java.net.URL;
+import org.jboss.dna.web.jcr.rest.client.domain.Workspace;
+import org.jboss.dna.web.jcr.rest.client.publish.IRestResponse;
+
+/**
+ * @author Dan Florian
+ * @since 0.6
+ */
+public final class PublishRequest extends JsonRestRequest {
+
+ // ===========================================================================================================================
+ // Fields
+ // ===========================================================================================================================
+
+ /**
+ * The workspace where the file is being published.
+ *
+ * @since 0.6
+ */
+ private final Workspace workspace;
+
+ /**
+ * The file being published.
+ *
+ * @since 0.6
+ */
+ private final File file;
+
+ // ===========================================================================================================================
+ // Constructors
+ // ===========================================================================================================================
+
+ /**
+ * @param workspace the workspace where the file is being published
+ * @param file the file being published
+ * @since 0.6
+ */
+ protected PublishRequest( Workspace workspace,
+ File file ) {
+ super(Method.PUT);
+ this.workspace = workspace;
+ this.file = file;
+ }
+
+ // ===========================================================================================================================
+ // Methods
+ // ===========================================================================================================================
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.jboss.dna.web.jcr.rest.client.json.JsonRestRequest#createResponse()
+ * @since 0.6
+ */
+ @Override
+ protected IRestResponse createResponse() throws Exception {
+ // TODO implement createResponse()
+ return null;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.jboss.dna.web.jcr.rest.client.json.JsonRestRequest#getUrl()
+ * @since 0.6
+ */
+ @Override
+ protected URL getUrl() {
+ // TODO implement getUrl()
+ return null;
+ }
+
+}
Property changes on: branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/json/PublishRequest.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/json/UnpublishRequest.java
===================================================================
--- branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/json/UnpublishRequest.java (rev 0)
+++ branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/json/UnpublishRequest.java 2009-07-14 12:59:48 UTC (rev 1111)
@@ -0,0 +1,99 @@
+/*
+ * JBoss DNA (http://www.jboss.org/dna)
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ * See the AUTHORS.txt file in the distribution for a full listing of
+ * individual contributors.
+ *
+ * JBoss DNA is free software. Unless otherwise indicated, all code in JBoss DNA
+ * is licensed to you under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * JBoss DNA is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.dna.web.jcr.rest.client.json;
+
+import java.io.File;
+import java.net.URL;
+import org.jboss.dna.web.jcr.rest.client.domain.Workspace;
+import org.jboss.dna.web.jcr.rest.client.publish.IRestResponse;
+
+/**
+ * @author Dan Florian
+ * @since 0.6
+ */
+public final class UnpublishRequest extends JsonRestRequest {
+
+ // ===========================================================================================================================
+ // Fields
+ // ===========================================================================================================================
+
+ /**
+ * The workspace where the file is being published.
+ *
+ * @since 0.6
+ */
+ private final Workspace workspace;
+
+ /**
+ * The file being published.
+ *
+ * @since 0.6
+ */
+ private final File file;
+
+ // ===========================================================================================================================
+ // Constructors
+ // ===========================================================================================================================
+
+ /**
+ * @param workspace the workspace where the file is being published
+ * @param file the file being published
+ * @since 0.6
+ */
+ protected UnpublishRequest( Workspace workspace,
+ File file ) {
+ super(Method.DELETE);
+ this.workspace = workspace;
+ this.file = file;
+ }
+
+ // ===========================================================================================================================
+ // Methods
+ // ===========================================================================================================================
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.jboss.dna.web.jcr.rest.client.json.JsonRestRequest#createResponse()
+ * @since 0.6
+ */
+ @Override
+ protected IRestResponse createResponse() throws Exception {
+ // TODO implement createResponse()
+ return null;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.jboss.dna.web.jcr.rest.client.json.JsonRestRequest#getUrl()
+ * @since 0.6
+ */
+ @Override
+ protected URL getUrl() {
+ // TODO implement getUrl()
+ return null;
+ }
+
+}
Property changes on: branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/json/UnpublishRequest.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/publish/IRestRequest.java
===================================================================
--- branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/publish/IRestRequest.java (rev 0)
+++ branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/publish/IRestRequest.java 2009-07-14 12:59:48 UTC (rev 1111)
@@ -0,0 +1,34 @@
+/*
+ * JBoss DNA (http://www.jboss.org/dna)
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ * See the AUTHORS.txt file in the distribution for a full listing of
+ * individual contributors.
+ *
+ * JBoss DNA is free software. Unless otherwise indicated, all code in JBoss DNA
+ * is licensed to you under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * JBoss DNA is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.dna.web.jcr.rest.client.publish;
+
+/**
+ * @author dan
+ *
+ */
+public interface IRestRequest {
+
+ IRestResponse execute() throws Exception;
+
+}
Property changes on: branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/publish/IRestRequest.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/publish/IRestRequestFactory.java
===================================================================
--- branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/publish/IRestRequestFactory.java (rev 0)
+++ branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/publish/IRestRequestFactory.java 2009-07-14 12:59:48 UTC (rev 1111)
@@ -0,0 +1,91 @@
+/*
+ * JBoss DNA (http://www.jboss.org/dna)
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ * See the AUTHORS.txt file in the distribution for a full listing of
+ * individual contributors.
+ *
+ * JBoss DNA is free software. Unless otherwise indicated, all code in JBoss DNA
+ * is licensed to you under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * JBoss DNA is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.dna.web.jcr.rest.client.publish;
+
+import java.io.File;
+import org.jboss.dna.web.jcr.rest.client.domain.Repository;
+import org.jboss.dna.web.jcr.rest.client.domain.Server;
+import org.jboss.dna.web.jcr.rest.client.domain.Workspace;
+
+/**
+ * @author Dan Florian
+ * @since 0.6
+ */
+public interface IRestRequestFactory {
+
+ /**
+ * @param server the server whose repositories are being requested
+ * @return the request
+ * @throws Exception if a problem creating the request
+ * @since 0.6
+ */
+ IRestRequest createGetRepositoriesRequest( Server server ) throws Exception;
+
+ /**
+ * @param repository the repository whose workspaces are being requested
+ * @return the request
+ * @throws Exception if a problem creating the request
+ * @since 0.6
+ */
+ IRestRequest createGetWorkspacesRequest( Repository repository ) throws Exception;
+
+ /**
+ * @param server the server to use when creating the request
+ * @return the request
+ * @throws Exception if there is a problem creating the request
+ * @since 0.6
+ */
+ IRestRequest createIsServerAliveRequest( Server server ) throws Exception;
+
+ /**
+ * @param workspace the workspace being checked
+ * @param file the file being checked
+ * @return the request
+ * @throws Exception if there is a problem creating the request
+ * @since 0.6
+ */
+ IRestRequest createIsPublishedRequest( Workspace workspace,
+ File file ) throws Exception;
+
+ /**
+ * @param workspace the workspace being checked
+ * @param file the file being published
+ * @return the request
+ * @throws Exception if there is a problem creating the request
+ * @since 0.6
+ */
+ IRestRequest createPublishRequest( Workspace workspace,
+ File file ) throws Exception;
+
+ /**
+ * @param workspace the workspace being checked
+ * @param file the file being unpublished
+ * @return the request
+ * @throws Exception if there is a problem creating the request
+ * @since 0.6
+ */
+ IRestRequest createUnpublishRequest( Workspace workspace,
+ File file ) throws Exception;
+
+}
Property changes on: branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/publish/IRestRequestFactory.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/publish/IRestResponse.java
===================================================================
--- branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/publish/IRestResponse.java (rev 0)
+++ branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/publish/IRestResponse.java 2009-07-14 12:59:48 UTC (rev 1111)
@@ -0,0 +1,34 @@
+/*
+ * JBoss DNA (http://www.jboss.org/dna)
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ * See the AUTHORS.txt file in the distribution for a full listing of
+ * individual contributors.
+ *
+ * JBoss DNA is free software. Unless otherwise indicated, all code in JBoss DNA
+ * is licensed to you under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * JBoss DNA is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.dna.web.jcr.rest.client.publish;
+
+/**
+ * @author dan
+ *
+ */
+public interface IRestResponse {
+
+ int getResponseCode();
+
+}
Property changes on: branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/publish/IRestResponse.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: branches/eclipse/dna-web-jcr-rest-client/src/main/resources/org/jboss/dna/web/jcr/rest/client/Messages.properties
===================================================================
--- branches/eclipse/dna-web-jcr-rest-client/src/main/resources/org/jboss/dna/web/jcr/rest/client/Messages.properties (rev 0)
+++ branches/eclipse/dna-web-jcr-rest-client/src/main/resources/org/jboss/dna/web/jcr/rest/client/Messages.properties 2009-07-14 12:59:48 UTC (rev 1111)
@@ -0,0 +1,47 @@
+#
+# 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.
+#
+ErrorDeletingServerRegistryFile = There was a problem deleting server registry file "{0}"
+ErrorRestoringServerRegistry = Error trying to restore the server registry from file "{0}"
+ErrorSavingServerRegistry = Error trying to save the server registry to "{0}"
+
+RepositoryEmptyNameMsg = A repository name cannot be empty
+RepositoryNullServerMsg = A repository server cannot be null
+RepositoryShortDescription = DNA Repository: Name: {0}, {1}
+
+ServerEmptyUserMsg = The user cannot be empty
+ServerEmptyUrlMsg = A server URL cannot be empty
+ServerExistsMsg = {0} already exists so it cannot be added
+ServerInvalidUrlMsg = The value "{0}" is not a valid server URL
+ServerShortDescription = DNA Server: URL={0} User={1}
+
+ServerManagerRegistryAddUnexpectedError = Unexpected error adding server to registry
+ServerManagerRegistryListenerError = This error was reported by an IServerRegistryListener
+ServerManagerRegistryListenerErrorsOccurred = Errors occurred processing a server registry event. Check error log for more details.
+ServerManagerRegistryRemoveUnexpectedError = {0} cannot be removed as it has not been registered
+ServerManagerRegistryUpdateAddError = There was an unexpected error updating the server in the registry. The old version of the server was successfully removed. However, the new version was not updated. Detail: {0}
+ServerManagerRegistryUpdateRemoveError = There was an unexpected error updating the server in the registry. The server has not been updated in the server registry. Detail: {0}
+
+WorkspaceEmptyNameMsg = A workspace name cannot be empty
+WorkspaceNullRepositoryMsg = A workspace repository cannot be null
+WorkspaceShortDescription = DNA Repository Workspace: Name: {0}, {1}
Property changes on: branches/eclipse/dna-web-jcr-rest-client/src/main/resources/org/jboss/dna/web/jcr/rest/client/Messages.properties
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: branches/eclipse/dna-web-jcr-rest-client/src/test/resources/log4j.properties
===================================================================
--- branches/eclipse/dna-web-jcr-rest-client/src/test/resources/log4j.properties (rev 0)
+++ branches/eclipse/dna-web-jcr-rest-client/src/test/resources/log4j.properties 2009-07-14 12:59:48 UTC (rev 1111)
@@ -0,0 +1,28 @@
+# Direct log messages to stdout
+log4j.appender.stdout=org.apache.log4j.ConsoleAppender
+log4j.appender.stdout.Target=System.out
+log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
+log4j.appender.stdout.layout.ConversionPattern=%d{ABSOLUTE} %5p %m%n
+
+# Direct log messages to a file
+log4j.appender.testlog=org.apache.log4j.FileAppender
+log4j.appender.testlog.File=target/logs/test/org.jboss.dna.web.jcr.rest.client.Test.log
+log4j.appender.testlog.layout=org.apache.log4j.PatternLayout
+log4j.appender.testlog.layout.ConversionPattern=%d{ABSOLUTE} %5p %m%n
+
+# Direct log messages to a file and use Mapped Diagnostic Contexts (MDC)
+log4j.appender.testlog-mdc=org.apache.log4j.FileAppender
+log4j.appender.testlog-mdc.File=target/logs/test/org.jboss.dna.web.jcr.rest.client.Test.log
+log4j.appender.testlog-mdc.layout=org.apache.log4j.PatternLayout
+log4j.appender.testlog-mdc.layout.ConversionPattern=%d{ABSOLUTE} %5p [%X{username}] %m%n
+
+# Root logger option
+log4j.rootLogger=INFO, stdout, testlog, testlog-mdc
+
+# Set up the default logging to be INFO level, then override specific units
+log4j.logger.org.jboss.dna=INFO
+
+# Set up the logging for the LoggerTest test cases (which need this to be explicitly set rather than inherited)
+log4j.logger.org.jboss.dna.common.util.LoggerTest=INFO
+
+
Property changes on: branches/eclipse/dna-web-jcr-rest-client/src/test/resources/log4j.properties
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: branches/eclipse/dna-web-jcr-rest-client/target/classes/org/jboss/dna/web/jcr/rest/client/IConstants.class
===================================================================
(Binary files differ)
Property changes on: branches/eclipse/dna-web-jcr-rest-client/target/classes/org/jboss/dna/web/jcr/rest/client/IConstants.class
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: branches/eclipse/dna-web-jcr-rest-client/target/classes/org/jboss/dna/web/jcr/rest/client/IServerRegistryListener.class
===================================================================
(Binary files differ)
Property changes on: branches/eclipse/dna-web-jcr-rest-client/target/classes/org/jboss/dna/web/jcr/rest/client/IServerRegistryListener.class
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: branches/eclipse/dna-web-jcr-rest-client/target/classes/org/jboss/dna/web/jcr/rest/client/Logger.class
===================================================================
(Binary files differ)
Property changes on: branches/eclipse/dna-web-jcr-rest-client/target/classes/org/jboss/dna/web/jcr/rest/client/Logger.class
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: branches/eclipse/dna-web-jcr-rest-client/target/classes/org/jboss/dna/web/jcr/rest/client/Messages.properties
===================================================================
--- branches/eclipse/dna-web-jcr-rest-client/target/classes/org/jboss/dna/web/jcr/rest/client/Messages.properties (rev 0)
+++ branches/eclipse/dna-web-jcr-rest-client/target/classes/org/jboss/dna/web/jcr/rest/client/Messages.properties 2009-07-14 12:59:48 UTC (rev 1111)
@@ -0,0 +1,47 @@
+#
+# 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.
+#
+ErrorDeletingServerRegistryFile = There was a problem deleting server registry file "{0}"
+ErrorRestoringServerRegistry = Error trying to restore the server registry from file "{0}"
+ErrorSavingServerRegistry = Error trying to save the server registry to "{0}"
+
+RepositoryEmptyNameMsg = A repository name cannot be empty
+RepositoryNullServerMsg = A repository server cannot be null
+RepositoryShortDescription = DNA Repository: Name: {0}, {1}
+
+ServerEmptyUserMsg = The user cannot be empty
+ServerEmptyUrlMsg = A server URL cannot be empty
+ServerExistsMsg = {0} already exists so it cannot be added
+ServerInvalidUrlMsg = The value "{0}" is not a valid server URL
+ServerShortDescription = DNA Server: URL={0} User={1}
+
+ServerManagerRegistryAddUnexpectedError = Unexpected error adding server to registry
+ServerManagerRegistryListenerError = This error was reported by an IServerRegistryListener
+ServerManagerRegistryListenerErrorsOccurred = Errors occurred processing a server registry event. Check error log for more details.
+ServerManagerRegistryRemoveUnexpectedError = {0} cannot be removed as it has not been registered
+ServerManagerRegistryUpdateAddError = There was an unexpected error updating the server in the registry. The old version of the server was successfully removed. However, the new version was not updated. Detail: {0}
+ServerManagerRegistryUpdateRemoveError = There was an unexpected error updating the server in the registry. The server has not been updated in the server registry. Detail: {0}
+
+WorkspaceEmptyNameMsg = A workspace name cannot be empty
+WorkspaceNullRepositoryMsg = A workspace repository cannot be null
+WorkspaceShortDescription = DNA Repository Workspace: Name: {0}, {1}
Added: branches/eclipse/dna-web-jcr-rest-client/target/classes/org/jboss/dna/web/jcr/rest/client/ServerManager.class
===================================================================
(Binary files differ)
Property changes on: branches/eclipse/dna-web-jcr-rest-client/target/classes/org/jboss/dna/web/jcr/rest/client/ServerManager.class
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: branches/eclipse/dna-web-jcr-rest-client/target/classes/org/jboss/dna/web/jcr/rest/client/ServerRegistryEvent$Type.class
===================================================================
(Binary files differ)
Property changes on: branches/eclipse/dna-web-jcr-rest-client/target/classes/org/jboss/dna/web/jcr/rest/client/ServerRegistryEvent$Type.class
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: branches/eclipse/dna-web-jcr-rest-client/target/classes/org/jboss/dna/web/jcr/rest/client/ServerRegistryEvent.class
===================================================================
(Binary files differ)
Property changes on: branches/eclipse/dna-web-jcr-rest-client/target/classes/org/jboss/dna/web/jcr/rest/client/ServerRegistryEvent.class
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: branches/eclipse/dna-web-jcr-rest-client/target/classes/org/jboss/dna/web/jcr/rest/client/Status$Severity.class
===================================================================
(Binary files differ)
Property changes on: branches/eclipse/dna-web-jcr-rest-client/target/classes/org/jboss/dna/web/jcr/rest/client/Status$Severity.class
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: branches/eclipse/dna-web-jcr-rest-client/target/classes/org/jboss/dna/web/jcr/rest/client/Status.class
===================================================================
(Binary files differ)
Property changes on: branches/eclipse/dna-web-jcr-rest-client/target/classes/org/jboss/dna/web/jcr/rest/client/Status.class
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: branches/eclipse/dna-web-jcr-rest-client/target/classes/org/jboss/dna/web/jcr/rest/client/Utils.class
===================================================================
(Binary files differ)
Property changes on: branches/eclipse/dna-web-jcr-rest-client/target/classes/org/jboss/dna/web/jcr/rest/client/Utils.class
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: branches/eclipse/dna-web-jcr-rest-client/target/classes/org/jboss/dna/web/jcr/rest/client/domain/IDnaObject.class
===================================================================
(Binary files differ)
Property changes on: branches/eclipse/dna-web-jcr-rest-client/target/classes/org/jboss/dna/web/jcr/rest/client/domain/IDnaObject.class
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: branches/eclipse/dna-web-jcr-rest-client/target/classes/org/jboss/dna/web/jcr/rest/client/domain/Repository.class
===================================================================
(Binary files differ)
Property changes on: branches/eclipse/dna-web-jcr-rest-client/target/classes/org/jboss/dna/web/jcr/rest/client/domain/Repository.class
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: branches/eclipse/dna-web-jcr-rest-client/target/classes/org/jboss/dna/web/jcr/rest/client/domain/Server.class
===================================================================
(Binary files differ)
Property changes on: branches/eclipse/dna-web-jcr-rest-client/target/classes/org/jboss/dna/web/jcr/rest/client/domain/Server.class
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: branches/eclipse/dna-web-jcr-rest-client/target/classes/org/jboss/dna/web/jcr/rest/client/domain/Workspace.class
===================================================================
(Binary files differ)
Property changes on: branches/eclipse/dna-web-jcr-rest-client/target/classes/org/jboss/dna/web/jcr/rest/client/domain/Workspace.class
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: branches/eclipse/dna-web-jcr-rest-client/target/classes/org/jboss/dna/web/jcr/rest/client/domain/validation/RepositoryValidator.class
===================================================================
(Binary files differ)
Property changes on: branches/eclipse/dna-web-jcr-rest-client/target/classes/org/jboss/dna/web/jcr/rest/client/domain/validation/RepositoryValidator.class
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: branches/eclipse/dna-web-jcr-rest-client/target/classes/org/jboss/dna/web/jcr/rest/client/domain/validation/ServerValidator.class
===================================================================
(Binary files differ)
Property changes on: branches/eclipse/dna-web-jcr-rest-client/target/classes/org/jboss/dna/web/jcr/rest/client/domain/validation/ServerValidator.class
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: branches/eclipse/dna-web-jcr-rest-client/target/classes/org/jboss/dna/web/jcr/rest/client/domain/validation/WorkspaceValidator.class
===================================================================
(Binary files differ)
Property changes on: branches/eclipse/dna-web-jcr-rest-client/target/classes/org/jboss/dna/web/jcr/rest/client/domain/validation/WorkspaceValidator.class
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: branches/eclipse/dna-web-jcr-rest-client/target/classes/org/jboss/dna/web/jcr/rest/client/json/GetRepositoriesRequest.class
===================================================================
(Binary files differ)
Property changes on: branches/eclipse/dna-web-jcr-rest-client/target/classes/org/jboss/dna/web/jcr/rest/client/json/GetRepositoriesRequest.class
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: branches/eclipse/dna-web-jcr-rest-client/target/classes/org/jboss/dna/web/jcr/rest/client/json/GetWorkspacesRequest.class
===================================================================
(Binary files differ)
Property changes on: branches/eclipse/dna-web-jcr-rest-client/target/classes/org/jboss/dna/web/jcr/rest/client/json/GetWorkspacesRequest.class
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: branches/eclipse/dna-web-jcr-rest-client/target/classes/org/jboss/dna/web/jcr/rest/client/json/IsPublishedRequest.class
===================================================================
(Binary files differ)
Property changes on: branches/eclipse/dna-web-jcr-rest-client/target/classes/org/jboss/dna/web/jcr/rest/client/json/IsPublishedRequest.class
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: branches/eclipse/dna-web-jcr-rest-client/target/classes/org/jboss/dna/web/jcr/rest/client/json/IsServerAliveRequest.class
===================================================================
(Binary files differ)
Property changes on: branches/eclipse/dna-web-jcr-rest-client/target/classes/org/jboss/dna/web/jcr/rest/client/json/IsServerAliveRequest.class
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: branches/eclipse/dna-web-jcr-rest-client/target/classes/org/jboss/dna/web/jcr/rest/client/json/JsonRequestFactory.class
===================================================================
(Binary files differ)
Property changes on: branches/eclipse/dna-web-jcr-rest-client/target/classes/org/jboss/dna/web/jcr/rest/client/json/JsonRequestFactory.class
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: branches/eclipse/dna-web-jcr-rest-client/target/classes/org/jboss/dna/web/jcr/rest/client/json/JsonRestRequest$Method.class
===================================================================
(Binary files differ)
Property changes on: branches/eclipse/dna-web-jcr-rest-client/target/classes/org/jboss/dna/web/jcr/rest/client/json/JsonRestRequest$Method.class
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: branches/eclipse/dna-web-jcr-rest-client/target/classes/org/jboss/dna/web/jcr/rest/client/json/JsonRestRequest.class
===================================================================
(Binary files differ)
Property changes on: branches/eclipse/dna-web-jcr-rest-client/target/classes/org/jboss/dna/web/jcr/rest/client/json/JsonRestRequest.class
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: branches/eclipse/dna-web-jcr-rest-client/target/classes/org/jboss/dna/web/jcr/rest/client/json/PublishCommand$1.class
===================================================================
(Binary files differ)
Property changes on: branches/eclipse/dna-web-jcr-rest-client/target/classes/org/jboss/dna/web/jcr/rest/client/json/PublishCommand$1.class
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: branches/eclipse/dna-web-jcr-rest-client/target/classes/org/jboss/dna/web/jcr/rest/client/json/PublishCommand.class
===================================================================
(Binary files differ)
Property changes on: branches/eclipse/dna-web-jcr-rest-client/target/classes/org/jboss/dna/web/jcr/rest/client/json/PublishCommand.class
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: branches/eclipse/dna-web-jcr-rest-client/target/classes/org/jboss/dna/web/jcr/rest/client/json/PublishRequest.class
===================================================================
(Binary files differ)
Property changes on: branches/eclipse/dna-web-jcr-rest-client/target/classes/org/jboss/dna/web/jcr/rest/client/json/PublishRequest.class
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: branches/eclipse/dna-web-jcr-rest-client/target/classes/org/jboss/dna/web/jcr/rest/client/json/UnpublishRequest.class
===================================================================
(Binary files differ)
Property changes on: branches/eclipse/dna-web-jcr-rest-client/target/classes/org/jboss/dna/web/jcr/rest/client/json/UnpublishRequest.class
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: branches/eclipse/dna-web-jcr-rest-client/target/classes/org/jboss/dna/web/jcr/rest/client/publish/IRestRequest.class
===================================================================
(Binary files differ)
Property changes on: branches/eclipse/dna-web-jcr-rest-client/target/classes/org/jboss/dna/web/jcr/rest/client/publish/IRestRequest.class
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: branches/eclipse/dna-web-jcr-rest-client/target/classes/org/jboss/dna/web/jcr/rest/client/publish/IRestRequestFactory.class
===================================================================
(Binary files differ)
Property changes on: branches/eclipse/dna-web-jcr-rest-client/target/classes/org/jboss/dna/web/jcr/rest/client/publish/IRestRequestFactory.class
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: branches/eclipse/dna-web-jcr-rest-client/target/classes/org/jboss/dna/web/jcr/rest/client/publish/IRestResponse.class
===================================================================
(Binary files differ)
Property changes on: branches/eclipse/dna-web-jcr-rest-client/target/classes/org/jboss/dna/web/jcr/rest/client/publish/IRestResponse.class
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: branches/eclipse/dna-web-jcr-rest-client/target/dna-web-jcr-rest-client-0.6-SNAPSHOT-sources.jar
===================================================================
(Binary files differ)
Property changes on: branches/eclipse/dna-web-jcr-rest-client/target/dna-web-jcr-rest-client-0.6-SNAPSHOT-sources.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: branches/eclipse/dna-web-jcr-rest-client/target/dna-web-jcr-rest-client-0.6-SNAPSHOT-test-sources.jar
===================================================================
(Binary files differ)
Property changes on: branches/eclipse/dna-web-jcr-rest-client/target/dna-web-jcr-rest-client-0.6-SNAPSHOT-test-sources.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: branches/eclipse/dna-web-jcr-rest-client/target/dna-web-jcr-rest-client-0.6-SNAPSHOT-tests.jar
===================================================================
(Binary files differ)
Property changes on: branches/eclipse/dna-web-jcr-rest-client/target/dna-web-jcr-rest-client-0.6-SNAPSHOT-tests.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: branches/eclipse/dna-web-jcr-rest-client/target/dna-web-jcr-rest-client-0.6-SNAPSHOT.jar
===================================================================
(Binary files differ)
Property changes on: branches/eclipse/dna-web-jcr-rest-client/target/dna-web-jcr-rest-client-0.6-SNAPSHOT.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: branches/eclipse/dna-web-jcr-rest-client/target/maven-archiver/pom.properties
===================================================================
--- branches/eclipse/dna-web-jcr-rest-client/target/maven-archiver/pom.properties (rev 0)
+++ branches/eclipse/dna-web-jcr-rest-client/target/maven-archiver/pom.properties 2009-07-14 12:59:48 UTC (rev 1111)
@@ -0,0 +1,5 @@
+#Generated by Maven
+#Thu Jul 09 09:17:20 CDT 2009
+version=0.6-SNAPSHOT
+groupId=org.jboss.dna
+artifactId=dna-web-jcr-rest-client
Property changes on: branches/eclipse/dna-web-jcr-rest-client/target/maven-archiver/pom.properties
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: branches/eclipse/dna-web-jcr-rest-client/target/test-classes/log4j.properties
===================================================================
--- branches/eclipse/dna-web-jcr-rest-client/target/test-classes/log4j.properties (rev 0)
+++ branches/eclipse/dna-web-jcr-rest-client/target/test-classes/log4j.properties 2009-07-14 12:59:48 UTC (rev 1111)
@@ -0,0 +1,28 @@
+# Direct log messages to stdout
+log4j.appender.stdout=org.apache.log4j.ConsoleAppender
+log4j.appender.stdout.Target=System.out
+log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
+log4j.appender.stdout.layout.ConversionPattern=%d{ABSOLUTE} %5p %m%n
+
+# Direct log messages to a file
+log4j.appender.testlog=org.apache.log4j.FileAppender
+log4j.appender.testlog.File=target/logs/test/org.jboss.dna.web.jcr.rest.client.Test.log
+log4j.appender.testlog.layout=org.apache.log4j.PatternLayout
+log4j.appender.testlog.layout.ConversionPattern=%d{ABSOLUTE} %5p %m%n
+
+# Direct log messages to a file and use Mapped Diagnostic Contexts (MDC)
+log4j.appender.testlog-mdc=org.apache.log4j.FileAppender
+log4j.appender.testlog-mdc.File=target/logs/test/org.jboss.dna.web.jcr.rest.client.Test.log
+log4j.appender.testlog-mdc.layout=org.apache.log4j.PatternLayout
+log4j.appender.testlog-mdc.layout.ConversionPattern=%d{ABSOLUTE} %5p [%X{username}] %m%n
+
+# Root logger option
+log4j.rootLogger=INFO, stdout, testlog, testlog-mdc
+
+# Set up the default logging to be INFO level, then override specific units
+log4j.logger.org.jboss.dna=INFO
+
+# Set up the logging for the LoggerTest test cases (which need this to be explicitly set rather than inherited)
+log4j.logger.org.jboss.dna.common.util.LoggerTest=INFO
+
+
16 years, 9 months