DNA SVN: r924 - trunk/extensions/dna-connector-svn/src/main/java/org/jboss/dna/connector/svn.
by dna-commits@lists.jboss.org
Author: spagop
Date: 2009-05-22 09:13:01 -0400 (Fri, 22 May 2009)
New Revision: 924
Added:
trunk/extensions/dna-connector-svn/src/main/java/org/jboss/dna/connector/svn/RepositoryAccessData.java
Log:
store the access data for repository
Added: trunk/extensions/dna-connector-svn/src/main/java/org/jboss/dna/connector/svn/RepositoryAccessData.java
===================================================================
--- trunk/extensions/dna-connector-svn/src/main/java/org/jboss/dna/connector/svn/RepositoryAccessData.java (rev 0)
+++ trunk/extensions/dna-connector-svn/src/main/java/org/jboss/dna/connector/svn/RepositoryAccessData.java 2009-05-22 13:13:01 UTC (rev 924)
@@ -0,0 +1,49 @@
+/**
+ *
+ */
+package org.jboss.dna.connector.svn;
+
+import net.jcip.annotations.ThreadSafe;
+
+@ThreadSafe
+public class RepositoryAccessData {
+
+
+ private String repositoryRootUrl;
+ private String username;
+ private String password;
+
+ /**
+ * @param password
+ * @param username
+ * @param repositoryRootUrl
+ */
+ public RepositoryAccessData( String repositoryRootUrl,
+ String username,
+ String password ) {
+ this.repositoryRootUrl = repositoryRootUrl;
+ this.username = username;
+ this.password = password;
+ }
+
+ /**
+ * @return the repositoryRootUrl
+ */
+ public String getRepositoryRootUrl() {
+ return repositoryRootUrl;
+ }
+
+ /**
+ * @return the username
+ */
+ public String getUsername() {
+ return username;
+ }
+
+ /**
+ * @return the password
+ */
+ public String getPassword() {
+ return password;
+ }
+}
15 years, 1 month
DNA SVN: r923 - in trunk: dna-common/src/test/java/org/jboss/dna/common/jcr and 11 other directories.
by dna-commits@lists.jboss.org
Author: rhauch
Date: 2009-05-21 22:15:19 -0400 (Thu, 21 May 2009)
New Revision: 923
Added:
trunk/docs/examples/gettingstarted/sequencers/src/main/java/org/jboss/example/dna/sequencer/JcrTools.java
trunk/extensions/dna-classloader-maven/src/test/java/org/jboss/dna/maven/AbstractJcrRepositoryTest.java
trunk/extensions/dna-classloader-maven/src/test/java/org/jboss/dna/maven/TestAbstractJcrRepositoryTest.java
Removed:
trunk/dna-common/src/test/java/org/jboss/dna/common/jcr/AbstractJcrRepositoryTest.java
trunk/dna-common/src/test/java/org/jboss/dna/common/jcr/TestAbstractJcrRepositoryTest.java
trunk/dna-repository/src/main/java/org/jboss/dna/repository/observation/NodeChange.java
trunk/dna-repository/src/main/java/org/jboss/dna/repository/observation/NodeChangeListener.java
trunk/dna-repository/src/main/java/org/jboss/dna/repository/observation/NodeChanges.java
trunk/dna-repository/src/main/java/org/jboss/dna/repository/observation/ObservationService.java
trunk/dna-repository/src/main/java/org/jboss/dna/repository/rules/InvalidRuleSetException.java
trunk/dna-repository/src/main/java/org/jboss/dna/repository/rules/RuleService.java
trunk/dna-repository/src/main/java/org/jboss/dna/repository/rules/RuleSet.java
trunk/dna-repository/src/main/java/org/jboss/dna/repository/rules/RuleSetRepositoryMonitor.java
trunk/dna-repository/src/main/java/org/jboss/dna/repository/util/JcrExecutionContext.java
trunk/dna-repository/src/main/java/org/jboss/dna/repository/util/JcrNamespaceRegistry.java
trunk/dna-repository/src/main/java/org/jboss/dna/repository/util/JcrTools.java
trunk/dna-repository/src/main/java/org/jboss/dna/repository/util/JndiSessionFactory.java
trunk/dna-repository/src/test/java/org/jboss/dna/repository/observation/NodeChangeTest.java
trunk/dna-repository/src/test/java/org/jboss/dna/repository/rules/RuleInput.java
trunk/dna-repository/src/test/java/org/jboss/dna/repository/rules/RuleResult.java
trunk/dna-repository/src/test/java/org/jboss/dna/repository/rules/RuleServiceTest.java
trunk/dna-repository/src/test/java/org/jboss/dna/repository/rules/RuleSetTest.java
trunk/dna-repository/src/test/java/org/jboss/dna/repository/util/JndiSessionFactoryTest.java
Modified:
trunk/dna-common/pom.xml
trunk/dna-repository/pom.xml
trunk/dna-repository/src/main/java/org/jboss/dna/repository/sequencer/Sequencer.java
trunk/dna-repository/src/main/java/org/jboss/dna/repository/sequencer/SequencingService.java
trunk/docs/examples/gettingstarted/sequencers/src/main/java/org/jboss/example/dna/sequencer/SequencingClient.java
trunk/extensions/dna-classloader-maven/src/test/java/org/jboss/dna/maven/MavenRepositoryTest.java
trunk/extensions/dna-classloader-maven/src/test/java/org/jboss/dna/maven/spi/JcrMavenUrlProviderTest.java
Log:
DNA-404 Remove ObservationService, migrate usage to observe RepositoryLibrary
Removed the ObservationService and the 'org.jboss.dna.repository.observation' package. Also removed the JCR API, since the ObservationService (and a few leftover JCR utility classes) were the only remaining use of JCR API in 'dna-repository'. Also removed the 'o.j.d.r.rules' package, since we're still not using JSR-92 rules for sequencers (path expressions are still very adequate, and we can always resurrect the code if needed). And finally, 'dna-repository' no longer needs the JCR unit test utilities that are in 'dna-common', so they were removed (actually copied into the 'dna-classloader-maven' project, which still uses JCR API), allowing 'dna-common' to no longer rely upon JCR API and Jackrabbit for test scope.
Modified: trunk/dna-common/pom.xml
===================================================================
--- trunk/dna-common/pom.xml 2009-05-21 22:26:25 UTC (rev 922)
+++ trunk/dna-common/pom.xml 2009-05-22 02:15:19 UTC (rev 923)
@@ -54,24 +54,6 @@
<groupId>net.jcip</groupId>
<artifactId>jcip-annotations</artifactId>
</dependency>
- <!--
- Java Content Repository API and Apache Jackrabbit for the JCR unit test infrastructure
- -->
- <dependency>
- <groupId>javax.jcr</groupId>
- <artifactId>jcr</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.jackrabbit</groupId>
- <artifactId>jackrabbit-api</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.jackrabbit</groupId>
- <artifactId>jackrabbit-core</artifactId>
- <scope>test</scope>
- </dependency>
</dependencies>
<reporting>
<plugins>
Deleted: trunk/dna-common/src/test/java/org/jboss/dna/common/jcr/AbstractJcrRepositoryTest.java
===================================================================
--- trunk/dna-common/src/test/java/org/jboss/dna/common/jcr/AbstractJcrRepositoryTest.java 2009-05-21 22:26:25 UTC (rev 922)
+++ trunk/dna-common/src/test/java/org/jboss/dna/common/jcr/AbstractJcrRepositoryTest.java 2009-05-22 02:15:19 UTC (rev 923)
@@ -1,178 +0,0 @@
-/*
- * JBoss DNA (http://www.jboss.org/dna)
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- * See the AUTHORS.txt file in the distribution for a full listing of
- * individual contributors.
- *
- * JBoss DNA is free software. Unless otherwise indicated, all code in JBoss DNA
- * is licensed to you under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * JBoss DNA is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.dna.common.jcr;
-
-import java.io.IOException;
-import javax.jcr.Credentials;
-import javax.jcr.Repository;
-import javax.jcr.RepositoryException;
-import javax.jcr.Session;
-import javax.jcr.SimpleCredentials;
-import org.apache.jackrabbit.api.JackrabbitRepository;
-import org.apache.jackrabbit.core.TransientRepository;
-import org.jboss.dna.common.util.FileUtil;
-import org.jboss.dna.common.util.Logger;
-import org.junit.After;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
-
-/**
- * An abstract base class for any unit test class that needs a JCR repository during one or more (but not necessarily all) of its
- * unit tests.
- * <p>
- * Typically, unit test classes need a repository for just some of it's unit tests (other unit tests don't need the repository
- * because they are just testing other functionality of the class under test), and this class was designed for this scenario. A
- * unit test method that needs a repository should call {@link #startRepository()}, and then may proceed to use the
- * {@link #getRepository() repository}. The test method need not call {@link #shutdownRepository()}, as it is called automatically
- * after every test (and does nothing if the repository was not started in the first place).
- * </p>
- * <p>
- * Some unit test methods may have a need to repeatedly start and stop the repository, and this can be done by calling
- * {@link #startRepository()} and {@link #shutdownRepository()} as many times as required.
- * </p>
- * <p>
- * Because the {@link TransientRepository transient repository} implementation used by this class automatically cleans itself up
- * whenever all {@link Session sessions} are closed, this class maintains an open session between the time the repository is
- * started and stopped. Therefore, unit tests can persist information in one session and see the information in other sessions.
- * </p>
- *
- * @author Randall Hauch
- */
-public abstract class AbstractJcrRepositoryTest {
-
- public static final String TESTDATA_PATH = "./src/test/resources/";
- public static final String JACKRABBIT_DATA_PATH = "./target/testdata/jackrabbittest/";
- public static final String REPOSITORY_DIRECTORY_PATH = JACKRABBIT_DATA_PATH + "repository";
- public static final String REPOSITORY_CONFIG_PATH = TESTDATA_PATH + "jackrabbitInMemoryTestRepositoryConfig.xml";
-
- public static final String WORKSPACE_NAME = "default";
-
- private static Repository repository;
-
- @BeforeClass
- public static void beforeAll() throws Exception {
- // Clean up the test data ...
- FileUtil.delete(JACKRABBIT_DATA_PATH);
-
- // Set up the transient repository (this shouldn't do anything yet)...
- repository = new TransientRepository(REPOSITORY_CONFIG_PATH, REPOSITORY_DIRECTORY_PATH);
- }
-
- @AfterClass
- public static void afterAll() {
- if (repository != null) {
- try {
- JackrabbitRepository jackrabbit = (JackrabbitRepository)repository;
- jackrabbit.shutdown();
- } finally {
- repository = null;
- // Clean up the test data ...
- FileUtil.delete(JACKRABBIT_DATA_PATH);
- }
- }
- }
-
- /** Used to keep at least one session open during each test; when last session is closed, all data is cleaned up */
- private Session keepAliveSession;
-
- protected Credentials simpleCredentials = new SimpleCredentials("jsmith", "secret".toCharArray());
-
- /**
- * Call this method during a test that needs the repository. It only needs to be called once during a test, although calling
- * it more than once does not hurt.
- * <p>
- * The repository can be started and {@link #shutdownRepository() shutdown} repeatedly during a single test.
- * </p>
- *
- * @throws RepositoryException if there is a problem starting the repository
- * @throws IOException if there's a problem reading the repository configuration
- * @see #shutdownRepository()
- */
- public synchronized void startRepository() throws RepositoryException, IOException {
- if (repository == null) {
- // Clean up the test data ...
- FileUtil.delete(JACKRABBIT_DATA_PATH);
-
- // Set up the transient repository (this shouldn't do anything yet)...
- repository = new TransientRepository(REPOSITORY_CONFIG_PATH, REPOSITORY_DIRECTORY_PATH);
-
- }
- if (keepAliveSession == null) {
- keepAliveSession = repository.login();
- }
- }
-
- /**
- * Shutdown the repository. This method is automatically called after every test, and does nothing if the repository has not
- * yet been started.
- */
- @After
- public synchronized void shutdownRepository() {
- if (keepAliveSession != null) {
- try {
- Logger.getLogger(this.getClass()).debug("Shutting down repository");
- keepAliveSession.logout();
- } finally {
- keepAliveSession = null;
- if (repository != null) {
- try {
- JackrabbitRepository jackrabbit = (JackrabbitRepository)repository;
- jackrabbit.shutdown();
- } finally {
- repository = null;
- // Clean up the test data ...
- FileUtil.delete(JACKRABBIT_DATA_PATH);
- }
- }
- }
- }
- }
-
- public boolean isRepositoryStarted() {
- return this.keepAliveSession != null;
- }
-
- /**
- * Get the repository. This will start the repository if necessary.
- *
- * @return repository
- * @throws RepositoryException if there is a problem obtaining the repository
- * @throws IOException if the repository has not yet been {@link #startRepository() started} and there's a problem reading the
- * repository configuration
- */
- public Repository getRepository() throws RepositoryException, IOException {
- startRepository();
- return repository;
- }
-
- /**
- * Get credentials that can be used to log into the repository.
- *
- * @return credentials
- */
- public Credentials getTestCredentials() {
- return this.simpleCredentials;
- }
-
-}
Deleted: trunk/dna-common/src/test/java/org/jboss/dna/common/jcr/TestAbstractJcrRepositoryTest.java
===================================================================
--- trunk/dna-common/src/test/java/org/jboss/dna/common/jcr/TestAbstractJcrRepositoryTest.java 2009-05-21 22:26:25 UTC (rev 922)
+++ trunk/dna-common/src/test/java/org/jboss/dna/common/jcr/TestAbstractJcrRepositoryTest.java 2009-05-22 02:15:19 UTC (rev 923)
@@ -1,89 +0,0 @@
-/*
- * JBoss DNA (http://www.jboss.org/dna)
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- * See the AUTHORS.txt file in the distribution for a full listing of
- * individual contributors.
- *
- * JBoss DNA is free software. Unless otherwise indicated, all code in JBoss DNA
- * is licensed to you under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * JBoss DNA is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-
-package org.jboss.dna.common.jcr;
-
-import static org.hamcrest.core.Is.is;
-import static org.hamcrest.core.IsNull.notNullValue;
-import static org.junit.Assert.assertThat;
-import javax.jcr.Node;
-import javax.jcr.Session;
-import org.junit.Test;
-
-/**
- * @author Randall Hauch
- */
-public class TestAbstractJcrRepositoryTest extends AbstractJcrRepositoryTest {
-
- @Test
- public void shouldBeAbleToStartAndShutdownRepository() throws Exception {
- for (int i = 0; i != 3; ++i) {
- startRepository();
- Session session = getRepository().login(getTestCredentials());
- assertThat(session, is(notNullValue()));
- assertThat(session.getRootNode(), is(notNullValue()));
- // Create a child node ...
- Node node = session.getRootNode().addNode("testnode", "nt:unstructured");
- assertThat(node, is(notNullValue()));
- assertThat(node.getName(), is("testnode"));
- assertThat(node.getPath(), is("/testnode"));
- // Save and close the session ...
- session.save();
- session.logout();
- shutdownRepository();
- }
- }
-
- @Test
- public void shouldAllowDataPersistedInOneSessionBeAccessibleInOtherSessions() throws Exception {
- startRepository();
- Session session = getRepository().login(getTestCredentials());
- assertThat(session, is(notNullValue()));
- assertThat(session.getRootNode(), is(notNullValue()));
- // Create a child node ...
- Node node = session.getRootNode().addNode("testnode", "nt:unstructured");
- assertThat(node, is(notNullValue()));
- assertThat(node.getName(), is("testnode"));
- assertThat(node.getPath(), is("/testnode"));
- // Save and close the session ...
- session.save();
- session.logout();
-
- for (int i = 0; i != 3; ++i) {
- // Create another session ...
- session = getRepository().login(getTestCredentials());
- assertThat(session, is(notNullValue()));
- assertThat(session.getRootNode(), is(notNullValue()));
- // Look for the child node ...
- node = session.getRootNode().getNode("testnode");
- assertThat(node, is(notNullValue()));
- assertThat(node.getName(), is("testnode"));
- assertThat(node.getPath(), is("/testnode"));
- // Close the session ...
- session.logout();
- }
-
- }
-
-}
Modified: trunk/dna-repository/pom.xml
===================================================================
--- trunk/dna-repository/pom.xml 2009-05-21 22:26:25 UTC (rev 922)
+++ trunk/dna-repository/pom.xml 2009-05-22 02:15:19 UTC (rev 923)
@@ -51,23 +51,6 @@
<scope>test</scope>
</dependency>
<!--
- Rules
- -->
- <dependency>
- <groupId>jsr94</groupId>
- <artifactId>jsr94</artifactId>
- </dependency>
- <dependency>
- <groupId>org.drools</groupId>
- <artifactId>drools-jsr94</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.drools</groupId>
- <artifactId>drools-compiler</artifactId>
- <scope>test</scope>
- </dependency>
- <!--
Testing (note the scope)
-->
<dependency>
@@ -110,16 +93,5 @@
<groupId>javax.jcr</groupId>
<artifactId>jcr</artifactId>
</dependency>
- <!--
- Apache Jackrabbit (JCR Implementation) for testing purposes
- -->
- <dependency>
- <groupId>org.apache.jackrabbit</groupId>
- <artifactId>jackrabbit-api</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.jackrabbit</groupId>
- <artifactId>jackrabbit-core</artifactId>
- </dependency>
</dependencies>
</project>
\ No newline at end of file
Deleted: trunk/dna-repository/src/main/java/org/jboss/dna/repository/observation/NodeChange.java
===================================================================
--- trunk/dna-repository/src/main/java/org/jboss/dna/repository/observation/NodeChange.java 2009-05-21 22:26:25 UTC (rev 922)
+++ trunk/dna-repository/src/main/java/org/jboss/dna/repository/observation/NodeChange.java 2009-05-22 02:15:19 UTC (rev 923)
@@ -1,188 +0,0 @@
-/*
- * JBoss DNA (http://www.jboss.org/dna)
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- * See the AUTHORS.txt file in the distribution for a full listing of
- * individual contributors.
- *
- * JBoss DNA is free software. Unless otherwise indicated, all code in JBoss DNA
- * is licensed to you under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * JBoss DNA is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.dna.repository.observation;
-
-import java.util.Collections;
-import java.util.Set;
-import net.jcip.annotations.Immutable;
-import org.jboss.dna.common.util.HashCode;
-
-/**
- * A notification of changes to a node.
- * @author Randall Hauch
- */
-@Immutable
-public class NodeChange {
-
- private final String repositorySourceName;
- private final String repositoryWorkspaceName;
- private final String absolutePath;
- private final int eventTypes;
- private final Set<String> modifiedProperties;
- private final Set<String> removedProperties;
- private final int hc;
-
- public NodeChange( String repositorySourceName, String repositoryWorkspaceName, String absolutePath, int eventTypes, Set<String> modifiedProperties, Set<String> removedProperties ) {
- assert repositorySourceName != null;
- assert repositoryWorkspaceName != null;
- assert absolutePath != null;
- this.repositorySourceName = repositorySourceName;
- this.repositoryWorkspaceName = repositoryWorkspaceName;
- this.absolutePath = absolutePath.trim();
- this.hc = HashCode.compute(this.repositoryWorkspaceName, this.absolutePath);
- this.eventTypes = eventTypes;
- if (modifiedProperties == null) modifiedProperties = Collections.emptySet();
- if (removedProperties == null) removedProperties = Collections.emptySet();
- this.modifiedProperties = Collections.unmodifiableSet(modifiedProperties);
- this.removedProperties = Collections.unmodifiableSet(removedProperties);
- }
-
- /**
- * @return absolutePath
- */
- public String getAbsolutePath() {
- return this.absolutePath;
- }
-
- /**
- * @return repositorySourceName
- */
- public String getRepositorySourceName() {
- return this.repositorySourceName;
- }
-
- /**
- * @return repositoryWorkspaceName
- */
- public String getRepositoryWorkspaceName() {
- return this.repositoryWorkspaceName;
- }
-
- /**
- * @return modifiedProperties
- */
- public Set<String> getModifiedProperties() {
- return this.modifiedProperties;
- }
-
- /**
- * @return removedProperties
- */
- public Set<String> getRemovedProperties() {
- return this.removedProperties;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public int hashCode() {
- return this.hc;
- }
-
- public boolean includesAllEventTypes( int... jcrEventTypes ) {
- for (int jcrEventType : jcrEventTypes) {
- if ((this.eventTypes & jcrEventType) == 0) return false;
- }
- return true;
- }
-
- public boolean includesEventTypes( int... jcrEventTypes ) {
- for (int jcrEventType : jcrEventTypes) {
- if ((this.eventTypes & jcrEventType) != 0) return true;
- }
- return false;
- }
-
- public boolean isSameNode( NodeChange that ) {
- if (that == this) return true;
- if (this.hc != that.hc) return false;
- if (!this.repositoryWorkspaceName.equals(that.repositoryWorkspaceName)) return false;
- if (!this.absolutePath.equals(that.absolutePath)) return false;
- return true;
- }
-
- /**
- * Return whether this node change occurs on a node on the supplied path.
- * @param absolutePath the path
- * @return true if the node is on the supplied absolute path, or false otherwise
- * @see #isNotOnPath(String)
- */
- public boolean isOnPath( String absolutePath ) {
- if (absolutePath == null) return false;
- if (this.getAbsolutePath().startsWith(absolutePath)) return true;
- return false;
- }
-
- /**
- * Return whether this node change occurs on a node on a different path than that supplied.
- * @param absolutePath the path
- * @return true if the node is on a different path, or false if it is on the same path
- * @see #isOnPath(String)
- */
- public boolean isNotOnPath( String absolutePath ) {
- return !isOnPath(absolutePath);
- }
-
- /**
- * Determine whether this node change includes the setting of new value(s) for the supplied property.
- * @param property the name of the property
- * @return true if the named property has a new value on this node, or false otherwise
- */
- public boolean isPropertyModified( String property ) {
- return this.modifiedProperties.contains(property);
- }
-
- /**
- * Determine whether this node change includes the removal of the supplied property.
- * @param property the name of the property
- * @return true if the named property was removed from this node, or false otherwise
- */
- public boolean isPropertyRemoved( String property ) {
- return this.removedProperties.contains(property);
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public boolean equals( Object obj ) {
- if (obj == this) return true;
- if (obj instanceof NodeChange) {
- NodeChange that = (NodeChange)obj;
- if (!this.isSameNode(that)) return false;
- if (this.eventTypes != that.eventTypes) return false;
- return true;
- }
- return false;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public String toString() {
- return this.repositoryWorkspaceName + "=>" + this.absolutePath;
- }
-}
Deleted: trunk/dna-repository/src/main/java/org/jboss/dna/repository/observation/NodeChangeListener.java
===================================================================
--- trunk/dna-repository/src/main/java/org/jboss/dna/repository/observation/NodeChangeListener.java 2009-05-21 22:26:25 UTC (rev 922)
+++ trunk/dna-repository/src/main/java/org/jboss/dna/repository/observation/NodeChangeListener.java 2009-05-22 02:15:19 UTC (rev 923)
@@ -1,33 +0,0 @@
-/*
- * JBoss DNA (http://www.jboss.org/dna)
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- * See the AUTHORS.txt file in the distribution for a full listing of
- * individual contributors.
- *
- * JBoss DNA is free software. Unless otherwise indicated, all code in JBoss DNA
- * is licensed to you under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * JBoss DNA is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.dna.repository.observation;
-
-/**
- * @author Randall Hauch
- */
-public interface NodeChangeListener {
-
- void onNodeChanges( NodeChanges changes );
-
-}
Deleted: trunk/dna-repository/src/main/java/org/jboss/dna/repository/observation/NodeChanges.java
===================================================================
--- trunk/dna-repository/src/main/java/org/jboss/dna/repository/observation/NodeChanges.java 2009-05-21 22:26:25 UTC (rev 922)
+++ trunk/dna-repository/src/main/java/org/jboss/dna/repository/observation/NodeChanges.java 2009-05-22 02:15:19 UTC (rev 923)
@@ -1,197 +0,0 @@
-/*
- * JBoss DNA (http://www.jboss.org/dna)
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- * See the AUTHORS.txt file in the distribution for a full listing of
- * individual contributors.
- *
- * JBoss DNA is free software. Unless otherwise indicated, all code in JBoss DNA
- * is licensed to you under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * JBoss DNA is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.dna.repository.observation;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Comparator;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import javax.jcr.RepositoryException;
-import javax.jcr.observation.Event;
-import org.jboss.dna.common.i18n.I18n;
-import org.jboss.dna.common.util.Logger;
-import org.jboss.dna.repository.RepositoryI18n;
-
-/**
- * A utility class that builds node changes from a sequence of events.
- * @author Randall Hauch
- */
-public class NodeChanges implements Iterable<NodeChange> {
-
- public static NodeChanges create( final String repositorySourceName, final String repositoryWorkspaceName, Iterable<Event> events ) throws RepositoryException {
- Map<String, NodeChangeDetails> detailsByNodePath = new HashMap<String, NodeChangeDetails>();
- // Process each of the events, extracting the node path and property details for each ...
- for (Event event : events) {
- final int eventType = event.getType();
- final String eventPath = event.getPath();
- if (eventType == Event.PROPERTY_ADDED || eventType == Event.PROPERTY_CHANGED || eventType == Event.PROPERTY_REMOVED) {
- // Extract the node's path and property name from the even path ...
- int lastDelim = eventPath.lastIndexOf('/');
- if (lastDelim < 1 || lastDelim == (eventPath.length() - 1)) {
- // The last delimiter doesn't exist, is the first character, or is the last character...
- I18n msg =
- eventType == Event.PROPERTY_ADDED ? RepositoryI18n.errorFindingPropertyNameInPropertyAddedEvent : eventType == Event.PROPERTY_CHANGED ? RepositoryI18n.errorFindingPropertyNameInPropertyChangedEvent : RepositoryI18n.errorFindingPropertyNameInPropertyRemovedEvent;
- Logger.getLogger(NodeChanges.class).error(msg, eventPath);
- continue;
- }
- String nodePath = eventPath.substring(0, lastDelim); // excludes the last delim
- String propertyName = eventPath.substring(lastDelim + 1);
- // Record the details ...
- NodeChangeDetails details = detailsByNodePath.get(nodePath);
- if (details == null) {
- details = new NodeChangeDetails(nodePath);
- detailsByNodePath.put(nodePath, details);
- }
- switch (eventType) {
- case Event.PROPERTY_ADDED: {
- details.addProperty(propertyName);
- break;
- }
- case Event.PROPERTY_CHANGED: {
- details.changeProperty(propertyName);
- break;
- }
- case Event.PROPERTY_REMOVED: {
- details.removeProperty(propertyName);
- break;
- }
- }
- } else if (eventType == Event.NODE_ADDED || eventType == Event.NODE_REMOVED) {
- // Remove the last delimiter if it appears at the end of the path ...
- String nodePath = eventPath;
- if (nodePath.length() > 1 && nodePath.charAt(nodePath.length() - 1) == '/') {
- nodePath = nodePath.substring(0, nodePath.length() - 1);
- }
- // Record the details ...
- NodeChangeDetails details = detailsByNodePath.get(nodePath);
- if (details == null) {
- details = new NodeChangeDetails(nodePath);
- detailsByNodePath.put(nodePath, details);
- }
- details.addEventType(eventType);
- }
- }
-
- // Create the node changes ...
- List<NodeChange> result = new ArrayList<NodeChange>(detailsByNodePath.size());
- for (NodeChangeDetails detail : detailsByNodePath.values()) {
- NodeChange change = new NodeChange(repositorySourceName, repositoryWorkspaceName, detail.getNodePath(), detail.getEventTypes(), detail.getModifiedProperties(), detail.getRemovedProperties());
- result.add(change);
- }
- return new NodeChanges(result);
- }
-
- protected static class NodeChangeDetails {
-
- private final String nodePath;
- private final Set<String> modifiedProperties = new HashSet<String>();
- private final Set<String> removedProperties = new HashSet<String>();
- private int eventTypes;
-
- protected NodeChangeDetails( String nodePath ) {
- this.nodePath = nodePath;
- }
-
- public void addEventType( int eventType ) {
- this.eventTypes |= eventType;
- }
-
- public void addProperty( String propertyName ) {
- this.modifiedProperties.add(propertyName);
- this.eventTypes |= Event.PROPERTY_ADDED;
- }
-
- public void changeProperty( String propertyName ) {
- this.modifiedProperties.add(propertyName);
- this.eventTypes |= Event.PROPERTY_CHANGED;
- }
-
- public void removeProperty( String propertyName ) {
- this.removedProperties.add(propertyName);
- this.eventTypes |= Event.PROPERTY_REMOVED;
- }
-
- /**
- * @return nodeAction
- */
- public int getEventTypes() {
- return this.eventTypes;
- }
-
- /**
- * @return nodePath
- */
- public String getNodePath() {
- return this.nodePath;
- }
-
- /**
- * @return addedProperties
- */
- public Set<String> getModifiedProperties() {
- return this.modifiedProperties;
- }
-
- /**
- * @return removedProperties
- */
- public Set<String> getRemovedProperties() {
- return this.removedProperties;
- }
- }
-
- protected static final Comparator<NodeChange> PRE_ORDER = new Comparator<NodeChange>() {
-
- public int compare( NodeChange change1, NodeChange change2 ) {
- return change1.getAbsolutePath().compareTo(change2.getAbsolutePath());
- }
- };
-
- private final List<NodeChange> changesInPreOrder;
-
- protected NodeChanges( List<NodeChange> changes ) {
- this.changesInPreOrder = Collections.unmodifiableList(changes);
- }
-
- /**
- * {@inheritDoc}
- */
- public Iterator<NodeChange> iterator() {
- return this.changesInPreOrder.iterator();
- }
-
- public Iterator<NodeChange> getPreOrder() {
- return this.changesInPreOrder.iterator();
- }
-
- public int size() {
- return this.changesInPreOrder.size();
- }
-
-}
Deleted: trunk/dna-repository/src/main/java/org/jboss/dna/repository/observation/ObservationService.java
===================================================================
--- trunk/dna-repository/src/main/java/org/jboss/dna/repository/observation/ObservationService.java 2009-05-21 22:26:25 UTC (rev 922)
+++ trunk/dna-repository/src/main/java/org/jboss/dna/repository/observation/ObservationService.java 2009-05-22 02:15:19 UTC (rev 923)
@@ -1,822 +0,0 @@
-/*
- * JBoss DNA (http://www.jboss.org/dna)
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- * See the AUTHORS.txt file in the distribution for a full listing of
- * individual contributors.
- *
- * JBoss DNA is free software. Unless otherwise indicated, all code in JBoss DNA
- * is licensed to you under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * JBoss DNA is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.dna.repository.observation;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Set;
-import java.util.concurrent.CopyOnWriteArrayList;
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.atomic.AtomicLong;
-import java.util.concurrent.locks.ReadWriteLock;
-import java.util.concurrent.locks.ReentrantReadWriteLock;
-import javax.jcr.RepositoryException;
-import javax.jcr.Session;
-import javax.jcr.UnsupportedRepositoryOperationException;
-import javax.jcr.observation.Event;
-import javax.jcr.observation.EventIterator;
-import javax.jcr.observation.EventListener;
-import javax.jcr.observation.ObservationManager;
-import net.jcip.annotations.GuardedBy;
-import net.jcip.annotations.ThreadSafe;
-import org.jboss.dna.common.util.CheckArg;
-import org.jboss.dna.common.util.Logger;
-import org.jboss.dna.repository.RepositoryI18n;
-import org.jboss.dna.repository.service.AbstractServiceAdministrator;
-import org.jboss.dna.repository.service.AdministeredService;
-import org.jboss.dna.repository.service.ServiceAdministrator;
-import org.jboss.dna.repository.util.SessionFactory;
-
-/**
- * @author Randall Hauch
- */
-public class ObservationService implements AdministeredService {
-
- /**
- * Interface to which problems with particular events are logged.
- *
- * @author Randall Hauch
- */
- public static interface ProblemLog {
-
- void error( String repositoryWorkspaceName,
- Throwable t );
- }
-
- /**
- * Problem log implementation that records problems in the log.
- *
- * @author Randall Hauch
- */
- public class DefaultProblemLog implements ProblemLog {
-
- /**
- * {@inheritDoc}
- */
- public void error( String repositoryWorkspaceName,
- Throwable t ) {
- getLogger().error(t, RepositoryI18n.errorProcessingEvents, repositoryWorkspaceName);
- }
- }
-
- protected static class NoOpProblemLog implements ProblemLog {
-
- /**
- * {@inheritDoc}
- */
- public void error( String repositoryWorkspaceName,
- Throwable t ) {
- }
- }
-
- public static final ProblemLog NO_OP_PROBLEM_LOG = new NoOpProblemLog();
-
- /**
- * The administrative component for this service.
- *
- * @author Randall Hauch
- */
- protected class Administrator extends AbstractServiceAdministrator {
-
- protected Administrator() {
- super(RepositoryI18n.observationServiceName, State.STARTED);
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- protected void doShutdown( State fromState ) {
- super.doShutdown(fromState);
- shutdownService();
- }
-
- /**
- * {@inheritDoc}
- */
- public boolean awaitTermination( long timeout,
- TimeUnit unit ) {
- return true;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- protected boolean doCheckIsTerminated() {
- return true;
- }
-
- }
-
- private Logger logger = Logger.getLogger(this.getClass());
- private ProblemLog problemLog = new DefaultProblemLog();
- private final Statistics statistics = new Statistics();
- private final SessionFactory sessionFactory;
- private final CopyOnWriteArrayList<WorkspaceListener> workspaceListeners = new CopyOnWriteArrayList<WorkspaceListener>();
- private final CopyOnWriteArrayList<EventListener> eventListeners = new CopyOnWriteArrayList<EventListener>();
- private final CopyOnWriteArrayList<NodeChangeListener> nodeChangeListeners = new CopyOnWriteArrayList<NodeChangeListener>();
- private final Administrator administrator = new Administrator();
-
- public ObservationService( SessionFactory sessionFactory ) {
- CheckArg.isNotNull(sessionFactory, "session factory");
- this.sessionFactory = sessionFactory;
- }
-
- /**
- * {@inheritDoc}
- */
- public ServiceAdministrator getAdministrator() {
- return this.administrator;
- }
-
- /**
- * @return sessionFactory
- */
- public SessionFactory getSessionFactory() {
- return this.sessionFactory;
- }
-
- /**
- * Get the statistics for this system.
- *
- * @return the statistics, which are updated as the system is used
- */
- public Statistics getStatistics() {
- return this.statistics;
- }
-
- /**
- * Get the logger for this system
- *
- * @return the logger
- */
- public Logger getLogger() {
- return this.logger;
- }
-
- /**
- * Set the logger for this system.
- *
- * @param logger the logger, or null if the standard logging should be used
- */
- public void setLogger( Logger logger ) {
- this.logger = logger != null ? logger : Logger.getLogger(this.getClass());
- }
-
- /**
- * @return problemLog
- */
- public ProblemLog getProblemLog() {
- return this.problemLog;
- }
-
- /**
- * Set the problem log that will be notified of problems handling events. By default, such problems are sent to the log.
- *
- * @param problemLog the new problem log implementation; if null, then the default problem log is used
- */
- public void setProblemLog( ProblemLog problemLog ) {
- this.problemLog = problemLog != null ? problemLog : new DefaultProblemLog();
- }
-
- public boolean addListener( EventListener listener ) {
- if (listener == null) return false;
- return this.eventListeners.addIfAbsent(listener);
- }
-
- public boolean removeListener( EventListener listener ) {
- if (listener == null) return false;
- return this.eventListeners.remove(listener);
- }
-
- public boolean addListener( NodeChangeListener listener ) {
- return this.nodeChangeListeners.addIfAbsent(listener);
- }
-
- public boolean removeListener( NodeChangeListener listener ) {
- if (listener == null) return false;
- return this.nodeChangeListeners.remove(listener);
- }
-
- protected void shutdownService() {
- // Unregister all listeners ...
- for (WorkspaceListener listener : this.workspaceListeners) {
- try {
- listener.unregister();
- } catch (RepositoryException e) {
- this.logger.error(e, RepositoryI18n.errorUnregisteringWorkspaceListenerWhileShuttingDownObservationService);
- }
- }
- }
-
- /**
- * Monitor the supplied workspace in the given repository for events of the given type on any node at or under the supplied
- * path.
- * <p>
- * Monitoring is accomplished by registering a listener on the workspace, so this monitoring only has access to the
- * information that is available in the given repository and workspace name.
- * </p>
- * <p>
- * The listener returned from this method is not managed by this SequencingService instance. If the listener is no longer
- * needed, it simply must be {@link ObservationManager#removeEventListener(EventListener) removed} as a listener of the
- * workspace and garbage collected. If this service is {@link ServiceAdministrator#shutdown() shutdown} while there are still
- * active listeners, those listeners will disconnect themselves from this service and the workspace with which they're
- * registered when they attempt to forward the next events.
- * </p>
- * <p>
- * The set of events that are monitored can be filtered by specifying restrictions based on characteristics of the node
- * associated with the event. In the case of event types {@link Event#NODE_ADDED NODE_ADDED} and {@link Event#NODE_REMOVED
- * NODE_REMOVED}, the node associated with an event is the node at (or formerly at) the path returned by
- * {@link Event#getPath() Event.getPath()}. In the case of event types {@link Event#PROPERTY_ADDED PROPERTY_ADDED},
- * {@link Event#PROPERTY_REMOVED PROPERTY_REMOVED} and {@link Event#PROPERTY_CHANGED PROPERTY_CHANGED}, the node associated
- * with an event is the parent node of the property at (or formerly at) the path returned by <code>Event.getPath</code>:
- * <ul>
- * <li> <code>absolutePath</code>, <code>isDeep</code>: Only events whose associated node is at <code>absolutePath</code> (or
- * within its subtree, if <code>isDeep</code> is <code>true</code>) will be received. It is permissible to register a listener
- * for a path where no node currently exists.</li>
- * <li> <code>uuids</code>: Only events whose associated node has one of the UUIDs in this list will be received. If his
- * parameter is <code>null</code> then no UUID-related restriction is placed on events received.</li>
- * <li> <code>nodeTypeNames</code>: Only events whose associated node has one of the node types (or a subtype of one of the
- * node types) in this list will be received. If this parameter is <code>null</code> then no node type-related restriction is
- * placed on events received.</li>
- * </ul>
- * The restrictions are "ANDed" together. In other words, for a particular node to be "listened to" it must meet all the
- * restrictions.
- * </p>
- * <p>
- * Additionally, if <code>noLocal</code> is <code>true</code>, then events generated by the session through which the listener
- * was registered are ignored. Otherwise, they are not ignored.
- * </p>
- * <p>
- * The filters of an already-registered {@link WorkspaceListener} can be changed at runtime by changing the attributes and
- * {@link WorkspaceListener#reregister() registering}.
- * </p>
- *
- * @param repositorySourceName the name of the repository source to be monitored
- * @param repositoryWorkspaceName the name of the workspace within the monitored repository
- * @param absolutePath the absolute path of the node at or below which changes are to be monitored; may be null if all nodes
- * in the workspace are to be monitored
- * @param eventTypes the bitmask of the {@link Event} types that are to be monitored
- * @param isDeep true if events below the node given by the <code>absolutePath</code> or by the <code>uuids</code> are to be
- * processed, or false if only the events at the node
- * @param uuids array of UUIDs of nodes that are to be monitored; may be null or empty if the UUIDs are not known
- * @param nodeTypeNames array of node type names that are to be monitored; may be null or empty if the monitoring has no node
- * type restrictions
- * @param noLocal true if the events originating in the supplied workspace are to be ignored, or false if they are also to be
- * processed.
- * @return the listener that was created and registered to perform the monitoring
- * @throws RepositoryException if there is a problem registering the listener
- */
- public WorkspaceListener monitor( String repositorySourceName,
- String repositoryWorkspaceName,
- String absolutePath,
- int eventTypes,
- boolean isDeep,
- String[] uuids,
- String[] nodeTypeNames,
- boolean noLocal ) throws RepositoryException {
- WorkspaceListener listener = new WorkspaceListener(repositorySourceName, repositoryWorkspaceName, eventTypes,
- absolutePath, isDeep, uuids, nodeTypeNames, noLocal);
- listener.register();
- this.workspaceListeners.add(listener);
- return listener;
- }
-
- /**
- * Monitor the supplied workspace for {@link WorkspaceListener#DEFAULT_EVENT_TYPES default event types} on any node at or
- * under the supplied path in the named repository.
- * <p>
- * Monitoring is accomplished by registering a listener on the workspace, so this monitoring only has access to the
- * information that is available in the given repository and workspace name.
- * </p>
- * <p>
- * The listener returned from this method is not managed by this SequencingService instance. If the listener is no longer
- * needed, it simply must be {@link ObservationManager#removeEventListener(EventListener) removed} as a listener of the
- * workspace and garbage collected.
- * </p>
- *
- * @param repositorySourceName the name of the repository source to be monitored
- * @param repositoryWorkspaceName the name of the workspace within the monitored repository
- * @param absolutePath the absolute path of the node at or below which changes are to be monitored; may be null if all nodes
- * in the workspace are to be monitored
- * @param nodeTypeNames the names of the node types that are to be monitored; may be null or empty if the monitoring has no
- * node type restrictions
- * @return the listener that was created and registered to perform the monitoring
- * @throws RepositoryException if there is a problem registering the listener
- */
- public WorkspaceListener monitor( String repositorySourceName,
- String repositoryWorkspaceName,
- String absolutePath,
- String... nodeTypeNames ) throws RepositoryException {
- return monitor(repositorySourceName,
- repositoryWorkspaceName,
- absolutePath,
- WorkspaceListener.DEFAULT_EVENT_TYPES,
- WorkspaceListener.DEFAULT_IS_DEEP,
- null,
- nodeTypeNames,
- WorkspaceListener.DEFAULT_NO_LOCAL);
- }
-
- /**
- * Monitor the supplied workspace in the named repository for the supplied event types on any node in the workspace.
- * <p>
- * Monitoring is accomplished by registering a listener on the workspace, so this monitoring only has access to the
- * information that is available in the given repository and workspace name.
- * </p>
- * <p>
- * The listener returned from this method is not managed by this SequencingService instance. If the listener is no longer
- * needed, it simply must be {@link ObservationManager#removeEventListener(EventListener) removed} as a listener of the
- * workspace and garbage collected.
- * </p>
- *
- * @param repositorySourceName the name of the repository source to be monitored
- * @param repositoryWorkspaceName the name of the workspace within the monitored repository
- * @param eventTypes the bitmask of the {@link Event} types that are to be monitored
- * @param nodeTypeNames the names of the node types that are to be monitored; may be null or empty if the monitoring has no
- * node type restrictions
- * @return the listener that was created and registered to perform the monitoring
- * @throws RepositoryException if there is a problem registering the listener
- */
- public WorkspaceListener monitor( String repositorySourceName,
- String repositoryWorkspaceName,
- int eventTypes,
- String... nodeTypeNames ) throws RepositoryException {
- return monitor(repositorySourceName,
- repositoryWorkspaceName,
- WorkspaceListener.DEFAULT_ABSOLUTE_PATH,
- eventTypes,
- WorkspaceListener.DEFAULT_IS_DEEP,
- null,
- nodeTypeNames,
- WorkspaceListener.DEFAULT_NO_LOCAL);
- }
-
- protected void unregisterListener( WorkspaceListener listener ) {
- if (listener != null) this.workspaceListeners.remove(listener);
- }
-
- /**
- * From section 2.8.8 of the JSR-170 specification:
- * <p>
- * On each persistent change, those listeners that are entitled to receive one or more events will have their onEvent method
- * called and be passed an EventIterator. The EventIterator will contain the event bundle reflecting the persistent changes
- * made but excluding those to which that particular listener is not entitled, according to the listeners access permissions
- * and filters.
- * </p>
- *
- * @param eventIterator
- * @param listener
- */
- protected void processEvents( EventIterator eventIterator,
- WorkspaceListener listener ) {
- if (eventIterator == null) return;
- List<Event> events = new ArrayList<Event>();
- // Copy the events ...
- while (eventIterator.hasNext()) {
- events.add((Event)eventIterator.next());
- }
- if (!getAdministrator().isStarted()) {
- this.statistics.recordIgnoredEventSet(events.size());
- return;
- }
-
- // Notify the event listeners ...
- boolean notifiedSomebody = false;
- List<EventListener> eventListeners = this.eventListeners; // use one consistent snapshot
- if (!eventListeners.isEmpty()) {
- DelegatingEventIterator eventIter = new DelegatingEventIterator(events.iterator(), events.size());
- for (EventListener eventListener : eventListeners) {
- eventListener.onEvent(eventIter);
- }
- notifiedSomebody = true;
- }
-
- // Now create the node change events ...
- List<NodeChangeListener> nodeChangeListeners = this.nodeChangeListeners; // use one consistent snapshot
- if (!nodeChangeListeners.isEmpty()) {
- final String repositorySourceName = listener.getRepositorySourceName();
- final String repositoryWorkspaceName = listener.getRepositoryWorkspaceName();
- try {
- NodeChanges nodeChanges = NodeChanges.create(repositorySourceName, repositoryWorkspaceName, events);
-
- // And notify the node change listeners ...
- int nodeChangeCount = nodeChanges.size();
- this.statistics.recordNodesChanged(nodeChangeCount);
- for (NodeChangeListener nodeChangeListener : nodeChangeListeners) {
- nodeChangeListener.onNodeChanges(nodeChanges);
- }
- } catch (Throwable t) {
- getProblemLog().error(repositoryWorkspaceName, t);
- }
- notifiedSomebody = true;
- }
-
- if (notifiedSomebody) {
- this.statistics.recordEventSet(events.size());
- } else {
- this.statistics.recordIgnoredEventSet(events.size());
- }
- }
-
- protected class DelegatingEventIterator implements EventIterator {
-
- private final Iterator<Event> events;
- private final int size;
- private int position = 0;
-
- protected DelegatingEventIterator( Iterator<Event> events,
- int size ) {
- this.events = events;
- this.size = size;
- }
-
- /**
- * {@inheritDoc}
- */
- public Event nextEvent() {
- ++position;
- return events.next();
- }
-
- /**
- * {@inheritDoc}
- */
- public long getPosition() {
- return position;
- }
-
- /**
- * {@inheritDoc}
- */
- public long getSize() {
- return size;
- }
-
- /**
- * {@inheritDoc}
- */
- public void skip( long skipNum ) {
- for (int i = 0; i != skipNum; ++i) {
- next();
- }
- }
-
- /**
- * {@inheritDoc}
- */
- public boolean hasNext() {
- return events.hasNext();
- }
-
- /**
- * {@inheritDoc}
- */
- public Object next() {
- return events.next();
- }
-
- /**
- * {@inheritDoc}
- */
- public void remove() {
- // does nothing
- }
-
- }
-
- /**
- * Implementation of the {@link EventListener JCR EventListener} interface, returned by the sequencing system.
- *
- * @author Randall Hauch
- */
- @ThreadSafe
- public class WorkspaceListener implements EventListener {
-
- public static final boolean DEFAULT_IS_DEEP = true;
- public static final boolean DEFAULT_NO_LOCAL = false;
- public static final int DEFAULT_EVENT_TYPES = Event.NODE_ADDED | /* Event.NODE_REMOVED| */Event.PROPERTY_ADDED
- | Event.PROPERTY_CHANGED /* |Event.PROPERTY_REMOVED */;
- public static final String DEFAULT_ABSOLUTE_PATH = "/";
-
- private final String repositorySourceName;
- private final String repositoryWorkspaceName;
- private final Set<String> uuids;
- private final Set<String> nodeTypeNames;
- private final int eventTypes;
- private final String absolutePath;
- private final boolean deep;
- private final boolean noLocal;
- @GuardedBy( "this" )
- private transient Session session;
-
- protected WorkspaceListener( String repositorySourceName,
- String repositoryWorkspaceName,
- int eventTypes,
- String absPath,
- boolean isDeep,
- String[] uuids,
- String[] nodeTypeNames,
- boolean noLocal ) {
- assert repositorySourceName != null;
-
- this.repositorySourceName = repositorySourceName;
- this.repositoryWorkspaceName = repositoryWorkspaceName;
- this.eventTypes = eventTypes;
- this.deep = isDeep;
- this.noLocal = noLocal;
- this.absolutePath = absPath != null && absPath.trim().length() != 0 ? absPath.trim() : null;
- // Set the UUIDs ...
- Set<String> newUuids = new HashSet<String>();
- if (uuids != null) {
- for (String uuid : uuids) {
- if (uuid != null && uuid.trim().length() != 0) newUuids.add(uuid.trim());
- }
- }
- this.uuids = Collections.unmodifiableSet(newUuids);
- // Set the node type names
- Set<String> newNodeTypeNames = new HashSet<String>();
- if (nodeTypeNames != null) {
- for (String nodeTypeName : nodeTypeNames) {
- if (nodeTypeName != null && nodeTypeName.trim().length() != 0) newNodeTypeNames.add(nodeTypeName.trim());
- }
- }
- this.nodeTypeNames = Collections.unmodifiableSet(newNodeTypeNames);
- }
-
- /**
- * @return repositorySourceName
- */
- public String getRepositorySourceName() {
- return this.repositorySourceName;
- }
-
- /**
- * @return repositoryWorkspaceName
- */
- public String getRepositoryWorkspaceName() {
- return this.repositoryWorkspaceName;
- }
-
- /**
- * @return eventTypes
- */
- public int getEventTypes() {
- return this.eventTypes;
- }
-
- /**
- * @return absolutePath
- */
- public String getAbsolutePath() {
- return this.absolutePath;
- }
-
- /**
- * @return deep
- */
- public boolean isDeep() {
- return this.deep;
- }
-
- /**
- * @return noLocal
- */
- public boolean isNoLocal() {
- return this.noLocal;
- }
-
- /**
- * @return uuids
- */
- public Set<String> getUuids() {
- return this.uuids;
- }
-
- /**
- * @return nodeTypeNames
- */
- public Set<String> getNodeTypeNames() {
- return this.nodeTypeNames;
- }
-
- public synchronized boolean isRegistered() {
- if (this.session != null && getAdministrator().isShutdown()) {
- // This sequencing system has been shutdown, so unregister this listener
- try {
- unregister();
- } catch (RepositoryException re) {
- String msg = "Error unregistering workspace listener after sequencing system has been shutdow.";
- Logger.getLogger(this.getClass()).debug(re, msg);
- }
- }
- return this.session != null;
- }
-
- public synchronized WorkspaceListener register() throws UnsupportedRepositoryOperationException, RepositoryException {
- if (this.session != null) return this;
- this.session = ObservationService.this.getSessionFactory().createSession(this.repositoryWorkspaceName);
- String[] uuids = this.uuids.isEmpty() ? null : this.uuids.toArray(new String[this.uuids.size()]);
- String[] nodeTypeNames = this.nodeTypeNames.isEmpty() ? null : this.nodeTypeNames.toArray(new String[this.nodeTypeNames.size()]);
- this.session.getWorkspace().getObservationManager().addEventListener(this,
- eventTypes,
- absolutePath,
- deep,
- uuids,
- nodeTypeNames,
- noLocal);
- return this;
- }
-
- public synchronized WorkspaceListener unregister() throws UnsupportedRepositoryOperationException, RepositoryException {
- if (this.session == null) return this;
- try {
- if (this.session.isLive()) {
- this.session.getWorkspace().getObservationManager().removeEventListener(this);
- this.session.logout();
- }
- } finally {
- this.session = null;
- unregisterListener(this);
- }
- return this;
- }
-
- public synchronized WorkspaceListener reregister() throws UnsupportedRepositoryOperationException, RepositoryException {
- unregister();
- register();
- return this;
- }
-
- /**
- * {@inheritDoc}
- */
- public void onEvent( EventIterator events ) {
- if (events != null) {
- if (getAdministrator().isShutdown()) {
- // This sequencing system has been shutdown, so unregister this listener
- try {
- unregister();
- } catch (RepositoryException re) {
- String msg = "Error unregistering workspace listener after sequencing system has been shutdow.";
- Logger.getLogger(this.getClass()).debug(re, msg);
- }
- } else {
- ObservationService.this.processEvents(events, this);
- }
- }
- }
- }
-
- /**
- * The statistics for the system. Each sequencing system has an instance of this class that is updated.
- *
- * @author Randall Hauch
- */
- @ThreadSafe
- public class Statistics {
-
- @GuardedBy( "lock" )
- private long numberOfEventsIgnored;
- @GuardedBy( "lock" )
- private long numberOfEventsEnqueued;
- @GuardedBy( "lock" )
- private long numberOfEventSetsIgnored;
- @GuardedBy( "lock" )
- private long numberOfEventSetsEnqueued;
- private final AtomicLong numberOfNodeChangesEnqueued = new AtomicLong(0);
- private final ReadWriteLock lock = new ReentrantReadWriteLock();
- private final AtomicLong startTime;
-
- protected Statistics() {
- startTime = new AtomicLong(System.currentTimeMillis());
- }
-
- public Statistics reset() {
- try {
- lock.writeLock().lock();
- this.startTime.set(System.currentTimeMillis());
- this.numberOfEventsIgnored = 0;
- this.numberOfEventsEnqueued = 0;
- this.numberOfEventSetsIgnored = 0;
- this.numberOfEventSetsEnqueued = 0;
- this.numberOfNodeChangesEnqueued.set(0);
- } finally {
- lock.writeLock().unlock();
- }
- return this;
- }
-
- /**
- * @return the system time when the statistics were started
- */
- public long getStartTime() {
- return this.startTime.get();
- }
-
- /**
- * @return the number of node changes that were processed
- */
- public long getNumberOfNodeChangesEnqueued() {
- return this.numberOfNodeChangesEnqueued.get();
- }
-
- /**
- * @return the number of events that were ignored because the system was not running
- */
- public long getNumberOfEventsIgnored() {
- try {
- lock.readLock().lock();
- return this.numberOfEventsIgnored;
- } finally {
- lock.readLock().unlock();
- }
- }
-
- /**
- * @return the number of events that were enqueued for processing
- */
- public long getNumberOfEventsEnqueued() {
- try {
- lock.readLock().lock();
- return this.numberOfEventsEnqueued;
- } finally {
- lock.readLock().unlock();
- }
- }
-
- /**
- * @return the number of event sets (transactions) that were enqueued for processing
- */
- public long getNumberOfEventSetsEnqueued() {
- try {
- lock.readLock().lock();
- return this.numberOfEventSetsEnqueued;
- } finally {
- lock.readLock().unlock();
- }
- }
-
- /**
- * @return the number of event sets (transactions) that were ignored because the system was not running
- */
- public long getNumberOfEventSetsIgnored() {
- try {
- lock.readLock().lock();
- return this.numberOfEventSetsIgnored;
- } finally {
- lock.readLock().unlock();
- }
- }
-
- protected void recordNodesChanged( long changeCount ) {
- this.numberOfNodeChangesEnqueued.addAndGet(changeCount);
- }
-
- protected void recordEventSet( long eventsInSet ) {
- try {
- lock.writeLock().lock();
- this.numberOfEventsEnqueued += eventsInSet;
- ++this.numberOfEventSetsEnqueued;
- } finally {
- lock.writeLock().unlock();
- }
- }
-
- protected void recordIgnoredEventSet( long eventsInSet ) {
- try {
- lock.writeLock().lock();
- this.numberOfEventsIgnored += eventsInSet;
- this.numberOfEventSetsIgnored += 1;
- ++this.numberOfEventSetsEnqueued;
- } finally {
- lock.writeLock().unlock();
- }
- }
- }
-}
Deleted: trunk/dna-repository/src/main/java/org/jboss/dna/repository/rules/InvalidRuleSetException.java
===================================================================
--- trunk/dna-repository/src/main/java/org/jboss/dna/repository/rules/InvalidRuleSetException.java 2009-05-21 22:26:25 UTC (rev 922)
+++ trunk/dna-repository/src/main/java/org/jboss/dna/repository/rules/InvalidRuleSetException.java 2009-05-22 02:15:19 UTC (rev 923)
@@ -1,66 +0,0 @@
-/*
- * JBoss DNA (http://www.jboss.org/dna)
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- * See the AUTHORS.txt file in the distribution for a full listing of
- * individual contributors.
- *
- * JBoss DNA is free software. Unless otherwise indicated, all code in JBoss DNA
- * is licensed to you under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * JBoss DNA is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.dna.repository.rules;
-
-/**
- * @author Randall Hauch
- */
-public class InvalidRuleSetException extends RuntimeException {
-
- /**
- */
- private static final long serialVersionUID = 6739445071678626125L;
-
- /**
- *
- */
- public InvalidRuleSetException() {
- }
-
- /**
- * @param message
- */
- public InvalidRuleSetException( String message ) {
- super(message);
-
- }
-
- /**
- * @param cause
- */
- public InvalidRuleSetException( Throwable cause ) {
- super(cause);
-
- }
-
- /**
- * @param message
- * @param cause
- */
- public InvalidRuleSetException( String message, Throwable cause ) {
- super(message, cause);
-
- }
-
-}
Deleted: trunk/dna-repository/src/main/java/org/jboss/dna/repository/rules/RuleService.java
===================================================================
--- trunk/dna-repository/src/main/java/org/jboss/dna/repository/rules/RuleService.java 2009-05-21 22:26:25 UTC (rev 922)
+++ trunk/dna-repository/src/main/java/org/jboss/dna/repository/rules/RuleService.java 2009-05-22 02:15:19 UTC (rev 923)
@@ -1,509 +0,0 @@
-/*
- * JBoss DNA (http://www.jboss.org/dna)
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- * See the AUTHORS.txt file in the distribution for a full listing of
- * individual contributors.
- *
- * JBoss DNA is free software. Unless otherwise indicated, all code in JBoss DNA
- * is licensed to you under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * JBoss DNA is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.dna.repository.rules;
-
-import java.io.IOException;
-import java.io.Reader;
-import java.io.StringReader;
-import java.rmi.RemoteException;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.concurrent.CountDownLatch;
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.locks.ReadWriteLock;
-import java.util.concurrent.locks.ReentrantReadWriteLock;
-import javax.rules.ConfigurationException;
-import javax.rules.RuleRuntime;
-import javax.rules.RuleServiceProvider;
-import javax.rules.RuleServiceProviderManager;
-import javax.rules.RuleSession;
-import javax.rules.StatelessRuleSession;
-import javax.rules.admin.LocalRuleExecutionSetProvider;
-import javax.rules.admin.RuleAdministrator;
-import javax.rules.admin.RuleExecutionSet;
-import javax.rules.admin.RuleExecutionSetCreateException;
-import javax.rules.admin.RuleExecutionSetDeregistrationException;
-import net.jcip.annotations.GuardedBy;
-import net.jcip.annotations.ThreadSafe;
-import org.jboss.dna.common.SystemFailureException;
-import org.jboss.dna.common.component.ClassLoaderFactory;
-import org.jboss.dna.common.component.StandardClassLoaderFactory;
-import org.jboss.dna.common.util.CheckArg;
-import org.jboss.dna.common.util.Logger;
-import org.jboss.dna.repository.RepositoryI18n;
-import org.jboss.dna.repository.service.AbstractServiceAdministrator;
-import org.jboss.dna.repository.service.AdministeredService;
-import org.jboss.dna.repository.service.ServiceAdministrator;
-
-/**
- * A rule service that is capable of executing rule sets using one or more JSR-94 rule engines. Sets of rules are
- * {@link #addRuleSet(RuleSet) added}, {@link #updateRuleSet(RuleSet) updated}, and {@link #removeRuleSet(String) removed}
- * (usually by some other component), and then these named rule sets can be {@link #executeRules(String, Map, Object...) run} with
- * inputs and facts to obtain output.
- * <p>
- * This service is thread safe. While multiple rule sets can be safely {@link #executeRules(String, Map, Object...) executed} at
- * the same time, all executions will be properly synchronized with methods to {@link #addRuleSet(RuleSet) add},
- * {@link #updateRuleSet(RuleSet) update}, and {@link #removeRuleSet(String) remove} rule sets.
- * </p>
- *
- * @author Randall Hauch
- */
-@ThreadSafe
-public class RuleService implements AdministeredService {
-
- protected static final ClassLoaderFactory DEFAULT_CLASSLOADER_FACTORY = new StandardClassLoaderFactory(
- RuleService.class.getClassLoader());
-
- /**
- * The administrative component for this service.
- *
- * @author Randall Hauch
- */
- protected class Administrator extends AbstractServiceAdministrator {
-
- protected Administrator() {
- super(RepositoryI18n.ruleServiceName, State.PAUSED);
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- protected void doShutdown( State fromState ) {
- super.doShutdown(fromState);
- // Remove all rule sets ...
- removeAllRuleSets();
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- protected boolean doCheckIsTerminated() {
- return RuleService.this.isTerminated();
- }
-
- /**
- * {@inheritDoc}
- */
- public boolean awaitTermination( long timeout,
- TimeUnit unit ) throws InterruptedException {
- return doAwaitTermination(timeout, unit);
- }
-
- }
-
- private Logger logger;
- private ClassLoaderFactory classLoaderFactory = DEFAULT_CLASSLOADER_FACTORY;
- private final Administrator administrator = new Administrator();
- private final ReadWriteLock lock = new ReentrantReadWriteLock();
- @GuardedBy( "lock" )
- private final Map<String, RuleSet> ruleSets = new HashMap<String, RuleSet>();
- private final CountDownLatch shutdownLatch = new CountDownLatch(1);
-
- /**
- * Create a new rule service, configured with no rule sets. Upon construction, the system is
- * {@link ServiceAdministrator#isPaused() paused} and must be configured and then {@link ServiceAdministrator#start() started}
- * .
- */
- public RuleService() {
- this.logger = Logger.getLogger(this.getClass());
- }
-
- /**
- * Return the administrative component for this service.
- *
- * @return the administrative component; never null
- */
- public ServiceAdministrator getAdministrator() {
- return this.administrator;
- }
-
- /**
- * Get the class loader factory that should be used to load sequencers. By default, this service uses a factory that will
- * return either the {@link Thread#getContextClassLoader() current thread's context class loader} (if not null) or the class
- * loader that loaded this class.
- *
- * @return the class loader factory; never null
- * @see #setClassLoaderFactory(ClassLoaderFactory)
- */
- public ClassLoaderFactory getClassLoaderFactory() {
- return this.classLoaderFactory;
- }
-
- /**
- * Set the Maven Repository that should be used to load the sequencer classes. By default, this service uses a class loader
- * factory that will return either the {@link Thread#getContextClassLoader() current thread's context class loader} (if not
- * null) or the class loader that loaded this class.
- *
- * @param classLoaderFactory the class loader factory reference, or null if the default class loader factory should be used.
- * @see #getClassLoaderFactory()
- */
- public void setClassLoaderFactory( ClassLoaderFactory classLoaderFactory ) {
- this.classLoaderFactory = classLoaderFactory != null ? classLoaderFactory : DEFAULT_CLASSLOADER_FACTORY;
- }
-
- /**
- * Obtain the rule sets that are currently available in this service.
- *
- * @return an unmodifiable copy of the rule sets; never null, but possibly empty ...
- */
- public Collection<RuleSet> getRuleSets() {
- List<RuleSet> results = new ArrayList<RuleSet>();
- try {
- this.lock.readLock().lock();
- // Make a copy of the rule sets ...
- if (ruleSets.size() != 0) results.addAll(this.ruleSets.values());
- } finally {
- this.lock.readLock().unlock();
- }
- return Collections.unmodifiableList(results);
- }
-
- /**
- * Add a rule set, or update any existing one that represents the {@link RuleSet#equals(Object) same rule set}
- *
- * @param ruleSet the new rule set
- * @return true if the rule set was added, or false if the rule set was not added (because it wasn't necessary)
- * @throws IllegalArgumentException if <code>ruleSet</code> is null
- * @throws InvalidRuleSetException if the supplied rule set is invalid, incomplete, incorrectly defined, or uses a JSR-94
- * service provider that cannot be found
- * @see #updateRuleSet(RuleSet)
- * @see #removeRuleSet(String)
- */
- public boolean addRuleSet( RuleSet ruleSet ) {
- CheckArg.isNotNull(ruleSet, "rule set");
- final String providerUri = ruleSet.getProviderUri();
- final String ruleSetName = ruleSet.getName();
- final String rules = ruleSet.getRules();
- final Map<?, ?> properties = ruleSet.getExecutionSetProperties();
- final Reader ruleReader = new StringReader(rules);
- boolean updatedRuleSets = false;
- try {
- this.lock.writeLock().lock();
-
- // Make sure the rule service provider is available ...
- RuleServiceProvider ruleServiceProvider = findRuleServiceProvider(ruleSet);
- assert ruleServiceProvider != null;
-
- // Now register a new execution set ...
- RuleAdministrator ruleAdmin = ruleServiceProvider.getRuleAdministrator();
- if (ruleAdmin == null) {
- throw new InvalidRuleSetException(
- RepositoryI18n.unableToObtainJsr94RuleAdministrator.text(providerUri,
- ruleSet.getComponentClassname(),
- ruleSetName));
- }
-
- // Is there is an existing rule set and, if so, whether it has changed ...
- RuleSet existing = this.ruleSets.get(ruleSetName);
-
- // Create the rule execution set (do this before deregistering, in case there is a problem)...
- LocalRuleExecutionSetProvider ruleExecutionSetProvider = ruleAdmin.getLocalRuleExecutionSetProvider(null);
- RuleExecutionSet executionSet = ruleExecutionSetProvider.createRuleExecutionSet(ruleReader, properties);
-
- // We should add the execiting rule set if there wasn't one or if the rule set has changed ...
- boolean shouldAdd = existing == null || ruleSet.hasChanged(existing);
- if (existing != null && shouldAdd) {
- // There is an existing execution set and it needs to be updated, so deregister it ...
- ruleServiceProvider = deregister(ruleSet);
- }
- if (shouldAdd) {
- boolean rollback = false;
- try {
- // Now register the new execution set and update the rule set managed by this service ...
- ruleAdmin.registerRuleExecutionSet(ruleSetName, executionSet, null);
- this.ruleSets.remove(ruleSet.getName());
- this.ruleSets.put(ruleSet.getName(), ruleSet);
- updatedRuleSets = true;
- } catch (Throwable t) {
- rollback = true;
- throw new InvalidRuleSetException(RepositoryI18n.errorAddingOrUpdatingRuleSet.text(ruleSet.getName()), t);
- } finally {
- if (rollback) {
- try {
- // There was a problem, so re-register the original existing rule set ...
- if (existing != null) {
- final String oldRules = existing.getRules();
- final Map<?, ?> oldProperties = existing.getExecutionSetProperties();
- final Reader oldRuleReader = new StringReader(oldRules);
- ruleServiceProvider = findRuleServiceProvider(existing);
- assert ruleServiceProvider != null;
- executionSet = ruleExecutionSetProvider.createRuleExecutionSet(oldRuleReader, oldProperties);
- ruleAdmin.registerRuleExecutionSet(ruleSetName, executionSet, null);
- this.ruleSets.remove(ruleSetName);
- this.ruleSets.put(ruleSetName, existing);
- }
- } catch (Throwable rollbackError) {
- // There was a problem rolling back to the existing rule set, and we're going to throw the
- // exception associated with the updated/new rule set, so just log this problem
- this.logger.error(rollbackError, RepositoryI18n.errorRollingBackRuleSetAfterUpdateFailed, ruleSetName);
- }
- }
- }
- }
- } catch (InvalidRuleSetException e) {
- throw e;
- } catch (ConfigurationException t) {
- throw new InvalidRuleSetException(
- RepositoryI18n.unableToObtainJsr94RuleAdministrator.text(providerUri,
- ruleSet.getComponentClassname(),
- ruleSetName));
- } catch (RemoteException t) {
- throw new InvalidRuleSetException(
- RepositoryI18n.errorUsingJsr94RuleAdministrator.text(providerUri,
- ruleSet.getComponentClassname(),
- ruleSetName));
- } catch (IOException t) {
- throw new InvalidRuleSetException(RepositoryI18n.errorReadingRulesAndProperties.text(ruleSetName));
- } catch (RuleExecutionSetDeregistrationException t) {
- throw new InvalidRuleSetException(RepositoryI18n.errorDeregisteringRuleSetBeforeUpdatingIt.text(ruleSetName));
- } catch (RuleExecutionSetCreateException t) {
- throw new InvalidRuleSetException(RepositoryI18n.errorRecreatingRuleSet.text(ruleSetName));
- } finally {
- this.lock.writeLock().unlock();
- }
- return updatedRuleSets;
- }
-
- /**
- * Update the configuration for a sequencer, or add it if there is no {@link RuleSet#equals(Object) matching configuration}.
- *
- * @param ruleSet the rule set to be updated
- * @return true if the rule set was updated, or false if the rule set was not updated (because it wasn't necessary)
- * @throws InvalidRuleSetException if the supplied rule set is invalid, incomplete, incorrectly defined, or uses a JSR-94
- * service provider that cannot be found
- * @see #addRuleSet(RuleSet)
- * @see #removeRuleSet(String)
- */
- public boolean updateRuleSet( RuleSet ruleSet ) {
- return addRuleSet(ruleSet);
- }
-
- /**
- * Remove a rule set.
- *
- * @param ruleSetName the name of the rule set to be removed
- * @return true if the rule set was removed, or if it was not an existing rule set
- * @throws IllegalArgumentException if <code>ruleSetName</code> is null or empty
- * @throws SystemFailureException if the rule set was found but there was a problem removing it
- * @see #addRuleSet(RuleSet)
- * @see #updateRuleSet(RuleSet)
- */
- public boolean removeRuleSet( String ruleSetName ) {
- CheckArg.isNotEmpty(ruleSetName, "rule set");
- try {
- this.lock.writeLock().lock();
- RuleSet ruleSet = this.ruleSets.remove(ruleSetName);
- if (ruleSet != null) {
- try {
- deregister(ruleSet);
- } catch (Throwable t) {
- // There was a problem deregistering the rule set, so put it back ...
- this.ruleSets.put(ruleSetName, ruleSet);
- }
- return true;
- }
- } catch (Throwable t) {
- throw new SystemFailureException(RepositoryI18n.errorRemovingRuleSet.text(ruleSetName), t);
- } finally {
- this.lock.writeLock().unlock();
- }
- return false;
- }
-
- /**
- * Get the logger for this system
- *
- * @return the logger
- */
- public Logger getLogger() {
- return this.logger;
- }
-
- /**
- * Set the logger for this system.
- *
- * @param logger the logger, or null if the standard logging should be used
- */
- public void setLogger( Logger logger ) {
- this.logger = logger != null ? logger : Logger.getLogger(this.getClass());
- }
-
- /**
- * Execute the set of rules defined by the supplied rule set name. This method is safe to be concurrently called by multiple
- * threads, and is properly synchronized with the methods to {@link #addRuleSet(RuleSet) add}, {@link #updateRuleSet(RuleSet)
- * update}, and {@link #removeRuleSet(String) remove} rule sets.
- *
- * @param ruleSetName the {@link RuleSet#getName() name} of the {@link RuleSet} that should be used
- * @param globals the global variables
- * @param facts the facts
- * @return the results of executing the rule set
- * @throws IllegalArgumentException if the rule set name is null, empty or blank, or if there is no rule set with the given
- * name
- * @throws SystemFailureException if there is no JSR-94 rule service provider with the {@link RuleSet#getProviderUri()
- * RuleSet's provider URI}.
- */
- public List<?> executeRules( String ruleSetName,
- Map<String, Object> globals,
- Object... facts ) {
- CheckArg.isNotEmpty(ruleSetName, "rule set name");
- List<?> result = null;
- List<?> factList = Arrays.asList(facts);
- try {
- this.lock.readLock().lock();
-
- // Find the rule set ...
- RuleSet ruleSet = this.ruleSets.get(ruleSetName);
- if (ruleSet == null) {
- throw new IllegalArgumentException(RepositoryI18n.unableToFindRuleSet.text(ruleSetName));
- }
-
- // Look up the provider ...
- RuleServiceProvider ruleServiceProvider = findRuleServiceProvider(ruleSet);
- assert ruleServiceProvider != null;
-
- // Create the rule session ...
- RuleRuntime ruleRuntime = ruleServiceProvider.getRuleRuntime();
- String executionSetName = ruleSet.getRuleSetUri();
- RuleSession session = ruleRuntime.createRuleSession(executionSetName, globals, RuleRuntime.STATELESS_SESSION_TYPE);
- try {
- StatelessRuleSession statelessSession = (StatelessRuleSession)session;
- result = statelessSession.executeRules(factList);
- } finally {
- session.release();
- }
- if (this.logger.isTraceEnabled()) {
- String msg = "Executed rule set '{1}' with globals {2} and facts {3} resulting in {4}";
- this.logger.trace(msg, ruleSetName, globals, Arrays.asList(facts), result);
- }
- } catch (Throwable t) {
- String msg = RepositoryI18n.errorExecutingRuleSetWithGlobalsAndFacts.text(ruleSetName, globals, Arrays.asList(facts));
- throw new SystemFailureException(msg, t);
- } finally {
- this.lock.readLock().unlock();
- }
- return result;
- }
-
- protected void removeAllRuleSets() {
- try {
- lock.writeLock().lock();
- for (RuleSet ruleSet : ruleSets.values()) {
- try {
- deregister(ruleSet);
- } catch (Throwable t) {
- logger.error(t, RepositoryI18n.errorRemovingRuleSetUponShutdown, ruleSet.getName());
- }
- }
- } finally {
- lock.writeLock().unlock();
- }
- this.shutdownLatch.countDown();
- }
-
- protected boolean doAwaitTermination( long timeout,
- TimeUnit unit ) throws InterruptedException {
- return this.shutdownLatch.await(timeout, unit);
- }
-
- protected boolean isTerminated() {
- return this.shutdownLatch.getCount() == 0;
- }
-
- /**
- * Finds the JSR-94 service provider instance and returns it. If it could not be found, this method attempts to load it.
- *
- * @param ruleSet the rule set for which the service provider is to be found; may not be null
- * @return the rule service provider; never null
- * @throws ConfigurationException if there is a problem loading the service provider
- * @throws InvalidRuleSetException if the service provider could not be found
- */
- private RuleServiceProvider findRuleServiceProvider( RuleSet ruleSet ) throws ConfigurationException {
- assert ruleSet != null;
- String providerUri = ruleSet.getProviderUri();
- RuleServiceProvider ruleServiceProvider = null;
- try {
- // If the provider could not be found, then a ConfigurationException will be thrown ...
- ruleServiceProvider = RuleServiceProviderManager.getRuleServiceProvider(providerUri);
- } catch (ConfigurationException e) {
- try {
- // Use JSR-94 to load the RuleServiceProvider instance ...
- ClassLoader loader = this.classLoaderFactory.getClassLoader(ruleSet.getComponentClasspathArray());
- // Don't call ClassLoader.loadClass(String), as this doesn't initialize the class!!
- Class.forName(ruleSet.getComponentClassname(), true, loader);
- ruleServiceProvider = RuleServiceProviderManager.getRuleServiceProvider(providerUri);
- this.logger.debug("Loaded the rule service provider {0} ({1})", providerUri, ruleSet.getComponentClassname());
- } catch (ConfigurationException ce) {
- throw ce;
- } catch (Throwable t) {
- throw new InvalidRuleSetException(
- RepositoryI18n.unableToObtainJsr94ServiceProvider.text(providerUri,
- ruleSet.getComponentClassname()),
- t);
- }
- }
- if (ruleServiceProvider == null) {
- throw new InvalidRuleSetException(
- RepositoryI18n.unableToObtainJsr94ServiceProvider.text(providerUri,
- ruleSet.getComponentClassname()));
- }
- return ruleServiceProvider;
- }
-
- /**
- * Deregister the supplied rule set, if it could be found. This method does nothing if any of the service provider components
- * could not be found.
- *
- * @param ruleSet the rule set to be deregistered; may not be null
- * @return the service provider reference, or null if the service provider could not be found ...
- * @throws ConfigurationException
- * @throws RuleExecutionSetDeregistrationException
- * @throws RemoteException
- */
- private RuleServiceProvider deregister( RuleSet ruleSet )
- throws ConfigurationException, RuleExecutionSetDeregistrationException, RemoteException {
- assert ruleSet != null;
- // Look up the provider ...
- String providerUri = ruleSet.getProviderUri();
- assert providerUri != null;
-
- // Look for the provider ...
- RuleServiceProvider ruleServiceProvider = RuleServiceProviderManager.getRuleServiceProvider(providerUri);
- if (ruleServiceProvider != null) {
- // Deregister the rule set ...
- RuleAdministrator ruleAdmin = ruleServiceProvider.getRuleAdministrator();
- if (ruleAdmin != null) {
- ruleAdmin.deregisterRuleExecutionSet(ruleSet.getRuleSetUri(), null);
- }
- }
- return ruleServiceProvider;
- }
-
-}
Deleted: trunk/dna-repository/src/main/java/org/jboss/dna/repository/rules/RuleSet.java
===================================================================
--- trunk/dna-repository/src/main/java/org/jboss/dna/repository/rules/RuleSet.java 2009-05-21 22:26:25 UTC (rev 922)
+++ trunk/dna-repository/src/main/java/org/jboss/dna/repository/rules/RuleSet.java 2009-05-22 02:15:19 UTC (rev 923)
@@ -1,154 +0,0 @@
-/*
- * JBoss DNA (http://www.jboss.org/dna)
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
-* See the AUTHORS.txt file in the distribution for a full listing of
-* individual contributors.
- *
- * JBoss DNA is free software. Unless otherwise indicated, all code in JBoss DNA
- * is licensed to you under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * JBoss DNA is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.dna.repository.rules;
-
-import java.io.ByteArrayInputStream;
-import java.io.InputStreamReader;
-import java.io.Reader;
-import java.util.HashMap;
-import java.util.Map;
-import javax.rules.RuleServiceProvider;
-import javax.rules.admin.RuleExecutionSet;
-import javax.rules.admin.RuleExecutionSetProvider;
-import net.jcip.annotations.Immutable;
-import org.jboss.dna.common.component.ClassLoaderFactory;
-import org.jboss.dna.common.component.ComponentConfig;
-import org.jboss.dna.common.util.CheckArg;
-
-/**
- * A description of a set of rules compatible with a JSR-94 rule engine.
- *
- * @author Randall Hauch
- */
-@Immutable
-public class RuleSet extends ComponentConfig implements Cloneable {
-
- private final String providerUri;
- private final String ruleSetUri;
- private final String rules;
-
- /**
- * Create a JSR-94 rule set definition.
- *
- * @param name the name of the rule set, which is considered the unique identifier
- * @param description the description
- * @param classname the name of the Java class used for the component
- * @param classpath the optional classpath (defined in a way compatible with a {@link ClassLoaderFactory}
- * @param providerUri the URI of the JSR-94 {@link RuleServiceProvider} implementation to use
- * @param ruleSetUri the URI of the JSR-94 {@link RuleExecutionSet} represented by this object; if null, the name is used
- * @param rules the string containing the rules in a provider-specific language
- * @param properties the provider-specific properties, whose values should be strings or byte arrays (the latter if the
- * provider expects an {@link Reader} with the value)
- * @throws IllegalArgumentException if any of the name, classname, provider URI, or rules parameters are null, empty or blank,
- * or if the classname is not a valid Java classname
- */
- public RuleSet( String name,
- String description,
- String classname,
- String[] classpath,
- String providerUri,
- String ruleSetUri,
- String rules,
- Map<String, Object> properties ) {
- super(name, description, System.currentTimeMillis(), properties, classname, classpath);
- if (ruleSetUri == null) ruleSetUri = name.trim();
- CheckArg.isNotEmpty(ruleSetUri, "rule set URI");
- CheckArg.isNotEmpty(providerUri, "provider URI");
- CheckArg.isNotEmpty(rules, "rules");
- this.providerUri = providerUri;
- this.ruleSetUri = ruleSetUri;
- this.rules = rules;
- }
-
- /**
- * Get the URI of the JSR-94 {@link RuleServiceProvider} implementation that should be used.
- *
- * @return the URI of the JSR-94 implementation; never null, empty or blank
- */
- public String getProviderUri() {
- return this.providerUri;
- }
-
- /**
- * Get the URI of this rule set. The value must be valid as defined by JSR-94 {@link RuleExecutionSet}.
- *
- * @return the rule set's URI; never null, empty or blank
- */
- public String getRuleSetUri() {
- return this.ruleSetUri;
- }
-
- /**
- * Get the rules defined in terms of the language reqired by the {@link #getProviderUri() provider}.
- *
- * @return the rules for this rule set
- */
- public String getRules() {
- return this.rules;
- }
-
- /**
- * Get the properties for this rule set that can be passed to an {@link RuleExecutionSetProvider}'s
- * {@link RuleExecutionSetProvider#createRuleExecutionSet(String, Map) createRuleExecutionSet} method.
- * <p>
- * This method converts any byte array value in the {@link #getProperties() properties} into an {@link Reader}. Since
- * {@link ByteArrayInputStream} is used, there is no need to close these stream.
- * </p>
- *
- * @return the properties; never null but possible empty
- */
- public Map<Object, Object> getExecutionSetProperties() {
- Map<Object, Object> props = new HashMap<Object, Object>();
- for (Map.Entry<String, Object> entry : getProperties().entrySet()) {
- String key = entry.getKey();
- Object value = entry.getValue();
- if (value instanceof byte[]) {
- value = new InputStreamReader(new ByteArrayInputStream((byte[])value));
- }
- props.put(key, value);
- }
- return props;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public boolean hasChanged( ComponentConfig obj ) {
- if (super.hasChanged(obj)) return true;
- RuleSet that = (RuleSet)obj;
- if (!this.providerUri.equals(that.providerUri)) return true;
- if (!this.ruleSetUri.equals(that.ruleSetUri)) return true;
- return false;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public RuleSet clone() {
- return new RuleSet(getName(), getDescription(), getComponentClassname(), getComponentClasspathArray(), this.providerUri,
- this.ruleSetUri, this.rules, getProperties());
- }
-}
Deleted: trunk/dna-repository/src/main/java/org/jboss/dna/repository/rules/RuleSetRepositoryMonitor.java
===================================================================
--- trunk/dna-repository/src/main/java/org/jboss/dna/repository/rules/RuleSetRepositoryMonitor.java 2009-05-21 22:26:25 UTC (rev 922)
+++ trunk/dna-repository/src/main/java/org/jboss/dna/repository/rules/RuleSetRepositoryMonitor.java 2009-05-22 02:15:19 UTC (rev 923)
@@ -1,271 +0,0 @@
-/*
- * JBoss DNA (http://www.jboss.org/dna)
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- * See the AUTHORS.txt file in the distribution for a full listing of
- * individual contributors.
- *
- * JBoss DNA is free software. Unless otherwise indicated, all code in JBoss DNA
- * is licensed to you under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * JBoss DNA is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.dna.repository.rules;
-
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Map;
-import java.util.Set;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-import java.util.regex.PatternSyntaxException;
-import javax.jcr.Node;
-import javax.jcr.RepositoryException;
-import javax.jcr.Session;
-import net.jcip.annotations.ThreadSafe;
-import org.jboss.dna.common.collection.SimpleProblems;
-import org.jboss.dna.common.util.CheckArg;
-import org.jboss.dna.common.util.Logger;
-import org.jboss.dna.repository.RepositoryI18n;
-import org.jboss.dna.repository.observation.NodeChange;
-import org.jboss.dna.repository.observation.NodeChangeListener;
-import org.jboss.dna.repository.observation.NodeChanges;
-import org.jboss.dna.repository.observation.ObservationService;
-import org.jboss.dna.repository.util.JcrExecutionContext;
-import org.jboss.dna.repository.util.JcrTools;
-
-/**
- * A component that can listen to a JCR repository and keep the {@link RuleSet} instances of a {@link RuleService} synchronized
- * with that repository.
- * <p>
- * This class is a {@link NodeChangeListener} that can {@link ObservationService#addListener(NodeChangeListener) subscribe} to
- * changes in one or more JCR repositories being monitored by an {@link ObservationService}. As changes under the rule sets
- * branch are discovered, they are processed asynchronously. This ensure that the processing of the repository contents does not
- * block the other listeners of the {@link ObservationService}.
- * </p>
- *
- * @author Randall Hauch
- */
-@ThreadSafe
-public class RuleSetRepositoryMonitor implements NodeChangeListener {
-
- public static final String DEFAULT_JCR_ABSOLUTE_PATH = "/dna:system/dna:ruleSets/";
-
- protected static final String JCR_PATH_DELIM = "/";
-
- private final JcrExecutionContext executionContext;
- private final RuleService ruleService;
- private final String jcrAbsolutePath;
- private final Pattern ruleSetNamePattern;
- private final ExecutorService executorService;
- private Logger logger;
-
- /**
- * Create an instance that can listen to the {@link RuleSet} definitions stored in a JCR repository and ensure that the
- * {@link RuleSet} instances of a {@link RuleService} reflect the definitions in the repository.
- *
- * @param ruleService the rule service that should be kept in sync with the JCR repository.
- * @param jcrAbsolutePath the absolute path to the branch where the rule sets are defined; if null or empty, the
- * {@link #DEFAULT_JCR_ABSOLUTE_PATH default path} is used
- * @param executionContext the context in which this monitor is to execute
- * @throws IllegalArgumentException if the rule service or execution context is null, or if the supplied
- * <code>jcrAbsolutePath</code> is invalid
- */
- public RuleSetRepositoryMonitor( RuleService ruleService,
- String jcrAbsolutePath,
- JcrExecutionContext executionContext ) {
- CheckArg.isNotNull(ruleService, "rule service");
- CheckArg.isNotNull(executionContext, "execution context");
- this.ruleService = ruleService;
- this.executionContext = executionContext;
- this.executorService = Executors.newSingleThreadExecutor();
- this.logger = Logger.getLogger(this.getClass());
- if (jcrAbsolutePath != null) jcrAbsolutePath = jcrAbsolutePath.trim();
- this.jcrAbsolutePath = jcrAbsolutePath != null && jcrAbsolutePath.length() != 0 ? jcrAbsolutePath : DEFAULT_JCR_ABSOLUTE_PATH;
- try {
- // Create the pattern to extract the rule set name from the absolute path ...
- String leadingPath = this.jcrAbsolutePath;
- if (!leadingPath.endsWith(JCR_PATH_DELIM)) leadingPath = leadingPath + JCR_PATH_DELIM;
- this.ruleSetNamePattern = Pattern.compile(leadingPath + "([^/]+)/?.*");
- } catch (PatternSyntaxException e) {
- throw new IllegalArgumentException(
- RepositoryI18n.unableToBuildRuleSetRegularExpressionPattern.text(e.getPattern(),
- jcrAbsolutePath,
- e.getDescription()));
- }
- }
-
- /**
- * @return ruleService
- */
- public RuleService getRuleService() {
- return this.ruleService;
- }
-
- /**
- * @return jcrAbsolutePath
- */
- public String getAbsolutePathToRuleSets() {
- return this.jcrAbsolutePath;
- }
-
- /**
- * @return logger
- */
- public Logger getLogger() {
- return this.logger;
- }
-
- /**
- * @param logger Sets logger to the specified value.
- */
- public void setLogger( Logger logger ) {
- this.logger = logger;
- }
-
- /**
- * {@inheritDoc}
- */
- public void onNodeChanges( NodeChanges changes ) {
- final Map<String, Set<String>> ruleSetNamesByWorkspaceName = new HashMap<String, Set<String>>();
- for (NodeChange nodeChange : changes) {
- if (nodeChange.isNotOnPath(this.jcrAbsolutePath)) continue;
- // Use a regular expression on the absolute path to get the name of the rule set that is affected ...
- Matcher matcher = this.ruleSetNamePattern.matcher(nodeChange.getAbsolutePath());
- if (!matcher.matches()) continue;
- String ruleSetName = matcher.group(1);
- // Record the repository name ...
- String workspaceName = nodeChange.getRepositoryWorkspaceName();
- Set<String> ruleSetNames = ruleSetNamesByWorkspaceName.get(workspaceName);
- if (ruleSetNames == null) {
- ruleSetNames = new HashSet<String>();
- ruleSetNamesByWorkspaceName.put(workspaceName, ruleSetNames);
- }
- // Record the rule set name ...
- ruleSetNames.add(ruleSetName);
-
- }
- if (ruleSetNamesByWorkspaceName.isEmpty()) return;
- // Otherwise there are changes, so submit the names to the executor service ...
- this.executorService.execute(new Runnable() {
-
- public void run() {
- processRuleSets(ruleSetNamesByWorkspaceName);
- }
- });
- }
-
- /**
- * Process the rule sets given by the supplied names, keyed by the repository workspace name.
- *
- * @param ruleSetNamesByWorkspaceName the set of rule set names keyed by the repository workspace name
- */
- protected void processRuleSets( Map<String, Set<String>> ruleSetNamesByWorkspaceName ) {
- final JcrTools tools = this.executionContext.getTools();
- final String relPathToRuleSets = getAbsolutePathToRuleSets().substring(1);
- for (Map.Entry<String, Set<String>> entry : ruleSetNamesByWorkspaceName.entrySet()) {
- String workspaceName = entry.getKey();
- Session session = null;
- try {
- session = this.executionContext.getSessionFactory().createSession(workspaceName);
- // Look up the node that represents the parent of the rule set nodes ...
- Node ruleSetsNode = session.getRootNode().getNode(relPathToRuleSets);
-
- for (String ruleSetName : entry.getValue()) {
- // Look up the node that represents the rule set...
- if (ruleSetsNode.hasNode(ruleSetName)) {
- // We don't handle multiple siblings with the same name, so this should grab the first one ...
- Node ruleSetNode = ruleSetsNode.getNode(ruleSetName);
- RuleSet ruleSet = buildRuleSet(ruleSetName, ruleSetNode, tools);
- if (ruleSet != null) {
- // Only do something if the RuleSet was instantiated ...
- getRuleService().addRuleSet(ruleSet);
- }
- } else {
- // The node doesn't exist, so remove the rule set ...
- getRuleService().removeRuleSet(ruleSetName);
- }
- }
- } catch (RepositoryException e) {
- getLogger().error(e, RepositoryI18n.errorObtainingSessionToRepositoryWorkspace, workspaceName);
- } finally {
- if (session != null) session.logout();
- }
- }
- }
-
- /**
- * Create a rule set from the supplied node. This is called whenever a branch of the repository is changed.
- * <p>
- * This implementation expects a node of type 'dna:ruleSet' and the following properties (expressed as XPath statements
- * relative to the supplied node):
- * <ul>
- * <li>The {@link RuleSet#getDescription() description} is obtained from the "<code>./@jcr:description</code>" string
- * property. This property is optional.</li>
- * <li>The {@link RuleSet#getComponentClassname() classname} is obtained from the "<code>./@dna:classname</code>" string
- * property. This property is required.</li>
- * <li>The {@link RuleSet#getComponentClasspath() classpath} is obtained from the "<code>./@dna:classpath</code>" string
- * property. This property is optional, and if abscent then the classpath will be assumed from the current context.</li>
- * <li>The {@link RuleSet#getProviderUri() provider URI} is obtained from the "<code>./@dna:serviceProviderUri</code>"
- * string property, and corresponds to the URI of the JSR-94 rules engine service provider. This property is required.</li>
- * <li>The {@link RuleSet#getRuleSetUri() rule set URI} is obtained from the "<code>./@dna:ruleSetUri</code>" string
- * property. This property is optional and defaults to the node name (e.g., "<code>./@jcr:name</code>").</li>
- * <li>The {@link RuleSet#getRules() definition of the rules} is obtained from the "<code>./@dna:rules</code>" string
- * property. This property is required and must be in a form suitable for the JSR-94 rules engine.</li>
- * <li>The {@link RuleSet#getProperties() properties} are obtained from the "<code>./dna:properties[contains(@jcr:mixinTypes,'dna:propertyContainer')]/*[@jcr:nodeType='dna:property']</code>"
- * property nodes, where the name of the property is extracted from the property node's "<code>./@jcr:name</code>" string
- * property and the value of the property is extracted from the property node's "<code>./@dna:propertyValue</code>" string
- * property. Rule set properties are optional.</li>
- * </ul>
- * </p>
- *
- * @param name the name of the rule set; never null
- * @param ruleSetNode the node representing the rule set; null if the rule set doesn't exist
- * @param tools
- * @return the rule set for the information stored in the repository, or null if the rule set does not exist or has errors
- */
- protected RuleSet buildRuleSet( String name,
- Node ruleSetNode,
- JcrTools tools ) {
- if (ruleSetNode == null) return null;
-
- SimpleProblems simpleProblems = new SimpleProblems();
- String description = tools.getPropertyAsString(ruleSetNode, "jcr:description", false, simpleProblems);
- String classname = tools.getPropertyAsString(ruleSetNode, "dna:classname", true, simpleProblems);
- String[] classpath = tools.getPropertyAsStringArray(ruleSetNode, "dna:classpath", false, simpleProblems);
- String providerUri = tools.getPropertyAsString(ruleSetNode, "dna:serviceProviderUri", true, simpleProblems);
- String ruleSetUri = tools.getPropertyAsString(ruleSetNode, "dna:ruleSetUri", true, name, simpleProblems);
- String rules = tools.getPropertyAsString(ruleSetNode, "dna:rules", true, simpleProblems);
- Map<String, Object> properties = tools.loadProperties(ruleSetNode, simpleProblems);
- if (simpleProblems.hasProblems()) {
- // There are problems, so store and save them, and then return null ...
- try {
- if (tools.storeProblems(ruleSetNode, simpleProblems)) ruleSetNode.save();
- } catch (RepositoryException e) {
- this.logger.error(e, RepositoryI18n.errorWritingProblemsOnRuleSet, tools.getReadable(ruleSetNode));
- }
- return null;
- }
- // There are no problems with this rule set, so make sure that there are no persisted problems anymore ...
- try {
- if (tools.removeProblems(ruleSetNode)) ruleSetNode.save();
- } catch (RepositoryException e) {
- this.logger.error(e, RepositoryI18n.errorWritingProblemsOnRuleSet, tools.getReadable(ruleSetNode));
- }
- return new RuleSet(name, description, classname, classpath, providerUri, ruleSetUri, rules, properties);
- }
-
-}
Modified: trunk/dna-repository/src/main/java/org/jboss/dna/repository/sequencer/Sequencer.java
===================================================================
--- trunk/dna-repository/src/main/java/org/jboss/dna/repository/sequencer/Sequencer.java 2009-05-21 22:26:25 UTC (rev 922)
+++ trunk/dna-repository/src/main/java/org/jboss/dna/repository/sequencer/Sequencer.java 2009-05-22 02:15:19 UTC (rev 923)
@@ -29,10 +29,9 @@
import org.jboss.dna.common.component.Component;
import org.jboss.dna.graph.Node;
import org.jboss.dna.graph.io.Destination;
+import org.jboss.dna.graph.observe.Observer;
import org.jboss.dna.graph.observe.NetChangeObserver.NetChange;
-import org.jboss.dna.repository.observation.NodeChange;
-import org.jboss.dna.repository.observation.NodeChanges;
-import org.jboss.dna.repository.observation.ObservationService;
+import org.jboss.dna.repository.RepositoryLibrary;
import org.jboss.dna.repository.util.RepositoryNodePath;
/**
@@ -54,10 +53,10 @@
* this sequencer, and closing any other acquired resources, even in the case of exceptions.
* <p>
* The {@link SequencingService} determines the sequencers that should be executed by monitoring the changes to one or more
- * workspaces (it is a listener registered with the {@link ObservationService}). Changes in those workspaces are aggregated
- * for each transaction, and organized into {@link NodeChanges changes for each node}. The SequencingService then determines
- * for each {@link NodeChange set of changes to a node} the set of full paths to the properties that have changed and whether
- * those paths {@link SequencerPathExpression#matcher(String) match} the sequencer's
+ * workspaces (it registers an {@link Observer} with the {@link RepositoryLibrary}). Changes in those workspaces are
+ * aggregated for each transaction, and organized into {@link NetChange changes for each node}. The SequencingService then
+ * determines for each {@link NetChange set of changes to a node} the set of full paths to the properties that have changed
+ * and whether those paths {@link SequencerPathExpression#matcher(String) match} the sequencer's
* {@link SequencerConfig#getPathExpressions() path expressions}. Each path expression produces the path to the output node,
* and these output paths are accumulated and (with the original node that changed, the node change summary, and other
* information) supplied to the sequencer via this method.
Modified: trunk/dna-repository/src/main/java/org/jboss/dna/repository/sequencer/SequencingService.java
===================================================================
--- trunk/dna-repository/src/main/java/org/jboss/dna/repository/sequencer/SequencingService.java 2009-05-21 22:26:25 UTC (rev 922)
+++ trunk/dna-repository/src/main/java/org/jboss/dna/repository/sequencer/SequencingService.java 2009-05-22 02:15:19 UTC (rev 923)
@@ -55,7 +55,6 @@
import org.jboss.dna.graph.property.Property;
import org.jboss.dna.repository.RepositoryI18n;
import org.jboss.dna.repository.RepositoryLibrary;
-import org.jboss.dna.repository.observation.NodeChange;
import org.jboss.dna.repository.service.AbstractServiceAdministrator;
import org.jboss.dna.repository.service.AdministeredService;
import org.jboss.dna.repository.service.ServiceAdministrator;
@@ -349,6 +348,9 @@
}
protected void shutdownService() {
+ // Unregister our observer ...
+ if (this.repositoryObserver != null) this.repositoryObserver.unregister();
+ // And shut down the executor service ..
if (this.executorService != null) {
this.executorService.shutdown();
}
@@ -387,7 +389,7 @@
/**
* Do the work of processing by sequencing the node. This method is called by the {@link #executorService executor service}
- * when it performs it's work on the enqueued {@link NodeChange NodeChange runnable objects}.
+ * when it performs it's work on the enqueued {@link NetChange NetChange runnable objects}.
*
* @param change the change describing the node to be processed.
*/
Deleted: trunk/dna-repository/src/main/java/org/jboss/dna/repository/util/JcrExecutionContext.java
===================================================================
--- trunk/dna-repository/src/main/java/org/jboss/dna/repository/util/JcrExecutionContext.java 2009-05-21 22:26:25 UTC (rev 922)
+++ trunk/dna-repository/src/main/java/org/jboss/dna/repository/util/JcrExecutionContext.java 2009-05-22 02:15:19 UTC (rev 923)
@@ -1,125 +0,0 @@
-/*
- * JBoss DNA (http://www.jboss.org/dna)
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- * See the AUTHORS.txt file in the distribution for a full listing of
- * individual contributors.
- *
- * JBoss DNA is free software. Unless otherwise indicated, all code in JBoss DNA
- * is licensed to you under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * JBoss DNA is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.dna.repository.util;
-
-import java.util.HashSet;
-import java.util.Set;
-import java.util.concurrent.atomic.AtomicBoolean;
-import javax.jcr.RepositoryException;
-import javax.jcr.Session;
-import org.jboss.dna.graph.ExecutionContext;
-import org.jboss.dna.repository.RepositoryI18n;
-
-/**
- * The context of an execution within a JCR environment.
- *
- * @author Randall Hauch
- */
-public class JcrExecutionContext extends ExecutionContext {
-
- private final String repositoryWorkspaceForNamespaceRegistry;
- private final ClosableSessionFactory sessionFactory;
- private final JcrTools jcrTools;
-
- public JcrExecutionContext( ExecutionContext context,
- final SessionFactory sessionFactory,
- String repositoryWorkspaceForNamespaceRegistry ) {
- super(context.with(new JcrNamespaceRegistry(sessionFactory, repositoryWorkspaceForNamespaceRegistry)));
- this.sessionFactory = new ClosableSessionFactory(sessionFactory);
- this.jcrTools = new JcrTools();
- this.repositoryWorkspaceForNamespaceRegistry = repositoryWorkspaceForNamespaceRegistry;
- }
-
- public JcrExecutionContext( SessionFactory sessionFactory,
- String repositoryWorkspaceForNamespaceRegistry ) {
- this(new ExecutionContext(), sessionFactory, repositoryWorkspaceForNamespaceRegistry);
- }
-
- /**
- * Get the session factory, which can be used to obtain sessions temporarily for this context. Any session obtained from this
- * factory should be {@link Session#logout() closed} before the execution finishes.
- *
- * @return the session factory
- */
- public SessionFactory getSessionFactory() {
- return this.sessionFactory;
- }
-
- /**
- * Get a set of utilities for working with JCR.
- *
- * @return the tools
- */
- public JcrTools getTools() {
- return this.jcrTools;
- }
-
- /**
- * {@inheritDoc}
- *
- * @see org.jboss.dna.graph.ExecutionContext#clone()
- */
- @Override
- public JcrExecutionContext clone() {
- return new JcrExecutionContext(this, this.sessionFactory.getDelegateFactory(),
- this.repositoryWorkspaceForNamespaceRegistry);
- }
-
- /**
- * This this context and release all resources (including any Session instances created).
- */
- public void close() {
- this.sessionFactory.close();
- }
-
- protected static class ClosableSessionFactory implements SessionFactory {
- private final SessionFactory delegateFactory;
- private final Set<Session> sessions = new HashSet<Session>();
- protected final AtomicBoolean closed = new AtomicBoolean(false);
-
- protected ClosableSessionFactory( SessionFactory sessionFactory ) {
- this.delegateFactory = sessionFactory;
- }
-
- public SessionFactory getDelegateFactory() {
- return this.delegateFactory;
- }
-
- public Session createSession( String name ) throws RepositoryException {
- if (closed.get()) throw new IllegalStateException(RepositoryI18n.executionContextHasBeenClosed.text());
- Session session = delegateFactory.createSession(name);
- if (session != null) sessions.add(session);
- return session;
- }
-
- public synchronized void close() {
- if (this.closed.get()) return;
- this.closed.set(true);
- for (Session session : sessions) {
- if (session != null) session.logout();
- }
- }
- }
-
-}
Deleted: trunk/dna-repository/src/main/java/org/jboss/dna/repository/util/JcrNamespaceRegistry.java
===================================================================
--- trunk/dna-repository/src/main/java/org/jboss/dna/repository/util/JcrNamespaceRegistry.java 2009-05-21 22:26:25 UTC (rev 922)
+++ trunk/dna-repository/src/main/java/org/jboss/dna/repository/util/JcrNamespaceRegistry.java 2009-05-22 02:15:19 UTC (rev 923)
@@ -1,217 +0,0 @@
-/*
- * JBoss DNA (http://www.jboss.org/dna)
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- * See the AUTHORS.txt file in the distribution for a full listing of
- * individual contributors.
- *
- * JBoss DNA is free software. Unless otherwise indicated, all code in JBoss DNA
- * is licensed to you under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * JBoss DNA is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.dna.repository.util;
-
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.Set;
-import javax.jcr.RepositoryException;
-import javax.jcr.Session;
-import org.jboss.dna.common.util.CheckArg;
-import org.jboss.dna.graph.property.NamespaceException;
-import org.jboss.dna.graph.property.NamespaceRegistry;
-import org.jboss.dna.graph.property.basic.BasicNamespace;
-
-/**
- * @author Randall Hauch
- */
-public class JcrNamespaceRegistry implements NamespaceRegistry {
-
- private final String repositoryWorkspaceName;
- private final SessionFactory sessionFactory;
-
- public JcrNamespaceRegistry( SessionFactory sessionFactory,
- String repositoryWorkspaceName ) {
- CheckArg.isNotNull(sessionFactory, "sessionFactory");
- CheckArg.isNotNull(repositoryWorkspaceName, "repositoryWorkspaceName");
- this.repositoryWorkspaceName = repositoryWorkspaceName;
- this.sessionFactory = sessionFactory;
- }
-
- /**
- * {@inheritDoc}
- */
- public String getDefaultNamespaceUri() {
- Session session = null;
- try {
- session = this.sessionFactory.createSession(this.repositoryWorkspaceName);
- return session.getNamespaceURI("");
- } catch (RepositoryException e) {
- throw new NamespaceException(e);
- } finally {
- if (session != null) {
- session.logout();
- }
- }
- }
-
- /**
- * {@inheritDoc}
- */
- public String getNamespaceForPrefix( String prefix ) {
- Session session = null;
- try {
- session = this.sessionFactory.createSession(this.repositoryWorkspaceName);
- return session.getNamespaceURI(prefix);
- } catch (RepositoryException e) {
- throw new NamespaceException(e);
- } finally {
- if (session != null) {
- session.logout();
- }
- }
- }
-
- /**
- * {@inheritDoc}
- */
- public String getPrefixForNamespaceUri( String namespaceUri,
- boolean generateIfMissing ) {
- Session session = null;
- try {
- session = this.sessionFactory.createSession(this.repositoryWorkspaceName);
- return session.getNamespacePrefix(namespaceUri);
- } catch (RepositoryException e) {
- throw new NamespaceException(e);
- } finally {
- if (session != null) {
- session.logout();
- }
- }
- }
-
- /**
- * {@inheritDoc}
- */
- public boolean isRegisteredNamespaceUri( String namespaceUri ) {
- Session session = null;
- try {
- session = this.sessionFactory.createSession(this.repositoryWorkspaceName);
- session.getNamespacePrefix(namespaceUri);
- return true;
- } catch (javax.jcr.NamespaceException e) {
- return false;
- } catch (RepositoryException e) {
- throw new NamespaceException(e);
- } finally {
- if (session != null) {
- session.logout();
- }
- }
- }
-
- /**
- * {@inheritDoc}
- */
- public String register( String prefix,
- String namespaceUri ) {
- String previousNamespaceUriForPrefix = null;
- Session session = null;
- try {
- session = this.sessionFactory.createSession(this.repositoryWorkspaceName);
- previousNamespaceUriForPrefix = session.getNamespacePrefix(namespaceUri);
- javax.jcr.NamespaceRegistry registry = session.getWorkspace().getNamespaceRegistry();
- registry.registerNamespace(prefix, namespaceUri);
- } catch (RepositoryException e) {
- throw new NamespaceException(e);
- } finally {
- if (session != null) {
- session.logout();
- }
- }
- return previousNamespaceUriForPrefix;
- }
-
- /**
- * {@inheritDoc}
- *
- * @see org.jboss.dna.graph.property.NamespaceRegistry#unregister(java.lang.String)
- */
- public boolean unregister( String namespaceUri ) {
- Session session = null;
- try {
- session = this.sessionFactory.createSession(this.repositoryWorkspaceName);
- String prefix = session.getNamespacePrefix(namespaceUri);
- javax.jcr.NamespaceRegistry registry = session.getWorkspace().getNamespaceRegistry();
- registry.unregisterNamespace(prefix);
- } catch (javax.jcr.NamespaceException e) {
- return false;
- } catch (RepositoryException e) {
- throw new NamespaceException(e);
- } finally {
- if (session != null) {
- session.logout();
- }
- }
- return true;
- }
-
- /**
- * {@inheritDoc}
- */
- public Set<String> getRegisteredNamespaceUris() {
- Session session = null;
- try {
- session = this.sessionFactory.createSession(this.repositoryWorkspaceName);
- javax.jcr.NamespaceRegistry registry = session.getWorkspace().getNamespaceRegistry();
- Set<String> result = new HashSet<String>();
- for (String uri : registry.getURIs()) {
- result.add(uri);
- }
- return Collections.unmodifiableSet(result);
- } catch (RepositoryException e) {
- throw new NamespaceException(e);
- } finally {
- if (session != null) {
- session.logout();
- }
- }
- }
-
- /**
- * {@inheritDoc}
- *
- * @see org.jboss.dna.graph.property.NamespaceRegistry#getNamespaces()
- */
- public Set<Namespace> getNamespaces() {
- Session session = null;
- try {
- session = this.sessionFactory.createSession(this.repositoryWorkspaceName);
- javax.jcr.NamespaceRegistry registry = session.getWorkspace().getNamespaceRegistry();
- Set<Namespace> result = new HashSet<Namespace>();
- for (String uri : registry.getURIs()) {
- String prefix = registry.getPrefix(uri);
- result.add(new BasicNamespace(prefix, uri));
- }
- return Collections.unmodifiableSet(result);
- } catch (RepositoryException e) {
- throw new NamespaceException(e);
- } finally {
- if (session != null) {
- session.logout();
- }
- }
- }
-
-}
Deleted: trunk/dna-repository/src/main/java/org/jboss/dna/repository/util/JcrTools.java
===================================================================
--- trunk/dna-repository/src/main/java/org/jboss/dna/repository/util/JcrTools.java 2009-05-21 22:26:25 UTC (rev 922)
+++ trunk/dna-repository/src/main/java/org/jboss/dna/repository/util/JcrTools.java 2009-05-22 02:15:19 UTC (rev 923)
@@ -1,329 +0,0 @@
-/*
- * JBoss DNA (http://www.jboss.org/dna)
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- * See the AUTHORS.txt file in the distribution for a full listing of
- * individual contributors.
- *
- * JBoss DNA is free software. Unless otherwise indicated, all code in JBoss DNA
- * is licensed to you under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * JBoss DNA is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.dna.repository.util;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.HashMap;
-import java.util.Map;
-import javax.jcr.Node;
-import javax.jcr.NodeIterator;
-import javax.jcr.PathNotFoundException;
-import javax.jcr.Property;
-import javax.jcr.PropertyType;
-import javax.jcr.RepositoryException;
-import javax.jcr.Session;
-import javax.jcr.Value;
-import javax.jcr.ValueFormatException;
-import org.jboss.dna.common.collection.Problem;
-import org.jboss.dna.common.collection.Problems;
-import org.jboss.dna.common.util.IoUtil;
-import org.jboss.dna.common.util.Logger;
-import org.jboss.dna.common.util.StringUtil;
-import org.jboss.dna.repository.RepositoryI18n;
-
-/**
- * @author Randall Hauch
- */
-public class JcrTools {
-
- public Map<String, Object> loadProperties( Node propertyContainer, Problems problems ) {
- return loadProperties(propertyContainer, null, problems);
- }
-
- public Map<String, Object> loadProperties( Node propertyContainer, Map<String, Object> properties, Problems problems ) {
- if (properties == null) properties = new HashMap<String, Object>();
- if (propertyContainer != null) {
- try {
- NodeIterator iter = propertyContainer.getNodes();
- while (iter.hasNext()) {
- Node propertyNode = iter.nextNode();
- if (propertyNode != null && propertyNode.getPrimaryNodeType().isNodeType("dna:property")) {
- String propertyName = propertyNode.getName();
- Object propertyValue = getPropertyValue(propertyNode, "dna:propertyValue", true, problems);
- properties.put(propertyName, propertyValue);
- }
- }
- } catch (RepositoryException e) {
- problems.addError(e, RepositoryI18n.errorReadingPropertiesFromContainerNode, getReadable(propertyContainer));
- }
- }
-
- return properties;
- }
-
- public boolean removeProblems( Node parent ) throws RepositoryException {
- Node problemsNode = null;
- if (parent.hasNode("dna:problems")) {
- problemsNode = parent.getNode("dna:problems");
- problemsNode.remove();
- return true;
- }
- return false;
- }
-
- public boolean storeProblems( Node parent, Problems problems ) throws RepositoryException {
- Node problemsNode = null;
- if (parent.hasNode("dna:problems")) {
- problemsNode = parent.getNode("dna:problems");
- // Delete all problems ...
- removeAllChildren(problemsNode);
- }
- if (problems.isEmpty()) {
- return false;
- }
- if (problemsNode == null) {
- problemsNode = parent.addNode("dna:problems"); // primary type dictated by child definition
- }
-
- // Add a child for each problem ...
- for (Problem problem : problems) {
- Node problemNode = problemsNode.addNode("problem", "dna:problem");
- // - dna:status (string) mandatory copy
- // < 'ERROR', 'WARNING', 'INFO'
- // - dna:message (string) mandatory copy
- // - dna:code (string) copy
- // - dna:type (string) copy
- // - dna:resource (string) copy
- // - dna:location (string) copy
- // - dna:trace (string) copy
- problemNode.setProperty("dna:status", problem.getStatus().name());
- problemNode.setProperty("dna:message", problem.getMessageString());
- if (problem.getCode() != Problem.DEFAULT_CODE) {
- problemNode.setProperty("dna:code", Integer.toString(problem.getCode()));
- }
- String resource = problem.getResource();
- if (resource != null) {
- problemNode.setProperty("dna:resource", resource);
- }
- String location = problem.getLocation();
- if (location != null) {
- problemNode.setProperty("dna:location", location);
- }
- Throwable t = problem.getThrowable();
- if (t != null) {
- String trace = StringUtil.getStackTrace(t);
- problemNode.setProperty("dna:trace", trace);
- }
- }
- return true;
- }
-
- public int removeAllChildren( Node node ) throws RepositoryException {
- int childrenRemoved = 0;
- NodeIterator iter = node.getNodes();
- while (iter.hasNext()) {
- Node child = iter.nextNode();
- child.remove();
- ++childrenRemoved;
- }
- return childrenRemoved;
- }
-
- public String getPropertyAsString( Node node, String propertyName, boolean required, Problems problems ) {
- return getPropertyAsString(node, propertyName, required, null);
- }
-
- public String getPropertyAsString( Node node, String propertyName, boolean required, String defaultValue, Problems problems ) {
- try {
- Property property = node.getProperty(propertyName);
- return property.getString();
- } catch (ValueFormatException e) {
- if (required) {
- problems.addError(e, RepositoryI18n.requiredPropertyOnNodeWasExpectedToBeStringValue, propertyName, getReadable(node));
- } else {
- problems.addError(e, RepositoryI18n.optionalPropertyOnNodeWasExpectedToBeStringValue, propertyName, getReadable(node));
- }
- } catch (PathNotFoundException e) {
- if (required) {
- problems.addError(e, RepositoryI18n.requiredPropertyIsMissingFromNode, propertyName, getReadable(node));
- }
- if (!required) return defaultValue;
- } catch (RepositoryException err) {
- if (required) {
- problems.addError(err, RepositoryI18n.errorGettingRequiredPropertyFromNode, propertyName, getReadable(node));
- } else {
- problems.addError(err, RepositoryI18n.errorGettingOptionalPropertyFromNode, propertyName, getReadable(node));
- }
- }
- return null;
- }
-
- public Object getPropertyValue( Node node, String propertyName, boolean required, Problems problems ) {
- try {
- Property property = node.getProperty(propertyName);
- switch (property.getType()) {
- case PropertyType.BINARY: {
- InputStream stream = property.getStream();
- try {
- stream = property.getStream();
- return IoUtil.readBytes(stream);
- } finally {
- if (stream != null) {
- try {
- stream.close();
- } catch (IOException e) {
- // Log ...
- Logger.getLogger(this.getClass()).error(e, RepositoryI18n.errorClosingBinaryStreamForPropertyFromNode, propertyName, node.getPath());
- }
- }
- }
- }
- default: {
- return property.getString();
- }
- }
- } catch (IOException e) {
- if (required) {
- problems.addError(e, RepositoryI18n.requiredPropertyOnNodeCouldNotBeRead, propertyName, getReadable(node));
- } else {
- problems.addError(e, RepositoryI18n.optionalPropertyOnNodeCouldNotBeRead, propertyName, getReadable(node));
- }
- } catch (PathNotFoundException e) {
- if (required) {
- problems.addError(e, RepositoryI18n.requiredPropertyIsMissingFromNode, propertyName, getReadable(node));
- }
- } catch (RepositoryException err) {
- if (required) {
- problems.addError(err, RepositoryI18n.errorGettingRequiredPropertyFromNode, propertyName, getReadable(node));
- } else {
- problems.addError(err, RepositoryI18n.errorGettingOptionalPropertyFromNode, propertyName, getReadable(node));
- }
- }
- return null;
- }
-
- public String[] getPropertyAsStringArray( Node node, String propertyName, boolean required, Problems problems, String... defaultValues ) {
- String[] result = defaultValues;
- try {
- Property property = node.getProperty(propertyName);
- if (property.getDefinition().isMultiple()) {
- Value[] values = property.getValues();
- result = new String[values.length];
- int i = 0;
- for (Value value : values) {
- result[i++] = value.getString();
- }
- } else {
- result = new String[] {property.getString()};
- }
- } catch (ValueFormatException e) {
- if (required) {
- problems.addError(e, RepositoryI18n.requiredPropertyOnNodeWasExpectedToBeStringArrayValue, propertyName, getReadable(node));
- } else {
- problems.addError(e, RepositoryI18n.optionalPropertyOnNodeWasExpectedToBeStringArrayValue, propertyName, getReadable(node));
- }
- } catch (PathNotFoundException e) {
- if (required) {
- problems.addError(e, RepositoryI18n.requiredPropertyIsMissingFromNode, propertyName, getReadable(node));
- }
- } catch (RepositoryException err) {
- if (required) {
- problems.addError(err, RepositoryI18n.errorGettingRequiredPropertyFromNode, propertyName, getReadable(node));
- } else {
- problems.addError(err, RepositoryI18n.errorGettingOptionalPropertyFromNode, propertyName, getReadable(node));
- }
- }
- return result;
- }
-
- public Node getNode( Node node, String relativePath, boolean required, Problems problems ) {
- Node result = null;
- try {
- result = node.getNode(relativePath);
- } catch (PathNotFoundException e) {
- if (required) problems.addError(e, RepositoryI18n.requiredNodeDoesNotExistRelativeToNode, relativePath, getReadable(node));
- } catch (RepositoryException err) {
- problems.addError(err, RepositoryI18n.errorGettingNodeRelativeToNode, relativePath, getReadable(node));
- }
- return result;
- }
-
- public String getReadable( Node node ) {
- if (node == null) return "";
- try {
- return node.getPath();
- } catch (RepositoryException err) {
- return node.toString();
- }
- }
-
- public Node findOrCreateNode( Session session, String path ) throws RepositoryException {
- return findOrCreateNode(session, path, null, null);
- }
-
- public Node findOrCreateNode( Session session, String path, String nodeType ) throws RepositoryException {
- return findOrCreateNode(session, path, nodeType, nodeType);
- }
-
- public Node findOrCreateNode( Session session, String path, String defaultNodeType, String finalNodeType ) throws RepositoryException {
- Node root = session.getRootNode();
- return findOrCreateNode(session, root, path, defaultNodeType, finalNodeType);
- }
-
- public Node findOrCreateNode( Session session, Node parentNode, String path, String defaultNodeType, String finalNodeType ) throws RepositoryException {
- // Remove leading and trailing slashes ...
- String relPath = path.replaceAll("^/+", "").replaceAll("/+$", "");
-
- // Look for the node first ...
- try {
- return parentNode.getNode(relPath);
- } catch (PathNotFoundException e) {
- // continue
- }
- // Create the node, which has to be done segment by segment ...
- String[] pathSegments = relPath.split("/");
- Node node = parentNode;
- for (int i = 0, len = pathSegments.length; i != len; ++i) {
- String pathSegment = pathSegments[i];
- pathSegment = pathSegment.trim();
- if (pathSegment.length() == 0) continue;
- if (node.hasNode(pathSegment)) {
- // Find the existing node ...
- node = node.getNode(pathSegment);
- } else {
- // Make sure there is no index on the final segment ...
- String pathSegmentWithNoIndex = pathSegment.replaceAll("(\\[\\d+\\])+$", "");
- // Create the node ...
- String nodeType = defaultNodeType;
- if (i == len - 1 && finalNodeType != null) nodeType = finalNodeType;
- if (nodeType != null) {
- node = node.addNode(pathSegmentWithNoIndex, nodeType);
- } else {
- node = node.addNode(pathSegmentWithNoIndex);
- }
- }
- }
- return node;
- }
-
- public Node findOrCreateChild( Session session, Node parent, String name ) throws RepositoryException {
- return findOrCreateChild(session, parent, name, null);
- }
-
- public Node findOrCreateChild( Session session, Node parent, String name, String nodeType ) throws RepositoryException {
- return findOrCreateNode(session, parent, name, nodeType, nodeType);
- }
-
-}
Deleted: trunk/dna-repository/src/main/java/org/jboss/dna/repository/util/JndiSessionFactory.java
===================================================================
--- trunk/dna-repository/src/main/java/org/jboss/dna/repository/util/JndiSessionFactory.java 2009-05-21 22:26:25 UTC (rev 922)
+++ trunk/dna-repository/src/main/java/org/jboss/dna/repository/util/JndiSessionFactory.java 2009-05-22 02:15:19 UTC (rev 923)
@@ -1,140 +0,0 @@
-/*
- * JBoss DNA (http://www.jboss.org/dna)
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- * See the AUTHORS.txt file in the distribution for a full listing of
- * individual contributors.
- *
- * JBoss DNA is free software. Unless otherwise indicated, all code in JBoss DNA
- * is licensed to you under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * JBoss DNA is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-
-package org.jboss.dna.repository.util;
-
-import javax.jcr.Credentials;
-import javax.jcr.Repository;
-import javax.jcr.Session;
-import javax.naming.Context;
-import javax.naming.InitialContext;
-import javax.naming.NamingException;
-import org.jboss.dna.common.SystemFailureException;
-import org.jboss.dna.common.util.CheckArg;
-import org.jboss.dna.repository.RepositoryI18n;
-
-/**
- * A SessionFactory implementation that creates {@link Session} instances using {@link Repository} instances registered in JNDI.
- * <p>
- * This factory using a naming convention where the name supplied to the {@link #createSession(String)} contains both the name of
- * the repository and the name of the workspace. Typically, this is <i><code>repositoryName/workspaceName</code></i>, where
- * <code>repositoryName</code> is the JNDI name under which the Repository instance was bound, and <code>workspaceName</code>
- * is the name of the workspace. Note that this method looks for the last delimiter in the whole name to distinguish between the
- * repository and workspace names.
- * </p>
- * <p>
- * For example, if "<code>java:comp/env/repository/dataRepository/myWorkspace</code>" is passed to the
- * {@link #createSession(String)} method, this factory will look for a {@link Repository} instance registered in JDNI with the
- * name "<code>java:comp/env/repository/dataRepository</code>" and use it to {@link Repository#login(String) create a session}
- * to the workspace named "<code>myWorkspace</code>".
- * </p>
- * <p>
- * By default, this factory creates an anonymous JCR session. To use sessions with specific {@link Credentials}, simply
- * {@link #registerCredentials(String, Credentials) register} credentials for the appropriate repository/workspace name. For
- * security reasons, it is not possible to retrieve the Credentials once registered with this factory.
- * </p>
- * @author Randall Hauch
- */
-public class JndiSessionFactory extends AbstractSessionFactory {
-
- private final Context context;
-
- /**
- * Create an instance of the factory by creating a new {@link InitialContext}. This is equivalent to calling
- * <code>new JndiSessionFactory(new InitialContext())</code>.
- * @throws NamingException if there is a problem creating the InitialContext.
- */
- public JndiSessionFactory() throws NamingException {
- this(new InitialContext());
- }
-
- /**
- * Create an instance of the factory by supplying the characters that may be used to delimit the workspace name from the
- * repository name. This constructor initializes the factory with a new {@link InitialContext}, and is equivalent to calling
- * <code>new JndiSessionFactory(new InitialContext(),workspaceDelimiters)</code>.
- * @param workspaceDelimiters the delimiters, or null/empty if the default delimiter of '/' should be used.
- * @throws NamingException if there is a problem creating the InitialContext.
- */
- public JndiSessionFactory( char... workspaceDelimiters ) throws NamingException {
- this(new InitialContext(), workspaceDelimiters);
- }
-
- /**
- * Create an instance of the factory using the supplied JNDI context.
- * @param context the naming context
- * @throws IllegalArgumentException if the context parameter is null
- */
- public JndiSessionFactory( Context context ) {
- this(context, DEFAULT_DELIMITERS);
- }
-
- /**
- * Create an instance of the factory by supplying naming context and the characters that may be used to delimit the workspace
- * name from the repository name.
- * @param context the naming context
- * @param workspaceDelimiters the delimiters, or null/empty if the default delimiter of '/' should be used.
- * @throws IllegalArgumentException if the context parameter is null
- */
- public JndiSessionFactory( Context context, char... workspaceDelimiters ) {
- super(workspaceDelimiters);
- CheckArg.isNotNull(context, "initial context");
- this.context = context;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- protected void doRegisterRepository( String name, Repository repository ) throws SystemFailureException {
- try {
- this.context.bind(name, repository);
- } catch (NamingException e) {
- throw new SystemFailureException(RepositoryI18n.unableToRegisterRepositoryInJndi.text(name));
- }
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- protected void doUnregisterRepository( String name ) throws SystemFailureException {
- try {
- this.context.unbind(name);
- } catch (NamingException e) {
- throw new SystemFailureException(RepositoryI18n.unableToUnregisterRepositoryInJndi.text(name));
- }
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- protected Repository findRegisteredRepository( String name ) throws SystemFailureException {
- try {
- return (Repository)this.context.lookup(name);
- } catch (NamingException e) {
- throw new SystemFailureException(RepositoryI18n.unableToFindRepositoryInJndi.text(name));
- }
- }
-}
Deleted: trunk/dna-repository/src/test/java/org/jboss/dna/repository/observation/NodeChangeTest.java
===================================================================
--- trunk/dna-repository/src/test/java/org/jboss/dna/repository/observation/NodeChangeTest.java 2009-05-21 22:26:25 UTC (rev 922)
+++ trunk/dna-repository/src/test/java/org/jboss/dna/repository/observation/NodeChangeTest.java 2009-05-22 02:15:19 UTC (rev 923)
@@ -1,67 +0,0 @@
-/*
- * JBoss DNA (http://www.jboss.org/dna)
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- * See the AUTHORS.txt file in the distribution for a full listing of
- * individual contributors.
- *
- * JBoss DNA is free software. Unless otherwise indicated, all code in JBoss DNA
- * is licensed to you under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * JBoss DNA is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.dna.repository.observation;
-
-import java.util.HashSet;
-import java.util.Set;
-import javax.jcr.observation.Event;
-import org.junit.Before;
-import org.junit.Test;
-
-/**
- * @author Randall Hauch
- */
-public class NodeChangeTest {
-
- private String validRepositoryWorkspaceName;
- private String validAbsolutePath;
- private int validEventTypes;
- private Set<String> validModifiedProperties;
- private Set<String> validRemovedProperties;
- private NodeChange nodeChange;
-
- @Before
- public void beforeEach() {
- validRepositoryWorkspaceName = "repositoryX";
- validAbsolutePath = "/a/b/c/d";
- validEventTypes = Event.NODE_ADDED | Event.PROPERTY_ADDED | Event.PROPERTY_CHANGED | Event.PROPERTY_REMOVED;
- validModifiedProperties = new HashSet<String>();
- validRemovedProperties = new HashSet<String>();
- validModifiedProperties.add("jcr:name");
- validModifiedProperties.add("jcr:title");
- validRemovedProperties.add("jcr:mime");
- nodeChange = new NodeChange("", validRepositoryWorkspaceName, validAbsolutePath, validEventTypes, validModifiedProperties,
- validRemovedProperties);
- }
-
- @Test( expected = UnsupportedOperationException.class )
- public void shouldHaveUnmodifiableSetOfModifiedPropertyNames() {
- nodeChange.getModifiedProperties().clear();
- }
-
- @Test( expected = UnsupportedOperationException.class )
- public void shouldHaveUnmodifiableSetOfRemovedPropertyNames() {
- nodeChange.getRemovedProperties().clear();
- }
-}
Deleted: trunk/dna-repository/src/test/java/org/jboss/dna/repository/rules/RuleInput.java
===================================================================
--- trunk/dna-repository/src/test/java/org/jboss/dna/repository/rules/RuleInput.java 2009-05-21 22:26:25 UTC (rev 922)
+++ trunk/dna-repository/src/test/java/org/jboss/dna/repository/rules/RuleInput.java 2009-05-22 02:15:19 UTC (rev 923)
@@ -1,81 +0,0 @@
-/*
- * JBoss DNA (http://www.jboss.org/dna)
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- * See the AUTHORS.txt file in the distribution for a full listing of
- * individual contributors.
- *
- * JBoss DNA is free software. Unless otherwise indicated, all code in JBoss DNA
- * is licensed to you under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * JBoss DNA is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.dna.repository.rules;
-
-public final class RuleInput {
-
- String mimeType = "";
- String header = "";
- String fileName = "";
-
- /**
- * @return fileName
- */
- public String getFileName() {
- return fileName;
- }
-
- /**
- * @return header
- */
- public String getHeader() {
- return header;
- }
-
- /**
- * @return mimeType
- */
- public String getMimeType() {
- return mimeType;
- }
-
- /**
- * @param fileName Sets fileName to the specified value.
- */
- public void setFileName( String fileName ) {
- this.fileName = fileName;
- }
-
- /**
- * @param header Sets header to the specified value.
- */
- public void setHeader( String header ) {
- this.header = header;
- }
-
- /**
- * @param mimeType Sets mimeType to the specified value.
- */
- public void setMimeType( String mimeType ) {
- this.mimeType = mimeType;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public String toString() {
- return this.fileName + " (" + this.mimeType + ") => " + this.header;
- }
-}
Deleted: trunk/dna-repository/src/test/java/org/jboss/dna/repository/rules/RuleResult.java
===================================================================
--- trunk/dna-repository/src/test/java/org/jboss/dna/repository/rules/RuleResult.java 2009-05-21 22:26:25 UTC (rev 922)
+++ trunk/dna-repository/src/test/java/org/jboss/dna/repository/rules/RuleResult.java 2009-05-22 02:15:19 UTC (rev 923)
@@ -1,43 +0,0 @@
-/*
- * JBoss DNA (http://www.jboss.org/dna)
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- * See the AUTHORS.txt file in the distribution for a full listing of
- * individual contributors.
- *
- * JBoss DNA is free software. Unless otherwise indicated, all code in JBoss DNA
- * is licensed to you under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * JBoss DNA is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.dna.repository.rules;
-
-/**
- * @author John Verhaeg
- */
-public final class RuleResult {
-
- String name;
-
- public RuleResult( String name ) {
- this.name = name != null ? name : "";
- }
-
- /**
- * @return name
- */
- public String getName() {
- return name;
- }
-}
Deleted: trunk/dna-repository/src/test/java/org/jboss/dna/repository/rules/RuleServiceTest.java
===================================================================
--- trunk/dna-repository/src/test/java/org/jboss/dna/repository/rules/RuleServiceTest.java 2009-05-21 22:26:25 UTC (rev 922)
+++ trunk/dna-repository/src/test/java/org/jboss/dna/repository/rules/RuleServiceTest.java 2009-05-22 02:15:19 UTC (rev 923)
@@ -1,244 +0,0 @@
-/*
- * JBoss DNA (http://www.jboss.org/dna)
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- * See the AUTHORS.txt file in the distribution for a full listing of
- * individual contributors.
- *
- * JBoss DNA is free software. Unless otherwise indicated, all code in JBoss DNA
- * is licensed to you under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * JBoss DNA is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.dna.repository.rules;
-
-import static org.hamcrest.core.Is.is;
-import static org.hamcrest.core.IsInstanceOf.instanceOf;
-import static org.hamcrest.core.IsNot.not;
-import static org.hamcrest.core.IsNull.notNullValue;
-import static org.hamcrest.core.IsSame.sameInstance;
-import static org.junit.Assert.assertThat;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-import java.io.IOException;
-import java.net.URL;
-import java.util.HashMap;
-import java.util.LinkedHashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import org.jboss.dna.common.component.ClassLoaderFactory;
-import org.jboss.dna.common.component.StandardClassLoaderFactory;
-import org.jboss.dna.common.util.IoUtil;
-import org.jboss.dna.common.util.Logger;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-
-/**
- * @author Randall Hauch
- */
-public class RuleServiceTest {
-
- protected static final String DROOLS_PROVIDER_CLASSNAME = "org.drools.jsr94.rules.RuleServiceProviderImpl";
- protected static final String DROOLS_PROVIDER_URI = "http://drools.org/";
-
- private RuleService ruleService;
- private ClassLoaderFactory classLoaderFactory;
-
- protected RuleSet createDroolsRuleSet( String desc ) throws IOException {
- String name = "SampleRuleSet";
- String description = desc != null ? desc : "This is a sample rule set that uses Drools";
- String providerClassname = DROOLS_PROVIDER_CLASSNAME;
- String providerUri = DROOLS_PROVIDER_URI;
- String[] providerClasspath = new String[] {};
- String ruleSetUri = null;
- URL ruleFile = this.getClass().getResource("/rule_test.dslr");
- URL dslFile = this.getClass().getResource("/rule_test.dsl");
- String rules = IoUtil.read(ruleFile.openStream());
- byte[] dslBytes = IoUtil.readBytes(dslFile.openStream());
- Map<String, Object> properties = new HashMap<String, Object>();
- properties.put("javax.rules.admin.RuleExecutionSet.source", "drl"); // as opposed to "xml"
- properties.put("javax.rules.admin.RuleExecutionSet.dsl", dslBytes);
- return new RuleSet(name, description, providerClassname, providerClasspath, providerUri, ruleSetUri, rules, properties);
- }
-
- protected RuleSet createRuleSetWithInvalidProvider() throws IOException {
- String name = "SampleRuleSet"; // same name as Drools rule set
- String description = "This is a sample rule set that uses Drools";
- String providerClassname = DROOLS_PROVIDER_CLASSNAME;
- String providerUri = DROOLS_PROVIDER_URI + "this/is/incorrect";
- String[] providerClasspath = new String[] {};
- String ruleSetUri = null;
- URL ruleFile = this.getClass().getResource("/rule_test.dslr");
- URL dslFile = this.getClass().getResource("/rule_test.dsl");
- String rules = IoUtil.read(ruleFile.openStream());
- byte[] dslBytes = IoUtil.readBytes(dslFile.openStream());
- Map<String, Object> properties = new HashMap<String, Object>();
- properties.put("javax.rules.admin.RuleExecutionSet.source", "drl"); // as opposed to "xml"
- properties.put("javax.rules.admin.RuleExecutionSet.dsl", dslBytes);
- return new RuleSet(name, description, providerClassname, providerClasspath, providerUri, ruleSetUri, rules, properties);
- }
-
- @Before
- public void beforeEach() {
- this.ruleService = new RuleService();
- this.classLoaderFactory = new StandardClassLoaderFactory();
- }
-
- @After
- public void afterEach() {
- this.ruleService.getAdministrator().shutdown();
- }
-
- @Test
- public void shouldHaveDefaultClasspathFactoryUponConstruction() {
- assertThat(ruleService.getClassLoaderFactory(), is(notNullValue()));
- assertThat(ruleService.getClassLoaderFactory(), is(sameInstance(RuleService.DEFAULT_CLASSLOADER_FACTORY)));
- }
-
- @Test
- public void shouldHaveLoggerUponConstruction() {
- assertThat(ruleService.getLogger(), is(notNullValue()));
- }
-
- @Test
- public void shouldHaveEmptyRuleSetCollectionUponConstruction() {
- assertThat(ruleService.getRuleSets(), is(notNullValue()));
- assertThat(ruleService.getRuleSets().isEmpty(), is(true));
- }
-
- @Test( expected = UnsupportedOperationException.class )
- public void shouldReturnUnmodifiableCollectionOfRuleSets() {
- ruleService.getRuleSets().add(null);
- }
-
- @Test
- public void shouldSetClassLoaderFactoryToDefaultWhenPassedNull() {
- assertThat(ruleService.getClassLoaderFactory(), is(sameInstance(RuleService.DEFAULT_CLASSLOADER_FACTORY)));
- ruleService.setClassLoaderFactory(classLoaderFactory);
- assertThat(ruleService.getClassLoaderFactory(), is(sameInstance(classLoaderFactory)));
- ruleService.setClassLoaderFactory(null);
- assertThat(ruleService.getClassLoaderFactory(), is(sameInstance(RuleService.DEFAULT_CLASSLOADER_FACTORY)));
- }
-
- @Test
- public void shouldSetLoggerToDefaultWhenPassedNull() {
- Logger defaultLogger = ruleService.getLogger();
- assertThat(ruleService.getLogger(), is(notNullValue()));
- Logger orgLogger = Logger.getLogger("org");
- ruleService.setLogger(orgLogger);
- assertThat(ruleService.getLogger().getName(), is(orgLogger.getName()));
- assertThat(ruleService.getLogger(), is(sameInstance(orgLogger)));
- ruleService.setLogger(null);
- assertThat(ruleService.getLogger().getName(), is(defaultLogger.getName()));
- assertThat(ruleService.getLogger(), is(not(orgLogger)));
- }
-
- @Test( expected = InvalidRuleSetException.class )
- public void shouldNotAddInvalidRuleSet() throws Exception {
- ruleService.addRuleSet(createRuleSetWithInvalidProvider());
-
- }
-
- @Test
- public void shouldAddValidRuleSet() throws Exception {
- int numRuleSetsBefore = ruleService.getRuleSets().size();
- RuleSet validRuleSet = createDroolsRuleSet(null);
- assertThat(ruleService.addRuleSet(validRuleSet), is(true));
- assertThat(ruleService.getRuleSets().size(), is(numRuleSetsBefore + 1));
- }
-
- @Test
- public void shouldNotUpdateValidRuleSetWithInvalidRuleSet() throws Exception {
- RuleSet validRuleSet = createDroolsRuleSet(null);
- final String ruleSetName = validRuleSet.getName();
-
- assertThat(ruleService.addRuleSet(validRuleSet), is(true));
- assertThat(ruleService.getRuleSets().size(), is(1));
- assertThat(ruleService.getRuleSets().iterator().next(), is(validRuleSet));
- // Verify this rule set works ...
- executeRuleSet(ruleSetName);
-
- // Try to update the rule set with something that's invalid ...
- RuleSet invalidRuleSet = createRuleSetWithInvalidProvider();
- assertThat(invalidRuleSet.getName(), is(ruleSetName));
- assertThat(invalidRuleSet.getName(), is(validRuleSet.getName()));
- try {
- ruleService.addRuleSet(invalidRuleSet);
- fail("Should not get here");
- } catch (InvalidRuleSetException e) {
- // This is expected since it was a bad rule set ...
- }
-
- // Verify the original rule set is still there and still works ...
- assertThat(ruleService.getRuleSets().size(), is(1));
- assertThat(ruleService.getRuleSets().iterator().next(), is(validRuleSet));
- executeRuleSet(ruleSetName);
- }
-
- @Test
- public void shouldModifyExistingRuleSetWhenAddedOnlyWhenChanged() throws Exception {
- int numRuleSetsBefore = ruleService.getRuleSets().size();
- RuleSet validRuleSet = createDroolsRuleSet(null);
- assertThat(ruleService.addRuleSet(validRuleSet), is(true));
- assertThat(ruleService.getRuleSets().size(), is(numRuleSetsBefore + 1));
-
- // Try to add an unchanged rule set ...
- RuleSet validRuleSet2 = createDroolsRuleSet(null);
- assertThat(validRuleSet2.hasChanged(validRuleSet), is(false));
- assertThat(ruleService.addRuleSet(validRuleSet2), is(false));
- assertThat(ruleService.getRuleSets().size(), is(numRuleSetsBefore + 1));
-
- // Try to add a changed rule set ...
- RuleSet validRuleSet3 = createDroolsRuleSet("This is an alternative description that causes it to be changed");
- assertThat(validRuleSet3.hasChanged(validRuleSet), is(true));
- assertThat(ruleService.addRuleSet(validRuleSet3), is(true));
- assertThat(ruleService.getRuleSets().size(), is(numRuleSetsBefore + 1));
- }
-
- @Test
- public void shouldExecuteRuleSet() throws Exception {
- RuleSet validRuleSet = createDroolsRuleSet(null);
- assertThat(ruleService.addRuleSet(validRuleSet), is(true));
-
- executeRuleSet(validRuleSet.getName());
- }
-
- protected void executeRuleSet( String ruleSetName ) {
- // Create some simple fact objects ...
- RuleInput info = new RuleInput();
- info.setFileName("someOtherInput.dsl");
- info.setHeader("This is the sequencer header");
- info.setMimeType("text");
-
- // Run the rules ...
- Set<String> output = new LinkedHashSet<String>();
- Map<String, Object> globals = new HashMap<String, Object>();
- globals.put("output", output);
-
- List<?> results = ruleService.executeRules(ruleSetName, globals, info);
- assertThat(results, is(notNullValue()));
- assertThat(results.isEmpty(), is(false));
- assertThat(results.size(), is(2));
- assertTrue(results.get(0) instanceof RuleResult || results.get(1) instanceof RuleResult);
- // Object result = results.get(0);
- // assertThat(result, is(instanceOf(RuleResult.class)));
- assertThat(output.isEmpty(), is(false));
- Object sequencer = output.iterator().next();
- assertThat(sequencer, is(instanceOf(String.class)));
- assertThat(((String)sequencer), is("A"));
- }
-
-}
Deleted: trunk/dna-repository/src/test/java/org/jboss/dna/repository/rules/RuleSetTest.java
===================================================================
--- trunk/dna-repository/src/test/java/org/jboss/dna/repository/rules/RuleSetTest.java 2009-05-21 22:26:25 UTC (rev 922)
+++ trunk/dna-repository/src/test/java/org/jboss/dna/repository/rules/RuleSetTest.java 2009-05-22 02:15:19 UTC (rev 923)
@@ -1,341 +0,0 @@
-/*
- * JBoss DNA (http://www.jboss.org/dna)
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- * See the AUTHORS.txt file in the distribution for a full listing of
- * individual contributors.
- *
- * JBoss DNA is free software. Unless otherwise indicated, all code in JBoss DNA
- * is licensed to you under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * JBoss DNA is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.dna.repository.rules;
-
-import static org.hamcrest.core.Is.is;
-import static org.hamcrest.core.IsInstanceOf.instanceOf;
-import static org.hamcrest.core.IsNull.notNullValue;
-import static org.junit.Assert.assertThat;
-import java.io.Reader;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.Set;
-import org.jboss.dna.common.util.IoUtil;
-import org.junit.Before;
-import org.junit.Test;
-
-/**
- * @author Randall Hauch
- */
-public class RuleSetTest {
-
- private RuleSet ruleSet;
- private String validName;
- private String validDescription;
- private String validClassname;
- private String[] validClasspath;
- private String validProviderUri;
- private String validRuleSetUri;
- private String validRules;
- private Map<String, Object> validProperties;
-
- @Before
- public void beforeEach() {
- this.validName = "This is a valid name";
- this.validDescription = "This is a valid description";
- this.validClassname = "com.acme.SuperDuper";
- this.validClasspath = new String[] {"classpath1", "classpath2"};
- this.validProviderUri = "http://www.acme.com/super/duper/rules_engine";
- this.validRuleSetUri = "com.something.whatever doesn't really need to be a URI";
- this.validRules = "when something is true then cheer";
- this.validProperties = new HashMap<String, Object>();
- this.validProperties.put("key1", "value1");
- this.validProperties.put("key2", null);
- this.validProperties.put("key3", "value3".getBytes());
- this.ruleSet = new RuleSet(validName, validDescription, validClassname, validClasspath, validProviderUri,
- validRuleSetUri, validRules, validProperties);
- }
-
- @Test( expected = IllegalArgumentException.class )
- public void shouldNotAllowNullName() {
- new RuleSet(null, validDescription, validClassname, validClasspath, validProviderUri, validRuleSetUri, validRules,
- validProperties);
- }
-
- @Test( expected = IllegalArgumentException.class )
- public void shouldNotAllowEmptyName() {
- new RuleSet("", validDescription, validClassname, validClasspath, validProviderUri, validRuleSetUri, validRules,
- validProperties);
- }
-
- @Test( expected = IllegalArgumentException.class )
- public void shouldNotAllowBlankName() {
- new RuleSet(" \t ", validDescription, validClassname, validClasspath, validProviderUri, validRuleSetUri, validRules,
- validProperties);
- }
-
- @Test
- public void shouldTrimName() {
- validName = " this is a valid name with leading and trailing whitespace ";
- ruleSet = new RuleSet(validName, validDescription, validClassname, validClasspath, validProviderUri, validRuleSetUri,
- validRules, validProperties);
- assertThat(ruleSet.getName(), is(validName.trim()));
- }
-
- @Test
- public void shouldAllowNullOrEmptyOrBlankDescriptionAndShouldReplaceWithEmptyString() {
- ruleSet = new RuleSet(validName, null, validClassname, validClasspath, validProviderUri, validRuleSetUri, validRules,
- validProperties);
- assertThat(ruleSet.getDescription(), is(""));
- ruleSet = new RuleSet(validName, "", validClassname, validClasspath, validProviderUri, validRuleSetUri, validRules,
- validProperties);
- assertThat(ruleSet.getDescription(), is(""));
- ruleSet = new RuleSet(validName, " \t ", validClassname, validClasspath, validProviderUri, validRuleSetUri, validRules,
- validProperties);
- assertThat(ruleSet.getDescription(), is(""));
- }
-
- @Test
- public void shouldTrimDescription() {
- ruleSet = new RuleSet(validName, " valid ", validClassname, validClasspath, validProviderUri, validRuleSetUri,
- validRules, validProperties);
- assertThat(ruleSet.getDescription(), is("valid"));
- }
-
- @Test( expected = IllegalArgumentException.class )
- public void shouldNotAllowNullClassname() {
- new RuleSet(validName, validDescription, null, validClasspath, validProviderUri, validRuleSetUri, validRules,
- validProperties);
- }
-
- @Test( expected = IllegalArgumentException.class )
- public void shouldNotAllowEmptyClassname() {
- new RuleSet(validName, validDescription, "", validClasspath, validProviderUri, validRuleSetUri, validRules,
- validProperties);
- }
-
- @Test( expected = IllegalArgumentException.class )
- public void shouldNotAllowBlankClassname() {
- new RuleSet(validName, validDescription, " ", validClasspath, validProviderUri, validRuleSetUri, validRules,
- validProperties);
- }
-
- @Test( expected = IllegalArgumentException.class )
- public void shouldNotAllowClassnameThatDoesNotFollowJavaNamingRules() {
- new RuleSet(validName, validDescription, "not a valid classname", validClasspath, validProviderUri, validRuleSetUri,
- validRules, validProperties);
- }
-
- @Test
- public void shouldAllowNullOrEmptyClasspath() {
- new RuleSet(validName, validDescription, validClassname, null, validProviderUri, validRuleSetUri, validRules,
- validProperties);
- }
-
- @Test
- public void shouldRemoveNullOrBlankClasspathItems() {
- new RuleSet(validName, validDescription, validClassname, new String[] {}, validProviderUri, validRuleSetUri, validRules,
- validProperties);
- }
-
- @Test
- public void shouldRemoveDuplicateClasspathItemsInCaseSensitiveManner() {
- validClasspath = new String[] {"path1", "path2", "path1", "path3", "path2"};
- ruleSet = new RuleSet(validName, validDescription, validClassname, validClasspath, validProviderUri, validRuleSetUri,
- validRules, validProperties);
- assertThat(ruleSet.getComponentClasspathArray(), is(new String[] {"path1", "path2", "path3"}));
-
- validClasspath = new String[] {"path1", "path2", "path1", "path3", "Path2"};
- ruleSet = new RuleSet(validName, validDescription, validClassname, validClasspath, validProviderUri, validRuleSetUri,
- validRules, validProperties);
- assertThat(ruleSet.getComponentClasspathArray(), is(new String[] {"path1", "path2", "path3", "Path2"}));
- }
-
- @Test( expected = IllegalArgumentException.class )
- public void shouldNotAllowNullProviderUri() {
- new RuleSet(validName, validDescription, validClassname, validClasspath, null, validRuleSetUri, validRules,
- validProperties);
- }
-
- @Test( expected = IllegalArgumentException.class )
- public void shouldNotAllowEmptyProviderUri() {
- new RuleSet(validName, validDescription, validClassname, validClasspath, "", validRuleSetUri, validRules, validProperties);
- }
-
- @Test( expected = IllegalArgumentException.class )
- public void shouldNotAllowBlankProviderUri() {
- new RuleSet(validName, validDescription, validClassname, validClasspath, " \t ", validRuleSetUri, validRules,
- validProperties);
- }
-
- @Test
- public void shouldUseNameInPlaceOfNullRuleSetUri() {
- ruleSet = new RuleSet(validName, validDescription, validClassname, validClasspath, validProviderUri, null, validRules,
- validProperties);
- assertThat(ruleSet.getRuleSetUri(), is(ruleSet.getName()));
- }
-
- @Test( expected = IllegalArgumentException.class )
- public void shouldNotAllowEmptyRuleSetUri() {
- new RuleSet(validName, validDescription, validClassname, validClasspath, validProviderUri, "", validRules,
- validProperties);
- }
-
- @Test( expected = IllegalArgumentException.class )
- public void shouldNotAllowBlankRuleSetUri() {
- new RuleSet(validName, validDescription, validClassname, validClasspath, validProviderUri, " \t ", validRules,
- validProperties);
- }
-
- @Test( expected = IllegalArgumentException.class )
- public void shouldNotAllowNullRules() {
- new RuleSet(validName, validDescription, validClassname, validClasspath, validProviderUri, validRuleSetUri, null,
- validProperties);
- }
-
- @Test( expected = IllegalArgumentException.class )
- public void shouldNotAllowEmptyRules() {
- new RuleSet(validName, validDescription, validClassname, validClasspath, validProviderUri, validRuleSetUri, "",
- validProperties);
- }
-
- @Test( expected = IllegalArgumentException.class )
- public void shouldNotAllowBlankRules() {
- new RuleSet(validName, validDescription, validClassname, validClasspath, validProviderUri, validRuleSetUri, " \t ",
- validProperties);
- }
-
- @Test
- public void shouldAllowNullOrEmptyProperties() {
- validProperties = null;
- ruleSet = new RuleSet(validName, validDescription, validClassname, validClasspath, validProviderUri, validRuleSetUri,
- validRules, validProperties);
- assertThat(ruleSet.getProperties(), is(notNullValue()));
- }
-
- @Test
- public void shouldWrapByteArrayPropertyValuesWithInputStreamInExecutionSetProperties() throws Exception {
- Map<Object, Object> executionSetProps = ruleSet.getExecutionSetProperties();
- assertThat(executionSetProps.size(), is(ruleSet.getProperties().size()));
- assertThat(executionSetProps.keySet(), is((Set<Object>)new HashSet<Object>(ruleSet.getProperties().keySet())));
- Iterator<Map.Entry<Object, Object>> executionSetPropIter = executionSetProps.entrySet().iterator();
- Iterator<Map.Entry<String, Object>> propIter = ruleSet.getProperties().entrySet().iterator();
- while (executionSetPropIter.hasNext() && propIter.hasNext()) {
- Map.Entry<Object, Object> execSetEntry = executionSetPropIter.next();
- Object execSetKey = execSetEntry.getKey();
- Object execSetValue = execSetEntry.getValue();
- Map.Entry<String, Object> propertyEntry = propIter.next();
- String propertyKey = propertyEntry.getKey();
- Object propertyValue = propertyEntry.getValue();
- // Check the entries ...
- assertThat(execSetKey, is((Object)propertyKey));
- if (propertyValue instanceof byte[]) {
- assertThat(execSetValue, is(instanceOf(Reader.class)));
- String streamValueAsString = IoUtil.read((Reader)execSetValue);
- String propertyValueAsString = new String((byte[])propertyValue);
- assertThat(streamValueAsString, is(propertyValueAsString));
- } else {
- assertThat(execSetValue, is(propertyValue));
- }
- }
- assertThat(executionSetPropIter.hasNext(), is(false));
- assertThat(propIter.hasNext(), is(false));
-
- new RuleSet(validName, validDescription, validClassname, validClasspath, validProviderUri, validRuleSetUri, validRules,
- validProperties);
- }
-
- @Test
- public void shouldConsiderAnyAttributeDifferencesAsChange() {
- RuleSet copy = ruleSet.clone();
- assertThat(copy.hasChanged(ruleSet), is(false));
- assertThat(copy.hasChanged(copy), is(false));
-
- copy = new RuleSet(validName + "x", validDescription, validClassname, validClasspath, validProviderUri, validRuleSetUri,
- validRules, validProperties);
- assertThat(copy.hasChanged(ruleSet), is(true));
- assertThat(copy.hasChanged(copy), is(false));
-
- copy = new RuleSet(validName, validDescription + "x", validClassname, validClasspath, validProviderUri, validRuleSetUri,
- validRules, validProperties);
- assertThat(copy.hasChanged(ruleSet), is(true));
- assertThat(copy.hasChanged(copy), is(false));
-
- copy = new RuleSet(validName, validDescription, validClassname + "x", validClasspath, validProviderUri, validRuleSetUri,
- validRules, validProperties);
- assertThat(copy.hasChanged(ruleSet), is(true));
- assertThat(copy.hasChanged(copy), is(false));
-
- copy = new RuleSet(validName, validDescription, validClassname, validClasspath, validProviderUri + "x", validRuleSetUri,
- validRules, validProperties);
- assertThat(copy.hasChanged(ruleSet), is(true));
- assertThat(copy.hasChanged(copy), is(false));
-
- validClasspath = new String[] {"classpath1", "classpath2x"};
- copy = new RuleSet(validName, validDescription, validClassname, validClasspath, validProviderUri, validRuleSetUri + "x",
- validRules, validProperties);
- assertThat(copy.hasChanged(ruleSet), is(true));
- assertThat(copy.hasChanged(copy), is(false));
-
- copy = new RuleSet(validName, validDescription, validClassname, validClasspath, validProviderUri, validRuleSetUri,
- validRules + "x", validProperties);
- assertThat(copy.hasChanged(ruleSet), is(true));
- assertThat(copy.hasChanged(copy), is(false));
-
- validProperties.remove("key1");
- copy = new RuleSet(validName, validDescription, validClassname, validClasspath, validProviderUri, validRuleSetUri,
- validRules, validProperties);
- assertThat(copy.hasChanged(ruleSet), is(true));
- assertThat(copy.hasChanged(copy), is(false));
- }
-
- @Test
- public void shouldConsiderOnlyNameWhenDeterminingIfSame() {
- RuleSet copy = ruleSet.clone();
- assertThat(copy.equals(ruleSet), is(true));
-
- copy = new RuleSet(validName + "x", validDescription, validClassname, validClasspath, validProviderUri, validRuleSetUri,
- validRules, validProperties);
- assertThat(copy.equals(ruleSet), is(false));
-
- copy = new RuleSet(validName, validDescription + "x", validClassname, validClasspath, validProviderUri, validRuleSetUri,
- validRules, validProperties);
- assertThat(copy.equals(ruleSet), is(true));
-
- copy = new RuleSet(validName, validDescription, validClassname + "x", validClasspath, validProviderUri, validRuleSetUri,
- validRules, validProperties);
- assertThat(copy.equals(ruleSet), is(true));
-
- copy = new RuleSet(validName, validDescription, validClassname, validClasspath, validProviderUri + "x", validRuleSetUri,
- validRules, validProperties);
- assertThat(copy.equals(ruleSet), is(true));
-
- validClasspath = new String[] {"classpath1", "classpath2x"};
- copy = new RuleSet(validName, validDescription, validClassname, validClasspath, validProviderUri, validRuleSetUri + "x",
- validRules, validProperties);
- assertThat(copy.equals(ruleSet), is(true));
-
- copy = new RuleSet(validName, validDescription, validClassname, validClasspath, validProviderUri, validRuleSetUri,
- validRules + "x", validProperties);
- assertThat(copy.equals(ruleSet), is(true));
-
- validProperties.remove("key1");
- copy = new RuleSet(validName, validDescription, validClassname, validClasspath, validProviderUri, validRuleSetUri,
- validRules, validProperties);
- assertThat(copy.equals(ruleSet), is(true));
- }
-
-}
Deleted: trunk/dna-repository/src/test/java/org/jboss/dna/repository/util/JndiSessionFactoryTest.java
===================================================================
--- trunk/dna-repository/src/test/java/org/jboss/dna/repository/util/JndiSessionFactoryTest.java 2009-05-21 22:26:25 UTC (rev 922)
+++ trunk/dna-repository/src/test/java/org/jboss/dna/repository/util/JndiSessionFactoryTest.java 2009-05-22 02:15:19 UTC (rev 923)
@@ -1,168 +0,0 @@
-/*
- * JBoss DNA (http://www.jboss.org/dna)
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- * See the AUTHORS.txt file in the distribution for a full listing of
- * individual contributors.
- *
- * JBoss DNA is free software. Unless otherwise indicated, all code in JBoss DNA
- * is licensed to you under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * JBoss DNA is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.dna.repository.util;
-
-import static org.hamcrest.core.Is.is;
-import static org.hamcrest.core.IsNull.notNullValue;
-import static org.hamcrest.core.IsNull.nullValue;
-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 javax.jcr.Repository;
-import javax.jcr.Session;
-import javax.naming.InitialContext;
-import javax.naming.NamingException;
-import org.jboss.dna.common.SystemFailureException;
-import org.jboss.dna.common.jcr.AbstractJcrRepositoryTest;
-import org.jboss.dna.common.naming.MockInitialContext;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-
-/**
- * @author Randall Hauch
- */
-public class JndiSessionFactoryTest extends AbstractJcrRepositoryTest {
-
- public static final String MOCK_REPOSITORY_NAME = "java:jcr/unit/test/repository/1";
- public static final String MOCK_REPOSITORY_NAME_ALT = "java:jcr/unit/test/repository/2";
-
- private JndiSessionFactory factory;
- private Repository mockRepository;
- private Session session;
-
- @Before
- public void beforeEach() throws Exception {
- this.mockRepository = mock(Repository.class);
- MockInitialContext.register(MOCK_REPOSITORY_NAME, this.mockRepository);
- this.factory = new JndiSessionFactory();
- }
-
- @After
- public void afterEach() {
- if (session != null) {
- session.logout();
- }
- MockInitialContext.tearDown();
- }
-
- protected void assertNotRegistered( String name ) {
- try {
- new InitialContext().lookup(name);
- fail("Unexpectedly found registered object");
- } catch (NamingException e) {
- // expected ...
- }
- }
-
- protected void assertRegistered( String name,
- Object obj ) {
- try {
- assertThat(new InitialContext().lookup(name), is(sameInstance(obj)));
- } catch (NamingException e) {
- fail("Failed to find registered object \"" + name + "\"");
- }
- }
-
- @Test
- public void shouldCreateSessionForRegisteredRepository() {
-
- }
-
- @Test( expected = SystemFailureException.class )
- public void shouldThrowSystemFailureWhenUnableToFindRegisteredRepository() throws Exception {
- factory.createSession(MOCK_REPOSITORY_NAME + "something_extra_that_can't_be_found");
- }
-
- @Test
- public void shouldFindWorkspaceInRegisteredName() {
- assertThat(factory.getWorkspaceName("java:jcr/path/to/repository/workspaceName"), is("workspaceName"));
- }
-
- @Test
- public void shouldReturnNullWorkspaceIfRegisteredNameEndsInDelimiter() {
- assertThat(factory.getWorkspaceName("java:jcr/path/to/repository/"), is(nullValue()));
- }
-
- @Test
- public void shouldReturnNullWorkspaceIfRegisteredNameHasNoDelimiter() {
- assertThat(factory.getWorkspaceName("java:jcr"), is(nullValue()));
- }
-
- @Test
- public void shouldFindRepositoryInRegisteredName() {
- assertThat(factory.getRepositoryName("java:jcr/path/to/repository/workspaceName"), is("java:jcr/path/to/repository"));
- }
-
- @Test
- public void shouldConsiderWholeRegisteredNameToBeRepositoryNameIfRegisteredNameEndsInDelimiter() {
- assertThat(factory.getRepositoryName("java:jcr/path/to/repository/"), is("java:jcr/path/to/repository"));
- }
-
- @Test
- public void shouldConsiderWholeRegisteredNameToBeRepositoryNameIfRegisteredNameHasNoDelimiter() {
- assertThat(factory.getRepositoryName("java:jcr"), is("java:jcr"));
- }
-
- @Test
- public void shouldRegisterSuppliedRepositoryInJndi() {
- assertNotRegistered(MOCK_REPOSITORY_NAME_ALT);
- factory.registerRepository(MOCK_REPOSITORY_NAME_ALT, mockRepository);
- assertRegistered(MOCK_REPOSITORY_NAME_ALT, mockRepository);
- }
-
- @Test
- public void shouldUnregisterRepositoryInJndiIfNullRepositoryReference() {
- assertRegistered(MOCK_REPOSITORY_NAME, mockRepository);
- factory.registerRepository(MOCK_REPOSITORY_NAME, null);
- assertNotRegistered(MOCK_REPOSITORY_NAME);
- }
-
- @Test
- public void shouldRemoveAllTrailingDelimitersWhenRegisteringRepository() {
- assertNotRegistered("java:jcr/unit/test/repository");
- factory.registerRepository("java:jcr/unit/test/repository///", mockRepository);
- assertRegistered("java:jcr/unit/test/repository", mockRepository);
- }
-
- @Test
- public void shouldCreateAnonymousSessionInRepositoryIfNoCredentialsAreRegisterd() throws Exception {
- Repository repository = getRepository();
- factory.registerRepository("java:jcr/unit/test/repository/", repository);
- session = factory.createSession("java:jcr/unit/test/repository/default");
- assertThat(session, is(notNullValue()));
- assertThat(session.getUserID(), is("anonymous")); // as defined in the Jackrabbit configuration file
- }
-
- @Test
- public void shouldCreateNonAnonymousSessionInRepositoryIfCredentialsAreRegistered() throws Exception {
- Repository repository = getRepository();
- factory.registerRepository("java:jcr/unit/test/repository/", repository);
- factory.registerCredentials("java:jcr/unit/test/repository/default", "jsmith", "secret".toCharArray());
- session = factory.createSession("java:jcr/unit/test/repository/default");
- assertThat(session, is(notNullValue()));
- assertThat(session.getUserID(), is("jsmith")); // as defined in the Jackrabbit configuration file
- }
-}
Copied: trunk/docs/examples/gettingstarted/sequencers/src/main/java/org/jboss/example/dna/sequencer/JcrTools.java (from rev 922, trunk/dna-repository/src/main/java/org/jboss/dna/repository/util/JcrTools.java)
===================================================================
--- trunk/docs/examples/gettingstarted/sequencers/src/main/java/org/jboss/example/dna/sequencer/JcrTools.java (rev 0)
+++ trunk/docs/examples/gettingstarted/sequencers/src/main/java/org/jboss/example/dna/sequencer/JcrTools.java 2009-05-22 02:15:19 UTC (rev 923)
@@ -0,0 +1,329 @@
+/*
+ * 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.example.dna.sequencer;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.HashMap;
+import java.util.Map;
+import javax.jcr.Node;
+import javax.jcr.NodeIterator;
+import javax.jcr.PathNotFoundException;
+import javax.jcr.Property;
+import javax.jcr.PropertyType;
+import javax.jcr.RepositoryException;
+import javax.jcr.Session;
+import javax.jcr.Value;
+import javax.jcr.ValueFormatException;
+import org.jboss.dna.common.collection.Problem;
+import org.jboss.dna.common.collection.Problems;
+import org.jboss.dna.common.util.IoUtil;
+import org.jboss.dna.common.util.Logger;
+import org.jboss.dna.common.util.StringUtil;
+import org.jboss.dna.repository.RepositoryI18n;
+
+/**
+ * @author Randall Hauch
+ */
+public class JcrTools {
+
+ public Map<String, Object> loadProperties( Node propertyContainer, Problems problems ) {
+ return loadProperties(propertyContainer, null, problems);
+ }
+
+ public Map<String, Object> loadProperties( Node propertyContainer, Map<String, Object> properties, Problems problems ) {
+ if (properties == null) properties = new HashMap<String, Object>();
+ if (propertyContainer != null) {
+ try {
+ NodeIterator iter = propertyContainer.getNodes();
+ while (iter.hasNext()) {
+ Node propertyNode = iter.nextNode();
+ if (propertyNode != null && propertyNode.getPrimaryNodeType().isNodeType("dna:property")) {
+ String propertyName = propertyNode.getName();
+ Object propertyValue = getPropertyValue(propertyNode, "dna:propertyValue", true, problems);
+ properties.put(propertyName, propertyValue);
+ }
+ }
+ } catch (RepositoryException e) {
+ problems.addError(e, RepositoryI18n.errorReadingPropertiesFromContainerNode, getReadable(propertyContainer));
+ }
+ }
+
+ return properties;
+ }
+
+ public boolean removeProblems( Node parent ) throws RepositoryException {
+ Node problemsNode = null;
+ if (parent.hasNode("dna:problems")) {
+ problemsNode = parent.getNode("dna:problems");
+ problemsNode.remove();
+ return true;
+ }
+ return false;
+ }
+
+ public boolean storeProblems( Node parent, Problems problems ) throws RepositoryException {
+ Node problemsNode = null;
+ if (parent.hasNode("dna:problems")) {
+ problemsNode = parent.getNode("dna:problems");
+ // Delete all problems ...
+ removeAllChildren(problemsNode);
+ }
+ if (problems.isEmpty()) {
+ return false;
+ }
+ if (problemsNode == null) {
+ problemsNode = parent.addNode("dna:problems"); // primary type dictated by child definition
+ }
+
+ // Add a child for each problem ...
+ for (Problem problem : problems) {
+ Node problemNode = problemsNode.addNode("problem", "dna:problem");
+ // - dna:status (string) mandatory copy
+ // < 'ERROR', 'WARNING', 'INFO'
+ // - dna:message (string) mandatory copy
+ // - dna:code (string) copy
+ // - dna:type (string) copy
+ // - dna:resource (string) copy
+ // - dna:location (string) copy
+ // - dna:trace (string) copy
+ problemNode.setProperty("dna:status", problem.getStatus().name());
+ problemNode.setProperty("dna:message", problem.getMessageString());
+ if (problem.getCode() != Problem.DEFAULT_CODE) {
+ problemNode.setProperty("dna:code", Integer.toString(problem.getCode()));
+ }
+ String resource = problem.getResource();
+ if (resource != null) {
+ problemNode.setProperty("dna:resource", resource);
+ }
+ String location = problem.getLocation();
+ if (location != null) {
+ problemNode.setProperty("dna:location", location);
+ }
+ Throwable t = problem.getThrowable();
+ if (t != null) {
+ String trace = StringUtil.getStackTrace(t);
+ problemNode.setProperty("dna:trace", trace);
+ }
+ }
+ return true;
+ }
+
+ public int removeAllChildren( Node node ) throws RepositoryException {
+ int childrenRemoved = 0;
+ NodeIterator iter = node.getNodes();
+ while (iter.hasNext()) {
+ Node child = iter.nextNode();
+ child.remove();
+ ++childrenRemoved;
+ }
+ return childrenRemoved;
+ }
+
+ public String getPropertyAsString( Node node, String propertyName, boolean required, Problems problems ) {
+ return getPropertyAsString(node, propertyName, required, null);
+ }
+
+ public String getPropertyAsString( Node node, String propertyName, boolean required, String defaultValue, Problems problems ) {
+ try {
+ Property property = node.getProperty(propertyName);
+ return property.getString();
+ } catch (ValueFormatException e) {
+ if (required) {
+ problems.addError(e, RepositoryI18n.requiredPropertyOnNodeWasExpectedToBeStringValue, propertyName, getReadable(node));
+ } else {
+ problems.addError(e, RepositoryI18n.optionalPropertyOnNodeWasExpectedToBeStringValue, propertyName, getReadable(node));
+ }
+ } catch (PathNotFoundException e) {
+ if (required) {
+ problems.addError(e, RepositoryI18n.requiredPropertyIsMissingFromNode, propertyName, getReadable(node));
+ }
+ if (!required) return defaultValue;
+ } catch (RepositoryException err) {
+ if (required) {
+ problems.addError(err, RepositoryI18n.errorGettingRequiredPropertyFromNode, propertyName, getReadable(node));
+ } else {
+ problems.addError(err, RepositoryI18n.errorGettingOptionalPropertyFromNode, propertyName, getReadable(node));
+ }
+ }
+ return null;
+ }
+
+ public Object getPropertyValue( Node node, String propertyName, boolean required, Problems problems ) {
+ try {
+ Property property = node.getProperty(propertyName);
+ switch (property.getType()) {
+ case PropertyType.BINARY: {
+ InputStream stream = property.getStream();
+ try {
+ stream = property.getStream();
+ return IoUtil.readBytes(stream);
+ } finally {
+ if (stream != null) {
+ try {
+ stream.close();
+ } catch (IOException e) {
+ // Log ...
+ Logger.getLogger(this.getClass()).error(e, RepositoryI18n.errorClosingBinaryStreamForPropertyFromNode, propertyName, node.getPath());
+ }
+ }
+ }
+ }
+ default: {
+ return property.getString();
+ }
+ }
+ } catch (IOException e) {
+ if (required) {
+ problems.addError(e, RepositoryI18n.requiredPropertyOnNodeCouldNotBeRead, propertyName, getReadable(node));
+ } else {
+ problems.addError(e, RepositoryI18n.optionalPropertyOnNodeCouldNotBeRead, propertyName, getReadable(node));
+ }
+ } catch (PathNotFoundException e) {
+ if (required) {
+ problems.addError(e, RepositoryI18n.requiredPropertyIsMissingFromNode, propertyName, getReadable(node));
+ }
+ } catch (RepositoryException err) {
+ if (required) {
+ problems.addError(err, RepositoryI18n.errorGettingRequiredPropertyFromNode, propertyName, getReadable(node));
+ } else {
+ problems.addError(err, RepositoryI18n.errorGettingOptionalPropertyFromNode, propertyName, getReadable(node));
+ }
+ }
+ return null;
+ }
+
+ public String[] getPropertyAsStringArray( Node node, String propertyName, boolean required, Problems problems, String... defaultValues ) {
+ String[] result = defaultValues;
+ try {
+ Property property = node.getProperty(propertyName);
+ if (property.getDefinition().isMultiple()) {
+ Value[] values = property.getValues();
+ result = new String[values.length];
+ int i = 0;
+ for (Value value : values) {
+ result[i++] = value.getString();
+ }
+ } else {
+ result = new String[] {property.getString()};
+ }
+ } catch (ValueFormatException e) {
+ if (required) {
+ problems.addError(e, RepositoryI18n.requiredPropertyOnNodeWasExpectedToBeStringArrayValue, propertyName, getReadable(node));
+ } else {
+ problems.addError(e, RepositoryI18n.optionalPropertyOnNodeWasExpectedToBeStringArrayValue, propertyName, getReadable(node));
+ }
+ } catch (PathNotFoundException e) {
+ if (required) {
+ problems.addError(e, RepositoryI18n.requiredPropertyIsMissingFromNode, propertyName, getReadable(node));
+ }
+ } catch (RepositoryException err) {
+ if (required) {
+ problems.addError(err, RepositoryI18n.errorGettingRequiredPropertyFromNode, propertyName, getReadable(node));
+ } else {
+ problems.addError(err, RepositoryI18n.errorGettingOptionalPropertyFromNode, propertyName, getReadable(node));
+ }
+ }
+ return result;
+ }
+
+ public Node getNode( Node node, String relativePath, boolean required, Problems problems ) {
+ Node result = null;
+ try {
+ result = node.getNode(relativePath);
+ } catch (PathNotFoundException e) {
+ if (required) problems.addError(e, RepositoryI18n.requiredNodeDoesNotExistRelativeToNode, relativePath, getReadable(node));
+ } catch (RepositoryException err) {
+ problems.addError(err, RepositoryI18n.errorGettingNodeRelativeToNode, relativePath, getReadable(node));
+ }
+ return result;
+ }
+
+ public String getReadable( Node node ) {
+ if (node == null) return "";
+ try {
+ return node.getPath();
+ } catch (RepositoryException err) {
+ return node.toString();
+ }
+ }
+
+ public Node findOrCreateNode( Session session, String path ) throws RepositoryException {
+ return findOrCreateNode(session, path, null, null);
+ }
+
+ public Node findOrCreateNode( Session session, String path, String nodeType ) throws RepositoryException {
+ return findOrCreateNode(session, path, nodeType, nodeType);
+ }
+
+ public Node findOrCreateNode( Session session, String path, String defaultNodeType, String finalNodeType ) throws RepositoryException {
+ Node root = session.getRootNode();
+ return findOrCreateNode(session, root, path, defaultNodeType, finalNodeType);
+ }
+
+ public Node findOrCreateNode( Session session, Node parentNode, String path, String defaultNodeType, String finalNodeType ) throws RepositoryException {
+ // Remove leading and trailing slashes ...
+ String relPath = path.replaceAll("^/+", "").replaceAll("/+$", "");
+
+ // Look for the node first ...
+ try {
+ return parentNode.getNode(relPath);
+ } catch (PathNotFoundException e) {
+ // continue
+ }
+ // Create the node, which has to be done segment by segment ...
+ String[] pathSegments = relPath.split("/");
+ Node node = parentNode;
+ for (int i = 0, len = pathSegments.length; i != len; ++i) {
+ String pathSegment = pathSegments[i];
+ pathSegment = pathSegment.trim();
+ if (pathSegment.length() == 0) continue;
+ if (node.hasNode(pathSegment)) {
+ // Find the existing node ...
+ node = node.getNode(pathSegment);
+ } else {
+ // Make sure there is no index on the final segment ...
+ String pathSegmentWithNoIndex = pathSegment.replaceAll("(\\[\\d+\\])+$", "");
+ // Create the node ...
+ String nodeType = defaultNodeType;
+ if (i == len - 1 && finalNodeType != null) nodeType = finalNodeType;
+ if (nodeType != null) {
+ node = node.addNode(pathSegmentWithNoIndex, nodeType);
+ } else {
+ node = node.addNode(pathSegmentWithNoIndex);
+ }
+ }
+ }
+ return node;
+ }
+
+ public Node findOrCreateChild( Session session, Node parent, String name ) throws RepositoryException {
+ return findOrCreateChild(session, parent, name, null);
+ }
+
+ public Node findOrCreateChild( Session session, Node parent, String name, String nodeType ) throws RepositoryException {
+ return findOrCreateNode(session, parent, name, nodeType, nodeType);
+ }
+
+}
Property changes on: trunk/docs/examples/gettingstarted/sequencers/src/main/java/org/jboss/example/dna/sequencer/JcrTools.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Modified: trunk/docs/examples/gettingstarted/sequencers/src/main/java/org/jboss/example/dna/sequencer/SequencingClient.java
===================================================================
--- trunk/docs/examples/gettingstarted/sequencers/src/main/java/org/jboss/example/dna/sequencer/SequencingClient.java 2009-05-21 22:26:25 UTC (rev 922)
+++ trunk/docs/examples/gettingstarted/sequencers/src/main/java/org/jboss/example/dna/sequencer/SequencingClient.java 2009-05-22 02:15:19 UTC (rev 923)
@@ -47,10 +47,9 @@
import org.apache.jackrabbit.api.JackrabbitNodeTypeManager;
import org.apache.jackrabbit.core.TransientRepository;
import org.jboss.dna.common.SystemFailureException;
+import org.jboss.dna.graph.ExecutionContext;
import org.jboss.dna.repository.sequencer.SequencerConfig;
import org.jboss.dna.repository.sequencer.SequencingService;
-import org.jboss.dna.repository.util.JcrExecutionContext;
-import org.jboss.dna.repository.util.JcrTools;
import org.jboss.dna.repository.util.SessionFactory;
import org.jboss.dna.repository.util.SimpleSessionFactory;
@@ -82,7 +81,7 @@
private Repository repository;
private SequencingService sequencingService;
private UserInterface userInterface;
- private JcrExecutionContext executionContext;
+ private ExecutionContext executionContext;
public SequencingClient() {
setJackrabbitConfigPath(DEFAULT_JACKRABBIT_CONFIG_PATH);
@@ -217,7 +216,7 @@
Credentials credentials = new SimpleCredentials(this.username, this.password);
sessionFactory.registerCredentials(repositoryWorkspaceName, credentials);
}
- this.executionContext = new JcrExecutionContext(sessionFactory, repositoryWorkspaceName);
+ this.executionContext = new ExecutionContext();
// Create the sequencing service, passing in the execution context and the repository library ...
this.sequencingService = new SequencingService();
@@ -307,7 +306,7 @@
// Now use the JCR API to upload the file ...
Session session = createSession();
- JcrTools tools = this.executionContext.getTools();
+ JcrTools tools = new JcrTools();
try {
// Create the node at the supplied path ...
Node node = tools.findOrCreateNode(session, nodePath, "nt:folder", "nt:file");
@@ -539,7 +538,7 @@
* @throws RepositoryException
*/
protected Session createSession() throws RepositoryException {
- return this.executionContext.getSessionFactory().createSession(this.repositoryName + "/" + this.workspaceName);
+ throw new UnsupportedOperationException();
}
protected String getMimeType( URL file ) {
Copied: trunk/extensions/dna-classloader-maven/src/test/java/org/jboss/dna/maven/AbstractJcrRepositoryTest.java (from rev 922, trunk/dna-common/src/test/java/org/jboss/dna/common/jcr/AbstractJcrRepositoryTest.java)
===================================================================
--- trunk/extensions/dna-classloader-maven/src/test/java/org/jboss/dna/maven/AbstractJcrRepositoryTest.java (rev 0)
+++ trunk/extensions/dna-classloader-maven/src/test/java/org/jboss/dna/maven/AbstractJcrRepositoryTest.java 2009-05-22 02:15:19 UTC (rev 923)
@@ -0,0 +1,178 @@
+/*
+ * 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.maven;
+
+import java.io.IOException;
+import javax.jcr.Credentials;
+import javax.jcr.Repository;
+import javax.jcr.RepositoryException;
+import javax.jcr.Session;
+import javax.jcr.SimpleCredentials;
+import org.apache.jackrabbit.api.JackrabbitRepository;
+import org.apache.jackrabbit.core.TransientRepository;
+import org.jboss.dna.common.util.FileUtil;
+import org.jboss.dna.common.util.Logger;
+import org.junit.After;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+
+/**
+ * An abstract base class for any unit test class that needs a JCR repository during one or more (but not necessarily all) of its
+ * unit tests.
+ * <p>
+ * Typically, unit test classes need a repository for just some of it's unit tests (other unit tests don't need the repository
+ * because they are just testing other functionality of the class under test), and this class was designed for this scenario. A
+ * unit test method that needs a repository should call {@link #startRepository()}, and then may proceed to use the
+ * {@link #getRepository() repository}. The test method need not call {@link #shutdownRepository()}, as it is called automatically
+ * after every test (and does nothing if the repository was not started in the first place).
+ * </p>
+ * <p>
+ * Some unit test methods may have a need to repeatedly start and stop the repository, and this can be done by calling
+ * {@link #startRepository()} and {@link #shutdownRepository()} as many times as required.
+ * </p>
+ * <p>
+ * Because the {@link TransientRepository transient repository} implementation used by this class automatically cleans itself up
+ * whenever all {@link Session sessions} are closed, this class maintains an open session between the time the repository is
+ * started and stopped. Therefore, unit tests can persist information in one session and see the information in other sessions.
+ * </p>
+ *
+ * @author Randall Hauch
+ */
+public abstract class AbstractJcrRepositoryTest {
+
+ public static final String TESTDATA_PATH = "./src/test/resources/";
+ public static final String JACKRABBIT_DATA_PATH = "./target/testdata/jackrabbittest/";
+ public static final String REPOSITORY_DIRECTORY_PATH = JACKRABBIT_DATA_PATH + "repository";
+ public static final String REPOSITORY_CONFIG_PATH = TESTDATA_PATH + "jackrabbitInMemoryTestRepositoryConfig.xml";
+
+ public static final String WORKSPACE_NAME = "default";
+
+ private static Repository repository;
+
+ @BeforeClass
+ public static void beforeAll() throws Exception {
+ // Clean up the test data ...
+ FileUtil.delete(JACKRABBIT_DATA_PATH);
+
+ // Set up the transient repository (this shouldn't do anything yet)...
+ repository = new TransientRepository(REPOSITORY_CONFIG_PATH, REPOSITORY_DIRECTORY_PATH);
+ }
+
+ @AfterClass
+ public static void afterAll() {
+ if (repository != null) {
+ try {
+ JackrabbitRepository jackrabbit = (JackrabbitRepository)repository;
+ jackrabbit.shutdown();
+ } finally {
+ repository = null;
+ // Clean up the test data ...
+ FileUtil.delete(JACKRABBIT_DATA_PATH);
+ }
+ }
+ }
+
+ /** Used to keep at least one session open during each test; when last session is closed, all data is cleaned up */
+ private Session keepAliveSession;
+
+ protected Credentials simpleCredentials = new SimpleCredentials("jsmith", "secret".toCharArray());
+
+ /**
+ * Call this method during a test that needs the repository. It only needs to be called once during a test, although calling
+ * it more than once does not hurt.
+ * <p>
+ * The repository can be started and {@link #shutdownRepository() shutdown} repeatedly during a single test.
+ * </p>
+ *
+ * @throws RepositoryException if there is a problem starting the repository
+ * @throws IOException if there's a problem reading the repository configuration
+ * @see #shutdownRepository()
+ */
+ public synchronized void startRepository() throws RepositoryException, IOException {
+ if (repository == null) {
+ // Clean up the test data ...
+ FileUtil.delete(JACKRABBIT_DATA_PATH);
+
+ // Set up the transient repository (this shouldn't do anything yet)...
+ repository = new TransientRepository(REPOSITORY_CONFIG_PATH, REPOSITORY_DIRECTORY_PATH);
+
+ }
+ if (keepAliveSession == null) {
+ keepAliveSession = repository.login();
+ }
+ }
+
+ /**
+ * Shutdown the repository. This method is automatically called after every test, and does nothing if the repository has not
+ * yet been started.
+ */
+ @After
+ public synchronized void shutdownRepository() {
+ if (keepAliveSession != null) {
+ try {
+ Logger.getLogger(this.getClass()).debug("Shutting down repository");
+ keepAliveSession.logout();
+ } finally {
+ keepAliveSession = null;
+ if (repository != null) {
+ try {
+ JackrabbitRepository jackrabbit = (JackrabbitRepository)repository;
+ jackrabbit.shutdown();
+ } finally {
+ repository = null;
+ // Clean up the test data ...
+ FileUtil.delete(JACKRABBIT_DATA_PATH);
+ }
+ }
+ }
+ }
+ }
+
+ public boolean isRepositoryStarted() {
+ return this.keepAliveSession != null;
+ }
+
+ /**
+ * Get the repository. This will start the repository if necessary.
+ *
+ * @return repository
+ * @throws RepositoryException if there is a problem obtaining the repository
+ * @throws IOException if the repository has not yet been {@link #startRepository() started} and there's a problem reading the
+ * repository configuration
+ */
+ public Repository getRepository() throws RepositoryException, IOException {
+ startRepository();
+ return repository;
+ }
+
+ /**
+ * Get credentials that can be used to log into the repository.
+ *
+ * @return credentials
+ */
+ public Credentials getTestCredentials() {
+ return this.simpleCredentials;
+ }
+
+}
Property changes on: trunk/extensions/dna-classloader-maven/src/test/java/org/jboss/dna/maven/AbstractJcrRepositoryTest.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Modified: trunk/extensions/dna-classloader-maven/src/test/java/org/jboss/dna/maven/MavenRepositoryTest.java
===================================================================
--- trunk/extensions/dna-classloader-maven/src/test/java/org/jboss/dna/maven/MavenRepositoryTest.java 2009-05-21 22:26:25 UTC (rev 922)
+++ trunk/extensions/dna-classloader-maven/src/test/java/org/jboss/dna/maven/MavenRepositoryTest.java 2009-05-22 02:15:19 UTC (rev 923)
@@ -37,7 +37,6 @@
import java.util.List;
import java.util.Properties;
import javax.jcr.RepositoryException;
-import org.jboss.dna.common.jcr.AbstractJcrRepositoryTest;
import org.jboss.dna.common.util.IoUtil;
import org.jboss.dna.common.util.StringUtil;
import org.jboss.dna.maven.spi.JcrMavenUrlProvider;
@@ -180,7 +179,10 @@
loadTestLibrary("org.jboss.example:ProjectI:1.0", "test/dependency/case1/testProjectI.xml");
}
- protected void setRepositoryContent( MavenId mavenId, ArtifactType artifactType, SignatureType signatureType, InputStream content ) throws Exception {
+ protected void setRepositoryContent( MavenId mavenId,
+ ArtifactType artifactType,
+ SignatureType signatureType,
+ InputStream content ) throws Exception {
// Set the content ...
URL url = this.urlProvider.getUrl(mavenId, artifactType, signatureType, true);
assertThat(url, is(notNullValue()));
@@ -199,7 +201,8 @@
}
- protected void loadTestLibrary( String mavenId, String pathToPomFile ) throws Exception {
+ protected void loadTestLibrary( String mavenId,
+ String pathToPomFile ) throws Exception {
MavenId id = new MavenId(mavenId);
setRepositoryContent(id, ArtifactType.POM, null, this.getClass().getClassLoader().getResourceAsStream(pathToPomFile));
setRepositoryContent(id, ArtifactType.JAR, null, this.getClass().getClassLoader().getResourceAsStream(PATH_TO_EMPTY_JAR));
@@ -231,25 +234,41 @@
@Test
public void shouldReturnValidUrlForMavenIdAndArtifactTypeAndSignatureType() throws Exception {
- assertThat(maven.getUrl(mavenId1, ArtifactType.JAR, null).toString(), is("jcr:/default/org/jboss/dna/dna-maven/1.0-SNAPSHOT/dna-maven-1.0-SNAPSHOT.jar"));
- assertThat(maven.getUrl(mavenId1, ArtifactType.JAR, SignatureType.MD5).toString(), is("jcr:/default/org/jboss/dna/dna-maven/1.0-SNAPSHOT/dna-maven-1.0-SNAPSHOT.jar.md5"));
- assertThat(maven.getUrl(mavenId1, ArtifactType.JAR, SignatureType.PGP).toString(), is("jcr:/default/org/jboss/dna/dna-maven/1.0-SNAPSHOT/dna-maven-1.0-SNAPSHOT.jar.asc"));
- assertThat(maven.getUrl(mavenId1, ArtifactType.JAR, SignatureType.SHA1).toString(), is("jcr:/default/org/jboss/dna/dna-maven/1.0-SNAPSHOT/dna-maven-1.0-SNAPSHOT.jar.sha1"));
+ assertThat(maven.getUrl(mavenId1, ArtifactType.JAR, null).toString(),
+ is("jcr:/default/org/jboss/dna/dna-maven/1.0-SNAPSHOT/dna-maven-1.0-SNAPSHOT.jar"));
+ assertThat(maven.getUrl(mavenId1, ArtifactType.JAR, SignatureType.MD5).toString(),
+ is("jcr:/default/org/jboss/dna/dna-maven/1.0-SNAPSHOT/dna-maven-1.0-SNAPSHOT.jar.md5"));
+ assertThat(maven.getUrl(mavenId1, ArtifactType.JAR, SignatureType.PGP).toString(),
+ is("jcr:/default/org/jboss/dna/dna-maven/1.0-SNAPSHOT/dna-maven-1.0-SNAPSHOT.jar.asc"));
+ assertThat(maven.getUrl(mavenId1, ArtifactType.JAR, SignatureType.SHA1).toString(),
+ is("jcr:/default/org/jboss/dna/dna-maven/1.0-SNAPSHOT/dna-maven-1.0-SNAPSHOT.jar.sha1"));
- assertThat(maven.getUrl(mavenId1, ArtifactType.SOURCE, null).toString(), is("jcr:/default/org/jboss/dna/dna-maven/1.0-SNAPSHOT/dna-maven-1.0-SNAPSHOT-sources.jar"));
- assertThat(maven.getUrl(mavenId1, ArtifactType.SOURCE, SignatureType.MD5).toString(), is("jcr:/default/org/jboss/dna/dna-maven/1.0-SNAPSHOT/dna-maven-1.0-SNAPSHOT-sources.jar.md5"));
- assertThat(maven.getUrl(mavenId1, ArtifactType.SOURCE, SignatureType.PGP).toString(), is("jcr:/default/org/jboss/dna/dna-maven/1.0-SNAPSHOT/dna-maven-1.0-SNAPSHOT-sources.jar.asc"));
- assertThat(maven.getUrl(mavenId1, ArtifactType.SOURCE, SignatureType.SHA1).toString(), is("jcr:/default/org/jboss/dna/dna-maven/1.0-SNAPSHOT/dna-maven-1.0-SNAPSHOT-sources.jar.sha1"));
+ assertThat(maven.getUrl(mavenId1, ArtifactType.SOURCE, null).toString(),
+ is("jcr:/default/org/jboss/dna/dna-maven/1.0-SNAPSHOT/dna-maven-1.0-SNAPSHOT-sources.jar"));
+ assertThat(maven.getUrl(mavenId1, ArtifactType.SOURCE, SignatureType.MD5).toString(),
+ is("jcr:/default/org/jboss/dna/dna-maven/1.0-SNAPSHOT/dna-maven-1.0-SNAPSHOT-sources.jar.md5"));
+ assertThat(maven.getUrl(mavenId1, ArtifactType.SOURCE, SignatureType.PGP).toString(),
+ is("jcr:/default/org/jboss/dna/dna-maven/1.0-SNAPSHOT/dna-maven-1.0-SNAPSHOT-sources.jar.asc"));
+ assertThat(maven.getUrl(mavenId1, ArtifactType.SOURCE, SignatureType.SHA1).toString(),
+ is("jcr:/default/org/jboss/dna/dna-maven/1.0-SNAPSHOT/dna-maven-1.0-SNAPSHOT-sources.jar.sha1"));
- assertThat(maven.getUrl(mavenId1, ArtifactType.POM, null).toString(), is("jcr:/default/org/jboss/dna/dna-maven/1.0-SNAPSHOT/dna-maven-1.0-SNAPSHOT.pom"));
- assertThat(maven.getUrl(mavenId1, ArtifactType.POM, SignatureType.MD5).toString(), is("jcr:/default/org/jboss/dna/dna-maven/1.0-SNAPSHOT/dna-maven-1.0-SNAPSHOT.pom.md5"));
- assertThat(maven.getUrl(mavenId1, ArtifactType.POM, SignatureType.PGP).toString(), is("jcr:/default/org/jboss/dna/dna-maven/1.0-SNAPSHOT/dna-maven-1.0-SNAPSHOT.pom.asc"));
- assertThat(maven.getUrl(mavenId1, ArtifactType.POM, SignatureType.SHA1).toString(), is("jcr:/default/org/jboss/dna/dna-maven/1.0-SNAPSHOT/dna-maven-1.0-SNAPSHOT.pom.sha1"));
+ assertThat(maven.getUrl(mavenId1, ArtifactType.POM, null).toString(),
+ is("jcr:/default/org/jboss/dna/dna-maven/1.0-SNAPSHOT/dna-maven-1.0-SNAPSHOT.pom"));
+ assertThat(maven.getUrl(mavenId1, ArtifactType.POM, SignatureType.MD5).toString(),
+ is("jcr:/default/org/jboss/dna/dna-maven/1.0-SNAPSHOT/dna-maven-1.0-SNAPSHOT.pom.md5"));
+ assertThat(maven.getUrl(mavenId1, ArtifactType.POM, SignatureType.PGP).toString(),
+ is("jcr:/default/org/jboss/dna/dna-maven/1.0-SNAPSHOT/dna-maven-1.0-SNAPSHOT.pom.asc"));
+ assertThat(maven.getUrl(mavenId1, ArtifactType.POM, SignatureType.SHA1).toString(),
+ is("jcr:/default/org/jboss/dna/dna-maven/1.0-SNAPSHOT/dna-maven-1.0-SNAPSHOT.pom.sha1"));
- assertThat(maven.getUrl(mavenId1, ArtifactType.METADATA, null).toString(), is("jcr:/default/org/jboss/dna/dna-maven/maven-metadata.xml"));
- assertThat(maven.getUrl(mavenId1, ArtifactType.METADATA, SignatureType.MD5).toString(), is("jcr:/default/org/jboss/dna/dna-maven/maven-metadata.xml.md5"));
- assertThat(maven.getUrl(mavenId1, ArtifactType.METADATA, SignatureType.PGP).toString(), is("jcr:/default/org/jboss/dna/dna-maven/maven-metadata.xml.asc"));
- assertThat(maven.getUrl(mavenId1, ArtifactType.METADATA, SignatureType.SHA1).toString(), is("jcr:/default/org/jboss/dna/dna-maven/maven-metadata.xml.sha1"));
+ assertThat(maven.getUrl(mavenId1, ArtifactType.METADATA, null).toString(),
+ is("jcr:/default/org/jboss/dna/dna-maven/maven-metadata.xml"));
+ assertThat(maven.getUrl(mavenId1, ArtifactType.METADATA, SignatureType.MD5).toString(),
+ is("jcr:/default/org/jboss/dna/dna-maven/maven-metadata.xml.md5"));
+ assertThat(maven.getUrl(mavenId1, ArtifactType.METADATA, SignatureType.PGP).toString(),
+ is("jcr:/default/org/jboss/dna/dna-maven/maven-metadata.xml.asc"));
+ assertThat(maven.getUrl(mavenId1, ArtifactType.METADATA, SignatureType.SHA1).toString(),
+ is("jcr:/default/org/jboss/dna/dna-maven/maven-metadata.xml.sha1"));
}
@Test
@@ -422,8 +441,10 @@
checkClasspath(new MavenId[] {projectE}, new MavenId[] {projectE, projectD, projectA, projectB});
checkClasspath(new MavenId[] {projectF}, new MavenId[] {projectF, projectE, projectC, projectD, projectA, projectB});
checkClasspath(new MavenId[] {projectG}, new MavenId[] {projectG, projectC, projectE, projectD, projectA});
- checkClasspath(new MavenId[] {projectH}, new MavenId[] {projectH, projectG, projectB, projectC, projectE, projectD, projectA});
- checkClasspath(new MavenId[] {projectI}, new MavenId[] {projectI, projectH, projectF, projectG, projectB, projectC, projectE, projectD, projectA});
+ checkClasspath(new MavenId[] {projectH}, new MavenId[] {projectH, projectG, projectB, projectC, projectE, projectD,
+ projectA});
+ checkClasspath(new MavenId[] {projectI}, new MavenId[] {projectI, projectH, projectF, projectG, projectB, projectC,
+ projectE, projectD, projectA});
}
@Test
@@ -439,7 +460,8 @@
checkClasspath(new MavenId[] {projectG}, new MavenId[] {projectG, projectC, projectE, projectD, projectA, projectB});
}
- protected void checkClasspath( MavenId[] projectIds, MavenId[] classpathProjects ) {
+ protected void checkClasspath( MavenId[] projectIds,
+ MavenId[] classpathProjects ) {
List<MavenId> idsExpectedOnClasspath = new ArrayList<MavenId>();
for (int i = 0; i != classpathProjects.length; ++i) {
idsExpectedOnClasspath.add(classpathProjects[i]);
Copied: trunk/extensions/dna-classloader-maven/src/test/java/org/jboss/dna/maven/TestAbstractJcrRepositoryTest.java (from rev 922, trunk/dna-common/src/test/java/org/jboss/dna/common/jcr/TestAbstractJcrRepositoryTest.java)
===================================================================
--- trunk/extensions/dna-classloader-maven/src/test/java/org/jboss/dna/maven/TestAbstractJcrRepositoryTest.java (rev 0)
+++ trunk/extensions/dna-classloader-maven/src/test/java/org/jboss/dna/maven/TestAbstractJcrRepositoryTest.java 2009-05-22 02:15:19 UTC (rev 923)
@@ -0,0 +1,89 @@
+/*
+ * 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.maven;
+
+import static org.hamcrest.core.Is.is;
+import static org.hamcrest.core.IsNull.notNullValue;
+import static org.junit.Assert.assertThat;
+import javax.jcr.Node;
+import javax.jcr.Session;
+import org.junit.Test;
+
+/**
+ * @author Randall Hauch
+ */
+public class TestAbstractJcrRepositoryTest extends AbstractJcrRepositoryTest {
+
+ @Test
+ public void shouldBeAbleToStartAndShutdownRepository() throws Exception {
+ for (int i = 0; i != 3; ++i) {
+ startRepository();
+ Session session = getRepository().login(getTestCredentials());
+ assertThat(session, is(notNullValue()));
+ assertThat(session.getRootNode(), is(notNullValue()));
+ // Create a child node ...
+ Node node = session.getRootNode().addNode("testnode", "nt:unstructured");
+ assertThat(node, is(notNullValue()));
+ assertThat(node.getName(), is("testnode"));
+ assertThat(node.getPath(), is("/testnode"));
+ // Save and close the session ...
+ session.save();
+ session.logout();
+ shutdownRepository();
+ }
+ }
+
+ @Test
+ public void shouldAllowDataPersistedInOneSessionBeAccessibleInOtherSessions() throws Exception {
+ startRepository();
+ Session session = getRepository().login(getTestCredentials());
+ assertThat(session, is(notNullValue()));
+ assertThat(session.getRootNode(), is(notNullValue()));
+ // Create a child node ...
+ Node node = session.getRootNode().addNode("testnode", "nt:unstructured");
+ assertThat(node, is(notNullValue()));
+ assertThat(node.getName(), is("testnode"));
+ assertThat(node.getPath(), is("/testnode"));
+ // Save and close the session ...
+ session.save();
+ session.logout();
+
+ for (int i = 0; i != 3; ++i) {
+ // Create another session ...
+ session = getRepository().login(getTestCredentials());
+ assertThat(session, is(notNullValue()));
+ assertThat(session.getRootNode(), is(notNullValue()));
+ // Look for the child node ...
+ node = session.getRootNode().getNode("testnode");
+ assertThat(node, is(notNullValue()));
+ assertThat(node.getName(), is("testnode"));
+ assertThat(node.getPath(), is("/testnode"));
+ // Close the session ...
+ session.logout();
+ }
+
+ }
+
+}
Property changes on: trunk/extensions/dna-classloader-maven/src/test/java/org/jboss/dna/maven/TestAbstractJcrRepositoryTest.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Modified: trunk/extensions/dna-classloader-maven/src/test/java/org/jboss/dna/maven/spi/JcrMavenUrlProviderTest.java
===================================================================
--- trunk/extensions/dna-classloader-maven/src/test/java/org/jboss/dna/maven/spi/JcrMavenUrlProviderTest.java 2009-05-21 22:26:25 UTC (rev 922)
+++ trunk/extensions/dna-classloader-maven/src/test/java/org/jboss/dna/maven/spi/JcrMavenUrlProviderTest.java 2009-05-22 02:15:19 UTC (rev 923)
@@ -34,8 +34,8 @@
import java.net.URLConnection;
import java.util.Properties;
import javax.jcr.SimpleCredentials;
-import org.jboss.dna.common.jcr.AbstractJcrRepositoryTest;
import org.jboss.dna.common.util.StringUtil;
+import org.jboss.dna.maven.AbstractJcrRepositoryTest;
import org.jboss.dna.maven.ArtifactType;
import org.jboss.dna.maven.MavenId;
import org.jboss.dna.maven.SignatureType;
@@ -124,25 +124,40 @@
@Test
public void shouldDetermineProperPathGivenMavenIdAndArtifactType() {
- assertThat(provider.getUrlPath(mavenId1, ArtifactType.JAR, null), is("/org/jboss/dna/dna-maven/1.0-SNAPSHOT/dna-maven-1.0-SNAPSHOT.jar"));
- assertThat(provider.getUrlPath(mavenId1, ArtifactType.JAR, SignatureType.MD5), is("/org/jboss/dna/dna-maven/1.0-SNAPSHOT/dna-maven-1.0-SNAPSHOT.jar.md5"));
- assertThat(provider.getUrlPath(mavenId1, ArtifactType.JAR, SignatureType.PGP), is("/org/jboss/dna/dna-maven/1.0-SNAPSHOT/dna-maven-1.0-SNAPSHOT.jar.asc"));
- assertThat(provider.getUrlPath(mavenId1, ArtifactType.JAR, SignatureType.SHA1), is("/org/jboss/dna/dna-maven/1.0-SNAPSHOT/dna-maven-1.0-SNAPSHOT.jar.sha1"));
+ assertThat(provider.getUrlPath(mavenId1, ArtifactType.JAR, null),
+ is("/org/jboss/dna/dna-maven/1.0-SNAPSHOT/dna-maven-1.0-SNAPSHOT.jar"));
+ assertThat(provider.getUrlPath(mavenId1, ArtifactType.JAR, SignatureType.MD5),
+ is("/org/jboss/dna/dna-maven/1.0-SNAPSHOT/dna-maven-1.0-SNAPSHOT.jar.md5"));
+ assertThat(provider.getUrlPath(mavenId1, ArtifactType.JAR, SignatureType.PGP),
+ is("/org/jboss/dna/dna-maven/1.0-SNAPSHOT/dna-maven-1.0-SNAPSHOT.jar.asc"));
+ assertThat(provider.getUrlPath(mavenId1, ArtifactType.JAR, SignatureType.SHA1),
+ is("/org/jboss/dna/dna-maven/1.0-SNAPSHOT/dna-maven-1.0-SNAPSHOT.jar.sha1"));
- assertThat(provider.getUrlPath(mavenId1, ArtifactType.SOURCE, null), is("/org/jboss/dna/dna-maven/1.0-SNAPSHOT/dna-maven-1.0-SNAPSHOT-sources.jar"));
- assertThat(provider.getUrlPath(mavenId1, ArtifactType.SOURCE, SignatureType.MD5), is("/org/jboss/dna/dna-maven/1.0-SNAPSHOT/dna-maven-1.0-SNAPSHOT-sources.jar.md5"));
- assertThat(provider.getUrlPath(mavenId1, ArtifactType.SOURCE, SignatureType.PGP), is("/org/jboss/dna/dna-maven/1.0-SNAPSHOT/dna-maven-1.0-SNAPSHOT-sources.jar.asc"));
- assertThat(provider.getUrlPath(mavenId1, ArtifactType.SOURCE, SignatureType.SHA1), is("/org/jboss/dna/dna-maven/1.0-SNAPSHOT/dna-maven-1.0-SNAPSHOT-sources.jar.sha1"));
+ assertThat(provider.getUrlPath(mavenId1, ArtifactType.SOURCE, null),
+ is("/org/jboss/dna/dna-maven/1.0-SNAPSHOT/dna-maven-1.0-SNAPSHOT-sources.jar"));
+ assertThat(provider.getUrlPath(mavenId1, ArtifactType.SOURCE, SignatureType.MD5),
+ is("/org/jboss/dna/dna-maven/1.0-SNAPSHOT/dna-maven-1.0-SNAPSHOT-sources.jar.md5"));
+ assertThat(provider.getUrlPath(mavenId1, ArtifactType.SOURCE, SignatureType.PGP),
+ is("/org/jboss/dna/dna-maven/1.0-SNAPSHOT/dna-maven-1.0-SNAPSHOT-sources.jar.asc"));
+ assertThat(provider.getUrlPath(mavenId1, ArtifactType.SOURCE, SignatureType.SHA1),
+ is("/org/jboss/dna/dna-maven/1.0-SNAPSHOT/dna-maven-1.0-SNAPSHOT-sources.jar.sha1"));
- assertThat(provider.getUrlPath(mavenId1, ArtifactType.POM, null), is("/org/jboss/dna/dna-maven/1.0-SNAPSHOT/dna-maven-1.0-SNAPSHOT.pom"));
- assertThat(provider.getUrlPath(mavenId1, ArtifactType.POM, SignatureType.MD5), is("/org/jboss/dna/dna-maven/1.0-SNAPSHOT/dna-maven-1.0-SNAPSHOT.pom.md5"));
- assertThat(provider.getUrlPath(mavenId1, ArtifactType.POM, SignatureType.PGP), is("/org/jboss/dna/dna-maven/1.0-SNAPSHOT/dna-maven-1.0-SNAPSHOT.pom.asc"));
- assertThat(provider.getUrlPath(mavenId1, ArtifactType.POM, SignatureType.SHA1), is("/org/jboss/dna/dna-maven/1.0-SNAPSHOT/dna-maven-1.0-SNAPSHOT.pom.sha1"));
+ assertThat(provider.getUrlPath(mavenId1, ArtifactType.POM, null),
+ is("/org/jboss/dna/dna-maven/1.0-SNAPSHOT/dna-maven-1.0-SNAPSHOT.pom"));
+ assertThat(provider.getUrlPath(mavenId1, ArtifactType.POM, SignatureType.MD5),
+ is("/org/jboss/dna/dna-maven/1.0-SNAPSHOT/dna-maven-1.0-SNAPSHOT.pom.md5"));
+ assertThat(provider.getUrlPath(mavenId1, ArtifactType.POM, SignatureType.PGP),
+ is("/org/jboss/dna/dna-maven/1.0-SNAPSHOT/dna-maven-1.0-SNAPSHOT.pom.asc"));
+ assertThat(provider.getUrlPath(mavenId1, ArtifactType.POM, SignatureType.SHA1),
+ is("/org/jboss/dna/dna-maven/1.0-SNAPSHOT/dna-maven-1.0-SNAPSHOT.pom.sha1"));
assertThat(provider.getUrlPath(mavenId1, ArtifactType.METADATA, null), is("/org/jboss/dna/dna-maven/maven-metadata.xml"));
- assertThat(provider.getUrlPath(mavenId1, ArtifactType.METADATA, SignatureType.MD5), is("/org/jboss/dna/dna-maven/maven-metadata.xml.md5"));
- assertThat(provider.getUrlPath(mavenId1, ArtifactType.METADATA, SignatureType.PGP), is("/org/jboss/dna/dna-maven/maven-metadata.xml.asc"));
- assertThat(provider.getUrlPath(mavenId1, ArtifactType.METADATA, SignatureType.SHA1), is("/org/jboss/dna/dna-maven/maven-metadata.xml.sha1"));
+ assertThat(provider.getUrlPath(mavenId1, ArtifactType.METADATA, SignatureType.MD5),
+ is("/org/jboss/dna/dna-maven/maven-metadata.xml.md5"));
+ assertThat(provider.getUrlPath(mavenId1, ArtifactType.METADATA, SignatureType.PGP),
+ is("/org/jboss/dna/dna-maven/maven-metadata.xml.asc"));
+ assertThat(provider.getUrlPath(mavenId1, ArtifactType.METADATA, SignatureType.SHA1),
+ is("/org/jboss/dna/dna-maven/maven-metadata.xml.sha1"));
}
@Test
@@ -152,25 +167,41 @@
@Test
public void shouldReturnValidUrlForMavenIdAndArtifactTypeAndSignatureType() throws Exception {
- assertThat(provider.getUrl(mavenId1, ArtifactType.JAR, null, false).toString(), is("jcr://org/jboss/dna/dna-maven/1.0-SNAPSHOT/dna-maven-1.0-SNAPSHOT.jar"));
- assertThat(provider.getUrl(mavenId1, ArtifactType.JAR, SignatureType.MD5, false).toString(), is("jcr://org/jboss/dna/dna-maven/1.0-SNAPSHOT/dna-maven-1.0-SNAPSHOT.jar.md5"));
- assertThat(provider.getUrl(mavenId1, ArtifactType.JAR, SignatureType.PGP, false).toString(), is("jcr://org/jboss/dna/dna-maven/1.0-SNAPSHOT/dna-maven-1.0-SNAPSHOT.jar.asc"));
- assertThat(provider.getUrl(mavenId1, ArtifactType.JAR, SignatureType.SHA1, false).toString(), is("jcr://org/jboss/dna/dna-maven/1.0-SNAPSHOT/dna-maven-1.0-SNAPSHOT.jar.sha1"));
+ assertThat(provider.getUrl(mavenId1, ArtifactType.JAR, null, false).toString(),
+ is("jcr://org/jboss/dna/dna-maven/1.0-SNAPSHOT/dna-maven-1.0-SNAPSHOT.jar"));
+ assertThat(provider.getUrl(mavenId1, ArtifactType.JAR, SignatureType.MD5, false).toString(),
+ is("jcr://org/jboss/dna/dna-maven/1.0-SNAPSHOT/dna-maven-1.0-SNAPSHOT.jar.md5"));
+ assertThat(provider.getUrl(mavenId1, ArtifactType.JAR, SignatureType.PGP, false).toString(),
+ is("jcr://org/jboss/dna/dna-maven/1.0-SNAPSHOT/dna-maven-1.0-SNAPSHOT.jar.asc"));
+ assertThat(provider.getUrl(mavenId1, ArtifactType.JAR, SignatureType.SHA1, false).toString(),
+ is("jcr://org/jboss/dna/dna-maven/1.0-SNAPSHOT/dna-maven-1.0-SNAPSHOT.jar.sha1"));
- assertThat(provider.getUrl(mavenId1, ArtifactType.SOURCE, null, false).toString(), is("jcr://org/jboss/dna/dna-maven/1.0-SNAPSHOT/dna-maven-1.0-SNAPSHOT-sources.jar"));
- assertThat(provider.getUrl(mavenId1, ArtifactType.SOURCE, SignatureType.MD5, false).toString(), is("jcr://org/jboss/dna/dna-maven/1.0-SNAPSHOT/dna-maven-1.0-SNAPSHOT-sources.jar.md5"));
- assertThat(provider.getUrl(mavenId1, ArtifactType.SOURCE, SignatureType.PGP, false).toString(), is("jcr://org/jboss/dna/dna-maven/1.0-SNAPSHOT/dna-maven-1.0-SNAPSHOT-sources.jar.asc"));
- assertThat(provider.getUrl(mavenId1, ArtifactType.SOURCE, SignatureType.SHA1, false).toString(), is("jcr://org/jboss/dna/dna-maven/1.0-SNAPSHOT/dna-maven-1.0-SNAPSHOT-sources.jar.sha1"));
+ assertThat(provider.getUrl(mavenId1, ArtifactType.SOURCE, null, false).toString(),
+ is("jcr://org/jboss/dna/dna-maven/1.0-SNAPSHOT/dna-maven-1.0-SNAPSHOT-sources.jar"));
+ assertThat(provider.getUrl(mavenId1, ArtifactType.SOURCE, SignatureType.MD5, false).toString(),
+ is("jcr://org/jboss/dna/dna-maven/1.0-SNAPSHOT/dna-maven-1.0-SNAPSHOT-sources.jar.md5"));
+ assertThat(provider.getUrl(mavenId1, ArtifactType.SOURCE, SignatureType.PGP, false).toString(),
+ is("jcr://org/jboss/dna/dna-maven/1.0-SNAPSHOT/dna-maven-1.0-SNAPSHOT-sources.jar.asc"));
+ assertThat(provider.getUrl(mavenId1, ArtifactType.SOURCE, SignatureType.SHA1, false).toString(),
+ is("jcr://org/jboss/dna/dna-maven/1.0-SNAPSHOT/dna-maven-1.0-SNAPSHOT-sources.jar.sha1"));
- assertThat(provider.getUrl(mavenId1, ArtifactType.POM, null, false).toString(), is("jcr://org/jboss/dna/dna-maven/1.0-SNAPSHOT/dna-maven-1.0-SNAPSHOT.pom"));
- assertThat(provider.getUrl(mavenId1, ArtifactType.POM, SignatureType.MD5, false).toString(), is("jcr://org/jboss/dna/dna-maven/1.0-SNAPSHOT/dna-maven-1.0-SNAPSHOT.pom.md5"));
- assertThat(provider.getUrl(mavenId1, ArtifactType.POM, SignatureType.PGP, false).toString(), is("jcr://org/jboss/dna/dna-maven/1.0-SNAPSHOT/dna-maven-1.0-SNAPSHOT.pom.asc"));
- assertThat(provider.getUrl(mavenId1, ArtifactType.POM, SignatureType.SHA1, false).toString(), is("jcr://org/jboss/dna/dna-maven/1.0-SNAPSHOT/dna-maven-1.0-SNAPSHOT.pom.sha1"));
+ assertThat(provider.getUrl(mavenId1, ArtifactType.POM, null, false).toString(),
+ is("jcr://org/jboss/dna/dna-maven/1.0-SNAPSHOT/dna-maven-1.0-SNAPSHOT.pom"));
+ assertThat(provider.getUrl(mavenId1, ArtifactType.POM, SignatureType.MD5, false).toString(),
+ is("jcr://org/jboss/dna/dna-maven/1.0-SNAPSHOT/dna-maven-1.0-SNAPSHOT.pom.md5"));
+ assertThat(provider.getUrl(mavenId1, ArtifactType.POM, SignatureType.PGP, false).toString(),
+ is("jcr://org/jboss/dna/dna-maven/1.0-SNAPSHOT/dna-maven-1.0-SNAPSHOT.pom.asc"));
+ assertThat(provider.getUrl(mavenId1, ArtifactType.POM, SignatureType.SHA1, false).toString(),
+ is("jcr://org/jboss/dna/dna-maven/1.0-SNAPSHOT/dna-maven-1.0-SNAPSHOT.pom.sha1"));
- assertThat(provider.getUrl(mavenId1, ArtifactType.METADATA, null, false).toString(), is("jcr://org/jboss/dna/dna-maven/maven-metadata.xml"));
- assertThat(provider.getUrl(mavenId1, ArtifactType.METADATA, SignatureType.MD5, false).toString(), is("jcr://org/jboss/dna/dna-maven/maven-metadata.xml.md5"));
- assertThat(provider.getUrl(mavenId1, ArtifactType.METADATA, SignatureType.PGP, false).toString(), is("jcr://org/jboss/dna/dna-maven/maven-metadata.xml.asc"));
- assertThat(provider.getUrl(mavenId1, ArtifactType.METADATA, SignatureType.SHA1, false).toString(), is("jcr://org/jboss/dna/dna-maven/maven-metadata.xml.sha1"));
+ assertThat(provider.getUrl(mavenId1, ArtifactType.METADATA, null, false).toString(),
+ is("jcr://org/jboss/dna/dna-maven/maven-metadata.xml"));
+ assertThat(provider.getUrl(mavenId1, ArtifactType.METADATA, SignatureType.MD5, false).toString(),
+ is("jcr://org/jboss/dna/dna-maven/maven-metadata.xml.md5"));
+ assertThat(provider.getUrl(mavenId1, ArtifactType.METADATA, SignatureType.PGP, false).toString(),
+ is("jcr://org/jboss/dna/dna-maven/maven-metadata.xml.asc"));
+ assertThat(provider.getUrl(mavenId1, ArtifactType.METADATA, SignatureType.SHA1, false).toString(),
+ is("jcr://org/jboss/dna/dna-maven/maven-metadata.xml.sha1"));
}
@Test
15 years, 1 month
DNA SVN: r922 - in trunk: dna-graph/src/main/java/org/jboss/dna/graph/request and 8 other directories.
by dna-commits@lists.jboss.org
Author: rhauch
Date: 2009-05-21 18:26:25 -0400 (Thu, 21 May 2009)
New Revision: 922
Added:
trunk/dna-graph/src/main/java/org/jboss/dna/graph/observe/NetChangeObserver.java
Modified:
trunk/dna-graph/src/main/java/org/jboss/dna/graph/request/ChangeRequest.java
trunk/dna-graph/src/main/java/org/jboss/dna/graph/request/CloneWorkspaceRequest.java
trunk/dna-graph/src/main/java/org/jboss/dna/graph/request/CopyBranchRequest.java
trunk/dna-graph/src/main/java/org/jboss/dna/graph/request/CreateNodeRequest.java
trunk/dna-graph/src/main/java/org/jboss/dna/graph/request/CreateWorkspaceRequest.java
trunk/dna-graph/src/main/java/org/jboss/dna/graph/request/DeleteBranchRequest.java
trunk/dna-graph/src/main/java/org/jboss/dna/graph/request/DeleteChildrenRequest.java
trunk/dna-graph/src/main/java/org/jboss/dna/graph/request/DestroyWorkspaceRequest.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/RemovePropertyRequest.java
trunk/dna-graph/src/main/java/org/jboss/dna/graph/request/RenameNodeRequest.java
trunk/dna-graph/src/main/java/org/jboss/dna/graph/request/SetPropertyRequest.java
trunk/dna-graph/src/main/java/org/jboss/dna/graph/request/UpdatePropertiesRequest.java
trunk/dna-graph/src/main/java/org/jboss/dna/graph/request/processor/RequestProcessor.java
trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/SessionCache.java
trunk/dna-repository/src/main/java/org/jboss/dna/repository/sequencer/Sequencer.java
trunk/dna-repository/src/main/java/org/jboss/dna/repository/sequencer/SequencingService.java
trunk/dna-repository/src/main/java/org/jboss/dna/repository/sequencer/StreamSequencerAdapter.java
trunk/dna-repository/src/test/java/org/jboss/dna/repository/DnaEngineTest.java
trunk/dna-repository/src/test/java/org/jboss/dna/repository/sequencer/MockSequencerA.java
trunk/dna-repository/src/test/java/org/jboss/dna/repository/sequencer/MockSequencerB.java
trunk/dna-repository/src/test/java/org/jboss/dna/repository/sequencer/SequencingServiceTest.java
trunk/dna-repository/src/test/java/org/jboss/dna/repository/sequencer/StreamSequencerAdapterTest.java
trunk/docs/examples/gettingstarted/sequencers/pom.xml
trunk/docs/examples/gettingstarted/sequencers/src/main/java/org/jboss/example/dna/sequencer/SequencingClient.java
trunk/docs/examples/gettingstarted/sequencers/src/test/java/org/jboss/example/dna/sequencer/SequencingClientTest.java
Log:
DNA-404 Remove ObservationService, migrate usage to observe RepositoryLibrary
Changed the SequencingService to use the new observation framework (by adding an observer to the RepositoryLibrary). This required an observer that computed the net change for a set of change requests, so the NetChangeObserver was added to the observation framework as an abstract subclass of ChangeObserver. Changed the test cases accordingly, eliminating any test that was only testing the old ObservationService behavior.
The old ObservationService framework will be removed in the next commit.
Added: trunk/dna-graph/src/main/java/org/jboss/dna/graph/observe/NetChangeObserver.java
===================================================================
--- trunk/dna-graph/src/main/java/org/jboss/dna/graph/observe/NetChangeObserver.java (rev 0)
+++ trunk/dna-graph/src/main/java/org/jboss/dna/graph/observe/NetChangeObserver.java 2009-05-21 22:26:25 UTC (rev 922)
@@ -0,0 +1,354 @@
+/*
+ * 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.observe;
+
+import java.util.Collections;
+import java.util.EnumSet;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+import java.util.TreeMap;
+import net.jcip.annotations.Immutable;
+import net.jcip.annotations.NotThreadSafe;
+import org.jboss.dna.common.util.HashCode;
+import org.jboss.dna.graph.Location;
+import org.jboss.dna.graph.property.Name;
+import org.jboss.dna.graph.property.Path;
+import org.jboss.dna.graph.property.Property;
+import org.jboss.dna.graph.request.ChangeRequest;
+import org.jboss.dna.graph.request.CreateNodeRequest;
+import org.jboss.dna.graph.request.DeleteBranchRequest;
+import org.jboss.dna.graph.request.DeleteChildrenRequest;
+import org.jboss.dna.graph.request.RemovePropertyRequest;
+import org.jboss.dna.graph.request.SetPropertyRequest;
+import org.jboss.dna.graph.request.UpdatePropertiesRequest;
+
+/**
+ * A specialized {@link Observer} that figures out the net changes made during a single {@link Changes set of changes}. For
+ * example, if a property is updated and then updated again, the net change will be a single change. Or, if a node is created and
+ * then deleted, no net change will be observed.
+ */
+public abstract class NetChangeObserver extends ChangeObserver {
+
+ public enum ChangeType {
+ NODE_ADDED,
+ NODE_REMOVED,
+ PROPERTY_ADDED,
+ PROPERTY_REMOVED,
+ PROPERTY_CHANGED;
+ }
+
+ protected NetChangeObserver() {
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.jboss.dna.graph.observe.ChangeObserver#notify(org.jboss.dna.graph.observe.Changes)
+ */
+ @Override
+ public void notify( Changes changes ) {
+ Map<String, Map<Location, NetChangeDetails>> detailsByLocationByWorkspace = new HashMap<String, Map<Location, NetChangeDetails>>();
+ // Process each of the events, extracting the node path and property details for each ...
+ for (ChangeRequest change : changes) {
+ Location location = change.changedLocation();
+ String workspace = change.changedWorkspace();
+
+ // Find the NetChangeDetails for this node ...
+ Map<Location, NetChangeDetails> detailsByLocation = detailsByLocationByWorkspace.get(workspace);
+ NetChangeDetails details = null;
+ if (detailsByLocation == null) {
+ detailsByLocation = new TreeMap<Location, NetChangeDetails>();
+ detailsByLocationByWorkspace.put(workspace, detailsByLocation);
+ details = new NetChangeDetails();
+ detailsByLocation.put(location, details);
+ } else {
+ details = detailsByLocation.get(location);
+ if (details == null) {
+ details = new NetChangeDetails();
+ detailsByLocation.put(location, details);
+ }
+ }
+
+ // Process the specific kind of change ...
+ if (change instanceof CreateNodeRequest) {
+ CreateNodeRequest create = (CreateNodeRequest)change;
+ details.addEventType(ChangeType.NODE_ADDED);
+ for (Property property : create) {
+ details.addProperty(property);
+ }
+ } else if (change instanceof UpdatePropertiesRequest) {
+ UpdatePropertiesRequest update = (UpdatePropertiesRequest)change;
+ for (Map.Entry<Name, Property> entry : update.properties().entrySet()) {
+ Property property = entry.getValue();
+ if (property != null) {
+ details.changeProperty(property);
+ } else {
+ details.removeProperty(entry.getKey());
+ }
+ }
+ } else if (change instanceof SetPropertyRequest) {
+ SetPropertyRequest set = (SetPropertyRequest)change;
+ details.changeProperty(set.property());
+ } else if (change instanceof RemovePropertyRequest) {
+ RemovePropertyRequest remove = (RemovePropertyRequest)change;
+ details.removeProperty(remove.propertyName());
+ } else if (change instanceof DeleteBranchRequest) {
+ details.addEventType(ChangeType.NODE_REMOVED);
+ } else if (change instanceof DeleteChildrenRequest) {
+ DeleteChildrenRequest delete = (DeleteChildrenRequest)change;
+ for (Location deletedChild : delete.getActualChildrenDeleted()) {
+ NetChangeDetails childDetails = detailsByLocation.get(location);
+ if (childDetails == null) {
+ childDetails = new NetChangeDetails();
+ detailsByLocation.put(deletedChild, childDetails);
+ }
+ childDetails.addEventType(ChangeType.NODE_REMOVED);
+ }
+ }
+ }
+
+ // Walk through the net changes ...
+ String sourceName = changes.getSourceName();
+ for (Map.Entry<String, Map<Location, NetChangeDetails>> byWorkspaceEntry : detailsByLocationByWorkspace.entrySet()) {
+ String workspaceName = byWorkspaceEntry.getKey();
+ // Iterate over the entries. Since we've used a TreeSet, we'll get these with the lower paths first ...
+ for (Map.Entry<Location, NetChangeDetails> entry : byWorkspaceEntry.getValue().entrySet()) {
+ Location location = entry.getKey();
+ NetChangeDetails details = entry.getValue();
+ notify(new NetChange(sourceName, workspaceName, location, details.getEventTypes(),
+ details.getModifiedProperties(), details.getRemovedProperties()));
+ }
+ }
+ }
+
+ /**
+ * Method that is called for each net change.
+ *
+ * @param change
+ */
+ protected abstract void notify( NetChange change );
+
+ /**
+ * A notification of changes to a node.
+ */
+ @Immutable
+ public static class NetChange {
+
+ private final String sourceName;
+ private final String workspaceName;
+ private final Location location;
+ private final EnumSet<ChangeType> eventTypes;
+ private final Set<Property> modifiedProperties;
+ private final Set<Name> removedProperties;
+ private final int hc;
+
+ public NetChange( String sourceName,
+ String workspaceName,
+ Location location,
+ EnumSet<ChangeType> eventTypes,
+ Set<Property> modifiedProperties,
+ Set<Name> removedProperties ) {
+ assert sourceName != null;
+ assert workspaceName != null;
+ assert location != null;
+ this.sourceName = sourceName;
+ this.workspaceName = workspaceName;
+ this.location = location;
+ this.hc = HashCode.compute(this.workspaceName, this.location);
+ this.eventTypes = eventTypes;
+ if (modifiedProperties == null) modifiedProperties = Collections.emptySet();
+ if (removedProperties == null) removedProperties = Collections.emptySet();
+ this.modifiedProperties = Collections.unmodifiableSet(modifiedProperties);
+ this.removedProperties = Collections.unmodifiableSet(removedProperties);
+ }
+
+ /**
+ * @return absolutePath
+ */
+ public Path getPath() {
+ return this.location.getPath();
+ }
+
+ /**
+ * @return repositorySourceName
+ */
+ public String getRepositorySourceName() {
+ return this.sourceName;
+ }
+
+ /**
+ * @return repositoryWorkspaceName
+ */
+ public String getRepositoryWorkspaceName() {
+ return this.workspaceName;
+ }
+
+ /**
+ * @return modifiedProperties
+ */
+ public Set<Property> getModifiedProperties() {
+ return this.modifiedProperties;
+ }
+
+ /**
+ * @return removedProperties
+ */
+ public Set<Name> getRemovedProperties() {
+ return this.removedProperties;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public int hashCode() {
+ return this.hc;
+ }
+
+ public boolean includesAll( ChangeType... jcrEventTypes ) {
+ for (ChangeType jcrEventType : jcrEventTypes) {
+ if (!this.eventTypes.contains(jcrEventType)) return false;
+ }
+ return true;
+ }
+
+ public boolean includes( ChangeType... jcrEventTypes ) {
+ for (ChangeType jcrEventType : jcrEventTypes) {
+ if (this.eventTypes.contains(jcrEventType)) return true;
+ }
+ return false;
+ }
+
+ public boolean is( ChangeType jcrEventTypes ) {
+ return this.eventTypes.contains(jcrEventTypes);
+ }
+
+ public boolean isSameNode( NetChange that ) {
+ if (that == this) return true;
+ if (this.hc != that.hc) return false;
+ if (!this.workspaceName.equals(that.workspaceName)) return false;
+ if (!this.location.equals(that.location)) return false;
+ return true;
+ }
+
+ /**
+ * Determine whether this node change includes the setting of new value(s) for the supplied property.
+ *
+ * @param property the name of the property
+ * @return true if the named property has a new value on this node, or false otherwise
+ */
+ public boolean isPropertyModified( String property ) {
+ return this.modifiedProperties.contains(property);
+ }
+
+ /**
+ * Determine whether this node change includes the removal of the supplied property.
+ *
+ * @param property the name of the property
+ * @return true if the named property was removed from this node, or false otherwise
+ */
+ public boolean isPropertyRemoved( String property ) {
+ return this.removedProperties.contains(property);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public boolean equals( Object obj ) {
+ if (obj == this) return true;
+ if (obj instanceof NetChange) {
+ NetChange that = (NetChange)obj;
+ if (!this.isSameNode(that)) return false;
+ if (this.eventTypes != that.eventTypes) return false;
+ return true;
+ }
+ return false;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public String toString() {
+ return this.workspaceName + "=>" + this.location;
+ }
+ }
+
+ /**
+ * Internal utility class used in the computation of the net changes.
+ */
+ @NotThreadSafe
+ private static class NetChangeDetails {
+
+ private final Set<Property> modifiedProperties = new HashSet<Property>();
+ private final Set<Name> removedProperties = new HashSet<Name>();
+ private EnumSet<ChangeType> eventTypes = EnumSet.noneOf(ChangeType.class);
+
+ protected NetChangeDetails() {
+ }
+
+ public void addEventType( ChangeType eventType ) {
+ this.eventTypes.add(eventType);
+ }
+
+ public void addProperty( Property property ) {
+ this.modifiedProperties.add(property);
+ this.eventTypes.add(ChangeType.PROPERTY_ADDED);
+ }
+
+ public void changeProperty( Property property ) {
+ this.modifiedProperties.add(property);
+ this.eventTypes.add(ChangeType.PROPERTY_CHANGED);
+ }
+
+ public void removeProperty( Name propertyName ) {
+ this.removedProperties.add(propertyName);
+ this.eventTypes.add(ChangeType.PROPERTY_REMOVED);
+ }
+
+ /**
+ * @return nodeAction
+ */
+ public EnumSet<ChangeType> getEventTypes() {
+ return this.eventTypes;
+ }
+
+ /**
+ * @return addedProperties
+ */
+ public Set<Property> getModifiedProperties() {
+ return this.modifiedProperties;
+ }
+
+ /**
+ * @return removedProperties
+ */
+ public Set<Name> getRemovedProperties() {
+ return this.removedProperties;
+ }
+ }
+}
Property changes on: trunk/dna-graph/src/main/java/org/jboss/dna/graph/observe/NetChangeObserver.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Modified: trunk/dna-graph/src/main/java/org/jboss/dna/graph/request/ChangeRequest.java
===================================================================
--- trunk/dna-graph/src/main/java/org/jboss/dna/graph/request/ChangeRequest.java 2009-05-21 19:10:30 UTC (rev 921)
+++ trunk/dna-graph/src/main/java/org/jboss/dna/graph/request/ChangeRequest.java 2009-05-21 22:26:25 UTC (rev 922)
@@ -52,4 +52,11 @@
* @return the location changed by this request
*/
public abstract Location changedLocation();
+
+ /**
+ * Get the name of the workspace that was changed by this request.
+ *
+ * @return the name of the workspace changed by this request
+ */
+ public abstract String changedWorkspace();
}
Modified: trunk/dna-graph/src/main/java/org/jboss/dna/graph/request/CloneWorkspaceRequest.java
===================================================================
--- trunk/dna-graph/src/main/java/org/jboss/dna/graph/request/CloneWorkspaceRequest.java 2009-05-21 19:10:30 UTC (rev 921)
+++ trunk/dna-graph/src/main/java/org/jboss/dna/graph/request/CloneWorkspaceRequest.java 2009-05-21 22:26:25 UTC (rev 922)
@@ -243,6 +243,16 @@
/**
* {@inheritDoc}
*
+ * @see org.jboss.dna.graph.request.ChangeRequest#changedWorkspace()
+ */
+ @Override
+ public String changedWorkspace() {
+ return actualWorkspaceName;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
* @see org.jboss.dna.graph.request.ChangeRequest#changes(java.lang.String, org.jboss.dna.graph.property.Path)
*/
@Override
Modified: trunk/dna-graph/src/main/java/org/jboss/dna/graph/request/CopyBranchRequest.java
===================================================================
--- trunk/dna-graph/src/main/java/org/jboss/dna/graph/request/CopyBranchRequest.java 2009-05-21 19:10:30 UTC (rev 921)
+++ trunk/dna-graph/src/main/java/org/jboss/dna/graph/request/CopyBranchRequest.java 2009-05-21 22:26:25 UTC (rev 922)
@@ -272,6 +272,16 @@
/**
* {@inheritDoc}
*
+ * @see org.jboss.dna.graph.request.ChangeRequest#changedWorkspace()
+ */
+ @Override
+ public String changedWorkspace() {
+ return intoWorkspace();
+ }
+
+ /**
+ * {@inheritDoc}
+ *
* @see java.lang.Object#hashCode()
*/
@Override
Modified: trunk/dna-graph/src/main/java/org/jboss/dna/graph/request/CreateNodeRequest.java
===================================================================
--- trunk/dna-graph/src/main/java/org/jboss/dna/graph/request/CreateNodeRequest.java 2009-05-21 19:10:30 UTC (rev 921)
+++ trunk/dna-graph/src/main/java/org/jboss/dna/graph/request/CreateNodeRequest.java 2009-05-21 22:26:25 UTC (rev 922)
@@ -324,12 +324,22 @@
*/
@Override
public Location changedLocation() {
- return under;
+ return actualLocation;
}
/**
* {@inheritDoc}
*
+ * @see org.jboss.dna.graph.request.ChangeRequest#changedWorkspace()
+ */
+ @Override
+ public String changedWorkspace() {
+ return workspaceName;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
* @see org.jboss.dna.graph.request.Request#cancel()
*/
@Override
Modified: trunk/dna-graph/src/main/java/org/jboss/dna/graph/request/CreateWorkspaceRequest.java
===================================================================
--- trunk/dna-graph/src/main/java/org/jboss/dna/graph/request/CreateWorkspaceRequest.java 2009-05-21 19:10:30 UTC (rev 921)
+++ trunk/dna-graph/src/main/java/org/jboss/dna/graph/request/CreateWorkspaceRequest.java 2009-05-21 22:26:25 UTC (rev 922)
@@ -204,6 +204,16 @@
/**
* {@inheritDoc}
*
+ * @see org.jboss.dna.graph.request.ChangeRequest#changedWorkspace()
+ */
+ @Override
+ public String changedWorkspace() {
+ return actualWorkspaceName;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
* @see org.jboss.dna.graph.request.ChangeRequest#changes(java.lang.String, org.jboss.dna.graph.property.Path)
*/
@Override
Modified: trunk/dna-graph/src/main/java/org/jboss/dna/graph/request/DeleteBranchRequest.java
===================================================================
--- trunk/dna-graph/src/main/java/org/jboss/dna/graph/request/DeleteBranchRequest.java 2009-05-21 19:10:30 UTC (rev 921)
+++ trunk/dna-graph/src/main/java/org/jboss/dna/graph/request/DeleteBranchRequest.java 2009-05-21 22:26:25 UTC (rev 922)
@@ -139,6 +139,16 @@
/**
* {@inheritDoc}
*
+ * @see org.jboss.dna.graph.request.ChangeRequest#changedWorkspace()
+ */
+ @Override
+ public String changedWorkspace() {
+ return workspaceName;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
* @see org.jboss.dna.graph.request.Request#cancel()
*/
@Override
Modified: trunk/dna-graph/src/main/java/org/jboss/dna/graph/request/DeleteChildrenRequest.java
===================================================================
--- trunk/dna-graph/src/main/java/org/jboss/dna/graph/request/DeleteChildrenRequest.java 2009-05-21 19:10:30 UTC (rev 921)
+++ trunk/dna-graph/src/main/java/org/jboss/dna/graph/request/DeleteChildrenRequest.java 2009-05-21 22:26:25 UTC (rev 922)
@@ -23,10 +23,13 @@
*/
package org.jboss.dna.graph.request;
+import java.util.LinkedList;
+import java.util.List;
import org.jboss.dna.common.util.CheckArg;
import org.jboss.dna.graph.GraphI18n;
import org.jboss.dna.graph.Location;
import org.jboss.dna.graph.property.Path;
+import org.jboss.dna.graph.property.Property;
/**
* Instruction that all nodes below a supplied node be deleted. This is similar to {@link DeleteBranchRequest}, except that the
@@ -39,6 +42,7 @@
private final Location at;
private final String workspaceName;
private Location actualLocation;
+ private List<Location> actualChildrenDeleted = new LinkedList<Location>();
/**
* Create a request to delete all children of the supplied node. The supplied parent node will not be deleted.
@@ -105,6 +109,88 @@
}
/**
+ * Add to the list of children that has been read the supplied children with the given path and identification properties. The
+ * children are added in order.
+ *
+ * @param children the locations of the children that were read
+ * @throws IllegalArgumentException if the parameter is null
+ * @throws IllegalStateException if the request is frozen
+ * @see #addDeletedChild(Location)
+ * @see #addDeletedChild(Path, Property)
+ * @see #addDeletedChild(Path, Property, Property...)
+ */
+ public void addDeletedChildren( Iterable<Location> children ) {
+ checkNotFrozen();
+ CheckArg.isNotNull(children, "children");
+ for (Location child : children) {
+ if (child != null) this.actualChildrenDeleted.add(child);
+ }
+ }
+
+ /**
+ * Add to the list of children that has been read the child with the given path and identification properties. The children
+ * should be added in order.
+ *
+ * @param child the location of the child that was read
+ * @throws IllegalArgumentException if the location is null
+ * @throws IllegalStateException if the request is frozen
+ * @see #addDeletedChild(Path, Property)
+ * @see #addDeletedChild(Path, Property, Property...)
+ */
+ public void addDeletedChild( Location child ) {
+ checkNotFrozen();
+ CheckArg.isNotNull(child, "child");
+ this.actualChildrenDeleted.add(child);
+ }
+
+ /**
+ * Add to the list of children that has been read the child with the given path and identification properties. The children
+ * should be added in order.
+ *
+ * @param pathToChild the path of the child that was just read
+ * @param firstIdProperty the first identification property of the child that was just read
+ * @param remainingIdProperties the remaining identification properties of the child that was just read
+ * @throws IllegalArgumentException if the path or identification properties are null
+ * @throws IllegalStateException if the request is frozen
+ * @see #addDeletedChild(Location)
+ * @see #addDeletedChild(Path, Property)
+ */
+ public void addDeletedChild( Path pathToChild,
+ Property firstIdProperty,
+ Property... remainingIdProperties ) {
+ checkNotFrozen();
+ Location child = Location.create(pathToChild, firstIdProperty, remainingIdProperties);
+ this.actualChildrenDeleted.add(child);
+ }
+
+ /**
+ * Add to the list of children that has been read the child with the given path and identification property. The children
+ * should be added in order.
+ *
+ * @param pathToChild the path of the child that was just read
+ * @param idProperty the identification property of the child that was just read
+ * @throws IllegalArgumentException if the path or identification properties are null
+ * @throws IllegalStateException if the request is frozen
+ * @see #addDeletedChild(Location)
+ * @see #addDeletedChild(Path, Property, Property...)
+ */
+ public void addDeletedChild( Path pathToChild,
+ Property idProperty ) {
+ checkNotFrozen();
+ Location child = Location.create(pathToChild, idProperty);
+ this.actualChildrenDeleted.add(child);
+ }
+
+ /**
+ * Get the list of the actual children that were deleted.
+ *
+ * @return the actual children, or empty if there were no children (if frozen)
+ */
+ public List<Location> getActualChildrenDeleted() {
+ return actualChildrenDeleted;
+ }
+
+ /**
* Get the actual location of the node that was deleted.
*
* @return the actual location, or null if the actual location was not set
@@ -137,6 +223,16 @@
/**
* {@inheritDoc}
*
+ * @see org.jboss.dna.graph.request.ChangeRequest#changedWorkspace()
+ */
+ @Override
+ public String changedWorkspace() {
+ return workspaceName;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
* @see java.lang.Object#equals(java.lang.Object)
*/
@Override
Modified: trunk/dna-graph/src/main/java/org/jboss/dna/graph/request/DestroyWorkspaceRequest.java
===================================================================
--- trunk/dna-graph/src/main/java/org/jboss/dna/graph/request/DestroyWorkspaceRequest.java 2009-05-21 19:10:30 UTC (rev 921)
+++ trunk/dna-graph/src/main/java/org/jboss/dna/graph/request/DestroyWorkspaceRequest.java 2009-05-21 22:26:25 UTC (rev 922)
@@ -136,6 +136,16 @@
/**
* {@inheritDoc}
*
+ * @see org.jboss.dna.graph.request.ChangeRequest#changedWorkspace()
+ */
+ @Override
+ public String changedWorkspace() {
+ return workspaceName;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
* @see org.jboss.dna.graph.request.ChangeRequest#changes(java.lang.String, org.jboss.dna.graph.property.Path)
*/
@Override
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-05-21 19:10:30 UTC (rev 921)
+++ trunk/dna-graph/src/main/java/org/jboss/dna/graph/request/MoveBranchRequest.java 2009-05-21 22:26:25 UTC (rev 922)
@@ -287,6 +287,16 @@
/**
* {@inheritDoc}
*
+ * @see org.jboss.dna.graph.request.ChangeRequest#changedWorkspace()
+ */
+ @Override
+ public String changedWorkspace() {
+ return workspaceName;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
* @see org.jboss.dna.graph.request.Request#cancel()
*/
@Override
Modified: trunk/dna-graph/src/main/java/org/jboss/dna/graph/request/RemovePropertyRequest.java
===================================================================
--- trunk/dna-graph/src/main/java/org/jboss/dna/graph/request/RemovePropertyRequest.java 2009-05-21 19:10:30 UTC (rev 921)
+++ trunk/dna-graph/src/main/java/org/jboss/dna/graph/request/RemovePropertyRequest.java 2009-05-21 22:26:25 UTC (rev 922)
@@ -194,6 +194,16 @@
/**
* {@inheritDoc}
*
+ * @see org.jboss.dna.graph.request.ChangeRequest#changedWorkspace()
+ */
+ @Override
+ public String changedWorkspace() {
+ return workspaceName;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
* @see java.lang.Object#toString()
*/
@Override
Modified: trunk/dna-graph/src/main/java/org/jboss/dna/graph/request/RenameNodeRequest.java
===================================================================
--- trunk/dna-graph/src/main/java/org/jboss/dna/graph/request/RenameNodeRequest.java 2009-05-21 19:10:30 UTC (rev 921)
+++ trunk/dna-graph/src/main/java/org/jboss/dna/graph/request/RenameNodeRequest.java 2009-05-21 22:26:25 UTC (rev 922)
@@ -185,6 +185,16 @@
/**
* {@inheritDoc}
*
+ * @see org.jboss.dna.graph.request.ChangeRequest#changedWorkspace()
+ */
+ @Override
+ public String changedWorkspace() {
+ return workspaceName;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
* @see org.jboss.dna.graph.request.Request#cancel()
*/
@Override
Modified: trunk/dna-graph/src/main/java/org/jboss/dna/graph/request/SetPropertyRequest.java
===================================================================
--- trunk/dna-graph/src/main/java/org/jboss/dna/graph/request/SetPropertyRequest.java 2009-05-21 19:10:30 UTC (rev 921)
+++ trunk/dna-graph/src/main/java/org/jboss/dna/graph/request/SetPropertyRequest.java 2009-05-21 22:26:25 UTC (rev 922)
@@ -194,6 +194,16 @@
/**
* {@inheritDoc}
*
+ * @see org.jboss.dna.graph.request.ChangeRequest#changedWorkspace()
+ */
+ @Override
+ public String changedWorkspace() {
+ return workspaceName;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
* @see java.lang.Object#toString()
*/
@Override
Modified: trunk/dna-graph/src/main/java/org/jboss/dna/graph/request/UpdatePropertiesRequest.java
===================================================================
--- trunk/dna-graph/src/main/java/org/jboss/dna/graph/request/UpdatePropertiesRequest.java 2009-05-21 19:10:30 UTC (rev 921)
+++ trunk/dna-graph/src/main/java/org/jboss/dna/graph/request/UpdatePropertiesRequest.java 2009-05-21 22:26:25 UTC (rev 922)
@@ -212,6 +212,16 @@
/**
* {@inheritDoc}
*
+ * @see org.jboss.dna.graph.request.ChangeRequest#changedWorkspace()
+ */
+ @Override
+ public String changedWorkspace() {
+ return workspaceName;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
* @see java.lang.Object#toString()
*/
@Override
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-05-21 19:10:30 UTC (rev 921)
+++ trunk/dna-graph/src/main/java/org/jboss/dna/graph/request/processor/RequestProcessor.java 2009-05-21 22:26:25 UTC (rev 922)
@@ -436,6 +436,7 @@
if (request.isCancelled()) return;
DeleteBranchRequest deleteChild = new DeleteBranchRequest(child, request.inWorkspace());
process(deleteChild);
+ request.addDeletedChild(child);
}
// Set the actual location of the parent node ...
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-05-21 19:10:30 UTC (rev 921)
+++ trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/SessionCache.java 2009-05-21 22:26:25 UTC (rev 922)
@@ -71,6 +71,7 @@
import org.jboss.dna.graph.property.ValueFormatException;
import org.jboss.dna.graph.request.BatchRequestBuilder;
import org.jboss.dna.graph.request.ChangeRequest;
+import org.jboss.dna.graph.request.CreateNodeRequest;
import org.jboss.dna.graph.request.Request;
import org.jboss.dna.jcr.cache.ChangedNodeInfo;
import org.jboss.dna.jcr.cache.ChildNode;
@@ -624,7 +625,13 @@
if (change.changes(workspaceName, path)) {
branchRequests.add(request);
// Record the UUID of the node being saved now ...
- UUID changedUuid = change.changedLocation().getUuid();
+ UUID changedUuid = null;
+ if (change instanceof CreateNodeRequest) {
+ // We want the parent UUID ...
+ changedUuid = ((CreateNodeRequest)change).under().getUuid();
+ } else {
+ changedUuid = change.changedLocation().getUuid();
+ }
assert changedUuid != null;
branchUuids.add(changedUuid);
} else {
@@ -665,13 +672,13 @@
throw new ConstraintViolationException();
}
}
-
+
for (UUID changedUuid : uuidsUnderBranch) {
if (!this.deletedNodes.containsKey(changedUuid)) {
checkAgainstTypeDefinitions(changedUuid, false);
}
}
-
+
// Now execute the branch ...
Graph.Batch branchBatch = store.batch(new BatchRequestBuilder(branchRequests));
try {
@@ -1302,8 +1309,8 @@
if (!definition.getId().equals(node.getDefinitionId())) {
// The node definition changed, so try to set the property ...
try {
- JcrValue value = new JcrValue(factories(), SessionCache.this, PropertyType.STRING,
- definition.getId().getString());
+ JcrValue value = new JcrValue(factories(), SessionCache.this, PropertyType.STRING, definition.getId()
+ .getString());
setProperty(DnaIntLexicon.NODE_DEFINITON, value);
} catch (ConstraintViolationException e) {
// We can't set this property on the node (according to the node definition).
@@ -1536,7 +1543,10 @@
// ---------------------------------------
// Now record the changes to the store ...
// ---------------------------------------
- Graph.Create<Graph.Batch> create = operations.createUnder(currentLocation).nodeNamed(name).with(desiredUuid).with(primaryTypeProp);
+ Graph.Create<Graph.Batch> create = operations.createUnder(currentLocation)
+ .nodeNamed(name)
+ .with(desiredUuid)
+ .with(primaryTypeProp);
if (nodeDefnDefn != null) {
create = create.with(nodeDefinitionProp);
}
@@ -2291,8 +2301,8 @@
DnaIntLexicon.MULTI_VALUED_PROPERTIES,
values,
false);
- Property dnaProp = propertyFactory.create(DnaIntLexicon.MULTI_VALUED_PROPERTIES,
- newSingleMultiPropertyNames.iterator().next());
+ Property dnaProp = propertyFactory.create(DnaIntLexicon.MULTI_VALUED_PROPERTIES, newSingleMultiPropertyNames.iterator()
+ .next());
PropertyId propId = new PropertyId(uuid, dnaProp.getName());
JcrPropertyDefinition defn = (JcrPropertyDefinition)propertyDefinition;
return new PropertyInfo(propId, defn.getId(), PropertyType.STRING, dnaProp, defn.isMultiple(), true, false);
Modified: trunk/dna-repository/src/main/java/org/jboss/dna/repository/sequencer/Sequencer.java
===================================================================
--- trunk/dna-repository/src/main/java/org/jboss/dna/repository/sequencer/Sequencer.java 2009-05-21 19:10:30 UTC (rev 921)
+++ trunk/dna-repository/src/main/java/org/jboss/dna/repository/sequencer/Sequencer.java 2009-05-21 22:26:25 UTC (rev 922)
@@ -29,6 +29,7 @@
import org.jboss.dna.common.component.Component;
import org.jboss.dna.graph.Node;
import org.jboss.dna.graph.io.Destination;
+import org.jboss.dna.graph.observe.NetChangeObserver.NetChange;
import org.jboss.dna.repository.observation.NodeChange;
import org.jboss.dna.repository.observation.NodeChanges;
import org.jboss.dna.repository.observation.ObservationService;
@@ -53,10 +54,10 @@
* this sequencer, and closing any other acquired resources, even in the case of exceptions.
* <p>
* The {@link SequencingService} determines the sequencers that should be executed by monitoring the changes to one or more
- * workspaces (it is a listener registered with the {@link ObservationService}). Changes in those workspaces
- * are aggregated for each transaction, and organized into {@link NodeChanges changes for each node}. The SequencingService
- * then determines for each {@link NodeChange set of changes to a node} the set of full paths to the properties that have
- * changed and whether those paths {@link SequencerPathExpression#matcher(String) match} the sequencer's
+ * workspaces (it is a listener registered with the {@link ObservationService}). Changes in those workspaces are aggregated
+ * for each transaction, and organized into {@link NodeChanges changes for each node}. The SequencingService then determines
+ * for each {@link NodeChange set of changes to a node} the set of full paths to the properties that have changed and whether
+ * those paths {@link SequencerPathExpression#matcher(String) match} the sequencer's
* {@link SequencerConfig#getPathExpressions() path expressions}. Each path expression produces the path to the output node,
* and these output paths are accumulated and (with the original node that changed, the node change summary, and other
* information) supplied to the sequencer via this method.
@@ -79,7 +80,7 @@
*/
void execute( Node input,
String sequencedPropertyName,
- NodeChange changes,
+ NetChange changes,
Set<RepositoryNodePath> outputPaths,
SequencerContext context,
Problems problems ) throws SequencerException;
Modified: trunk/dna-repository/src/main/java/org/jboss/dna/repository/sequencer/SequencingService.java
===================================================================
--- trunk/dna-repository/src/main/java/org/jboss/dna/repository/sequencer/SequencingService.java 2009-05-21 19:10:30 UTC (rev 921)
+++ trunk/dna-repository/src/main/java/org/jboss/dna/repository/sequencer/SequencingService.java 2009-05-21 22:26:25 UTC (rev 922)
@@ -34,7 +34,6 @@
import java.util.concurrent.RejectedExecutionException;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicLong;
-import javax.jcr.observation.Event;
import net.jcip.annotations.Immutable;
import net.jcip.annotations.ThreadSafe;
import org.jboss.dna.common.collection.SimpleProblems;
@@ -48,24 +47,28 @@
import org.jboss.dna.graph.Graph;
import org.jboss.dna.graph.Node;
import org.jboss.dna.graph.connector.RepositorySource;
+import org.jboss.dna.graph.observe.ChangeObserver;
+import org.jboss.dna.graph.observe.NetChangeObserver;
+import org.jboss.dna.graph.observe.NetChangeObserver.NetChange;
+import org.jboss.dna.graph.property.Name;
+import org.jboss.dna.graph.property.Path;
+import org.jboss.dna.graph.property.Property;
import org.jboss.dna.repository.RepositoryI18n;
import org.jboss.dna.repository.RepositoryLibrary;
import org.jboss.dna.repository.observation.NodeChange;
-import org.jboss.dna.repository.observation.NodeChangeListener;
-import org.jboss.dna.repository.observation.NodeChanges;
import org.jboss.dna.repository.service.AbstractServiceAdministrator;
import org.jboss.dna.repository.service.AdministeredService;
import org.jboss.dna.repository.service.ServiceAdministrator;
import org.jboss.dna.repository.util.RepositoryNodePath;
/**
- * A sequencing system is used to monitor changes in the content of DNA repositories and to sequence the
- * content to extract or to generate structured information.
+ * A sequencing system is used to monitor changes in the content of DNA repositories and to sequence the content to extract or to
+ * generate structured information.
*
* @author Randall Hauch
* @author John Verhaeg
*/
-public class SequencingService implements AdministeredService, NodeChangeListener {
+public class SequencingService implements AdministeredService {
/**
* Interface used to select the set of {@link Sequencer} instances that should be run.
@@ -84,7 +87,7 @@
*/
List<Sequencer> selectSequencers( List<Sequencer> sequencers,
Node node,
- NodeChange nodeChange );
+ NetChange nodeChange );
}
/**
@@ -97,52 +100,17 @@
public List<Sequencer> selectSequencers( List<Sequencer> sequencers,
Node node,
- NodeChange nodeChange ) {
+ NetChange nodeChange ) {
return sequencers;
}
}
/**
- * Interface used to determine whether a {@link NodeChange} should be processed.
- *
- * @author Randall Hauch
- */
- public static interface NodeFilter {
-
- /**
- * Determine whether the node represented by the supplied change should be submitted for sequencing.
- *
- * @param nodeChange the node change event
- * @return true if the node should be submitted for sequencing, or false if the change should be ignored
- */
- boolean accept( NodeChange nodeChange );
- }
-
- /**
- * The default filter implementation, which accepts only new nodes or nodes that have new or changed properties.
- *
- * @author Randall Hauch
- */
- protected static class DefaultNodeFilter implements NodeFilter {
-
- public boolean accept( NodeChange nodeChange ) {
- // Only care about new nodes or nodes that have new/changed properies ...
- return nodeChange.includesEventTypes(Event.NODE_ADDED, Event.PROPERTY_ADDED, Event.PROPERTY_CHANGED);
- }
- }
-
- /**
* The default {@link Selector} that considers every {@link Sequencer} to be used for every node.
*
* @see SequencingService#setSequencerSelector(org.jboss.dna.repository.sequencer.SequencingService.Selector)
*/
public static final Selector DEFAULT_SEQUENCER_SELECTOR = new DefaultSelector();
- /**
- * The default {@link NodeFilter} that accepts new nodes or nodes that have new/changed properties.
- *
- * @see SequencingService#setSequencerSelector(org.jboss.dna.repository.sequencer.SequencingService.Selector)
- */
- public static final NodeFilter DEFAULT_NODE_FILTER = new DefaultNodeFilter();
/**
* Class loader factory instance that always returns the {@link Thread#getContextClassLoader() current thread's context class
@@ -201,9 +169,9 @@
private ExecutionContext executionContext;
private SequencerLibrary sequencerLibrary = new SequencerLibrary();
private Selector sequencerSelector = DEFAULT_SEQUENCER_SELECTOR;
- private NodeFilter nodeFilter = DEFAULT_NODE_FILTER;
private ExecutorService executorService;
private RepositoryLibrary repositoryLibrary;
+ private ChangeObserver repositoryObserver;
private final Statistics statistics = new Statistics();
private final Administrator administrator = new Administrator();
@@ -311,11 +279,11 @@
public RepositoryLibrary getRepositoryLibrary() {
return this.repositoryLibrary;
}
-
- public void setRepositoryLibrary(RepositoryLibrary repositoryLibrary) {
+
+ public void setRepositoryLibrary( RepositoryLibrary repositoryLibrary ) {
this.repositoryLibrary = repositoryLibrary;
}
-
+
/**
* Get the executor service used to run the sequencers.
*
@@ -373,8 +341,11 @@
}
assert this.executorService != null;
assert this.sequencerSelector != null;
- assert this.nodeFilter != null;
assert this.sequencerLibrary != null;
+ assert this.repositoryLibrary != null;
+ this.repositoryObserver = new RepositoryObserver();
+ // Register the observer ...
+ this.repositoryLibrary.register(this.repositoryObserver);
}
protected void shutdownService() {
@@ -415,79 +386,41 @@
}
/**
- * Get the node filter used by this system.
- *
- * @return the node filter
- */
- public NodeFilter getNodeFilter() {
- return this.nodeFilter;
- }
-
- /**
- * Set the filter that checks which nodes are to be sequenced, or null if the {@link #DEFAULT_NODE_FILTER default node filter}
- * should be used.
- *
- * @param nodeFilter the new node filter
- */
- public void setNodeFilter( NodeFilter nodeFilter ) {
- this.nodeFilter = nodeFilter != null ? nodeFilter : DEFAULT_NODE_FILTER;
- }
-
- /**
- * {@inheritDoc}
- */
- public void onNodeChanges( NodeChanges changes ) {
- NodeFilter filter = this.getNodeFilter();
- for (final NodeChange changedNode : changes) {
- // Only care about new nodes or nodes that have new/changed properies ...
- if (filter.accept(changedNode)) {
- try {
- this.executorService.execute(new Runnable() {
-
- public void run() {
- processChangedNode(changedNode);
- }
- });
- } catch (RejectedExecutionException e) {
- // The executor service has been shut down, so do nothing with this set of changes
- }
- }
- }
- }
-
- /**
* Do the work of processing by sequencing the node. This method is called by the {@link #executorService executor service}
* when it performs it's work on the enqueued {@link NodeChange NodeChange runnable objects}.
*
- * @param changedNode the node to be processed.
+ * @param change the change describing the node to be processed.
*/
- protected void processChangedNode( NodeChange changedNode ) {
+ protected void processChange( NetChange change ) {
final ExecutionContext context = this.getExecutionContext();
final Logger logger = context.getLogger(getClass());
assert logger != null;
-
+
try {
- final String repositorySourceName = changedNode.getRepositorySourceName();
- final String repositoryWorkspaceName = changedNode.getRepositoryWorkspaceName();
+ final String repositorySourceName = change.getRepositorySourceName();
+ final String repositoryWorkspaceName = change.getRepositoryWorkspaceName();
// Figure out which sequencers accept this path,
// and track which output nodes should be passed to each sequencer...
- final String nodePath = changedNode.getAbsolutePath();
+ final Path nodePath = change.getPath();
+ final String nodePathStr = context.getValueFactories().getStringFactory().create(nodePath);
Map<SequencerCall, Set<RepositoryNodePath>> sequencerCalls = new HashMap<SequencerCall, Set<RepositoryNodePath>>();
List<Sequencer> allSequencers = this.sequencerLibrary.getInstances();
List<Sequencer> sequencers = new ArrayList<Sequencer>(allSequencers.size());
for (Sequencer sequencer : allSequencers) {
final SequencerConfig config = sequencer.getConfiguration();
for (SequencerPathExpression pathExpression : config.getPathExpressions()) {
- for (String propertyName : changedNode.getModifiedProperties()) {
- String path = nodePath + "/@" + propertyName;
+ for (Property property : change.getModifiedProperties()) {
+ Name propertyName = property.getName();
+ String propertyNameStr = context.getValueFactories().getStringFactory().create(propertyName);
+ String path = nodePathStr + "/@" + propertyNameStr;
SequencerPathExpression.Matcher matcher = pathExpression.matcher(path);
if (matcher.matches()) {
// String selectedPath = matcher.getSelectedPath();
RepositoryNodePath outputPath = RepositoryNodePath.parse(matcher.getOutputPath(),
repositorySourceName,
repositoryWorkspaceName);
- SequencerCall call = new SequencerCall(sequencer, propertyName);
+ SequencerCall call = new SequencerCall(sequencer, propertyNameStr);
// Record the output path ...
Set<RepositoryNodePath> outputPaths = sequencerCalls.get(call);
if (outputPaths == null) {
@@ -508,16 +441,15 @@
if (!sequencers.isEmpty()) {
// Find the changed node ...
- String relPath = changedNode.getAbsolutePath().replaceAll("^/+", "");
- node = graph.getNodeAt(relPath);
+ node = graph.getNodeAt(nodePath);
// Figure out which sequencers should run ...
- sequencers = this.sequencerSelector.selectSequencers(sequencers, node, changedNode);
+ sequencers = this.sequencerSelector.selectSequencers(sequencers, node, change);
}
if (sequencers.isEmpty()) {
this.statistics.recordNodeSkipped();
if (logger.isDebugEnabled()) {
- logger.trace("Skipping '{0}': no sequencers matched this condition", changedNode);
+ logger.trace("Skipping '{0}': no sequencers matched this condition", change);
}
} else {
// Run each of those sequencers ...
@@ -536,16 +468,16 @@
final SimpleProblems problems = new SimpleProblems();
SequencerContext sequencerContext = new SequencerContext(context, graph);
try {
- sequencer.execute(node, propertyName, changedNode, outputPaths, sequencerContext, problems);
+ sequencer.execute(node, propertyName, change, outputPaths, sequencerContext, problems);
sequencerContext.getDestination().submit();
} catch (SequencerException e) {
- logger.error(e, RepositoryI18n.errorWhileSequencingNode, sequencerName, changedNode);
+ logger.error(e, RepositoryI18n.errorWhileSequencingNode, sequencerName, change);
}
}
this.statistics.recordNodeSequenced();
}
} catch (Throwable e) {
- logger.error(e, RepositoryI18n.errorFindingSequencersToRunAgainstNode, changedNode);
+ logger.error(e, RepositoryI18n.errorFindingSequencersToRunAgainstNode, change);
}
}
@@ -655,4 +587,31 @@
return false;
}
}
+
+ protected class RepositoryObserver extends NetChangeObserver {
+ protected RepositoryObserver() {
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.jboss.dna.graph.observe.NetChangeObserver#notify(org.jboss.dna.graph.observe.NetChangeObserver.NetChange)
+ */
+ @Override
+ protected void notify( final NetChange change ) {
+ // Only care about new nodes or nodes that have new/changed properies ...
+ if (change.includes(ChangeType.NODE_ADDED, ChangeType.PROPERTY_ADDED, ChangeType.PROPERTY_CHANGED)) {
+ try {
+ getExecutorService().execute(new Runnable() {
+
+ public void run() {
+ processChange(change);
+ }
+ });
+ } catch (RejectedExecutionException e) {
+ // The executor service has been shut down, so do nothing with this set of changes
+ }
+ }
+ }
+ }
}
Modified: trunk/dna-repository/src/main/java/org/jboss/dna/repository/sequencer/StreamSequencerAdapter.java
===================================================================
--- trunk/dna-repository/src/main/java/org/jboss/dna/repository/sequencer/StreamSequencerAdapter.java 2009-05-21 19:10:30 UTC (rev 921)
+++ trunk/dna-repository/src/main/java/org/jboss/dna/repository/sequencer/StreamSequencerAdapter.java 2009-05-21 22:26:25 UTC (rev 922)
@@ -33,6 +33,7 @@
import java.util.Set;
import org.jboss.dna.common.collection.Problems;
import org.jboss.dna.graph.Node;
+import org.jboss.dna.graph.observe.NetChangeObserver.NetChange;
import org.jboss.dna.graph.property.Path;
import org.jboss.dna.graph.property.PathFactory;
import org.jboss.dna.graph.property.Property;
@@ -41,7 +42,6 @@
import org.jboss.dna.graph.sequencer.StreamSequencer;
import org.jboss.dna.graph.sequencer.StreamSequencerContext;
import org.jboss.dna.repository.RepositoryI18n;
-import org.jboss.dna.repository.observation.NodeChange;
import org.jboss.dna.repository.util.RepositoryNodePath;
/**
@@ -78,7 +78,7 @@
*/
public void execute( Node input,
String sequencedPropertyName,
- NodeChange changes,
+ NetChange changes,
Set<RepositoryNodePath> outputPaths,
SequencerContext context,
Problems problems ) throws SequencerException {
Modified: trunk/dna-repository/src/test/java/org/jboss/dna/repository/DnaEngineTest.java
===================================================================
--- trunk/dna-repository/src/test/java/org/jboss/dna/repository/DnaEngineTest.java 2009-05-21 19:10:30 UTC (rev 921)
+++ trunk/dna-repository/src/test/java/org/jboss/dna/repository/DnaEngineTest.java 2009-05-21 22:26:25 UTC (rev 922)
@@ -31,13 +31,11 @@
import static org.mockito.Mockito.stub;
import java.io.ByteArrayInputStream;
import java.io.InputStream;
-import java.util.Arrays;
import java.util.concurrent.TimeUnit;
import javax.jcr.observation.Event;
import org.jboss.dna.graph.connector.RepositoryConnection;
import org.jboss.dna.graph.connector.inmemory.InMemoryRepositorySource;
import org.jboss.dna.graph.mimetype.MimeTypeDetector;
-import org.jboss.dna.repository.observation.NodeChanges;
import org.jboss.dna.repository.sequencer.MockSequencerA;
import org.jboss.dna.repository.sequencer.SequencingService;
import org.junit.Before;
@@ -160,11 +158,6 @@
SequencingService sequencer = engine.getSequencingService();
assertThat(sequencer.getStatistics().getNumberOfNodesSequenced(), is(0L));
- NodeChanges changes = NodeChanges.create("config repo", "", Arrays.asList(new Event[] {}));
- sequencer.onNodeChanges(changes);
-
- assertThat(sequencer.getStatistics().getNumberOfNodesSequenced(), is(0L));
-
Event e1 = mock(Event.class);
stub(e1.getType()).toReturn(Event.NODE_ADDED);
stub(e1.getPath()).toReturn("/test");
Modified: trunk/dna-repository/src/test/java/org/jboss/dna/repository/sequencer/MockSequencerA.java
===================================================================
--- trunk/dna-repository/src/test/java/org/jboss/dna/repository/sequencer/MockSequencerA.java 2009-05-21 19:10:30 UTC (rev 921)
+++ trunk/dna-repository/src/test/java/org/jboss/dna/repository/sequencer/MockSequencerA.java 2009-05-21 22:26:25 UTC (rev 922)
@@ -31,7 +31,7 @@
import net.jcip.annotations.ThreadSafe;
import org.jboss.dna.common.collection.Problems;
import org.jboss.dna.graph.Node;
-import org.jboss.dna.repository.observation.NodeChange;
+import org.jboss.dna.graph.observe.NetChangeObserver.NetChange;
import org.jboss.dna.repository.util.RepositoryNodePath;
/**
@@ -68,7 +68,7 @@
*/
public void execute( Node input,
String sequencedPropertyName,
- NodeChange changes,
+ NetChange changes,
Set<RepositoryNodePath> outputPaths,
SequencerContext context,
Problems problems ) {
Modified: trunk/dna-repository/src/test/java/org/jboss/dna/repository/sequencer/MockSequencerB.java
===================================================================
--- trunk/dna-repository/src/test/java/org/jboss/dna/repository/sequencer/MockSequencerB.java 2009-05-21 19:10:30 UTC (rev 921)
+++ trunk/dna-repository/src/test/java/org/jboss/dna/repository/sequencer/MockSequencerB.java 2009-05-21 22:26:25 UTC (rev 922)
@@ -31,7 +31,7 @@
import net.jcip.annotations.ThreadSafe;
import org.jboss.dna.common.collection.Problems;
import org.jboss.dna.graph.Node;
-import org.jboss.dna.repository.observation.NodeChange;
+import org.jboss.dna.graph.observe.NetChangeObserver.NetChange;
import org.jboss.dna.repository.util.RepositoryNodePath;
/**
@@ -68,7 +68,7 @@
*/
public void execute( Node input,
String sequencedPropertyName,
- NodeChange changes,
+ NetChange changes,
Set<RepositoryNodePath> outputPaths,
SequencerContext context,
Problems problems ) {
Modified: trunk/dna-repository/src/test/java/org/jboss/dna/repository/sequencer/SequencingServiceTest.java
===================================================================
--- trunk/dna-repository/src/test/java/org/jboss/dna/repository/sequencer/SequencingServiceTest.java 2009-05-21 19:10:30 UTC (rev 921)
+++ trunk/dna-repository/src/test/java/org/jboss/dna/repository/sequencer/SequencingServiceTest.java 2009-05-21 22:26:25 UTC (rev 922)
@@ -30,30 +30,22 @@
import static org.hamcrest.core.IsSame.sameInstance;
import static org.junit.Assert.assertThat;
import static org.junit.matchers.JUnitMatchers.hasItem;
-import java.io.IOException;
import java.util.Collections;
import java.util.concurrent.TimeUnit;
-import javax.jcr.Node;
-import javax.jcr.RepositoryException;
-import javax.jcr.Session;
import javax.jcr.observation.Event;
-import org.jboss.dna.common.SystemFailureException;
-import org.jboss.dna.common.jcr.AbstractJcrRepositoryTest;
+import org.jboss.dna.graph.ExecutionContext;
+import org.jboss.dna.graph.Graph;
import org.jboss.dna.graph.connector.inmemory.InMemoryRepositorySource;
import org.jboss.dna.repository.RepositoryLibrary;
-import org.jboss.dna.repository.observation.ObservationService;
import org.jboss.dna.repository.service.ServiceAdministrator;
-import org.jboss.dna.repository.util.JcrExecutionContext;
-import org.jboss.dna.repository.util.SessionFactory;
import org.junit.After;
import org.junit.Before;
-import org.junit.Ignore;
import org.junit.Test;
/**
* @author Randall Hauch
*/
-public class SequencingServiceTest extends AbstractJcrRepositoryTest {
+public class SequencingServiceTest {
public static final int ALL_EVENT_TYPES = Event.NODE_ADDED | Event.NODE_REMOVED | Event.PROPERTY_ADDED
| Event.PROPERTY_CHANGED | Event.PROPERTY_REMOVED;
@@ -62,9 +54,8 @@
public static final String REPOSITORY_WORKSPACE_NAME = "testRepository-Workspace";
private RepositoryLibrary sources;
- private ObservationService observationService;
private SequencingService sequencingService;
- private JcrExecutionContext executionContext;
+ private ExecutionContext executionContext;
@Before
public void beforeEach() {
@@ -72,32 +63,17 @@
InMemoryRepositorySource source = new InMemoryRepositorySource();
source.setName(REPOSITORY_SOURCE_NAME);
sources.addSource(source);
-
- SessionFactory sessionFactory = new SessionFactory() {
- public Session createSession( String name ) throws RepositoryException {
- assertThat(name, is(REPOSITORY_WORKSPACE_NAME));
- try {
- return getRepository().login(getTestCredentials());
- } catch (IOException e) {
- throw new SystemFailureException(e);
- }
- }
- };
- this.executionContext = new JcrExecutionContext(sessionFactory, REPOSITORY_WORKSPACE_NAME);
+
+ this.executionContext = new ExecutionContext();
this.sequencingService = new SequencingService();
this.sequencingService.setExecutionContext(this.executionContext);
this.sequencingService.setRepositoryLibrary(sources);
- this.observationService = new ObservationService(this.executionContext.getSessionFactory());
- this.observationService.addListener(this.sequencingService);
}
@After
public void afterEach() throws Exception {
- this.observationService.getAdministrator().shutdown();
- this.observationService.getAdministrator().awaitTermination(5, TimeUnit.SECONDS);
this.sequencingService.getAdministrator().shutdown();
this.sequencingService.getAdministrator().awaitTermination(5, TimeUnit.SECONDS);
- super.shutdownRepository();
}
@Test
@@ -210,108 +186,6 @@
}
@Test
- public void shouldBeAbleToMonitorWorkspaceWhenPausedOrStarted() throws Exception {
- startRepository();
- Session session = getRepository().login(getTestCredentials());
-
- // Try when paused ...
- assertThat(sequencingService.getAdministrator().isPaused(), is(true));
- assertThat(observationService.getAdministrator().pause().isPaused(), is(true));
- ObservationService.WorkspaceListener listener = observationService.monitor(REPOSITORY_SOURCE_NAME, REPOSITORY_WORKSPACE_NAME, Event.NODE_ADDED);
- assertThat(listener, is(notNullValue()));
- assertThat(listener.getAbsolutePath(), is("/"));
- assertThat(listener.getEventTypes(), is(Event.NODE_ADDED));
-
- // Cause an event ...
- session.getRootNode().addNode("testnodeA", "nt:unstructured");
- session.save();
- Thread.sleep(100); // let the events be handled ...
- assertThat(observationService.getStatistics().getNumberOfEventsIgnored(), is((long)1));
-
- // Reset the statistics and remove the listener ...
- sequencingService.getStatistics().reset();
- observationService.getStatistics().reset();
- assertThat(listener.isRegistered(), is(true));
- listener.unregister();
- assertThat(listener.isRegistered(), is(false));
-
- // Start the sequencing sequencingService and try monitoring the workspace ...
- assertThat(sequencingService.getAdministrator().start().isStarted(), is(true));
- assertThat(observationService.getAdministrator().start().isStarted(), is(true));
- ObservationService.WorkspaceListener listener2 = observationService.monitor(REPOSITORY_SOURCE_NAME, REPOSITORY_WORKSPACE_NAME, Event.NODE_ADDED);
- assertThat(listener2.isRegistered(), is(true));
- assertThat(listener2, is(notNullValue()));
- assertThat(listener2.getAbsolutePath(), is("/"));
- assertThat(listener2.getEventTypes(), is(Event.NODE_ADDED));
-
- // Cause an event ...
- session.getRootNode().addNode("testnodeB", "nt:unstructured");
- session.save();
- Thread.sleep(100); // let the events be handled ...
-
- // Check the results: nothing ignored, and 1 node skipped (since no sequencers apply)
- assertThat(observationService.getStatistics().getNumberOfEventsIgnored(), is((long)0));
- assertThat(sequencingService.getStatistics().getNumberOfNodesSkipped(), is((long)1));
-
- sequencingService.getAdministrator().shutdown();
- sequencingService.getStatistics().reset();
- observationService.getAdministrator().shutdown();
- observationService.getStatistics().reset();
-
- // Cause another event ...
- session.getRootNode().addNode("testnodeC", "nt:unstructured");
- session.save();
- Thread.sleep(100); // let the events be handled ...
- // The listener should no longer be registered ...
- assertThat(listener2.isRegistered(), is(false));
-
- // Check the results: nothing ignored, and nothing skipped
- assertThat(observationService.getStatistics().getNumberOfEventsIgnored(), is((long)0));
- assertThat(sequencingService.getStatistics().getNumberOfNodesSkipped(), is((long)0));
- }
-
- @Test
- public void shouldUnregisterAllWorkspaceListenersWhenSystemIsShutdownAndNotWhenPaused() throws Exception {
- startRepository();
- Session session = getRepository().login(getTestCredentials());
-
- // Start the sequencing sequencingService and try monitoring the workspace ...
- assertThat(sequencingService.getAdministrator().start().isStarted(), is(true));
- ObservationService.WorkspaceListener listener = observationService.monitor(REPOSITORY_SOURCE_NAME, REPOSITORY_WORKSPACE_NAME, Event.NODE_ADDED);
- assertThat(listener.isRegistered(), is(true));
- assertThat(listener, is(notNullValue()));
- assertThat(listener.getAbsolutePath(), is("/"));
- assertThat(listener.getEventTypes(), is(Event.NODE_ADDED));
-
- // Cause an event ...
- session.getRootNode().addNode("testnodeB", "nt:unstructured");
- session.save();
- assertThat(listener.isRegistered(), is(true));
-
- // Pause the sequencingService, can cause an event ...
- sequencingService.getAdministrator().pause();
- session.getRootNode().addNode("testnodeB", "nt:unstructured");
- session.save();
- assertThat(listener.isRegistered(), is(true));
-
- // Shut down the services and await termination ...
- sequencingService.getAdministrator().shutdown();
- observationService.getAdministrator().shutdown();
- sequencingService.getAdministrator().awaitTermination(2, TimeUnit.SECONDS);
- observationService.getAdministrator().awaitTermination(2, TimeUnit.SECONDS);
-
- // Cause another event ...
- session.getRootNode().addNode("testnodeC", "nt:unstructured");
- session.save();
-
- // The listener should no longer be registered ...
- assertThat(listener.isRegistered(), is(false));
- }
-
- // FIXME: This test needs to be unignored after the observation service is re-written to not use JCR
-
- @Ignore
- @Test
public void shouldExecuteSequencersUponChangesToRepositoryThatMatchSequencerPathExpressions() throws Exception {
// Add configurations for a sequencer ...
String name = "MockSequencerA";
@@ -319,21 +193,16 @@
String classname = MockSequencerA.class.getName();
String[] classpath = null;
String[] pathExpressions = {"/testnodeC/testnodeD/@description => ."};
- SequencerConfig configA = new SequencerConfig(name, desc, Collections.<String, Object>emptyMap(), classname, classpath, pathExpressions);
+ SequencerConfig configA = new SequencerConfig(name, desc, Collections.<String, Object>emptyMap(), classname, classpath,
+ pathExpressions);
sequencingService.addSequencer(configA);
- // Start the repository and get a session ...
- startRepository();
- Session session = getRepository().login(getTestCredentials());
-
// Start the sequencing sequencingService and try monitoring the workspace ...
assertThat(sequencingService.getAdministrator().start().isStarted(), is(true));
- ObservationService.WorkspaceListener listener = observationService.monitor(REPOSITORY_SOURCE_NAME, REPOSITORY_WORKSPACE_NAME, ALL_EVENT_TYPES);
- assertThat(listener.isRegistered(), is(true));
- assertThat(listener, is(notNullValue()));
- assertThat(listener.getAbsolutePath(), is("/"));
- assertThat(listener.getEventTypes(), is(ALL_EVENT_TYPES));
+ // Create a graph for the source ...
+ Graph graph = Graph.create(sources.getSource(REPOSITORY_SOURCE_NAME), executionContext);
+
// The sequencer should not yet have run ...
MockSequencerA sequencerA = (MockSequencerA)sequencingService.getSequencerLibrary().getInstances().get(0);
assertThat(sequencerA, is(notNullValue()));
@@ -342,22 +211,21 @@
assertThat(sequencingService.getSequencerLibrary().getInstances(), hasItem((Sequencer)sequencerA));
// Cause an event, but not one that the sequencer cares about ...
- Node nodeC = session.getRootNode().addNode("testnodeC", "nt:unstructured");
- assertThat(nodeC, is(notNullValue()));
- session.save();
+ graph.batch().create("/testnodeC").with("jcr:primaryType", "nt:unstructured").and().execute();
+
+ // Verify that our sequencer was not called ...
assertThat(sequencerA.getCounter(), is(0));
assertThat(sequencingService.getSequencerLibrary().getInstances(), hasItem((Sequencer)sequencerA));
// Cause another event, but again one that the sequencer does not care about ...
- Node nodeD = nodeC.addNode("testnodeD", "nt:unstructured");
- assertThat(nodeD, is(notNullValue()));
- session.save();
+ graph.batch().create("/testnodeC/testnodeD").with("jcr:primaryType", "nt:unstructured").and().execute();
+
+ // Verify that our sequencer was not called ...
assertThat(sequencerA.getCounter(), is(0));
assertThat(sequencingService.getSequencerLibrary().getInstances(), hasItem((Sequencer)sequencerA));
// Now set the property that the sequencer DOES care about ...
- nodeD.setProperty("description", "This is the value");
- session.save();
+ graph.batch().set("description").on("/testnodeC/testnodeD").to("This is the value").and().execute();
// Wait for the event to be processed and the sequencer to be called ...
sequencerA.awaitExecution(4, TimeUnit.SECONDS); // wait for the sequencer to be called
Modified: trunk/dna-repository/src/test/java/org/jboss/dna/repository/sequencer/StreamSequencerAdapterTest.java
===================================================================
--- trunk/dna-repository/src/test/java/org/jboss/dna/repository/sequencer/StreamSequencerAdapterTest.java 2009-05-21 19:10:30 UTC (rev 921)
+++ trunk/dna-repository/src/test/java/org/jboss/dna/repository/sequencer/StreamSequencerAdapterTest.java 2009-05-21 22:26:25 UTC (rev 922)
@@ -34,24 +34,26 @@
import java.io.InputStream;
import java.util.Arrays;
import java.util.Collections;
+import java.util.EnumSet;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Set;
-import javax.jcr.observation.Event;
import org.jboss.dna.common.collection.Problems;
import org.jboss.dna.common.collection.SimpleProblems;
import org.jboss.dna.graph.ExecutionContext;
import org.jboss.dna.graph.Graph;
+import org.jboss.dna.graph.Location;
import org.jboss.dna.graph.Node;
import org.jboss.dna.graph.connector.inmemory.InMemoryRepositorySource;
import org.jboss.dna.graph.mimetype.MimeTypeDetectors;
+import org.jboss.dna.graph.observe.NetChangeObserver.ChangeType;
+import org.jboss.dna.graph.observe.NetChangeObserver.NetChange;
import org.jboss.dna.graph.property.Path;
import org.jboss.dna.graph.property.PathNotFoundException;
import org.jboss.dna.graph.property.Property;
import org.jboss.dna.graph.sequencer.SequencerOutput;
import org.jboss.dna.graph.sequencer.StreamSequencer;
import org.jboss.dna.graph.sequencer.StreamSequencerContext;
-import org.jboss.dna.repository.observation.NodeChange;
import org.jboss.dna.repository.util.RepositoryNodePath;
import org.junit.Before;
import org.junit.Test;
@@ -125,8 +127,11 @@
graph.set("sequencedProperty").on("/a/b/c").to(new ByteArrayInputStream(sampleData.getBytes()));
Node inputNode = graph.getNodeAt("/a/b/c");
- NodeChange nodeChange = new NodeChange(repositorySourceName, repositoryWorkspaceName, "/a/b/c", Event.PROPERTY_CHANGED,
- Collections.singleton("sequencedProperty"), null);
+ Location location = Location.create(context.getValueFactories().getPathFactory().create("/a/b/c"));
+ Property sequencedProperty = inputNode.getProperty("sequencedProperty");
+ NetChange nodeChange = new NetChange(repositorySourceName, repositoryWorkspaceName, location,
+ EnumSet.of(ChangeType.PROPERTY_CHANGED), Collections.singleton(sequencedProperty),
+ null);
Set<RepositoryNodePath> outputPaths = new HashSet<RepositoryNodePath>();
outputPaths.add(new RepositoryNodePath(repositorySourceName, repositoryWorkspaceName, "/d/e"));
sequencerOutput.setProperty("alpha/beta", "isSomething", true);
@@ -181,8 +186,11 @@
// Set the property that will be sequenced ...
// Set up the node changes ...
- NodeChange nodeChange = new NodeChange(repositorySourceName, repositoryWorkspaceName, "/a/b/c", Event.PROPERTY_CHANGED,
- Collections.singleton("sequencedProperty"), null);
+ Location location = Location.create(context.getValueFactories().getPathFactory().create("/a/b/c"));
+ Property sequencedProperty = nodeC.getProperty("sequencedProperty");
+ NetChange nodeChange = new NetChange(repositorySourceName, repositoryWorkspaceName, location,
+ EnumSet.of(ChangeType.PROPERTY_CHANGED), Collections.singleton(sequencedProperty),
+ null);
// Set up the output directory ...
Set<RepositoryNodePath> outputPaths = new HashSet<RepositoryNodePath>();
@@ -214,8 +222,11 @@
graph.set("sequencedProperty").on(nodeC.getLocation()).to((String)null);
// Set up the node changes ...
- NodeChange nodeChange = new NodeChange(repositorySourceName, repositoryWorkspaceName, "/a/b/c", Event.PROPERTY_CHANGED,
- Collections.singleton("sequencedProperty"), null);
+ Location location = Location.create(context.getValueFactories().getPathFactory().create("/a/b/c"));
+ Property sequencedProperty = nodeC.getProperty("sequencedProperty");
+ NetChange nodeChange = new NetChange(repositorySourceName, repositoryWorkspaceName, location,
+ EnumSet.of(ChangeType.PROPERTY_CHANGED), Collections.singleton(sequencedProperty),
+ null);
// Set up the output directory ...
Set<RepositoryNodePath> outputPaths = new HashSet<RepositoryNodePath>();
@@ -247,8 +258,11 @@
// assertThat(nodeE.getProperty("jcr:primaryType").getString(), is("nt:unstructured"));
// Set up the node changes ...
- NodeChange nodeChange = new NodeChange(repositorySourceName, repositoryWorkspaceName, "/a/b/c", Event.PROPERTY_CHANGED,
- Collections.singleton("sequencedProperty"), null);
+ Location location = Location.create(context.getValueFactories().getPathFactory().create("/a/b/c"));
+ Property sequencedProperty = nodeC.getProperty("sequencedProperty");
+ NetChange nodeChange = new NetChange(repositorySourceName, repositoryWorkspaceName, location,
+ EnumSet.of(ChangeType.PROPERTY_CHANGED), Collections.singleton(sequencedProperty),
+ null);
// Set up the output directory ...
Set<RepositoryNodePath> outputPaths = new HashSet<RepositoryNodePath>();
@@ -285,8 +299,11 @@
assertThat(nodeC, is(notNullValue()));
// Set up the node changes ...
- NodeChange nodeChange = new NodeChange(repositorySourceName, repositoryWorkspaceName, "/a/b/c", Event.PROPERTY_CHANGED,
- Collections.singleton("sequencedProperty"), null);
+ Location location = Location.create(context.getValueFactories().getPathFactory().create("/a/b/c"));
+ Property sequencedProperty = nodeC.getProperty("sequencedProperty");
+ NetChange nodeChange = new NetChange(repositorySourceName, repositoryWorkspaceName, location,
+ EnumSet.of(ChangeType.PROPERTY_CHANGED), Collections.singleton(sequencedProperty),
+ null);
// Set up the output directory ...
Set<RepositoryNodePath> outputPaths = new HashSet<RepositoryNodePath>();
@@ -327,8 +344,11 @@
assertThat(nodeC, is(notNullValue()));
// Set up the node changes ...
- NodeChange nodeChange = new NodeChange(repositorySourceName, repositoryWorkspaceName, "/a/b/c", Event.PROPERTY_CHANGED,
- Collections.singleton("sequencedProperty"), null);
+ Location location = Location.create(context.getValueFactories().getPathFactory().create("/a/b/c"));
+ Property sequencedProperty = nodeC.getProperty("sequencedProperty");
+ NetChange nodeChange = new NetChange(repositorySourceName, repositoryWorkspaceName, location,
+ EnumSet.of(ChangeType.PROPERTY_CHANGED), Collections.singleton(sequencedProperty),
+ null);
// Set up the output directory ...
Set<RepositoryNodePath> outputPaths = new HashSet<RepositoryNodePath>();
Modified: trunk/docs/examples/gettingstarted/sequencers/pom.xml
===================================================================
--- trunk/docs/examples/gettingstarted/sequencers/pom.xml 2009-05-21 19:10:30 UTC (rev 921)
+++ trunk/docs/examples/gettingstarted/sequencers/pom.xml 2009-05-21 22:26:25 UTC (rev 922)
@@ -18,7 +18,7 @@
<dependencies>
<dependency>
<groupId>org.jboss.dna</groupId>
- <artifactId>dna-repository</artifactId>
+ <artifactId>dna-jcr</artifactId>
<version>${pom.version}</version>
<scope>compile</scope>
</dependency>
Modified: trunk/docs/examples/gettingstarted/sequencers/src/main/java/org/jboss/example/dna/sequencer/SequencingClient.java
===================================================================
--- trunk/docs/examples/gettingstarted/sequencers/src/main/java/org/jboss/example/dna/sequencer/SequencingClient.java 2009-05-21 19:10:30 UTC (rev 921)
+++ trunk/docs/examples/gettingstarted/sequencers/src/main/java/org/jboss/example/dna/sequencer/SequencingClient.java 2009-05-21 22:26:25 UTC (rev 922)
@@ -44,11 +44,9 @@
import javax.jcr.SimpleCredentials;
import javax.jcr.Value;
import javax.jcr.ValueFormatException;
-import javax.jcr.observation.Event;
import org.apache.jackrabbit.api.JackrabbitNodeTypeManager;
import org.apache.jackrabbit.core.TransientRepository;
import org.jboss.dna.common.SystemFailureException;
-import org.jboss.dna.repository.observation.ObservationService;
import org.jboss.dna.repository.sequencer.SequencerConfig;
import org.jboss.dna.repository.sequencer.SequencingService;
import org.jboss.dna.repository.util.JcrExecutionContext;
@@ -83,7 +81,6 @@
private Session keepAliveSession;
private Repository repository;
private SequencingService sequencingService;
- private ObservationService observationService;
private UserInterface userInterface;
private JcrExecutionContext executionContext;
@@ -225,7 +222,7 @@
// Create the sequencing service, passing in the execution context and the repository library ...
this.sequencingService = new SequencingService();
this.sequencingService.setExecutionContext(executionContext);
- //this.sequencingService.setRepositoryLibrary(repositoryLibrary);
+ // this.sequencingService.setRepositoryLibrary(repositoryLibrary);
// Configure the sequencers. In this example, we only two sequencers that processes image and mp3 files.
// So create a configurations. Note that the sequencing service expects the class to be on the thread's current
@@ -264,14 +261,6 @@
String[] javaPathExpressions = {"//(*.java[*])/jcr:content[@jcr:data] => /java/$1"};
SequencerConfig javaSequencerConfig = new SequencerConfig(name, desc, classname, classpath, javaPathExpressions);
this.sequencingService.addSequencer(javaSequencerConfig);
-
- // Use the DNA observation service to listen to the JCR repository (or multiple ones), and
- // then register the sequencing service as a listener to this observation service...
- this.observationService = new ObservationService(this.executionContext.getSessionFactory());
- this.observationService.getAdministrator().start();
- this.observationService.addListener(this.sequencingService);
- this.observationService.monitor(this.repositoryName, repositoryWorkspaceName, Event.NODE_ADDED | Event.PROPERTY_ADDED
- | Event.PROPERTY_CHANGED);
}
// Start up the sequencing service ...
this.sequencingService.getAdministrator().start();
@@ -288,12 +277,6 @@
// Shut down the service and wait until it's all shut down ...
this.sequencingService.getAdministrator().shutdown();
this.sequencingService.getAdministrator().awaitTermination(5, TimeUnit.SECONDS);
-
- if (this.observationService != null) {
- // Shut down the observation service ...
- this.observationService.getAdministrator().shutdown();
- this.observationService.getAdministrator().awaitTermination(5, TimeUnit.SECONDS);
- }
}
/**
@@ -318,10 +301,10 @@
String mimeType = getMimeType(url);
if (mimeType == null) {
- System.err.println("Could not determine mime type for file. Cancelling upload.");
- return;
+ System.err.println("Could not determine mime type for file. Cancelling upload.");
+ return;
}
-
+
// Now use the JCR API to upload the file ...
Session session = createSession();
JcrTools tools = this.executionContext.getTools();
Modified: trunk/docs/examples/gettingstarted/sequencers/src/test/java/org/jboss/example/dna/sequencer/SequencingClientTest.java
===================================================================
--- trunk/docs/examples/gettingstarted/sequencers/src/test/java/org/jboss/example/dna/sequencer/SequencingClientTest.java 2009-05-21 19:10:30 UTC (rev 921)
+++ trunk/docs/examples/gettingstarted/sequencers/src/test/java/org/jboss/example/dna/sequencer/SequencingClientTest.java 2009-05-21 22:26:25 UTC (rev 922)
@@ -91,6 +91,7 @@
}
+ @Ignore
@Test
public void shouldStartupAndShutdownRepositoryAndSequencingService() throws Exception {
client.startRepository();
@@ -139,6 +140,7 @@
assertThat(client.getStatistics().getNumberOfNodesSequenced(), is(1l));
}
+ @Ignore
@Test
public void shouldUploadAndNotSequencePictFile() throws Exception {
client.setUserInterface(new MockUserInterface(this.pictImageUrl, "/a/b/caution.pict", 0));
15 years, 1 month
DNA SVN: r921 - in trunk: dna-graph/src/test/java/org/jboss/dna/graph/mimetype and 6 other directories.
by dna-commits@lists.jboss.org
Author: rhauch
Date: 2009-05-21 15:10:30 -0400 (Thu, 21 May 2009)
New Revision: 921
Added:
trunk/dna-graph/src/main/java/org/jboss/dna/graph/mimetype/MimeTypeDetectorConfig.java
trunk/dna-graph/src/main/java/org/jboss/dna/graph/mimetype/MimeTypeDetectors.java
trunk/dna-graph/src/test/java/org/jboss/dna/graph/mimetype/AbstractMimeTypeTest.java
Removed:
trunk/dna-repository/src/main/java/org/jboss/dna/repository/mimetype/MimeTypeDetectorConfig.java
trunk/dna-repository/src/main/java/org/jboss/dna/repository/mimetype/MimeTypeDetectors.java
trunk/dna-repository/src/test/java/org/jboss/dna/repository/mimetype/AbstractMimeTypeTest.java
Modified:
trunk/dna-repository/src/main/java/org/jboss/dna/repository/DnaEngine.java
trunk/dna-repository/src/test/java/org/jboss/dna/repository/sequencer/StreamSequencerAdapterTest.java
trunk/extensions/dna-mimetype-detector-aperture/pom.xml
trunk/extensions/dna-mimetype-detector-aperture/src/test/java/org/jboss/dna/mimetype/aperture/MimeTypeTest.java
Log:
DNA-404 Remove ObservationService, migrate usage to observe RepositoryLibrary
Moved the MimeTypeDetectors and MimeTypeDetectorConfig classes into 'dna-graph'.
Copied: trunk/dna-graph/src/main/java/org/jboss/dna/graph/mimetype/MimeTypeDetectorConfig.java (from rev 920, trunk/dna-repository/src/main/java/org/jboss/dna/repository/mimetype/MimeTypeDetectorConfig.java)
===================================================================
--- trunk/dna-graph/src/main/java/org/jboss/dna/graph/mimetype/MimeTypeDetectorConfig.java (rev 0)
+++ trunk/dna-graph/src/main/java/org/jboss/dna/graph/mimetype/MimeTypeDetectorConfig.java 2009-05-21 19:10:30 UTC (rev 921)
@@ -0,0 +1,55 @@
+/*
+ * 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.mimetype;
+
+import java.util.Map;
+import org.jboss.dna.common.component.ComponentConfig;
+import org.jboss.dna.graph.mimetype.MimeTypeDetector;
+
+/**
+ * @author jverhaeg
+ */
+public class MimeTypeDetectorConfig extends ComponentConfig {
+
+ public MimeTypeDetectorConfig( String name,
+ String description,
+ Map<String, Object> properties,
+ String classname,
+ String[] classpath ) {
+ super(name, description, properties, classname, classpath);
+ }
+
+ public MimeTypeDetectorConfig( String name,
+ String description,
+ Map<String, Object> properties,
+ Class<? extends MimeTypeDetector> clazz ) {
+ super(name, description, properties, clazz.getName());
+ }
+
+ public MimeTypeDetectorConfig( String name,
+ String description,
+ Class<? extends MimeTypeDetector> clazz ) {
+ super(name, description, clazz.getName());
+ }
+}
Property changes on: trunk/dna-graph/src/main/java/org/jboss/dna/graph/mimetype/MimeTypeDetectorConfig.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Copied: trunk/dna-graph/src/main/java/org/jboss/dna/graph/mimetype/MimeTypeDetectors.java (from rev 920, trunk/dna-repository/src/main/java/org/jboss/dna/repository/mimetype/MimeTypeDetectors.java)
===================================================================
--- trunk/dna-graph/src/main/java/org/jboss/dna/graph/mimetype/MimeTypeDetectors.java (rev 0)
+++ trunk/dna-graph/src/main/java/org/jboss/dna/graph/mimetype/MimeTypeDetectors.java 2009-05-21 19:10:30 UTC (rev 921)
@@ -0,0 +1,162 @@
+/*
+ * 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.mimetype;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.concurrent.atomic.AtomicReference;
+import net.jcip.annotations.ThreadSafe;
+import org.jboss.dna.common.component.ClassLoaderFactory;
+import org.jboss.dna.common.component.ComponentLibrary;
+import org.jboss.dna.common.component.StandardClassLoaderFactory;
+import org.jboss.dna.common.util.Logger;
+import org.jboss.dna.graph.mimetype.MimeTypeDetector;
+
+/**
+ * Facility for managing {@link MimeTypeDetectorConfig}s.
+ *
+ * @author jverhaeg
+ */
+@ThreadSafe
+public final class MimeTypeDetectors implements MimeTypeDetector {
+
+ /**
+ * Class loader factory instance that always returns the {@link Thread#getContextClassLoader() current thread's context class
+ * loader}, or if <code>null</code> the class loader for this class.
+ */
+ protected static final ClassLoaderFactory DEFAULT_CLASSLOADER_FACTORY = new StandardClassLoaderFactory(
+ MimeTypeDetectors.class.getClassLoader());
+
+ private final ComponentLibrary<MimeTypeDetector, MimeTypeDetectorConfig> library;
+ private final AtomicReference<Logger> logger;
+
+ public MimeTypeDetectors() {
+ logger = new AtomicReference<Logger>(Logger.getLogger(getClass()));
+ library = new ComponentLibrary<MimeTypeDetector, MimeTypeDetectorConfig>(true);
+ library.setClassLoaderFactory(DEFAULT_CLASSLOADER_FACTORY);
+ }
+
+ /**
+ * Adds the configuration for a MIME-type detector <em>before</em> any previously added configurations, or updates any
+ * existing one that represents the {@link MimeTypeDetectorConfig#equals(Object) same configuration}
+ *
+ * @param config the new configuration; must not be <code>null</code>.
+ * @return <code>true</code> if the detector was added, or <code>false</code> if there already was an existing detector
+ * configuration.
+ * @see #removeDetector(MimeTypeDetectorConfig)
+ */
+ public boolean addDetector( MimeTypeDetectorConfig config ) {
+ return library.add(config);
+ }
+
+ /**
+ * Gets the class loader factory that should be used to load MIME-type detectors. By default, this service uses a factory that
+ * will return either the {@link Thread#getContextClassLoader() current thread's context class loader}, or if
+ * <code>null</code> the class loader for this class.
+ *
+ * @return the class loader factory; never <code>null</code>
+ * @see #setClassLoaderFactory(ClassLoaderFactory)
+ */
+ public ClassLoaderFactory getClassLoaderFactory() {
+ return library.getClassLoaderFactory();
+ }
+
+ /**
+ * Gets the logger for this system
+ *
+ * @return the logger
+ */
+ public Logger getLogger() {
+ return logger.get();
+ }
+
+ /**
+ * Returns the first non-null result of iterating over the {@link #addDetector(MimeTypeDetectorConfig) registered} MIME-type
+ * detectors in the reverse order in which they were registered to determine the MIME-type of a data source, using its
+ * supplied content and/or its supplied name, depending upon the implementation. If the MIME-type cannot be determined by any
+ * registered detector, "text/plain" or "application/octet-stream" will be returned, the former only if it is determined the
+ * stream contains no nulls.
+ *
+ * @param name The name of the data source; may be <code>null</code>.
+ * @param content The content of the data source; may be <code>null</code>.
+ * @return The MIME-type of the data source; never <code>null</code>.
+ * @throws IOException If an error occurs reading the supplied content.
+ */
+ public String mimeTypeOf( String name,
+ InputStream content ) throws IOException {
+ if (content != null && content.markSupported()) {
+ content.mark(Integer.MAX_VALUE);
+ }
+ // Check if registered detectors can determine MIME-type
+ for (MimeTypeDetector detector : library.getInstances()) {
+ String mimeType = detector.mimeTypeOf(name, content);
+ if (mimeType != null) return mimeType;
+ }
+ // If not, try to analyze stream to determine if it represents text or binary content
+ if (content != null && content.markSupported()) {
+ try {
+ content.reset();
+ for (int chr = content.read(); chr >= 0; chr = content.read()) {
+ if (chr == 0) return "application/octet-stream";
+ }
+ } catch (IOException meansTooManyBytesRead) {
+ return "application/octet-stream";
+ }
+ }
+ return "text/plain";
+ }
+
+ /**
+ * Removes the configuration for a MIME-type detector.
+ *
+ * @param config the configuration to be removed; must not be <code>null</code>.
+ * @return <code>true</code> if the configuration was removed, or <code>false</code> if there was no existing configuration
+ * @see #addDetector(MimeTypeDetectorConfig)
+ */
+ public boolean removeDetector( MimeTypeDetectorConfig config ) {
+ return library.remove(config);
+ }
+
+ /**
+ * Sets the Maven Repository that should be used to load the MIME-type detectors. By default, this service uses a factory that
+ * will return either the {@link Thread#getContextClassLoader() current thread's context class loader}, or if
+ * <code>null</code> the class loader for this class.
+ *
+ * @param classLoaderFactory the class loader factory, or <code>null</code> if the default class loader factory should be
+ * used.
+ * @see #getClassLoaderFactory()
+ */
+ public void setClassLoaderFactory( ClassLoaderFactory classLoaderFactory ) {
+ library.setClassLoaderFactory(classLoaderFactory != null ? classLoaderFactory : DEFAULT_CLASSLOADER_FACTORY);
+ }
+
+ /**
+ * Sets the logger for this system.
+ *
+ * @param logger the logger, or <code>null</code> if the standard logging should be used
+ */
+ public void setLogger( Logger logger ) {
+ this.logger.set(logger != null ? logger : Logger.getLogger(getClass()));
+ }
+}
Property changes on: trunk/dna-graph/src/main/java/org/jboss/dna/graph/mimetype/MimeTypeDetectors.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Copied: trunk/dna-graph/src/test/java/org/jboss/dna/graph/mimetype/AbstractMimeTypeTest.java (from rev 920, trunk/dna-repository/src/test/java/org/jboss/dna/repository/mimetype/AbstractMimeTypeTest.java)
===================================================================
--- trunk/dna-graph/src/test/java/org/jboss/dna/graph/mimetype/AbstractMimeTypeTest.java (rev 0)
+++ trunk/dna-graph/src/test/java/org/jboss/dna/graph/mimetype/AbstractMimeTypeTest.java 2009-05-21 19:10:30 UTC (rev 921)
@@ -0,0 +1,1417 @@
+/*
+ * 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.mimetype;
+
+import static org.hamcrest.core.Is.is;
+import static org.hamcrest.core.IsNull.notNullValue;
+import static org.junit.Assert.assertThat;
+import java.io.File;
+import java.io.InputStream;
+import java.util.Collections;
+import org.jboss.dna.graph.mimetype.MimeTypeDetector;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+/**
+ * All test classes that test {@link MimeTypeDetector MIME-type detector implementations} should extend this class to help ensure
+ * all implementations test the same types of data sources.
+ *
+ * @author John Verhaeg
+ */
+public abstract class AbstractMimeTypeTest {
+
+ private final MimeTypeDetectorConfig config;
+ private MimeTypeDetectors detectors;
+
+ protected AbstractMimeTypeTest( Class<? extends MimeTypeDetector> detector ) {
+ assertThat(detector, notNullValue());
+ this.config = new MimeTypeDetectorConfig("MIME-Type Detector", "MIME-Type Detector",
+ Collections.<String, Object>emptyMap(), detector.getName(), null);
+ }
+
+ @Before
+ public void before() throws Exception {
+ detectors = new MimeTypeDetectors();
+ detectors.addDetector(config);
+ }
+
+ @After
+ public void after() {
+ detectors.removeDetector(config);
+ }
+
+ protected void testMimeType( String name,
+ String mimeType ) throws Exception {
+ InputStream content = new File("../../dna-repository/src/test/resources/" + name).toURI().toURL().openStream();
+ assertThat(detectors.mimeTypeOf(name, content), is(mimeType));
+ }
+
+ protected abstract String expectedMimeTypeForText_test_txt();
+
+ protected abstract String expectedMimeTypeForText_plain_text_txt();
+
+ protected abstract String expectedMimeTypeForText_plain_text_ansi_txt();
+
+ protected abstract String expectedMimeTypeForText_plain_text_empty_txt();
+
+ protected abstract String expectedMimeTypeForText_plain_text_utf16be_txt();
+
+ protected abstract String expectedMimeTypeForText_plain_text_utf16le_txt();
+
+ protected abstract String expectedMimeTypeForText_plain_text_utf8_txt();
+
+ protected abstract String expectedMimeTypeForText_plain_text_with_null_character_txt();
+
+ protected abstract String expectedMimeTypeForText_plain_text_without_extension();
+
+ protected abstract String expectedMimeTypeForRtf_test_rtf();
+
+ protected abstract String expectedMimeTypeForRtf_rtf_openoffice_1_1_5_rtf();
+
+ protected abstract String expectedMimeTypeForRtf_rtf_openoffice_2_0_rtf();
+
+ protected abstract String expectedMimeTypeForRtf_rtf_staroffice_5_2_rtf();
+
+ protected abstract String expectedMimeTypeForRtf_rtf_word_2000_rtf();
+
+ protected abstract String expectedMimeTypeForMp3_test_mp3();
+
+ protected abstract String expectedMimeTypeForMp3_test_128_44_jstereo_mp3();
+
+ protected abstract String expectedMimeTypeForMp3_jingle1_mp3();
+
+ protected abstract String expectedMimeTypeForMp3_jingle2_mp3();
+
+ protected abstract String expectedMimeTypeForMp3_jingle3_mp3();
+
+ protected abstract String expectedMimeTypeForWav();
+
+ protected abstract String expectedMimeTypeForBmp();
+
+ protected abstract String expectedMimeTypeForGif();
+
+ protected abstract String expectedMimeTypeForIcon();
+
+ protected abstract String expectedMimeTypeForJpeg_test_jpg();
+
+ protected abstract String expectedMimeTypeForJpeg_jpg_exif_img_9367_JPG();
+
+ protected abstract String expectedMimeTypeForJpeg_jpg_exif_zerolength_jpg();
+
+ protected abstract String expectedMimeTypeForJpeg_jpg_geotagged_jpg();
+
+ protected abstract String expectedMimeTypeForJpeg_jpg_geotagged_ipanema_jpg();
+
+ protected abstract String expectedMimeTypeForPortablePixelMap_test_ppm();
+
+ protected abstract String expectedMimeTypeForPortablePixelMap_test_pnm();
+
+ protected abstract String expectedMimeTypeForPng();
+
+ protected abstract String expectedMimeTypeForTiff();
+
+ protected abstract String expectedMimeTypeForTga();
+
+ protected abstract String expectedMimeTypeForWmf();
+
+ protected abstract String expectedMimeTypeForXcf();
+
+ protected abstract String expectedMimeTypeForXpm();
+
+ protected abstract String expectedMimeTypeForXml_test_xml();
+
+ protected abstract String expectedMimeTypeForXml_test_excel_spreadsheet_xml();
+
+ protected abstract String expectedMimeTypeForXml_CurrencyFormatterExample_mxml();
+
+ protected abstract String expectedMimeTypeForXml_xml_handwritten_xml();
+
+ protected abstract String expectedMimeTypeForXml_xml_nonexistent_dtd_xml();
+
+ protected abstract String expectedMimeTypeForXml_xml_nonexistent_remote_dtd_xml();
+
+ protected abstract String expectedMimeTypeForXml_xml_nonexistent_remote_xsd_xml();
+
+ protected abstract String expectedMimeTypeForXml_xml_nonexistent_xsd_xml();
+
+ protected abstract String expectedMimeTypeForXml_xml_utf8_bom();
+
+ protected abstract String expectedMimeTypeForXsd();
+
+ protected abstract String expectedMimeTypeForDtd();
+
+ protected abstract String expectedMimeTypeForHtml_master_xml();
+
+ protected abstract String expectedMimeTypeForHtml_html_condenast_html();
+
+ protected abstract String expectedMimeTypeForHtml_html_handwritten_html();
+
+ protected abstract String expectedMimeTypeForHtml_html_handwritten_with_wrong_file_extension_txt();
+
+ protected abstract String expectedMimeTypeForHtml_html_quelle_de_html();
+
+ protected abstract String expectedMimeTypeForHtml_html_utf16_leading_whitespace_wrong_extension_doc();
+
+ protected abstract String expectedMimeTypeForJava();
+
+ protected abstract String expectedMimeTypeFor1_2Class();
+
+ protected abstract String expectedMimeTypeFor1_3Class();
+
+ protected abstract String expectedMimeTypeFor1_4Class();
+
+ protected abstract String expectedMimeTypeForPerl();
+
+ protected abstract String expectedMimeTypeForPython();
+
+ protected abstract String expectedMimeTypeForPdf_test_pdf();
+
+ protected abstract String expectedMimeTypeForPdf_pdf_distiller_6_weirdchars_pdf();
+
+ protected abstract String expectedMimeTypeForPdf_pdf_no_author_pdf();
+
+ protected abstract String expectedMimeTypeForPdf_pdf_openoffice_1_1_5_writer_pdf();
+
+ protected abstract String expectedMimeTypeForPdf_pdf_openoffice_2_0_writer_pdf();
+
+ protected abstract String expectedMimeTypeForPdf_pdf_word_2000_pdfcreator_0_8_0_pdf();
+
+ protected abstract String expectedMimeTypeForPdf_pdf_word_2000_pdfmaker_7_0_pdf();
+
+ protected abstract String expectedMimeTypeForPdf_pdf_word_2000_pdfwriter_7_0_pdf();
+
+ protected abstract String expectedMimeTypeForPostscript_test_ps();
+
+ protected abstract String expectedMimeTypeForPostscript_test_eps();
+
+ protected abstract String expectedMimeTypeForJar();
+
+ protected abstract String expectedMimeTypeForJavaManifest();
+
+ protected abstract String expectedMimeTypeForGZip_test_tar_gz();
+
+ protected abstract String expectedMimeTypeForGZip_test_txt_gz();
+
+ protected abstract String expectedMimeTypeForZip();
+
+ protected abstract String expectedMimeTypeForBash();
+
+ protected abstract String expectedMimeTypeForOgg();
+
+ protected abstract String expectedMimeTypeForOpenDocumentFormula();
+
+ protected abstract String expectedMimeTypeForOpenDocumentGraphics();
+
+ protected abstract String expectedMimeTypeForOpenDocumentGraphicsTemplate();
+
+ protected abstract String expectedMimeTypeForOpenDocumentPresentation_component_architecture_odp();
+
+ protected abstract String expectedMimeTypeForOpenDocumentPresentation_openoffice_2_0_impress_odp();
+
+ protected abstract String expectedMimeTypeForOpenDocumentPresentationTemplate();
+
+ protected abstract String expectedMimeTypeForOpenDocumentSpreadsheet();
+
+ protected abstract String expectedMimeTypeForOpenDocumentSpreadsheetTemplate();
+
+ protected abstract String expectedMimeTypeForOpenDocumentText();
+
+ protected abstract String expectedMimeTypeForOpenDocumentTextTemplate();
+
+ protected abstract String expectedMimeTypeForOpenOfficeCalc();
+
+ protected abstract String expectedMimeTypeForOpenOfficeCalcTemplate();
+
+ protected abstract String expectedMimeTypeForOpenOfficeDraw();
+
+ protected abstract String expectedMimeTypeForOpenOfficeDrawTemplate();
+
+ protected abstract String expectedMimeTypeForOpenOfficeImpress();
+
+ protected abstract String expectedMimeTypeForOpenOfficeImpressTemplate();
+
+ protected abstract String expectedMimeTypeForOpenOfficeWriter();
+
+ protected abstract String expectedMimeTypeForOpenOfficeWriterTemplate();
+
+ protected abstract String expectedMimeTypeForStarOfficeCalc();
+
+ protected abstract String expectedMimeTypeForStarOfficeDraw();
+
+ protected abstract String expectedMimeTypeForStarOfficeImpress();
+
+ protected abstract String expectedMimeTypeForStarOfficeWriter();
+
+ protected abstract String expectedMimeTypeForStarOfficeCalcTemplate();
+
+ protected abstract String expectedMimeTypeForStarOfficeDrawTemplate();
+
+ protected abstract String expectedMimeTypeForStarOfficeImpressTemplate();
+
+ protected abstract String expectedMimeTypeForStarOfficeWriterTemplate();
+
+ protected abstract String expectedMimeTypeForWord_test_word_2000_doc();
+
+ protected abstract String expectedMimeTypeForWord_test_word_6_0_95_doc();
+
+ protected abstract String expectedMimeTypeForWord_microsoft_word_2000_doc();
+
+ protected abstract String expectedMimeTypeForWord_microsoft_word_2000_with_wrong_file_extension_pdf();
+
+ protected abstract String expectedMimeTypeForWord_microsoft_word_2007beta2_docm();
+
+ protected abstract String expectedMimeTypeForWord_microsoft_word_2007beta2_docx();
+
+ protected abstract String expectedMimeTypeForWord_microsoft_word_2007beta2_dotm();
+
+ protected abstract String expectedMimeTypeForWord_microsoft_word_2007beta2_dotx();
+
+ protected abstract String expectedMimeTypeForWorks_microsoft_works_spreadsheet_4_0_2000_wks();
+
+ protected abstract String expectedMimeTypeForWorks_microsoft_works_spreadsheet_7_0_xlr();
+
+ protected abstract String expectedMimeTypeForWorks_microsoft_works_word_processor_2000_wps();
+
+ protected abstract String expectedMimeTypeForWorks_microsoft_works_word_processor_3_0_wps();
+
+ protected abstract String expectedMimeTypeForWorks_microsoft_works_word_processor_4_0_wps();
+
+ protected abstract String expectedMimeTypeForWorks_microsoft_works_word_processor_7_0_wps();
+
+ protected abstract String expectedMimeTypeForWorkbook_corel_quattro_pro_6_wb2();
+
+ protected abstract String expectedMimeTypeForWorkbook_microsoft_works_spreadsheet_3_0_wks();
+
+ protected abstract String expectedMimeTypeForExcel_test_excel_2000_xls();
+
+ protected abstract String expectedMimeTypeForExcel_microsoft_excel_2000_xls();
+
+ protected abstract String expectedMimeTypeForExcel_microsoft_excel_2007beta2_xlam();
+
+ protected abstract String expectedMimeTypeForExcel_microsoft_excel_2007beta2_xlsb();
+
+ protected abstract String expectedMimeTypeForExcel_microsoft_excel_2007beta2_xlsm();
+
+ protected abstract String expectedMimeTypeForExcel_microsoft_excel_2007beta2_xlsx();
+
+ protected abstract String expectedMimeTypeForExcel_microsoft_excel_2007beta2_xltm();
+
+ protected abstract String expectedMimeTypeForExcel_microsoft_excel_2007beta2_xltx();
+
+ protected abstract String expectedMimeTypeForPowerpoint_test_ppt();
+
+ protected abstract String expectedMimeTypeForPowerpoint_microsoft_powerpoint_2000_ppt();
+
+ protected abstract String expectedMimeTypeForPowerpoint_microsoft_powerpoint_2007beta2_potm();
+
+ protected abstract String expectedMimeTypeForPowerpoint_microsoft_powerpoint_2007beta2_potx();
+
+ protected abstract String expectedMimeTypeForPowerpoint_microsoft_powerpoint_2007beta2_ppsm();
+
+ protected abstract String expectedMimeTypeForPowerpoint_microsoft_powerpoint_2007beta2_ppsx();
+
+ protected abstract String expectedMimeTypeForPowerpoint_microsoft_powerpoint_2007beta2_pptm();
+
+ protected abstract String expectedMimeTypeForPowerpoint_microsoft_powerpoint_2007beta2_pptx();
+
+ protected abstract String expectedMimeTypeForPublisher();
+
+ protected abstract String expectedMimeTypeForVisio();
+
+ protected abstract String expectedMimeTypeForOutlook();
+
+ protected abstract String expectedMimeTypeForShw_corel_presentations_3_0_shw();
+
+ protected abstract String expectedMimeTypeForShw_corel_presentations_x3_shw();
+
+ protected abstract String expectedMimeTypeForPro_corel_quattro_pro_7_wb3();
+
+ protected abstract String expectedMimeTypeForPro_corel_quattro_pro_x3_qpw();
+
+ protected abstract String expectedMimeTypeForWordperfect_corel_wordperfect_4_2_wp();
+
+ protected abstract String expectedMimeTypeForWordperfect_corel_wordperfect_5_0_wp();
+
+ protected abstract String expectedMimeTypeForWordperfect_corel_wordperfect_5_1_wp();
+
+ protected abstract String expectedMimeTypeForWordperfect_corel_wordperfect_5_1_far_east_wp();
+
+ protected abstract String expectedMimeTypeForWordperfect_corel_wordperfect_x3_wpd();
+
+ protected abstract String expectedMimeTypeForMail_test_excel_web_archive_mht();
+
+ protected abstract String expectedMimeTypeForMail_mail_thunderbird_1_5_eml();
+
+ protected abstract String expectedMimeTypeForMail_mhtml_firefox_mht();
+
+ protected abstract String expectedMimeTypeForMail_mhtml_internet_explorer_mht();
+
+ protected abstract String expectedMimeTypeForAddressBook();
+
+ protected abstract String expectedMimeTypeForVCard_vcard_antoni_kontact_vcf();
+
+ protected abstract String expectedMimeTypeForVCard_vcard_antoni_outlook2003_vcf();
+
+ protected abstract String expectedMimeTypeForVCard_vcard_dirk_vcf();
+
+ protected abstract String expectedMimeTypeForVCard_vcard_rfc2426_vcf();
+
+ protected abstract String expectedMimeTypeForVCard_vcard_vCards_SAP_vcf();
+
+ protected abstract String expectedMimeTypeForCalendar_basicCalendar_ics();
+
+ protected abstract String expectedMimeTypeForCalendar_cal01_ics();
+
+ protected abstract String expectedMimeTypeForCalendar_cal01_1_ics();
+
+ protected abstract String expectedMimeTypeForCalendar_cal01_2_ics();
+
+ protected abstract String expectedMimeTypeForCalendar_cal01_3_ics();
+
+ protected abstract String expectedMimeTypeForCalendar_cal01_4_ics();
+
+ protected abstract String expectedMimeTypeForCalendar_cal01_5_ics();
+
+ protected abstract String expectedMimeTypeForCalendar_cal01_6_ics();
+
+ protected abstract String expectedMimeTypeForCalendar_cal01_exrule_ics();
+
+ protected abstract String expectedMimeTypeForCalendar_calconnect7_ics();
+
+ protected abstract String expectedMimeTypeForCalendar_calconnect9_ics();
+
+ protected abstract String expectedMimeTypeForCalendar_combined_multiplevcalendar_ics();
+
+ protected abstract String expectedMimeTypeForCalendar_combined_onevcalendar_ics();
+
+ protected abstract String expectedMimeTypeForCalendar_extendedCalendar_ics();
+
+ protected abstract String expectedMimeTypeForCalendar_freebusy_ics();
+
+ protected abstract String expectedMimeTypeForCalendar_geol_ics();
+
+ protected abstract String expectedMimeTypeForCalendar_gkexample_ics();
+
+ protected abstract String expectedMimeTypeForCalendar_incoming_ics();
+
+ protected abstract String expectedMimeTypeForCalendar_korganizer_jicaltest_vjournal_ics();
+
+ protected abstract String expectedMimeTypeForCalendar_korganizer_jicaltest_ics();
+
+ protected abstract String expectedMimeTypeForCalendar_php_flp_ics();
+
+ protected abstract String expectedMimeTypeForCalendar_simplevevent_ics();
+
+ protected abstract String expectedMimeTypeForCalendar_sunbird_sample_ics();
+
+ protected abstract String expectedMimeTypeForCalendar_tag_bug_ics();
+
+ protected abstract String expectedMimeTypeForCalendar_test_created_ics();
+
+ protected abstract String expectedMimeTypeForCalendar_Todos1_ics();
+
+ protected abstract String expectedMimeTypeForAu();
+
+ protected abstract String expectedMimeTypeForBin();
+
+ protected abstract String expectedMimeTypeForEmf();
+
+ protected abstract String expectedMimeTypeForFli();
+
+ protected abstract String expectedMimeTypeForPcx();
+
+ protected abstract String expectedMimeTypeForPict();
+
+ protected abstract String expectedMimeTypeForPsd();
+
+ protected abstract String expectedMimeTypeForTar();
+
+ @Test
+ public void shouldProvideMimeTypeForText_test_txt() throws Exception {
+ testMimeType("test.txt", expectedMimeTypeForText_test_txt());
+ }
+
+ @Test
+ public void shouldProvideMimeTypeForText_plain_text_txt() throws Exception {
+ testMimeType("docs/plain-text.txt", expectedMimeTypeForText_plain_text_txt());
+ }
+
+ @Test
+ public void shouldProvideMimeTypeForText_plain_text_ansi_txt() throws Exception {
+ testMimeType("docs/plain-text-ansi.txt", expectedMimeTypeForText_plain_text_ansi_txt());
+ }
+
+ @Test
+ public void shouldProvideMimeTypeForText_plain_text_empty_txt() throws Exception {
+ testMimeType("docs/plain-text-empty.txt", expectedMimeTypeForText_plain_text_empty_txt());
+ }
+
+ @Test
+ public void shouldProvideMimeTypeForText_plain_text_utf16be_txt() throws Exception {
+ testMimeType("docs/plain-text-utf16be.txt", expectedMimeTypeForText_plain_text_utf16be_txt());
+ }
+
+ @Test
+ public void shouldProvideMimeTypeForText_plain_text_utf16le_txt() throws Exception {
+ testMimeType("docs/plain-text-utf16le.txt", expectedMimeTypeForText_plain_text_utf16le_txt());
+ }
+
+ @Test
+ public void shouldProvideMimeTypeForText_plain_text_utf8_txt() throws Exception {
+ testMimeType("docs/plain-text-utf8.txt", expectedMimeTypeForText_plain_text_utf8_txt());
+ }
+
+ @Test
+ public void shouldProvideMimeTypeForText_plain_text_with_null_character_txt() throws Exception {
+ testMimeType("docs/plain-text-with-null-character.txt", expectedMimeTypeForText_plain_text_with_null_character_txt());
+ }
+
+ @Test
+ public void shouldProvideMimeTypeForText_plain_text_without_extension() throws Exception {
+ testMimeType("docs/plain-text-without-extension", expectedMimeTypeForText_plain_text_without_extension());
+ }
+
+ @Test
+ public void shouldProvideMimeTypeForRtf_test_rtf() throws Exception {
+ testMimeType("test.rtf", expectedMimeTypeForRtf_test_rtf());
+ }
+
+ @Test
+ public void shouldProvideMimeTypeForRtf_rtf_openoffice_1_1_5_rtf() throws Exception {
+ testMimeType("docs/rtf-openoffice-1.1.5.rtf", expectedMimeTypeForRtf_rtf_openoffice_1_1_5_rtf());
+ }
+
+ @Test
+ public void shouldProvideMimeTypeForRtf_rtf_openoffice_2_0_rtf() throws Exception {
+ testMimeType("docs/rtf-openoffice-2.0.rtf", expectedMimeTypeForRtf_rtf_openoffice_2_0_rtf());
+ }
+
+ @Test
+ public void shouldProvideMimeTypeForRtf_rtf_staroffice_5_2_rtf() throws Exception {
+ testMimeType("docs/rtf-staroffice-5.2.rtf", expectedMimeTypeForRtf_rtf_staroffice_5_2_rtf());
+ }
+
+ @Test
+ public void shouldProvideMimeTypeForRtf_rtf_word_2000_rtf() throws Exception {
+ testMimeType("docs/rtf-word-2000.rtf", expectedMimeTypeForRtf_rtf_word_2000_rtf());
+ }
+
+ @Test
+ public void shouldProvideMimeTypeForMp3_test_mp3() throws Exception {
+ testMimeType("test.mp3", expectedMimeTypeForMp3_test_mp3());
+ }
+
+ @Test
+ public void shouldProvideMimeTypeForMp3_test_128_44_jstereo_mp3() throws Exception {
+ testMimeType("test_128_44_jstereo.mp3", expectedMimeTypeForMp3_test_128_44_jstereo_mp3());
+ }
+
+ @Test
+ public void shouldProvideMimeTypeForMp3_jingle1_mp3() throws Exception {
+ testMimeType("docs/jingle1.mp3", expectedMimeTypeForMp3_jingle1_mp3());
+ }
+
+ @Test
+ public void shouldProvideMimeTypeForMp3_jingle2_mp3() throws Exception {
+ testMimeType("docs/jingle2.mp3", expectedMimeTypeForMp3_jingle2_mp3());
+ }
+
+ @Test
+ public void shouldProvideMimeTypeForMp3_jingle3_mp3() throws Exception {
+ testMimeType("docs/jingle3.mp3", expectedMimeTypeForMp3_jingle3_mp3());
+ }
+
+ @Test
+ public void shouldProvideMimeTypeForWav() throws Exception {
+ testMimeType("test.wav", expectedMimeTypeForWav());
+ }
+
+ @Test
+ public void shouldProvideMimeTypeForBmp() throws Exception {
+ testMimeType("test.bmp", expectedMimeTypeForBmp());
+ }
+
+ @Test
+ public void shouldProvideMimeTypeForGif() throws Exception {
+ testMimeType("test.gif", expectedMimeTypeForGif());
+ }
+
+ @Test
+ public void shouldProvideMimeTypeForIcon() throws Exception {
+ testMimeType("test.ico", expectedMimeTypeForIcon());
+ }
+
+ @Test
+ public void shouldProvideMimeTypeForJpeg_test_jpg() throws Exception {
+ testMimeType("test.jpg", expectedMimeTypeForJpeg_test_jpg());
+ }
+
+ @Test
+ public void shouldProvideMimeTypeForJpeg_jpg_exif_img_9367_JPG() throws Exception {
+ testMimeType("docs/jpg-exif-img_9367.JPG", expectedMimeTypeForJpeg_jpg_exif_img_9367_JPG());
+ }
+
+ @Test
+ public void shouldProvideMimeTypeForJpeg_jpg_exif_zerolength_jpg() throws Exception {
+ testMimeType("docs/jpg-exif-zerolength.jpg", expectedMimeTypeForJpeg_jpg_exif_zerolength_jpg());
+ }
+
+ @Test
+ public void shouldProvideMimeTypeForJpeg_jpg_geotagged_jpg() throws Exception {
+ testMimeType("docs/jpg-geotagged.jpg", expectedMimeTypeForJpeg_jpg_geotagged_jpg());
+ }
+
+ @Test
+ public void shouldProvideMimeTypeForJpeg_jpg_geotagged_ipanema_jpg() throws Exception {
+ testMimeType("docs/jpg-geotagged-ipanema.jpg", expectedMimeTypeForJpeg_jpg_geotagged_ipanema_jpg());
+ }
+
+ @Test
+ public void shouldProvideMimeTypeForPortablePixelMap_test_ppm() throws Exception {
+ testMimeType("test.ppm", expectedMimeTypeForPortablePixelMap_test_ppm());
+ }
+
+ @Test
+ public void shouldProvideMimeTypeForPortablePixelMap_test_pnm() throws Exception {
+ testMimeType("test.pnm", expectedMimeTypeForPortablePixelMap_test_pnm());
+ }
+
+ @Test
+ public void shouldProvideMimeTypeForPng() throws Exception {
+ testMimeType("test.png", expectedMimeTypeForPng());
+ }
+
+ @Test
+ public void shouldProvideMimeTypeForTiff() throws Exception {
+ testMimeType("test_nocompress.tif", expectedMimeTypeForTiff());
+ }
+
+ @Test
+ public void shouldProvideMimeTypeForTga() throws Exception {
+ testMimeType("test.tga", expectedMimeTypeForTga());
+ }
+
+ @Test
+ public void shouldProvideMimeTypeForWmf() throws Exception {
+ testMimeType("test.wmf", expectedMimeTypeForWmf());
+ }
+
+ @Test
+ public void shouldProvideMimeTypeForXcf() throws Exception {
+ testMimeType("test.xcf", expectedMimeTypeForXcf());
+ }
+
+ @Test
+ public void shouldProvideMimeTypeForXpm() throws Exception {
+ testMimeType("test.xpm", expectedMimeTypeForXpm());
+ }
+
+ @Test
+ public void shouldProvideMimeTypeForXml_test_xml() throws Exception {
+ testMimeType("test.xml", expectedMimeTypeForXml_test_xml());
+ }
+
+ @Test
+ public void shouldProvideMimeTypeForXml_test_excel_spreadsheet_xml() throws Exception {
+ testMimeType("test_excel_spreadsheet.xml", expectedMimeTypeForXml_test_excel_spreadsheet_xml());
+ }
+
+ @Test
+ public void shouldProvideMimeTypeForXml_CurrencyFormatterExample_mxml() throws Exception {
+ testMimeType("CurrencyFormatterExample.mxml", expectedMimeTypeForXml_CurrencyFormatterExample_mxml());
+ }
+
+ @Test
+ public void shouldProvideMimeTypeForXml_xml_handwritten_xml() throws Exception {
+ testMimeType("docs/xml-handwritten.xml", expectedMimeTypeForXml_xml_handwritten_xml());
+ }
+
+ @Test
+ public void shouldProvideMimeTypeForXml_xml_nonexistent_dtd_xml() throws Exception {
+ testMimeType("docs/xml-nonexistent-dtd.xml", expectedMimeTypeForXml_xml_nonexistent_dtd_xml());
+ }
+
+ @Test
+ public void shouldProvideMimeTypeForXml_xml_nonexistent_remote_dtd_xml() throws Exception {
+ testMimeType("docs/xml-nonexistent-remote-dtd.xml", expectedMimeTypeForXml_xml_nonexistent_remote_dtd_xml());
+ }
+
+ @Test
+ public void shouldProvideMimeTypeForXml_xml_nonexistent_remote_xsd_xml() throws Exception {
+ testMimeType("docs/xml-nonexistent-remote-xsd.xml", expectedMimeTypeForXml_xml_nonexistent_remote_xsd_xml());
+ }
+
+ @Test
+ public void shouldProvideMimeTypeForXml_xml_nonexistent_xsd_xml() throws Exception {
+ testMimeType("docs/xml-nonexistent-xsd.xml", expectedMimeTypeForXml_xml_nonexistent_xsd_xml());
+ }
+
+ @Test
+ public void shouldProvideMimeTypeForXml_xml_utf8_bom() throws Exception {
+ testMimeType("docs/xml-utf8-bom", expectedMimeTypeForXml_xml_utf8_bom());
+ }
+
+ @Test
+ public void shouldProvideMimeTypeForXsd() throws Exception {
+ testMimeType("Descriptor.1.0.xsd", expectedMimeTypeForXsd());
+ }
+
+ @Test
+ public void shouldProvideMimeTypeForDtd() throws Exception {
+ testMimeType("test.dtd", expectedMimeTypeForDtd());
+ }
+
+ @Test
+ public void shouldProvideMimeTypeForHtml_master_xml() throws Exception {
+ testMimeType("master.xml", expectedMimeTypeForHtml_master_xml());
+ }
+
+ @Test
+ public void shouldProvideMimeTypeForHtml_html_condenast_html() throws Exception {
+ testMimeType("docs/html-condenast.html", expectedMimeTypeForHtml_html_condenast_html());
+ }
+
+ @Test
+ public void shouldProvideMimeTypeForHtml_html_handwritten_html() throws Exception {
+ testMimeType("docs/html-handwritten.html", expectedMimeTypeForHtml_html_handwritten_html());
+ }
+
+ @Test
+ public void shouldProvideMimeTypeForHtml_html_handwritten_with_wrong_file_extension_txt() throws Exception {
+ testMimeType("docs/html-handwritten-with-wrong-file-extension.txt",
+ expectedMimeTypeForHtml_html_handwritten_with_wrong_file_extension_txt());
+ }
+
+ @Test
+ public void shouldProvideMimeTypeForHtml_html_quelle_de_html() throws Exception {
+ testMimeType("docs/html-quelle.de.html", expectedMimeTypeForHtml_html_quelle_de_html());
+ }
+
+ @Test
+ public void shouldProvideMimeTypeForHtml_html_utf16_leading_whitespace_wrong_extension_doc() throws Exception {
+ testMimeType("docs/html-utf16-leading-whitespace-wrong-extension.doc",
+ expectedMimeTypeForHtml_html_utf16_leading_whitespace_wrong_extension_doc());
+ }
+
+ @Test
+ public void shouldProvideMimeTypeForJava() throws Exception {
+ testMimeType("test.java", expectedMimeTypeForJava());
+ }
+
+ @Test
+ public void shouldProvideMimeTypeFor1_2Class() throws Exception {
+ testMimeType("test_1.2.class", expectedMimeTypeFor1_2Class());
+ }
+
+ @Test
+ public void shouldProvideMimeTypeFor1_3Class() throws Exception {
+ testMimeType("test_1.3.class", expectedMimeTypeFor1_3Class());
+ }
+
+ @Test
+ public void shouldProvideMimeTypeFor1_4Class() throws Exception {
+ testMimeType("test_1.4.class", expectedMimeTypeFor1_4Class());
+ }
+
+ @Test
+ public void shouldProvideMimeTypeForPerl() throws Exception {
+ testMimeType("test.pl", expectedMimeTypeForPerl());
+ }
+
+ @Test
+ public void shouldProvideMimeTypeForPython() throws Exception {
+ testMimeType("test.py", expectedMimeTypeForPython());
+ }
+
+ @Test
+ public void shouldProvideMimeTypeForPdf_test_pdf() throws Exception {
+ testMimeType("test.pdf", expectedMimeTypeForPdf_test_pdf());
+ }
+
+ @Test
+ public void shouldProvideMimeTypeForPdf_pdf_distiller_6_weirdchars_pdf() throws Exception {
+ testMimeType("docs/pdf-distiller-6-weirdchars.pdf", expectedMimeTypeForPdf_pdf_distiller_6_weirdchars_pdf());
+ }
+
+ @Test
+ public void shouldProvideMimeTypeForPdf_pdf_no_author_pdf() throws Exception {
+ testMimeType("docs/pdf-no-author.pdf", expectedMimeTypeForPdf_pdf_no_author_pdf());
+ }
+
+ @Test
+ public void shouldProvideMimeTypeForPdf_pdf_openoffice_1_1_5_writer_pdf() throws Exception {
+ testMimeType("docs/pdf-openoffice-1.1.5-writer.pdf", expectedMimeTypeForPdf_pdf_openoffice_1_1_5_writer_pdf());
+ }
+
+ @Test
+ public void shouldProvideMimeTypeForPdf_pdf_openoffice_2_0_writer_pdf() throws Exception {
+ testMimeType("docs/pdf-openoffice-2.0-writer.pdf", expectedMimeTypeForPdf_pdf_openoffice_2_0_writer_pdf());
+ }
+
+ @Test
+ public void shouldProvideMimeTypeForPdf_pdf_word_2000_pdfcreator_0_8_0_pdf() throws Exception {
+ testMimeType("docs/pdf-word-2000-pdfcreator-0.8.0.pdf", expectedMimeTypeForPdf_pdf_word_2000_pdfcreator_0_8_0_pdf());
+ }
+
+ @Test
+ public void shouldProvideMimeTypeForPdf_pdf_word_2000_pdfmaker_7_0_pdf() throws Exception {
+ testMimeType("docs/pdf-word-2000-pdfmaker-7.0.pdf", expectedMimeTypeForPdf_pdf_word_2000_pdfmaker_7_0_pdf());
+ }
+
+ @Test
+ public void shouldProvideMimeTypeForPdf_pdf_word_2000_pdfwriter_7_0_pdf() throws Exception {
+ testMimeType("docs/pdf-word-2000-pdfwriter-7.0.pdf", expectedMimeTypeForPdf_pdf_word_2000_pdfwriter_7_0_pdf());
+ }
+
+ @Test
+ public void shouldProvideMimeTypeForPostscript_test_ps() throws Exception {
+ testMimeType("test.ps", expectedMimeTypeForPostscript_test_ps());
+ }
+
+ @Test
+ public void shouldProvideMimeTypeForPostscript_test_eps() throws Exception {
+ testMimeType("test.eps", expectedMimeTypeForPostscript_test_eps());
+ }
+
+ @Test
+ public void shouldProvideMimeTypeForJar() throws Exception {
+ testMimeType("dna-repository-0.2-SNAPSHOT.jar", expectedMimeTypeForJar());
+ }
+
+ @Test
+ public void shouldProvideMimeTypeForJavaManifest() throws Exception {
+ testMimeType("aperture.example.manifest.mf", expectedMimeTypeForJavaManifest());
+ }
+
+ @Test
+ public void shouldProvideMimeTypeForGZip_test_tar_gz() throws Exception {
+ testMimeType("test.tar.gz", expectedMimeTypeForGZip_test_tar_gz());
+ }
+
+ @Test
+ public void shouldProvideMimeTypeForGZip_test_txt_gz() throws Exception {
+ testMimeType("test.txt.gz", expectedMimeTypeForGZip_test_txt_gz());
+ }
+
+ @Test
+ public void shouldProvideMimeTypeForZip() throws Exception {
+ testMimeType("docs/counting-input-stream-test-file.dat", expectedMimeTypeForZip());
+ }
+
+ @Test
+ public void shouldProvideMimeTypeForBash() throws Exception {
+ testMimeType("test.sh", expectedMimeTypeForBash());
+ }
+
+ @Test
+ public void shouldProvideMimeTypeForOgg() throws Exception {
+ testMimeType("test.ogg", expectedMimeTypeForOgg());
+ }
+
+ @Test
+ public void shouldProvideMimeTypeForOpenDocumentFormula() throws Exception {
+ testMimeType("docs/openoffice-2.0-formula.odf", expectedMimeTypeForOpenDocumentFormula());
+ }
+
+ @Test
+ public void shouldProvideMimeTypeForOpenDocumentGraphics() throws Exception {
+ testMimeType("docs/openoffice-2.0-draw.odg", expectedMimeTypeForOpenDocumentGraphics());
+ }
+
+ @Test
+ public void shouldProvideMimeTypeForOpenDocumentGraphicsTemplate() throws Exception {
+ testMimeType("docs/openoffice-2.0-draw-template.otg", expectedMimeTypeForOpenDocumentGraphicsTemplate());
+ }
+
+ @Test
+ public void shouldProvideMimeTypeForOpenDocumentPresentation_component_architecture_odp() throws Exception {
+ testMimeType("component-architecture.odp", expectedMimeTypeForOpenDocumentPresentation_component_architecture_odp());
+ }
+
+ @Test
+ public void shouldProvideMimeTypeForOpenDocumentPresentation_openoffice_2_0_impress_odp() throws Exception {
+ testMimeType("docs/openoffice-2.0-impress.odp", expectedMimeTypeForOpenDocumentPresentation_openoffice_2_0_impress_odp());
+ }
+
+ @Test
+ public void shouldProvideMimeTypeForOpenDocumentPresentationTemplate() throws Exception {
+ testMimeType("docs/openoffice-2.0-impress-template.otp", expectedMimeTypeForOpenDocumentPresentationTemplate());
+ }
+
+ @Test
+ public void shouldProvideMimeTypeForOpenDocumentSpreadsheet() throws Exception {
+ testMimeType("docs/openoffice-2.0-calc.ods", expectedMimeTypeForOpenDocumentSpreadsheet());
+ }
+
+ @Test
+ public void shouldProvideMimeTypeForOpenDocumentSpreadsheetTemplate() throws Exception {
+ testMimeType("docs/openoffice-2.0-calc-template.ots", expectedMimeTypeForOpenDocumentSpreadsheetTemplate());
+ }
+
+ @Test
+ public void shouldProvideMimeTypeForOpenDocumentText() throws Exception {
+ testMimeType("docs/openoffice-2.0-writer.odt", expectedMimeTypeForOpenDocumentText());
+ }
+
+ @Test
+ public void shouldProvideMimeTypeForOpenDocumentTextTemplate() throws Exception {
+ testMimeType("docs/openoffice-2.0-writer-template.ott", expectedMimeTypeForOpenDocumentTextTemplate());
+ }
+
+ @Test
+ public void shouldProvideMimeTypeForOpenOfficeCalc() throws Exception {
+ testMimeType("docs/openoffice-1.1.5-calc.sxc", expectedMimeTypeForOpenOfficeCalc());
+ }
+
+ @Test
+ public void shouldProvideMimeTypeForOpenOfficeCalcTemplate() throws Exception {
+ testMimeType("docs/openoffice-1.1.5-calc-template.stc", expectedMimeTypeForOpenOfficeCalcTemplate());
+ }
+
+ @Test
+ public void shouldProvideMimeTypeForOpenOfficeDraw() throws Exception {
+ testMimeType("docs/openoffice-1.1.5-draw.sxd", expectedMimeTypeForOpenOfficeDraw());
+ }
+
+ @Test
+ public void shouldProvideMimeTypeForOpenOfficeDrawTemplate() throws Exception {
+ testMimeType("docs/openoffice-1.1.5-draw-template.std", expectedMimeTypeForOpenOfficeDrawTemplate());
+ }
+
+ @Test
+ public void shouldProvideMimeTypeForOpenOfficeImpress() throws Exception {
+ testMimeType("docs/openoffice-1.1.5-impress.sxi", expectedMimeTypeForOpenOfficeImpress());
+ }
+
+ @Test
+ public void shouldProvideMimeTypeForOpenOfficeImpressTemplate() throws Exception {
+ testMimeType("docs/openoffice-1.1.5-impress-template.sti", expectedMimeTypeForOpenOfficeImpressTemplate());
+ }
+
+ @Test
+ public void shouldProvideMimeTypeForOpenOfficeWriter() throws Exception {
+ testMimeType("docs/openoffice-1.1.5-writer.sxw", expectedMimeTypeForOpenOfficeWriter());
+ }
+
+ @Test
+ public void shouldProvideMimeTypeForOpenOfficeWriterTemplate() throws Exception {
+ testMimeType("docs/openoffice-1.1.5-writer-template.stw", expectedMimeTypeForOpenOfficeWriterTemplate());
+ }
+
+ @Test
+ public void shouldProvideMimeTypeForStarOfficeCalc() throws Exception {
+ testMimeType("docs/staroffice-5.2-calc.sdc", expectedMimeTypeForStarOfficeCalc());
+ }
+
+ @Test
+ public void shouldProvideMimeTypeForStarOfficeDraw() throws Exception {
+ testMimeType("docs/staroffice-5.2-draw.sda", expectedMimeTypeForStarOfficeDraw());
+ }
+
+ @Test
+ public void shouldProvideMimeTypeForStarOfficeImpress() throws Exception {
+ testMimeType("docs/staroffice-5.2-impress.sdd", expectedMimeTypeForStarOfficeImpress());
+ }
+
+ @Test
+ public void shouldProvideMimeTypeForStarOfficeWriter() throws Exception {
+ testMimeType("docs/staroffice-5.2-writer.sdw", expectedMimeTypeForStarOfficeWriter());
+ }
+
+ @Test
+ public void shouldProvideMimeTypeForStarOfficeCalcTemplate() throws Exception {
+ testMimeType("docs/staroffice-5.2-calc-template.vor", expectedMimeTypeForStarOfficeCalcTemplate());
+ }
+
+ @Test
+ public void shouldProvideMimeTypeForStarOfficeDrawTemplate() throws Exception {
+ testMimeType("docs/staroffice-5.2-draw-template.vor", expectedMimeTypeForStarOfficeDrawTemplate());
+ }
+
+ @Test
+ public void shouldProvideMimeTypeForStarOfficeImpressTemplate() throws Exception {
+ testMimeType("docs/staroffice-5.2-impress-template.vor", expectedMimeTypeForStarOfficeImpressTemplate());
+ }
+
+ @Test
+ public void shouldProvideMimeTypeForStarOfficeWriterTemplate() throws Exception {
+ testMimeType("docs/staroffice-5.2-writer-template.vor", expectedMimeTypeForStarOfficeWriterTemplate());
+ }
+
+ @Test
+ public void shouldProvideMimeTypeForWord_test_word_2000_doc() throws Exception {
+ testMimeType("test_word_2000.doc", expectedMimeTypeForWord_test_word_2000_doc());
+ }
+
+ @Test
+ public void shouldProvideMimeTypeForWord_test_word_6_0_95_doc() throws Exception {
+ testMimeType("test_word_6.0_95.doc", expectedMimeTypeForWord_test_word_6_0_95_doc());
+ }
+
+ @Test
+ public void shouldProvideMimeTypeForWord_microsoft_word_2000_doc() throws Exception {
+ testMimeType("docs/microsoft-word-2000.doc", expectedMimeTypeForWord_microsoft_word_2000_doc());
+ }
+
+ @Test
+ public void shouldProvideMimeTypeForWord_microsoft_word_2000_with_wrong_file_extension_pdf() throws Exception {
+ testMimeType("docs/microsoft-word-2000-with-wrong-file-extension.pdf",
+ expectedMimeTypeForWord_microsoft_word_2000_with_wrong_file_extension_pdf());
+ }
+
+ @Test
+ public void shouldProvideMimeTypeForWord_microsoft_word_2007beta2_docm() throws Exception {
+ testMimeType("docs/microsoft-word-2007beta2.docm", expectedMimeTypeForWord_microsoft_word_2007beta2_docm());
+ }
+
+ @Test
+ public void shouldProvideMimeTypeForWord_microsoft_word_2007beta2_docx() throws Exception {
+ testMimeType("docs/microsoft-word-2007beta2.docx", expectedMimeTypeForWord_microsoft_word_2007beta2_docx());
+ }
+
+ @Test
+ public void shouldProvideMimeTypeForWord_microsoft_word_2007beta2_dotm() throws Exception {
+ testMimeType("docs/microsoft-word-2007beta2.dotm", expectedMimeTypeForWord_microsoft_word_2007beta2_dotm());
+ }
+
+ @Test
+ public void shouldProvideMimeTypeForWord_microsoft_word_2007beta2_dotx() throws Exception {
+ testMimeType("docs/microsoft-word-2007beta2.dotx", expectedMimeTypeForWord_microsoft_word_2007beta2_dotx());
+ }
+
+ @Test
+ public void shouldProvideMimeTypeForWorks_microsoft_works_spreadsheet_4_0_2000_wks() throws Exception {
+ testMimeType("docs/microsoft-works-spreadsheet-4.0-2000.wks",
+ expectedMimeTypeForWorks_microsoft_works_spreadsheet_4_0_2000_wks());
+ }
+
+ @Test
+ public void shouldProvideMimeTypeForWorks_microsoft_works_spreadsheet_7_0_xlr() throws Exception {
+ testMimeType("docs/microsoft-works-spreadsheet-7.0.xlr", expectedMimeTypeForWorks_microsoft_works_spreadsheet_7_0_xlr());
+ }
+
+ @Test
+ public void shouldProvideMimeTypeForWorks_microsoft_works_word_processor_2000_wps() throws Exception {
+ testMimeType("docs/microsoft-works-word-processor-2000.wps",
+ expectedMimeTypeForWorks_microsoft_works_word_processor_2000_wps());
+ }
+
+ @Test
+ public void shouldProvideMimeTypeForWorks_microsoft_works_word_processor_3_0_wps() throws Exception {
+ testMimeType("docs/microsoft-works-word-processor-3.0.wps",
+ expectedMimeTypeForWorks_microsoft_works_word_processor_3_0_wps());
+ }
+
+ @Test
+ public void shouldProvideMimeTypeForWorks_microsoft_works_word_processor_4_0_wps() throws Exception {
+ testMimeType("docs/microsoft-works-word-processor-4.0.wps",
+ expectedMimeTypeForWorks_microsoft_works_word_processor_4_0_wps());
+ }
+
+ @Test
+ public void shouldProvideMimeTypeForWorks_microsoft_works_word_processor_7_0_wps() throws Exception {
+ testMimeType("docs/microsoft-works-word-processor-7.0.wps",
+ expectedMimeTypeForWorks_microsoft_works_word_processor_7_0_wps());
+ }
+
+ @Test
+ public void shouldProvideMimeTypeForWorkbook_corel_quattro_pro_6_wb2() throws Exception {
+ testMimeType("docs/corel-quattro-pro-6.wb2", expectedMimeTypeForWorkbook_corel_quattro_pro_6_wb2());
+ }
+
+ @Test
+ public void shouldProvideMimeTypeForWorkbook_microsoft_works_spreadsheet_3_0_wks() throws Exception {
+ testMimeType("docs/microsoft-works-spreadsheet-3.0.wks",
+ expectedMimeTypeForWorkbook_microsoft_works_spreadsheet_3_0_wks());
+ }
+
+ @Test
+ public void shouldProvideMimeTypeForExcel_test_excel_2000_xls() throws Exception {
+ testMimeType("test_excel_2000.xls", expectedMimeTypeForExcel_test_excel_2000_xls());
+ }
+
+ @Test
+ public void shouldProvideMimeTypeForExcel_microsoft_excel_2000_xls() throws Exception {
+ testMimeType("docs/microsoft-excel-2000.xls", expectedMimeTypeForExcel_microsoft_excel_2000_xls());
+ }
+
+ @Test
+ public void shouldProvideMimeTypeForExcel_microsoft_excel_2007beta2_xlam() throws Exception {
+ testMimeType("docs/microsoft-excel-2007beta2.xlam", expectedMimeTypeForExcel_microsoft_excel_2007beta2_xlam());
+ }
+
+ @Test
+ public void shouldProvideMimeTypeForExcel_microsoft_excel_2007beta2_xlsb() throws Exception {
+ testMimeType("docs/microsoft-excel-2007beta2.xlsb", expectedMimeTypeForExcel_microsoft_excel_2007beta2_xlsb());
+ }
+
+ @Test
+ public void shouldProvideMimeTypeForExcel_microsoft_excel_2007beta2_xlsm() throws Exception {
+ testMimeType("docs/microsoft-excel-2007beta2.xlsm", expectedMimeTypeForExcel_microsoft_excel_2007beta2_xlsm());
+ }
+
+ @Test
+ public void shouldProvideMimeTypeForExcel_microsoft_excel_2007beta2_xlsx() throws Exception {
+ testMimeType("docs/microsoft-excel-2007beta2.xlsx", expectedMimeTypeForExcel_microsoft_excel_2007beta2_xlsx());
+ }
+
+ @Test
+ public void shouldProvideMimeTypeForExcel_microsoft_excel_2007beta2_xltm() throws Exception {
+ testMimeType("docs/microsoft-excel-2007beta2.xltm", expectedMimeTypeForExcel_microsoft_excel_2007beta2_xltm());
+ }
+
+ @Test
+ public void shouldProvideMimeTypeForExcel_microsoft_excel_2007beta2_xltx() throws Exception {
+ testMimeType("docs/microsoft-excel-2007beta2.xltx", expectedMimeTypeForExcel_microsoft_excel_2007beta2_xltx());
+ }
+
+ @Test
+ public void shouldProvideMimeTypeForPowerpoint_test_ppt() throws Exception {
+ testMimeType("test.ppt", expectedMimeTypeForPowerpoint_test_ppt());
+ }
+
+ @Test
+ public void shouldProvideMimeTypeForPowerpoint_microsoft_powerpoint_2000_ppt() throws Exception {
+ testMimeType("docs/microsoft-powerpoint-2000.ppt", expectedMimeTypeForPowerpoint_microsoft_powerpoint_2000_ppt());
+ }
+
+ @Test
+ public void shouldProvideMimeTypeForPowerpoint_microsoft_powerpoint_2007beta2_potm() throws Exception {
+ testMimeType("docs/microsoft-powerpoint-2007beta2.potm",
+ expectedMimeTypeForPowerpoint_microsoft_powerpoint_2007beta2_potm());
+ }
+
+ @Test
+ public void shouldProvideMimeTypeForPowerpoint_microsoft_powerpoint_2007beta2_potx() throws Exception {
+ testMimeType("docs/microsoft-powerpoint-2007beta2.potx",
+ expectedMimeTypeForPowerpoint_microsoft_powerpoint_2007beta2_potx());
+ }
+
+ @Test
+ public void shouldProvideMimeTypeForPowerpoint_microsoft_powerpoint_2007beta2_ppsm() throws Exception {
+ testMimeType("docs/microsoft-powerpoint-2007beta2.ppsm",
+ expectedMimeTypeForPowerpoint_microsoft_powerpoint_2007beta2_ppsm());
+ }
+
+ @Test
+ public void shouldProvideMimeTypeForPowerpoint_microsoft_powerpoint_2007beta2_ppsx() throws Exception {
+ testMimeType("docs/microsoft-powerpoint-2007beta2.ppsx",
+ expectedMimeTypeForPowerpoint_microsoft_powerpoint_2007beta2_ppsx());
+ }
+
+ @Test
+ public void shouldProvideMimeTypeForPowerpoint_microsoft_powerpoint_2007beta2_pptm() throws Exception {
+ testMimeType("docs/microsoft-powerpoint-2007beta2.pptm",
+ expectedMimeTypeForPowerpoint_microsoft_powerpoint_2007beta2_pptm());
+ }
+
+ @Test
+ public void shouldProvideMimeTypeForPowerpoint_microsoft_powerpoint_2007beta2_pptx() throws Exception {
+ testMimeType("docs/microsoft-powerpoint-2007beta2.pptx",
+ expectedMimeTypeForPowerpoint_microsoft_powerpoint_2007beta2_pptx());
+ }
+
+ @Test
+ public void shouldProvideMimeTypeForPublisher() throws Exception {
+ testMimeType("docs/microsoft-publisher-2003.pub", expectedMimeTypeForPublisher());
+ }
+
+ @Test
+ public void shouldProvideMimeTypeForVisio() throws Exception {
+ testMimeType("docs/microsoft-visio.vsd", expectedMimeTypeForVisio());
+ }
+
+ @Test
+ public void shouldProvideMimeTypeForOutlook() throws Exception {
+ testMimeType("TestData.pst", expectedMimeTypeForOutlook());
+ }
+
+ @Test
+ public void shouldProvideMimeTypeForShw_corel_presentations_3_0_shw() throws Exception {
+ testMimeType("docs/corel-presentations-3.0.shw", expectedMimeTypeForShw_corel_presentations_3_0_shw());
+ }
+
+ @Test
+ public void shouldProvideMimeTypeForShw_corel_presentations_x3_shw() throws Exception {
+ testMimeType("docs/corel-presentations-x3.shw", expectedMimeTypeForShw_corel_presentations_x3_shw());
+ }
+
+ @Test
+ public void shouldProvideMimeTypeForQuattroPro_corel_quattro_pro_7_wb3() throws Exception {
+ testMimeType("docs/corel-quattro-pro-7.wb3", expectedMimeTypeForPro_corel_quattro_pro_7_wb3());
+ }
+
+ @Test
+ public void shouldProvideMimeTypeForQuattroPro_corel_quattro_pro_x3_qpw() throws Exception {
+ testMimeType("docs/corel-quattro-pro-x3.qpw", expectedMimeTypeForPro_corel_quattro_pro_x3_qpw());
+ }
+
+ @Test
+ public void shouldProvideMimeTypeForWordperfect_corel_wordperfect_4_2_wp() throws Exception {
+ testMimeType("docs/corel-wordperfect-4.2.wp", expectedMimeTypeForWordperfect_corel_wordperfect_4_2_wp());
+ }
+
+ @Test
+ public void shouldProvideMimeTypeForWordperfect_corel_wordperfect_5_0_wp() throws Exception {
+ testMimeType("docs/corel-wordperfect-5.0.wp", expectedMimeTypeForWordperfect_corel_wordperfect_5_0_wp());
+ }
+
+ @Test
+ public void shouldProvideMimeTypeForWordperfect_corel_wordperfect_5_1_wp() throws Exception {
+ testMimeType("docs/corel-wordperfect-5.1.wp", expectedMimeTypeForWordperfect_corel_wordperfect_5_1_wp());
+ }
+
+ @Test
+ public void shouldProvideMimeTypeForWordperfect_corel_wordperfect_5_1_far_east_wp() throws Exception {
+ testMimeType("docs/corel-wordperfect-5.1-far-east.wp", expectedMimeTypeForWordperfect_corel_wordperfect_5_1_far_east_wp());
+ }
+
+ @Test
+ public void shouldProvideMimeTypeForWordperfect_corel_wordperfect_x3_wpd() throws Exception {
+ testMimeType("docs/corel-wordperfect-x3.wpd", expectedMimeTypeForWordperfect_corel_wordperfect_x3_wpd());
+ }
+
+ @Test
+ public void shouldProvideMimeTypeForMail_test_excel_web_archive_mht() throws Exception {
+ testMimeType("test_excel_web_archive.mht", expectedMimeTypeForMail_test_excel_web_archive_mht());
+ }
+
+ @Test
+ public void shouldProvideMimeTypeForMail_mail_thunderbird_1_5_eml() throws Exception {
+ testMimeType("docs/mail-thunderbird-1.5.eml", expectedMimeTypeForMail_mail_thunderbird_1_5_eml());
+ }
+
+ @Test
+ public void shouldProvideMimeTypeForMail_mhtml_firefox_mht() throws Exception {
+ testMimeType("docs/mhtml-firefox.mht", expectedMimeTypeForMail_mhtml_firefox_mht());
+ }
+
+ @Test
+ public void shouldProvideMimeTypeForMail_mhtml_internet_explorer_mht() throws Exception {
+ testMimeType("docs/mhtml-internet-explorer.mht", expectedMimeTypeForMail_mhtml_internet_explorer_mht());
+ }
+
+ @Test
+ public void shouldProvideMimeTypeForAddressBook() throws Exception {
+ testMimeType("docs/thunderbird-addressbook.mab", expectedMimeTypeForAddressBook());
+ }
+
+ @Test
+ public void shouldProvideMimeTypeForVCard_vcard_antoni_kontact_vcf() throws Exception {
+ testMimeType("docs/vcard-antoni-kontact.vcf", expectedMimeTypeForVCard_vcard_antoni_kontact_vcf());
+ }
+
+ @Test
+ public void shouldProvideMimeTypeForVCard_vcard_antoni_outlook2003_vcf() throws Exception {
+ testMimeType("docs/vcard-antoni-outlook2003.vcf", expectedMimeTypeForVCard_vcard_antoni_outlook2003_vcf());
+ }
+
+ @Test
+ public void shouldProvideMimeTypeForVCard_vcard_dirk_vcf() throws Exception {
+ testMimeType("docs/vcard-dirk.vcf", expectedMimeTypeForVCard_vcard_dirk_vcf());
+ }
+
+ @Test
+ public void shouldProvideMimeTypeForVCard_vcard_rfc2426_vcf() throws Exception {
+ testMimeType("docs/vcard-rfc2426.vcf", expectedMimeTypeForVCard_vcard_rfc2426_vcf());
+ }
+
+ @Test
+ public void shouldProvideMimeTypeForVCard_vcard_vCards_SAP_vcf() throws Exception {
+ testMimeType("docs/vcard-vCards-SAP.vcf", expectedMimeTypeForVCard_vcard_vCards_SAP_vcf());
+ }
+
+ @Test
+ public void shouldProvideMimeTypeForCalendar_basicCalendar_ics() throws Exception {
+ testMimeType("docs/icaltestdata/basicCalendar.ics", expectedMimeTypeForCalendar_basicCalendar_ics());
+ }
+
+ @Test
+ public void shouldProvideMimeTypeForCalendar_cal01_ics() throws Exception {
+ testMimeType("docs/icaltestdata/cal01.ics", expectedMimeTypeForCalendar_cal01_ics());
+ }
+
+ @Test
+ public void shouldProvideMimeTypeForCalendar_cal01_1_ics() throws Exception {
+ testMimeType("docs/icaltestdata/cal01-1.ics", expectedMimeTypeForCalendar_cal01_1_ics());
+ }
+
+ @Test
+ public void shouldProvideMimeTypeForCalendar_cal01_2_ics() throws Exception {
+ testMimeType("docs/icaltestdata/cal01-2.ics", expectedMimeTypeForCalendar_cal01_2_ics());
+ }
+
+ @Test
+ public void shouldProvideMimeTypeForCalendar_cal01_3_ics() throws Exception {
+ testMimeType("docs/icaltestdata/cal01-3.ics", expectedMimeTypeForCalendar_cal01_3_ics());
+ }
+
+ @Test
+ public void shouldProvideMimeTypeForCalendar_cal01_4_ics() throws Exception {
+ testMimeType("docs/icaltestdata/cal01-4.ics", expectedMimeTypeForCalendar_cal01_4_ics());
+ }
+
+ @Test
+ public void shouldProvideMimeTypeForCalendar_cal01_5_ics() throws Exception {
+ testMimeType("docs/icaltestdata/cal01-5.ics", expectedMimeTypeForCalendar_cal01_5_ics());
+ }
+
+ @Test
+ public void shouldProvideMimeTypeForCalendar_cal01_6_ics() throws Exception {
+ testMimeType("docs/icaltestdata/cal01-6.ics", expectedMimeTypeForCalendar_cal01_6_ics());
+ }
+
+ @Test
+ public void shouldProvideMimeTypeForCalendar_cal01_exrule_ics() throws Exception {
+ testMimeType("docs/icaltestdata/cal01-exrule.ics", expectedMimeTypeForCalendar_cal01_exrule_ics());
+ }
+
+ @Test
+ public void shouldProvideMimeTypeForCalendar_calconnect7_ics() throws Exception {
+ testMimeType("docs/icaltestdata/calconnect7.ics", expectedMimeTypeForCalendar_calconnect7_ics());
+ }
+
+ @Test
+ public void shouldProvideMimeTypeForCalendar_calconnect9_ics() throws Exception {
+ testMimeType("docs/icaltestdata/calconnect9.ics", expectedMimeTypeForCalendar_calconnect9_ics());
+ }
+
+ @Test
+ public void shouldProvideMimeTypeForCalendar_combined_multiplevcalendar_ics() throws Exception {
+ testMimeType("docs/icaltestdata/combined_multiplevcalendar.ics",
+ expectedMimeTypeForCalendar_combined_multiplevcalendar_ics());
+ }
+
+ @Test
+ public void shouldProvideMimeTypeForCalendar_combined_onevcalendar_ics() throws Exception {
+ testMimeType("docs/icaltestdata/combined_onevcalendar.ics", expectedMimeTypeForCalendar_combined_onevcalendar_ics());
+ }
+
+ @Test
+ public void shouldProvideMimeTypeForCalendar_extendedCalendar_ics() throws Exception {
+ testMimeType("docs/icaltestdata/extendedCalendar.ics", expectedMimeTypeForCalendar_extendedCalendar_ics());
+ }
+
+ @Test
+ public void shouldProvideMimeTypeForCalendar_freebusy_ics() throws Exception {
+ testMimeType("docs/icaltestdata/freebusy.ics", expectedMimeTypeForCalendar_freebusy_ics());
+ }
+
+ @Test
+ public void shouldProvideMimeTypeForCalendar_geol_ics() throws Exception {
+ testMimeType("docs/icaltestdata/geo1.ics", expectedMimeTypeForCalendar_geol_ics());
+ }
+
+ @Test
+ public void shouldProvideMimeTypeForCalendar_gkexample_ics() throws Exception {
+ testMimeType("docs/icaltestdata/gkexample.ics", expectedMimeTypeForCalendar_gkexample_ics());
+ }
+
+ @Test
+ public void shouldProvideMimeTypeForCalendar_incoming_ics() throws Exception {
+ testMimeType("docs/icaltestdata/incoming.ics", expectedMimeTypeForCalendar_incoming_ics());
+ }
+
+ @Test
+ public void shouldProvideMimeTypeForCalendar_korganizer_jicaltest_vjournal_ics() throws Exception {
+ testMimeType("docs/icaltestdata/korganizer-jicaltest-vjournal.ics",
+ expectedMimeTypeForCalendar_korganizer_jicaltest_vjournal_ics());
+ }
+
+ @Test
+ public void shouldProvideMimeTypeForCalendar_korganizer_jicaltest_ics() throws Exception {
+ testMimeType("docs/icaltestdata/korganizer-jicaltest.ics", expectedMimeTypeForCalendar_korganizer_jicaltest_ics());
+ }
+
+ @Test
+ public void shouldProvideMimeTypeForCalendar_php_flp_ics() throws Exception {
+ testMimeType("docs/icaltestdata/php-flp.ics", expectedMimeTypeForCalendar_php_flp_ics());
+ }
+
+ @Test
+ public void shouldProvideMimeTypeForCalendar_simplevevent_ics() throws Exception {
+ testMimeType("docs/icaltestdata/simplevevent.ics", expectedMimeTypeForCalendar_simplevevent_ics());
+ }
+
+ @Test
+ public void shouldProvideMimeTypeForCalendar_sunbird_sample_ics() throws Exception {
+ testMimeType("docs/icaltestdata/sunbird_sample.ics", expectedMimeTypeForCalendar_sunbird_sample_ics());
+ }
+
+ @Test
+ public void shouldProvideMimeTypeForCalendar_tag_bug_ics() throws Exception {
+ testMimeType("docs/icaltestdata/tag-bug.ics", expectedMimeTypeForCalendar_tag_bug_ics());
+ }
+
+ @Test
+ public void shouldProvideMimeTypeForCalendar_test_created_ics() throws Exception {
+ testMimeType("docs/icaltestdata/test-created.ics", expectedMimeTypeForCalendar_test_created_ics());
+ }
+
+ @Test
+ public void shouldProvideMimeTypeForCalendar_Todos1_ics() throws Exception {
+ testMimeType("docs/icaltestdata/Todos1.ics", expectedMimeTypeForCalendar_Todos1_ics());
+ }
+
+ @Test
+ public void shouldProvideMimeTypeForAu() throws Exception {
+ testMimeType("test.au", expectedMimeTypeForAu());
+ }
+
+ @Test
+ public void shouldProvideMimeTypeForBin() throws Exception {
+ testMimeType("test.bin", expectedMimeTypeForBin());
+ }
+
+ @Test
+ public void shouldProvideMimeTypeForEmf() throws Exception {
+ testMimeType("test.emf", expectedMimeTypeForEmf());
+ }
+
+ @Test
+ public void shouldProvideMimeTypeForFli() throws Exception {
+ testMimeType("test.fli", expectedMimeTypeForFli());
+ }
+
+ @Test
+ public void shouldProvideMimeTypeForPcx() throws Exception {
+ testMimeType("test.pcx", expectedMimeTypeForPcx());
+ }
+
+ @Test
+ public void shouldProvideMimeTypeForPict() throws Exception {
+ testMimeType("test.pict", expectedMimeTypeForPict());
+ }
+
+ @Test
+ public void shouldProvideMimeTypeForPsd() throws Exception {
+ testMimeType("test.psd", expectedMimeTypeForPsd());
+ }
+
+ @Test
+ public void shouldProvideMimeTypeForTar() throws Exception {
+ testMimeType("test.tar", expectedMimeTypeForTar());
+ }
+}
Property changes on: trunk/dna-graph/src/test/java/org/jboss/dna/graph/mimetype/AbstractMimeTypeTest.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
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-05-21 19:03:27 UTC (rev 920)
+++ trunk/dna-repository/src/main/java/org/jboss/dna/repository/DnaEngine.java 2009-05-21 19:10:30 UTC (rev 921)
@@ -47,13 +47,13 @@
import org.jboss.dna.graph.connector.RepositorySourceException;
import org.jboss.dna.graph.mimetype.ExtensionBasedMimeTypeDetector;
import org.jboss.dna.graph.mimetype.MimeTypeDetector;
+import org.jboss.dna.graph.mimetype.MimeTypeDetectorConfig;
+import org.jboss.dna.graph.mimetype.MimeTypeDetectors;
import org.jboss.dna.graph.property.Name;
import org.jboss.dna.graph.property.Path;
import org.jboss.dna.graph.property.PathExpression;
import org.jboss.dna.graph.property.PathNotFoundException;
import org.jboss.dna.graph.property.Property;
-import org.jboss.dna.repository.mimetype.MimeTypeDetectorConfig;
-import org.jboss.dna.repository.mimetype.MimeTypeDetectors;
import org.jboss.dna.repository.sequencer.SequencerConfig;
import org.jboss.dna.repository.sequencer.SequencingService;
Deleted: trunk/dna-repository/src/main/java/org/jboss/dna/repository/mimetype/MimeTypeDetectorConfig.java
===================================================================
--- trunk/dna-repository/src/main/java/org/jboss/dna/repository/mimetype/MimeTypeDetectorConfig.java 2009-05-21 19:03:27 UTC (rev 920)
+++ trunk/dna-repository/src/main/java/org/jboss/dna/repository/mimetype/MimeTypeDetectorConfig.java 2009-05-21 19:10:30 UTC (rev 921)
@@ -1,55 +0,0 @@
-/*
- * JBoss DNA (http://www.jboss.org/dna)
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- * See the AUTHORS.txt file in the distribution for a full listing of
- * individual contributors.
- *
- * JBoss DNA is free software. Unless otherwise indicated, all code in JBoss DNA
- * is licensed to you under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * JBoss DNA is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.dna.repository.mimetype;
-
-import java.util.Map;
-import org.jboss.dna.common.component.ComponentConfig;
-import org.jboss.dna.graph.mimetype.MimeTypeDetector;
-
-/**
- * @author jverhaeg
- */
-public class MimeTypeDetectorConfig extends ComponentConfig {
-
- public MimeTypeDetectorConfig( String name,
- String description,
- Map<String, Object> properties,
- String classname,
- String[] classpath ) {
- super(name, description, properties, classname, classpath);
- }
-
- public MimeTypeDetectorConfig( String name,
- String description,
- Map<String, Object> properties,
- Class<? extends MimeTypeDetector> clazz ) {
- super(name, description, properties, clazz.getName());
- }
-
- public MimeTypeDetectorConfig( String name,
- String description,
- Class<? extends MimeTypeDetector> clazz ) {
- super(name, description, clazz.getName());
- }
-}
Deleted: trunk/dna-repository/src/main/java/org/jboss/dna/repository/mimetype/MimeTypeDetectors.java
===================================================================
--- trunk/dna-repository/src/main/java/org/jboss/dna/repository/mimetype/MimeTypeDetectors.java 2009-05-21 19:03:27 UTC (rev 920)
+++ trunk/dna-repository/src/main/java/org/jboss/dna/repository/mimetype/MimeTypeDetectors.java 2009-05-21 19:10:30 UTC (rev 921)
@@ -1,162 +0,0 @@
-/*
- * JBoss DNA (http://www.jboss.org/dna)
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- * See the AUTHORS.txt file in the distribution for a full listing of
- * individual contributors.
- *
- * JBoss DNA is free software. Unless otherwise indicated, all code in JBoss DNA
- * is licensed to you under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * JBoss DNA is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.dna.repository.mimetype;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.concurrent.atomic.AtomicReference;
-import net.jcip.annotations.ThreadSafe;
-import org.jboss.dna.common.component.ClassLoaderFactory;
-import org.jboss.dna.common.component.ComponentLibrary;
-import org.jboss.dna.common.component.StandardClassLoaderFactory;
-import org.jboss.dna.common.util.Logger;
-import org.jboss.dna.graph.mimetype.MimeTypeDetector;
-
-/**
- * Facility for managing {@link MimeTypeDetectorConfig}s.
- *
- * @author jverhaeg
- */
-@ThreadSafe
-public final class MimeTypeDetectors implements MimeTypeDetector {
-
- /**
- * Class loader factory instance that always returns the {@link Thread#getContextClassLoader() current thread's context class
- * loader}, or if <code>null</code> the class loader for this class.
- */
- protected static final ClassLoaderFactory DEFAULT_CLASSLOADER_FACTORY = new StandardClassLoaderFactory(
- MimeTypeDetectors.class.getClassLoader());
-
- private final ComponentLibrary<MimeTypeDetector, MimeTypeDetectorConfig> library;
- private final AtomicReference<Logger> logger;
-
- public MimeTypeDetectors() {
- logger = new AtomicReference<Logger>(Logger.getLogger(getClass()));
- library = new ComponentLibrary<MimeTypeDetector, MimeTypeDetectorConfig>(true);
- library.setClassLoaderFactory(DEFAULT_CLASSLOADER_FACTORY);
- }
-
- /**
- * Adds the configuration for a MIME-type detector <em>before</em> any previously added configurations, or updates any
- * existing one that represents the {@link MimeTypeDetectorConfig#equals(Object) same configuration}
- *
- * @param config the new configuration; must not be <code>null</code>.
- * @return <code>true</code> if the detector was added, or <code>false</code> if there already was an existing detector
- * configuration.
- * @see #removeDetector(MimeTypeDetectorConfig)
- */
- public boolean addDetector( MimeTypeDetectorConfig config ) {
- return library.add(config);
- }
-
- /**
- * Gets the class loader factory that should be used to load MIME-type detectors. By default, this service uses a factory that
- * will return either the {@link Thread#getContextClassLoader() current thread's context class loader}, or if
- * <code>null</code> the class loader for this class.
- *
- * @return the class loader factory; never <code>null</code>
- * @see #setClassLoaderFactory(ClassLoaderFactory)
- */
- public ClassLoaderFactory getClassLoaderFactory() {
- return library.getClassLoaderFactory();
- }
-
- /**
- * Gets the logger for this system
- *
- * @return the logger
- */
- public Logger getLogger() {
- return logger.get();
- }
-
- /**
- * Returns the first non-null result of iterating over the {@link #addDetector(MimeTypeDetectorConfig) registered} MIME-type
- * detectors in the reverse order in which they were registered to determine the MIME-type of a data source, using its
- * supplied content and/or its supplied name, depending upon the implementation. If the MIME-type cannot be determined by any
- * registered detector, "text/plain" or "application/octet-stream" will be returned, the former only if it is determined the
- * stream contains no nulls.
- *
- * @param name The name of the data source; may be <code>null</code>.
- * @param content The content of the data source; may be <code>null</code>.
- * @return The MIME-type of the data source; never <code>null</code>.
- * @throws IOException If an error occurs reading the supplied content.
- */
- public String mimeTypeOf( String name,
- InputStream content ) throws IOException {
- if (content != null && content.markSupported()) {
- content.mark(Integer.MAX_VALUE);
- }
- // Check if registered detectors can determine MIME-type
- for (MimeTypeDetector detector : library.getInstances()) {
- String mimeType = detector.mimeTypeOf(name, content);
- if (mimeType != null) return mimeType;
- }
- // If not, try to analyze stream to determine if it represents text or binary content
- if (content != null && content.markSupported()) {
- try {
- content.reset();
- for (int chr = content.read(); chr >= 0; chr = content.read()) {
- if (chr == 0) return "application/octet-stream";
- }
- } catch (IOException meansTooManyBytesRead) {
- return "application/octet-stream";
- }
- }
- return "text/plain";
- }
-
- /**
- * Removes the configuration for a MIME-type detector.
- *
- * @param config the configuration to be removed; must not be <code>null</code>.
- * @return <code>true</code> if the configuration was removed, or <code>false</code> if there was no existing configuration
- * @see #addDetector(MimeTypeDetectorConfig)
- */
- public boolean removeDetector( MimeTypeDetectorConfig config ) {
- return library.remove(config);
- }
-
- /**
- * Sets the Maven Repository that should be used to load the MIME-type detectors. By default, this service uses a factory that
- * will return either the {@link Thread#getContextClassLoader() current thread's context class loader}, or if
- * <code>null</code> the class loader for this class.
- *
- * @param classLoaderFactory the class loader factory, or <code>null</code> if the default class loader factory should be
- * used.
- * @see #getClassLoaderFactory()
- */
- public void setClassLoaderFactory( ClassLoaderFactory classLoaderFactory ) {
- library.setClassLoaderFactory(classLoaderFactory != null ? classLoaderFactory : DEFAULT_CLASSLOADER_FACTORY);
- }
-
- /**
- * Sets the logger for this system.
- *
- * @param logger the logger, or <code>null</code> if the standard logging should be used
- */
- public void setLogger( Logger logger ) {
- this.logger.set(logger != null ? logger : Logger.getLogger(getClass()));
- }
-}
Deleted: trunk/dna-repository/src/test/java/org/jboss/dna/repository/mimetype/AbstractMimeTypeTest.java
===================================================================
--- trunk/dna-repository/src/test/java/org/jboss/dna/repository/mimetype/AbstractMimeTypeTest.java 2009-05-21 19:03:27 UTC (rev 920)
+++ trunk/dna-repository/src/test/java/org/jboss/dna/repository/mimetype/AbstractMimeTypeTest.java 2009-05-21 19:10:30 UTC (rev 921)
@@ -1,1417 +0,0 @@
-/*
- * JBoss DNA (http://www.jboss.org/dna)
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- * See the AUTHORS.txt file in the distribution for a full listing of
- * individual contributors.
- *
- * JBoss DNA is free software. Unless otherwise indicated, all code in JBoss DNA
- * is licensed to you under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * JBoss DNA is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.dna.repository.mimetype;
-
-import static org.hamcrest.core.Is.is;
-import static org.hamcrest.core.IsNull.notNullValue;
-import static org.junit.Assert.assertThat;
-import java.io.File;
-import java.io.InputStream;
-import java.util.Collections;
-import org.jboss.dna.graph.mimetype.MimeTypeDetector;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-
-/**
- * All test classes that test {@link MimeTypeDetector MIME-type detector implementations} should extend this class to help ensure
- * all implementations test the same types of data sources.
- *
- * @author John Verhaeg
- */
-public abstract class AbstractMimeTypeTest {
-
- private final MimeTypeDetectorConfig config;
- private MimeTypeDetectors detectors;
-
- protected AbstractMimeTypeTest( Class<? extends MimeTypeDetector> detector ) {
- assertThat(detector, notNullValue());
- this.config = new MimeTypeDetectorConfig("MIME-Type Detector", "MIME-Type Detector",
- Collections.<String, Object>emptyMap(), detector.getName(), null);
- }
-
- @Before
- public void before() throws Exception {
- detectors = new MimeTypeDetectors();
- detectors.addDetector(config);
- }
-
- @After
- public void after() {
- detectors.removeDetector(config);
- }
-
- protected void testMimeType( String name,
- String mimeType ) throws Exception {
- InputStream content = new File("../../dna-repository/src/test/resources/" + name).toURI().toURL().openStream();
- assertThat(detectors.mimeTypeOf(name, content), is(mimeType));
- }
-
- protected abstract String expectedMimeTypeForText_test_txt();
-
- protected abstract String expectedMimeTypeForText_plain_text_txt();
-
- protected abstract String expectedMimeTypeForText_plain_text_ansi_txt();
-
- protected abstract String expectedMimeTypeForText_plain_text_empty_txt();
-
- protected abstract String expectedMimeTypeForText_plain_text_utf16be_txt();
-
- protected abstract String expectedMimeTypeForText_plain_text_utf16le_txt();
-
- protected abstract String expectedMimeTypeForText_plain_text_utf8_txt();
-
- protected abstract String expectedMimeTypeForText_plain_text_with_null_character_txt();
-
- protected abstract String expectedMimeTypeForText_plain_text_without_extension();
-
- protected abstract String expectedMimeTypeForRtf_test_rtf();
-
- protected abstract String expectedMimeTypeForRtf_rtf_openoffice_1_1_5_rtf();
-
- protected abstract String expectedMimeTypeForRtf_rtf_openoffice_2_0_rtf();
-
- protected abstract String expectedMimeTypeForRtf_rtf_staroffice_5_2_rtf();
-
- protected abstract String expectedMimeTypeForRtf_rtf_word_2000_rtf();
-
- protected abstract String expectedMimeTypeForMp3_test_mp3();
-
- protected abstract String expectedMimeTypeForMp3_test_128_44_jstereo_mp3();
-
- protected abstract String expectedMimeTypeForMp3_jingle1_mp3();
-
- protected abstract String expectedMimeTypeForMp3_jingle2_mp3();
-
- protected abstract String expectedMimeTypeForMp3_jingle3_mp3();
-
- protected abstract String expectedMimeTypeForWav();
-
- protected abstract String expectedMimeTypeForBmp();
-
- protected abstract String expectedMimeTypeForGif();
-
- protected abstract String expectedMimeTypeForIcon();
-
- protected abstract String expectedMimeTypeForJpeg_test_jpg();
-
- protected abstract String expectedMimeTypeForJpeg_jpg_exif_img_9367_JPG();
-
- protected abstract String expectedMimeTypeForJpeg_jpg_exif_zerolength_jpg();
-
- protected abstract String expectedMimeTypeForJpeg_jpg_geotagged_jpg();
-
- protected abstract String expectedMimeTypeForJpeg_jpg_geotagged_ipanema_jpg();
-
- protected abstract String expectedMimeTypeForPortablePixelMap_test_ppm();
-
- protected abstract String expectedMimeTypeForPortablePixelMap_test_pnm();
-
- protected abstract String expectedMimeTypeForPng();
-
- protected abstract String expectedMimeTypeForTiff();
-
- protected abstract String expectedMimeTypeForTga();
-
- protected abstract String expectedMimeTypeForWmf();
-
- protected abstract String expectedMimeTypeForXcf();
-
- protected abstract String expectedMimeTypeForXpm();
-
- protected abstract String expectedMimeTypeForXml_test_xml();
-
- protected abstract String expectedMimeTypeForXml_test_excel_spreadsheet_xml();
-
- protected abstract String expectedMimeTypeForXml_CurrencyFormatterExample_mxml();
-
- protected abstract String expectedMimeTypeForXml_xml_handwritten_xml();
-
- protected abstract String expectedMimeTypeForXml_xml_nonexistent_dtd_xml();
-
- protected abstract String expectedMimeTypeForXml_xml_nonexistent_remote_dtd_xml();
-
- protected abstract String expectedMimeTypeForXml_xml_nonexistent_remote_xsd_xml();
-
- protected abstract String expectedMimeTypeForXml_xml_nonexistent_xsd_xml();
-
- protected abstract String expectedMimeTypeForXml_xml_utf8_bom();
-
- protected abstract String expectedMimeTypeForXsd();
-
- protected abstract String expectedMimeTypeForDtd();
-
- protected abstract String expectedMimeTypeForHtml_master_xml();
-
- protected abstract String expectedMimeTypeForHtml_html_condenast_html();
-
- protected abstract String expectedMimeTypeForHtml_html_handwritten_html();
-
- protected abstract String expectedMimeTypeForHtml_html_handwritten_with_wrong_file_extension_txt();
-
- protected abstract String expectedMimeTypeForHtml_html_quelle_de_html();
-
- protected abstract String expectedMimeTypeForHtml_html_utf16_leading_whitespace_wrong_extension_doc();
-
- protected abstract String expectedMimeTypeForJava();
-
- protected abstract String expectedMimeTypeFor1_2Class();
-
- protected abstract String expectedMimeTypeFor1_3Class();
-
- protected abstract String expectedMimeTypeFor1_4Class();
-
- protected abstract String expectedMimeTypeForPerl();
-
- protected abstract String expectedMimeTypeForPython();
-
- protected abstract String expectedMimeTypeForPdf_test_pdf();
-
- protected abstract String expectedMimeTypeForPdf_pdf_distiller_6_weirdchars_pdf();
-
- protected abstract String expectedMimeTypeForPdf_pdf_no_author_pdf();
-
- protected abstract String expectedMimeTypeForPdf_pdf_openoffice_1_1_5_writer_pdf();
-
- protected abstract String expectedMimeTypeForPdf_pdf_openoffice_2_0_writer_pdf();
-
- protected abstract String expectedMimeTypeForPdf_pdf_word_2000_pdfcreator_0_8_0_pdf();
-
- protected abstract String expectedMimeTypeForPdf_pdf_word_2000_pdfmaker_7_0_pdf();
-
- protected abstract String expectedMimeTypeForPdf_pdf_word_2000_pdfwriter_7_0_pdf();
-
- protected abstract String expectedMimeTypeForPostscript_test_ps();
-
- protected abstract String expectedMimeTypeForPostscript_test_eps();
-
- protected abstract String expectedMimeTypeForJar();
-
- protected abstract String expectedMimeTypeForJavaManifest();
-
- protected abstract String expectedMimeTypeForGZip_test_tar_gz();
-
- protected abstract String expectedMimeTypeForGZip_test_txt_gz();
-
- protected abstract String expectedMimeTypeForZip();
-
- protected abstract String expectedMimeTypeForBash();
-
- protected abstract String expectedMimeTypeForOgg();
-
- protected abstract String expectedMimeTypeForOpenDocumentFormula();
-
- protected abstract String expectedMimeTypeForOpenDocumentGraphics();
-
- protected abstract String expectedMimeTypeForOpenDocumentGraphicsTemplate();
-
- protected abstract String expectedMimeTypeForOpenDocumentPresentation_component_architecture_odp();
-
- protected abstract String expectedMimeTypeForOpenDocumentPresentation_openoffice_2_0_impress_odp();
-
- protected abstract String expectedMimeTypeForOpenDocumentPresentationTemplate();
-
- protected abstract String expectedMimeTypeForOpenDocumentSpreadsheet();
-
- protected abstract String expectedMimeTypeForOpenDocumentSpreadsheetTemplate();
-
- protected abstract String expectedMimeTypeForOpenDocumentText();
-
- protected abstract String expectedMimeTypeForOpenDocumentTextTemplate();
-
- protected abstract String expectedMimeTypeForOpenOfficeCalc();
-
- protected abstract String expectedMimeTypeForOpenOfficeCalcTemplate();
-
- protected abstract String expectedMimeTypeForOpenOfficeDraw();
-
- protected abstract String expectedMimeTypeForOpenOfficeDrawTemplate();
-
- protected abstract String expectedMimeTypeForOpenOfficeImpress();
-
- protected abstract String expectedMimeTypeForOpenOfficeImpressTemplate();
-
- protected abstract String expectedMimeTypeForOpenOfficeWriter();
-
- protected abstract String expectedMimeTypeForOpenOfficeWriterTemplate();
-
- protected abstract String expectedMimeTypeForStarOfficeCalc();
-
- protected abstract String expectedMimeTypeForStarOfficeDraw();
-
- protected abstract String expectedMimeTypeForStarOfficeImpress();
-
- protected abstract String expectedMimeTypeForStarOfficeWriter();
-
- protected abstract String expectedMimeTypeForStarOfficeCalcTemplate();
-
- protected abstract String expectedMimeTypeForStarOfficeDrawTemplate();
-
- protected abstract String expectedMimeTypeForStarOfficeImpressTemplate();
-
- protected abstract String expectedMimeTypeForStarOfficeWriterTemplate();
-
- protected abstract String expectedMimeTypeForWord_test_word_2000_doc();
-
- protected abstract String expectedMimeTypeForWord_test_word_6_0_95_doc();
-
- protected abstract String expectedMimeTypeForWord_microsoft_word_2000_doc();
-
- protected abstract String expectedMimeTypeForWord_microsoft_word_2000_with_wrong_file_extension_pdf();
-
- protected abstract String expectedMimeTypeForWord_microsoft_word_2007beta2_docm();
-
- protected abstract String expectedMimeTypeForWord_microsoft_word_2007beta2_docx();
-
- protected abstract String expectedMimeTypeForWord_microsoft_word_2007beta2_dotm();
-
- protected abstract String expectedMimeTypeForWord_microsoft_word_2007beta2_dotx();
-
- protected abstract String expectedMimeTypeForWorks_microsoft_works_spreadsheet_4_0_2000_wks();
-
- protected abstract String expectedMimeTypeForWorks_microsoft_works_spreadsheet_7_0_xlr();
-
- protected abstract String expectedMimeTypeForWorks_microsoft_works_word_processor_2000_wps();
-
- protected abstract String expectedMimeTypeForWorks_microsoft_works_word_processor_3_0_wps();
-
- protected abstract String expectedMimeTypeForWorks_microsoft_works_word_processor_4_0_wps();
-
- protected abstract String expectedMimeTypeForWorks_microsoft_works_word_processor_7_0_wps();
-
- protected abstract String expectedMimeTypeForWorkbook_corel_quattro_pro_6_wb2();
-
- protected abstract String expectedMimeTypeForWorkbook_microsoft_works_spreadsheet_3_0_wks();
-
- protected abstract String expectedMimeTypeForExcel_test_excel_2000_xls();
-
- protected abstract String expectedMimeTypeForExcel_microsoft_excel_2000_xls();
-
- protected abstract String expectedMimeTypeForExcel_microsoft_excel_2007beta2_xlam();
-
- protected abstract String expectedMimeTypeForExcel_microsoft_excel_2007beta2_xlsb();
-
- protected abstract String expectedMimeTypeForExcel_microsoft_excel_2007beta2_xlsm();
-
- protected abstract String expectedMimeTypeForExcel_microsoft_excel_2007beta2_xlsx();
-
- protected abstract String expectedMimeTypeForExcel_microsoft_excel_2007beta2_xltm();
-
- protected abstract String expectedMimeTypeForExcel_microsoft_excel_2007beta2_xltx();
-
- protected abstract String expectedMimeTypeForPowerpoint_test_ppt();
-
- protected abstract String expectedMimeTypeForPowerpoint_microsoft_powerpoint_2000_ppt();
-
- protected abstract String expectedMimeTypeForPowerpoint_microsoft_powerpoint_2007beta2_potm();
-
- protected abstract String expectedMimeTypeForPowerpoint_microsoft_powerpoint_2007beta2_potx();
-
- protected abstract String expectedMimeTypeForPowerpoint_microsoft_powerpoint_2007beta2_ppsm();
-
- protected abstract String expectedMimeTypeForPowerpoint_microsoft_powerpoint_2007beta2_ppsx();
-
- protected abstract String expectedMimeTypeForPowerpoint_microsoft_powerpoint_2007beta2_pptm();
-
- protected abstract String expectedMimeTypeForPowerpoint_microsoft_powerpoint_2007beta2_pptx();
-
- protected abstract String expectedMimeTypeForPublisher();
-
- protected abstract String expectedMimeTypeForVisio();
-
- protected abstract String expectedMimeTypeForOutlook();
-
- protected abstract String expectedMimeTypeForShw_corel_presentations_3_0_shw();
-
- protected abstract String expectedMimeTypeForShw_corel_presentations_x3_shw();
-
- protected abstract String expectedMimeTypeForPro_corel_quattro_pro_7_wb3();
-
- protected abstract String expectedMimeTypeForPro_corel_quattro_pro_x3_qpw();
-
- protected abstract String expectedMimeTypeForWordperfect_corel_wordperfect_4_2_wp();
-
- protected abstract String expectedMimeTypeForWordperfect_corel_wordperfect_5_0_wp();
-
- protected abstract String expectedMimeTypeForWordperfect_corel_wordperfect_5_1_wp();
-
- protected abstract String expectedMimeTypeForWordperfect_corel_wordperfect_5_1_far_east_wp();
-
- protected abstract String expectedMimeTypeForWordperfect_corel_wordperfect_x3_wpd();
-
- protected abstract String expectedMimeTypeForMail_test_excel_web_archive_mht();
-
- protected abstract String expectedMimeTypeForMail_mail_thunderbird_1_5_eml();
-
- protected abstract String expectedMimeTypeForMail_mhtml_firefox_mht();
-
- protected abstract String expectedMimeTypeForMail_mhtml_internet_explorer_mht();
-
- protected abstract String expectedMimeTypeForAddressBook();
-
- protected abstract String expectedMimeTypeForVCard_vcard_antoni_kontact_vcf();
-
- protected abstract String expectedMimeTypeForVCard_vcard_antoni_outlook2003_vcf();
-
- protected abstract String expectedMimeTypeForVCard_vcard_dirk_vcf();
-
- protected abstract String expectedMimeTypeForVCard_vcard_rfc2426_vcf();
-
- protected abstract String expectedMimeTypeForVCard_vcard_vCards_SAP_vcf();
-
- protected abstract String expectedMimeTypeForCalendar_basicCalendar_ics();
-
- protected abstract String expectedMimeTypeForCalendar_cal01_ics();
-
- protected abstract String expectedMimeTypeForCalendar_cal01_1_ics();
-
- protected abstract String expectedMimeTypeForCalendar_cal01_2_ics();
-
- protected abstract String expectedMimeTypeForCalendar_cal01_3_ics();
-
- protected abstract String expectedMimeTypeForCalendar_cal01_4_ics();
-
- protected abstract String expectedMimeTypeForCalendar_cal01_5_ics();
-
- protected abstract String expectedMimeTypeForCalendar_cal01_6_ics();
-
- protected abstract String expectedMimeTypeForCalendar_cal01_exrule_ics();
-
- protected abstract String expectedMimeTypeForCalendar_calconnect7_ics();
-
- protected abstract String expectedMimeTypeForCalendar_calconnect9_ics();
-
- protected abstract String expectedMimeTypeForCalendar_combined_multiplevcalendar_ics();
-
- protected abstract String expectedMimeTypeForCalendar_combined_onevcalendar_ics();
-
- protected abstract String expectedMimeTypeForCalendar_extendedCalendar_ics();
-
- protected abstract String expectedMimeTypeForCalendar_freebusy_ics();
-
- protected abstract String expectedMimeTypeForCalendar_geol_ics();
-
- protected abstract String expectedMimeTypeForCalendar_gkexample_ics();
-
- protected abstract String expectedMimeTypeForCalendar_incoming_ics();
-
- protected abstract String expectedMimeTypeForCalendar_korganizer_jicaltest_vjournal_ics();
-
- protected abstract String expectedMimeTypeForCalendar_korganizer_jicaltest_ics();
-
- protected abstract String expectedMimeTypeForCalendar_php_flp_ics();
-
- protected abstract String expectedMimeTypeForCalendar_simplevevent_ics();
-
- protected abstract String expectedMimeTypeForCalendar_sunbird_sample_ics();
-
- protected abstract String expectedMimeTypeForCalendar_tag_bug_ics();
-
- protected abstract String expectedMimeTypeForCalendar_test_created_ics();
-
- protected abstract String expectedMimeTypeForCalendar_Todos1_ics();
-
- protected abstract String expectedMimeTypeForAu();
-
- protected abstract String expectedMimeTypeForBin();
-
- protected abstract String expectedMimeTypeForEmf();
-
- protected abstract String expectedMimeTypeForFli();
-
- protected abstract String expectedMimeTypeForPcx();
-
- protected abstract String expectedMimeTypeForPict();
-
- protected abstract String expectedMimeTypeForPsd();
-
- protected abstract String expectedMimeTypeForTar();
-
- @Test
- public void shouldProvideMimeTypeForText_test_txt() throws Exception {
- testMimeType("test.txt", expectedMimeTypeForText_test_txt());
- }
-
- @Test
- public void shouldProvideMimeTypeForText_plain_text_txt() throws Exception {
- testMimeType("docs/plain-text.txt", expectedMimeTypeForText_plain_text_txt());
- }
-
- @Test
- public void shouldProvideMimeTypeForText_plain_text_ansi_txt() throws Exception {
- testMimeType("docs/plain-text-ansi.txt", expectedMimeTypeForText_plain_text_ansi_txt());
- }
-
- @Test
- public void shouldProvideMimeTypeForText_plain_text_empty_txt() throws Exception {
- testMimeType("docs/plain-text-empty.txt", expectedMimeTypeForText_plain_text_empty_txt());
- }
-
- @Test
- public void shouldProvideMimeTypeForText_plain_text_utf16be_txt() throws Exception {
- testMimeType("docs/plain-text-utf16be.txt", expectedMimeTypeForText_plain_text_utf16be_txt());
- }
-
- @Test
- public void shouldProvideMimeTypeForText_plain_text_utf16le_txt() throws Exception {
- testMimeType("docs/plain-text-utf16le.txt", expectedMimeTypeForText_plain_text_utf16le_txt());
- }
-
- @Test
- public void shouldProvideMimeTypeForText_plain_text_utf8_txt() throws Exception {
- testMimeType("docs/plain-text-utf8.txt", expectedMimeTypeForText_plain_text_utf8_txt());
- }
-
- @Test
- public void shouldProvideMimeTypeForText_plain_text_with_null_character_txt() throws Exception {
- testMimeType("docs/plain-text-with-null-character.txt", expectedMimeTypeForText_plain_text_with_null_character_txt());
- }
-
- @Test
- public void shouldProvideMimeTypeForText_plain_text_without_extension() throws Exception {
- testMimeType("docs/plain-text-without-extension", expectedMimeTypeForText_plain_text_without_extension());
- }
-
- @Test
- public void shouldProvideMimeTypeForRtf_test_rtf() throws Exception {
- testMimeType("test.rtf", expectedMimeTypeForRtf_test_rtf());
- }
-
- @Test
- public void shouldProvideMimeTypeForRtf_rtf_openoffice_1_1_5_rtf() throws Exception {
- testMimeType("docs/rtf-openoffice-1.1.5.rtf", expectedMimeTypeForRtf_rtf_openoffice_1_1_5_rtf());
- }
-
- @Test
- public void shouldProvideMimeTypeForRtf_rtf_openoffice_2_0_rtf() throws Exception {
- testMimeType("docs/rtf-openoffice-2.0.rtf", expectedMimeTypeForRtf_rtf_openoffice_2_0_rtf());
- }
-
- @Test
- public void shouldProvideMimeTypeForRtf_rtf_staroffice_5_2_rtf() throws Exception {
- testMimeType("docs/rtf-staroffice-5.2.rtf", expectedMimeTypeForRtf_rtf_staroffice_5_2_rtf());
- }
-
- @Test
- public void shouldProvideMimeTypeForRtf_rtf_word_2000_rtf() throws Exception {
- testMimeType("docs/rtf-word-2000.rtf", expectedMimeTypeForRtf_rtf_word_2000_rtf());
- }
-
- @Test
- public void shouldProvideMimeTypeForMp3_test_mp3() throws Exception {
- testMimeType("test.mp3", expectedMimeTypeForMp3_test_mp3());
- }
-
- @Test
- public void shouldProvideMimeTypeForMp3_test_128_44_jstereo_mp3() throws Exception {
- testMimeType("test_128_44_jstereo.mp3", expectedMimeTypeForMp3_test_128_44_jstereo_mp3());
- }
-
- @Test
- public void shouldProvideMimeTypeForMp3_jingle1_mp3() throws Exception {
- testMimeType("docs/jingle1.mp3", expectedMimeTypeForMp3_jingle1_mp3());
- }
-
- @Test
- public void shouldProvideMimeTypeForMp3_jingle2_mp3() throws Exception {
- testMimeType("docs/jingle2.mp3", expectedMimeTypeForMp3_jingle2_mp3());
- }
-
- @Test
- public void shouldProvideMimeTypeForMp3_jingle3_mp3() throws Exception {
- testMimeType("docs/jingle3.mp3", expectedMimeTypeForMp3_jingle3_mp3());
- }
-
- @Test
- public void shouldProvideMimeTypeForWav() throws Exception {
- testMimeType("test.wav", expectedMimeTypeForWav());
- }
-
- @Test
- public void shouldProvideMimeTypeForBmp() throws Exception {
- testMimeType("test.bmp", expectedMimeTypeForBmp());
- }
-
- @Test
- public void shouldProvideMimeTypeForGif() throws Exception {
- testMimeType("test.gif", expectedMimeTypeForGif());
- }
-
- @Test
- public void shouldProvideMimeTypeForIcon() throws Exception {
- testMimeType("test.ico", expectedMimeTypeForIcon());
- }
-
- @Test
- public void shouldProvideMimeTypeForJpeg_test_jpg() throws Exception {
- testMimeType("test.jpg", expectedMimeTypeForJpeg_test_jpg());
- }
-
- @Test
- public void shouldProvideMimeTypeForJpeg_jpg_exif_img_9367_JPG() throws Exception {
- testMimeType("docs/jpg-exif-img_9367.JPG", expectedMimeTypeForJpeg_jpg_exif_img_9367_JPG());
- }
-
- @Test
- public void shouldProvideMimeTypeForJpeg_jpg_exif_zerolength_jpg() throws Exception {
- testMimeType("docs/jpg-exif-zerolength.jpg", expectedMimeTypeForJpeg_jpg_exif_zerolength_jpg());
- }
-
- @Test
- public void shouldProvideMimeTypeForJpeg_jpg_geotagged_jpg() throws Exception {
- testMimeType("docs/jpg-geotagged.jpg", expectedMimeTypeForJpeg_jpg_geotagged_jpg());
- }
-
- @Test
- public void shouldProvideMimeTypeForJpeg_jpg_geotagged_ipanema_jpg() throws Exception {
- testMimeType("docs/jpg-geotagged-ipanema.jpg", expectedMimeTypeForJpeg_jpg_geotagged_ipanema_jpg());
- }
-
- @Test
- public void shouldProvideMimeTypeForPortablePixelMap_test_ppm() throws Exception {
- testMimeType("test.ppm", expectedMimeTypeForPortablePixelMap_test_ppm());
- }
-
- @Test
- public void shouldProvideMimeTypeForPortablePixelMap_test_pnm() throws Exception {
- testMimeType("test.pnm", expectedMimeTypeForPortablePixelMap_test_pnm());
- }
-
- @Test
- public void shouldProvideMimeTypeForPng() throws Exception {
- testMimeType("test.png", expectedMimeTypeForPng());
- }
-
- @Test
- public void shouldProvideMimeTypeForTiff() throws Exception {
- testMimeType("test_nocompress.tif", expectedMimeTypeForTiff());
- }
-
- @Test
- public void shouldProvideMimeTypeForTga() throws Exception {
- testMimeType("test.tga", expectedMimeTypeForTga());
- }
-
- @Test
- public void shouldProvideMimeTypeForWmf() throws Exception {
- testMimeType("test.wmf", expectedMimeTypeForWmf());
- }
-
- @Test
- public void shouldProvideMimeTypeForXcf() throws Exception {
- testMimeType("test.xcf", expectedMimeTypeForXcf());
- }
-
- @Test
- public void shouldProvideMimeTypeForXpm() throws Exception {
- testMimeType("test.xpm", expectedMimeTypeForXpm());
- }
-
- @Test
- public void shouldProvideMimeTypeForXml_test_xml() throws Exception {
- testMimeType("test.xml", expectedMimeTypeForXml_test_xml());
- }
-
- @Test
- public void shouldProvideMimeTypeForXml_test_excel_spreadsheet_xml() throws Exception {
- testMimeType("test_excel_spreadsheet.xml", expectedMimeTypeForXml_test_excel_spreadsheet_xml());
- }
-
- @Test
- public void shouldProvideMimeTypeForXml_CurrencyFormatterExample_mxml() throws Exception {
- testMimeType("CurrencyFormatterExample.mxml", expectedMimeTypeForXml_CurrencyFormatterExample_mxml());
- }
-
- @Test
- public void shouldProvideMimeTypeForXml_xml_handwritten_xml() throws Exception {
- testMimeType("docs/xml-handwritten.xml", expectedMimeTypeForXml_xml_handwritten_xml());
- }
-
- @Test
- public void shouldProvideMimeTypeForXml_xml_nonexistent_dtd_xml() throws Exception {
- testMimeType("docs/xml-nonexistent-dtd.xml", expectedMimeTypeForXml_xml_nonexistent_dtd_xml());
- }
-
- @Test
- public void shouldProvideMimeTypeForXml_xml_nonexistent_remote_dtd_xml() throws Exception {
- testMimeType("docs/xml-nonexistent-remote-dtd.xml", expectedMimeTypeForXml_xml_nonexistent_remote_dtd_xml());
- }
-
- @Test
- public void shouldProvideMimeTypeForXml_xml_nonexistent_remote_xsd_xml() throws Exception {
- testMimeType("docs/xml-nonexistent-remote-xsd.xml", expectedMimeTypeForXml_xml_nonexistent_remote_xsd_xml());
- }
-
- @Test
- public void shouldProvideMimeTypeForXml_xml_nonexistent_xsd_xml() throws Exception {
- testMimeType("docs/xml-nonexistent-xsd.xml", expectedMimeTypeForXml_xml_nonexistent_xsd_xml());
- }
-
- @Test
- public void shouldProvideMimeTypeForXml_xml_utf8_bom() throws Exception {
- testMimeType("docs/xml-utf8-bom", expectedMimeTypeForXml_xml_utf8_bom());
- }
-
- @Test
- public void shouldProvideMimeTypeForXsd() throws Exception {
- testMimeType("Descriptor.1.0.xsd", expectedMimeTypeForXsd());
- }
-
- @Test
- public void shouldProvideMimeTypeForDtd() throws Exception {
- testMimeType("test.dtd", expectedMimeTypeForDtd());
- }
-
- @Test
- public void shouldProvideMimeTypeForHtml_master_xml() throws Exception {
- testMimeType("master.xml", expectedMimeTypeForHtml_master_xml());
- }
-
- @Test
- public void shouldProvideMimeTypeForHtml_html_condenast_html() throws Exception {
- testMimeType("docs/html-condenast.html", expectedMimeTypeForHtml_html_condenast_html());
- }
-
- @Test
- public void shouldProvideMimeTypeForHtml_html_handwritten_html() throws Exception {
- testMimeType("docs/html-handwritten.html", expectedMimeTypeForHtml_html_handwritten_html());
- }
-
- @Test
- public void shouldProvideMimeTypeForHtml_html_handwritten_with_wrong_file_extension_txt() throws Exception {
- testMimeType("docs/html-handwritten-with-wrong-file-extension.txt",
- expectedMimeTypeForHtml_html_handwritten_with_wrong_file_extension_txt());
- }
-
- @Test
- public void shouldProvideMimeTypeForHtml_html_quelle_de_html() throws Exception {
- testMimeType("docs/html-quelle.de.html", expectedMimeTypeForHtml_html_quelle_de_html());
- }
-
- @Test
- public void shouldProvideMimeTypeForHtml_html_utf16_leading_whitespace_wrong_extension_doc() throws Exception {
- testMimeType("docs/html-utf16-leading-whitespace-wrong-extension.doc",
- expectedMimeTypeForHtml_html_utf16_leading_whitespace_wrong_extension_doc());
- }
-
- @Test
- public void shouldProvideMimeTypeForJava() throws Exception {
- testMimeType("test.java", expectedMimeTypeForJava());
- }
-
- @Test
- public void shouldProvideMimeTypeFor1_2Class() throws Exception {
- testMimeType("test_1.2.class", expectedMimeTypeFor1_2Class());
- }
-
- @Test
- public void shouldProvideMimeTypeFor1_3Class() throws Exception {
- testMimeType("test_1.3.class", expectedMimeTypeFor1_3Class());
- }
-
- @Test
- public void shouldProvideMimeTypeFor1_4Class() throws Exception {
- testMimeType("test_1.4.class", expectedMimeTypeFor1_4Class());
- }
-
- @Test
- public void shouldProvideMimeTypeForPerl() throws Exception {
- testMimeType("test.pl", expectedMimeTypeForPerl());
- }
-
- @Test
- public void shouldProvideMimeTypeForPython() throws Exception {
- testMimeType("test.py", expectedMimeTypeForPython());
- }
-
- @Test
- public void shouldProvideMimeTypeForPdf_test_pdf() throws Exception {
- testMimeType("test.pdf", expectedMimeTypeForPdf_test_pdf());
- }
-
- @Test
- public void shouldProvideMimeTypeForPdf_pdf_distiller_6_weirdchars_pdf() throws Exception {
- testMimeType("docs/pdf-distiller-6-weirdchars.pdf", expectedMimeTypeForPdf_pdf_distiller_6_weirdchars_pdf());
- }
-
- @Test
- public void shouldProvideMimeTypeForPdf_pdf_no_author_pdf() throws Exception {
- testMimeType("docs/pdf-no-author.pdf", expectedMimeTypeForPdf_pdf_no_author_pdf());
- }
-
- @Test
- public void shouldProvideMimeTypeForPdf_pdf_openoffice_1_1_5_writer_pdf() throws Exception {
- testMimeType("docs/pdf-openoffice-1.1.5-writer.pdf", expectedMimeTypeForPdf_pdf_openoffice_1_1_5_writer_pdf());
- }
-
- @Test
- public void shouldProvideMimeTypeForPdf_pdf_openoffice_2_0_writer_pdf() throws Exception {
- testMimeType("docs/pdf-openoffice-2.0-writer.pdf", expectedMimeTypeForPdf_pdf_openoffice_2_0_writer_pdf());
- }
-
- @Test
- public void shouldProvideMimeTypeForPdf_pdf_word_2000_pdfcreator_0_8_0_pdf() throws Exception {
- testMimeType("docs/pdf-word-2000-pdfcreator-0.8.0.pdf", expectedMimeTypeForPdf_pdf_word_2000_pdfcreator_0_8_0_pdf());
- }
-
- @Test
- public void shouldProvideMimeTypeForPdf_pdf_word_2000_pdfmaker_7_0_pdf() throws Exception {
- testMimeType("docs/pdf-word-2000-pdfmaker-7.0.pdf", expectedMimeTypeForPdf_pdf_word_2000_pdfmaker_7_0_pdf());
- }
-
- @Test
- public void shouldProvideMimeTypeForPdf_pdf_word_2000_pdfwriter_7_0_pdf() throws Exception {
- testMimeType("docs/pdf-word-2000-pdfwriter-7.0.pdf", expectedMimeTypeForPdf_pdf_word_2000_pdfwriter_7_0_pdf());
- }
-
- @Test
- public void shouldProvideMimeTypeForPostscript_test_ps() throws Exception {
- testMimeType("test.ps", expectedMimeTypeForPostscript_test_ps());
- }
-
- @Test
- public void shouldProvideMimeTypeForPostscript_test_eps() throws Exception {
- testMimeType("test.eps", expectedMimeTypeForPostscript_test_eps());
- }
-
- @Test
- public void shouldProvideMimeTypeForJar() throws Exception {
- testMimeType("dna-repository-0.2-SNAPSHOT.jar", expectedMimeTypeForJar());
- }
-
- @Test
- public void shouldProvideMimeTypeForJavaManifest() throws Exception {
- testMimeType("aperture.example.manifest.mf", expectedMimeTypeForJavaManifest());
- }
-
- @Test
- public void shouldProvideMimeTypeForGZip_test_tar_gz() throws Exception {
- testMimeType("test.tar.gz", expectedMimeTypeForGZip_test_tar_gz());
- }
-
- @Test
- public void shouldProvideMimeTypeForGZip_test_txt_gz() throws Exception {
- testMimeType("test.txt.gz", expectedMimeTypeForGZip_test_txt_gz());
- }
-
- @Test
- public void shouldProvideMimeTypeForZip() throws Exception {
- testMimeType("docs/counting-input-stream-test-file.dat", expectedMimeTypeForZip());
- }
-
- @Test
- public void shouldProvideMimeTypeForBash() throws Exception {
- testMimeType("test.sh", expectedMimeTypeForBash());
- }
-
- @Test
- public void shouldProvideMimeTypeForOgg() throws Exception {
- testMimeType("test.ogg", expectedMimeTypeForOgg());
- }
-
- @Test
- public void shouldProvideMimeTypeForOpenDocumentFormula() throws Exception {
- testMimeType("docs/openoffice-2.0-formula.odf", expectedMimeTypeForOpenDocumentFormula());
- }
-
- @Test
- public void shouldProvideMimeTypeForOpenDocumentGraphics() throws Exception {
- testMimeType("docs/openoffice-2.0-draw.odg", expectedMimeTypeForOpenDocumentGraphics());
- }
-
- @Test
- public void shouldProvideMimeTypeForOpenDocumentGraphicsTemplate() throws Exception {
- testMimeType("docs/openoffice-2.0-draw-template.otg", expectedMimeTypeForOpenDocumentGraphicsTemplate());
- }
-
- @Test
- public void shouldProvideMimeTypeForOpenDocumentPresentation_component_architecture_odp() throws Exception {
- testMimeType("component-architecture.odp", expectedMimeTypeForOpenDocumentPresentation_component_architecture_odp());
- }
-
- @Test
- public void shouldProvideMimeTypeForOpenDocumentPresentation_openoffice_2_0_impress_odp() throws Exception {
- testMimeType("docs/openoffice-2.0-impress.odp", expectedMimeTypeForOpenDocumentPresentation_openoffice_2_0_impress_odp());
- }
-
- @Test
- public void shouldProvideMimeTypeForOpenDocumentPresentationTemplate() throws Exception {
- testMimeType("docs/openoffice-2.0-impress-template.otp", expectedMimeTypeForOpenDocumentPresentationTemplate());
- }
-
- @Test
- public void shouldProvideMimeTypeForOpenDocumentSpreadsheet() throws Exception {
- testMimeType("docs/openoffice-2.0-calc.ods", expectedMimeTypeForOpenDocumentSpreadsheet());
- }
-
- @Test
- public void shouldProvideMimeTypeForOpenDocumentSpreadsheetTemplate() throws Exception {
- testMimeType("docs/openoffice-2.0-calc-template.ots", expectedMimeTypeForOpenDocumentSpreadsheetTemplate());
- }
-
- @Test
- public void shouldProvideMimeTypeForOpenDocumentText() throws Exception {
- testMimeType("docs/openoffice-2.0-writer.odt", expectedMimeTypeForOpenDocumentText());
- }
-
- @Test
- public void shouldProvideMimeTypeForOpenDocumentTextTemplate() throws Exception {
- testMimeType("docs/openoffice-2.0-writer-template.ott", expectedMimeTypeForOpenDocumentTextTemplate());
- }
-
- @Test
- public void shouldProvideMimeTypeForOpenOfficeCalc() throws Exception {
- testMimeType("docs/openoffice-1.1.5-calc.sxc", expectedMimeTypeForOpenOfficeCalc());
- }
-
- @Test
- public void shouldProvideMimeTypeForOpenOfficeCalcTemplate() throws Exception {
- testMimeType("docs/openoffice-1.1.5-calc-template.stc", expectedMimeTypeForOpenOfficeCalcTemplate());
- }
-
- @Test
- public void shouldProvideMimeTypeForOpenOfficeDraw() throws Exception {
- testMimeType("docs/openoffice-1.1.5-draw.sxd", expectedMimeTypeForOpenOfficeDraw());
- }
-
- @Test
- public void shouldProvideMimeTypeForOpenOfficeDrawTemplate() throws Exception {
- testMimeType("docs/openoffice-1.1.5-draw-template.std", expectedMimeTypeForOpenOfficeDrawTemplate());
- }
-
- @Test
- public void shouldProvideMimeTypeForOpenOfficeImpress() throws Exception {
- testMimeType("docs/openoffice-1.1.5-impress.sxi", expectedMimeTypeForOpenOfficeImpress());
- }
-
- @Test
- public void shouldProvideMimeTypeForOpenOfficeImpressTemplate() throws Exception {
- testMimeType("docs/openoffice-1.1.5-impress-template.sti", expectedMimeTypeForOpenOfficeImpressTemplate());
- }
-
- @Test
- public void shouldProvideMimeTypeForOpenOfficeWriter() throws Exception {
- testMimeType("docs/openoffice-1.1.5-writer.sxw", expectedMimeTypeForOpenOfficeWriter());
- }
-
- @Test
- public void shouldProvideMimeTypeForOpenOfficeWriterTemplate() throws Exception {
- testMimeType("docs/openoffice-1.1.5-writer-template.stw", expectedMimeTypeForOpenOfficeWriterTemplate());
- }
-
- @Test
- public void shouldProvideMimeTypeForStarOfficeCalc() throws Exception {
- testMimeType("docs/staroffice-5.2-calc.sdc", expectedMimeTypeForStarOfficeCalc());
- }
-
- @Test
- public void shouldProvideMimeTypeForStarOfficeDraw() throws Exception {
- testMimeType("docs/staroffice-5.2-draw.sda", expectedMimeTypeForStarOfficeDraw());
- }
-
- @Test
- public void shouldProvideMimeTypeForStarOfficeImpress() throws Exception {
- testMimeType("docs/staroffice-5.2-impress.sdd", expectedMimeTypeForStarOfficeImpress());
- }
-
- @Test
- public void shouldProvideMimeTypeForStarOfficeWriter() throws Exception {
- testMimeType("docs/staroffice-5.2-writer.sdw", expectedMimeTypeForStarOfficeWriter());
- }
-
- @Test
- public void shouldProvideMimeTypeForStarOfficeCalcTemplate() throws Exception {
- testMimeType("docs/staroffice-5.2-calc-template.vor", expectedMimeTypeForStarOfficeCalcTemplate());
- }
-
- @Test
- public void shouldProvideMimeTypeForStarOfficeDrawTemplate() throws Exception {
- testMimeType("docs/staroffice-5.2-draw-template.vor", expectedMimeTypeForStarOfficeDrawTemplate());
- }
-
- @Test
- public void shouldProvideMimeTypeForStarOfficeImpressTemplate() throws Exception {
- testMimeType("docs/staroffice-5.2-impress-template.vor", expectedMimeTypeForStarOfficeImpressTemplate());
- }
-
- @Test
- public void shouldProvideMimeTypeForStarOfficeWriterTemplate() throws Exception {
- testMimeType("docs/staroffice-5.2-writer-template.vor", expectedMimeTypeForStarOfficeWriterTemplate());
- }
-
- @Test
- public void shouldProvideMimeTypeForWord_test_word_2000_doc() throws Exception {
- testMimeType("test_word_2000.doc", expectedMimeTypeForWord_test_word_2000_doc());
- }
-
- @Test
- public void shouldProvideMimeTypeForWord_test_word_6_0_95_doc() throws Exception {
- testMimeType("test_word_6.0_95.doc", expectedMimeTypeForWord_test_word_6_0_95_doc());
- }
-
- @Test
- public void shouldProvideMimeTypeForWord_microsoft_word_2000_doc() throws Exception {
- testMimeType("docs/microsoft-word-2000.doc", expectedMimeTypeForWord_microsoft_word_2000_doc());
- }
-
- @Test
- public void shouldProvideMimeTypeForWord_microsoft_word_2000_with_wrong_file_extension_pdf() throws Exception {
- testMimeType("docs/microsoft-word-2000-with-wrong-file-extension.pdf",
- expectedMimeTypeForWord_microsoft_word_2000_with_wrong_file_extension_pdf());
- }
-
- @Test
- public void shouldProvideMimeTypeForWord_microsoft_word_2007beta2_docm() throws Exception {
- testMimeType("docs/microsoft-word-2007beta2.docm", expectedMimeTypeForWord_microsoft_word_2007beta2_docm());
- }
-
- @Test
- public void shouldProvideMimeTypeForWord_microsoft_word_2007beta2_docx() throws Exception {
- testMimeType("docs/microsoft-word-2007beta2.docx", expectedMimeTypeForWord_microsoft_word_2007beta2_docx());
- }
-
- @Test
- public void shouldProvideMimeTypeForWord_microsoft_word_2007beta2_dotm() throws Exception {
- testMimeType("docs/microsoft-word-2007beta2.dotm", expectedMimeTypeForWord_microsoft_word_2007beta2_dotm());
- }
-
- @Test
- public void shouldProvideMimeTypeForWord_microsoft_word_2007beta2_dotx() throws Exception {
- testMimeType("docs/microsoft-word-2007beta2.dotx", expectedMimeTypeForWord_microsoft_word_2007beta2_dotx());
- }
-
- @Test
- public void shouldProvideMimeTypeForWorks_microsoft_works_spreadsheet_4_0_2000_wks() throws Exception {
- testMimeType("docs/microsoft-works-spreadsheet-4.0-2000.wks",
- expectedMimeTypeForWorks_microsoft_works_spreadsheet_4_0_2000_wks());
- }
-
- @Test
- public void shouldProvideMimeTypeForWorks_microsoft_works_spreadsheet_7_0_xlr() throws Exception {
- testMimeType("docs/microsoft-works-spreadsheet-7.0.xlr", expectedMimeTypeForWorks_microsoft_works_spreadsheet_7_0_xlr());
- }
-
- @Test
- public void shouldProvideMimeTypeForWorks_microsoft_works_word_processor_2000_wps() throws Exception {
- testMimeType("docs/microsoft-works-word-processor-2000.wps",
- expectedMimeTypeForWorks_microsoft_works_word_processor_2000_wps());
- }
-
- @Test
- public void shouldProvideMimeTypeForWorks_microsoft_works_word_processor_3_0_wps() throws Exception {
- testMimeType("docs/microsoft-works-word-processor-3.0.wps",
- expectedMimeTypeForWorks_microsoft_works_word_processor_3_0_wps());
- }
-
- @Test
- public void shouldProvideMimeTypeForWorks_microsoft_works_word_processor_4_0_wps() throws Exception {
- testMimeType("docs/microsoft-works-word-processor-4.0.wps",
- expectedMimeTypeForWorks_microsoft_works_word_processor_4_0_wps());
- }
-
- @Test
- public void shouldProvideMimeTypeForWorks_microsoft_works_word_processor_7_0_wps() throws Exception {
- testMimeType("docs/microsoft-works-word-processor-7.0.wps",
- expectedMimeTypeForWorks_microsoft_works_word_processor_7_0_wps());
- }
-
- @Test
- public void shouldProvideMimeTypeForWorkbook_corel_quattro_pro_6_wb2() throws Exception {
- testMimeType("docs/corel-quattro-pro-6.wb2", expectedMimeTypeForWorkbook_corel_quattro_pro_6_wb2());
- }
-
- @Test
- public void shouldProvideMimeTypeForWorkbook_microsoft_works_spreadsheet_3_0_wks() throws Exception {
- testMimeType("docs/microsoft-works-spreadsheet-3.0.wks",
- expectedMimeTypeForWorkbook_microsoft_works_spreadsheet_3_0_wks());
- }
-
- @Test
- public void shouldProvideMimeTypeForExcel_test_excel_2000_xls() throws Exception {
- testMimeType("test_excel_2000.xls", expectedMimeTypeForExcel_test_excel_2000_xls());
- }
-
- @Test
- public void shouldProvideMimeTypeForExcel_microsoft_excel_2000_xls() throws Exception {
- testMimeType("docs/microsoft-excel-2000.xls", expectedMimeTypeForExcel_microsoft_excel_2000_xls());
- }
-
- @Test
- public void shouldProvideMimeTypeForExcel_microsoft_excel_2007beta2_xlam() throws Exception {
- testMimeType("docs/microsoft-excel-2007beta2.xlam", expectedMimeTypeForExcel_microsoft_excel_2007beta2_xlam());
- }
-
- @Test
- public void shouldProvideMimeTypeForExcel_microsoft_excel_2007beta2_xlsb() throws Exception {
- testMimeType("docs/microsoft-excel-2007beta2.xlsb", expectedMimeTypeForExcel_microsoft_excel_2007beta2_xlsb());
- }
-
- @Test
- public void shouldProvideMimeTypeForExcel_microsoft_excel_2007beta2_xlsm() throws Exception {
- testMimeType("docs/microsoft-excel-2007beta2.xlsm", expectedMimeTypeForExcel_microsoft_excel_2007beta2_xlsm());
- }
-
- @Test
- public void shouldProvideMimeTypeForExcel_microsoft_excel_2007beta2_xlsx() throws Exception {
- testMimeType("docs/microsoft-excel-2007beta2.xlsx", expectedMimeTypeForExcel_microsoft_excel_2007beta2_xlsx());
- }
-
- @Test
- public void shouldProvideMimeTypeForExcel_microsoft_excel_2007beta2_xltm() throws Exception {
- testMimeType("docs/microsoft-excel-2007beta2.xltm", expectedMimeTypeForExcel_microsoft_excel_2007beta2_xltm());
- }
-
- @Test
- public void shouldProvideMimeTypeForExcel_microsoft_excel_2007beta2_xltx() throws Exception {
- testMimeType("docs/microsoft-excel-2007beta2.xltx", expectedMimeTypeForExcel_microsoft_excel_2007beta2_xltx());
- }
-
- @Test
- public void shouldProvideMimeTypeForPowerpoint_test_ppt() throws Exception {
- testMimeType("test.ppt", expectedMimeTypeForPowerpoint_test_ppt());
- }
-
- @Test
- public void shouldProvideMimeTypeForPowerpoint_microsoft_powerpoint_2000_ppt() throws Exception {
- testMimeType("docs/microsoft-powerpoint-2000.ppt", expectedMimeTypeForPowerpoint_microsoft_powerpoint_2000_ppt());
- }
-
- @Test
- public void shouldProvideMimeTypeForPowerpoint_microsoft_powerpoint_2007beta2_potm() throws Exception {
- testMimeType("docs/microsoft-powerpoint-2007beta2.potm",
- expectedMimeTypeForPowerpoint_microsoft_powerpoint_2007beta2_potm());
- }
-
- @Test
- public void shouldProvideMimeTypeForPowerpoint_microsoft_powerpoint_2007beta2_potx() throws Exception {
- testMimeType("docs/microsoft-powerpoint-2007beta2.potx",
- expectedMimeTypeForPowerpoint_microsoft_powerpoint_2007beta2_potx());
- }
-
- @Test
- public void shouldProvideMimeTypeForPowerpoint_microsoft_powerpoint_2007beta2_ppsm() throws Exception {
- testMimeType("docs/microsoft-powerpoint-2007beta2.ppsm",
- expectedMimeTypeForPowerpoint_microsoft_powerpoint_2007beta2_ppsm());
- }
-
- @Test
- public void shouldProvideMimeTypeForPowerpoint_microsoft_powerpoint_2007beta2_ppsx() throws Exception {
- testMimeType("docs/microsoft-powerpoint-2007beta2.ppsx",
- expectedMimeTypeForPowerpoint_microsoft_powerpoint_2007beta2_ppsx());
- }
-
- @Test
- public void shouldProvideMimeTypeForPowerpoint_microsoft_powerpoint_2007beta2_pptm() throws Exception {
- testMimeType("docs/microsoft-powerpoint-2007beta2.pptm",
- expectedMimeTypeForPowerpoint_microsoft_powerpoint_2007beta2_pptm());
- }
-
- @Test
- public void shouldProvideMimeTypeForPowerpoint_microsoft_powerpoint_2007beta2_pptx() throws Exception {
- testMimeType("docs/microsoft-powerpoint-2007beta2.pptx",
- expectedMimeTypeForPowerpoint_microsoft_powerpoint_2007beta2_pptx());
- }
-
- @Test
- public void shouldProvideMimeTypeForPublisher() throws Exception {
- testMimeType("docs/microsoft-publisher-2003.pub", expectedMimeTypeForPublisher());
- }
-
- @Test
- public void shouldProvideMimeTypeForVisio() throws Exception {
- testMimeType("docs/microsoft-visio.vsd", expectedMimeTypeForVisio());
- }
-
- @Test
- public void shouldProvideMimeTypeForOutlook() throws Exception {
- testMimeType("TestData.pst", expectedMimeTypeForOutlook());
- }
-
- @Test
- public void shouldProvideMimeTypeForShw_corel_presentations_3_0_shw() throws Exception {
- testMimeType("docs/corel-presentations-3.0.shw", expectedMimeTypeForShw_corel_presentations_3_0_shw());
- }
-
- @Test
- public void shouldProvideMimeTypeForShw_corel_presentations_x3_shw() throws Exception {
- testMimeType("docs/corel-presentations-x3.shw", expectedMimeTypeForShw_corel_presentations_x3_shw());
- }
-
- @Test
- public void shouldProvideMimeTypeForQuattroPro_corel_quattro_pro_7_wb3() throws Exception {
- testMimeType("docs/corel-quattro-pro-7.wb3", expectedMimeTypeForPro_corel_quattro_pro_7_wb3());
- }
-
- @Test
- public void shouldProvideMimeTypeForQuattroPro_corel_quattro_pro_x3_qpw() throws Exception {
- testMimeType("docs/corel-quattro-pro-x3.qpw", expectedMimeTypeForPro_corel_quattro_pro_x3_qpw());
- }
-
- @Test
- public void shouldProvideMimeTypeForWordperfect_corel_wordperfect_4_2_wp() throws Exception {
- testMimeType("docs/corel-wordperfect-4.2.wp", expectedMimeTypeForWordperfect_corel_wordperfect_4_2_wp());
- }
-
- @Test
- public void shouldProvideMimeTypeForWordperfect_corel_wordperfect_5_0_wp() throws Exception {
- testMimeType("docs/corel-wordperfect-5.0.wp", expectedMimeTypeForWordperfect_corel_wordperfect_5_0_wp());
- }
-
- @Test
- public void shouldProvideMimeTypeForWordperfect_corel_wordperfect_5_1_wp() throws Exception {
- testMimeType("docs/corel-wordperfect-5.1.wp", expectedMimeTypeForWordperfect_corel_wordperfect_5_1_wp());
- }
-
- @Test
- public void shouldProvideMimeTypeForWordperfect_corel_wordperfect_5_1_far_east_wp() throws Exception {
- testMimeType("docs/corel-wordperfect-5.1-far-east.wp", expectedMimeTypeForWordperfect_corel_wordperfect_5_1_far_east_wp());
- }
-
- @Test
- public void shouldProvideMimeTypeForWordperfect_corel_wordperfect_x3_wpd() throws Exception {
- testMimeType("docs/corel-wordperfect-x3.wpd", expectedMimeTypeForWordperfect_corel_wordperfect_x3_wpd());
- }
-
- @Test
- public void shouldProvideMimeTypeForMail_test_excel_web_archive_mht() throws Exception {
- testMimeType("test_excel_web_archive.mht", expectedMimeTypeForMail_test_excel_web_archive_mht());
- }
-
- @Test
- public void shouldProvideMimeTypeForMail_mail_thunderbird_1_5_eml() throws Exception {
- testMimeType("docs/mail-thunderbird-1.5.eml", expectedMimeTypeForMail_mail_thunderbird_1_5_eml());
- }
-
- @Test
- public void shouldProvideMimeTypeForMail_mhtml_firefox_mht() throws Exception {
- testMimeType("docs/mhtml-firefox.mht", expectedMimeTypeForMail_mhtml_firefox_mht());
- }
-
- @Test
- public void shouldProvideMimeTypeForMail_mhtml_internet_explorer_mht() throws Exception {
- testMimeType("docs/mhtml-internet-explorer.mht", expectedMimeTypeForMail_mhtml_internet_explorer_mht());
- }
-
- @Test
- public void shouldProvideMimeTypeForAddressBook() throws Exception {
- testMimeType("docs/thunderbird-addressbook.mab", expectedMimeTypeForAddressBook());
- }
-
- @Test
- public void shouldProvideMimeTypeForVCard_vcard_antoni_kontact_vcf() throws Exception {
- testMimeType("docs/vcard-antoni-kontact.vcf", expectedMimeTypeForVCard_vcard_antoni_kontact_vcf());
- }
-
- @Test
- public void shouldProvideMimeTypeForVCard_vcard_antoni_outlook2003_vcf() throws Exception {
- testMimeType("docs/vcard-antoni-outlook2003.vcf", expectedMimeTypeForVCard_vcard_antoni_outlook2003_vcf());
- }
-
- @Test
- public void shouldProvideMimeTypeForVCard_vcard_dirk_vcf() throws Exception {
- testMimeType("docs/vcard-dirk.vcf", expectedMimeTypeForVCard_vcard_dirk_vcf());
- }
-
- @Test
- public void shouldProvideMimeTypeForVCard_vcard_rfc2426_vcf() throws Exception {
- testMimeType("docs/vcard-rfc2426.vcf", expectedMimeTypeForVCard_vcard_rfc2426_vcf());
- }
-
- @Test
- public void shouldProvideMimeTypeForVCard_vcard_vCards_SAP_vcf() throws Exception {
- testMimeType("docs/vcard-vCards-SAP.vcf", expectedMimeTypeForVCard_vcard_vCards_SAP_vcf());
- }
-
- @Test
- public void shouldProvideMimeTypeForCalendar_basicCalendar_ics() throws Exception {
- testMimeType("docs/icaltestdata/basicCalendar.ics", expectedMimeTypeForCalendar_basicCalendar_ics());
- }
-
- @Test
- public void shouldProvideMimeTypeForCalendar_cal01_ics() throws Exception {
- testMimeType("docs/icaltestdata/cal01.ics", expectedMimeTypeForCalendar_cal01_ics());
- }
-
- @Test
- public void shouldProvideMimeTypeForCalendar_cal01_1_ics() throws Exception {
- testMimeType("docs/icaltestdata/cal01-1.ics", expectedMimeTypeForCalendar_cal01_1_ics());
- }
-
- @Test
- public void shouldProvideMimeTypeForCalendar_cal01_2_ics() throws Exception {
- testMimeType("docs/icaltestdata/cal01-2.ics", expectedMimeTypeForCalendar_cal01_2_ics());
- }
-
- @Test
- public void shouldProvideMimeTypeForCalendar_cal01_3_ics() throws Exception {
- testMimeType("docs/icaltestdata/cal01-3.ics", expectedMimeTypeForCalendar_cal01_3_ics());
- }
-
- @Test
- public void shouldProvideMimeTypeForCalendar_cal01_4_ics() throws Exception {
- testMimeType("docs/icaltestdata/cal01-4.ics", expectedMimeTypeForCalendar_cal01_4_ics());
- }
-
- @Test
- public void shouldProvideMimeTypeForCalendar_cal01_5_ics() throws Exception {
- testMimeType("docs/icaltestdata/cal01-5.ics", expectedMimeTypeForCalendar_cal01_5_ics());
- }
-
- @Test
- public void shouldProvideMimeTypeForCalendar_cal01_6_ics() throws Exception {
- testMimeType("docs/icaltestdata/cal01-6.ics", expectedMimeTypeForCalendar_cal01_6_ics());
- }
-
- @Test
- public void shouldProvideMimeTypeForCalendar_cal01_exrule_ics() throws Exception {
- testMimeType("docs/icaltestdata/cal01-exrule.ics", expectedMimeTypeForCalendar_cal01_exrule_ics());
- }
-
- @Test
- public void shouldProvideMimeTypeForCalendar_calconnect7_ics() throws Exception {
- testMimeType("docs/icaltestdata/calconnect7.ics", expectedMimeTypeForCalendar_calconnect7_ics());
- }
-
- @Test
- public void shouldProvideMimeTypeForCalendar_calconnect9_ics() throws Exception {
- testMimeType("docs/icaltestdata/calconnect9.ics", expectedMimeTypeForCalendar_calconnect9_ics());
- }
-
- @Test
- public void shouldProvideMimeTypeForCalendar_combined_multiplevcalendar_ics() throws Exception {
- testMimeType("docs/icaltestdata/combined_multiplevcalendar.ics",
- expectedMimeTypeForCalendar_combined_multiplevcalendar_ics());
- }
-
- @Test
- public void shouldProvideMimeTypeForCalendar_combined_onevcalendar_ics() throws Exception {
- testMimeType("docs/icaltestdata/combined_onevcalendar.ics", expectedMimeTypeForCalendar_combined_onevcalendar_ics());
- }
-
- @Test
- public void shouldProvideMimeTypeForCalendar_extendedCalendar_ics() throws Exception {
- testMimeType("docs/icaltestdata/extendedCalendar.ics", expectedMimeTypeForCalendar_extendedCalendar_ics());
- }
-
- @Test
- public void shouldProvideMimeTypeForCalendar_freebusy_ics() throws Exception {
- testMimeType("docs/icaltestdata/freebusy.ics", expectedMimeTypeForCalendar_freebusy_ics());
- }
-
- @Test
- public void shouldProvideMimeTypeForCalendar_geol_ics() throws Exception {
- testMimeType("docs/icaltestdata/geo1.ics", expectedMimeTypeForCalendar_geol_ics());
- }
-
- @Test
- public void shouldProvideMimeTypeForCalendar_gkexample_ics() throws Exception {
- testMimeType("docs/icaltestdata/gkexample.ics", expectedMimeTypeForCalendar_gkexample_ics());
- }
-
- @Test
- public void shouldProvideMimeTypeForCalendar_incoming_ics() throws Exception {
- testMimeType("docs/icaltestdata/incoming.ics", expectedMimeTypeForCalendar_incoming_ics());
- }
-
- @Test
- public void shouldProvideMimeTypeForCalendar_korganizer_jicaltest_vjournal_ics() throws Exception {
- testMimeType("docs/icaltestdata/korganizer-jicaltest-vjournal.ics",
- expectedMimeTypeForCalendar_korganizer_jicaltest_vjournal_ics());
- }
-
- @Test
- public void shouldProvideMimeTypeForCalendar_korganizer_jicaltest_ics() throws Exception {
- testMimeType("docs/icaltestdata/korganizer-jicaltest.ics", expectedMimeTypeForCalendar_korganizer_jicaltest_ics());
- }
-
- @Test
- public void shouldProvideMimeTypeForCalendar_php_flp_ics() throws Exception {
- testMimeType("docs/icaltestdata/php-flp.ics", expectedMimeTypeForCalendar_php_flp_ics());
- }
-
- @Test
- public void shouldProvideMimeTypeForCalendar_simplevevent_ics() throws Exception {
- testMimeType("docs/icaltestdata/simplevevent.ics", expectedMimeTypeForCalendar_simplevevent_ics());
- }
-
- @Test
- public void shouldProvideMimeTypeForCalendar_sunbird_sample_ics() throws Exception {
- testMimeType("docs/icaltestdata/sunbird_sample.ics", expectedMimeTypeForCalendar_sunbird_sample_ics());
- }
-
- @Test
- public void shouldProvideMimeTypeForCalendar_tag_bug_ics() throws Exception {
- testMimeType("docs/icaltestdata/tag-bug.ics", expectedMimeTypeForCalendar_tag_bug_ics());
- }
-
- @Test
- public void shouldProvideMimeTypeForCalendar_test_created_ics() throws Exception {
- testMimeType("docs/icaltestdata/test-created.ics", expectedMimeTypeForCalendar_test_created_ics());
- }
-
- @Test
- public void shouldProvideMimeTypeForCalendar_Todos1_ics() throws Exception {
- testMimeType("docs/icaltestdata/Todos1.ics", expectedMimeTypeForCalendar_Todos1_ics());
- }
-
- @Test
- public void shouldProvideMimeTypeForAu() throws Exception {
- testMimeType("test.au", expectedMimeTypeForAu());
- }
-
- @Test
- public void shouldProvideMimeTypeForBin() throws Exception {
- testMimeType("test.bin", expectedMimeTypeForBin());
- }
-
- @Test
- public void shouldProvideMimeTypeForEmf() throws Exception {
- testMimeType("test.emf", expectedMimeTypeForEmf());
- }
-
- @Test
- public void shouldProvideMimeTypeForFli() throws Exception {
- testMimeType("test.fli", expectedMimeTypeForFli());
- }
-
- @Test
- public void shouldProvideMimeTypeForPcx() throws Exception {
- testMimeType("test.pcx", expectedMimeTypeForPcx());
- }
-
- @Test
- public void shouldProvideMimeTypeForPict() throws Exception {
- testMimeType("test.pict", expectedMimeTypeForPict());
- }
-
- @Test
- public void shouldProvideMimeTypeForPsd() throws Exception {
- testMimeType("test.psd", expectedMimeTypeForPsd());
- }
-
- @Test
- public void shouldProvideMimeTypeForTar() throws Exception {
- testMimeType("test.tar", expectedMimeTypeForTar());
- }
-}
Modified: trunk/dna-repository/src/test/java/org/jboss/dna/repository/sequencer/StreamSequencerAdapterTest.java
===================================================================
--- trunk/dna-repository/src/test/java/org/jboss/dna/repository/sequencer/StreamSequencerAdapterTest.java 2009-05-21 19:03:27 UTC (rev 920)
+++ trunk/dna-repository/src/test/java/org/jboss/dna/repository/sequencer/StreamSequencerAdapterTest.java 2009-05-21 19:10:30 UTC (rev 921)
@@ -44,13 +44,13 @@
import org.jboss.dna.graph.Graph;
import org.jboss.dna.graph.Node;
import org.jboss.dna.graph.connector.inmemory.InMemoryRepositorySource;
+import org.jboss.dna.graph.mimetype.MimeTypeDetectors;
import org.jboss.dna.graph.property.Path;
import org.jboss.dna.graph.property.PathNotFoundException;
import org.jboss.dna.graph.property.Property;
import org.jboss.dna.graph.sequencer.SequencerOutput;
import org.jboss.dna.graph.sequencer.StreamSequencer;
import org.jboss.dna.graph.sequencer.StreamSequencerContext;
-import org.jboss.dna.repository.mimetype.MimeTypeDetectors;
import org.jboss.dna.repository.observation.NodeChange;
import org.jboss.dna.repository.util.RepositoryNodePath;
import org.junit.Before;
Modified: trunk/extensions/dna-mimetype-detector-aperture/pom.xml
===================================================================
--- trunk/extensions/dna-mimetype-detector-aperture/pom.xml 2009-05-21 19:03:27 UTC (rev 920)
+++ trunk/extensions/dna-mimetype-detector-aperture/pom.xml 2009-05-21 19:10:30 UTC (rev 921)
@@ -23,12 +23,7 @@
</dependency>
<dependency>
<groupId>org.jboss.dna</groupId>
- <artifactId>dna-repository</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.jboss.dna</groupId>
- <artifactId>dna-repository</artifactId>
+ <artifactId>dna-graph</artifactId>
<version>${pom.version}</version>
<type>test-jar</type>
<scope>test</scope>
Modified: trunk/extensions/dna-mimetype-detector-aperture/src/test/java/org/jboss/dna/mimetype/aperture/MimeTypeTest.java
===================================================================
--- trunk/extensions/dna-mimetype-detector-aperture/src/test/java/org/jboss/dna/mimetype/aperture/MimeTypeTest.java 2009-05-21 19:03:27 UTC (rev 920)
+++ trunk/extensions/dna-mimetype-detector-aperture/src/test/java/org/jboss/dna/mimetype/aperture/MimeTypeTest.java 2009-05-21 19:10:30 UTC (rev 921)
@@ -22,8 +22,7 @@
package org.jboss.dna.mimetype.aperture;
import java.io.FileNotFoundException;
-import org.jboss.dna.mimetype.aperture.ApertureMimeTypeDetector;
-import org.jboss.dna.repository.mimetype.AbstractMimeTypeTest;
+import org.jboss.dna.graph.mimetype.AbstractMimeTypeTest;
import org.junit.Test;
/**
@@ -43,7 +42,7 @@
/**
* {@inheritDoc}
*
- * @see org.jboss.dna.repository.mimetype.AbstractMimeTypeTest#expectedMimeTypeForText_plain_text_ansi_txt()
+ * @see AbstractMimeTypeTest#expectedMimeTypeForText_plain_text_ansi_txt()
*/
@Override
protected String expectedMimeTypeForText_plain_text_ansi_txt() {
@@ -53,7 +52,7 @@
/**
* {@inheritDoc}
*
- * @see org.jboss.dna.repository.mimetype.AbstractMimeTypeTest#expectedMimeTypeForText_plain_text_empty_txt()
+ * @see AbstractMimeTypeTest#expectedMimeTypeForText_plain_text_empty_txt()
*/
@Override
protected String expectedMimeTypeForText_plain_text_empty_txt() {
@@ -63,7 +62,7 @@
/**
* {@inheritDoc}
*
- * @see org.jboss.dna.repository.mimetype.AbstractMimeTypeTest#expectedMimeTypeForText_plain_text_txt()
+ * @see AbstractMimeTypeTest#expectedMimeTypeForText_plain_text_txt()
*/
@Override
protected String expectedMimeTypeForText_plain_text_txt() {
@@ -73,7 +72,7 @@
/**
* {@inheritDoc}
*
- * @see org.jboss.dna.repository.mimetype.AbstractMimeTypeTest#expectedMimeTypeForText_plain_text_with_null_character_txt()
+ * @see AbstractMimeTypeTest#expectedMimeTypeForText_plain_text_with_null_character_txt()
*/
@Override
protected String expectedMimeTypeForText_plain_text_with_null_character_txt() {
@@ -83,7 +82,7 @@
/**
* {@inheritDoc}
*
- * @see org.jboss.dna.repository.mimetype.AbstractMimeTypeTest#expectedMimeTypeForText_plain_text_utf16be_txt()
+ * @see AbstractMimeTypeTest#expectedMimeTypeForText_plain_text_utf16be_txt()
*/
@Override
protected String expectedMimeTypeForText_plain_text_utf16be_txt() {
@@ -93,7 +92,7 @@
/**
* {@inheritDoc}
*
- * @see org.jboss.dna.repository.mimetype.AbstractMimeTypeTest#expectedMimeTypeForText_plain_text_utf16le_txt()
+ * @see AbstractMimeTypeTest#expectedMimeTypeForText_plain_text_utf16le_txt()
*/
@Override
protected String expectedMimeTypeForText_plain_text_utf16le_txt() {
@@ -103,7 +102,7 @@
/**
* {@inheritDoc}
*
- * @see org.jboss.dna.repository.mimetype.AbstractMimeTypeTest#expectedMimeTypeForText_plain_text_utf8_txt()
+ * @see AbstractMimeTypeTest#expectedMimeTypeForText_plain_text_utf8_txt()
*/
@Override
protected String expectedMimeTypeForText_plain_text_utf8_txt() {
@@ -113,7 +112,7 @@
/**
* {@inheritDoc}
*
- * @see org.jboss.dna.repository.mimetype.AbstractMimeTypeTest#expectedMimeTypeForText_plain_text_without_extension()
+ * @see AbstractMimeTypeTest#expectedMimeTypeForText_plain_text_without_extension()
*/
@Override
protected String expectedMimeTypeForText_plain_text_without_extension() {
@@ -123,7 +122,7 @@
/**
* {@inheritDoc}
*
- * @see org.jboss.dna.repository.mimetype.AbstractMimeTypeTest#expectedMimeTypeForRtf_rtf_staroffice_5_2_rtf()
+ * @see AbstractMimeTypeTest#expectedMimeTypeForRtf_rtf_staroffice_5_2_rtf()
*/
@Override
protected String expectedMimeTypeForRtf_rtf_staroffice_5_2_rtf() {
@@ -133,7 +132,7 @@
/**
* {@inheritDoc}
*
- * @see org.jboss.dna.repository.mimetype.AbstractMimeTypeTest#expectedMimeTypeForRtf_rtf_openoffice_2_0_rtf()
+ * @see AbstractMimeTypeTest#expectedMimeTypeForRtf_rtf_openoffice_2_0_rtf()
*/
@Override
protected String expectedMimeTypeForRtf_rtf_openoffice_2_0_rtf() {
@@ -143,7 +142,7 @@
/**
* {@inheritDoc}
*
- * @see org.jboss.dna.repository.mimetype.AbstractMimeTypeTest#expectedMimeTypeForRtf_rtf_word_2000_rtf()
+ * @see AbstractMimeTypeTest#expectedMimeTypeForRtf_rtf_word_2000_rtf()
*/
@Override
protected String expectedMimeTypeForRtf_rtf_word_2000_rtf() {
@@ -153,7 +152,7 @@
/**
* {@inheritDoc}
*
- * @see org.jboss.dna.repository.mimetype.AbstractMimeTypeTest#expectedMimeTypeForRtf_rtf_openoffice_1_1_5_rtf()
+ * @see AbstractMimeTypeTest#expectedMimeTypeForRtf_rtf_openoffice_1_1_5_rtf()
*/
@Override
protected String expectedMimeTypeForRtf_rtf_openoffice_1_1_5_rtf() {
@@ -163,7 +162,7 @@
/**
* {@inheritDoc}
*
- * @see org.jboss.dna.repository.mimetype.AbstractMimeTypeTest#expectedMimeTypeForRtf_test_rtf()
+ * @see AbstractMimeTypeTest#expectedMimeTypeForRtf_test_rtf()
*/
@Override
protected String expectedMimeTypeForRtf_test_rtf() {
@@ -173,7 +172,7 @@
/**
* {@inheritDoc}
*
- * @see org.jboss.dna.repository.mimetype.AbstractMimeTypeTest#expectedMimeTypeForMp3_jingle3_mp3()
+ * @see AbstractMimeTypeTest#expectedMimeTypeForMp3_jingle3_mp3()
*/
@Override
protected String expectedMimeTypeForMp3_jingle3_mp3() {
@@ -183,7 +182,7 @@
/**
* {@inheritDoc}
*
- * @see org.jboss.dna.repository.mimetype.AbstractMimeTypeTest#expectedMimeTypeForMp3_jingle1_mp3()
+ * @see AbstractMimeTypeTest#expectedMimeTypeForMp3_jingle1_mp3()
*/
@Override
protected String expectedMimeTypeForMp3_jingle1_mp3() {
@@ -193,7 +192,7 @@
/**
* {@inheritDoc}
*
- * @see org.jboss.dna.repository.mimetype.AbstractMimeTypeTest#expectedMimeTypeForMp3_jingle2_mp3()
+ * @see AbstractMimeTypeTest#expectedMimeTypeForMp3_jingle2_mp3()
*/
@Override
protected String expectedMimeTypeForMp3_jingle2_mp3() {
@@ -203,7 +202,7 @@
/**
* {@inheritDoc}
*
- * @see org.jboss.dna.repository.mimetype.AbstractMimeTypeTest#expectedMimeTypeForMp3_test_128_44_jstereo_mp3()
+ * @see AbstractMimeTypeTest#expectedMimeTypeForMp3_test_128_44_jstereo_mp3()
*/
@Override
protected String expectedMimeTypeForMp3_test_128_44_jstereo_mp3() {
@@ -213,7 +212,7 @@
/**
* {@inheritDoc}
*
- * @see org.jboss.dna.repository.mimetype.AbstractMimeTypeTest#expectedMimeTypeForMp3_test_mp3()
+ * @see AbstractMimeTypeTest#expectedMimeTypeForMp3_test_mp3()
*/
@Override
protected String expectedMimeTypeForMp3_test_mp3() {
@@ -243,7 +242,7 @@
/**
* {@inheritDoc}
*
- * @see org.jboss.dna.repository.mimetype.AbstractMimeTypeTest#expectedMimeTypeForJpeg_jpg_geotagged_jpg()
+ * @see AbstractMimeTypeTest#expectedMimeTypeForJpeg_jpg_geotagged_jpg()
*/
@Override
protected String expectedMimeTypeForJpeg_jpg_geotagged_jpg() {
@@ -253,7 +252,7 @@
/**
* {@inheritDoc}
*
- * @see org.jboss.dna.repository.mimetype.AbstractMimeTypeTest#expectedMimeTypeForJpeg_jpg_exif_zerolength_jpg()
+ * @see AbstractMimeTypeTest#expectedMimeTypeForJpeg_jpg_exif_zerolength_jpg()
*/
@Override
protected String expectedMimeTypeForJpeg_jpg_exif_zerolength_jpg() {
@@ -263,7 +262,7 @@
/**
* {@inheritDoc}
*
- * @see org.jboss.dna.repository.mimetype.AbstractMimeTypeTest#expectedMimeTypeForJpeg_jpg_geotagged_ipanema_jpg()
+ * @see AbstractMimeTypeTest#expectedMimeTypeForJpeg_jpg_geotagged_ipanema_jpg()
*/
@Override
protected String expectedMimeTypeForJpeg_jpg_geotagged_ipanema_jpg() {
@@ -273,7 +272,7 @@
/**
* {@inheritDoc}
*
- * @see org.jboss.dna.repository.mimetype.AbstractMimeTypeTest#expectedMimeTypeForJpeg_jpg_exif_img_9367_JPG()
+ * @see AbstractMimeTypeTest#expectedMimeTypeForJpeg_jpg_exif_img_9367_JPG()
*/
@Override
protected String expectedMimeTypeForJpeg_jpg_exif_img_9367_JPG() {
@@ -283,7 +282,7 @@
/**
* {@inheritDoc}
*
- * @see org.jboss.dna.repository.mimetype.AbstractMimeTypeTest#expectedMimeTypeForJpeg_test_jpg()
+ * @see AbstractMimeTypeTest#expectedMimeTypeForJpeg_test_jpg()
*/
@Override
protected String expectedMimeTypeForJpeg_test_jpg() {
@@ -293,7 +292,7 @@
/**
* {@inheritDoc}
*
- * @see org.jboss.dna.repository.mimetype.AbstractMimeTypeTest#expectedMimeTypeForPortablePixelMap_test_ppm()
+ * @see AbstractMimeTypeTest#expectedMimeTypeForPortablePixelMap_test_ppm()
*/
@Override
protected String expectedMimeTypeForPortablePixelMap_test_ppm() {
@@ -303,7 +302,7 @@
/**
* {@inheritDoc}
*
- * @see org.jboss.dna.repository.mimetype.AbstractMimeTypeTest#expectedMimeTypeForPortablePixelMap_test_pnm()
+ * @see AbstractMimeTypeTest#expectedMimeTypeForPortablePixelMap_test_pnm()
*/
@Override
protected String expectedMimeTypeForPortablePixelMap_test_pnm() {
@@ -343,7 +342,7 @@
/**
* {@inheritDoc}
*
- * @see org.jboss.dna.repository.mimetype.AbstractMimeTypeTest#expectedMimeTypeForXml_xml_utf8_bom()
+ * @see AbstractMimeTypeTest#expectedMimeTypeForXml_xml_utf8_bom()
*/
@Override
protected String expectedMimeTypeForXml_xml_utf8_bom() {
@@ -353,7 +352,7 @@
/**
* {@inheritDoc}
*
- * @see org.jboss.dna.repository.mimetype.AbstractMimeTypeTest#expectedMimeTypeForXml_CurrencyFormatterExample_mxml()
+ * @see AbstractMimeTypeTest#expectedMimeTypeForXml_CurrencyFormatterExample_mxml()
*/
@Override
protected String expectedMimeTypeForXml_CurrencyFormatterExample_mxml() {
@@ -363,7 +362,7 @@
/**
* {@inheritDoc}
*
- * @see org.jboss.dna.repository.mimetype.AbstractMimeTypeTest#expectedMimeTypeForXml_test_excel_spreadsheet_xml()
+ * @see AbstractMimeTypeTest#expectedMimeTypeForXml_test_excel_spreadsheet_xml()
*/
@Override
protected String expectedMimeTypeForXml_test_excel_spreadsheet_xml() {
@@ -373,7 +372,7 @@
/**
* {@inheritDoc}
*
- * @see org.jboss.dna.repository.mimetype.AbstractMimeTypeTest#expectedMimeTypeForXml_test_xml()
+ * @see AbstractMimeTypeTest#expectedMimeTypeForXml_test_xml()
*/
@Override
protected String expectedMimeTypeForXml_test_xml() {
@@ -383,7 +382,7 @@
/**
* {@inheritDoc}
*
- * @see org.jboss.dna.repository.mimetype.AbstractMimeTypeTest#expectedMimeTypeForXml_xml_handwritten_xml()
+ * @see AbstractMimeTypeTest#expectedMimeTypeForXml_xml_handwritten_xml()
*/
@Override
protected String expectedMimeTypeForXml_xml_handwritten_xml() {
@@ -393,7 +392,7 @@
/**
* {@inheritDoc}
*
- * @see org.jboss.dna.repository.mimetype.AbstractMimeTypeTest#expectedMimeTypeForXml_xml_nonexistent_dtd_xml()
+ * @see AbstractMimeTypeTest#expectedMimeTypeForXml_xml_nonexistent_dtd_xml()
*/
@Override
protected String expectedMimeTypeForXml_xml_nonexistent_dtd_xml() {
@@ -403,7 +402,7 @@
/**
* {@inheritDoc}
*
- * @see org.jboss.dna.repository.mimetype.AbstractMimeTypeTest#expectedMimeTypeForXml_xml_nonexistent_remote_dtd_xml()
+ * @see AbstractMimeTypeTest#expectedMimeTypeForXml_xml_nonexistent_remote_dtd_xml()
*/
@Override
protected String expectedMimeTypeForXml_xml_nonexistent_remote_dtd_xml() {
@@ -413,7 +412,7 @@
/**
* {@inheritDoc}
*
- * @see org.jboss.dna.repository.mimetype.AbstractMimeTypeTest#expectedMimeTypeForXml_xml_nonexistent_remote_xsd_xml()
+ * @see AbstractMimeTypeTest#expectedMimeTypeForXml_xml_nonexistent_remote_xsd_xml()
*/
@Override
protected String expectedMimeTypeForXml_xml_nonexistent_remote_xsd_xml() {
@@ -423,7 +422,7 @@
/**
* {@inheritDoc}
*
- * @see org.jboss.dna.repository.mimetype.AbstractMimeTypeTest#expectedMimeTypeForXml_xml_nonexistent_xsd_xml()
+ * @see AbstractMimeTypeTest#expectedMimeTypeForXml_xml_nonexistent_xsd_xml()
*/
@Override
protected String expectedMimeTypeForXml_xml_nonexistent_xsd_xml() {
@@ -443,7 +442,7 @@
/**
* {@inheritDoc}
*
- * @see org.jboss.dna.repository.mimetype.AbstractMimeTypeTest#expectedMimeTypeForHtml_html_condenast_html()
+ * @see AbstractMimeTypeTest#expectedMimeTypeForHtml_html_condenast_html()
*/
@Override
protected String expectedMimeTypeForHtml_html_condenast_html() {
@@ -453,7 +452,7 @@
/**
* {@inheritDoc}
*
- * @see org.jboss.dna.repository.mimetype.AbstractMimeTypeTest#expectedMimeTypeForHtml_html_handwritten_html()
+ * @see AbstractMimeTypeTest#expectedMimeTypeForHtml_html_handwritten_html()
*/
@Override
protected String expectedMimeTypeForHtml_html_handwritten_html() {
@@ -463,7 +462,7 @@
/**
* {@inheritDoc}
*
- * @see org.jboss.dna.repository.mimetype.AbstractMimeTypeTest#expectedMimeTypeForHtml_html_handwritten_with_wrong_file_extension_txt()
+ * @see AbstractMimeTypeTest#expectedMimeTypeForHtml_html_handwritten_with_wrong_file_extension_txt()
*/
@Override
protected String expectedMimeTypeForHtml_html_handwritten_with_wrong_file_extension_txt() {
@@ -473,7 +472,7 @@
/**
* {@inheritDoc}
*
- * @see org.jboss.dna.repository.mimetype.AbstractMimeTypeTest#expectedMimeTypeForHtml_html_quelle_de_html()
+ * @see AbstractMimeTypeTest#expectedMimeTypeForHtml_html_quelle_de_html()
*/
@Override
protected String expectedMimeTypeForHtml_html_quelle_de_html() {
@@ -483,7 +482,7 @@
/**
* {@inheritDoc}
*
- * @see org.jboss.dna.repository.mimetype.AbstractMimeTypeTest#expectedMimeTypeForHtml_html_utf16_leading_whitespace_wrong_extension_doc()
+ * @see AbstractMimeTypeTest#expectedMimeTypeForHtml_html_utf16_leading_whitespace_wrong_extension_doc()
*/
@Override
protected String expectedMimeTypeForHtml_html_utf16_leading_whitespace_wrong_extension_doc() {
@@ -493,7 +492,7 @@
/**
* {@inheritDoc}
*
- * @see org.jboss.dna.repository.mimetype.AbstractMimeTypeTest#expectedMimeTypeForHtml_master_xml()
+ * @see AbstractMimeTypeTest#expectedMimeTypeForHtml_master_xml()
*/
@Override
protected String expectedMimeTypeForHtml_master_xml() {
@@ -533,7 +532,7 @@
/**
* {@inheritDoc}
*
- * @see org.jboss.dna.repository.mimetype.AbstractMimeTypeTest#expectedMimeTypeForPdf_test_pdf()
+ * @see AbstractMimeTypeTest#expectedMimeTypeForPdf_test_pdf()
*/
@Override
protected String expectedMimeTypeForPdf_test_pdf() {
@@ -543,7 +542,7 @@
/**
* {@inheritDoc}
*
- * @see org.jboss.dna.repository.mimetype.AbstractMimeTypeTest#expectedMimeTypeForPdf_pdf_no_author_pdf()
+ * @see AbstractMimeTypeTest#expectedMimeTypeForPdf_pdf_no_author_pdf()
*/
@Override
protected String expectedMimeTypeForPdf_pdf_no_author_pdf() {
@@ -553,7 +552,7 @@
/**
* {@inheritDoc}
*
- * @see org.jboss.dna.repository.mimetype.AbstractMimeTypeTest#expectedMimeTypeForPdf_pdf_openoffice_1_1_5_writer_pdf()
+ * @see AbstractMimeTypeTest#expectedMimeTypeForPdf_pdf_openoffice_1_1_5_writer_pdf()
*/
@Override
protected String expectedMimeTypeForPdf_pdf_openoffice_1_1_5_writer_pdf() {
@@ -563,7 +562,7 @@
/**
* {@inheritDoc}
*
- * @see org.jboss.dna.repository.mimetype.AbstractMimeTypeTest#expectedMimeTypeForPdf_pdf_openoffice_2_0_writer_pdf()
+ * @see AbstractMimeTypeTest#expectedMimeTypeForPdf_pdf_openoffice_2_0_writer_pdf()
*/
@Override
protected String expectedMimeTypeForPdf_pdf_openoffice_2_0_writer_pdf() {
@@ -573,7 +572,7 @@
/**
* {@inheritDoc}
*
- * @see org.jboss.dna.repository.mimetype.AbstractMimeTypeTest#expectedMimeTypeForPdf_pdf_word_2000_pdfcreator_0_8_0_pdf()
+ * @see AbstractMimeTypeTest#expectedMimeTypeForPdf_pdf_word_2000_pdfcreator_0_8_0_pdf()
*/
@Override
protected String expectedMimeTypeForPdf_pdf_word_2000_pdfcreator_0_8_0_pdf() {
@@ -583,7 +582,7 @@
/**
* {@inheritDoc}
*
- * @see org.jboss.dna.repository.mimetype.AbstractMimeTypeTest#expectedMimeTypeForPdf_pdf_word_2000_pdfmaker_7_0_pdf()
+ * @see AbstractMimeTypeTest#expectedMimeTypeForPdf_pdf_word_2000_pdfmaker_7_0_pdf()
*/
@Override
protected String expectedMimeTypeForPdf_pdf_word_2000_pdfmaker_7_0_pdf() {
@@ -593,7 +592,7 @@
/**
* {@inheritDoc}
*
- * @see org.jboss.dna.repository.mimetype.AbstractMimeTypeTest#expectedMimeTypeForPdf_pdf_word_2000_pdfwriter_7_0_pdf()
+ * @see AbstractMimeTypeTest#expectedMimeTypeForPdf_pdf_word_2000_pdfwriter_7_0_pdf()
*/
@Override
protected String expectedMimeTypeForPdf_pdf_word_2000_pdfwriter_7_0_pdf() {
@@ -603,7 +602,7 @@
/**
* {@inheritDoc}
*
- * @see org.jboss.dna.repository.mimetype.AbstractMimeTypeTest#expectedMimeTypeForPdf_pdf_distiller_6_weirdchars_pdf()
+ * @see AbstractMimeTypeTest#expectedMimeTypeForPdf_pdf_distiller_6_weirdchars_pdf()
*/
@Override
protected String expectedMimeTypeForPdf_pdf_distiller_6_weirdchars_pdf() {
@@ -613,7 +612,7 @@
/**
* {@inheritDoc}
*
- * @see org.jboss.dna.repository.mimetype.AbstractMimeTypeTest#expectedMimeTypeForPostscript_test_eps()
+ * @see AbstractMimeTypeTest#expectedMimeTypeForPostscript_test_eps()
*/
@Override
protected String expectedMimeTypeForPostscript_test_eps() {
@@ -623,7 +622,7 @@
/**
* {@inheritDoc}
*
- * @see org.jboss.dna.repository.mimetype.AbstractMimeTypeTest#expectedMimeTypeForPostscript_test_ps()
+ * @see AbstractMimeTypeTest#expectedMimeTypeForPostscript_test_ps()
*/
@Override
protected String expectedMimeTypeForPostscript_test_ps() {
@@ -643,7 +642,7 @@
/**
* {@inheritDoc}
*
- * @see org.jboss.dna.repository.mimetype.AbstractMimeTypeTest#expectedMimeTypeForGZip_test_tar_gz()
+ * @see AbstractMimeTypeTest#expectedMimeTypeForGZip_test_tar_gz()
*/
@Override
protected String expectedMimeTypeForGZip_test_tar_gz() {
@@ -653,7 +652,7 @@
/**
* {@inheritDoc}
*
- * @see org.jboss.dna.repository.mimetype.AbstractMimeTypeTest#expectedMimeTypeForGZip_test_txt_gz()
+ * @see AbstractMimeTypeTest#expectedMimeTypeForGZip_test_txt_gz()
*/
@Override
protected String expectedMimeTypeForGZip_test_txt_gz() {
@@ -693,7 +692,7 @@
/**
* {@inheritDoc}
*
- * @see org.jboss.dna.repository.mimetype.AbstractMimeTypeTest#expectedMimeTypeForOpenDocumentPresentation_openoffice_2_0_impress_odp()
+ * @see AbstractMimeTypeTest#expectedMimeTypeForOpenDocumentPresentation_openoffice_2_0_impress_odp()
*/
@Override
protected String expectedMimeTypeForOpenDocumentPresentation_openoffice_2_0_impress_odp() {
@@ -703,7 +702,7 @@
/**
* {@inheritDoc}
*
- * @see org.jboss.dna.repository.mimetype.AbstractMimeTypeTest#expectedMimeTypeForOpenDocumentPresentation_component_architecture_odp()
+ * @see AbstractMimeTypeTest#expectedMimeTypeForOpenDocumentPresentation_component_architecture_odp()
*/
@Override
protected String expectedMimeTypeForOpenDocumentPresentation_component_architecture_odp() {
@@ -798,7 +797,7 @@
/**
* {@inheritDoc}
*
- * @see org.jboss.dna.repository.mimetype.AbstractMimeTypeTest#expectedMimeTypeForStarOfficeWriterTemplate()
+ * @see AbstractMimeTypeTest#expectedMimeTypeForStarOfficeWriterTemplate()
*/
@Override
protected String expectedMimeTypeForStarOfficeWriterTemplate() {
@@ -808,7 +807,7 @@
/**
* {@inheritDoc}
*
- * @see org.jboss.dna.repository.mimetype.AbstractMimeTypeTest#expectedMimeTypeForStarOfficeCalcTemplate()
+ * @see AbstractMimeTypeTest#expectedMimeTypeForStarOfficeCalcTemplate()
*/
@Override
protected String expectedMimeTypeForStarOfficeCalcTemplate() {
@@ -818,7 +817,7 @@
/**
* {@inheritDoc}
*
- * @see org.jboss.dna.repository.mimetype.AbstractMimeTypeTest#expectedMimeTypeForStarOfficeDrawTemplate()
+ * @see AbstractMimeTypeTest#expectedMimeTypeForStarOfficeDrawTemplate()
*/
@Override
protected String expectedMimeTypeForStarOfficeDrawTemplate() {
@@ -828,7 +827,7 @@
/**
* {@inheritDoc}
*
- * @see org.jboss.dna.repository.mimetype.AbstractMimeTypeTest#expectedMimeTypeForStarOfficeImpressTemplate()
+ * @see AbstractMimeTypeTest#expectedMimeTypeForStarOfficeImpressTemplate()
*/
@Override
protected String expectedMimeTypeForStarOfficeImpressTemplate() {
@@ -838,7 +837,7 @@
/**
* {@inheritDoc}
*
- * @see org.jboss.dna.repository.mimetype.AbstractMimeTypeTest#expectedMimeTypeForWord_test_word_2000_doc()
+ * @see AbstractMimeTypeTest#expectedMimeTypeForWord_test_word_2000_doc()
*/
@Override
protected String expectedMimeTypeForWord_test_word_2000_doc() {
@@ -848,7 +847,7 @@
/**
* {@inheritDoc}
*
- * @see org.jboss.dna.repository.mimetype.AbstractMimeTypeTest#expectedMimeTypeForWord_test_word_6_0_95_doc()
+ * @see AbstractMimeTypeTest#expectedMimeTypeForWord_test_word_6_0_95_doc()
*/
@Override
protected String expectedMimeTypeForWord_test_word_6_0_95_doc() {
@@ -858,7 +857,7 @@
/**
* {@inheritDoc}
*
- * @see org.jboss.dna.repository.mimetype.AbstractMimeTypeTest#expectedMimeTypeForWord_microsoft_word_2000_doc()
+ * @see AbstractMimeTypeTest#expectedMimeTypeForWord_microsoft_word_2000_doc()
*/
@Override
protected String expectedMimeTypeForWord_microsoft_word_2000_doc() {
@@ -868,7 +867,7 @@
/**
* {@inheritDoc}
*
- * @see org.jboss.dna.repository.mimetype.AbstractMimeTypeTest#expectedMimeTypeForWord_microsoft_word_2000_with_wrong_file_extension_pdf()
+ * @see AbstractMimeTypeTest#expectedMimeTypeForWord_microsoft_word_2000_with_wrong_file_extension_pdf()
*/
@Override
protected String expectedMimeTypeForWord_microsoft_word_2000_with_wrong_file_extension_pdf() {
@@ -878,7 +877,7 @@
/**
* {@inheritDoc}
*
- * @see org.jboss.dna.repository.mimetype.AbstractMimeTypeTest#expectedMimeTypeForWord_microsoft_word_2007beta2_dotx()
+ * @see AbstractMimeTypeTest#expectedMimeTypeForWord_microsoft_word_2007beta2_dotx()
*/
@Override
protected String expectedMimeTypeForWord_microsoft_word_2007beta2_dotx() {
@@ -888,7 +887,7 @@
/**
* {@inheritDoc}
*
- * @see org.jboss.dna.repository.mimetype.AbstractMimeTypeTest#expectedMimeTypeForWord_microsoft_word_2007beta2_docm()
+ * @see AbstractMimeTypeTest#expectedMimeTypeForWord_microsoft_word_2007beta2_docm()
*/
@Override
protected String expectedMimeTypeForWord_microsoft_word_2007beta2_docm() {
@@ -898,7 +897,7 @@
/**
* {@inheritDoc}
*
- * @see org.jboss.dna.repository.mimetype.AbstractMimeTypeTest#expectedMimeTypeForWord_microsoft_word_2007beta2_docx()
+ * @see AbstractMimeTypeTest#expectedMimeTypeForWord_microsoft_word_2007beta2_docx()
*/
@Override
protected String expectedMimeTypeForWord_microsoft_word_2007beta2_docx() {
@@ -908,7 +907,7 @@
/**
* {@inheritDoc}
*
- * @see org.jboss.dna.repository.mimetype.AbstractMimeTypeTest#expectedMimeTypeForWord_microsoft_word_2007beta2_dotm()
+ * @see AbstractMimeTypeTest#expectedMimeTypeForWord_microsoft_word_2007beta2_dotm()
*/
@Override
protected String expectedMimeTypeForWord_microsoft_word_2007beta2_dotm() {
@@ -918,7 +917,7 @@
/**
* {@inheritDoc}
*
- * @see org.jboss.dna.repository.mimetype.AbstractMimeTypeTest#expectedMimeTypeForWorks_microsoft_works_spreadsheet_4_0_2000_wks()
+ * @see AbstractMimeTypeTest#expectedMimeTypeForWorks_microsoft_works_spreadsheet_4_0_2000_wks()
*/
@Override
protected String expectedMimeTypeForWorks_microsoft_works_spreadsheet_4_0_2000_wks() {
@@ -928,7 +927,7 @@
/**
* {@inheritDoc}
*
- * @see org.jboss.dna.repository.mimetype.AbstractMimeTypeTest#expectedMimeTypeForWorks_microsoft_works_word_processor_7_0_wps()
+ * @see AbstractMimeTypeTest#expectedMimeTypeForWorks_microsoft_works_word_processor_7_0_wps()
*/
@Override
protected String expectedMimeTypeForWorks_microsoft_works_word_processor_7_0_wps() {
@@ -938,7 +937,7 @@
/**
* {@inheritDoc}
*
- * @see org.jboss.dna.repository.mimetype.AbstractMimeTypeTest#expectedMimeTypeForWorks_microsoft_works_spreadsheet_7_0_xlr()
+ * @see AbstractMimeTypeTest#expectedMimeTypeForWorks_microsoft_works_spreadsheet_7_0_xlr()
*/
@Override
protected String expectedMimeTypeForWorks_microsoft_works_spreadsheet_7_0_xlr() {
@@ -948,7 +947,7 @@
/**
* {@inheritDoc}
*
- * @see org.jboss.dna.repository.mimetype.AbstractMimeTypeTest#expectedMimeTypeForWorks_microsoft_works_word_processor_2000_wps()
+ * @see AbstractMimeTypeTest#expectedMimeTypeForWorks_microsoft_works_word_processor_2000_wps()
*/
@Override
protected String expectedMimeTypeForWorks_microsoft_works_word_processor_2000_wps() {
@@ -958,7 +957,7 @@
/**
* {@inheritDoc}
*
- * @see org.jboss.dna.repository.mimetype.AbstractMimeTypeTest#expectedMimeTypeForWorks_microsoft_works_word_processor_4_0_wps()
+ * @see AbstractMimeTypeTest#expectedMimeTypeForWorks_microsoft_works_word_processor_4_0_wps()
*/
@Override
protected String expectedMimeTypeForWorks_microsoft_works_word_processor_4_0_wps() {
@@ -968,7 +967,7 @@
/**
* {@inheritDoc}
*
- * @see org.jboss.dna.repository.mimetype.AbstractMimeTypeTest#expectedMimeTypeForWorks_microsoft_works_word_processor_3_0_wps()
+ * @see AbstractMimeTypeTest#expectedMimeTypeForWorks_microsoft_works_word_processor_3_0_wps()
*/
@Override
protected String expectedMimeTypeForWorks_microsoft_works_word_processor_3_0_wps() {
@@ -978,7 +977,7 @@
/**
* {@inheritDoc}
*
- * @see org.jboss.dna.repository.mimetype.AbstractMimeTypeTest#expectedMimeTypeForWorkbook_corel_quattro_pro_6_wb2()
+ * @see AbstractMimeTypeTest#expectedMimeTypeForWorkbook_corel_quattro_pro_6_wb2()
*/
@Override
protected String expectedMimeTypeForWorkbook_corel_quattro_pro_6_wb2() {
@@ -988,7 +987,7 @@
/**
* {@inheritDoc}
*
- * @see org.jboss.dna.repository.mimetype.AbstractMimeTypeTest#expectedMimeTypeForWorkbook_microsoft_works_spreadsheet_3_0_wks()
+ * @see AbstractMimeTypeTest#expectedMimeTypeForWorkbook_microsoft_works_spreadsheet_3_0_wks()
*/
@Override
protected String expectedMimeTypeForWorkbook_microsoft_works_spreadsheet_3_0_wks() {
@@ -998,7 +997,7 @@
/**
* {@inheritDoc}
*
- * @see org.jboss.dna.repository.mimetype.AbstractMimeTypeTest#expectedMimeTypeForExcel_test_excel_2000_xls()
+ * @see AbstractMimeTypeTest#expectedMimeTypeForExcel_test_excel_2000_xls()
*/
@Override
protected String expectedMimeTypeForExcel_test_excel_2000_xls() {
@@ -1008,7 +1007,7 @@
/**
* {@inheritDoc}
*
- * @see org.jboss.dna.repository.mimetype.AbstractMimeTypeTest#expectedMimeTypeForExcel_microsoft_excel_2007beta2_xltx()
+ * @see AbstractMimeTypeTest#expectedMimeTypeForExcel_microsoft_excel_2007beta2_xltx()
*/
@Override
protected String expectedMimeTypeForExcel_microsoft_excel_2007beta2_xltx() {
@@ -1018,7 +1017,7 @@
/**
* {@inheritDoc}
*
- * @see org.jboss.dna.repository.mimetype.AbstractMimeTypeTest#expectedMimeTypeForExcel_microsoft_excel_2000_xls()
+ * @see AbstractMimeTypeTest#expectedMimeTypeForExcel_microsoft_excel_2000_xls()
*/
@Override
protected String expectedMimeTypeForExcel_microsoft_excel_2000_xls() {
@@ -1028,7 +1027,7 @@
/**
* {@inheritDoc}
*
- * @see org.jboss.dna.repository.mimetype.AbstractMimeTypeTest#expectedMimeTypeForExcel_microsoft_excel_2007beta2_xlam()
+ * @see AbstractMimeTypeTest#expectedMimeTypeForExcel_microsoft_excel_2007beta2_xlam()
*/
@Override
protected String expectedMimeTypeForExcel_microsoft_excel_2007beta2_xlam() {
@@ -1038,7 +1037,7 @@
/**
* {@inheritDoc}
*
- * @see org.jboss.dna.repository.mimetype.AbstractMimeTypeTest#expectedMimeTypeForExcel_microsoft_excel_2007beta2_xltm()
+ * @see AbstractMimeTypeTest#expectedMimeTypeForExcel_microsoft_excel_2007beta2_xltm()
*/
@Override
protected String expectedMimeTypeForExcel_microsoft_excel_2007beta2_xltm() {
@@ -1048,7 +1047,7 @@
/**
* {@inheritDoc}
*
- * @see org.jboss.dna.repository.mimetype.AbstractMimeTypeTest#expectedMimeTypeForExcel_microsoft_excel_2007beta2_xlsx()
+ * @see AbstractMimeTypeTest#expectedMimeTypeForExcel_microsoft_excel_2007beta2_xlsx()
*/
@Override
protected String expectedMimeTypeForExcel_microsoft_excel_2007beta2_xlsx() {
@@ -1058,7 +1057,7 @@
/**
* {@inheritDoc}
*
- * @see org.jboss.dna.repository.mimetype.AbstractMimeTypeTest#expectedMimeTypeForExcel_microsoft_excel_2007beta2_xlsb()
+ * @see AbstractMimeTypeTest#expectedMimeTypeForExcel_microsoft_excel_2007beta2_xlsb()
*/
@Override
protected String expectedMimeTypeForExcel_microsoft_excel_2007beta2_xlsb() {
@@ -1068,7 +1067,7 @@
/**
* {@inheritDoc}
*
- * @see org.jboss.dna.repository.mimetype.AbstractMimeTypeTest#expectedMimeTypeForExcel_microsoft_excel_2007beta2_xlsm()
+ * @see AbstractMimeTypeTest#expectedMimeTypeForExcel_microsoft_excel_2007beta2_xlsm()
*/
@Override
protected String expectedMimeTypeForExcel_microsoft_excel_2007beta2_xlsm() {
@@ -1078,7 +1077,7 @@
/**
* {@inheritDoc}
*
- * @see org.jboss.dna.repository.mimetype.AbstractMimeTypeTest#expectedMimeTypeForPowerpoint_microsoft_powerpoint_2007beta2_potm()
+ * @see AbstractMimeTypeTest#expectedMimeTypeForPowerpoint_microsoft_powerpoint_2007beta2_potm()
*/
@Override
protected String expectedMimeTypeForPowerpoint_microsoft_powerpoint_2007beta2_potm() {
@@ -1088,7 +1087,7 @@
/**
* {@inheritDoc}
*
- * @see org.jboss.dna.repository.mimetype.AbstractMimeTypeTest#expectedMimeTypeForPowerpoint_microsoft_powerpoint_2007beta2_ppsm()
+ * @see AbstractMimeTypeTest#expectedMimeTypeForPowerpoint_microsoft_powerpoint_2007beta2_ppsm()
*/
@Override
protected String expectedMimeTypeForPowerpoint_microsoft_powerpoint_2007beta2_ppsm() {
@@ -1098,7 +1097,7 @@
/**
* {@inheritDoc}
*
- * @see org.jboss.dna.repository.mimetype.AbstractMimeTypeTest#expectedMimeTypeForPowerpoint_microsoft_powerpoint_2007beta2_pptm()
+ * @see AbstractMimeTypeTest#expectedMimeTypeForPowerpoint_microsoft_powerpoint_2007beta2_pptm()
*/
@Override
protected String expectedMimeTypeForPowerpoint_microsoft_powerpoint_2007beta2_pptm() {
@@ -1108,7 +1107,7 @@
/**
* {@inheritDoc}
*
- * @see org.jboss.dna.repository.mimetype.AbstractMimeTypeTest#expectedMimeTypeForPowerpoint_microsoft_powerpoint_2007beta2_pptx()
+ * @see AbstractMimeTypeTest#expectedMimeTypeForPowerpoint_microsoft_powerpoint_2007beta2_pptx()
*/
@Override
protected String expectedMimeTypeForPowerpoint_microsoft_powerpoint_2007beta2_pptx() {
@@ -1118,7 +1117,7 @@
/**
* {@inheritDoc}
*
- * @see org.jboss.dna.repository.mimetype.AbstractMimeTypeTest#expectedMimeTypeForPowerpoint_microsoft_powerpoint_2007beta2_potx()
+ * @see AbstractMimeTypeTest#expectedMimeTypeForPowerpoint_microsoft_powerpoint_2007beta2_potx()
*/
@Override
protected String expectedMimeTypeForPowerpoint_microsoft_powerpoint_2007beta2_potx() {
@@ -1128,7 +1127,7 @@
/**
* {@inheritDoc}
*
- * @see org.jboss.dna.repository.mimetype.AbstractMimeTypeTest#expectedMimeTypeForPowerpoint_microsoft_powerpoint_2000_ppt()
+ * @see AbstractMimeTypeTest#expectedMimeTypeForPowerpoint_microsoft_powerpoint_2000_ppt()
*/
@Override
protected String expectedMimeTypeForPowerpoint_microsoft_powerpoint_2000_ppt() {
@@ -1138,7 +1137,7 @@
/**
* {@inheritDoc}
*
- * @see org.jboss.dna.repository.mimetype.AbstractMimeTypeTest#expectedMimeTypeForPowerpoint_test_ppt()
+ * @see AbstractMimeTypeTest#expectedMimeTypeForPowerpoint_test_ppt()
*/
@Override
protected String expectedMimeTypeForPowerpoint_test_ppt() {
@@ -1148,7 +1147,7 @@
/**
* {@inheritDoc}
*
- * @see org.jboss.dna.repository.mimetype.AbstractMimeTypeTest#expectedMimeTypeForPowerpoint_microsoft_powerpoint_2007beta2_ppsx()
+ * @see AbstractMimeTypeTest#expectedMimeTypeForPowerpoint_microsoft_powerpoint_2007beta2_ppsx()
*/
@Override
protected String expectedMimeTypeForPowerpoint_microsoft_powerpoint_2007beta2_ppsx() {
@@ -1173,7 +1172,7 @@
/**
* {@inheritDoc}
*
- * @see org.jboss.dna.repository.mimetype.AbstractMimeTypeTest#expectedMimeTypeForShw_corel_presentations_3_0_shw()
+ * @see AbstractMimeTypeTest#expectedMimeTypeForShw_corel_presentations_3_0_shw()
*/
@Override
protected String expectedMimeTypeForShw_corel_presentations_3_0_shw() {
@@ -1183,7 +1182,7 @@
/**
* {@inheritDoc}
*
- * @see org.jboss.dna.repository.mimetype.AbstractMimeTypeTest#expectedMimeTypeForShw_corel_presentations_x3_shw()
+ * @see AbstractMimeTypeTest#expectedMimeTypeForShw_corel_presentations_x3_shw()
*/
@Override
protected String expectedMimeTypeForShw_corel_presentations_x3_shw() {
@@ -1193,7 +1192,7 @@
/**
* {@inheritDoc}
*
- * @see org.jboss.dna.repository.mimetype.AbstractMimeTypeTest#expectedMimeTypeForPro_corel_quattro_pro_7_wb3()
+ * @see AbstractMimeTypeTest#expectedMimeTypeForPro_corel_quattro_pro_7_wb3()
*/
@Override
protected String expectedMimeTypeForPro_corel_quattro_pro_7_wb3() {
@@ -1203,7 +1202,7 @@
/**
* {@inheritDoc}
*
- * @see org.jboss.dna.repository.mimetype.AbstractMimeTypeTest#expectedMimeTypeForPro_corel_quattro_pro_x3_qpw()
+ * @see AbstractMimeTypeTest#expectedMimeTypeForPro_corel_quattro_pro_x3_qpw()
*/
@Override
protected String expectedMimeTypeForPro_corel_quattro_pro_x3_qpw() {
@@ -1213,7 +1212,7 @@
/**
* {@inheritDoc}
*
- * @see org.jboss.dna.repository.mimetype.AbstractMimeTypeTest#expectedMimeTypeForWordperfect_corel_wordperfect_x3_wpd()
+ * @see AbstractMimeTypeTest#expectedMimeTypeForWordperfect_corel_wordperfect_x3_wpd()
*/
@Override
protected String expectedMimeTypeForWordperfect_corel_wordperfect_x3_wpd() {
@@ -1223,7 +1222,7 @@
/**
* {@inheritDoc}
*
- * @see org.jboss.dna.repository.mimetype.AbstractMimeTypeTest#expectedMimeTypeForWordperfect_corel_wordperfect_4_2_wp()
+ * @see AbstractMimeTypeTest#expectedMimeTypeForWordperfect_corel_wordperfect_4_2_wp()
*/
@Override
protected String expectedMimeTypeForWordperfect_corel_wordperfect_4_2_wp() {
@@ -1233,7 +1232,7 @@
/**
* {@inheritDoc}
*
- * @see org.jboss.dna.repository.mimetype.AbstractMimeTypeTest#expectedMimeTypeForWordperfect_corel_wordperfect_5_0_wp()
+ * @see AbstractMimeTypeTest#expectedMimeTypeForWordperfect_corel_wordperfect_5_0_wp()
*/
@Override
protected String expectedMimeTypeForWordperfect_corel_wordperfect_5_0_wp() {
@@ -1243,7 +1242,7 @@
/**
* {@inheritDoc}
*
- * @see org.jboss.dna.repository.mimetype.AbstractMimeTypeTest#expectedMimeTypeForWordperfect_corel_wordperfect_5_1_far_east_wp()
+ * @see AbstractMimeTypeTest#expectedMimeTypeForWordperfect_corel_wordperfect_5_1_far_east_wp()
*/
@Override
protected String expectedMimeTypeForWordperfect_corel_wordperfect_5_1_far_east_wp() {
@@ -1253,7 +1252,7 @@
/**
* {@inheritDoc}
*
- * @see org.jboss.dna.repository.mimetype.AbstractMimeTypeTest#expectedMimeTypeForWordperfect_corel_wordperfect_5_1_wp()
+ * @see AbstractMimeTypeTest#expectedMimeTypeForWordperfect_corel_wordperfect_5_1_wp()
*/
@Override
protected String expectedMimeTypeForWordperfect_corel_wordperfect_5_1_wp() {
@@ -1263,7 +1262,7 @@
/**
* {@inheritDoc}
*
- * @see org.jboss.dna.repository.mimetype.AbstractMimeTypeTest#expectedMimeTypeForMail_test_excel_web_archive_mht()
+ * @see AbstractMimeTypeTest#expectedMimeTypeForMail_test_excel_web_archive_mht()
*/
@Override
protected String expectedMimeTypeForMail_test_excel_web_archive_mht() {
@@ -1273,7 +1272,7 @@
/**
* {@inheritDoc}
*
- * @see org.jboss.dna.repository.mimetype.AbstractMimeTypeTest#expectedMimeTypeForMail_mail_thunderbird_1_5_eml()
+ * @see AbstractMimeTypeTest#expectedMimeTypeForMail_mail_thunderbird_1_5_eml()
*/
@Override
protected String expectedMimeTypeForMail_mail_thunderbird_1_5_eml() {
@@ -1283,7 +1282,7 @@
/**
* {@inheritDoc}
*
- * @see org.jboss.dna.repository.mimetype.AbstractMimeTypeTest#expectedMimeTypeForMail_mhtml_firefox_mht()
+ * @see AbstractMimeTypeTest#expectedMimeTypeForMail_mhtml_firefox_mht()
*/
@Override
protected String expectedMimeTypeForMail_mhtml_firefox_mht() {
@@ -1293,7 +1292,7 @@
/**
* {@inheritDoc}
*
- * @see org.jboss.dna.repository.mimetype.AbstractMimeTypeTest#expectedMimeTypeForMail_mhtml_internet_explorer_mht()
+ * @see AbstractMimeTypeTest#expectedMimeTypeForMail_mhtml_internet_explorer_mht()
*/
@Override
protected String expectedMimeTypeForMail_mhtml_internet_explorer_mht() {
@@ -1308,7 +1307,7 @@
/**
* {@inheritDoc}
*
- * @see org.jboss.dna.repository.mimetype.AbstractMimeTypeTest#expectedMimeTypeForVCard_vcard_vCards_SAP_vcf()
+ * @see AbstractMimeTypeTest#expectedMimeTypeForVCard_vcard_vCards_SAP_vcf()
*/
@Override
protected String expectedMimeTypeForVCard_vcard_vCards_SAP_vcf() {
@@ -1318,7 +1317,7 @@
/**
* {@inheritDoc}
*
- * @see org.jboss.dna.repository.mimetype.AbstractMimeTypeTest#expectedMimeTypeForVCard_vcard_antoni_kontact_vcf()
+ * @see AbstractMimeTypeTest#expectedMimeTypeForVCard_vcard_antoni_kontact_vcf()
*/
@Override
protected String expectedMimeTypeForVCard_vcard_antoni_kontact_vcf() {
@@ -1328,7 +1327,7 @@
/**
* {@inheritDoc}
*
- * @see org.jboss.dna.repository.mimetype.AbstractMimeTypeTest#expectedMimeTypeForVCard_vcard_antoni_outlook2003_vcf()
+ * @see AbstractMimeTypeTest#expectedMimeTypeForVCard_vcard_antoni_outlook2003_vcf()
*/
@Override
protected String expectedMimeTypeForVCard_vcard_antoni_outlook2003_vcf() {
@@ -1338,7 +1337,7 @@
/**
* {@inheritDoc}
*
- * @see org.jboss.dna.repository.mimetype.AbstractMimeTypeTest#expectedMimeTypeForVCard_vcard_dirk_vcf()
+ * @see AbstractMimeTypeTest#expectedMimeTypeForVCard_vcard_dirk_vcf()
*/
@Override
protected String expectedMimeTypeForVCard_vcard_dirk_vcf() {
@@ -1348,7 +1347,7 @@
/**
* {@inheritDoc}
*
- * @see org.jboss.dna.repository.mimetype.AbstractMimeTypeTest#expectedMimeTypeForVCard_vcard_rfc2426_vcf()
+ * @see AbstractMimeTypeTest#expectedMimeTypeForVCard_vcard_rfc2426_vcf()
*/
@Override
protected String expectedMimeTypeForVCard_vcard_rfc2426_vcf() {
@@ -1358,7 +1357,7 @@
/**
* {@inheritDoc}
*
- * @see org.jboss.dna.repository.mimetype.AbstractMimeTypeTest#expectedMimeTypeForCalendar_Todos1_ics()
+ * @see AbstractMimeTypeTest#expectedMimeTypeForCalendar_Todos1_ics()
*/
@Override
protected String expectedMimeTypeForCalendar_Todos1_ics() {
@@ -1368,7 +1367,7 @@
/**
* {@inheritDoc}
*
- * @see org.jboss.dna.repository.mimetype.AbstractMimeTypeTest#expectedMimeTypeForCalendar_basicCalendar_ics()
+ * @see AbstractMimeTypeTest#expectedMimeTypeForCalendar_basicCalendar_ics()
*/
@Override
protected String expectedMimeTypeForCalendar_basicCalendar_ics() {
@@ -1378,7 +1377,7 @@
/**
* {@inheritDoc}
*
- * @see org.jboss.dna.repository.mimetype.AbstractMimeTypeTest#expectedMimeTypeForCalendar_cal01_1_ics()
+ * @see AbstractMimeTypeTest#expectedMimeTypeForCalendar_cal01_1_ics()
*/
@Override
protected String expectedMimeTypeForCalendar_cal01_1_ics() {
@@ -1388,7 +1387,7 @@
/**
* {@inheritDoc}
*
- * @see org.jboss.dna.repository.mimetype.AbstractMimeTypeTest#expectedMimeTypeForCalendar_cal01_2_ics()
+ * @see AbstractMimeTypeTest#expectedMimeTypeForCalendar_cal01_2_ics()
*/
@Override
protected String expectedMimeTypeForCalendar_cal01_2_ics() {
@@ -1398,7 +1397,7 @@
/**
* {@inheritDoc}
*
- * @see org.jboss.dna.repository.mimetype.AbstractMimeTypeTest#expectedMimeTypeForCalendar_cal01_3_ics()
+ * @see AbstractMimeTypeTest#expectedMimeTypeForCalendar_cal01_3_ics()
*/
@Override
protected String expectedMimeTypeForCalendar_cal01_3_ics() {
@@ -1408,7 +1407,7 @@
/**
* {@inheritDoc}
*
- * @see org.jboss.dna.repository.mimetype.AbstractMimeTypeTest#expectedMimeTypeForCalendar_cal01_4_ics()
+ * @see AbstractMimeTypeTest#expectedMimeTypeForCalendar_cal01_4_ics()
*/
@Override
protected String expectedMimeTypeForCalendar_cal01_4_ics() {
@@ -1418,7 +1417,7 @@
/**
* {@inheritDoc}
*
- * @see org.jboss.dna.repository.mimetype.AbstractMimeTypeTest#expectedMimeTypeForCalendar_cal01_5_ics()
+ * @see AbstractMimeTypeTest#expectedMimeTypeForCalendar_cal01_5_ics()
*/
@Override
protected String expectedMimeTypeForCalendar_cal01_5_ics() {
@@ -1428,7 +1427,7 @@
/**
* {@inheritDoc}
*
- * @see org.jboss.dna.repository.mimetype.AbstractMimeTypeTest#expectedMimeTypeForCalendar_cal01_6_ics()
+ * @see AbstractMimeTypeTest#expectedMimeTypeForCalendar_cal01_6_ics()
*/
@Override
protected String expectedMimeTypeForCalendar_cal01_6_ics() {
@@ -1438,7 +1437,7 @@
/**
* {@inheritDoc}
*
- * @see org.jboss.dna.repository.mimetype.AbstractMimeTypeTest#expectedMimeTypeForCalendar_cal01_exrule_ics()
+ * @see AbstractMimeTypeTest#expectedMimeTypeForCalendar_cal01_exrule_ics()
*/
@Override
protected String expectedMimeTypeForCalendar_cal01_exrule_ics() {
@@ -1448,7 +1447,7 @@
/**
* {@inheritDoc}
*
- * @see org.jboss.dna.repository.mimetype.AbstractMimeTypeTest#expectedMimeTypeForCalendar_cal01_ics()
+ * @see AbstractMimeTypeTest#expectedMimeTypeForCalendar_cal01_ics()
*/
@Override
protected String expectedMimeTypeForCalendar_cal01_ics() {
@@ -1458,7 +1457,7 @@
/**
* {@inheritDoc}
*
- * @see org.jboss.dna.repository.mimetype.AbstractMimeTypeTest#expectedMimeTypeForCalendar_calconnect7_ics()
+ * @see AbstractMimeTypeTest#expectedMimeTypeForCalendar_calconnect7_ics()
*/
@Override
protected String expectedMimeTypeForCalendar_calconnect7_ics() {
@@ -1468,7 +1467,7 @@
/**
* {@inheritDoc}
*
- * @see org.jboss.dna.repository.mimetype.AbstractMimeTypeTest#expectedMimeTypeForCalendar_calconnect9_ics()
+ * @see AbstractMimeTypeTest#expectedMimeTypeForCalendar_calconnect9_ics()
*/
@Override
protected String expectedMimeTypeForCalendar_calconnect9_ics() {
@@ -1478,7 +1477,7 @@
/**
* {@inheritDoc}
*
- * @see org.jboss.dna.repository.mimetype.AbstractMimeTypeTest#expectedMimeTypeForCalendar_combined_multiplevcalendar_ics()
+ * @see AbstractMimeTypeTest#expectedMimeTypeForCalendar_combined_multiplevcalendar_ics()
*/
@Override
protected String expectedMimeTypeForCalendar_combined_multiplevcalendar_ics() {
@@ -1488,7 +1487,7 @@
/**
* {@inheritDoc}
*
- * @see org.jboss.dna.repository.mimetype.AbstractMimeTypeTest#expectedMimeTypeForCalendar_combined_onevcalendar_ics()
+ * @see AbstractMimeTypeTest#expectedMimeTypeForCalendar_combined_onevcalendar_ics()
*/
@Override
protected String expectedMimeTypeForCalendar_combined_onevcalendar_ics() {
@@ -1498,7 +1497,7 @@
/**
* {@inheritDoc}
*
- * @see org.jboss.dna.repository.mimetype.AbstractMimeTypeTest#expectedMimeTypeForCalendar_extendedCalendar_ics()
+ * @see AbstractMimeTypeTest#expectedMimeTypeForCalendar_extendedCalendar_ics()
*/
@Override
protected String expectedMimeTypeForCalendar_extendedCalendar_ics() {
@@ -1508,7 +1507,7 @@
/**
* {@inheritDoc}
*
- * @see org.jboss.dna.repository.mimetype.AbstractMimeTypeTest#expectedMimeTypeForCalendar_freebusy_ics()
+ * @see AbstractMimeTypeTest#expectedMimeTypeForCalendar_freebusy_ics()
*/
@Override
protected String expectedMimeTypeForCalendar_freebusy_ics() {
@@ -1518,7 +1517,7 @@
/**
* {@inheritDoc}
*
- * @see org.jboss.dna.repository.mimetype.AbstractMimeTypeTest#expectedMimeTypeForCalendar_geol_ics()
+ * @see AbstractMimeTypeTest#expectedMimeTypeForCalendar_geol_ics()
*/
@Override
protected String expectedMimeTypeForCalendar_geol_ics() {
@@ -1528,7 +1527,7 @@
/**
* {@inheritDoc}
*
- * @see org.jboss.dna.repository.mimetype.AbstractMimeTypeTest#expectedMimeTypeForCalendar_gkexample_ics()
+ * @see AbstractMimeTypeTest#expectedMimeTypeForCalendar_gkexample_ics()
*/
@Override
protected String expectedMimeTypeForCalendar_gkexample_ics() {
@@ -1538,7 +1537,7 @@
/**
* {@inheritDoc}
*
- * @see org.jboss.dna.repository.mimetype.AbstractMimeTypeTest#expectedMimeTypeForCalendar_incoming_ics()
+ * @see AbstractMimeTypeTest#expectedMimeTypeForCalendar_incoming_ics()
*/
@Override
protected String expectedMimeTypeForCalendar_incoming_ics() {
@@ -1548,7 +1547,7 @@
/**
* {@inheritDoc}
*
- * @see org.jboss.dna.repository.mimetype.AbstractMimeTypeTest#expectedMimeTypeForCalendar_korganizer_jicaltest_ics()
+ * @see AbstractMimeTypeTest#expectedMimeTypeForCalendar_korganizer_jicaltest_ics()
*/
@Override
protected String expectedMimeTypeForCalendar_korganizer_jicaltest_ics() {
@@ -1558,7 +1557,7 @@
/**
* {@inheritDoc}
*
- * @see org.jboss.dna.repository.mimetype.AbstractMimeTypeTest#expectedMimeTypeForCalendar_korganizer_jicaltest_vjournal_ics()
+ * @see AbstractMimeTypeTest#expectedMimeTypeForCalendar_korganizer_jicaltest_vjournal_ics()
*/
@Override
protected String expectedMimeTypeForCalendar_korganizer_jicaltest_vjournal_ics() {
@@ -1568,7 +1567,7 @@
/**
* {@inheritDoc}
*
- * @see org.jboss.dna.repository.mimetype.AbstractMimeTypeTest#expectedMimeTypeForCalendar_php_flp_ics()
+ * @see AbstractMimeTypeTest#expectedMimeTypeForCalendar_php_flp_ics()
*/
@Override
protected String expectedMimeTypeForCalendar_php_flp_ics() {
@@ -1578,7 +1577,7 @@
/**
* {@inheritDoc}
*
- * @see org.jboss.dna.repository.mimetype.AbstractMimeTypeTest#expectedMimeTypeForCalendar_simplevevent_ics()
+ * @see AbstractMimeTypeTest#expectedMimeTypeForCalendar_simplevevent_ics()
*/
@Override
protected String expectedMimeTypeForCalendar_simplevevent_ics() {
@@ -1588,7 +1587,7 @@
/**
* {@inheritDoc}
*
- * @see org.jboss.dna.repository.mimetype.AbstractMimeTypeTest#expectedMimeTypeForCalendar_sunbird_sample_ics()
+ * @see AbstractMimeTypeTest#expectedMimeTypeForCalendar_sunbird_sample_ics()
*/
@Override
protected String expectedMimeTypeForCalendar_sunbird_sample_ics() {
@@ -1598,7 +1597,7 @@
/**
* {@inheritDoc}
*
- * @see org.jboss.dna.repository.mimetype.AbstractMimeTypeTest#expectedMimeTypeForCalendar_tag_bug_ics()
+ * @see AbstractMimeTypeTest#expectedMimeTypeForCalendar_tag_bug_ics()
*/
@Override
protected String expectedMimeTypeForCalendar_tag_bug_ics() {
@@ -1608,7 +1607,7 @@
/**
* {@inheritDoc}
*
- * @see org.jboss.dna.repository.mimetype.AbstractMimeTypeTest#expectedMimeTypeForCalendar_test_created_ics()
+ * @see AbstractMimeTypeTest#expectedMimeTypeForCalendar_test_created_ics()
*/
@Override
protected String expectedMimeTypeForCalendar_test_created_ics() {
15 years, 1 month
DNA SVN: r920 - in trunk: dna-jcr/src/test/java/org/jboss/dna/jcr and 6 other directories.
by dna-commits@lists.jboss.org
Author: rhauch
Date: 2009-05-21 15:03:27 -0400 (Thu, 21 May 2009)
New Revision: 920
Removed:
trunk/dna-repository/src/main/java/org/jboss/dna/repository/mimetype/MimeType.java
trunk/dna-repository/src/test/java/org/jboss/dna/repository/mimetype/MimeTypeTest.java
Modified:
trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/JcrEngine.java
trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/JcrConfigurationTest.java
trunk/dna-repository/src/main/java/org/jboss/dna/repository/Configurator.java
trunk/dna-repository/src/main/java/org/jboss/dna/repository/DnaEngine.java
trunk/dna-repository/src/main/java/org/jboss/dna/repository/RepositoryLibrary.java
trunk/dna-repository/src/main/java/org/jboss/dna/repository/RepositoryService.java
trunk/dna-repository/src/main/java/org/jboss/dna/repository/mimetype/MimeTypeDetectorConfig.java
trunk/dna-repository/src/main/java/org/jboss/dna/repository/mimetype/MimeTypeDetectors.java
trunk/dna-repository/src/main/java/org/jboss/dna/repository/sequencer/StreamSequencerAdapter.java
trunk/dna-repository/src/test/java/org/jboss/dna/repository/DnaEngineTest.java
trunk/dna-repository/src/test/java/org/jboss/dna/repository/RepositoryServiceTest.java
trunk/dna-repository/src/test/java/org/jboss/dna/repository/mimetype/AbstractMimeTypeTest.java
trunk/dna-repository/src/test/java/org/jboss/dna/repository/sequencer/StreamSequencerAdapterTest.java
Log:
DNA-404 Remove ObservationService, migrate usage to observe RepositoryLibrary
Began the removal of ObservationService by first simplifying DnaEngine initialization. Changed how the MIME type detectors are managed (no longer in RepositoryLibrary, which seemed the wrong place, and now in the DnaEngine proper), exposing the MIME type detectors via the DnaEngine's ExecutionContext. Also removed the MimeType singleton class to ensure that all detection is done via the (existing) ExecutionContext.getMimeTypeDetector().mimeTypeOf(...) approach.
Modified: trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/JcrEngine.java
===================================================================
--- trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/JcrEngine.java 2009-05-21 17:01:04 UTC (rev 919)
+++ trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/JcrEngine.java 2009-05-21 19:03:27 UTC (rev 920)
@@ -25,6 +25,7 @@
import java.util.HashMap;
import java.util.Map;
+import java.util.concurrent.TimeUnit;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;
import javax.jcr.Repository;
@@ -44,7 +45,6 @@
import org.jboss.dna.jcr.JcrRepository.Option;
import org.jboss.dna.repository.DnaEngine;
import org.jboss.dna.repository.RepositoryService;
-import org.jboss.dna.repository.observation.ObservationService;
import org.jboss.dna.repository.sequencer.SequencingService;
/**
@@ -98,10 +98,6 @@
return dnaEngine.getRepositoryService();
}
- protected final ObservationService getObservationService() {
- return dnaEngine.getObservationService();
- }
-
protected final SequencingService getSequencingService() {
return dnaEngine.getSequencingService();
}
@@ -167,8 +163,8 @@
Node optionNode = configuration.getNodeAt(optionLocation);
Property valueProperty = optionNode.getProperty(DnaLexicon.VALUE);
- options.put(Option.valueOf(segment.getName().getLocalName()),
- valueProperty.getFirstValue().toString());
+ options.put(Option.valueOf(segment.getName().getLocalName()), valueProperty.getFirstValue()
+ .toString());
}
@@ -187,11 +183,40 @@
* Lifecycle methods
*/
+ /**
+ * Start this engine to make it available for use.
+ *
+ * @throws IllegalStateException if this method is called when already shut down.
+ * @see #shutdown()
+ */
public void start() {
dnaEngine.start();
}
+ /**
+ * Shutdown this engine to close all connections, terminate any ongoing background operations (such as sequencing), and
+ * reclaim any resources that were acquired by this engine. This method may be called multiple times, but only the first time
+ * has an effect.
+ *
+ * @see #start()
+ */
public void shutdown() {
dnaEngine.shutdown();
}
+
+ /**
+ * Blocks until the shutdown has completed, or the timeout occurs, or the current thread is interrupted, whichever happens
+ * first.
+ *
+ * @param timeout the maximum time to wait for each component in this engine
+ * @param unit the time unit of the timeout argument
+ * @return <tt>true</tt> if this service complete shut down and <tt>false</tt> if the timeout elapsed before it was shut down
+ * completely
+ * @throws InterruptedException if interrupted while waiting
+ */
+ public boolean awaitTermination( long timeout,
+ TimeUnit unit ) throws InterruptedException {
+ return dnaEngine.awaitTermination(timeout, unit);
+ }
+
}
Modified: trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/JcrConfigurationTest.java
===================================================================
--- trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/JcrConfigurationTest.java 2009-05-21 17:01:04 UTC (rev 919)
+++ trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/JcrConfigurationTest.java 2009-05-21 19:03:27 UTC (rev 920)
@@ -301,7 +301,7 @@
assertThat(engine.getRepositorySource("config repo"), is(notNullValue()));
assertThat(engine.getRepositorySource("config repo"), is(instanceOf(InMemoryRepositorySource.class)));
- RepositoryLibrary library = engine.getRepositoryService().getRepositorySourceManager();
+ RepositoryLibrary library = engine.getRepositoryService().getRepositoryLibrary();
assertThat(library.getConnectionPool("config repo").getInUseCount(), is(0));
RepositoryConnection connection = library.getConnectionPool("config repo").getConnection();
Modified: trunk/dna-repository/src/main/java/org/jboss/dna/repository/Configurator.java
===================================================================
--- trunk/dna-repository/src/main/java/org/jboss/dna/repository/Configurator.java 2009-05-21 17:01:04 UTC (rev 919)
+++ trunk/dna-repository/src/main/java/org/jboss/dna/repository/Configurator.java 2009-05-21 19:03:27 UTC (rev 920)
@@ -169,6 +169,14 @@
* @return this instance for method chaining purposes; never null
*/
public ConfigRepositoryDetails<ReturnType> under( String path );
+
+ /**
+ * Specify the path under which the configuration content is to be found. This path is assumed to be "/" by default.
+ *
+ * @param workspace the name of the workspace with the configuration content in the configuration source; may not be null
+ * @return this instance for method chaining purposes; never null
+ */
+ public ConfigRepositoryDetails<ReturnType> inWorkspace( String workspace );
}
/**
@@ -454,7 +462,7 @@
protected ConfigurationRepository createDefaultConfigurationSource() {
InMemoryRepositorySource defaultSource = new InMemoryRepositorySource();
defaultSource.setName("Configuration");
- ConfigurationRepository result = new ConfigurationRepository(defaultSource, "Configuration Repository", null);
+ ConfigurationRepository result = new ConfigurationRepository(defaultSource, "Configuration Repository", null, null);
return result;
}
@@ -527,7 +535,7 @@
configuration().create(path).with(DnaLexicon.READABLE_NAME, id).and();
return path;
}
-
+
protected void recordBeanPropertiesInGraph( Path path,
Object javaBean ) {
Reflection reflector = new Reflection(javaBean.getClass());
@@ -612,7 +620,7 @@
* @see org.jboss.dna.repository.Configurator.SetDescription#describedAs(java.lang.String)
*/
public ConfigRepositoryDetails<ReturnType> describedAs( String description ) {
- Configurator.this.configurationSource = Configurator.this.configurationSource.with(description);
+ Configurator.this.configurationSource = Configurator.this.configurationSource.withDescription(description);
return this;
}
@@ -630,13 +638,23 @@
/**
* {@inheritDoc}
*
+ * @see org.jboss.dna.repository.Configurator.ConfigRepositoryDetails#inWorkspace(java.lang.String)
+ */
+ public ConfigRepositoryDetails<ReturnType> inWorkspace( String workspace ) {
+ Configurator.this.configurationSource = Configurator.this.configurationSource.withWorkspace(workspace);
+ return this;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
* @see org.jboss.dna.repository.Configurator.ConfigRepositoryDetails#under(java.lang.String)
*/
public ConfigRepositoryDetails<ReturnType> under( String path ) {
CheckArg.isNotNull(path, "path");
Path newPath = getExecutionContext().getValueFactories().getPathFactory().create(path);
Configurator.this.configurationSource = Configurator.this.configurationSource.with(newPath);
- return null;
+ return this;
}
/**
@@ -661,7 +679,7 @@
protected final ReturnType returnObject;
public ClassChooser( Path pathOfComponentNode,
- ReturnType returnObject ) {
+ ReturnType returnObject ) {
assert pathOfComponentNode != null;
assert returnObject != null;
this.pathOfComponentNode = pathOfComponentNode;
@@ -846,7 +864,7 @@
protected Path path() {
return this.path;
}
-
+
/**
* {@inheritDoc}
*
@@ -1018,17 +1036,20 @@
private final RepositorySource source;
private final String description;
private final Path path;
+ private final String workspace;
protected ConfigurationRepository( RepositorySource source ) {
- this(source, null, null);
+ this(source, null, null, null);
}
protected ConfigurationRepository( RepositorySource source,
String description,
- Path path ) {
+ Path path,
+ String workspace ) {
this.source = source;
this.description = description != null ? description : "";
this.path = path != null ? path : RootPath.INSTANCE;
+ this.workspace = workspace != null ? workspace : "";
}
/**
@@ -1052,12 +1073,23 @@
return path;
}
- public ConfigurationRepository with( String description ) {
- return new ConfigurationRepository(source, description, path);
+ /**
+ * @return workspace
+ */
+ public String getWorkspace() {
+ return workspace;
}
+ public ConfigurationRepository withDescription( String description ) {
+ return new ConfigurationRepository(source, description, path, workspace);
+ }
+
public ConfigurationRepository with( Path path ) {
- return new ConfigurationRepository(source, description, path);
+ return new ConfigurationRepository(source, description, path, workspace);
}
+
+ public ConfigurationRepository withWorkspace( String workspace ) {
+ return new ConfigurationRepository(source, description, path, workspace);
+ }
}
}
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-05-21 17:01:04 UTC (rev 919)
+++ trunk/dna-repository/src/main/java/org/jboss/dna/repository/DnaEngine.java 2009-05-21 19:03:27 UTC (rev 920)
@@ -22,7 +22,6 @@
package org.jboss.dna.repository;
import java.util.ArrayList;
-import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
@@ -46,16 +45,17 @@
import org.jboss.dna.graph.connector.RepositoryConnectionFactory;
import org.jboss.dna.graph.connector.RepositorySource;
import org.jboss.dna.graph.connector.RepositorySourceException;
+import org.jboss.dna.graph.mimetype.ExtensionBasedMimeTypeDetector;
+import org.jboss.dna.graph.mimetype.MimeTypeDetector;
import org.jboss.dna.graph.property.Name;
import org.jboss.dna.graph.property.Path;
import org.jboss.dna.graph.property.PathExpression;
import org.jboss.dna.graph.property.PathNotFoundException;
import org.jboss.dna.graph.property.Property;
import org.jboss.dna.repository.mimetype.MimeTypeDetectorConfig;
-import org.jboss.dna.repository.observation.ObservationService;
+import org.jboss.dna.repository.mimetype.MimeTypeDetectors;
import org.jboss.dna.repository.sequencer.SequencerConfig;
import org.jboss.dna.repository.sequencer.SequencingService;
-import org.jboss.dna.repository.service.AdministeredService;
/**
* A single instance of the DNA services, which is obtained after setting up the {@link DnaConfiguration#build() configuration}.
@@ -71,12 +71,11 @@
private final ConfigurationScanner scanner;
private final Problems problems;
private final ExecutionContext context;
- private final List<AdministeredService> services;
private final RepositoryService repositoryService;
- private final ObservationService observationService;
private final SequencingService sequencingService;
private final ExecutorService executorService;
+ private final MimeTypeDetectors detectors;
private final RepositoryConnectionFactory connectionFactory;
@@ -85,40 +84,38 @@
this.problems = new SimpleProblems();
// Use the configuration's context ...
- this.context = context;
+ this.detectors = new MimeTypeDetectors();
+ this.context = context.with(detectors);
// And set up the scanner ...
this.configuration = configuration;
this.scanner = new ConfigurationScanner(this.problems, this.context, this.configuration);
- // Add the configuration source to the repository library ...
- final RepositorySource configSource = this.configuration.getRepositorySource();
- RepositoryLibrary library = new RepositoryLibrary();
- library.addSource(configSource);
+ // Add the mime type detectors in the configuration ...
+ for (MimeTypeDetectorConfig config : scanner.getMimeTypeDetectors()) {
+ detectors.addDetector(config);
+ }
+ // Add an extension-based detector by default ...
+ detectors.addDetector(new MimeTypeDetectorConfig("ExtensionDetector", "Extension-based MIME type detector",
+ ExtensionBasedMimeTypeDetector.class));
// Create the RepositoryService, pointing it to the configuration repository ...
Path pathToConfigurationRoot = this.configuration.getPath();
- repositoryService = new RepositoryService(library, configSource.getName(), "", pathToConfigurationRoot, context);
+ String configWorkspaceName = this.configuration.getWorkspace();
+ final RepositorySource configSource = this.configuration.getRepositorySource();
+ repositoryService = new RepositoryService(configSource, configWorkspaceName, pathToConfigurationRoot, context);
- for (MimeTypeDetectorConfig config : scanner.getMimeTypeDetectors()) {
- library.getMimeTypeDetectors().addDetector(config);
- }
-
// Create the sequencing service ...
executorService = new ScheduledThreadPoolExecutor(10); // Use a magic number for now
sequencingService = new SequencingService();
sequencingService.setExecutionContext(context);
sequencingService.setExecutorService(executorService);
- sequencingService.setRepositoryLibrary(repositoryService.getRepositorySourceManager());
+ sequencingService.setRepositoryLibrary(repositoryService.getRepositoryLibrary());
for (SequencerConfig sequencerConfig : scanner.getSequencingConfigurations()) {
sequencingService.addSequencer(sequencerConfig);
}
- // Create the observation service ...
- observationService = null; // new ObservationService(null);
-
- this.services = Arrays.asList(new AdministeredService[] { /* observationService, */repositoryService, sequencingService,});
-
+ // Set up the connection factory for this engine ...
connectionFactory = new RepositoryConnectionFactory() {
public RepositoryConnection createConnection( String sourceName ) throws RepositorySourceException {
RepositorySource source = DnaEngine.this.getRepositorySource(sourceName);
@@ -140,48 +137,87 @@
return problems;
}
- /*
- * Lookup methods
+ /**
+ * Get the context in which this engine is executing.
+ *
+ * @return the execution context; never null
*/
public final ExecutionContext getExecutionContext() {
return context;
}
+ /**
+ * Get the {@link RepositorySource} instance used by this engine.
+ *
+ * @param repositoryName the name of the repository source
+ * @return the source, or null if no source with the given name exists
+ */
public final RepositorySource getRepositorySource( String repositoryName ) {
- return repositoryService.getRepositorySourceManager().getSource(repositoryName);
+ return repositoryService.getRepositoryLibrary().getSource(repositoryName);
}
+ /**
+ * Get a factory of connections, backed by the RepositorySor
+ *
+ * @return the connection factory; never null
+ */
public final RepositoryConnectionFactory getRepositoryConnectionFactory() {
return connectionFactory;
}
+ /**
+ * Get the repository service.
+ *
+ * @return the repository service owned by this engine; never null
+ */
public final RepositoryService getRepositoryService() {
return repositoryService;
}
- public final ObservationService getObservationService() {
- return observationService;
- }
-
+ /**
+ * Get the sequencing service.
+ *
+ * @return the sequencing service owned by this engine; never null
+ */
public final SequencingService getSequencingService() {
return sequencingService;
}
+ /**
+ * Return the component that is able to detect MIME types given the name of a stream and a stream.
+ *
+ * @return the MIME type detector used by this engine; never null
+ */
+ protected final MimeTypeDetector getMimeTypeDetector() {
+ return detectors;
+ }
+
/*
* Lifecycle methods
*/
-
+ /**
+ * Start this engine to make it available for use.
+ *
+ * @throws IllegalStateException if this method is called when already shut down.
+ * @see #shutdown()
+ */
public void start() {
- for (AdministeredService service : services) {
- service.getAdministrator().start();
- }
+ repositoryService.getAdministrator().start();
+ sequencingService.getAdministrator().start();
}
+ /**
+ * Shutdown this engine to close all connections, terminate any ongoing background operations (such as sequencing), and
+ * reclaim any resources that were acquired by this engine. This method may be called multiple times, but only the first time
+ * has an effect.
+ *
+ * @see #start()
+ */
public void shutdown() {
- for (AdministeredService service : services) {
- service.getAdministrator().shutdown();
- }
+ // First, shutdown the sequencing service, which will prevent any additional jobs from going through ...
+ sequencingService.getAdministrator().shutdown();
+ // Then terminate the executor service, which may be running background jobs that are not yet completed ...
try {
executorService.awaitTermination(10 * 60, TimeUnit.SECONDS); // No TimeUnit.MINUTES in JDK 5
} catch (InterruptedException ie) {
@@ -189,9 +225,30 @@
Thread.interrupted();
}
executorService.shutdown();
+
+ // Finally shut down the repository source, which closes all connections ...
+ repositoryService.getAdministrator().shutdown();
}
/**
+ * Blocks until the shutdown has completed, or the timeout occurs, or the current thread is interrupted, whichever happens
+ * first.
+ *
+ * @param timeout the maximum time to wait for each component in this engine
+ * @param unit the time unit of the timeout argument
+ * @return <tt>true</tt> if this service complete shut down and <tt>false</tt> if the timeout elapsed before it was shut down
+ * completely
+ * @throws InterruptedException if interrupted while waiting
+ */
+ public boolean awaitTermination( long timeout,
+ TimeUnit unit ) throws InterruptedException {
+ if (!sequencingService.getAdministrator().awaitTermination(timeout, unit)) return false;
+ if (!executorService.awaitTermination(timeout, unit)) return false;
+ if (!repositoryService.getAdministrator().awaitTermination(timeout, unit)) return false;
+ return true;
+ }
+
+ /**
* The component responsible for reading the configuration repository and (eventually) for propagating changes in the
* configuration repository into the services.
*/
Modified: trunk/dna-repository/src/main/java/org/jboss/dna/repository/RepositoryLibrary.java
===================================================================
--- trunk/dna-repository/src/main/java/org/jboss/dna/repository/RepositoryLibrary.java 2009-05-21 17:01:04 UTC (rev 919)
+++ trunk/dna-repository/src/main/java/org/jboss/dna/repository/RepositoryLibrary.java 2009-05-21 19:03:27 UTC (rev 920)
@@ -46,7 +46,6 @@
import org.jboss.dna.graph.observe.Changes;
import org.jboss.dna.graph.observe.Observable;
import org.jboss.dna.graph.observe.Observer;
-import org.jboss.dna.repository.mimetype.MimeTypeDetectors;
import org.jboss.dna.repository.service.AbstractServiceAdministrator;
import org.jboss.dna.repository.service.ServiceAdministrator;
@@ -106,7 +105,6 @@
}
- private final MimeTypeDetectors mimeTypeDetectors = new MimeTypeDetectors();
private final ServiceAdministrator administrator = new Administrator();
private final ReadWriteLock sourcesLock = new ReentrantReadWriteLock();
private final CopyOnWriteArrayList<RepositoryConnectionPool> pools = new CopyOnWriteArrayList<RepositoryConnectionPool>();
@@ -215,13 +213,6 @@
}
/**
- * @return mimeTypeDetectors
- */
- public MimeTypeDetectors getMimeTypeDetectors() {
- return mimeTypeDetectors;
- }
-
- /**
* Get the delegate connection factory.
*
* @return the connection factory to which this instance should delegate in the event that a source is not found in this
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-05-21 17:01:04 UTC (rev 919)
+++ trunk/dna-repository/src/main/java/org/jboss/dna/repository/RepositoryService.java 2009-05-21 19:03:27 UTC (rev 920)
@@ -156,6 +156,35 @@
}
/**
+ * Create a service instance, reading the configuration describing new {@link RepositorySource} instances from the supplied
+ * configuration repository.
+ *
+ * @param configurationSource the {@link RepositorySource} that is the configuration repository
+ * @param configurationWorkspaceName the name of the workspace in the {@link RepositorySource} that is the configuration
+ * repository, or null if the default workspace of the source should be used (if there is one)
+ * @param pathToConfigurationRoot the path of the node in the configuration source repository that should be treated by this
+ * service as the root of the service's configuration; if null, then "/dna:system" is used
+ * @param context the execution context in which this service should run
+ * @throws IllegalArgumentException if the bootstrap source is null or the execution context is null
+ */
+ public RepositoryService( RepositorySource configurationSource,
+ String configurationWorkspaceName,
+ Path pathToConfigurationRoot,
+ ExecutionContext context ) {
+ CheckArg.isNotNull(configurationSource, "configurationSource");
+ CheckArg.isNotNull(context, "context");
+ if (pathToConfigurationRoot == null) pathToConfigurationRoot = context.getValueFactories()
+ .getPathFactory()
+ .create("/dna:system");
+ this.sources = new RepositoryLibrary();
+ this.sources.addSource(configurationSource);
+ this.pathToConfigurationRoot = pathToConfigurationRoot;
+ this.configurationSourceName = configurationSource.getName();
+ this.configurationWorkspaceName = configurationWorkspaceName;
+ this.context = context;
+ }
+
+ /**
* {@inheritDoc}
*/
public ServiceAdministrator getAdministrator() {
@@ -177,9 +206,11 @@
}
/**
- * @return sources
+ * Get the library of {@link RepositorySource} instances used by this service.
+ *
+ * @return the RepositorySource library; never null
*/
- public RepositoryLibrary getRepositorySourceManager() {
+ public RepositoryLibrary getRepositoryLibrary() {
return sources;
}
Deleted: trunk/dna-repository/src/main/java/org/jboss/dna/repository/mimetype/MimeType.java
===================================================================
--- trunk/dna-repository/src/main/java/org/jboss/dna/repository/mimetype/MimeType.java 2009-05-21 17:01:04 UTC (rev 919)
+++ trunk/dna-repository/src/main/java/org/jboss/dna/repository/mimetype/MimeType.java 2009-05-21 19:03:27 UTC (rev 920)
@@ -1,86 +0,0 @@
-/*
- * JBoss DNA (http://www.jboss.org/dna)
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- * See the AUTHORS.txt file in the distribution for a full listing of
- * individual contributors.
- *
- * JBoss DNA is free software. Unless otherwise indicated, all code in JBoss DNA
- * is licensed to you under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * JBoss DNA is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.dna.repository.mimetype;
-
-import java.io.IOException;
-import java.io.InputStream;
-import org.jboss.dna.common.component.ClassLoaderFactory;
-
-/**
- * Convenience class for working with the default {@link MimeTypeDetectors MIME-type detectors}.
- *
- * @author jverhaeg
- */
-public final class MimeType {
-
- /**
- * The set of
- */
- public static final MimeTypeDetectors DEFAULT_DETECTORS = MimeTypeDetectors.DEFAULT_DETECTORS;
-
- /**
- * @param config See {@link MimeTypeDetectors#addDetector(MimeTypeDetectorConfig)}.
- * @return See {@link MimeTypeDetectors#addDetector(MimeTypeDetectorConfig)}.
- * @see MimeTypeDetectors#addDetector(MimeTypeDetectorConfig)
- */
- public static boolean addDetector( MimeTypeDetectorConfig config ) {
- return DEFAULT_DETECTORS.addDetector(config);
- }
-
- /**
- * @return See {@link MimeTypeDetectors#getClassLoaderFactory()}.
- * @see MimeTypeDetectors#getClassLoaderFactory()
- */
- public static ClassLoaderFactory getClassLoaderFactory() {
- return DEFAULT_DETECTORS.getClassLoaderFactory();
- }
-
- /**
- * @param name See {@link MimeTypeDetectors#mimeTypeOf(String, InputStream)}.
- * @param content See {@link MimeTypeDetectors#mimeTypeOf(String, InputStream)}.
- * @return See {@link MimeTypeDetectors#mimeTypeOf(String, InputStream)}.
- * @throws IOException See {@link MimeTypeDetectors#mimeTypeOf(String, InputStream)}.
- */
- public static String of( String name,
- InputStream content ) throws IOException {
- return DEFAULT_DETECTORS.mimeTypeOf(name, content);
- }
-
- /**
- * @param config See {@link MimeTypeDetectors#removeDetector(MimeTypeDetectorConfig)}.
- * @return See {@link MimeTypeDetectors#removeDetector(MimeTypeDetectorConfig)}.
- * @see MimeTypeDetectors#removeDetector(MimeTypeDetectorConfig)
- */
- public static boolean removeDetector( MimeTypeDetectorConfig config ) {
- return DEFAULT_DETECTORS.removeDetector(config);
- }
-
- /**
- * @param classLoaderFactory See {@link MimeTypeDetectors#setClassLoaderFactory(ClassLoaderFactory)}.
- * @see MimeTypeDetectors#setClassLoaderFactory(ClassLoaderFactory)
- */
- public static void setClassLoaderFactory( ClassLoaderFactory classLoaderFactory ) {
- DEFAULT_DETECTORS.setClassLoaderFactory(classLoaderFactory);
- }
-}
Modified: trunk/dna-repository/src/main/java/org/jboss/dna/repository/mimetype/MimeTypeDetectorConfig.java
===================================================================
--- trunk/dna-repository/src/main/java/org/jboss/dna/repository/mimetype/MimeTypeDetectorConfig.java 2009-05-21 17:01:04 UTC (rev 919)
+++ trunk/dna-repository/src/main/java/org/jboss/dna/repository/mimetype/MimeTypeDetectorConfig.java 2009-05-21 19:03:27 UTC (rev 920)
@@ -25,6 +25,7 @@
import java.util.Map;
import org.jboss.dna.common.component.ComponentConfig;
+import org.jboss.dna.graph.mimetype.MimeTypeDetector;
/**
* @author jverhaeg
@@ -32,10 +33,23 @@
public class MimeTypeDetectorConfig extends ComponentConfig {
public MimeTypeDetectorConfig( String name,
- String description,
- Map<String, Object> properties,
- String classname,
- String[] classpath ) {
+ String description,
+ Map<String, Object> properties,
+ String classname,
+ String[] classpath ) {
super(name, description, properties, classname, classpath);
}
+
+ public MimeTypeDetectorConfig( String name,
+ String description,
+ Map<String, Object> properties,
+ Class<? extends MimeTypeDetector> clazz ) {
+ super(name, description, properties, clazz.getName());
+ }
+
+ public MimeTypeDetectorConfig( String name,
+ String description,
+ Class<? extends MimeTypeDetector> clazz ) {
+ super(name, description, clazz.getName());
+ }
}
Modified: trunk/dna-repository/src/main/java/org/jboss/dna/repository/mimetype/MimeTypeDetectors.java
===================================================================
--- trunk/dna-repository/src/main/java/org/jboss/dna/repository/mimetype/MimeTypeDetectors.java 2009-05-21 17:01:04 UTC (rev 919)
+++ trunk/dna-repository/src/main/java/org/jboss/dna/repository/mimetype/MimeTypeDetectors.java 2009-05-21 19:03:27 UTC (rev 920)
@@ -41,8 +41,6 @@
@ThreadSafe
public final class MimeTypeDetectors implements MimeTypeDetector {
- public static final MimeTypeDetectors DEFAULT_DETECTORS = new MimeTypeDetectors();
-
/**
* Class loader factory instance that always returns the {@link Thread#getContextClassLoader() current thread's context class
* loader}, or if <code>null</code> the class loader for this class.
Modified: trunk/dna-repository/src/main/java/org/jboss/dna/repository/sequencer/StreamSequencerAdapter.java
===================================================================
--- trunk/dna-repository/src/main/java/org/jboss/dna/repository/sequencer/StreamSequencerAdapter.java 2009-05-21 17:01:04 UTC (rev 919)
+++ trunk/dna-repository/src/main/java/org/jboss/dna/repository/sequencer/StreamSequencerAdapter.java 2009-05-21 19:03:27 UTC (rev 920)
@@ -41,7 +41,6 @@
import org.jboss.dna.graph.sequencer.StreamSequencer;
import org.jboss.dna.graph.sequencer.StreamSequencerContext;
import org.jboss.dna.repository.RepositoryI18n;
-import org.jboss.dna.repository.mimetype.MimeType;
import org.jboss.dna.repository.observation.NodeChange;
import org.jboss.dna.repository.util.RepositoryNodePath;
@@ -234,21 +233,19 @@
assert sequencedProperty != null;
assert context != null;
assert problems != null;
- // Note: getMimeType() will still operate lazily, and thus throw a SequencerException, since it is very intrusive and
- // potentially slow-running.
ValueFactories factories = context.getExecutionContext().getValueFactories();
- // TODO: Is this safe?
Path path = factories.getPathFactory().create(input.getLocation().getPath());
Set<org.jboss.dna.graph.property.Property> props = new HashSet<org.jboss.dna.graph.property.Property>(
input.getPropertiesByName()
.values());
props = Collections.unmodifiableSet(props);
- String mimeType = getMimeType(sequencedProperty, path.getLastSegment().getName().getLocalName());
+ String mimeType = getMimeType(context, sequencedProperty, path.getLastSegment().getName().getLocalName());
return new StreamSequencerContext(context.getExecutionContext(), path, props, mimeType, problems);
}
- protected String getMimeType( Property sequencedProperty,
+ protected String getMimeType( SequencerContext context,
+ Property sequencedProperty,
String name ) {
SequencerException err = null;
String mimeType = null;
@@ -256,7 +253,7 @@
try {
// Parallel the JCR lemma for converting objects into streams
stream = new ByteArrayInputStream(sequencedProperty.toString().getBytes());
- mimeType = MimeType.of(name, stream);
+ mimeType = context.getExecutionContext().getMimeTypeDetector().mimeTypeOf(name, stream);
return mimeType;
} catch (Exception error) {
err = new SequencerException(error);
Modified: trunk/dna-repository/src/test/java/org/jboss/dna/repository/DnaEngineTest.java
===================================================================
--- trunk/dna-repository/src/test/java/org/jboss/dna/repository/DnaEngineTest.java 2009-05-21 17:01:04 UTC (rev 919)
+++ trunk/dna-repository/src/test/java/org/jboss/dna/repository/DnaEngineTest.java 2009-05-21 19:03:27 UTC (rev 920)
@@ -37,7 +37,6 @@
import org.jboss.dna.graph.connector.RepositoryConnection;
import org.jboss.dna.graph.connector.inmemory.InMemoryRepositorySource;
import org.jboss.dna.graph.mimetype.MimeTypeDetector;
-import org.jboss.dna.repository.mimetype.MimeTypeDetectors;
import org.jboss.dna.repository.observation.NodeChanges;
import org.jboss.dna.repository.sequencer.MockSequencerA;
import org.jboss.dna.repository.sequencer.SequencingService;
@@ -74,7 +73,7 @@
assertThat(engine.getRepositorySource("config repo"), is(notNullValue()));
assertThat(engine.getRepositorySource("config repo"), is(instanceOf(InMemoryRepositorySource.class)));
- RepositoryLibrary library = engine.getRepositoryService().getRepositorySourceManager();
+ RepositoryLibrary library = engine.getRepositoryService().getRepositoryLibrary();
assertThat(library.getConnectionPool("config repo").getInUseCount(), is(0));
RepositoryConnection connection = library.getConnectionPool("config repo").getConnection();
@@ -109,7 +108,7 @@
assertThat(engine.getRepositorySource("JCR"), is(instanceOf(InMemoryRepositorySource.class)));
assertThat(engine.getRepositorySource("JCR").getName(), is("JCR"));
- RepositoryLibrary library = engine.getRepositoryService().getRepositorySourceManager();
+ RepositoryLibrary library = engine.getRepositoryService().getRepositoryLibrary();
RepositoryConnection connection = library.getConnectionPool("JCR").getConnection();
assertThat(connection.ping(500, TimeUnit.MILLISECONDS), is(true));
connection.close();
@@ -135,10 +134,8 @@
assertThat(engine.getRepositorySource("config repo"), is(notNullValue()));
assertThat(engine.getRepositorySource("config repo"), is(instanceOf(InMemoryRepositorySource.class)));
- RepositoryLibrary library = engine.getRepositoryService().getRepositorySourceManager();
- MimeTypeDetectors detectors = library.getMimeTypeDetectors();
-
- assertThat(detectors.mimeTypeOf("test", new ByteArrayInputStream("This is useless data".getBytes())), is("mock"));
+ MimeTypeDetector detector = engine.getExecutionContext().getMimeTypeDetector();
+ assertThat(detector.mimeTypeOf("test", new ByteArrayInputStream("This is useless data".getBytes())), is("mock"));
}
@Test
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-05-21 17:01:04 UTC (rev 919)
+++ trunk/dna-repository/src/test/java/org/jboss/dna/repository/RepositoryServiceTest.java 2009-05-21 19:03:27 UTC (rev 920)
@@ -282,7 +282,7 @@
service.getAdministrator().start();
// Get the source, which should be configured ...
- RepositorySource repositorySourceA = service.getRepositorySourceManager().getSource("source A");
+ RepositorySource repositorySourceA = service.getRepositoryLibrary().getSource("source A");
assertThat(repositorySourceA, is(instanceOf(FakeRepositorySource.class)));
FakeRepositorySource sourceA = (FakeRepositorySource)repositorySourceA;
Modified: trunk/dna-repository/src/test/java/org/jboss/dna/repository/mimetype/AbstractMimeTypeTest.java
===================================================================
--- trunk/dna-repository/src/test/java/org/jboss/dna/repository/mimetype/AbstractMimeTypeTest.java 2009-05-21 17:01:04 UTC (rev 919)
+++ trunk/dna-repository/src/test/java/org/jboss/dna/repository/mimetype/AbstractMimeTypeTest.java 2009-05-21 19:03:27 UTC (rev 920)
@@ -43,26 +43,29 @@
public abstract class AbstractMimeTypeTest {
private final MimeTypeDetectorConfig config;
+ private MimeTypeDetectors detectors;
protected AbstractMimeTypeTest( Class<? extends MimeTypeDetector> detector ) {
assertThat(detector, notNullValue());
- this.config = new MimeTypeDetectorConfig("MIME-Type Detector", "MIME-Type Detector", Collections.<String, Object>emptyMap(), detector.getName(), null);
+ this.config = new MimeTypeDetectorConfig("MIME-Type Detector", "MIME-Type Detector",
+ Collections.<String, Object>emptyMap(), detector.getName(), null);
}
@Before
public void before() throws Exception {
- MimeType.addDetector(config);
+ detectors = new MimeTypeDetectors();
+ detectors.addDetector(config);
}
@After
public void after() {
- MimeType.removeDetector(config);
+ detectors.removeDetector(config);
}
protected void testMimeType( String name,
String mimeType ) throws Exception {
InputStream content = new File("../../dna-repository/src/test/resources/" + name).toURI().toURL().openStream();
- assertThat(MimeType.of(name, content), is(mimeType));
+ assertThat(detectors.mimeTypeOf(name, content), is(mimeType));
}
protected abstract String expectedMimeTypeForText_test_txt();
Deleted: trunk/dna-repository/src/test/java/org/jboss/dna/repository/mimetype/MimeTypeTest.java
===================================================================
--- trunk/dna-repository/src/test/java/org/jboss/dna/repository/mimetype/MimeTypeTest.java 2009-05-21 17:01:04 UTC (rev 919)
+++ trunk/dna-repository/src/test/java/org/jboss/dna/repository/mimetype/MimeTypeTest.java 2009-05-21 19:03:27 UTC (rev 920)
@@ -1,52 +0,0 @@
-/*
- * JBoss DNA (http://www.jboss.org/dna)
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- * See the AUTHORS.txt file in the distribution for a full listing of
- * individual contributors.
- *
- * JBoss DNA is free software. Unless otherwise indicated, all code in JBoss DNA
- * is licensed to you under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * JBoss DNA is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.dna.repository.mimetype;
-
-import static org.hamcrest.core.Is.is;
-import static org.junit.Assert.assertThat;
-import java.io.File;
-import java.io.InputStream;
-import org.junit.Test;
-
-/**
- * @author John Verhaeg
- */
-public class MimeTypeTest {
-
- private final void testMimeType( String name,
- String mimeType ) throws Exception {
- InputStream content = new File("src/test/resources/" + name).toURI().toURL().openStream();
- assertThat(MimeType.of(name, content), is(mimeType));
- }
-
- @Test
- public void shouldProvideDefaultTextMimeTypeWhenNoDetectorsRegisteredAndNoNullsInContent() throws Exception {
- testMimeType("test.txt", "text/plain");
- }
-
- @Test
- public void shouldProvideDefaultBinaryMimeTypeWhenNoDetectorsRegisteredAndNoNullsInContent() throws Exception {
- testMimeType("docs/plain-text-utf16be.txt", "application/octet-stream");
- }
-}
Modified: trunk/dna-repository/src/test/java/org/jboss/dna/repository/sequencer/StreamSequencerAdapterTest.java
===================================================================
--- trunk/dna-repository/src/test/java/org/jboss/dna/repository/sequencer/StreamSequencerAdapterTest.java 2009-05-21 17:01:04 UTC (rev 919)
+++ trunk/dna-repository/src/test/java/org/jboss/dna/repository/sequencer/StreamSequencerAdapterTest.java 2009-05-21 19:03:27 UTC (rev 920)
@@ -50,6 +50,7 @@
import org.jboss.dna.graph.sequencer.SequencerOutput;
import org.jboss.dna.graph.sequencer.StreamSequencer;
import org.jboss.dna.graph.sequencer.StreamSequencerContext;
+import org.jboss.dna.repository.mimetype.MimeTypeDetectors;
import org.jboss.dna.repository.observation.NodeChange;
import org.jboss.dna.repository.util.RepositoryNodePath;
import org.junit.Before;
@@ -79,7 +80,8 @@
@Before
public void beforeEach() {
problems = new SimpleProblems();
- this.context = new ExecutionContext();
+ // Set up the MIME type detectors ...
+ this.context = new ExecutionContext().with(new MimeTypeDetectors());
this.sequencerOutput = new SequencerOutputMap(this.context.getValueFactories());
final SequencerOutputMap finalOutput = sequencerOutput;
@@ -277,8 +279,7 @@
try {
graph.getNodeAt("/d");
fail();
- }
- catch(PathNotFoundException pnfe) {
+ } catch (PathNotFoundException pnfe) {
// Expected
}
assertThat(nodeC, is(notNullValue()));
@@ -314,15 +315,13 @@
try {
graph.getNodeAt("/d");
fail();
- }
- catch(PathNotFoundException pnfe) {
+ } catch (PathNotFoundException pnfe) {
// Expected
}
try {
graph.getNodeAt("/x");
fail();
- }
- catch(PathNotFoundException pnfe) {
+ } catch (PathNotFoundException pnfe) {
// Expected
}
assertThat(nodeC, is(notNullValue()));
@@ -479,13 +478,15 @@
@Test
public void shouldProvideInputProperties() throws Exception {
-
this.sequencedProperty = mock(Property.class);
graph.create("/a").and().create("/a/b").and().create("/a/b/c");
graph.set("x").on("/a/b/c").to(true);
graph.set("y").on("/a/b/c").to(Arrays.asList(new String[] {"asdf", "xyzzy"}));
Node input = graph.getNodeAt("/a/b/c");
- StreamSequencerContext sequencerContext = sequencer.createStreamSequencerContext(input, sequencedProperty, seqContext, problems);
+ StreamSequencerContext sequencerContext = sequencer.createStreamSequencerContext(input,
+ sequencedProperty,
+ seqContext,
+ problems);
assertThat(sequencerContext.getInputProperties(), notNullValue());
assertThat(sequencerContext.getInputProperties().isEmpty(), is(false));
assertThat(sequencerContext.getInputProperties().size(), is(3));
15 years, 1 month
DNA SVN: r919 - in trunk/dna-repository/src/main/java/org/jboss/dna/repository: sequencer and 1 other directory.
by dna-commits@lists.jboss.org
Author: rhauch
Date: 2009-05-21 13:01:04 -0400 (Thu, 21 May 2009)
New Revision: 919
Modified:
trunk/dna-repository/src/main/java/org/jboss/dna/repository/RepositoryService.java
trunk/dna-repository/src/main/java/org/jboss/dna/repository/sequencer/StreamSequencerAdapter.java
Log:
DNA-401 Remove SequencingService Dependency on JCR
Minor corrections to remove warnings and JavaDoc compiler errors.
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-05-21 16:44:53 UTC (rev 918)
+++ trunk/dna-repository/src/main/java/org/jboss/dna/repository/RepositoryService.java 2009-05-21 17:01:04 UTC (rev 919)
@@ -251,6 +251,7 @@
if (problems.hasErrors()) return null;
// Create the instance ...
+ assert classnameProperty != null;
String classname = stringFactory.create(classnameProperty.getValues().next());
String[] classpath = classpathProperty == null ? new String[] {} : stringFactory.create(classpathProperty.getValuesAsArray());
ClassLoader classLoader = context.getClassLoader(classpath);
@@ -265,6 +266,7 @@
} catch (Throwable err) {
problems.addError(err, RepositoryI18n.unableToInstantiateClassUsingClasspath, classname, classpath);
}
+ if (source == null) return null;
// We need to set the name using the local name of the node...
Property nameProperty = context.getPropertyFactory().create(JcrLexicon.NAME,
Modified: trunk/dna-repository/src/main/java/org/jboss/dna/repository/sequencer/StreamSequencerAdapter.java
===================================================================
--- trunk/dna-repository/src/main/java/org/jboss/dna/repository/sequencer/StreamSequencerAdapter.java 2009-05-21 16:44:53 UTC (rev 918)
+++ trunk/dna-repository/src/main/java/org/jboss/dna/repository/sequencer/StreamSequencerAdapter.java 2009-05-21 17:01:04 UTC (rev 919)
@@ -164,7 +164,7 @@
/**
* Creates all nodes along the given node path if they are missing. Ensures that nodePath is a valid path to a node.
*
- * @param nodePath the node path to create
+ * @param targetPath the node path to create
* @param context the sequencer context under which it should be created
*/
private void buildPathTo( Path targetPath,
@@ -241,7 +241,8 @@
Path path = factories.getPathFactory().create(input.getLocation().getPath());
Set<org.jboss.dna.graph.property.Property> props = new HashSet<org.jboss.dna.graph.property.Property>(
- input.getPropertiesByName().values());
+ input.getPropertiesByName()
+ .values());
props = Collections.unmodifiableSet(props);
String mimeType = getMimeType(sequencedProperty, path.getLastSegment().getName().getLocalName());
return new StreamSequencerContext(context.getExecutionContext(), path, props, mimeType, problems);
15 years, 1 month
DNA SVN: r918 - in trunk: dna-graph/src/main/java/org/jboss/dna/graph/request/processor and 4 other directories.
by dna-commits@lists.jboss.org
Author: rhauch
Date: 2009-05-21 12:44:53 -0400 (Thu, 21 May 2009)
New Revision: 918
Modified:
trunk/dna-graph/src/main/java/org/jboss/dna/graph/connector/inmemory/InMemoryRequestProcessor.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/MockRepositoryRequestProcessor.java
trunk/extensions/dna-connector-filesystem/src/main/java/org/jboss/dna/connector/filesystem/FileSystemRequestProcessor.java
trunk/extensions/dna-connector-jbosscache/src/main/java/org/jboss/dna/connector/jbosscache/JBossCacheRequestProcessor.java
trunk/extensions/dna-connector-store-jpa/src/main/java/org/jboss/dna/connector/store/jpa/model/basic/BasicRequestProcessor.java
Log:
DNA-252 Complete support for events to the connector framework
Changed the name of the method in RequestProcessor to record an event, hopefully making it a little easier to understand what it is doing when reading the code.
Modified: trunk/dna-graph/src/main/java/org/jboss/dna/graph/connector/inmemory/InMemoryRequestProcessor.java
===================================================================
--- trunk/dna-graph/src/main/java/org/jboss/dna/graph/connector/inmemory/InMemoryRequestProcessor.java 2009-05-21 16:44:06 UTC (rev 917)
+++ trunk/dna-graph/src/main/java/org/jboss/dna/graph/connector/inmemory/InMemoryRequestProcessor.java 2009-05-21 16:44:53 UTC (rev 918)
@@ -135,7 +135,7 @@
Location oldLocation = getActualLocation(request.from().getPath(), node);
Location newLocation = Location.create(newPath, newNode.getUuid());
request.setActualLocations(oldLocation, newLocation);
- record(request);
+ recordChange(request);
}
@Override
@@ -197,7 +197,7 @@
}
Location actualLocation = getActualLocation(path, node);
request.setActualLocationOfNode(actualLocation);
- record(request);
+ recordChange(request);
}
@Override
@@ -209,7 +209,7 @@
workspace.removeNode(getExecutionContext(), node);
Location actualLocation = getActualLocation(request.at().getPath(), node);
request.setActualLocationOfNode(actualLocation);
- record(request);
+ recordChange(request);
}
@Override
@@ -228,7 +228,7 @@
Location oldLocation = getActualLocation(request.from().getPath(), node);
Location newLocation = Location.create(newPath, newParent.getUuid());
request.setActualLocations(oldLocation, newLocation);
- record(request);
+ recordChange(request);
}
@Override
@@ -250,7 +250,7 @@
}
Location actualLocation = getActualLocation(request.on().getPath(), node);
request.setActualLocationOfNode(actualLocation);
- record(request);
+ recordChange(request);
}
/**
@@ -271,7 +271,7 @@
InMemoryNode root = workspace.getRoot();
request.setActualRootLocation(Location.create(pathFactory.createRootPath(), root.getUuid()));
request.setActualWorkspaceName(workspace.getName());
- record(request);
+ recordChange(request);
}
}
@@ -286,7 +286,7 @@
if (workspace != null) {
InMemoryNode root = workspace.getRoot();
request.setActualRootLocation(Location.create(pathFactory.createRootPath(), root.getUuid()));
- record(request);
+ recordChange(request);
} else {
String msg = GraphI18n.workspaceDoesNotExistInRepository.text(request.workspaceName(), repository.getSourceName());
request.setError(new InvalidWorkspaceException(msg));
@@ -367,7 +367,7 @@
InMemoryNode root = target.getRoot();
request.setActualRootLocation(Location.create(pathFactory.createRootPath(), root.getUuid()));
request.setActualWorkspaceName(target.getName());
- record(request);
+ recordChange(request);
}
}
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-05-21 16:44:06 UTC (rev 917)
+++ trunk/dna-graph/src/main/java/org/jboss/dna/graph/request/processor/RequestProcessor.java 2009-05-21 16:44:53 UTC (rev 918)
@@ -121,7 +121,7 @@
*
* @param request the completed change request; may not be null
*/
- protected void record( ChangeRequest request ) {
+ protected void recordChange( ChangeRequest request ) {
assert request != null;
assert !request.isCancelled();
assert !request.hasError();
Modified: trunk/dna-graph/src/test/java/org/jboss/dna/graph/connector/MockRepositoryRequestProcessor.java
===================================================================
--- trunk/dna-graph/src/test/java/org/jboss/dna/graph/connector/MockRepositoryRequestProcessor.java 2009-05-21 16:44:06 UTC (rev 917)
+++ trunk/dna-graph/src/test/java/org/jboss/dna/graph/connector/MockRepositoryRequestProcessor.java 2009-05-21 16:44:53 UTC (rev 918)
@@ -100,7 +100,7 @@
*/
@Override
public void process( CreateWorkspaceRequest request ) {
- record(request);
+ recordChange(request);
}
/**
@@ -110,7 +110,7 @@
*/
@Override
public void process( CloneWorkspaceRequest request ) {
- record(request);
+ recordChange(request);
}
/**
@@ -120,7 +120,7 @@
*/
@Override
public void process( DestroyWorkspaceRequest request ) {
- record(request);
+ recordChange(request);
}
/**
@@ -130,7 +130,7 @@
*/
@Override
public void process( CopyBranchRequest request ) {
- record(request);
+ recordChange(request);
}
/**
@@ -140,7 +140,7 @@
*/
@Override
public void process( CreateNodeRequest request ) {
- record(request);
+ recordChange(request);
}
/**
@@ -150,7 +150,7 @@
*/
@Override
public void process( DeleteBranchRequest request ) {
- record(request);
+ recordChange(request);
}
/**
@@ -160,7 +160,7 @@
*/
@Override
public void process( MoveBranchRequest request ) {
- record(request);
+ recordChange(request);
}
/**
@@ -190,7 +190,7 @@
*/
@Override
public void process( UpdatePropertiesRequest request ) {
- record(request);
+ recordChange(request);
}
/**
@@ -250,7 +250,7 @@
*/
@Override
public void process( RemovePropertyRequest request ) {
- record(request);
+ recordChange(request);
}
/**
@@ -260,7 +260,7 @@
*/
@Override
public void process( RenameNodeRequest request ) {
- record(request);
+ recordChange(request);
}
/**
@@ -270,7 +270,7 @@
*/
@Override
public void process( SetPropertyRequest request ) {
- record(request);
+ recordChange(request);
}
/**
Modified: trunk/extensions/dna-connector-filesystem/src/main/java/org/jboss/dna/connector/filesystem/FileSystemRequestProcessor.java
===================================================================
--- trunk/extensions/dna-connector-filesystem/src/main/java/org/jboss/dna/connector/filesystem/FileSystemRequestProcessor.java 2009-05-21 16:44:06 UTC (rev 917)
+++ trunk/extensions/dna-connector-filesystem/src/main/java/org/jboss/dna/connector/filesystem/FileSystemRequestProcessor.java 2009-05-21 16:44:53 UTC (rev 918)
@@ -414,7 +414,7 @@
request.setActualWorkspaceName(getCanonicalWorkspaceName(directory));
request.setActualRootLocation(Location.create(pathFactory().createRootPath()));
availableWorkspaceNames.add(workspaceName);
- record(request);
+ recordChange(request);
} else {
request.setError(new InvalidWorkspaceException(FileSystemI18n.workspaceDoesNotExist.text(workspaceName)));
}
@@ -437,7 +437,7 @@
request.setError(new InvalidWorkspaceException(FileSystemI18n.workspaceDoesNotExist.text(workspaceName)));
} else {
request.setActualRootLocation(Location.create(pathFactory().createRootPath()));
- record(request);
+ recordChange(request);
}
}
Modified: trunk/extensions/dna-connector-jbosscache/src/main/java/org/jboss/dna/connector/jbosscache/JBossCacheRequestProcessor.java
===================================================================
--- trunk/extensions/dna-connector-jbosscache/src/main/java/org/jboss/dna/connector/jbosscache/JBossCacheRequestProcessor.java 2009-05-21 16:44:06 UTC (rev 917)
+++ trunk/extensions/dna-connector-jbosscache/src/main/java/org/jboss/dna/connector/jbosscache/JBossCacheRequestProcessor.java 2009-05-21 16:44:53 UTC (rev 918)
@@ -183,7 +183,7 @@
}
Path nodePath = pathFactory.create(parent, newSegment);
request.setActualLocationOfNode(Location.create(nodePath));
- record(request);
+ recordChange(request);
}
@Override
@@ -215,7 +215,7 @@
node.put(propName, value);
}
request.setActualLocationOfNode(Location.create(nodePath));
- record(request);
+ recordChange(request);
}
@Override
@@ -252,7 +252,7 @@
Path newPath = pathFactory.create(newParentPath, newSegment);
request.setActualLocations(Location.create(nodePath), Location.create(newPath));
- record(request);
+ recordChange(request);
}
@Override
@@ -269,7 +269,7 @@
if (cache.removeNode(node.getFqn())) {
removeFromChildList(cache, parent, nameOfRemovedNode, getExecutionContext());
request.setActualLocationOfNode(Location.create(nodePath));
- record(request);
+ recordChange(request);
} else {
String msg = JBossCacheConnectorI18n.unableToDeleteBranch.text(getSourceName(), request.inWorkspace(), nodePath);
request.setError(new RepositorySourceException(msg));
@@ -303,7 +303,7 @@
Path newPath = pathFactory.create(newParentPath, newSegment);
request.setActualLocations(Location.create(nodePath), Location.create(newPath));
- record(request);
+ recordChange(request);
}
/**
@@ -371,7 +371,7 @@
}
request.setActualRootLocation(Location.create(pathFactory.createRootPath()));
request.setActualWorkspaceName(workspaceName);
- record(request);
+ recordChange(request);
}
/**
@@ -421,7 +421,7 @@
// Copy the list of child segments in the root (this maintains the order of the children) ...
Path.Segment[] childNames = (Path.Segment[])fromRoot.get(JBossCacheLexicon.CHILD_PATH_SEGMENT_LIST);
intoRoot.put(JBossCacheLexicon.CHILD_PATH_SEGMENT_LIST, childNames);
- record(request);
+ recordChange(request);
}
/**
@@ -438,7 +438,7 @@
return;
}
request.setActualRootLocation(Location.create(pathFactory.createRootPath()));
- record(request);
+ recordChange(request);
}
// ----------------------------------------------------------------------------------------------------------------
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-05-21 16:44:06 UTC (rev 917)
+++ trunk/extensions/dna-connector-store-jpa/src/main/java/org/jboss/dna/connector/store/jpa/model/basic/BasicRequestProcessor.java 2009-05-21 16:44:53 UTC (rev 918)
@@ -952,7 +952,7 @@
return;
}
if (actualLocation != null) request.setActualLocationOfNode(actualLocation);
- record(request);
+ recordChange(request);
}
/**
@@ -1238,7 +1238,7 @@
return;
}
request.setActualLocations(actualFromLocation, actualToLocation);
- record(request);
+ recordChange(request);
}
/**
@@ -1252,7 +1252,7 @@
Location location = delete(request, request.at(), request.inWorkspace(), true);
if (location != null) {
request.setActualLocationOfNode(location);
- record(request);
+ recordChange(request);
}
}
@@ -1267,7 +1267,7 @@
Location location = delete(request, request.at(), request.inWorkspace(), false);
if (location != null) {
request.setActualLocationOfNode(location);
- record(request);
+ recordChange(request);
}
}
@@ -1484,7 +1484,7 @@
return;
}
request.setActualLocations(actualOldLocation, actualNewLocation);
- record(request);
+ recordChange(request);
}
/**
@@ -1557,7 +1557,7 @@
// Create the root node ...
Location root = Location.create(pathFactory.createRootPath());
request.setActualRootLocation(getActualLocation(entity.getId(), root).location);
- record(request);
+ recordChange(request);
}
/**
@@ -1657,7 +1657,7 @@
// Finish up the request ...
Location root = Location.create(pathFactory.createRootPath(), rootNodeUuid);
request.setActualRootLocation(getActualLocation(intoWorkspace.getId(), root).location);
- record(request);
+ recordChange(request);
}
/**
@@ -1697,7 +1697,7 @@
// Finish the request ...
request.setActualRootLocation(actual.location);
- record(request);
+ recordChange(request);
}
/**
15 years, 1 month
DNA SVN: r917 - in trunk: dna-graph/src/main/java/org/jboss/dna/graph/connector/inmemory and 16 other directories.
by dna-commits@lists.jboss.org
Author: rhauch
Date: 2009-05-21 12:44:06 -0400 (Thu, 21 May 2009)
New Revision: 917
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/FederatedRepositorySource.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/JoinMirrorRequestProcessor.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/inmemory/InMemoryRepositoryConnection.java
trunk/dna-graph/src/main/java/org/jboss/dna/graph/connector/inmemory/InMemoryRequestProcessor.java
trunk/dna-graph/src/main/java/org/jboss/dna/graph/observe/Changes.java
trunk/dna-graph/src/main/java/org/jboss/dna/graph/request/CloneWorkspaceRequest.java
trunk/dna-graph/src/main/java/org/jboss/dna/graph/request/CreateWorkspaceRequest.java
trunk/dna-graph/src/main/java/org/jboss/dna/graph/request/DestroyWorkspaceRequest.java
trunk/dna-graph/src/main/java/org/jboss/dna/graph/request/processor/LoggingRequestProcessor.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/GraphTest.java
trunk/dna-graph/src/test/java/org/jboss/dna/graph/connector/MockRepositoryRequestProcessor.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/JoinRequestProcessorTest.java
trunk/extensions/dna-connector-federation/src/main/java/org/jboss/dna/connector/federation/FederatingRequestProcessor.java
trunk/extensions/dna-connector-filesystem/src/main/java/org/jboss/dna/connector/filesystem/FileSystemRequestProcessor.java
trunk/extensions/dna-connector-jbosscache/src/main/java/org/jboss/dna/connector/jbosscache/JBossCacheConnection.java
trunk/extensions/dna-connector-jbosscache/src/main/java/org/jboss/dna/connector/jbosscache/JBossCacheRequestProcessor.java
trunk/extensions/dna-connector-jbosscache/src/main/java/org/jboss/dna/connector/jbosscache/JBossCacheSource.java
trunk/extensions/dna-connector-jbosscache/src/test/java/org/jboss/dna/connector/jbosscache/JBossCacheRequestProcessorTest.java
trunk/extensions/dna-connector-jdbc-metadata/src/main/java/org/jboss/dna/connector/jdbc/JdbcRequestProcesor.java
trunk/extensions/dna-connector-store-jpa/src/main/java/org/jboss/dna/connector/store/jpa/JpaConnection.java
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.java
trunk/extensions/dna-connector-store-jpa/src/main/java/org/jboss/dna/connector/store/jpa/model/basic/BasicModel.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/test/java/org/jboss/dna/connector/store/jpa/ModelTest.java
trunk/extensions/dna-connector-store-jpa/src/test/java/org/jboss/dna/connector/store/jpa/model/basic/BasicModelTest.java
trunk/extensions/dna-connector-svn/src/main/java/org/jboss/dna/connector/svn/SVNRepositoryRequestProcessor.java
Log:
DNA-252 Complete support for events to the connector framework
Changed the connectors to publish their change requests as events, if the RepositoryContext provides an Observer reference.
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-05-20 21:38:18 UTC (rev 916)
+++ trunk/dna-graph/src/main/java/org/jboss/dna/graph/connector/federation/FederatedRepositoryConnection.java 2009-05-21 16:44:06 UTC (rev 917)
@@ -37,6 +37,7 @@
import org.jboss.dna.graph.cache.CachePolicy;
import org.jboss.dna.graph.connector.RepositoryConnection;
import org.jboss.dna.graph.connector.RepositorySourceException;
+import org.jboss.dna.graph.observe.Observer;
import org.jboss.dna.graph.property.DateTime;
import org.jboss.dna.graph.request.CompositeRequest;
import org.jboss.dna.graph.request.Request;
@@ -76,11 +77,14 @@
private final FederatedRepository repository;
private final Stopwatch stopwatch;
private final Logger logger;
+ private final Observer observer;
- FederatedRepositoryConnection( FederatedRepository repository ) {
+ FederatedRepositoryConnection( FederatedRepository repository,
+ Observer observer ) {
this.repository = repository;
this.logger = Logger.getLogger(getClass());
this.stopwatch = logger.isTraceEnabled() ? new Stopwatch() : null;
+ this.observer = observer;
}
/**
@@ -208,7 +212,7 @@
// ----------------------------------------------------------------------------------------------------
// Step 2: Join the results of the source-specific (forked) requests back into the submitted requests
// ----------------------------------------------------------------------------------------------------
- JoinRequestProcessor join = new JoinRequestProcessor(repository, context, nowInUtc);
+ JoinRequestProcessor join = new JoinRequestProcessor(repository, context, observer, nowInUtc);
try {
if (awaitAllSubtasks) {
join.process(requests);
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-05-20 21:38:18 UTC (rev 916)
+++ trunk/dna-graph/src/main/java/org/jboss/dna/graph/connector/federation/FederatedRepositorySource.java 2009-05-21 16:44:06 UTC (rev 917)
@@ -57,6 +57,7 @@
import org.jboss.dna.graph.connector.RepositorySource;
import org.jboss.dna.graph.connector.RepositorySourceCapabilities;
import org.jboss.dna.graph.connector.RepositorySourceException;
+import org.jboss.dna.graph.observe.Observer;
import org.jboss.dna.graph.property.NamespaceRegistry;
import org.jboss.dna.graph.property.Path;
import org.jboss.dna.graph.property.Property;
@@ -309,7 +310,8 @@
config = this.configuration;
}
}
- return new FederatedRepositoryConnection(config);
+ Observer observer = this.context != null ? this.context.getObserver() : null;
+ return new FederatedRepositoryConnection(config, observer);
}
/**
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-05-20 21:38:18 UTC (rev 916)
+++ trunk/dna-graph/src/main/java/org/jboss/dna/graph/connector/federation/ForkRequestProcessor.java 2009-05-21 16:44:06 UTC (rev 917)
@@ -497,7 +497,7 @@
ExecutionContext context,
DateTime now,
Queue<FederatedRequest> federatedRequestQueue ) {
- super(repository.getSourceName(), context, now);
+ super(repository.getSourceName(), context, null, now);
this.repository = repository;
this.executor = this.repository.getExecutor();
this.connectionFactory = this.repository.getConnectionFactory();
Modified: trunk/dna-graph/src/main/java/org/jboss/dna/graph/connector/federation/JoinMirrorRequestProcessor.java
===================================================================
--- trunk/dna-graph/src/main/java/org/jboss/dna/graph/connector/federation/JoinMirrorRequestProcessor.java 2009-05-20 21:38:18 UTC (rev 916)
+++ trunk/dna-graph/src/main/java/org/jboss/dna/graph/connector/federation/JoinMirrorRequestProcessor.java 2009-05-21 16:44:06 UTC (rev 917)
@@ -28,6 +28,7 @@
import org.jboss.dna.graph.ExecutionContext;
import org.jboss.dna.graph.Location;
import org.jboss.dna.graph.cache.CachePolicy;
+import org.jboss.dna.graph.observe.Observer;
import org.jboss.dna.graph.property.DateTime;
import org.jboss.dna.graph.property.Name;
import org.jboss.dna.graph.property.Property;
@@ -67,9 +68,10 @@
JoinMirrorRequestProcessor( String sourceName,
ExecutionContext context,
+ Observer observer,
DateTime now,
CachePolicy defaultCachePolicy ) {
- super(sourceName, context, now, defaultCachePolicy);
+ super(sourceName, context, observer, now, defaultCachePolicy);
}
@@ -171,7 +173,8 @@
*/
@Override
public void process( ReadNextBlockOfChildrenRequest request ) {
- ReadNextBlockOfChildrenRequest source = (ReadNextBlockOfChildrenRequest)federatedRequest.getFirstProjectedRequest().getRequest();
+ ReadNextBlockOfChildrenRequest source = (ReadNextBlockOfChildrenRequest)federatedRequest.getFirstProjectedRequest()
+ .getRequest();
if (checkErrorOrCancel(request, source)) return;
request.setActualLocationOfStartingAfterNode(source.getActualLocationOfStartingAfterNode());
for (Location childInSource : source.getChildren()) {
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-05-20 21:38:18 UTC (rev 916)
+++ trunk/dna-graph/src/main/java/org/jboss/dna/graph/connector/federation/JoinRequestProcessor.java 2009-05-21 16:44:06 UTC (rev 917)
@@ -35,6 +35,7 @@
import org.jboss.dna.graph.GraphI18n;
import org.jboss.dna.graph.Location;
import org.jboss.dna.graph.connector.federation.FederatedRequest.ProjectedRequest;
+import org.jboss.dna.graph.observe.Observer;
import org.jboss.dna.graph.property.DateTime;
import org.jboss.dna.graph.property.Name;
import org.jboss.dna.graph.property.Path;
@@ -81,16 +82,18 @@
*
* @param repository the federated repository configuration; never null
* @param context the execution context in which this processor is executing; may not be null
+ * @param observer the observer for change events; may be null
* @param now the timestamp representing the current time in UTC; may not be null
*/
public JoinRequestProcessor( FederatedRepository repository,
ExecutionContext context,
+ Observer observer,
DateTime now ) {
- super(repository.getSourceName(), context, now, repository.getDefaultCachePolicy());
+ super(repository.getSourceName(), context, observer, now, repository.getDefaultCachePolicy());
// this.repository = repository;
this.propertyFactory = context.getPropertyFactory();
this.pathFactory = context.getValueFactories().getPathFactory();
- this.mirrorProcessor = new JoinMirrorRequestProcessor(repository.getSourceName(), context, now,
+ this.mirrorProcessor = new JoinMirrorRequestProcessor(repository.getSourceName(), context, observer, now,
repository.getDefaultCachePolicy());
}
Modified: trunk/dna-graph/src/main/java/org/jboss/dna/graph/connector/inmemory/InMemoryRepositoryConnection.java
===================================================================
--- trunk/dna-graph/src/main/java/org/jboss/dna/graph/connector/inmemory/InMemoryRepositoryConnection.java 2009-05-20 21:38:18 UTC (rev 916)
+++ trunk/dna-graph/src/main/java/org/jboss/dna/graph/connector/inmemory/InMemoryRepositoryConnection.java 2009-05-21 16:44:06 UTC (rev 917)
@@ -102,7 +102,7 @@
sw.start();
}
// Do any commands update/write?
- RequestProcessor processor = new InMemoryRequestProcessor(context, this.repository);
+ RequestProcessor processor = new InMemoryRequestProcessor(context, this.repository, this.source.getRepositoryContext());
Lock lock = request.isReadOnly() ? repository.getLock().readLock() : repository.getLock().writeLock();
lock.lock();
Modified: trunk/dna-graph/src/main/java/org/jboss/dna/graph/connector/inmemory/InMemoryRequestProcessor.java
===================================================================
--- trunk/dna-graph/src/main/java/org/jboss/dna/graph/connector/inmemory/InMemoryRequestProcessor.java 2009-05-20 21:38:18 UTC (rev 916)
+++ trunk/dna-graph/src/main/java/org/jboss/dna/graph/connector/inmemory/InMemoryRequestProcessor.java 2009-05-21 16:44:06 UTC (rev 917)
@@ -37,6 +37,7 @@
import org.jboss.dna.graph.GraphI18n;
import org.jboss.dna.graph.JcrLexicon;
import org.jboss.dna.graph.Location;
+import org.jboss.dna.graph.connector.RepositoryContext;
import org.jboss.dna.graph.property.Name;
import org.jboss.dna.graph.property.Path;
import org.jboss.dna.graph.property.PathFactory;
@@ -70,8 +71,9 @@
private final InMemoryRepository repository;
protected InMemoryRequestProcessor( ExecutionContext context,
- InMemoryRepository repository ) {
- super(repository.getSourceName(), context);
+ InMemoryRepository repository,
+ RepositoryContext repositoryContext ) {
+ super(repository.getSourceName(), context, repositoryContext != null ? repositoryContext.getObserver() : null);
this.repository = repository;
pathFactory = context.getValueFactories().getPathFactory();
propertyFactory = context.getPropertyFactory();
@@ -133,6 +135,7 @@
Location oldLocation = getActualLocation(request.from().getPath(), node);
Location newLocation = Location.create(newPath, newNode.getUuid());
request.setActualLocations(oldLocation, newLocation);
+ record(request);
}
@Override
@@ -149,6 +152,7 @@
Path lowestExisting = workspace.getLowestExistingPath(parent);
request.setError(new PathNotFoundException(request.under(), lowestExisting,
GraphI18n.inMemoryNodeDoesNotExist.text(parent)));
+ return;
}
UUID uuid = null;
for (Property property : request.properties()) {
@@ -193,6 +197,7 @@
}
Location actualLocation = getActualLocation(path, node);
request.setActualLocationOfNode(actualLocation);
+ record(request);
}
@Override
@@ -204,6 +209,7 @@
workspace.removeNode(getExecutionContext(), node);
Location actualLocation = getActualLocation(request.at().getPath(), node);
request.setActualLocationOfNode(actualLocation);
+ record(request);
}
@Override
@@ -222,6 +228,7 @@
Location oldLocation = getActualLocation(request.from().getPath(), node);
Location newLocation = Location.create(newPath, newParent.getUuid());
request.setActualLocations(oldLocation, newLocation);
+ record(request);
}
@Override
@@ -243,6 +250,7 @@
}
Location actualLocation = getActualLocation(request.on().getPath(), node);
request.setActualLocationOfNode(actualLocation);
+ record(request);
}
/**
@@ -263,6 +271,7 @@
InMemoryNode root = workspace.getRoot();
request.setActualRootLocation(Location.create(pathFactory.createRootPath(), root.getUuid()));
request.setActualWorkspaceName(workspace.getName());
+ record(request);
}
}
@@ -273,7 +282,12 @@
*/
@Override
public void process( DestroyWorkspaceRequest request ) {
- if (!repository.destroyWorkspace(request.workspaceName())) {
+ InMemoryRepository.Workspace workspace = repository.getWorkspace(getExecutionContext(), request.workspaceName());
+ if (workspace != null) {
+ InMemoryNode root = workspace.getRoot();
+ request.setActualRootLocation(Location.create(pathFactory.createRootPath(), root.getUuid()));
+ record(request);
+ } else {
String msg = GraphI18n.workspaceDoesNotExistInRepository.text(request.workspaceName(), repository.getSourceName());
request.setError(new InvalidWorkspaceException(msg));
}
@@ -353,6 +367,7 @@
InMemoryNode root = target.getRoot();
request.setActualRootLocation(Location.create(pathFactory.createRootPath(), root.getUuid()));
request.setActualWorkspaceName(target.getName());
+ record(request);
}
}
Modified: trunk/dna-graph/src/main/java/org/jboss/dna/graph/observe/Changes.java
===================================================================
--- trunk/dna-graph/src/main/java/org/jboss/dna/graph/observe/Changes.java 2009-05-20 21:38:18 UTC (rev 916)
+++ trunk/dna-graph/src/main/java/org/jboss/dna/graph/observe/Changes.java 2009-05-21 16:44:06 UTC (rev 917)
@@ -45,6 +45,13 @@
private final DateTime timestamp;
private final List<ChangeRequest> changeRequests;
+ public Changes( Subject subject,
+ String sourceName,
+ DateTime timestamp,
+ List<ChangeRequest> requests ) {
+ this("", subject, sourceName, timestamp, requests);
+ }
+
public Changes( String processId,
Subject subject,
String sourceName,
Modified: trunk/dna-graph/src/main/java/org/jboss/dna/graph/request/CloneWorkspaceRequest.java
===================================================================
--- trunk/dna-graph/src/main/java/org/jboss/dna/graph/request/CloneWorkspaceRequest.java 2009-05-20 21:38:18 UTC (rev 916)
+++ trunk/dna-graph/src/main/java/org/jboss/dna/graph/request/CloneWorkspaceRequest.java 2009-05-21 16:44:06 UTC (rev 917)
@@ -26,6 +26,7 @@
import org.jboss.dna.common.util.CheckArg;
import org.jboss.dna.common.util.HashCode;
import org.jboss.dna.graph.Location;
+import org.jboss.dna.graph.property.Path;
import org.jboss.dna.graph.request.CreateWorkspaceRequest.CreateConflictBehavior;
/**
@@ -33,7 +34,7 @@
* the {@link #targetConflictBehavior() target conflict behavior} defines the behavior to be followed. If the workspace being
* cloned does not exist, the {@link #cloneConflictBehavior() clone conflict behavior} defines the behavior to be followed.
*/
-public final class CloneWorkspaceRequest extends Request {
+public final class CloneWorkspaceRequest extends ChangeRequest {
private static final long serialVersionUID = 1L;
@@ -228,4 +229,25 @@
public String toString() {
return "clone workspace \"" + nameOfWorkspaceToBeCloned() + "\" as workspace \"" + desiredNameOfTargetWorkspace() + "\"";
}
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.jboss.dna.graph.request.ChangeRequest#changedLocation()
+ */
+ @Override
+ public Location changedLocation() {
+ return actualLocationOfRoot;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.jboss.dna.graph.request.ChangeRequest#changes(java.lang.String, org.jboss.dna.graph.property.Path)
+ */
+ @Override
+ public boolean changes( String workspace,
+ Path path ) {
+ return actualWorkspaceName != null && actualWorkspaceName.equals(workspace);
+ }
}
Modified: trunk/dna-graph/src/main/java/org/jboss/dna/graph/request/CreateWorkspaceRequest.java
===================================================================
--- trunk/dna-graph/src/main/java/org/jboss/dna/graph/request/CreateWorkspaceRequest.java 2009-05-20 21:38:18 UTC (rev 916)
+++ trunk/dna-graph/src/main/java/org/jboss/dna/graph/request/CreateWorkspaceRequest.java 2009-05-21 16:44:06 UTC (rev 917)
@@ -25,12 +25,13 @@
import org.jboss.dna.common.util.CheckArg;
import org.jboss.dna.graph.Location;
+import org.jboss.dna.graph.property.Path;
/**
* Request that a new workspace be created with the supplied name. The request also specifies the desired
* {@link #conflictBehavior() behavior} for the recipient if a workspace already exists with the name.
*/
-public final class CreateWorkspaceRequest extends Request {
+public final class CreateWorkspaceRequest extends ChangeRequest {
private static final long serialVersionUID = 1L;
@@ -189,4 +190,25 @@
public String toString() {
return "create new workspace \"" + desiredNameOfNewWorkspace() + "\"";
}
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.jboss.dna.graph.request.ChangeRequest#changedLocation()
+ */
+ @Override
+ public Location changedLocation() {
+ return actualLocationOfRoot;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.jboss.dna.graph.request.ChangeRequest#changes(java.lang.String, org.jboss.dna.graph.property.Path)
+ */
+ @Override
+ public boolean changes( String workspace,
+ Path path ) {
+ return actualWorkspaceName != null && actualWorkspaceName.equals(workspace);
+ }
}
Modified: trunk/dna-graph/src/main/java/org/jboss/dna/graph/request/DestroyWorkspaceRequest.java
===================================================================
--- trunk/dna-graph/src/main/java/org/jboss/dna/graph/request/DestroyWorkspaceRequest.java 2009-05-20 21:38:18 UTC (rev 916)
+++ trunk/dna-graph/src/main/java/org/jboss/dna/graph/request/DestroyWorkspaceRequest.java 2009-05-21 16:44:06 UTC (rev 917)
@@ -24,15 +24,18 @@
package org.jboss.dna.graph.request;
import org.jboss.dna.common.util.CheckArg;
+import org.jboss.dna.graph.Location;
+import org.jboss.dna.graph.property.Path;
/**
* Request that an existing workspace with the supplied name be destroyed.
*/
-public final class DestroyWorkspaceRequest extends Request {
+public final class DestroyWorkspaceRequest extends ChangeRequest {
private static final long serialVersionUID = 1L;
private final String workspaceName;
+ private Location actualLocationOfRoot;
/**
* Create a request to destroy an existing workspace.
@@ -55,6 +58,26 @@
}
/**
+ * Get the actual location of the root node in the new workspace, or null if the workspace was not (yet) created.
+ *
+ * @return the actual location of the root node in the new workspace, or null if the workspace was not (yet) created
+ */
+ public Location getActualLocationOfRoot() {
+ return actualLocationOfRoot;
+ }
+
+ /**
+ * Set the actual location of the root node in the new workspace.
+ *
+ * @param actualLocationOfRoot the actual location of the workspace's root node.
+ * @throws IllegalStateException if the request is frozen
+ */
+ public void setActualRootLocation( Location actualLocationOfRoot ) {
+ checkNotFrozen();
+ this.actualLocationOfRoot = actualLocationOfRoot;
+ }
+
+ /**
* {@inheritDoc}
*
* @see org.jboss.dna.graph.request.Request#isReadOnly()
@@ -99,4 +122,25 @@
public String toString() {
return "destroy workspace \"" + workspaceName() + "\"";
}
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.jboss.dna.graph.request.ChangeRequest#changedLocation()
+ */
+ @Override
+ public Location changedLocation() {
+ return actualLocationOfRoot;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.jboss.dna.graph.request.ChangeRequest#changes(java.lang.String, org.jboss.dna.graph.property.Path)
+ */
+ @Override
+ public boolean changes( String workspace,
+ Path path ) {
+ return workspaceName().equals(workspace);
+ }
}
Modified: trunk/dna-graph/src/main/java/org/jboss/dna/graph/request/processor/LoggingRequestProcessor.java
===================================================================
--- trunk/dna-graph/src/main/java/org/jboss/dna/graph/request/processor/LoggingRequestProcessor.java 2009-05-20 21:38:18 UTC (rev 916)
+++ trunk/dna-graph/src/main/java/org/jboss/dna/graph/request/processor/LoggingRequestProcessor.java 2009-05-21 16:44:06 UTC (rev 917)
@@ -69,7 +69,7 @@
public LoggingRequestProcessor( RequestProcessor delegate,
Logger logger,
Logger.Level level ) {
- super(delegate.getSourceName(), delegate.getExecutionContext());
+ super(delegate.getSourceName(), delegate.getExecutionContext(), null);
CheckArg.isNotNull(logger, "logger");
this.delegate = delegate;
this.logger = logger;
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-05-20 21:38:18 UTC (rev 916)
+++ trunk/dna-graph/src/main/java/org/jboss/dna/graph/request/processor/RequestProcessor.java 2009-05-21 16:44:06 UTC (rev 917)
@@ -35,12 +35,15 @@
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;
import org.jboss.dna.graph.property.Name;
import org.jboss.dna.graph.property.Path;
import org.jboss.dna.graph.property.Property;
import org.jboss.dna.graph.property.ReferentialIntegrityException;
import org.jboss.dna.graph.request.CacheableRequest;
+import org.jboss.dna.graph.request.ChangeRequest;
import org.jboss.dna.graph.request.CloneWorkspaceRequest;
import org.jboss.dna.graph.request.CompositeRequest;
import org.jboss.dna.graph.request.CopyBranchRequest;
@@ -82,20 +85,25 @@
private final String sourceName;
private final DateTime nowInUtc;
private final CachePolicy defaultCachePolicy;
+ private final List<ChangeRequest> changes;
+ private final Observer observer;
protected RequestProcessor( String sourceName,
- ExecutionContext context ) {
- this(sourceName, context, null, null);
+ ExecutionContext context,
+ Observer observer ) {
+ this(sourceName, context, observer, null, null);
}
protected RequestProcessor( String sourceName,
ExecutionContext context,
+ Observer observer,
DateTime now ) {
- this(sourceName, context, now, null);
+ this(sourceName, context, observer, now, null);
}
protected RequestProcessor( String sourceName,
ExecutionContext context,
+ Observer observer,
DateTime now,
CachePolicy defaultCachePolicy ) {
CheckArg.isNotEmpty(sourceName, "sourceName");
@@ -104,9 +112,23 @@
this.sourceName = sourceName;
this.nowInUtc = now != null ? now : context.getValueFactories().getDateFactory().createUtc();
this.defaultCachePolicy = defaultCachePolicy;
+ this.changes = observer != null ? new LinkedList<ChangeRequest>() : null;
+ this.observer = observer;
}
/**
+ * Record the supplied change request for publishing through the event mechanism.
+ *
+ * @param request the completed change request; may not be null
+ */
+ protected void record( ChangeRequest request ) {
+ assert request != null;
+ assert !request.isCancelled();
+ assert !request.hasError();
+ if (changes != null) changes.add(request);
+ }
+
+ /**
* Get the name of the source against which this processor is executing.
*
* @return the repository source name; never null or empty
@@ -761,7 +783,11 @@
* Close this processor, allowing it to clean up any open resources.
*/
public void close() {
- // do nothing
+ // Publish any changes ...
+ if (observer != null && !this.changes.isEmpty()) {
+ Changes changes = new Changes(context.getSubject(), getSourceName(), getNowInUtc(), this.changes);
+ observer.notify(changes);
+ }
}
/**
Modified: trunk/dna-graph/src/test/java/org/jboss/dna/graph/GraphTest.java
===================================================================
--- trunk/dna-graph/src/test/java/org/jboss/dna/graph/GraphTest.java 2009-05-20 21:38:18 UTC (rev 916)
+++ trunk/dna-graph/src/test/java/org/jboss/dna/graph/GraphTest.java 2009-05-21 16:44:06 UTC (rev 917)
@@ -1058,7 +1058,7 @@
@SuppressWarnings( "synthetic-access" )
class Processor extends RequestProcessor {
protected Processor() {
- super(sourceName, context);
+ super(sourceName, context, null);
}
@Override
Modified: trunk/dna-graph/src/test/java/org/jboss/dna/graph/connector/MockRepositoryRequestProcessor.java
===================================================================
--- trunk/dna-graph/src/test/java/org/jboss/dna/graph/connector/MockRepositoryRequestProcessor.java 2009-05-20 21:38:18 UTC (rev 916)
+++ trunk/dna-graph/src/test/java/org/jboss/dna/graph/connector/MockRepositoryRequestProcessor.java 2009-05-21 16:44:06 UTC (rev 917)
@@ -64,7 +64,7 @@
public MockRepositoryRequestProcessor( String sourceName,
ExecutionContext context,
Queue<Request> processed ) {
- super(sourceName, context);
+ super(sourceName, context, null);
assert processed != null;
this.processed = processed;
}
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-05-20 21:38:18 UTC (rev 916)
+++ trunk/dna-graph/src/test/java/org/jboss/dna/graph/connector/federation/FederatedRepositoryConnectionTest.java 2009-05-21 16:44:06 UTC (rev 917)
@@ -50,7 +50,7 @@
@Before
public void beforeEach() {
MockitoAnnotations.initMocks(this);
- connection = new FederatedRepositoryConnection(repository);
+ connection = new FederatedRepositoryConnection(repository, null);
}
@Test
Modified: trunk/dna-graph/src/test/java/org/jboss/dna/graph/connector/federation/JoinRequestProcessorTest.java
===================================================================
--- trunk/dna-graph/src/test/java/org/jboss/dna/graph/connector/federation/JoinRequestProcessorTest.java 2009-05-20 21:38:18 UTC (rev 916)
+++ trunk/dna-graph/src/test/java/org/jboss/dna/graph/connector/federation/JoinRequestProcessorTest.java 2009-05-21 16:44:06 UTC (rev 917)
@@ -338,7 +338,7 @@
protected JoinRequestProcessorWithUnknownHandler( FederatedRepository repository,
ExecutionContext context,
DateTime now ) {
- super(repository, context, now);
+ super(repository, context, null, now);
}
@Override
Modified: trunk/extensions/dna-connector-federation/src/main/java/org/jboss/dna/connector/federation/FederatingRequestProcessor.java
===================================================================
--- trunk/extensions/dna-connector-federation/src/main/java/org/jboss/dna/connector/federation/FederatingRequestProcessor.java 2009-05-20 21:38:18 UTC (rev 916)
+++ trunk/extensions/dna-connector-federation/src/main/java/org/jboss/dna/connector/federation/FederatingRequestProcessor.java 2009-05-21 16:44:06 UTC (rev 917)
@@ -116,7 +116,7 @@
Map<String, FederatedWorkspace> workspaces,
FederatedWorkspace defaultWorkspace,
RepositoryConnectionFactory connectionFactory ) {
- super(sourceName, context);
+ super(sourceName, context, null);
CheckArg.isNotEmpty(workspaces, "workspaces");
CheckArg.isNotNull(connectionFactory, "connectionFactory");
this.workspaces = workspaces;
Modified: trunk/extensions/dna-connector-filesystem/src/main/java/org/jboss/dna/connector/filesystem/FileSystemRequestProcessor.java
===================================================================
--- trunk/extensions/dna-connector-filesystem/src/main/java/org/jboss/dna/connector/filesystem/FileSystemRequestProcessor.java 2009-05-20 21:38:18 UTC (rev 916)
+++ trunk/extensions/dna-connector-filesystem/src/main/java/org/jboss/dna/connector/filesystem/FileSystemRequestProcessor.java 2009-05-21 16:44:06 UTC (rev 917)
@@ -100,7 +100,7 @@
ExecutionContext context,
FilenameFilter filenameFilter,
boolean updatesAllowed ) {
- super(sourceName, context);
+ super(sourceName, context, null);
assert defaultWorkspace != null;
assert defaultWorkspace.exists();
assert defaultWorkspace.canRead();
@@ -391,9 +391,7 @@
*/
@Override
public void process( CloneWorkspaceRequest request ) {
- if (!updatesAllowed) {
- request.setError(new InvalidRequestException(FileSystemI18n.sourceIsReadOnly.text(getSourceName())));
- }
+ updatesAllowed(request);
}
/**
@@ -416,6 +414,7 @@
request.setActualWorkspaceName(getCanonicalWorkspaceName(directory));
request.setActualRootLocation(Location.create(pathFactory().createRootPath()));
availableWorkspaceNames.add(workspaceName);
+ record(request);
} else {
request.setError(new InvalidWorkspaceException(FileSystemI18n.workspaceDoesNotExist.text(workspaceName)));
}
@@ -436,6 +435,9 @@
// This doesn't delete the file/directory; rather, it just remove the workspace from the available set ...
if (!this.availableWorkspaceNames.remove(workspaceName)) {
request.setError(new InvalidWorkspaceException(FileSystemI18n.workspaceDoesNotExist.text(workspaceName)));
+ } else {
+ request.setActualRootLocation(Location.create(pathFactory().createRootPath()));
+ record(request);
}
}
Modified: trunk/extensions/dna-connector-jbosscache/src/main/java/org/jboss/dna/connector/jbosscache/JBossCacheConnection.java
===================================================================
--- trunk/extensions/dna-connector-jbosscache/src/main/java/org/jboss/dna/connector/jbosscache/JBossCacheConnection.java 2009-05-20 21:38:18 UTC (rev 916)
+++ trunk/extensions/dna-connector-jbosscache/src/main/java/org/jboss/dna/connector/jbosscache/JBossCacheConnection.java 2009-05-21 16:44:06 UTC (rev 917)
@@ -29,6 +29,7 @@
import org.jboss.dna.graph.cache.CachePolicy;
import org.jboss.dna.graph.connector.RepositoryConnection;
import org.jboss.dna.graph.connector.RepositorySourceException;
+import org.jboss.dna.graph.observe.Observer;
import org.jboss.dna.graph.request.Request;
import org.jboss.dna.graph.request.processor.RequestProcessor;
@@ -94,7 +95,8 @@
*/
public void execute( final ExecutionContext context,
final Request request ) throws RepositorySourceException {
- RequestProcessor processor = new JBossCacheRequestProcessor(getSourceName(), context, workspaces,
+ Observer observer = source.getObserver();
+ RequestProcessor processor = new JBossCacheRequestProcessor(getSourceName(), context, observer, workspaces,
source.getNameOfDefaultWorkspace(),
source.isCreatingWorkspacesAllowed());
try {
Modified: trunk/extensions/dna-connector-jbosscache/src/main/java/org/jboss/dna/connector/jbosscache/JBossCacheRequestProcessor.java
===================================================================
--- trunk/extensions/dna-connector-jbosscache/src/main/java/org/jboss/dna/connector/jbosscache/JBossCacheRequestProcessor.java 2009-05-20 21:38:18 UTC (rev 916)
+++ trunk/extensions/dna-connector-jbosscache/src/main/java/org/jboss/dna/connector/jbosscache/JBossCacheRequestProcessor.java 2009-05-21 16:44:06 UTC (rev 917)
@@ -40,6 +40,7 @@
import org.jboss.dna.graph.ExecutionContext;
import org.jboss.dna.graph.Location;
import org.jboss.dna.graph.connector.RepositorySourceException;
+import org.jboss.dna.graph.observe.Observer;
import org.jboss.dna.graph.property.Name;
import org.jboss.dna.graph.property.Path;
import org.jboss.dna.graph.property.PathFactory;
@@ -85,16 +86,18 @@
/**
* @param sourceName the name of the source in which this processor is operating
* @param context the execution context in which this processor operates
+ * @param observer the observer to which events should be published; may be null if the events are not be published
* @param workspaces the manager for the workspaces
* @param defaultWorkspaceName the name of the default workspace; never null
* @param creatingWorkspacesAllowed true if clients can create new workspaces, or false otherwise
*/
JBossCacheRequestProcessor( String sourceName,
ExecutionContext context,
+ Observer observer,
JBossCacheWorkspaces workspaces,
String defaultWorkspaceName,
boolean creatingWorkspacesAllowed ) {
- super(sourceName, context);
+ super(sourceName, context, observer);
assert workspaces != null;
assert defaultWorkspaceName != null;
this.workspaces = workspaces;
@@ -180,6 +183,7 @@
}
Path nodePath = pathFactory.create(parent, newSegment);
request.setActualLocationOfNode(Location.create(nodePath));
+ record(request);
}
@Override
@@ -211,6 +215,7 @@
node.put(propName, value);
}
request.setActualLocationOfNode(Location.create(nodePath));
+ record(request);
}
@Override
@@ -247,6 +252,7 @@
Path newPath = pathFactory.create(newParentPath, newSegment);
request.setActualLocations(Location.create(nodePath), Location.create(newPath));
+ record(request);
}
@Override
@@ -263,6 +269,7 @@
if (cache.removeNode(node.getFqn())) {
removeFromChildList(cache, parent, nameOfRemovedNode, getExecutionContext());
request.setActualLocationOfNode(Location.create(nodePath));
+ record(request);
} else {
String msg = JBossCacheConnectorI18n.unableToDeleteBranch.text(getSourceName(), request.inWorkspace(), nodePath);
request.setError(new RepositorySourceException(msg));
@@ -296,6 +303,7 @@
Path newPath = pathFactory.create(newParentPath, newSegment);
request.setActualLocations(Location.create(nodePath), Location.create(newPath));
+ record(request);
}
/**
@@ -363,6 +371,7 @@
}
request.setActualRootLocation(Location.create(pathFactory.createRootPath()));
request.setActualWorkspaceName(workspaceName);
+ record(request);
}
/**
@@ -412,6 +421,7 @@
// Copy the list of child segments in the root (this maintains the order of the children) ...
Path.Segment[] childNames = (Path.Segment[])fromRoot.get(JBossCacheLexicon.CHILD_PATH_SEGMENT_LIST);
intoRoot.put(JBossCacheLexicon.CHILD_PATH_SEGMENT_LIST, childNames);
+ record(request);
}
/**
@@ -421,10 +431,14 @@
*/
@Override
public void process( DestroyWorkspaceRequest request ) {
- if (!this.workspaces.removeWorkspace(request.workspaceName())) {
- String msg = JBossCacheConnectorI18n.workspaceDoesNotExist.text(request.workspaceName());
+ Cache<Name, Object> fromCache = workspaces.getWorkspace(request.workspaceName(), false);
+ if (fromCache == null) {
+ String msg = JBossCacheConnectorI18n.workspaceDoesNotExist.text(getSourceName(), request.workspaceName());
request.setError(new InvalidWorkspaceException(msg));
+ return;
}
+ request.setActualRootLocation(Location.create(pathFactory.createRootPath()));
+ record(request);
}
// ----------------------------------------------------------------------------------------------------------------
Modified: trunk/extensions/dna-connector-jbosscache/src/main/java/org/jboss/dna/connector/jbosscache/JBossCacheSource.java
===================================================================
--- trunk/extensions/dna-connector-jbosscache/src/main/java/org/jboss/dna/connector/jbosscache/JBossCacheSource.java 2009-05-20 21:38:18 UTC (rev 916)
+++ trunk/extensions/dna-connector-jbosscache/src/main/java/org/jboss/dna/connector/jbosscache/JBossCacheSource.java 2009-05-21 16:44:06 UTC (rev 917)
@@ -58,6 +58,7 @@
import org.jboss.dna.graph.connector.RepositorySource;
import org.jboss.dna.graph.connector.RepositorySourceCapabilities;
import org.jboss.dna.graph.connector.RepositorySourceException;
+import org.jboss.dna.graph.observe.Observer;
import org.jboss.dna.graph.property.Name;
/**
@@ -115,6 +116,7 @@
private volatile RepositorySourceCapabilities capabilities = new RepositorySourceCapabilities(true, true, false, true, false);
private transient JBossCacheWorkspaces workspaces;
private transient Context jndiContext;
+ private transient RepositoryContext repositoryContext;
/**
* Create a repository source instance.
@@ -128,6 +130,7 @@
* @see org.jboss.dna.graph.connector.RepositorySource#initialize(org.jboss.dna.graph.connector.RepositoryContext)
*/
public void initialize( RepositoryContext context ) throws RepositorySourceException {
+ this.repositoryContext = context;
}
/**
@@ -476,6 +479,17 @@
return new JBossCacheConnection(this, this.workspaces);
}
+ /**
+ * @return repositoryContext
+ */
+ protected RepositoryContext getRepositoryContext() {
+ return repositoryContext;
+ }
+
+ protected Observer getObserver() {
+ return repositoryContext != null ? repositoryContext.getObserver() : null;
+ }
+
protected Context getContext() {
return this.jndiContext;
}
Modified: trunk/extensions/dna-connector-jbosscache/src/test/java/org/jboss/dna/connector/jbosscache/JBossCacheRequestProcessorTest.java
===================================================================
--- trunk/extensions/dna-connector-jbosscache/src/test/java/org/jboss/dna/connector/jbosscache/JBossCacheRequestProcessorTest.java 2009-05-20 21:38:18 UTC (rev 916)
+++ trunk/extensions/dna-connector-jbosscache/src/test/java/org/jboss/dna/connector/jbosscache/JBossCacheRequestProcessorTest.java 2009-05-21 16:44:06 UTC (rev 917)
@@ -71,7 +71,7 @@
initialWorkspaceNames.add("workspace2");
defaultWorkspaceName = initialWorkspaceNames.iterator().next();
workspaces = new JBossCacheWorkspaces("source", cacheFactory, defaultConfigName, initialWorkspaceNames, jndi);
- processor = new JBossCacheRequestProcessor("source", context, workspaces, defaultWorkspaceName, true);
+ processor = new JBossCacheRequestProcessor("source", context, null, workspaces, defaultWorkspaceName, true);
pathFactory = context.getValueFactories().getPathFactory();
}
Modified: trunk/extensions/dna-connector-jdbc-metadata/src/main/java/org/jboss/dna/connector/jdbc/JdbcRequestProcesor.java
===================================================================
--- trunk/extensions/dna-connector-jdbc-metadata/src/main/java/org/jboss/dna/connector/jdbc/JdbcRequestProcesor.java 2009-05-20 21:38:18 UTC (rev 916)
+++ trunk/extensions/dna-connector-jdbc-metadata/src/main/java/org/jboss/dna/connector/jdbc/JdbcRequestProcesor.java 2009-05-21 16:44:06 UTC (rev 917)
@@ -66,7 +66,7 @@
ExecutionContext context,
Connection connection,
UUID rootNodeUuid ) {
- super(sourceName, context);
+ super(sourceName, context, null);
this.connection = connection;
this.rootNodeUuid = rootNodeUuid;
}
@@ -83,7 +83,7 @@
Connection connection,
UUID rootNodeUuid,
DateTime now ) {
- super(sourceName, context, now);
+ super(sourceName, context, null, now);
this.connection = connection;
this.rootNodeUuid = rootNodeUuid;
}
Modified: trunk/extensions/dna-connector-store-jpa/src/main/java/org/jboss/dna/connector/store/jpa/JpaConnection.java
===================================================================
--- trunk/extensions/dna-connector-store-jpa/src/main/java/org/jboss/dna/connector/store/jpa/JpaConnection.java 2009-05-20 21:38:18 UTC (rev 916)
+++ trunk/extensions/dna-connector-store-jpa/src/main/java/org/jboss/dna/connector/store/jpa/JpaConnection.java 2009-05-21 16:44:06 UTC (rev 917)
@@ -31,6 +31,7 @@
import org.jboss.dna.graph.cache.CachePolicy;
import org.jboss.dna.graph.connector.RepositoryConnection;
import org.jboss.dna.graph.connector.RepositorySourceException;
+import org.jboss.dna.graph.observe.Observer;
import org.jboss.dna.graph.request.Request;
import org.jboss.dna.graph.request.processor.RequestProcessor;
@@ -50,8 +51,10 @@
private final long largeValueMinimumSizeInBytes;
private final boolean compressData;
private final boolean enforceReferentialIntegrity;
+ private final Observer observer;
/*package*/JpaConnection( String sourceName,
+ Observer observer,
CachePolicy cachePolicy,
EntityManager entityManager,
Model model,
@@ -66,6 +69,7 @@
assert entityManager != null;
assert model != null;
assert rootNodeUuid != null;
+ this.observer = observer;
this.name = sourceName;
this.cachePolicy = cachePolicy; // may be null
this.entityManager = entityManager;
@@ -127,6 +131,7 @@
long size = largeValueMinimumSizeInBytes;
RequestProcessor proc = model.createRequestProcessor(name,
context,
+ observer,
entityManager,
rootNodeUuid,
nameOfDefaultWorkspace,
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-05-20 21:38:18 UTC (rev 916)
+++ trunk/extensions/dna-connector-store-jpa/src/main/java/org/jboss/dna/connector/store/jpa/JpaSource.java 2009-05-21 16:44:06 UTC (rev 917)
@@ -58,6 +58,7 @@
import org.jboss.dna.graph.connector.RepositorySource;
import org.jboss.dna.graph.connector.RepositorySourceCapabilities;
import org.jboss.dna.graph.connector.RepositorySourceException;
+import org.jboss.dna.graph.observe.Observer;
/**
* The {@link RepositorySource} for the connector that stores content in a (custom) relational database. This connector uses Java
@@ -929,7 +930,8 @@
if (entityManager == null) {
entityManager = entityManagerFactory.createEntityManager();
}
- return new JpaConnection(getName(), cachePolicy, entityManager, model, rootUuid, defaultWorkspace,
+ Observer observer = repositoryContext != null ? repositoryContext.getObserver() : null;
+ return new JpaConnection(getName(), observer, cachePolicy, entityManager, model, rootUuid, defaultWorkspace,
getPredefinedWorkspaceNames(), largeValueSizeInBytes, isCreatingWorkspacesAllowed(),
compressData, referentialIntegrityEnforced);
}
Modified: trunk/extensions/dna-connector-store-jpa/src/main/java/org/jboss/dna/connector/store/jpa/Model.java
===================================================================
--- trunk/extensions/dna-connector-store-jpa/src/main/java/org/jboss/dna/connector/store/jpa/Model.java 2009-05-20 21:38:18 UTC (rev 916)
+++ trunk/extensions/dna-connector-store-jpa/src/main/java/org/jboss/dna/connector/store/jpa/Model.java 2009-05-21 16:44:06 UTC (rev 917)
@@ -30,6 +30,7 @@
import org.jboss.dna.common.i18n.I18n;
import org.jboss.dna.common.util.CheckArg;
import org.jboss.dna.graph.ExecutionContext;
+import org.jboss.dna.graph.observe.Observer;
import org.jboss.dna.graph.request.processor.RequestProcessor;
/**
@@ -78,6 +79,7 @@
public abstract RequestProcessor createRequestProcessor( String sourceName,
ExecutionContext context,
+ Observer observer,
EntityManager entityManager,
UUID rootNodeUuid,
String nameOfDefaultWorkspace,
Modified: trunk/extensions/dna-connector-store-jpa/src/main/java/org/jboss/dna/connector/store/jpa/model/basic/BasicModel.java
===================================================================
--- trunk/extensions/dna-connector-store-jpa/src/main/java/org/jboss/dna/connector/store/jpa/model/basic/BasicModel.java 2009-05-20 21:38:18 UTC (rev 916)
+++ trunk/extensions/dna-connector-store-jpa/src/main/java/org/jboss/dna/connector/store/jpa/model/basic/BasicModel.java 2009-05-21 16:44:06 UTC (rev 917)
@@ -32,6 +32,7 @@
import org.jboss.dna.connector.store.jpa.model.common.NamespaceEntity;
import org.jboss.dna.connector.store.jpa.model.common.WorkspaceEntity;
import org.jboss.dna.graph.ExecutionContext;
+import org.jboss.dna.graph.observe.Observer;
import org.jboss.dna.graph.request.CopyBranchRequest;
import org.jboss.dna.graph.request.DeleteBranchRequest;
import org.jboss.dna.graph.request.MoveBranchRequest;
@@ -101,12 +102,13 @@
/**
* {@inheritDoc}
*
- * @see org.jboss.dna.connector.store.jpa.Model#createRequestProcessor(String, ExecutionContext, EntityManager, UUID, String,
- * String[], long, boolean, boolean, boolean)
+ * @see org.jboss.dna.connector.store.jpa.Model#createRequestProcessor(String, ExecutionContext, Observer, EntityManager,
+ * UUID, String, String[], long, boolean, boolean, boolean)
*/
@Override
public RequestProcessor createRequestProcessor( String sourceName,
ExecutionContext context,
+ Observer observer,
EntityManager entityManager,
UUID rootNodeUuid,
String nameOfDefaultWorkspace,
@@ -115,7 +117,7 @@
boolean creatingWorkspacesAllowed,
boolean compressData,
boolean enforceReferentialIntegrity ) {
- return new BasicRequestProcessor(sourceName, context, entityManager, rootNodeUuid, nameOfDefaultWorkspace,
+ return new BasicRequestProcessor(sourceName, context, observer, entityManager, rootNodeUuid, nameOfDefaultWorkspace,
predefinedWorkspaceNames, largeValueMinimumSizeInBytes, creatingWorkspacesAllowed,
compressData, enforceReferentialIntegrity);
}
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-05-20 21:38:18 UTC (rev 916)
+++ trunk/extensions/dna-connector-store-jpa/src/main/java/org/jboss/dna/connector/store/jpa/model/basic/BasicRequestProcessor.java 2009-05-21 16:44:06 UTC (rev 917)
@@ -66,6 +66,7 @@
import org.jboss.dna.graph.ExecutionContext;
import org.jboss.dna.graph.JcrLexicon;
import org.jboss.dna.graph.Location;
+import org.jboss.dna.graph.observe.Observer;
import org.jboss.dna.graph.property.Binary;
import org.jboss.dna.graph.property.Name;
import org.jboss.dna.graph.property.NameFactory;
@@ -132,6 +133,7 @@
/**
* @param sourceName
* @param context
+ * @param observer
* @param entityManager
* @param rootNodeUuid
* @param nameOfDefaultWorkspace
@@ -143,6 +145,7 @@
*/
public BasicRequestProcessor( String sourceName,
ExecutionContext context,
+ Observer observer,
EntityManager entityManager,
UUID rootNodeUuid,
String nameOfDefaultWorkspace,
@@ -151,7 +154,7 @@
boolean creatingWorkspacesAllowed,
boolean compressData,
boolean enforceReferentialIntegrity ) {
- super(sourceName, context);
+ super(sourceName, context, observer);
assert entityManager != null;
assert rootNodeUuid != null;
assert predefinedWorkspaceNames != null;
@@ -949,6 +952,7 @@
return;
}
if (actualLocation != null) request.setActualLocationOfNode(actualLocation);
+ record(request);
}
/**
@@ -1234,6 +1238,7 @@
return;
}
request.setActualLocations(actualFromLocation, actualToLocation);
+ record(request);
}
/**
@@ -1245,7 +1250,10 @@
public void process( DeleteBranchRequest request ) {
logger.trace(request.toString());
Location location = delete(request, request.at(), request.inWorkspace(), true);
- if (location != null) request.setActualLocationOfNode(location);
+ if (location != null) {
+ request.setActualLocationOfNode(location);
+ record(request);
+ }
}
/**
@@ -1257,7 +1265,10 @@
public void process( DeleteChildrenRequest request ) {
logger.trace(request.toString());
Location location = delete(request, request.at(), request.inWorkspace(), false);
- if (location != null) request.setActualLocationOfNode(location);
+ if (location != null) {
+ request.setActualLocationOfNode(location);
+ record(request);
+ }
}
protected Location delete( Request request,
@@ -1473,6 +1484,7 @@
return;
}
request.setActualLocations(actualOldLocation, actualNewLocation);
+ record(request);
}
/**
@@ -1523,6 +1535,7 @@
if (!creatingWorkspacesAllowed) {
String msg = JpaConnectorI18n.unableToCreateWorkspaces.text(getSourceName());
request.setError(new InvalidRequestException(msg));
+ return;
}
Set<String> existingNames = workspaces.getWorkspaceNames();
int counter = 0;
@@ -1544,6 +1557,7 @@
// Create the root node ...
Location root = Location.create(pathFactory.createRootPath());
request.setActualRootLocation(getActualLocation(entity.getId(), root).location);
+ record(request);
}
/**
@@ -1557,6 +1571,7 @@
if (!creatingWorkspacesAllowed) {
String msg = JpaConnectorI18n.unableToCreateWorkspaces.text(getSourceName());
request.setError(new InvalidRequestException(msg));
+ return;
}
Set<String> existingNames = workspaces.getWorkspaceNames();
String name = request.desiredNameOfTargetWorkspace();
@@ -1642,6 +1657,7 @@
// Finish up the request ...
Location root = Location.create(pathFactory.createRootPath(), rootNodeUuid);
request.setActualRootLocation(getActualLocation(intoWorkspace.getId(), root).location);
+ record(request);
}
/**
@@ -1657,6 +1673,9 @@
Long workspaceId = workspace.getId();
assert workspaceId != null;
+ // Get the actual location of the root node ...
+ ActualLocation actual = getActualLocation(workspaceId, Location.create(pathFactory.createRootPath()));
+
// Delete the workspace ...
workspaces.destroy(workspace.getName());
@@ -1675,6 +1694,10 @@
// Delete unused large values ...
LargeValueEntity.deleteUnused(entities);
+
+ // Finish the request ...
+ request.setActualRootLocation(actual.location);
+ record(request);
}
/**
Modified: trunk/extensions/dna-connector-store-jpa/src/test/java/org/jboss/dna/connector/store/jpa/ModelTest.java
===================================================================
--- trunk/extensions/dna-connector-store-jpa/src/test/java/org/jboss/dna/connector/store/jpa/ModelTest.java 2009-05-20 21:38:18 UTC (rev 916)
+++ trunk/extensions/dna-connector-store-jpa/src/test/java/org/jboss/dna/connector/store/jpa/ModelTest.java 2009-05-21 16:44:06 UTC (rev 917)
@@ -31,6 +31,7 @@
import org.hibernate.ejb.Ejb3Configuration;
import org.jboss.dna.common.i18n.I18n;
import org.jboss.dna.graph.ExecutionContext;
+import org.jboss.dna.graph.observe.Observer;
import org.jboss.dna.graph.request.processor.RequestProcessor;
import org.junit.Before;
import org.junit.Test;
@@ -107,6 +108,7 @@
@Override
public RequestProcessor createRequestProcessor( String sourceName,
ExecutionContext context,
+ Observer observer,
EntityManager entityManager,
UUID rootNodeUuid,
String nameOfDefaultWorkspace,
Modified: trunk/extensions/dna-connector-store-jpa/src/test/java/org/jboss/dna/connector/store/jpa/model/basic/BasicModelTest.java
===================================================================
--- trunk/extensions/dna-connector-store-jpa/src/test/java/org/jboss/dna/connector/store/jpa/model/basic/BasicModelTest.java 2009-05-20 21:38:18 UTC (rev 916)
+++ trunk/extensions/dna-connector-store-jpa/src/test/java/org/jboss/dna/connector/store/jpa/model/basic/BasicModelTest.java 2009-05-21 16:44:06 UTC (rev 917)
@@ -128,6 +128,7 @@
stub(manager.getTransaction()).toReturn(txn);
RequestProcessor proc = model.createRequestProcessor("test source",
context,
+ null,
manager,
UUID.randomUUID(),
"default workspace",
Modified: trunk/extensions/dna-connector-svn/src/main/java/org/jboss/dna/connector/svn/SVNRepositoryRequestProcessor.java
===================================================================
--- trunk/extensions/dna-connector-svn/src/main/java/org/jboss/dna/connector/svn/SVNRepositoryRequestProcessor.java 2009-05-20 21:38:18 UTC (rev 916)
+++ trunk/extensions/dna-connector-svn/src/main/java/org/jboss/dna/connector/svn/SVNRepositoryRequestProcessor.java 2009-05-21 16:44:06 UTC (rev 917)
@@ -103,7 +103,7 @@
ExecutionContext context,
SVNRepository repository,
boolean updatesAllowed ) {
- super(sourceName, context);
+ super(sourceName, context, null);
this.defaultNamespaceUri = getExecutionContext().getNamespaceRegistry().getDefaultNamespaceUri();
this.updatesAllowed = updatesAllowed;
this.repository = repository;
15 years, 1 month
DNA SVN: r916 - in trunk: dna-graph/src/main/java/org/jboss/dna/graph/sequencer and 23 other directories.
by dna-commits@lists.jboss.org
Author: bcarothers
Date: 2009-05-20 17:38:18 -0400 (Wed, 20 May 2009)
New Revision: 916
Added:
trunk/dna-graph/src/main/java/org/jboss/dna/graph/sequencer/StreamSequencerContext.java
trunk/dna-repository/src/main/java/org/jboss/dna/repository/sequencer/SequencerContext.java
Removed:
trunk/dna-graph/src/main/java/org/jboss/dna/graph/sequencer/SequencerContext.java
Modified:
trunk/dna-graph/src/main/java/org/jboss/dna/graph/Graph.java
trunk/dna-graph/src/main/java/org/jboss/dna/graph/sequencer/SequencerOutput.java
trunk/dna-graph/src/main/java/org/jboss/dna/graph/sequencer/StreamSequencer.java
trunk/dna-graph/src/main/java/org/jboss/dna/graph/sequencer/package-info.java
trunk/dna-graph/src/test/java/org/jboss/dna/graph/sequencer/MockSequencerContext.java
trunk/dna-graph/src/test/java/org/jboss/dna/graph/sequencer/MockSequencerOutput.java
trunk/dna-repository/src/main/java/org/jboss/dna/repository/DnaEngine.java
trunk/dna-repository/src/main/java/org/jboss/dna/repository/DnaLexicon.java
trunk/dna-repository/src/main/java/org/jboss/dna/repository/RepositoryService.java
trunk/dna-repository/src/main/java/org/jboss/dna/repository/observation/NodeChange.java
trunk/dna-repository/src/main/java/org/jboss/dna/repository/observation/NodeChanges.java
trunk/dna-repository/src/main/java/org/jboss/dna/repository/observation/ObservationService.java
trunk/dna-repository/src/main/java/org/jboss/dna/repository/sequencer/Sequencer.java
trunk/dna-repository/src/main/java/org/jboss/dna/repository/sequencer/SequencerOutputMap.java
trunk/dna-repository/src/main/java/org/jboss/dna/repository/sequencer/SequencingService.java
trunk/dna-repository/src/main/java/org/jboss/dna/repository/sequencer/StreamSequencerAdapter.java
trunk/dna-repository/src/main/java/org/jboss/dna/repository/util/RepositoryNodePath.java
trunk/dna-repository/src/test/java/org/jboss/dna/repository/DnaEngineTest.java
trunk/dna-repository/src/test/java/org/jboss/dna/repository/observation/NodeChangeTest.java
trunk/dna-repository/src/test/java/org/jboss/dna/repository/sequencer/MockSequencerA.java
trunk/dna-repository/src/test/java/org/jboss/dna/repository/sequencer/MockSequencerB.java
trunk/dna-repository/src/test/java/org/jboss/dna/repository/sequencer/SequencingServiceTest.java
trunk/dna-repository/src/test/java/org/jboss/dna/repository/sequencer/StreamSequencerAdapterTest.java
trunk/docs/examples/gettingstarted/sequencers/src/main/java/org/jboss/example/dna/sequencer/SequencingClient.java
trunk/docs/examples/gettingstarted/sequencers/src/test/java/org/jboss/example/dna/sequencer/SequencingClientTest.java
trunk/extensions/dna-common-jdbc/src/main/java/org/jboss/dna/graph/sequencers/JdbcSequencer.java
trunk/extensions/dna-sequencer-cnd/src/main/java/org/jboss/dna/sequencer/cnd/CndSequencer.java
trunk/extensions/dna-sequencer-cnd/src/test/java/org/jboss/dna/sequencer/cnd/CndSequencerTest.java
trunk/extensions/dna-sequencer-images/src/main/java/org/jboss/dna/sequencer/image/ImageMetadataSequencer.java
trunk/extensions/dna-sequencer-images/src/test/java/org/jboss/dna/sequencer/image/ImageMetadataSequencerTest.java
trunk/extensions/dna-sequencer-java/src/main/java/org/jboss/dna/sequencer/java/JavaMetadataSequencer.java
trunk/extensions/dna-sequencer-java/src/test/java/org/jboss/dna/sequencer/java/JavaMetadataSequencerTest.java
trunk/extensions/dna-sequencer-mp3/src/main/java/org/jboss/dna/sequencer/mp3/Mp3MetadataSequencer.java
trunk/extensions/dna-sequencer-msoffice/src/main/java/org/jboss/dna/sequencer/msoffice/MSOfficeMetadataSequencer.java
trunk/extensions/dna-sequencer-xml/src/main/java/org/jboss/dna/sequencer/xml/XmlSequencer.java
trunk/extensions/dna-sequencer-xml/src/main/java/org/jboss/dna/sequencer/xml/XmlSequencerHandler.java
trunk/extensions/dna-sequencer-xml/src/test/java/org/jboss/dna/sequencer/xml/InheritingXmlSequencerTest.java
trunk/extensions/dna-sequencer-xml/src/test/java/org/jboss/dna/sequencer/xml/XmlSequencerHandlerTest.java
trunk/extensions/dna-sequencer-xml/src/test/java/org/jboss/dna/sequencer/xml/XmlSequencerTest.java
trunk/extensions/dna-sequencer-zip/src/main/java/org/jboss/dna/sequencer/zip/ZipSequencer.java
trunk/extensions/dna-sequencer-zip/src/test/java/org/jboss/dna/sequencer/zip/ZipSequencerTest.java
Log:
DNA-401 Remove SequencingService Dependency on JCR
Resolved the defect by applying a patch that:
- Renames SequencerContext to StreamSequencerContext (causing a surprising percentage of the changed lines in the patch)
- Creates a new SequencerContext that replaces the use of JcrExecutionContext for SequencingService
- Adds the concept of a repository source name to ChangedNode and its ilk to reflect the fact that DNA can manage multiple independent repositories
- Modifies all of the code in SequencingService and StreamSequencerAdapter that used to use the JCR layer for data access to use the graph layer directly.
- Modifies DnaEngine to tie the RepositoryService (actually, the RepositoryLibrary) into the SequencingService so that the sequencing service can determine which repository source the changed node is in and act on that repository source accordingly
The patch breaks one existing test case in StreamSequencerAdapterTest that can't/shouldn't be fixed until ObservationService is modified to not use JCR. The patch also breaks 4 test cases in the sequencing quickstart. This test really just needs to get rewritten to use DnaEngine and JcrEngine after ObservationService is changed. If we adopt this patch, I will make a note in the extant defect for re-writing the quickstarts to use DnaEngine and JcrEngine.
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-05-20 20:32:08 UTC (rev 915)
+++ trunk/dna-graph/src/main/java/org/jboss/dna/graph/Graph.java 2009-05-20 21:38:18 UTC (rev 916)
@@ -1931,6 +1931,58 @@
}
/**
+ * Import the content from the provided stream of XML data, specifying via the returned {@link ImportInto object} where the
+ * content is to be imported.
+ *
+ * @param stream the open stream of XML data that the importer can read the content that is to be imported
+ * @return the object that should be used to specify into which the content is to be imported
+ * @throws IllegalArgumentException if the <code>stream</code> or destination path are null
+ */
+ public ImportInto<Conjunction<Graph>> importXmlFrom( final InputStream stream ) {
+ CheckArg.isNotNull(stream, "stream");
+
+ return new ImportInto<Conjunction<Graph>>() {
+ private boolean skipRootElement = false;
+
+ public ImportInto<Conjunction<Graph>> skippingRootElement( boolean skipRootElement ) {
+ this.skipRootElement = skipRootElement;
+ return this;
+ }
+
+ public Conjunction<Graph> into( String path ) throws IOException, SAXException {
+ return into(Location.create(createPath(path)));
+ }
+
+ public Conjunction<Graph> into( Path path ) throws IOException, SAXException {
+ return into(Location.create(path));
+ }
+
+ public Conjunction<Graph> into( Property idProperty ) throws IOException, SAXException {
+ return into(Location.create(idProperty));
+ }
+
+ public Conjunction<Graph> into( Property firstIdProperty,
+ Property... additionalIdProperties ) throws IOException, SAXException {
+ return into(Location.create(firstIdProperty, additionalIdProperties));
+ }
+
+ public Conjunction<Graph> into( Iterable<Property> idProperties ) throws IOException, SAXException {
+ return into(Location.create(idProperties));
+ }
+
+ public Conjunction<Graph> into( UUID uuid ) throws IOException, SAXException {
+ return into(Location.create(uuid));
+ }
+
+ public Conjunction<Graph> into( Location at ) throws IOException, SAXException {
+ GraphImporter importer = new GraphImporter(Graph.this);
+ importer.importXml(stream, at, skipRootElement).execute(); // 'importXml' creates and uses a new batch
+ return Graph.this.nextGraph;
+ }
+ };
+ }
+
+ /**
* Import the content from the XML file at the supplied URI, specifying via the returned {@link ImportInto object} where the
* content is to be imported.
*
Deleted: trunk/dna-graph/src/main/java/org/jboss/dna/graph/sequencer/SequencerContext.java
===================================================================
--- trunk/dna-graph/src/main/java/org/jboss/dna/graph/sequencer/SequencerContext.java 2009-05-20 20:32:08 UTC (rev 915)
+++ trunk/dna-graph/src/main/java/org/jboss/dna/graph/sequencer/SequencerContext.java 2009-05-20 21:38:18 UTC (rev 916)
@@ -1,112 +0,0 @@
-/*
- * JBoss DNA (http://www.jboss.org/dna)
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- * See the AUTHORS.txt file in the distribution for a full listing of
- * individual contributors.
- *
- * JBoss DNA is free software. Unless otherwise indicated, all code in JBoss DNA
- * is licensed to you under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * JBoss DNA is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.dna.graph.sequencer;
-
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Map;
-import java.util.Set;
-import org.jboss.dna.common.collection.Problems;
-import org.jboss.dna.common.collection.SimpleProblems;
-import org.jboss.dna.graph.ExecutionContext;
-import org.jboss.dna.graph.property.Name;
-import org.jboss.dna.graph.property.Path;
-import org.jboss.dna.graph.property.Property;
-
-/**
- * @author John Verhaeg
- */
-public class SequencerContext extends ExecutionContext {
-
- private final Path inputPath;
- private final Map<Name, Property> inputPropertiesByName;
- private final Set<Property> inputProperties;
- private final Problems problems;
- private final String mimeType;
-
- public SequencerContext( ExecutionContext context,
- Path inputPath,
- Set<Property> inputProperties,
- String mimeType,
- Problems problems ) {
- super(context);
- this.inputPath = inputPath;
- this.inputProperties = inputProperties != null ? new HashSet<Property>(inputProperties) : new HashSet<Property>();
- this.mimeType = mimeType;
- this.problems = problems != null ? problems : new SimpleProblems();
- Map<Name, Property> inputPropertiesByName = new HashMap<Name, Property>();
- for (Property property : this.inputProperties) {
- inputPropertiesByName.put(property.getName(), property);
- }
- this.inputPropertiesByName = Collections.unmodifiableMap(inputPropertiesByName);
- }
-
- /**
- * Return the path of the input node containing the content being sequenced.
- *
- * @return input node's path.
- */
- public Path getInputPath() {
- return inputPath;
- }
-
- /**
- * Return the set of properties from the input node containing the content being sequenced.
- *
- * @return the input node's properties; never <code>null</code>.
- */
- public Set<Property> getInputProperties() {
- return inputProperties;
- }
-
- /**
- * Return the property with the supplied name from the input node containing the content being sequenced.
- *
- * @param name
- * @return the input node property, or <code>null</code> if none exists.
- */
- public Property getInputProperty( Name name ) {
- return inputPropertiesByName.get(name);
- }
-
- /**
- * Return the MIME-type of the content being sequenced.
- *
- * @return the MIME-type
- */
- public String getMimeType() {
- return this.mimeType;
- }
-
- /**
- * Get an interface that can be used to record various problems, warnings, and errors that are not extreme enough to warrant
- * throwing exceptions.
- *
- * @return the interface for recording problems; never null
- */
- public Problems getProblems() {
- return this.problems;
- }
-}
Modified: trunk/dna-graph/src/main/java/org/jboss/dna/graph/sequencer/SequencerOutput.java
===================================================================
--- trunk/dna-graph/src/main/java/org/jboss/dna/graph/sequencer/SequencerOutput.java 2009-05-20 20:32:08 UTC (rev 915)
+++ trunk/dna-graph/src/main/java/org/jboss/dna/graph/sequencer/SequencerOutput.java 2009-05-20 21:38:18 UTC (rev 916)
@@ -37,13 +37,13 @@
/**
* Set the supplied property on the supplied node.
* <p>
- * The {@link SequencerContext#getValueFactories() value factories} should be used to create paths, names, and values. These
+ * The {@link StreamSequencerContext#getValueFactories() value factories} should be used to create paths, names, and values. These
* factories can be used to create new values or convert values from one property type to another. (Note that each of the
* factories have methods that create values from all of the property types.)
* </p>
* <p>
* This method is provided as a convenience, but it identical to creating a {@link Path} and {@link Name} using the
- * {@link SequencerContext#getValueFactories() factories} and calling {@link #setProperty(Path, Name, Object...)}.
+ * {@link StreamSequencerContext#getValueFactories() factories} and calling {@link #setProperty(Path, Name, Object...)}.
* </p>
*
* @param nodePath the path to the node containing the property; may not be null
@@ -58,7 +58,7 @@
* Set the supplied reference on the supplied node.
* <p>
* This method is provided as a convenience, but it identical to creating a {@link Path} and {@link Name} using the
- * {@link SequencerContext#getValueFactories() factories} and calling {@link #setProperty(Path, Name, Object...)}.
+ * {@link StreamSequencerContext#getValueFactories() factories} and calling {@link #setProperty(Path, Name, Object...)}.
* </p>
*
* @param nodePath the path to the node containing the property; may not be null
@@ -73,7 +73,7 @@
/**
* Set the supplied property on the supplied node.
* <p>
- * The {@link SequencerContext#getValueFactories() value factories} should be used to create paths, names, and values. These
+ * The {@link StreamSequencerContext#getValueFactories() value factories} should be used to create paths, names, and values. These
* factories can be used to create new values or convert values from one property type to another. (Note that each of the
* factories have methods that create values from all of the property types.)
* </p>
Modified: trunk/dna-graph/src/main/java/org/jboss/dna/graph/sequencer/StreamSequencer.java
===================================================================
--- trunk/dna-graph/src/main/java/org/jboss/dna/graph/sequencer/StreamSequencer.java 2009-05-20 20:32:08 UTC (rev 915)
+++ trunk/dna-graph/src/main/java/org/jboss/dna/graph/sequencer/StreamSequencer.java 2009-05-20 21:38:18 UTC (rev 916)
@@ -52,5 +52,5 @@
*/
void sequence( InputStream stream,
SequencerOutput output,
- SequencerContext context );
+ StreamSequencerContext context );
}
Copied: trunk/dna-graph/src/main/java/org/jboss/dna/graph/sequencer/StreamSequencerContext.java (from rev 886, trunk/dna-graph/src/main/java/org/jboss/dna/graph/sequencer/SequencerContext.java)
===================================================================
--- trunk/dna-graph/src/main/java/org/jboss/dna/graph/sequencer/StreamSequencerContext.java (rev 0)
+++ trunk/dna-graph/src/main/java/org/jboss/dna/graph/sequencer/StreamSequencerContext.java 2009-05-20 21:38:18 UTC (rev 916)
@@ -0,0 +1,112 @@
+/*
+ * 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.sequencer;
+
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+import org.jboss.dna.common.collection.Problems;
+import org.jboss.dna.common.collection.SimpleProblems;
+import org.jboss.dna.graph.ExecutionContext;
+import org.jboss.dna.graph.property.Name;
+import org.jboss.dna.graph.property.Path;
+import org.jboss.dna.graph.property.Property;
+
+/**
+ * @author John Verhaeg
+ */
+public class StreamSequencerContext extends ExecutionContext {
+
+ private final Path inputPath;
+ private final Map<Name, Property> inputPropertiesByName;
+ private final Set<Property> inputProperties;
+ private final Problems problems;
+ private final String mimeType;
+
+ public StreamSequencerContext( ExecutionContext context,
+ Path inputPath,
+ Set<Property> inputProperties,
+ String mimeType,
+ Problems problems ) {
+ super(context);
+ this.inputPath = inputPath;
+ this.inputProperties = inputProperties != null ? new HashSet<Property>(inputProperties) : new HashSet<Property>();
+ this.mimeType = mimeType;
+ this.problems = problems != null ? problems : new SimpleProblems();
+ Map<Name, Property> inputPropertiesByName = new HashMap<Name, Property>();
+ for (Property property : this.inputProperties) {
+ inputPropertiesByName.put(property.getName(), property);
+ }
+ this.inputPropertiesByName = Collections.unmodifiableMap(inputPropertiesByName);
+ }
+
+ /**
+ * Return the path of the input node containing the content being sequenced.
+ *
+ * @return input node's path.
+ */
+ public Path getInputPath() {
+ return inputPath;
+ }
+
+ /**
+ * Return the set of properties from the input node containing the content being sequenced.
+ *
+ * @return the input node's properties; never <code>null</code>.
+ */
+ public Set<Property> getInputProperties() {
+ return inputProperties;
+ }
+
+ /**
+ * Return the property with the supplied name from the input node containing the content being sequenced.
+ *
+ * @param name
+ * @return the input node property, or <code>null</code> if none exists.
+ */
+ public Property getInputProperty( Name name ) {
+ return inputPropertiesByName.get(name);
+ }
+
+ /**
+ * Return the MIME-type of the content being sequenced.
+ *
+ * @return the MIME-type
+ */
+ public String getMimeType() {
+ return this.mimeType;
+ }
+
+ /**
+ * Get an interface that can be used to record various problems, warnings, and errors that are not extreme enough to warrant
+ * throwing exceptions.
+ *
+ * @return the interface for recording problems; never null
+ */
+ public Problems getProblems() {
+ return this.problems;
+ }
+}
Modified: trunk/dna-graph/src/main/java/org/jboss/dna/graph/sequencer/package-info.java
===================================================================
--- trunk/dna-graph/src/main/java/org/jboss/dna/graph/sequencer/package-info.java 2009-05-20 20:32:08 UTC (rev 915)
+++ trunk/dna-graph/src/main/java/org/jboss/dna/graph/sequencer/package-info.java 2009-05-20 21:38:18 UTC (rev 916)
@@ -29,7 +29,7 @@
* <p>The {@link StreamSequencer} interface is a special form of sequencer that processes information coming
* through an {@link java.io.InputStream}. Implementations are responsible for processing the content and generating
* structured content using the supplied {@link SequencerOutput} interface. Additional details about the information
- * being sequenced is available in the supplied {@link SequencerContext}.
+ * being sequenced is available in the supplied {@link StreamSequencerContext}.
* </p>
*/
Modified: trunk/dna-graph/src/test/java/org/jboss/dna/graph/sequencer/MockSequencerContext.java
===================================================================
--- trunk/dna-graph/src/test/java/org/jboss/dna/graph/sequencer/MockSequencerContext.java 2009-05-20 20:32:08 UTC (rev 915)
+++ trunk/dna-graph/src/test/java/org/jboss/dna/graph/sequencer/MockSequencerContext.java 2009-05-20 21:38:18 UTC (rev 916)
@@ -31,7 +31,7 @@
* @author John Verhaeg
*/
@Immutable
-public class MockSequencerContext extends SequencerContext {
+public class MockSequencerContext extends StreamSequencerContext {
public MockSequencerContext() {
super(new ExecutionContext(), null, null, null, new SimpleProblems());
Modified: trunk/dna-graph/src/test/java/org/jboss/dna/graph/sequencer/MockSequencerOutput.java
===================================================================
--- trunk/dna-graph/src/test/java/org/jboss/dna/graph/sequencer/MockSequencerOutput.java 2009-05-20 20:32:08 UTC (rev 915)
+++ trunk/dna-graph/src/test/java/org/jboss/dna/graph/sequencer/MockSequencerOutput.java 2009-05-20 21:38:18 UTC (rev 916)
@@ -32,7 +32,7 @@
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.sequencer.SequencerContext;
+import org.jboss.dna.graph.sequencer.StreamSequencerContext;
import org.jboss.dna.graph.sequencer.SequencerOutput;
/**
@@ -43,14 +43,14 @@
public class MockSequencerOutput implements SequencerOutput {
private final Map<Path, Map<Name, Property>> propertiesByPath;
- private final SequencerContext context;
+ private final StreamSequencerContext context;
private final LinkedList<Path> nodePathsInCreationOrder;
- public MockSequencerOutput( SequencerContext context ) {
+ public MockSequencerOutput( StreamSequencerContext context ) {
this(context, false);
}
- public MockSequencerOutput( SequencerContext context,
+ public MockSequencerOutput( StreamSequencerContext context,
boolean recordOrderOfNodeCreation ) {
this.context = context;
this.propertiesByPath = new HashMap<Path, Map<Name, Property>>();
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-05-20 20:32:08 UTC (rev 915)
+++ trunk/dna-repository/src/main/java/org/jboss/dna/repository/DnaEngine.java 2009-05-20 21:38:18 UTC (rev 916)
@@ -56,9 +56,6 @@
import org.jboss.dna.repository.sequencer.SequencerConfig;
import org.jboss.dna.repository.sequencer.SequencingService;
import org.jboss.dna.repository.service.AdministeredService;
-import org.jboss.dna.repository.util.JcrExecutionContext;
-import org.jboss.dna.repository.util.SessionFactory;
-import org.jboss.dna.repository.util.SimpleSessionFactory;
/**
* A single instance of the DNA services, which is obtained after setting up the {@link DnaConfiguration#build() configuration}.
@@ -76,7 +73,6 @@
private final ExecutionContext context;
private final List<AdministeredService> services;
- private final SessionFactory jcrSessionFactory;
private final RepositoryService repositoryService;
private final ObservationService observationService;
private final SequencingService sequencingService;
@@ -111,10 +107,9 @@
// Create the sequencing service ...
executorService = new ScheduledThreadPoolExecutor(10); // Use a magic number for now
sequencingService = new SequencingService();
- jcrSessionFactory = createSessionFactory();
- JcrExecutionContext jcrContext = new JcrExecutionContext(context, jcrSessionFactory, "");
- sequencingService.setExecutionContext(jcrContext);
+ sequencingService.setExecutionContext(context);
sequencingService.setExecutorService(executorService);
+ sequencingService.setRepositoryLibrary(repositoryService.getRepositorySourceManager());
for (SequencerConfig sequencerConfig : scanner.getSequencingConfigurations()) {
sequencingService.addSequencer(sequencerConfig);
}
@@ -137,15 +132,6 @@
}
/**
- * Method that can be overridden in subclasses to create (and populate) the SessionFactory used by the sequencing service.
- *
- * @return a session factory, which may not be null
- */
- protected SessionFactory createSessionFactory() {
- return new SimpleSessionFactory();
- }
-
- /**
* Get the problems that were encountered when setting up this engine from the configuration.
*
* @return the problems, which may be empty but will never be null
Modified: trunk/dna-repository/src/main/java/org/jboss/dna/repository/DnaLexicon.java
===================================================================
--- trunk/dna-repository/src/main/java/org/jboss/dna/repository/DnaLexicon.java 2009-05-20 20:32:08 UTC (rev 915)
+++ trunk/dna-repository/src/main/java/org/jboss/dna/repository/DnaLexicon.java 2009-05-20 21:38:18 UTC (rev 916)
@@ -38,6 +38,7 @@
public static final Name SEQUENCERS = new BasicName(Namespace.URI, "sequencers");
public static final Name SEQUENCER = new BasicName(Namespace.URI, "sequencer");
public static final Name PATH_EXPRESSIONS = new BasicName(Namespace.URI, "pathExpressions");
+ public static final Name JNDI_NAME = new BasicName(Namespace.URI, "jndiName");
public static final Name MIME_TYPE_DETECTORS = new BasicName(Namespace.URI, "mimeTypeDetectors");
public static final Name MIME_TYPE_DETECTOR = new BasicName(Namespace.URI, "mimeTypeDetector");
public static final Name OPTIONS = new BasicName(Namespace.URI, "options");
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-05-20 20:32:08 UTC (rev 915)
+++ trunk/dna-repository/src/main/java/org/jboss/dna/repository/RepositoryService.java 2009-05-20 21:38:18 UTC (rev 916)
@@ -235,7 +235,6 @@
* @param problems the problems container in which any problems should be reported; never null
* @return the repository source instance, or null if it could not be created
*/
- @SuppressWarnings( "null" )
protected RepositorySource createRepositorySource( Path path,
Map<Name, Property> properties,
Problems problems ) {
Modified: trunk/dna-repository/src/main/java/org/jboss/dna/repository/observation/NodeChange.java
===================================================================
--- trunk/dna-repository/src/main/java/org/jboss/dna/repository/observation/NodeChange.java 2009-05-20 20:32:08 UTC (rev 915)
+++ trunk/dna-repository/src/main/java/org/jboss/dna/repository/observation/NodeChange.java 2009-05-20 21:38:18 UTC (rev 916)
@@ -35,6 +35,7 @@
@Immutable
public class NodeChange {
+ private final String repositorySourceName;
private final String repositoryWorkspaceName;
private final String absolutePath;
private final int eventTypes;
@@ -42,9 +43,11 @@
private final Set<String> removedProperties;
private final int hc;
- public NodeChange( String repositoryWorkspaceName, String absolutePath, int eventTypes, Set<String> modifiedProperties, Set<String> removedProperties ) {
+ public NodeChange( String repositorySourceName, String repositoryWorkspaceName, String absolutePath, int eventTypes, Set<String> modifiedProperties, Set<String> removedProperties ) {
+ assert repositorySourceName != null;
assert repositoryWorkspaceName != null;
assert absolutePath != null;
+ this.repositorySourceName = repositorySourceName;
this.repositoryWorkspaceName = repositoryWorkspaceName;
this.absolutePath = absolutePath.trim();
this.hc = HashCode.compute(this.repositoryWorkspaceName, this.absolutePath);
@@ -63,6 +66,13 @@
}
/**
+ * @return repositorySourceName
+ */
+ public String getRepositorySourceName() {
+ return this.repositorySourceName;
+ }
+
+ /**
* @return repositoryWorkspaceName
*/
public String getRepositoryWorkspaceName() {
Modified: trunk/dna-repository/src/main/java/org/jboss/dna/repository/observation/NodeChanges.java
===================================================================
--- trunk/dna-repository/src/main/java/org/jboss/dna/repository/observation/NodeChanges.java 2009-05-20 20:32:08 UTC (rev 915)
+++ trunk/dna-repository/src/main/java/org/jboss/dna/repository/observation/NodeChanges.java 2009-05-20 21:38:18 UTC (rev 916)
@@ -44,7 +44,7 @@
*/
public class NodeChanges implements Iterable<NodeChange> {
- public static NodeChanges create( final String repositoryWorkspaceName, Iterable<Event> events ) throws RepositoryException {
+ public static NodeChanges create( final String repositorySourceName, final String repositoryWorkspaceName, Iterable<Event> events ) throws RepositoryException {
Map<String, NodeChangeDetails> detailsByNodePath = new HashMap<String, NodeChangeDetails>();
// Process each of the events, extracting the node path and property details for each ...
for (Event event : events) {
@@ -101,7 +101,7 @@
// Create the node changes ...
List<NodeChange> result = new ArrayList<NodeChange>(detailsByNodePath.size());
for (NodeChangeDetails detail : detailsByNodePath.values()) {
- NodeChange change = new NodeChange(repositoryWorkspaceName, detail.getNodePath(), detail.getEventTypes(), detail.getModifiedProperties(), detail.getRemovedProperties());
+ NodeChange change = new NodeChange(repositorySourceName, repositoryWorkspaceName, detail.getNodePath(), detail.getEventTypes(), detail.getModifiedProperties(), detail.getRemovedProperties());
result.add(change);
}
return new NodeChanges(result);
Modified: trunk/dna-repository/src/main/java/org/jboss/dna/repository/observation/ObservationService.java
===================================================================
--- trunk/dna-repository/src/main/java/org/jboss/dna/repository/observation/ObservationService.java 2009-05-20 20:32:08 UTC (rev 915)
+++ trunk/dna-repository/src/main/java/org/jboss/dna/repository/observation/ObservationService.java 2009-05-20 21:38:18 UTC (rev 916)
@@ -235,11 +235,11 @@
}
/**
- * Monitor the supplied workspace for events of the given type on any node at or under the supplied path.
+ * Monitor the supplied workspace in the given repository for events of the given type on any node at or under the supplied
+ * path.
* <p>
* Monitoring is accomplished by registering a listener on the workspace, so this monitoring only has access to the
- * information that visible to the session created by the {@link #getSessionFactory() session factory} for the given
- * repository and workspace name.
+ * information that is available in the given repository and workspace name.
* </p>
* <p>
* The listener returned from this method is not managed by this SequencingService instance. If the listener is no longer
@@ -250,41 +250,40 @@
* </p>
* <p>
* The set of events that are monitored can be filtered by specifying restrictions based on characteristics of the node
- * associated with the event. In the case of event types {@link Event#NODE_ADDED NODE_ADDED} and
- * {@link Event#NODE_REMOVED NODE_REMOVED}, the node associated with an event is the node at (or formerly at) the path
- * returned by {@link Event#getPath() Event.getPath()}. In the case of event types
- * {@link Event#PROPERTY_ADDED PROPERTY_ADDED}, {@link Event#PROPERTY_REMOVED PROPERTY_REMOVED} and
- * {@link Event#PROPERTY_CHANGED PROPERTY_CHANGED}, the node associated with an event is the parent node of the property at
- * (or formerly at) the path returned by <code>Event.getPath</code>:
+ * associated with the event. In the case of event types {@link Event#NODE_ADDED NODE_ADDED} and {@link Event#NODE_REMOVED
+ * NODE_REMOVED}, the node associated with an event is the node at (or formerly at) the path returned by
+ * {@link Event#getPath() Event.getPath()}. In the case of event types {@link Event#PROPERTY_ADDED PROPERTY_ADDED},
+ * {@link Event#PROPERTY_REMOVED PROPERTY_REMOVED} and {@link Event#PROPERTY_CHANGED PROPERTY_CHANGED}, the node associated
+ * with an event is the parent node of the property at (or formerly at) the path returned by <code>Event.getPath</code>:
* <ul>
- * <li> <code>absolutePath</code>, <code>isDeep</code>: Only events whose associated node is at
- * <code>absolutePath</code> (or within its subtree, if <code>isDeep</code> is <code>true</code>) will be received. It
- * is permissible to register a listener for a path where no node currently exists. </li>
+ * <li> <code>absolutePath</code>, <code>isDeep</code>: Only events whose associated node is at <code>absolutePath</code> (or
+ * within its subtree, if <code>isDeep</code> is <code>true</code>) will be received. It is permissible to register a listener
+ * for a path where no node currently exists.</li>
* <li> <code>uuids</code>: Only events whose associated node has one of the UUIDs in this list will be received. If his
- * parameter is <code>null</code> then no UUID-related restriction is placed on events received. </li>
+ * parameter is <code>null</code> then no UUID-related restriction is placed on events received.</li>
* <li> <code>nodeTypeNames</code>: Only events whose associated node has one of the node types (or a subtype of one of the
- * node types) in this list will be received. If this parameter is <code>null</code> then no node type-related restriction
- * is placed on events received. </li>
+ * node types) in this list will be received. If this parameter is <code>null</code> then no node type-related restriction is
+ * placed on events received.</li>
* </ul>
* The restrictions are "ANDed" together. In other words, for a particular node to be "listened to" it must meet all the
* restrictions.
* </p>
* <p>
- * Additionally, if <code>noLocal</code> is <code>true</code>, then events generated by the session through which the
- * listener was registered are ignored. Otherwise, they are not ignored.
+ * Additionally, if <code>noLocal</code> is <code>true</code>, then events generated by the session through which the listener
+ * was registered are ignored. Otherwise, they are not ignored.
* </p>
* <p>
* The filters of an already-registered {@link WorkspaceListener} can be changed at runtime by changing the attributes and
* {@link WorkspaceListener#reregister() registering}.
* </p>
*
- * @param repositoryWorkspaceName the name to be used with the session factory to obtain a session to the repository and
- * workspace that is to be monitored
+ * @param repositorySourceName the name of the repository source to be monitored
+ * @param repositoryWorkspaceName the name of the workspace within the monitored repository
* @param absolutePath the absolute path of the node at or below which changes are to be monitored; may be null if all nodes
* in the workspace are to be monitored
* @param eventTypes the bitmask of the {@link Event} types that are to be monitored
- * @param isDeep true if events below the node given by the <code>absolutePath</code> or by the <code>uuids</code> are to
- * be processed, or false if only the events at the node
+ * @param isDeep true if events below the node given by the <code>absolutePath</code> or by the <code>uuids</code> are to be
+ * processed, or false if only the events at the node
* @param uuids array of UUIDs of nodes that are to be monitored; may be null or empty if the UUIDs are not known
* @param nodeTypeNames array of node type names that are to be monitored; may be null or empty if the monitoring has no node
* type restrictions
@@ -293,15 +292,16 @@
* @return the listener that was created and registered to perform the monitoring
* @throws RepositoryException if there is a problem registering the listener
*/
- public WorkspaceListener monitor( String repositoryWorkspaceName,
+ public WorkspaceListener monitor( String repositorySourceName,
+ String repositoryWorkspaceName,
String absolutePath,
int eventTypes,
boolean isDeep,
String[] uuids,
String[] nodeTypeNames,
boolean noLocal ) throws RepositoryException {
- WorkspaceListener listener = new WorkspaceListener(repositoryWorkspaceName, eventTypes, absolutePath, isDeep, uuids,
- nodeTypeNames, noLocal);
+ WorkspaceListener listener = new WorkspaceListener(repositorySourceName, repositoryWorkspaceName, eventTypes,
+ absolutePath, isDeep, uuids, nodeTypeNames, noLocal);
listener.register();
this.workspaceListeners.add(listener);
return listener;
@@ -309,11 +309,10 @@
/**
* Monitor the supplied workspace for {@link WorkspaceListener#DEFAULT_EVENT_TYPES default event types} on any node at or
- * under the supplied path.
+ * under the supplied path in the named repository.
* <p>
* Monitoring is accomplished by registering a listener on the workspace, so this monitoring only has access to the
- * information that visible to the session created by the {@link #getSessionFactory() session factory} for the given
- * repository and workspace name.
+ * information that is available in the given repository and workspace name.
* </p>
* <p>
* The listener returned from this method is not managed by this SequencingService instance. If the listener is no longer
@@ -321,8 +320,8 @@
* workspace and garbage collected.
* </p>
*
- * @param repositoryWorkspaceName the name to be used with the session factory to obtain a session to the repository and
- * workspace that is to be monitored
+ * @param repositorySourceName the name of the repository source to be monitored
+ * @param repositoryWorkspaceName the name of the workspace within the monitored repository
* @param absolutePath the absolute path of the node at or below which changes are to be monitored; may be null if all nodes
* in the workspace are to be monitored
* @param nodeTypeNames the names of the node types that are to be monitored; may be null or empty if the monitoring has no
@@ -330,10 +329,12 @@
* @return the listener that was created and registered to perform the monitoring
* @throws RepositoryException if there is a problem registering the listener
*/
- public WorkspaceListener monitor( String repositoryWorkspaceName,
+ public WorkspaceListener monitor( String repositorySourceName,
+ String repositoryWorkspaceName,
String absolutePath,
String... nodeTypeNames ) throws RepositoryException {
- return monitor(repositoryWorkspaceName,
+ return monitor(repositorySourceName,
+ repositoryWorkspaceName,
absolutePath,
WorkspaceListener.DEFAULT_EVENT_TYPES,
WorkspaceListener.DEFAULT_IS_DEEP,
@@ -343,11 +344,10 @@
}
/**
- * Monitor the supplied workspace for the supplied event types on any node in the workspace.
+ * Monitor the supplied workspace in the named repository for the supplied event types on any node in the workspace.
* <p>
* Monitoring is accomplished by registering a listener on the workspace, so this monitoring only has access to the
- * information that visible to the session created by the {@link #getSessionFactory() session factory} for the given
- * repository and workspace name.
+ * information that is available in the given repository and workspace name.
* </p>
* <p>
* The listener returned from this method is not managed by this SequencingService instance. If the listener is no longer
@@ -355,18 +355,20 @@
* workspace and garbage collected.
* </p>
*
- * @param repositoryWorkspaceName the name to be used with the session factory to obtain a session to the repository and
- * workspace that is to be monitored
+ * @param repositorySourceName the name of the repository source to be monitored
+ * @param repositoryWorkspaceName the name of the workspace within the monitored repository
* @param eventTypes the bitmask of the {@link Event} types that are to be monitored
* @param nodeTypeNames the names of the node types that are to be monitored; may be null or empty if the monitoring has no
* node type restrictions
* @return the listener that was created and registered to perform the monitoring
* @throws RepositoryException if there is a problem registering the listener
*/
- public WorkspaceListener monitor( String repositoryWorkspaceName,
+ public WorkspaceListener monitor( String repositorySourceName,
+ String repositoryWorkspaceName,
int eventTypes,
String... nodeTypeNames ) throws RepositoryException {
- return monitor(repositoryWorkspaceName,
+ return monitor(repositorySourceName,
+ repositoryWorkspaceName,
WorkspaceListener.DEFAULT_ABSOLUTE_PATH,
eventTypes,
WorkspaceListener.DEFAULT_IS_DEEP,
@@ -418,9 +420,10 @@
// Now create the node change events ...
List<NodeChangeListener> nodeChangeListeners = this.nodeChangeListeners; // use one consistent snapshot
if (!nodeChangeListeners.isEmpty()) {
+ final String repositorySourceName = listener.getRepositorySourceName();
final String repositoryWorkspaceName = listener.getRepositoryWorkspaceName();
try {
- NodeChanges nodeChanges = NodeChanges.create(repositoryWorkspaceName, events);
+ NodeChanges nodeChanges = NodeChanges.create(repositorySourceName, repositoryWorkspaceName, events);
// And notify the node change listeners ...
int nodeChangeCount = nodeChanges.size();
@@ -521,6 +524,7 @@
| Event.PROPERTY_CHANGED /* |Event.PROPERTY_REMOVED */;
public static final String DEFAULT_ABSOLUTE_PATH = "/";
+ private final String repositorySourceName;
private final String repositoryWorkspaceName;
private final Set<String> uuids;
private final Set<String> nodeTypeNames;
@@ -531,13 +535,17 @@
@GuardedBy( "this" )
private transient Session session;
- protected WorkspaceListener( String repositoryWorkspaceName,
+ protected WorkspaceListener( String repositorySourceName,
+ String repositoryWorkspaceName,
int eventTypes,
String absPath,
boolean isDeep,
String[] uuids,
String[] nodeTypeNames,
boolean noLocal ) {
+ assert repositorySourceName != null;
+
+ this.repositorySourceName = repositorySourceName;
this.repositoryWorkspaceName = repositoryWorkspaceName;
this.eventTypes = eventTypes;
this.deep = isDeep;
@@ -562,6 +570,13 @@
}
/**
+ * @return repositorySourceName
+ */
+ public String getRepositorySourceName() {
+ return this.repositorySourceName;
+ }
+
+ /**
* @return repositoryWorkspaceName
*/
public String getRepositoryWorkspaceName() {
Modified: trunk/dna-repository/src/main/java/org/jboss/dna/repository/sequencer/Sequencer.java
===================================================================
--- trunk/dna-repository/src/main/java/org/jboss/dna/repository/sequencer/Sequencer.java 2009-05-20 20:32:08 UTC (rev 915)
+++ trunk/dna-repository/src/main/java/org/jboss/dna/repository/sequencer/Sequencer.java 2009-05-20 21:38:18 UTC (rev 916)
@@ -24,17 +24,14 @@
package org.jboss.dna.repository.sequencer;
import java.util.Set;
-import javax.jcr.Node;
-import javax.jcr.RepositoryException;
-import javax.jcr.Session;
import net.jcip.annotations.ThreadSafe;
import org.jboss.dna.common.collection.Problems;
import org.jboss.dna.common.component.Component;
+import org.jboss.dna.graph.Node;
+import org.jboss.dna.graph.io.Destination;
import org.jboss.dna.repository.observation.NodeChange;
-import org.jboss.dna.repository.observation.NodeChangeListener;
import org.jboss.dna.repository.observation.NodeChanges;
import org.jboss.dna.repository.observation.ObservationService;
-import org.jboss.dna.repository.util.JcrExecutionContext;
import org.jboss.dna.repository.util.RepositoryNodePath;
/**
@@ -52,12 +49,11 @@
/**
* Execute the sequencing operation on the supplied node, which has recently been created or changed. The implementation of
- * this method is responsible for {@link JcrExecutionContext#getSessionFactory() getting sessions}, modifying the appropriate
- * nodes, {@link Session#save() saving} any changes made by this sequencer, and {@link Session#logout() closing} all sessions
- * (and any other acquired resources), even in the case of exceptions.
+ * this method is responsible for modifying the appropriate nodes and {@link Destination#submit() saving} any changes made by
+ * this sequencer, and closing any other acquired resources, even in the case of exceptions.
* <p>
* The {@link SequencingService} determines the sequencers that should be executed by monitoring the changes to one or more
- * workspaces (it is a {@link NodeChangeListener} registered with the {@link ObservationService}). Changes in those workspaces
+ * workspaces (it is a listener registered with the {@link ObservationService}). Changes in those workspaces
* are aggregated for each transaction, and organized into {@link NodeChanges changes for each node}. The SequencingService
* then determines for each {@link NodeChange set of changes to a node} the set of full paths to the properties that have
* changed and whether those paths {@link SequencerPathExpression#matcher(String) match} the sequencer's
@@ -76,17 +72,16 @@
* @param changes the immutable summary of changes that occurred on the <code>input</code> node within the transaction; never
* null
* @param outputPaths the paths to the nodes where the sequencing content should be placed; never null and never empty, but
- * the set may contain paths for non-existant nodes or may reference the <code>input</code> node
+ * the set may contain paths for non-existent nodes or may reference the <code>input</code> node
* @param context the context in which this sequencer is executing; never null
* @param problems the interface used for recording problems; never null
- * @throws RepositoryException if there is a problem while working with the repository
* @throws SequencerException if there is an error in this sequencer
*/
void execute( Node input,
String sequencedPropertyName,
NodeChange changes,
Set<RepositoryNodePath> outputPaths,
- JcrExecutionContext context,
- Problems problems ) throws RepositoryException, SequencerException;
+ SequencerContext context,
+ Problems problems ) throws SequencerException;
}
Added: trunk/dna-repository/src/main/java/org/jboss/dna/repository/sequencer/SequencerContext.java
===================================================================
--- trunk/dna-repository/src/main/java/org/jboss/dna/repository/sequencer/SequencerContext.java (rev 0)
+++ trunk/dna-repository/src/main/java/org/jboss/dna/repository/sequencer/SequencerContext.java 2009-05-20 21:38:18 UTC (rev 916)
@@ -0,0 +1,57 @@
+package org.jboss.dna.repository.sequencer;
+
+import net.jcip.annotations.NotThreadSafe;
+import org.jboss.dna.graph.ExecutionContext;
+import org.jboss.dna.graph.Graph;
+import org.jboss.dna.graph.io.Destination;
+import org.jboss.dna.graph.io.GraphBatchDestination;
+
+/**
+ * The sequencer context represents the complete context of a sequencer invocation, including the execution context
+ * (which contains JAAS credentials, namespace mappings, and value factories) and the I/O environment for writing
+ * output.
+ *
+ * <p>
+ * This class is not thread safe due to its use of {@link Destination a destination}.
+ * </p>
+ */
+@NotThreadSafe
+public class SequencerContext {
+
+ private final ExecutionContext executionContext;
+ private final Graph graph;
+ private final Destination destination;
+
+ public SequencerContext( ExecutionContext executionContext,
+ Graph graph ) {
+ super();
+
+ assert executionContext != null;
+ assert graph != null;
+
+ this.executionContext = executionContext;
+ this.graph = graph;
+ this.destination = new GraphBatchDestination(graph.batch());
+ }
+
+ /**
+ * Returns the execution context under which this sequencer context operates
+ * @return the execution context under which this sequencer context operates
+ */
+ public ExecutionContext getExecutionContext() {
+ return executionContext;
+ }
+
+ /**
+ * Returns the I/O environment in which this sequencer context operates
+ * @return the I/O environment in which this sequencer context operates
+ */
+ public Destination getDestination() {
+ return destination;
+ }
+
+ Graph graph() {
+ return this.graph;
+ }
+
+}
Property changes on: trunk/dna-repository/src/main/java/org/jboss/dna/repository/sequencer/SequencerContext.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Modified: trunk/dna-repository/src/main/java/org/jboss/dna/repository/sequencer/SequencerOutputMap.java
===================================================================
--- trunk/dna-repository/src/main/java/org/jboss/dna/repository/sequencer/SequencerOutputMap.java 2009-05-20 20:32:08 UTC (rev 915)
+++ trunk/dna-repository/src/main/java/org/jboss/dna/repository/sequencer/SequencerOutputMap.java 2009-05-20 21:38:18 UTC (rev 916)
@@ -50,18 +50,14 @@
@NotThreadSafe
public class SequencerOutputMap implements SequencerOutput, Iterable<SequencerOutputMap.Entry> {
- private static final String JCR_NAME_PROPERTY_NAME = "jcr:name";
-
private final Map<Path, List<PropertyValue>> data;
private transient boolean valuesSorted = true;
private final ValueFactories factories;
- private final Name jcrName;
public SequencerOutputMap( ValueFactories factories ) {
CheckArg.isNotNull(factories, "factories");
this.data = new HashMap<Path, List<PropertyValue>>();
this.factories = factories;
- this.jcrName = this.factories.getNameFactory().create(JCR_NAME_PROPERTY_NAME);
}
ValueFactories getFactories() {
@@ -76,8 +72,6 @@
Object... values ) {
CheckArg.isNotNull(nodePath, "nodePath");
CheckArg.isNotNull(propertyName, "property");
- // Ignore the "jcr:name" property, as that's handled by the path ...
- if (this.jcrName.equals(propertyName)) return;
// Find or create the entry for this node ...
List<PropertyValue> properties = this.data.get(nodePath);
Modified: trunk/dna-repository/src/main/java/org/jboss/dna/repository/sequencer/SequencingService.java
===================================================================
--- trunk/dna-repository/src/main/java/org/jboss/dna/repository/sequencer/SequencingService.java 2009-05-20 20:32:08 UTC (rev 915)
+++ trunk/dna-repository/src/main/java/org/jboss/dna/repository/sequencer/SequencingService.java 2009-05-20 21:38:18 UTC (rev 916)
@@ -34,10 +34,6 @@
import java.util.concurrent.RejectedExecutionException;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicLong;
-import javax.jcr.Node;
-import javax.jcr.Repository;
-import javax.jcr.RepositoryException;
-import javax.jcr.Session;
import javax.jcr.observation.Event;
import net.jcip.annotations.Immutable;
import net.jcip.annotations.ThreadSafe;
@@ -48,18 +44,22 @@
import org.jboss.dna.common.util.CheckArg;
import org.jboss.dna.common.util.HashCode;
import org.jboss.dna.common.util.Logger;
+import org.jboss.dna.graph.ExecutionContext;
+import org.jboss.dna.graph.Graph;
+import org.jboss.dna.graph.Node;
+import org.jboss.dna.graph.connector.RepositorySource;
import org.jboss.dna.repository.RepositoryI18n;
+import org.jboss.dna.repository.RepositoryLibrary;
import org.jboss.dna.repository.observation.NodeChange;
import org.jboss.dna.repository.observation.NodeChangeListener;
import org.jboss.dna.repository.observation.NodeChanges;
import org.jboss.dna.repository.service.AbstractServiceAdministrator;
import org.jboss.dna.repository.service.AdministeredService;
import org.jboss.dna.repository.service.ServiceAdministrator;
-import org.jboss.dna.repository.util.JcrExecutionContext;
import org.jboss.dna.repository.util.RepositoryNodePath;
/**
- * A sequencing system is used to monitor changes in the content of {@link Repository JCR repositories} and to sequence the
+ * A sequencing system is used to monitor changes in the content of DNA repositories and to sequence the
* content to extract or to generate structured information.
*
* @author Randall Hauch
@@ -198,11 +198,12 @@
}
- private JcrExecutionContext executionContext;
+ private ExecutionContext executionContext;
private SequencerLibrary sequencerLibrary = new SequencerLibrary();
private Selector sequencerSelector = DEFAULT_SEQUENCER_SELECTOR;
private NodeFilter nodeFilter = DEFAULT_NODE_FILTER;
private ExecutorService executorService;
+ private RepositoryLibrary repositoryLibrary;
private final Statistics statistics = new Statistics();
private final Administrator administrator = new Administrator();
@@ -286,14 +287,14 @@
/**
* @return executionContext
*/
- public JcrExecutionContext getExecutionContext() {
+ public ExecutionContext getExecutionContext() {
return this.executionContext;
}
/**
* @param executionContext Sets executionContext to the specified value.
*/
- public void setExecutionContext( JcrExecutionContext executionContext ) {
+ public void setExecutionContext( ExecutionContext executionContext ) {
CheckArg.isNotNull(executionContext, "execution context");
if (this.getAdministrator().isStarted()) {
throw new IllegalStateException(RepositoryI18n.unableToChangeExecutionContextWhileRunning.text());
@@ -303,6 +304,19 @@
}
/**
+ * Get the repository library to be used for repository lookup
+ *
+ * @return the repository library
+ */
+ public RepositoryLibrary getRepositoryLibrary() {
+ return this.repositoryLibrary;
+ }
+
+ public void setRepositoryLibrary(RepositoryLibrary repositoryLibrary) {
+ this.repositoryLibrary = repositoryLibrary;
+ }
+
+ /**
* Get the executor service used to run the sequencers.
*
* @return the executor service
@@ -448,100 +462,88 @@
* @param changedNode the node to be processed.
*/
protected void processChangedNode( NodeChange changedNode ) {
- final JcrExecutionContext context = this.getExecutionContext();
+ final ExecutionContext context = this.getExecutionContext();
final Logger logger = context.getLogger(getClass());
assert logger != null;
+
try {
+ final String repositorySourceName = changedNode.getRepositorySourceName();
final String repositoryWorkspaceName = changedNode.getRepositoryWorkspaceName();
- Session session = null;
- try {
- // Figure out which sequencers accept this path,
- // and track which output nodes should be passed to each sequencer...
- final String nodePath = changedNode.getAbsolutePath();
- Map<SequencerCall, Set<RepositoryNodePath>> sequencerCalls = new HashMap<SequencerCall, Set<RepositoryNodePath>>();
- List<Sequencer> allSequencers = this.sequencerLibrary.getInstances();
- List<Sequencer> sequencers = new ArrayList<Sequencer>(allSequencers.size());
- for (Sequencer sequencer : allSequencers) {
- final SequencerConfig config = sequencer.getConfiguration();
- for (SequencerPathExpression pathExpression : config.getPathExpressions()) {
- for (String propertyName : changedNode.getModifiedProperties()) {
- String path = nodePath + "/@" + propertyName;
- SequencerPathExpression.Matcher matcher = pathExpression.matcher(path);
- if (matcher.matches()) {
- // String selectedPath = matcher.getSelectedPath();
- RepositoryNodePath outputPath = RepositoryNodePath.parse(matcher.getOutputPath(),
- repositoryWorkspaceName);
- SequencerCall call = new SequencerCall(sequencer, propertyName);
- // Record the output path ...
- Set<RepositoryNodePath> outputPaths = sequencerCalls.get(call);
- if (outputPaths == null) {
- outputPaths = new HashSet<RepositoryNodePath>();
- sequencerCalls.put(call, outputPaths);
- }
- outputPaths.add(outputPath);
- sequencers.add(sequencer);
- break;
+
+ // Figure out which sequencers accept this path,
+ // and track which output nodes should be passed to each sequencer...
+ final String nodePath = changedNode.getAbsolutePath();
+ Map<SequencerCall, Set<RepositoryNodePath>> sequencerCalls = new HashMap<SequencerCall, Set<RepositoryNodePath>>();
+ List<Sequencer> allSequencers = this.sequencerLibrary.getInstances();
+ List<Sequencer> sequencers = new ArrayList<Sequencer>(allSequencers.size());
+ for (Sequencer sequencer : allSequencers) {
+ final SequencerConfig config = sequencer.getConfiguration();
+ for (SequencerPathExpression pathExpression : config.getPathExpressions()) {
+ for (String propertyName : changedNode.getModifiedProperties()) {
+ String path = nodePath + "/@" + propertyName;
+ SequencerPathExpression.Matcher matcher = pathExpression.matcher(path);
+ if (matcher.matches()) {
+ // String selectedPath = matcher.getSelectedPath();
+ RepositoryNodePath outputPath = RepositoryNodePath.parse(matcher.getOutputPath(),
+ repositorySourceName,
+ repositoryWorkspaceName);
+ SequencerCall call = new SequencerCall(sequencer, propertyName);
+ // Record the output path ...
+ Set<RepositoryNodePath> outputPaths = sequencerCalls.get(call);
+ if (outputPaths == null) {
+ outputPaths = new HashSet<RepositoryNodePath>();
+ sequencerCalls.put(call, outputPaths);
}
+ outputPaths.add(outputPath);
+ sequencers.add(sequencer);
+ break;
}
}
}
+ }
- Node node = null;
- if (!sequencers.isEmpty()) {
- // Create a session that we'll use for all sequencing ...
- session = context.getSessionFactory().createSession(repositoryWorkspaceName);
+ RepositorySource source = repositoryLibrary.getSource(repositorySourceName);
+ Graph graph = Graph.create(source, context);
+ Node node = null;
+ if (!sequencers.isEmpty()) {
- // Find the changed node ...
- String relPath = changedNode.getAbsolutePath().replaceAll("^/+", "");
- node = session.getRootNode().getNode(relPath);
+ // Find the changed node ...
+ String relPath = changedNode.getAbsolutePath().replaceAll("^/+", "");
+ node = graph.getNodeAt(relPath);
- // Figure out which sequencers should run ...
- sequencers = this.sequencerSelector.selectSequencers(sequencers, node, changedNode);
+ // Figure out which sequencers should run ...
+ sequencers = this.sequencerSelector.selectSequencers(sequencers, node, changedNode);
+ }
+ if (sequencers.isEmpty()) {
+ this.statistics.recordNodeSkipped();
+ if (logger.isDebugEnabled()) {
+ logger.trace("Skipping '{0}': no sequencers matched this condition", changedNode);
}
- if (sequencers.isEmpty()) {
- this.statistics.recordNodeSkipped();
- if (logger.isDebugEnabled()) {
- logger.trace("Skipping '{0}': no sequencers matched this condition", changedNode);
- }
- } else {
- // Run each of those sequencers ...
- for (Map.Entry<SequencerCall, Set<RepositoryNodePath>> entry : sequencerCalls.entrySet()) {
- final SequencerCall sequencerCall = entry.getKey();
- final Set<RepositoryNodePath> outputPaths = entry.getValue();
- final Sequencer sequencer = sequencerCall.getSequencer();
- final String sequencerName = sequencer.getConfiguration().getName();
- final String propertyName = sequencerCall.getSequencedPropertyName();
+ } else {
+ // Run each of those sequencers ...
+ for (Map.Entry<SequencerCall, Set<RepositoryNodePath>> entry : sequencerCalls.entrySet()) {
- // Get the paths to the nodes where the sequencer should write it's output ...
- assert outputPaths != null && outputPaths.size() != 0;
+ final SequencerCall sequencerCall = entry.getKey();
+ final Set<RepositoryNodePath> outputPaths = entry.getValue();
+ final Sequencer sequencer = sequencerCall.getSequencer();
+ final String sequencerName = sequencer.getConfiguration().getName();
+ final String propertyName = sequencerCall.getSequencedPropertyName();
- // Create a new execution context for each sequencer
- final SimpleProblems problems = new SimpleProblems();
- JcrExecutionContext sequencerContext = context.clone();
- try {
- sequencer.execute(node, propertyName, changedNode, outputPaths, sequencerContext, problems);
- } catch (RepositoryException e) {
- logger.error(e, RepositoryI18n.errorInRepositoryWhileSequencingNode, sequencerName, changedNode);
- } catch (SequencerException e) {
- logger.error(e, RepositoryI18n.errorWhileSequencingNode, sequencerName, changedNode);
- } finally {
- try {
- // Save the changes made by each sequencer ...
- if (session != null) session.save();
- } finally {
- // And always close the context.
- // This closes all sessions that may have been created by the sequencer.
- sequencerContext.close();
- }
- }
+ // Get the paths to the nodes where the sequencer should write it's output ...
+ assert outputPaths != null && outputPaths.size() != 0;
+
+ // Create a new execution context for each sequencer
+ final SimpleProblems problems = new SimpleProblems();
+ SequencerContext sequencerContext = new SequencerContext(context, graph);
+ try {
+ sequencer.execute(node, propertyName, changedNode, outputPaths, sequencerContext, problems);
+ sequencerContext.getDestination().submit();
+ } catch (SequencerException e) {
+ logger.error(e, RepositoryI18n.errorWhileSequencingNode, sequencerName, changedNode);
}
- this.statistics.recordNodeSequenced();
}
- } finally {
- if (session != null) session.logout();
+ this.statistics.recordNodeSequenced();
}
- } catch (RepositoryException e) {
- logger.error(e, RepositoryI18n.errorInRepositoryWhileFindingSequencersToRunAgainstNode, changedNode);
} catch (Throwable e) {
logger.error(e, RepositoryI18n.errorFindingSequencersToRunAgainstNode, changedNode);
}
Modified: trunk/dna-repository/src/main/java/org/jboss/dna/repository/sequencer/StreamSequencerAdapter.java
===================================================================
--- trunk/dna-repository/src/main/java/org/jboss/dna/repository/sequencer/StreamSequencerAdapter.java 2009-05-20 20:32:08 UTC (rev 915)
+++ trunk/dna-repository/src/main/java/org/jboss/dna/repository/sequencer/StreamSequencerAdapter.java 2009-05-20 21:38:18 UTC (rev 916)
@@ -23,38 +23,26 @@
*/
package org.jboss.dna.repository.sequencer;
+import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
-import java.math.BigDecimal;
-import java.util.Calendar;
import java.util.Collections;
-import java.util.Date;
import java.util.HashSet;
+import java.util.LinkedList;
+import java.util.List;
import java.util.Set;
-import javax.jcr.Node;
-import javax.jcr.PathNotFoundException;
-import javax.jcr.Property;
-import javax.jcr.PropertyIterator;
-import javax.jcr.PropertyType;
-import javax.jcr.RepositoryException;
-import javax.jcr.Session;
-import javax.jcr.Value;
import org.jboss.dna.common.collection.Problems;
-import org.jboss.dna.common.util.Logger;
-import org.jboss.dna.graph.ExecutionContext;
-import org.jboss.dna.graph.property.Binary;
-import org.jboss.dna.graph.property.DateTime;
-import org.jboss.dna.graph.property.Name;
-import org.jboss.dna.graph.property.NamespaceRegistry;
+import org.jboss.dna.graph.Node;
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.ValueFactories;
-import org.jboss.dna.graph.sequencer.SequencerContext;
import org.jboss.dna.graph.sequencer.StreamSequencer;
+import org.jboss.dna.graph.sequencer.StreamSequencerContext;
import org.jboss.dna.repository.RepositoryI18n;
import org.jboss.dna.repository.mimetype.MimeType;
import org.jboss.dna.repository.observation.NodeChange;
-import org.jboss.dna.repository.util.JcrExecutionContext;
import org.jboss.dna.repository.util.RepositoryNodePath;
/**
@@ -93,30 +81,33 @@
String sequencedPropertyName,
NodeChange changes,
Set<RepositoryNodePath> outputPaths,
- JcrExecutionContext execContext,
- Problems problems ) throws RepositoryException, SequencerException {
+ SequencerContext context,
+ Problems problems ) throws SequencerException {
// 'sequencedPropertyName' contains the name of the modified property on 'input' that resulted in the call to this
// sequencer.
// 'changes' contains all of the changes to this node that occurred in the transaction.
// 'outputPaths' contains the paths of the node(s) where this sequencer is to save it's data.
// Get the property that contains the data, given by 'propertyName' ...
- Property sequencedProperty = null;
- try {
- sequencedProperty = input.getProperty(sequencedPropertyName);
- } catch (PathNotFoundException e) {
- String msg = RepositoryI18n.unableToFindPropertyForSequencing.text(sequencedPropertyName, input.getPath());
- throw new SequencerException(msg, e);
+ Property sequencedProperty = input.getProperty(sequencedPropertyName);
+
+ if (sequencedProperty == null) {
+ String msg = RepositoryI18n.unableToFindPropertyForSequencing.text(sequencedPropertyName, input.getLocation());
+ throw new SequencerException(msg);
}
// Get the binary property with the image content, and build the image metadata from the image ...
- SequencerOutputMap output = new SequencerOutputMap(execContext.getValueFactories());
+ SequencerOutputMap output = new SequencerOutputMap(context.getExecutionContext().getValueFactories());
InputStream stream = null;
Throwable firstError = null;
try {
- stream = sequencedProperty.getStream();
- SequencerContext sequencerContext = createSequencerContext(input, sequencedProperty, execContext, problems);
- this.streamSequencer.sequence(stream, output, sequencerContext);
+ // Parallel the JCR lemma for converting objects into streams
+ stream = new ByteArrayInputStream(sequencedProperty.toString().getBytes());
+ StreamSequencerContext StreamSequencerContext = createStreamSequencerContext(input,
+ sequencedProperty,
+ context,
+ problems);
+ this.streamSequencer.sequence(stream, output, StreamSequencerContext);
} catch (Throwable t) {
// Record the error ...
firstError = t;
@@ -139,159 +130,94 @@
// Find each output node and save the image metadata there ...
for (RepositoryNodePath outputPath : outputPaths) {
- Session session = null;
- try {
- // Get the name of the repository workspace and the path to the output node
- final String repositoryWorkspaceName = outputPath.getRepositoryWorkspaceName();
- final String nodePath = outputPath.getNodePath();
+ // Get the name of the repository workspace and the path to the output node
+ final String repositoryWorkspaceName = outputPath.getWorkspaceName();
+ final String nodePath = outputPath.getNodePath();
- // Create a session to the repository where the data should be written ...
- session = execContext.getSessionFactory().createSession(repositoryWorkspaceName);
+ // Find or create the output node in this session ...
+ context.graph().useWorkspace(repositoryWorkspaceName);
- // Find or create the output node in this session ...
- Node outputNode = execContext.getTools().findOrCreateNode(session, nodePath);
+ buildPathTo(nodePath, context);
+ Node outputNode = context.graph().getNodeAt(nodePath);
- // Now save the image metadata to the output node ...
- if (saveOutput(outputNode, output, execContext)) {
- session.save();
- }
- } finally {
- // Always close the session ...
- if (session != null) session.logout();
- }
+ // Now save the image metadata to the output node ...
+ saveOutput(outputNode, output, context);
}
+
+ context.getDestination().submit();
}
/**
+ * Creates all nodes along the given node path if they are missing. Ensures that nodePath is a valid path to a node.
+ *
+ * @param nodePath the node path to create
+ * @param context the sequencer context under which it should be created
+ */
+ private void buildPathTo( String nodePath,
+ SequencerContext context ) {
+ PathFactory pathFactory = context.getExecutionContext().getValueFactories().getPathFactory();
+ Path targetPath = pathFactory.create(nodePath);
+
+ buildPathTo(targetPath, context);
+ }
+
+ /**
+ * Creates all nodes along the given node path if they are missing. Ensures that nodePath is a valid path to a node.
+ *
+ * @param nodePath the node path to create
+ * @param context the sequencer context under which it should be created
+ */
+ private void buildPathTo( Path targetPath,
+ SequencerContext context ) {
+ PathFactory pathFactory = context.getExecutionContext().getValueFactories().getPathFactory();
+
+ Path workingPath = pathFactory.createRootPath();
+ Path.Segment[] segments = targetPath.getSegmentsArray();
+ for (int i = 0; i < segments.length; i++) {
+ workingPath = pathFactory.create(workingPath, segments[i]);
+
+ context.graph().createIfMissing(workingPath);
+ }
+ }
+
+ /**
* Save the sequencing output to the supplied node. This method does not need to save the output, as that is done by the
* caller of this method.
*
* @param outputNode the existing node onto (or below) which the output is to be written; never null
* @param output the (immutable) sequencing output; never null
* @param context the execution context for this sequencing operation; never null
- * @return true if the output was written to the node, or false if no information was written
- * @throws RepositoryException
*/
- protected boolean saveOutput( Node outputNode,
- SequencerOutputMap output,
- JcrExecutionContext context ) throws RepositoryException {
- if (output.isEmpty()) return false;
- final PathFactory pathFactory = context.getValueFactories().getPathFactory();
- final NamespaceRegistry namespaceRegistry = context.getNamespaceRegistry();
- final Path outputNodePath = pathFactory.create(outputNode.getPath());
- final Name jcrPrimaryTypePropertyName = context.getValueFactories().getNameFactory().create("jcr:primaryType");
+ protected void saveOutput( Node outputNode,
+ SequencerOutputMap output,
+ SequencerContext context ) {
+ if (output.isEmpty()) return;
+ final PathFactory pathFactory = context.getExecutionContext().getValueFactories().getPathFactory();
+ final PropertyFactory propertyFactory = context.getExecutionContext().getPropertyFactory();
+ // TODO: Is it safe to assume that the location for this node will include a path?
+ final Path outputNodePath = pathFactory.create(outputNode.getLocation().getPath());
// Iterate over the entries in the output, in Path's natural order (shorter paths first and in lexicographical order by
// prefix and name)
for (SequencerOutputMap.Entry entry : output) {
Path targetNodePath = entry.getPath();
- Name primaryType = entry.getPrimaryTypeValue();
// Resolve this path relative to the output node path, handling any parent or self references ...
Path absolutePath = targetNodePath.isAbsolute() ? targetNodePath : outputNodePath.resolve(targetNodePath);
- Path relativePath = absolutePath.relativeTo(outputNodePath);
- // Find or add the node (which may involve adding intermediate nodes) ...
- Node targetNode = outputNode;
- for (int i = 0, max = relativePath.size(); i != max; ++i) {
- Path.Segment segment = relativePath.getSegment(i);
- String qualifiedName = segment.getString(namespaceRegistry);
- if (targetNode.hasNode(qualifiedName)) {
- targetNode = targetNode.getNode(qualifiedName);
- } else {
- // It doesn't exist, so create it ...
- if (segment.hasIndex()) {
- // Use a name without an index ...
- qualifiedName = segment.getName().getString(namespaceRegistry);
- }
- // We only have the primary type for the final one ...
- if (i == (max - 1) && primaryType != null) {
- targetNode = targetNode.addNode(qualifiedName, primaryType.getString(namespaceRegistry,
- Path.NO_OP_ENCODER));
- } else {
- targetNode = targetNode.addNode(qualifiedName);
- }
- }
- assert targetNode != null;
- }
- assert targetNode != null;
-
+ List<Property> properties = new LinkedList<Property>();
// Set all of the properties on this
for (SequencerOutputMap.PropertyValue property : entry.getPropertyValues()) {
- String propertyName = property.getName().getString(namespaceRegistry, Path.NO_OP_ENCODER);
- Object value = property.getValue();
- if (jcrPrimaryTypePropertyName.equals(property.getName())) {
- // Skip the primary type property (which is protected in Jackrabbit 1.5)
- Logger.getLogger(this.getClass()).trace("Skipping property {0}/{1}={2}",
- targetNode.getPath(),
- propertyName,
- value);
- continue;
- }
- Logger.getLogger(this.getClass()).trace("Writing property {0}/{1}={2}", targetNode.getPath(), propertyName, value);
- if (value instanceof Boolean) {
- targetNode.setProperty(propertyName, ((Boolean)value).booleanValue());
- } else if (value instanceof String) {
- targetNode.setProperty(propertyName, (String)value);
- } else if (value instanceof String[]) {
- targetNode.setProperty(propertyName, (String[])value);
- } else if (value instanceof Integer) {
- targetNode.setProperty(propertyName, ((Integer)value).intValue());
- } else if (value instanceof Short) {
- targetNode.setProperty(propertyName, ((Short)value).shortValue());
- } else if (value instanceof Long) {
- targetNode.setProperty(propertyName, ((Long)value).longValue());
- } else if (value instanceof Float) {
- targetNode.setProperty(propertyName, ((Float)value).floatValue());
- } else if (value instanceof Double) {
- targetNode.setProperty(propertyName, ((Double)value).doubleValue());
- } else if (value instanceof Binary) {
- Binary binaryValue = (Binary)value;
- try {
- binaryValue.acquire();
- targetNode.setProperty(propertyName, binaryValue.getStream());
- } finally {
- binaryValue.release();
- }
- } else if (value instanceof BigDecimal) {
- targetNode.setProperty(propertyName, ((BigDecimal)value).doubleValue());
- } else if (value instanceof DateTime) {
- targetNode.setProperty(propertyName, ((DateTime)value).toCalendar());
- } else if (value instanceof Date) {
- DateTime instant = context.getValueFactories().getDateFactory().create((Date)value);
- targetNode.setProperty(propertyName, instant.toCalendar());
- } else if (value instanceof Calendar) {
- targetNode.setProperty(propertyName, (Calendar)value);
- } else if (value instanceof Name) {
- Name nameValue = (Name)value;
- String stringValue = nameValue.getString(namespaceRegistry);
- targetNode.setProperty(propertyName, stringValue);
- } else if (value instanceof Path) {
- // Find the path to reference node ...
- Path pathToReferencedNode = (Path)value;
- if (!pathToReferencedNode.isAbsolute()) {
- // Resolve the path relative to the output node ...
- pathToReferencedNode = outputNodePath.resolve(pathToReferencedNode);
- }
- // Find the referenced node ...
- try {
- Node referencedNode = outputNode.getNode(pathToReferencedNode.getString());
- targetNode.setProperty(propertyName, referencedNode);
- } catch (PathNotFoundException e) {
- String msg = RepositoryI18n.errorGettingNodeRelativeToNode.text(value, outputNode.getPath());
- throw new SequencerException(msg, e);
- }
- } else if (value == null) {
- // Remove the property ...
- targetNode.setProperty(propertyName, (String)null);
- } else {
- String msg = RepositoryI18n.unknownPropertyValueType.text(value, value.getClass().getName());
- throw new SequencerException(msg);
- }
+ // String propertyName = property.getName().getString(namespaceRegistry, Path.NO_OP_ENCODER);
+ properties.add(propertyFactory.create(property.getName(), property.getValue()));
+ // TODO: Handle reference properties - currently passed in as Paths
}
- }
- return true;
+ if (absolutePath.getParent() != null) {
+ buildPathTo(absolutePath.getParent(), context);
+ }
+ context.getDestination().create(absolutePath, properties);
+ }
}
protected String[] extractMixinTypes( Object value ) {
@@ -300,90 +226,35 @@
return null;
}
- protected SequencerContext createSequencerContext( Node input,
- Property sequencedProperty,
- ExecutionContext context,
- Problems problems ) throws RepositoryException {
+ protected StreamSequencerContext createStreamSequencerContext( Node input,
+ Property sequencedProperty,
+ SequencerContext context,
+ Problems problems ) {
assert input != null;
assert sequencedProperty != null;
assert context != null;
assert problems != null;
- // Translate JCR path and property values to DNA constructs and cache them to improve performance and prevent
- // RepositoryException from being thrown by getters
// Note: getMimeType() will still operate lazily, and thus throw a SequencerException, since it is very intrusive and
// potentially slow-running.
- ValueFactories factories = context.getValueFactories();
- Path path = factories.getPathFactory().create(input.getPath());
- Set<org.jboss.dna.graph.property.Property> props = new HashSet<org.jboss.dna.graph.property.Property>();
- for (PropertyIterator iter = input.getProperties(); iter.hasNext();) {
- javax.jcr.Property jcrProp = iter.nextProperty();
- org.jboss.dna.graph.property.Property prop;
- if (jcrProp.getDefinition().isMultiple()) {
- Value[] jcrVals = jcrProp.getValues();
- Object[] vals = new Object[jcrVals.length];
- int ndx = 0;
- for (Value jcrVal : jcrVals) {
- vals[ndx++] = convert(factories, jcrProp.getName(), jcrVal);
- }
- prop = context.getPropertyFactory().create(factories.getNameFactory().create(jcrProp.getName()), vals);
- } else {
- Value jcrVal = jcrProp.getValue();
- Object val = convert(factories, jcrProp.getName(), jcrVal);
- prop = context.getPropertyFactory().create(factories.getNameFactory().create(jcrProp.getName()), val);
- }
- props.add(prop);
- }
+ ValueFactories factories = context.getExecutionContext().getValueFactories();
+ // TODO: Is this safe?
+ Path path = factories.getPathFactory().create(input.getLocation().getPath());
+
+ Set<org.jboss.dna.graph.property.Property> props = new HashSet<org.jboss.dna.graph.property.Property>(
+ input.getPropertiesByName().values());
props = Collections.unmodifiableSet(props);
String mimeType = getMimeType(sequencedProperty, path.getLastSegment().getName().getLocalName());
- return new SequencerContext(context, path, props, mimeType, problems);
+ return new StreamSequencerContext(context.getExecutionContext(), path, props, mimeType, problems);
}
- protected Object convert( ValueFactories factories,
- String name,
- Value jcrValue ) throws RepositoryException {
- switch (jcrValue.getType()) {
- case PropertyType.BINARY: {
- return factories.getBinaryFactory().create(jcrValue.getStream());
- }
- case PropertyType.BOOLEAN: {
- return factories.getBooleanFactory().create(jcrValue.getBoolean());
- }
- case PropertyType.DATE: {
- return factories.getDateFactory().create(jcrValue.getDate());
- }
- case PropertyType.DOUBLE: {
- return factories.getDoubleFactory().create(jcrValue.getDouble());
- }
- case PropertyType.LONG: {
- return factories.getLongFactory().create(jcrValue.getLong());
- }
- case PropertyType.NAME: {
- return factories.getNameFactory().create(jcrValue.getString());
- }
- case PropertyType.PATH: {
- return factories.getPathFactory().create(jcrValue.getString());
- }
- case PropertyType.REFERENCE: {
- return factories.getReferenceFactory().create(jcrValue.getString());
- }
- case PropertyType.STRING: {
- return factories.getStringFactory().create(jcrValue.getString());
- }
- default: {
- throw new RepositoryException(RepositoryI18n.unknownPropertyValueType.text(name, jcrValue.getType()));
- }
- }
- }
-
- @SuppressWarnings( "null" )
- // The need for the SuppressWarnings looks like an Eclipse bug
protected String getMimeType( Property sequencedProperty,
String name ) {
SequencerException err = null;
String mimeType = null;
InputStream stream = null;
try {
- stream = sequencedProperty.getStream();
+ // Parallel the JCR lemma for converting objects into streams
+ stream = new ByteArrayInputStream(sequencedProperty.toString().getBytes());
mimeType = MimeType.of(name, stream);
return mimeType;
} catch (Exception error) {
@@ -398,7 +269,6 @@
}
}
}
- if (err != null) throw err;
- return mimeType;
+ throw err;
}
}
Modified: trunk/dna-repository/src/main/java/org/jboss/dna/repository/util/RepositoryNodePath.java
===================================================================
--- trunk/dna-repository/src/main/java/org/jboss/dna/repository/util/RepositoryNodePath.java 2009-05-20 20:32:08 UTC (rev 915)
+++ trunk/dna-repository/src/main/java/org/jboss/dna/repository/util/RepositoryNodePath.java 2009-05-20 21:38:18 UTC (rev 916)
@@ -37,27 +37,29 @@
protected static final Pattern PATTERN = Pattern.compile("([^:/]):(/.*)");
- public static RepositoryNodePath parse( String path, String defaultRepositoryWorkspaceName ) {
+ public static RepositoryNodePath parse( String path, String repositorySourceName, String defaultRepositoryWorkspaceName ) {
Matcher matcher = PATTERN.matcher(path);
if (matcher.matches()) {
try {
- return new RepositoryNodePath(matcher.group(1), matcher.group(2));
+ return new RepositoryNodePath(repositorySourceName, matcher.group(1), matcher.group(2));
} catch (Throwable t) {
throw new IllegalArgumentException(RepositoryI18n.invalidRepositoryNodePath.text(path, t.getMessage()));
}
}
- return new RepositoryNodePath(defaultRepositoryWorkspaceName, path);
+ return new RepositoryNodePath(repositorySourceName, defaultRepositoryWorkspaceName, path);
}
- private final String repositoryName;
+ private final String repositorySourceName;
+ private final String workspaceName;
private final String nodePath;
private final int hc;
- public RepositoryNodePath( String repositoryName, String nodePath ) {
- this.repositoryName = repositoryName;
+ public RepositoryNodePath( String repositorySourceName, String workspaceName, String nodePath ) {
+ this.repositorySourceName = repositorySourceName;
+ this.workspaceName = workspaceName;
this.nodePath = nodePath;
- this.hc = HashCode.compute(this.repositoryName, this.nodePath);
+ this.hc = HashCode.compute(this.repositorySourceName, this.workspaceName, this.nodePath);
}
/**
@@ -70,11 +72,19 @@
/**
* @return repositoryName
*/
- public String getRepositoryWorkspaceName() {
- return this.repositoryName;
+ public String getRepositorySourceName() {
+ return this.repositorySourceName;
}
/**
+ *
+ * @return the workspace name
+ */
+ public String getWorkspaceName() {
+ return this.workspaceName;
+ }
+
+ /**
* {@inheritDoc}
*/
@Override
@@ -90,7 +100,8 @@
if (obj == this) return true;
if (obj instanceof RepositoryNodePath) {
RepositoryNodePath that = (RepositoryNodePath)obj;
- if (!this.repositoryName.equals(that.repositoryName)) return false;
+ if (!this.repositorySourceName.equals(that.repositorySourceName)) return false;
+ if (!this.workspaceName.equals(that.workspaceName)) return false;
if (!this.nodePath.equals(that.nodePath)) return false;
return true;
}
@@ -102,6 +113,6 @@
*/
@Override
public String toString() {
- return this.repositoryName + ":" + this.nodePath;
+ return this.repositorySourceName + ":" + this.workspaceName + ":" + this.nodePath;
}
}
Modified: trunk/dna-repository/src/test/java/org/jboss/dna/repository/DnaEngineTest.java
===================================================================
--- trunk/dna-repository/src/test/java/org/jboss/dna/repository/DnaEngineTest.java 2009-05-20 20:32:08 UTC (rev 915)
+++ trunk/dna-repository/src/test/java/org/jboss/dna/repository/DnaEngineTest.java 2009-05-20 21:38:18 UTC (rev 916)
@@ -163,7 +163,7 @@
SequencingService sequencer = engine.getSequencingService();
assertThat(sequencer.getStatistics().getNumberOfNodesSequenced(), is(0L));
- NodeChanges changes = NodeChanges.create("", Arrays.asList(new Event[] {}));
+ NodeChanges changes = NodeChanges.create("config repo", "", Arrays.asList(new Event[] {}));
sequencer.onNodeChanges(changes);
assertThat(sequencer.getStatistics().getNumberOfNodesSequenced(), is(0L));
Modified: trunk/dna-repository/src/test/java/org/jboss/dna/repository/observation/NodeChangeTest.java
===================================================================
--- trunk/dna-repository/src/test/java/org/jboss/dna/repository/observation/NodeChangeTest.java 2009-05-20 20:32:08 UTC (rev 915)
+++ trunk/dna-repository/src/test/java/org/jboss/dna/repository/observation/NodeChangeTest.java 2009-05-20 21:38:18 UTC (rev 916)
@@ -51,7 +51,7 @@
validModifiedProperties.add("jcr:name");
validModifiedProperties.add("jcr:title");
validRemovedProperties.add("jcr:mime");
- nodeChange = new NodeChange(validRepositoryWorkspaceName, validAbsolutePath, validEventTypes, validModifiedProperties,
+ nodeChange = new NodeChange("", validRepositoryWorkspaceName, validAbsolutePath, validEventTypes, validModifiedProperties,
validRemovedProperties);
}
Modified: trunk/dna-repository/src/test/java/org/jboss/dna/repository/sequencer/MockSequencerA.java
===================================================================
--- trunk/dna-repository/src/test/java/org/jboss/dna/repository/sequencer/MockSequencerA.java 2009-05-20 20:32:08 UTC (rev 915)
+++ trunk/dna-repository/src/test/java/org/jboss/dna/repository/sequencer/MockSequencerA.java 2009-05-20 21:38:18 UTC (rev 916)
@@ -28,13 +28,10 @@
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger;
-import javax.jcr.Node;
import net.jcip.annotations.ThreadSafe;
import org.jboss.dna.common.collection.Problems;
+import org.jboss.dna.graph.Node;
import org.jboss.dna.repository.observation.NodeChange;
-import org.jboss.dna.repository.sequencer.Sequencer;
-import org.jboss.dna.repository.sequencer.SequencerConfig;
-import org.jboss.dna.repository.util.JcrExecutionContext;
import org.jboss.dna.repository.util.RepositoryNodePath;
/**
@@ -73,7 +70,7 @@
String sequencedPropertyName,
NodeChange changes,
Set<RepositoryNodePath> outputPaths,
- JcrExecutionContext context,
+ SequencerContext context,
Problems problems ) {
// increment the counter and record the progress ...
this.counter.incrementAndGet();
Modified: trunk/dna-repository/src/test/java/org/jboss/dna/repository/sequencer/MockSequencerB.java
===================================================================
--- trunk/dna-repository/src/test/java/org/jboss/dna/repository/sequencer/MockSequencerB.java 2009-05-20 20:32:08 UTC (rev 915)
+++ trunk/dna-repository/src/test/java/org/jboss/dna/repository/sequencer/MockSequencerB.java 2009-05-20 21:38:18 UTC (rev 916)
@@ -28,13 +28,10 @@
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger;
-import javax.jcr.Node;
import net.jcip.annotations.ThreadSafe;
import org.jboss.dna.common.collection.Problems;
+import org.jboss.dna.graph.Node;
import org.jboss.dna.repository.observation.NodeChange;
-import org.jboss.dna.repository.sequencer.Sequencer;
-import org.jboss.dna.repository.sequencer.SequencerConfig;
-import org.jboss.dna.repository.util.JcrExecutionContext;
import org.jboss.dna.repository.util.RepositoryNodePath;
/**
@@ -73,7 +70,7 @@
String sequencedPropertyName,
NodeChange changes,
Set<RepositoryNodePath> outputPaths,
- JcrExecutionContext context,
+ SequencerContext context,
Problems problems ) {
// increment the counter and record the progress ...
this.counter.incrementAndGet();
Modified: trunk/dna-repository/src/test/java/org/jboss/dna/repository/sequencer/SequencingServiceTest.java
===================================================================
--- trunk/dna-repository/src/test/java/org/jboss/dna/repository/sequencer/SequencingServiceTest.java 2009-05-20 20:32:08 UTC (rev 915)
+++ trunk/dna-repository/src/test/java/org/jboss/dna/repository/sequencer/SequencingServiceTest.java 2009-05-20 21:38:18 UTC (rev 916)
@@ -39,15 +39,15 @@
import javax.jcr.observation.Event;
import org.jboss.dna.common.SystemFailureException;
import org.jboss.dna.common.jcr.AbstractJcrRepositoryTest;
+import org.jboss.dna.graph.connector.inmemory.InMemoryRepositorySource;
+import org.jboss.dna.repository.RepositoryLibrary;
import org.jboss.dna.repository.observation.ObservationService;
-import org.jboss.dna.repository.sequencer.Sequencer;
-import org.jboss.dna.repository.sequencer.SequencerConfig;
-import org.jboss.dna.repository.sequencer.SequencingService;
import org.jboss.dna.repository.service.ServiceAdministrator;
import org.jboss.dna.repository.util.JcrExecutionContext;
import org.jboss.dna.repository.util.SessionFactory;
import org.junit.After;
import org.junit.Before;
+import org.junit.Ignore;
import org.junit.Test;
/**
@@ -57,14 +57,22 @@
public static final int ALL_EVENT_TYPES = Event.NODE_ADDED | Event.NODE_REMOVED | Event.PROPERTY_ADDED
| Event.PROPERTY_CHANGED | Event.PROPERTY_REMOVED;
+
+ public static final String REPOSITORY_SOURCE_NAME = "repository";
public static final String REPOSITORY_WORKSPACE_NAME = "testRepository-Workspace";
+ private RepositoryLibrary sources;
private ObservationService observationService;
private SequencingService sequencingService;
private JcrExecutionContext executionContext;
@Before
public void beforeEach() {
+ sources = new RepositoryLibrary();
+ InMemoryRepositorySource source = new InMemoryRepositorySource();
+ source.setName(REPOSITORY_SOURCE_NAME);
+ sources.addSource(source);
+
SessionFactory sessionFactory = new SessionFactory() {
public Session createSession( String name ) throws RepositoryException {
assertThat(name, is(REPOSITORY_WORKSPACE_NAME));
@@ -78,6 +86,7 @@
this.executionContext = new JcrExecutionContext(sessionFactory, REPOSITORY_WORKSPACE_NAME);
this.sequencingService = new SequencingService();
this.sequencingService.setExecutionContext(this.executionContext);
+ this.sequencingService.setRepositoryLibrary(sources);
this.observationService = new ObservationService(this.executionContext.getSessionFactory());
this.observationService.addListener(this.sequencingService);
}
@@ -208,7 +217,7 @@
// Try when paused ...
assertThat(sequencingService.getAdministrator().isPaused(), is(true));
assertThat(observationService.getAdministrator().pause().isPaused(), is(true));
- ObservationService.WorkspaceListener listener = observationService.monitor(REPOSITORY_WORKSPACE_NAME, Event.NODE_ADDED);
+ ObservationService.WorkspaceListener listener = observationService.monitor(REPOSITORY_SOURCE_NAME, REPOSITORY_WORKSPACE_NAME, Event.NODE_ADDED);
assertThat(listener, is(notNullValue()));
assertThat(listener.getAbsolutePath(), is("/"));
assertThat(listener.getEventTypes(), is(Event.NODE_ADDED));
@@ -229,7 +238,7 @@
// Start the sequencing sequencingService and try monitoring the workspace ...
assertThat(sequencingService.getAdministrator().start().isStarted(), is(true));
assertThat(observationService.getAdministrator().start().isStarted(), is(true));
- ObservationService.WorkspaceListener listener2 = observationService.monitor(REPOSITORY_WORKSPACE_NAME, Event.NODE_ADDED);
+ ObservationService.WorkspaceListener listener2 = observationService.monitor(REPOSITORY_SOURCE_NAME, REPOSITORY_WORKSPACE_NAME, Event.NODE_ADDED);
assertThat(listener2.isRegistered(), is(true));
assertThat(listener2, is(notNullValue()));
assertThat(listener2.getAbsolutePath(), is("/"));
@@ -268,7 +277,7 @@
// Start the sequencing sequencingService and try monitoring the workspace ...
assertThat(sequencingService.getAdministrator().start().isStarted(), is(true));
- ObservationService.WorkspaceListener listener = observationService.monitor(REPOSITORY_WORKSPACE_NAME, Event.NODE_ADDED);
+ ObservationService.WorkspaceListener listener = observationService.monitor(REPOSITORY_SOURCE_NAME, REPOSITORY_WORKSPACE_NAME, Event.NODE_ADDED);
assertThat(listener.isRegistered(), is(true));
assertThat(listener, is(notNullValue()));
assertThat(listener.getAbsolutePath(), is("/"));
@@ -299,6 +308,9 @@
assertThat(listener.isRegistered(), is(false));
}
+ // FIXME: This test needs to be unignored after the observation service is re-written to not use JCR
+
+ @Ignore
@Test
public void shouldExecuteSequencersUponChangesToRepositoryThatMatchSequencerPathExpressions() throws Exception {
// Add configurations for a sequencer ...
@@ -316,7 +328,7 @@
// Start the sequencing sequencingService and try monitoring the workspace ...
assertThat(sequencingService.getAdministrator().start().isStarted(), is(true));
- ObservationService.WorkspaceListener listener = observationService.monitor(REPOSITORY_WORKSPACE_NAME, ALL_EVENT_TYPES);
+ ObservationService.WorkspaceListener listener = observationService.monitor(REPOSITORY_SOURCE_NAME, REPOSITORY_WORKSPACE_NAME, ALL_EVENT_TYPES);
assertThat(listener.isRegistered(), is(true));
assertThat(listener, is(notNullValue()));
assertThat(listener.getAbsolutePath(), is("/"));
Modified: trunk/dna-repository/src/test/java/org/jboss/dna/repository/sequencer/StreamSequencerAdapterTest.java
===================================================================
--- trunk/dna-repository/src/test/java/org/jboss/dna/repository/sequencer/StreamSequencerAdapterTest.java 2009-05-20 20:32:08 UTC (rev 915)
+++ trunk/dna-repository/src/test/java/org/jboss/dna/repository/sequencer/StreamSequencerAdapterTest.java 2009-05-20 21:38:18 UTC (rev 916)
@@ -32,31 +32,26 @@
import static org.mockito.Mockito.mock;
import java.io.ByteArrayInputStream;
import java.io.InputStream;
+import java.util.Arrays;
import java.util.Collections;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Set;
-import javax.jcr.Node;
-import javax.jcr.Session;
import javax.jcr.observation.Event;
import org.jboss.dna.common.collection.Problems;
import org.jboss.dna.common.collection.SimpleProblems;
-import org.jboss.dna.common.jcr.AbstractJcrRepositoryTest;
+import org.jboss.dna.graph.ExecutionContext;
+import org.jboss.dna.graph.Graph;
+import org.jboss.dna.graph.Node;
+import org.jboss.dna.graph.connector.inmemory.InMemoryRepositorySource;
import org.jboss.dna.graph.property.Path;
+import org.jboss.dna.graph.property.PathNotFoundException;
import org.jboss.dna.graph.property.Property;
-import org.jboss.dna.graph.sequencer.SequencerContext;
import org.jboss.dna.graph.sequencer.SequencerOutput;
import org.jboss.dna.graph.sequencer.StreamSequencer;
+import org.jboss.dna.graph.sequencer.StreamSequencerContext;
import org.jboss.dna.repository.observation.NodeChange;
-import org.jboss.dna.repository.sequencer.SequencerConfig;
-import org.jboss.dna.repository.sequencer.SequencerException;
-import org.jboss.dna.repository.sequencer.SequencerOutputMap;
-import org.jboss.dna.repository.sequencer.StreamSequencerAdapter;
-import org.jboss.dna.repository.util.JcrExecutionContext;
-import org.jboss.dna.repository.util.JcrTools;
import org.jboss.dna.repository.util.RepositoryNodePath;
-import org.jboss.dna.repository.util.SessionFactory;
-import org.junit.After;
import org.junit.Before;
import org.junit.Test;
@@ -64,35 +59,33 @@
* @author Randall Hauch
* @author John Verhaeg
*/
-public class StreamSequencerAdapterTest extends AbstractJcrRepositoryTest {
+public class StreamSequencerAdapterTest {
private StreamSequencer streamSequencer;
private StreamSequencerAdapter sequencer;
private String[] validExpressions = {"/a/* => /output"};
- private SequencerConfig validConfig = new SequencerConfig("name", "desc", Collections.<String, Object>emptyMap(), "something.class", null, validExpressions);
- private JcrTools tools;
- private Session session;
+ private SequencerConfig validConfig = new SequencerConfig("name", "desc", Collections.<String, Object>emptyMap(),
+ "something.class", null, validExpressions);
private SequencerOutputMap sequencerOutput;
private String sampleData = "The little brown fox didn't something bad.";
- private JcrExecutionContext context;
- private String repositoryWorkspaceName = "something";
+ private ExecutionContext context;
+ private SequencerContext seqContext;
+ private String repositorySourceName = "repository";
+ private String repositoryWorkspaceName = "";
private Problems problems;
- private javax.jcr.Property sequencedProperty;
+ private Graph graph;
+ private Property sequencedProperty;
@Before
public void beforeEach() {
- final JcrTools tools = new JcrTools();
- this.tools = tools;
- final SessionFactory sessionFactory = new SessionFactory() {
-
- public Session createSession( String name ) {
- return createTestSession();
- }
- };
problems = new SimpleProblems();
- this.context = new JcrExecutionContext(sessionFactory, "doesn't matter");
+ this.context = new ExecutionContext();
this.sequencerOutput = new SequencerOutputMap(this.context.getValueFactories());
final SequencerOutputMap finalOutput = sequencerOutput;
+
+ InMemoryRepositorySource source = new InMemoryRepositorySource();
+ source.setName("repository");
+ graph = Graph.create(source.getConnection(), context);
this.streamSequencer = new StreamSequencer() {
/**
@@ -101,7 +94,7 @@
*/
public void sequence( InputStream stream,
SequencerOutput output,
- SequencerContext context ) {
+ StreamSequencerContext context ) {
for (SequencerOutputMap.Entry entry : finalOutput) {
Path nodePath = entry.getPath();
for (SequencerOutputMap.PropertyValue property : entry.getPropertyValues()) {
@@ -111,49 +104,31 @@
}
};
sequencer = new StreamSequencerAdapter(streamSequencer);
+ seqContext = new SequencerContext(context, graph);
}
- @After
- public void afterEach() {
- if (session != null) {
- try {
- session.logout();
- } finally {
- session = null;
- }
- }
- }
-
- protected Session createTestSession() {
- try {
- return getRepository().login(getTestCredentials());
- } catch (Exception e) {
- fail("Unable to create repository session: " + e.getMessage());
- return null; // won't get here
- }
- }
-
protected void testSequencer( final StreamSequencer sequencer ) throws Throwable {
StreamSequencer streamSequencer = new StreamSequencer() {
public void sequence( InputStream stream,
SequencerOutput output,
- SequencerContext context ) {
+ StreamSequencerContext context ) {
sequencer.sequence(stream, output, context);
}
};
StreamSequencerAdapter adapter = new StreamSequencerAdapter(streamSequencer);
- startRepository();
- session = getRepository().login(getTestCredentials());
- Node inputNode = tools.findOrCreateNode(session, "/a/b/c");
- Node outputNode = tools.findOrCreateNode(session, "/d/e");
- inputNode.setProperty("sequencedProperty", new ByteArrayInputStream(sampleData.getBytes()));
- NodeChange nodeChange = new NodeChange(repositoryWorkspaceName, inputNode.getPath(), Event.PROPERTY_CHANGED,
+
+ graph.create("/a").and().create("/a/b").and().create("/a/b/c");
+ graph.create("/d").and().create("/d/e");
+ graph.set("sequencedProperty").on("/a/b/c").to(new ByteArrayInputStream(sampleData.getBytes()));
+ Node inputNode = graph.getNodeAt("/a/b/c");
+
+ NodeChange nodeChange = new NodeChange(repositorySourceName, repositoryWorkspaceName, "/a/b/c", Event.PROPERTY_CHANGED,
Collections.singleton("sequencedProperty"), null);
Set<RepositoryNodePath> outputPaths = new HashSet<RepositoryNodePath>();
- outputPaths.add(new RepositoryNodePath(repositoryWorkspaceName, outputNode.getPath()));
+ outputPaths.add(new RepositoryNodePath(repositorySourceName, repositoryWorkspaceName, "/d/e"));
sequencerOutput.setProperty("alpha/beta", "isSomething", true);
- adapter.execute(inputNode, "sequencedProperty", nodeChange, outputPaths, context, problems);
+ adapter.execute(inputNode, "sequencedProperty", nodeChange, outputPaths, seqContext, problems);
}
@Test
@@ -188,181 +163,201 @@
@Test
public void shouldExecuteSequencerOnExistingNodeAndOutputToExistingNode() throws Exception {
- startRepository();
- session = getRepository().login(getTestCredentials());
// Set up the repository for the test ...
- Node nodeC = tools.findOrCreateNode(session, "/a/b/c");
- Node nodeE = tools.findOrCreateNode(session, "/d/e");
+ graph.create("/a").and().create("/a/b").and().create("/a/b/c");
+ graph.create("/d").and().create("/d/e");
+ graph.set("sequencedProperty").on("/a/b/c").to(new ByteArrayInputStream(sampleData.getBytes()));
+ Node nodeC = graph.getNodeAt("/a/b/c");
+ Node nodeE = graph.getNodeAt("/d/e");
assertThat(nodeC, is(notNullValue()));
assertThat(nodeE, is(notNullValue()));
- assertThat(nodeE.getNodes().getSize(), is(0l));
- assertThat(nodeE.getProperties().getSize(), is(1l)); // jcr:primaryType
- assertThat(nodeE.getProperty("jcr:primaryType").getString(), is("nt:unstructured"));
+ assertThat(nodeE.getChildren().size(), is(0));
+ assertThat(nodeE.getProperties().size(), is(1)); // jcr:uuid
+ // assertThat(nodeE.getProperty("jcr:primaryType").getString(), is("nt:unstructured"));
// Set the property that will be sequenced ...
- nodeC.setProperty("sequencedProperty", new ByteArrayInputStream(sampleData.getBytes()));
// Set up the node changes ...
- NodeChange nodeChange = new NodeChange(repositoryWorkspaceName, nodeC.getPath(), Event.PROPERTY_CHANGED,
+ NodeChange nodeChange = new NodeChange(repositorySourceName, repositoryWorkspaceName, "/a/b/c", Event.PROPERTY_CHANGED,
Collections.singleton("sequencedProperty"), null);
// Set up the output directory ...
Set<RepositoryNodePath> outputPaths = new HashSet<RepositoryNodePath>();
- outputPaths.add(new RepositoryNodePath(repositoryWorkspaceName, nodeE.getPath()));
+ outputPaths.add(new RepositoryNodePath(repositorySourceName, repositoryWorkspaceName, "/d/e"));
// Generate the output data that the sequencer subclass will produce and that should be saved to the repository ...
sequencerOutput.setProperty("alpha/beta", "isSomething", true);
// Call the sequencer ...
- sequencer.execute(nodeC, "sequencedProperty", nodeChange, outputPaths, context, problems);
+ sequencer.execute(nodeC, "sequencedProperty", nodeChange, outputPaths, seqContext, problems);
}
@Test( expected = SequencerException.class )
public void shouldExecuteSequencerOnExistingNodeWithMissingSequencedPropertyAndOutputToExistingNode() throws Exception {
- startRepository();
- session = getRepository().login(getTestCredentials());
// Set up the repository for the test ...
- Node nodeC = tools.findOrCreateNode(session, "/a/b/c");
- Node nodeE = tools.findOrCreateNode(session, "/d/e");
+ graph.create("/a").and().create("/a/b").and().create("/a/b/c");
+ graph.create("/d").and().create("/d/e");
+ Node nodeC = graph.getNodeAt("/a/b/c");
+ Node nodeE = graph.getNodeAt("/d/e");
assertThat(nodeC, is(notNullValue()));
assertThat(nodeE, is(notNullValue()));
- assertThat(nodeE.getNodes().getSize(), is(0l));
- assertThat(nodeE.getProperties().getSize(), is(1l)); // jcr:primaryType
- assertThat(nodeE.getProperty("jcr:primaryType").getString(), is("nt:unstructured"));
+ assertThat(nodeE.getChildren().size(), is(0));
+ assertThat(nodeE.getProperties().size(), is(1)); // jcr:uuid
+ // assertThat(nodeE.getProperty("jcr:primaryType").getString(), is("nt:unstructured"));
// Set the property that will be sequenced ...
// THIS TEST REQUIRES THIS PROPERTY TO BE NULL OR NON-EXISTANT
- nodeC.setProperty("sequencedProperty", (InputStream)null);
+ graph.set("sequencedProperty").on(nodeC.getLocation()).to((String)null);
// Set up the node changes ...
- NodeChange nodeChange = new NodeChange(repositoryWorkspaceName, nodeC.getPath(), Event.PROPERTY_CHANGED,
+ NodeChange nodeChange = new NodeChange(repositorySourceName, repositoryWorkspaceName, "/a/b/c", Event.PROPERTY_CHANGED,
Collections.singleton("sequencedProperty"), null);
// Set up the output directory ...
Set<RepositoryNodePath> outputPaths = new HashSet<RepositoryNodePath>();
- outputPaths.add(new RepositoryNodePath(repositoryWorkspaceName, nodeE.getPath()));
+ outputPaths.add(new RepositoryNodePath(repositorySourceName, repositoryWorkspaceName, "/d/e"));
// Generate the output data that the sequencer subclass will produce and that should be saved to the repository ...
sequencerOutput.setProperty("alpha/beta", "isSomething", true);
// Call the sequencer, which should cause the exception ...
- sequencer.execute(nodeC, "sequencedProperty", nodeChange, outputPaths, context, problems);
+ sequencer.execute(nodeC, "sequencedProperty", nodeChange, outputPaths, seqContext, problems);
}
@Test
public void shouldExecuteSequencerOnExistingNodeAndOutputToMultipleExistingNodes() throws Exception {
- startRepository();
- session = getRepository().login(getTestCredentials());
// Set up the repository for the test ...
- Node nodeC = tools.findOrCreateNode(session, "/a/b/c");
- Node nodeE = tools.findOrCreateNode(session, "/d/e");
+ graph.create("/a").and().create("/a/b").and().create("/a/b/c");
+ graph.create("/d").and().create("/d/e");
+
+ // Set the property that will be sequenced ...
+ graph.set("sequencedProperty").on("/a/b/c").to(new ByteArrayInputStream(sampleData.getBytes()));
+
+ Node nodeC = graph.getNodeAt("/a/b/c");
+ Node nodeE = graph.getNodeAt("/d/e");
assertThat(nodeC, is(notNullValue()));
assertThat(nodeE, is(notNullValue()));
- assertThat(nodeE.getNodes().getSize(), is(0l));
- assertThat(nodeE.getProperties().getSize(), is(1l)); // jcr:primaryType
- assertThat(nodeE.getProperty("jcr:primaryType").getString(), is("nt:unstructured"));
+ assertThat(nodeE.getChildren().size(), is(0));
+ assertThat(nodeE.getProperties().size(), is(1)); // jcr:uuid
+ // assertThat(nodeE.getProperty("jcr:primaryType").getString(), is("nt:unstructured"));
- // Set the property that will be sequenced ...
- nodeC.setProperty("sequencedProperty", new ByteArrayInputStream(sampleData.getBytes()));
-
// Set up the node changes ...
- NodeChange nodeChange = new NodeChange(repositoryWorkspaceName, nodeC.getPath(), Event.PROPERTY_CHANGED,
+ NodeChange nodeChange = new NodeChange(repositorySourceName, repositoryWorkspaceName, "/a/b/c", Event.PROPERTY_CHANGED,
Collections.singleton("sequencedProperty"), null);
// Set up the output directory ...
Set<RepositoryNodePath> outputPaths = new HashSet<RepositoryNodePath>();
- outputPaths.add(new RepositoryNodePath(repositoryWorkspaceName, "/d/e"));
- outputPaths.add(new RepositoryNodePath(repositoryWorkspaceName, "/x/y/z"));
+ outputPaths.add(new RepositoryNodePath(repositorySourceName, repositoryWorkspaceName, "/d/e"));
+ outputPaths.add(new RepositoryNodePath(repositorySourceName, repositoryWorkspaceName, "/x/y/z"));
// Generate the output data that the sequencer subclass will produce and that should be saved to the repository ...
sequencerOutput.setProperty("alpha/beta", "isSomething", true);
// Call the sequencer ...
- sequencer.execute(nodeC, "sequencedProperty", nodeChange, outputPaths, context, problems);
+ sequencer.execute(nodeC, "sequencedProperty", nodeChange, outputPaths, seqContext, problems);
// Check to see that the output nodes have been created ...
- assertThat(session.getRootNode().hasNode("d/e"), is(true));
- assertThat(session.getRootNode().hasNode("x/y/z"), is(true));
+ assertThat(graph.getNodeAt("/d/e"), is(notNullValue()));
+ assertThat(graph.getNodeAt("/x/y/z"), is(notNullValue()));
}
@Test
public void shouldExecuteSequencerOnExistingNodeAndOutputToNonExistingNode() throws Exception {
- startRepository();
- session = getRepository().login(getTestCredentials());
// Set up the repository for the test ...
- Node nodeC = tools.findOrCreateNode(session, "/a/b/c");
- assertThat(session.getRootNode().hasNode("d"), is(false));
- assertThat(nodeC, is(notNullValue()));
+ graph.create("/a").and().create("/a/b").and().create("/a/b/c");
// Set the property that will be sequenced ...
- nodeC.setProperty("sequencedProperty", new ByteArrayInputStream(sampleData.getBytes()));
+ graph.set("sequencedProperty").on("/a/b/c").to(new ByteArrayInputStream(sampleData.getBytes()));
+ Node nodeC = graph.getNodeAt("/a/b/c");
+ try {
+ graph.getNodeAt("/d");
+ fail();
+ }
+ catch(PathNotFoundException pnfe) {
+ // Expected
+ }
+ assertThat(nodeC, is(notNullValue()));
+
// Set up the node changes ...
- NodeChange nodeChange = new NodeChange(repositoryWorkspaceName, nodeC.getPath(), Event.PROPERTY_CHANGED,
+ NodeChange nodeChange = new NodeChange(repositorySourceName, repositoryWorkspaceName, "/a/b/c", Event.PROPERTY_CHANGED,
Collections.singleton("sequencedProperty"), null);
// Set up the output directory ...
Set<RepositoryNodePath> outputPaths = new HashSet<RepositoryNodePath>();
- outputPaths.add(new RepositoryNodePath(repositoryWorkspaceName, "/d/e"));
+ outputPaths.add(new RepositoryNodePath(repositorySourceName, repositoryWorkspaceName, "/d/e"));
// Generate the output data that the sequencer subclass will produce and that should be saved to the repository ...
sequencerOutput.setProperty("alpha/beta", "isSomething", true);
// Call the sequencer ...
- sequencer.execute(nodeC, "sequencedProperty", nodeChange, outputPaths, context, problems);
+ sequencer.execute(nodeC, "sequencedProperty", nodeChange, outputPaths, seqContext, problems);
// Check to see that the "/d/e" node has been created ...
- assertThat(session.getRootNode().hasNode("d/e"), is(true));
+ assertThat(graph.getNodeAt("/d/e"), is(notNullValue()));
}
@Test
public void shouldExecuteSequencerOnExistingNodeAndOutputToMultipleNonExistingNodes() throws Exception {
- startRepository();
- session = getRepository().login(getTestCredentials());
// Set up the repository for the test ...
- Node nodeC = tools.findOrCreateNode(session, "/a/b/c");
- assertThat(session.getRootNode().hasNode("d"), is(false));
- assertThat(session.getRootNode().hasNode("x"), is(false));
- assertThat(nodeC, is(notNullValue()));
+ graph.create("/a").and().create("/a/b").and().create("/a/b/c");
// Set the property that will be sequenced ...
- nodeC.setProperty("sequencedProperty", new ByteArrayInputStream(sampleData.getBytes()));
+ graph.set("sequencedProperty").on("/a/b/c").to(new ByteArrayInputStream(sampleData.getBytes()));
+ Node nodeC = graph.getNodeAt("/a/b/c");
+ try {
+ graph.getNodeAt("/d");
+ fail();
+ }
+ catch(PathNotFoundException pnfe) {
+ // Expected
+ }
+ try {
+ graph.getNodeAt("/x");
+ fail();
+ }
+ catch(PathNotFoundException pnfe) {
+ // Expected
+ }
+ assertThat(nodeC, is(notNullValue()));
+
// Set up the node changes ...
- NodeChange nodeChange = new NodeChange(repositoryWorkspaceName, nodeC.getPath(), Event.PROPERTY_CHANGED,
+ NodeChange nodeChange = new NodeChange(repositorySourceName, repositoryWorkspaceName, "/a/b/c", Event.PROPERTY_CHANGED,
Collections.singleton("sequencedProperty"), null);
// Set up the output directory ...
Set<RepositoryNodePath> outputPaths = new HashSet<RepositoryNodePath>();
- outputPaths.add(new RepositoryNodePath(repositoryWorkspaceName, "/d/e"));
- outputPaths.add(new RepositoryNodePath(repositoryWorkspaceName, "/x/y/z"));
- outputPaths.add(new RepositoryNodePath(repositoryWorkspaceName, "/x/z"));
+ outputPaths.add(new RepositoryNodePath(repositorySourceName, repositoryWorkspaceName, "/d/e"));
+ outputPaths.add(new RepositoryNodePath(repositorySourceName, repositoryWorkspaceName, "/x/y/z"));
+ outputPaths.add(new RepositoryNodePath(repositorySourceName, repositoryWorkspaceName, "/x/z"));
// Generate the output data that the sequencer subclass will produce and that should be saved to the repository ...
sequencerOutput.setProperty("alpha/beta", "isSomething", true);
// Call the sequencer ...
- sequencer.execute(nodeC, "sequencedProperty", nodeChange, outputPaths, context, problems);
+ sequencer.execute(nodeC, "sequencedProperty", nodeChange, outputPaths, seqContext, problems);
// Check to see that the output nodes have been created ...
- assertThat(session.getRootNode().hasNode("d/e"), is(true));
- assertThat(session.getRootNode().hasNode("x/y/z"), is(true));
- assertThat(session.getRootNode().hasNode("x/z"), is(true));
+ assertThat(graph.getNodeAt("/d/e"), is(notNullValue()));
+ assertThat(graph.getNodeAt("/x/y/z"), is(notNullValue()));
+ assertThat(graph.getNodeAt("/x/z"), is(notNullValue()));
// Check to see that the sequencer-generated nodes have been created ...
// Node beta = session.getRootNode().getNode("d/e/alpha/beta");
// for (PropertyIterator iter = beta.getProperties(); iter.hasNext();) {
// Property property = iter.nextProperty();
- // System.out.println("Property on " + beta.getPath() + " ===> " + property.getName() + " = " + property.getValue());
+ // System.out.println("Property on " + beta.getLocation().getPath() + " ===> " + property.getName() + " = " +
+ // property.getValue());
// }
- assertThat(session.getRootNode().getNode("d/e/alpha/beta").getProperty("isSomething").getBoolean(), is(true));
- assertThat(session.getRootNode().getNode("x/y/z/alpha/beta").getProperty("isSomething").getBoolean(), is(true));
- assertThat(session.getRootNode().getNode("x/z/alpha/beta").getProperty("isSomething").getBoolean(), is(true));
+ assertThat(graph.getNodeAt("/d/e/alpha/beta").getProperty("isSomething").getFirstValue().toString(), is("true"));
+ assertThat(graph.getNodeAt("/x/y/z/alpha/beta").getProperty("isSomething").getFirstValue().toString(), is("true"));
+ assertThat(graph.getNodeAt("/x/z/alpha/beta").getProperty("isSomething").getFirstValue().toString(), is("true"));
}
@Test
@@ -376,7 +371,7 @@
public void sequence( InputStream stream,
SequencerOutput output,
- SequencerContext context ) {
+ StreamSequencerContext context ) {
assertThat(stream, notNullValue());
}
});
@@ -388,7 +383,7 @@
public void sequence( InputStream stream,
SequencerOutput output,
- SequencerContext context ) {
+ StreamSequencerContext context ) {
assertThat(output, notNullValue());
}
});
@@ -400,7 +395,7 @@
public void sequence( InputStream stream,
SequencerOutput output,
- SequencerContext context ) {
+ StreamSequencerContext context ) {
assertThat(context, notNullValue());
}
});
@@ -408,104 +403,111 @@
@Test( expected = java.lang.AssertionError.class )
public void shouldNotAllowNullInputNode() throws Exception {
- sequencer.createSequencerContext(null, sequencedProperty, context, problems);
+ sequencer.createStreamSequencerContext(null, sequencedProperty, seqContext, problems);
}
@Test( expected = java.lang.AssertionError.class )
public void shouldNotAllowNullSequencedProperty() throws Exception {
- startRepository();
- session = getRepository().login(getTestCredentials());
- Node input = tools.findOrCreateNode(session, "/a");
- sequencer.createSequencerContext(input, null, context, problems);
+ graph.create("/a");
+ Node input = graph.getNodeAt("/a");
+ sequencer.createStreamSequencerContext(input, null, seqContext, problems);
}
@Test( expected = java.lang.AssertionError.class )
public void shouldNotAllowNullExecutionContext() throws Exception {
- startRepository();
- session = getRepository().login(getTestCredentials());
- Node input = tools.findOrCreateNode(session, "/a");
- sequencer.createSequencerContext(input, sequencedProperty, null, problems);
+ this.sequencedProperty = mock(Property.class);
+ graph.create("/a");
+ Node input = graph.getNodeAt("/a");
+ sequencer.createStreamSequencerContext(input, sequencedProperty, null, problems);
}
@Test
public void shouldProvideNamespaceRegistry() throws Exception {
- startRepository();
- session = getRepository().login(getTestCredentials());
- this.sequencedProperty = mock(javax.jcr.Property.class);
- Node input = tools.findOrCreateNode(session, "/a/b/c");
- SequencerContext sequencerContext = sequencer.createSequencerContext(input, sequencedProperty, context, problems);
+ this.sequencedProperty = mock(Property.class);
+ graph.create("/a").and().create("/a/b").and().create("/a/b/c");
+ Node input = graph.getNodeAt("/a/b/c");
+ StreamSequencerContext sequencerContext = sequencer.createStreamSequencerContext(input,
+ sequencedProperty,
+ seqContext,
+ problems);
assertThat(sequencerContext.getNamespaceRegistry(), notNullValue());
}
@Test
public void shouldProvideValueFactories() throws Exception {
- startRepository();
- session = getRepository().login(getTestCredentials());
- this.sequencedProperty = mock(javax.jcr.Property.class);
- Node input = tools.findOrCreateNode(session, "/a/b/c");
- SequencerContext sequencerContext = sequencer.createSequencerContext(input, sequencedProperty, context, problems);
+ this.sequencedProperty = mock(Property.class);
+ graph.create("/a").and().create("/a/b").and().create("/a/b/c");
+ Node input = graph.getNodeAt("/a/b/c");
+ StreamSequencerContext sequencerContext = sequencer.createStreamSequencerContext(input,
+ sequencedProperty,
+ seqContext,
+ problems);
assertThat(sequencerContext.getValueFactories(), notNullValue());
}
@Test
public void shouldProvidePathToInput() throws Exception {
- startRepository();
- session = getRepository().login(getTestCredentials());
- this.sequencedProperty = mock(javax.jcr.Property.class);
- Node input = tools.findOrCreateNode(session, "/a/b/c");
- SequencerContext sequencerContext = sequencer.createSequencerContext(input, sequencedProperty, context, problems);
+ this.sequencedProperty = mock(Property.class);
+ graph.create("/a").and().create("/a/b").and().create("/a/b/c");
+ Node input = graph.getNodeAt("/a/b/c");
+ StreamSequencerContext sequencerContext = sequencer.createStreamSequencerContext(input,
+ sequencedProperty,
+ seqContext,
+ problems);
assertThat(sequencerContext.getInputPath(), is(context.getValueFactories().getPathFactory().create("/a/b/c")));
}
@Test
public void shouldNeverReturnNullInputProperties() throws Exception {
- startRepository();
- session = getRepository().login(getTestCredentials());
- this.sequencedProperty = mock(javax.jcr.Property.class);
- Node input = tools.findOrCreateNode(session, "/a/b/c");
- SequencerContext sequencerContext = sequencer.createSequencerContext(input, sequencedProperty, context, problems);
+ this.sequencedProperty = mock(Property.class);
+ graph.create("/a").and().create("/a/b").and().create("/a/b/c");
+ Node input = graph.getNodeAt("/a/b/c");
+ StreamSequencerContext sequencerContext = sequencer.createStreamSequencerContext(input,
+ sequencedProperty,
+ seqContext,
+ problems);
assertThat(sequencerContext.getInputProperties(), notNullValue());
assertThat(sequencerContext.getInputProperties().isEmpty(), is(false));
}
@Test
public void shouldProvideInputProperties() throws Exception {
- startRepository();
- session = getRepository().login(getTestCredentials());
- this.sequencedProperty = mock(javax.jcr.Property.class);
- Node input = tools.findOrCreateNode(session, "/a/b/c");
- input.setProperty("x", true);
- input.setProperty("y", new String[] {"asdf", "xyzzy"});
- SequencerContext sequencerContext = sequencer.createSequencerContext(input, sequencedProperty, context, problems);
+
+ this.sequencedProperty = mock(Property.class);
+ graph.create("/a").and().create("/a/b").and().create("/a/b/c");
+ graph.set("x").on("/a/b/c").to(true);
+ graph.set("y").on("/a/b/c").to(Arrays.asList(new String[] {"asdf", "xyzzy"}));
+ Node input = graph.getNodeAt("/a/b/c");
+ StreamSequencerContext sequencerContext = sequencer.createStreamSequencerContext(input, sequencedProperty, seqContext, problems);
assertThat(sequencerContext.getInputProperties(), notNullValue());
assertThat(sequencerContext.getInputProperties().isEmpty(), is(false));
assertThat(sequencerContext.getInputProperties().size(), is(3));
- verifyProperty(sequencerContext,
- "jcr:primaryType",
- context.getValueFactories().getNameFactory().create("{http://www.jcp.org/jcr/nt/1.0}unstructured"));
+ // verifyProperty(sequencerContext, "jcr:uuid", /* some UUID */null );
verifyProperty(sequencerContext, "x", true);
verifyProperty(sequencerContext, "y", "asdf", "xyzzy");
}
@Test
public void shouldCreateSequencerContextThatProvidesMimeType() throws Exception {
- startRepository();
- session = getRepository().login(getTestCredentials());
- this.sequencedProperty = mock(javax.jcr.Property.class);
- Node input = tools.findOrCreateNode(session, "/a/b/c");
- SequencerContext sequencerContext = sequencer.createSequencerContext(input, sequencedProperty, context, problems);
+ this.sequencedProperty = mock(Property.class);
+ graph.create("/a").and().create("/a/b").and().create("/a/b/c");
+ Node input = graph.getNodeAt("/a/b/c");
+ StreamSequencerContext sequencerContext = sequencer.createStreamSequencerContext(input,
+ sequencedProperty,
+ seqContext,
+ problems);
assertThat(sequencerContext.getMimeType(), is("text/plain"));
}
- private void verifyProperty( SequencerContext context,
+ private void verifyProperty( StreamSequencerContext context,
String name,
Object... values ) {
Property prop = context.getInputProperty(context.getValueFactories().getNameFactory().create(name));
Modified: trunk/docs/examples/gettingstarted/sequencers/src/main/java/org/jboss/example/dna/sequencer/SequencingClient.java
===================================================================
--- trunk/docs/examples/gettingstarted/sequencers/src/main/java/org/jboss/example/dna/sequencer/SequencingClient.java 2009-05-20 20:32:08 UTC (rev 915)
+++ trunk/docs/examples/gettingstarted/sequencers/src/main/java/org/jboss/example/dna/sequencer/SequencingClient.java 2009-05-20 21:38:18 UTC (rev 916)
@@ -222,9 +222,10 @@
}
this.executionContext = new JcrExecutionContext(sessionFactory, repositoryWorkspaceName);
- // Create the sequencing service, passing in the execution context ...
+ // Create the sequencing service, passing in the execution context and the repository library ...
this.sequencingService = new SequencingService();
this.sequencingService.setExecutionContext(executionContext);
+ //this.sequencingService.setRepositoryLibrary(repositoryLibrary);
// Configure the sequencers. In this example, we only two sequencers that processes image and mp3 files.
// So create a configurations. Note that the sequencing service expects the class to be on the thread's current
@@ -269,7 +270,7 @@
this.observationService = new ObservationService(this.executionContext.getSessionFactory());
this.observationService.getAdministrator().start();
this.observationService.addListener(this.sequencingService);
- this.observationService.monitor(repositoryWorkspaceName, Event.NODE_ADDED | Event.PROPERTY_ADDED
+ this.observationService.monitor(this.repositoryName, repositoryWorkspaceName, Event.NODE_ADDED | Event.PROPERTY_ADDED
| Event.PROPERTY_CHANGED);
}
// Start up the sequencing service ...
Modified: trunk/docs/examples/gettingstarted/sequencers/src/test/java/org/jboss/example/dna/sequencer/SequencingClientTest.java
===================================================================
--- trunk/docs/examples/gettingstarted/sequencers/src/test/java/org/jboss/example/dna/sequencer/SequencingClientTest.java 2009-05-20 20:32:08 UTC (rev 915)
+++ trunk/docs/examples/gettingstarted/sequencers/src/test/java/org/jboss/example/dna/sequencer/SequencingClientTest.java 2009-05-20 21:38:18 UTC (rev 916)
@@ -33,6 +33,7 @@
import org.jboss.dna.common.util.FileUtil;
import org.junit.After;
import org.junit.Before;
+import org.junit.Ignore;
import org.junit.Test;
/**
@@ -98,6 +99,7 @@
client.shutdownRepository();
}
+ @Ignore
@Test
public void shouldUploadAndSequencePngFile() throws Exception {
client.setUserInterface(new MockUserInterface(this.pngImageUrl, "/a/b/caution.png", 1));
@@ -117,6 +119,7 @@
assertThat(client.getStatistics().getNumberOfNodesSequenced(), is(1l));
}
+ @Ignore
@Test
public void shouldUploadAndSequenceJpegFile() throws Exception {
client.setUserInterface(new MockUserInterface(this.jpegImageUrl, "/a/b/caution.jpeg", 1));
@@ -155,6 +158,7 @@
assertThat(client.getStatistics().getNumberOfNodesSequenced(), is(0l));
}
+ @Ignore
@Test
public void shouldUploadAndSequenceMp3File() throws Exception {
client.setUserInterface(new MockUserInterface(this.mp3Url, "/a/b/test.mp3", 1));
@@ -187,6 +191,7 @@
}
}
+ @Ignore
@Test
public void shouldUploadAndSequenceJavaSourceFile() throws Exception {
client.setUserInterface(new MockUserInterface(this.javaSourceUrl, "/a/b/MySource.java", 1));
Modified: trunk/extensions/dna-common-jdbc/src/main/java/org/jboss/dna/graph/sequencers/JdbcSequencer.java
===================================================================
--- trunk/extensions/dna-common-jdbc/src/main/java/org/jboss/dna/graph/sequencers/JdbcSequencer.java 2009-05-20 20:32:08 UTC (rev 915)
+++ trunk/extensions/dna-common-jdbc/src/main/java/org/jboss/dna/graph/sequencers/JdbcSequencer.java 2009-05-20 21:38:18 UTC (rev 916)
@@ -24,7 +24,7 @@
package org.jboss.dna.graph.sequencers;
import java.sql.Connection;
-import org.jboss.dna.graph.sequencer.SequencerContext;
+import org.jboss.dna.graph.sequencer.StreamSequencerContext;
import org.jboss.dna.graph.sequencer.SequencerOutput;
/**
@@ -46,5 +46,5 @@
*/
void sequence( Connection connection,
SequencerOutput output,
- SequencerContext context );
+ StreamSequencerContext context );
}
Modified: trunk/extensions/dna-sequencer-cnd/src/main/java/org/jboss/dna/sequencer/cnd/CndSequencer.java
===================================================================
--- trunk/extensions/dna-sequencer-cnd/src/main/java/org/jboss/dna/sequencer/cnd/CndSequencer.java 2009-05-20 20:32:08 UTC (rev 915)
+++ trunk/extensions/dna-sequencer-cnd/src/main/java/org/jboss/dna/sequencer/cnd/CndSequencer.java 2009-05-20 21:38:18 UTC (rev 916)
@@ -31,7 +31,7 @@
import org.jboss.dna.graph.io.Destination;
import org.jboss.dna.graph.property.Path;
import org.jboss.dna.graph.property.Property;
-import org.jboss.dna.graph.sequencer.SequencerContext;
+import org.jboss.dna.graph.sequencer.StreamSequencerContext;
import org.jboss.dna.graph.sequencer.SequencerOutput;
import org.jboss.dna.graph.sequencer.StreamSequencer;
@@ -44,11 +44,11 @@
* {@inheritDoc}
*
* @see org.jboss.dna.graph.sequencer.StreamSequencer#sequence(java.io.InputStream,
- * org.jboss.dna.graph.sequencer.SequencerOutput, org.jboss.dna.graph.sequencer.SequencerContext)
+ * org.jboss.dna.graph.sequencer.SequencerOutput, org.jboss.dna.graph.sequencer.StreamSequencerContext)
*/
public void sequence( InputStream stream,
SequencerOutput output,
- SequencerContext context ) {
+ StreamSequencerContext context ) {
// Create the destination that forwards to the sequencer output ...
Destination destination = new OutputDestination(output, context);
// Use the CND importer ...
@@ -64,10 +64,10 @@
protected class OutputDestination implements Destination {
private final SequencerOutput output;
- private final SequencerContext context;
+ private final StreamSequencerContext context;
protected OutputDestination( SequencerOutput output,
- SequencerContext context ) {
+ StreamSequencerContext context ) {
this.output = output;
this.context = context;
}
Modified: trunk/extensions/dna-sequencer-cnd/src/test/java/org/jboss/dna/sequencer/cnd/CndSequencerTest.java
===================================================================
--- trunk/extensions/dna-sequencer-cnd/src/test/java/org/jboss/dna/sequencer/cnd/CndSequencerTest.java 2009-05-20 20:32:08 UTC (rev 915)
+++ trunk/extensions/dna-sequencer-cnd/src/test/java/org/jboss/dna/sequencer/cnd/CndSequencerTest.java 2009-05-20 21:38:18 UTC (rev 916)
@@ -31,7 +31,7 @@
import java.net.URL;
import org.jboss.dna.graph.sequencer.MockSequencerContext;
import org.jboss.dna.graph.sequencer.MockSequencerOutput;
-import org.jboss.dna.graph.sequencer.SequencerContext;
+import org.jboss.dna.graph.sequencer.StreamSequencerContext;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
@@ -47,7 +47,7 @@
private URL cndImages;
private URL cndMp3;
private URL cndBuiltIns;
- private SequencerContext context;
+ private StreamSequencerContext context;
@Before
public void beforeEach() {
Modified: trunk/extensions/dna-sequencer-images/src/main/java/org/jboss/dna/sequencer/image/ImageMetadataSequencer.java
===================================================================
--- trunk/extensions/dna-sequencer-images/src/main/java/org/jboss/dna/sequencer/image/ImageMetadataSequencer.java 2009-05-20 20:32:08 UTC (rev 915)
+++ trunk/extensions/dna-sequencer-images/src/main/java/org/jboss/dna/sequencer/image/ImageMetadataSequencer.java 2009-05-20 21:38:18 UTC (rev 916)
@@ -27,7 +27,7 @@
import org.jboss.dna.graph.property.NameFactory;
import org.jboss.dna.graph.property.Path;
import org.jboss.dna.graph.property.PathFactory;
-import org.jboss.dna.graph.sequencer.SequencerContext;
+import org.jboss.dna.graph.sequencer.StreamSequencerContext;
import org.jboss.dna.graph.sequencer.SequencerOutput;
import org.jboss.dna.graph.sequencer.StreamSequencer;
@@ -88,11 +88,11 @@
/**
* {@inheritDoc}
*
- * @see StreamSequencer#sequence(InputStream, SequencerOutput, SequencerContext)
+ * @see StreamSequencer#sequence(InputStream, SequencerOutput, StreamSequencerContext)
*/
public void sequence( InputStream stream,
SequencerOutput output,
- SequencerContext context ) {
+ StreamSequencerContext context ) {
ImageMetadata metadata = new ImageMetadata();
metadata.setInput(stream);
Modified: trunk/extensions/dna-sequencer-images/src/test/java/org/jboss/dna/sequencer/image/ImageMetadataSequencerTest.java
===================================================================
--- trunk/extensions/dna-sequencer-images/src/test/java/org/jboss/dna/sequencer/image/ImageMetadataSequencerTest.java 2009-05-20 20:32:08 UTC (rev 915)
+++ trunk/extensions/dna-sequencer-images/src/test/java/org/jboss/dna/sequencer/image/ImageMetadataSequencerTest.java 2009-05-20 21:38:18 UTC (rev 916)
@@ -32,7 +32,7 @@
import java.net.URL;
import org.jboss.dna.graph.sequencer.MockSequencerContext;
import org.jboss.dna.graph.sequencer.MockSequencerOutput;
-import org.jboss.dna.graph.sequencer.SequencerContext;
+import org.jboss.dna.graph.sequencer.StreamSequencerContext;
import org.jboss.dna.sequencer.image.ImageMetadataSequencer;
import org.junit.After;
import org.junit.Before;
@@ -51,7 +51,7 @@
private URL cautionJpg;
private URL cautionPict;
private URL cautionPng;
- private SequencerContext context;
+ private StreamSequencerContext context;
@Before
public void beforeEach() {
Modified: trunk/extensions/dna-sequencer-java/src/main/java/org/jboss/dna/sequencer/java/JavaMetadataSequencer.java
===================================================================
--- trunk/extensions/dna-sequencer-java/src/main/java/org/jboss/dna/sequencer/java/JavaMetadataSequencer.java 2009-05-20 20:32:08 UTC (rev 915)
+++ trunk/extensions/dna-sequencer-java/src/main/java/org/jboss/dna/sequencer/java/JavaMetadataSequencer.java 2009-05-20 21:38:18 UTC (rev 916)
@@ -29,7 +29,7 @@
import org.jboss.dna.graph.property.NameFactory;
import org.jboss.dna.graph.property.Path;
import org.jboss.dna.graph.property.PathFactory;
-import org.jboss.dna.graph.sequencer.SequencerContext;
+import org.jboss.dna.graph.sequencer.StreamSequencerContext;
import org.jboss.dna.graph.sequencer.SequencerOutput;
import org.jboss.dna.graph.sequencer.StreamSequencer;
import org.jboss.dna.sequencer.java.metadata.AnnotationMetadata;
@@ -175,11 +175,11 @@
* {@inheritDoc}
*
* @see org.jboss.dna.graph.sequencer.StreamSequencer#sequence(java.io.InputStream,
- * org.jboss.dna.graph.sequencer.SequencerOutput, org.jboss.dna.graph.sequencer.SequencerContext)
+ * org.jboss.dna.graph.sequencer.SequencerOutput, org.jboss.dna.graph.sequencer.StreamSequencerContext)
*/
public void sequence( InputStream stream,
SequencerOutput output,
- SequencerContext context ) {
+ StreamSequencerContext context ) {
JavaMetadata javaMetadata = null;
NameFactory nameFactory = context.getValueFactories().getNameFactory();
PathFactory pathFactory = context.getValueFactories().getPathFactory();
Modified: trunk/extensions/dna-sequencer-java/src/test/java/org/jboss/dna/sequencer/java/JavaMetadataSequencerTest.java
===================================================================
--- trunk/extensions/dna-sequencer-java/src/test/java/org/jboss/dna/sequencer/java/JavaMetadataSequencerTest.java 2009-05-20 20:32:08 UTC (rev 915)
+++ trunk/extensions/dna-sequencer-java/src/test/java/org/jboss/dna/sequencer/java/JavaMetadataSequencerTest.java 2009-05-20 21:38:18 UTC (rev 916)
@@ -33,7 +33,7 @@
import java.io.InputStream;
import org.jboss.dna.graph.sequencer.MockSequencerContext;
import org.jboss.dna.graph.sequencer.MockSequencerOutput;
-import org.jboss.dna.graph.sequencer.SequencerContext;
+import org.jboss.dna.graph.sequencer.StreamSequencerContext;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
@@ -47,7 +47,7 @@
private InputStream content;
private MockSequencerOutput output;
private File source;
- private SequencerContext context;
+ private StreamSequencerContext context;
@Before
public void beforeEach() {
Modified: trunk/extensions/dna-sequencer-mp3/src/main/java/org/jboss/dna/sequencer/mp3/Mp3MetadataSequencer.java
===================================================================
--- trunk/extensions/dna-sequencer-mp3/src/main/java/org/jboss/dna/sequencer/mp3/Mp3MetadataSequencer.java 2009-05-20 20:32:08 UTC (rev 915)
+++ trunk/extensions/dna-sequencer-mp3/src/main/java/org/jboss/dna/sequencer/mp3/Mp3MetadataSequencer.java 2009-05-20 21:38:18 UTC (rev 916)
@@ -24,7 +24,7 @@
package org.jboss.dna.sequencer.mp3;
import java.io.InputStream;
-import org.jboss.dna.graph.sequencer.SequencerContext;
+import org.jboss.dna.graph.sequencer.StreamSequencerContext;
import org.jboss.dna.graph.sequencer.SequencerOutput;
import org.jboss.dna.graph.sequencer.StreamSequencer;
@@ -63,11 +63,11 @@
/**
* {@inheritDoc}
*
- * @see StreamSequencer#sequence(InputStream, SequencerOutput, SequencerContext)
+ * @see StreamSequencer#sequence(InputStream, SequencerOutput, StreamSequencerContext)
*/
public void sequence( InputStream stream,
SequencerOutput output,
- SequencerContext context ) {
+ StreamSequencerContext context ) {
Mp3Metadata metadata = Mp3Metadata.instance(stream);
if (metadata != null) {
Modified: trunk/extensions/dna-sequencer-msoffice/src/main/java/org/jboss/dna/sequencer/msoffice/MSOfficeMetadataSequencer.java
===================================================================
--- trunk/extensions/dna-sequencer-msoffice/src/main/java/org/jboss/dna/sequencer/msoffice/MSOfficeMetadataSequencer.java 2009-05-20 20:32:08 UTC (rev 915)
+++ trunk/extensions/dna-sequencer-msoffice/src/main/java/org/jboss/dna/sequencer/msoffice/MSOfficeMetadataSequencer.java 2009-05-20 21:38:18 UTC (rev 916)
@@ -27,7 +27,7 @@
import java.io.InputStream;
import java.util.Iterator;
import java.util.List;
-import org.jboss.dna.graph.sequencer.SequencerContext;
+import org.jboss.dna.graph.sequencer.StreamSequencerContext;
import org.jboss.dna.graph.sequencer.SequencerOutput;
import org.jboss.dna.graph.sequencer.StreamSequencer;
import org.jboss.dna.sequencer.msoffice.excel.ExcelMetadata;
@@ -123,7 +123,7 @@
*/
public void sequence( InputStream stream,
SequencerOutput output,
- SequencerContext context ) {
+ StreamSequencerContext context ) {
MSOfficeMetadata metadata = MSOfficeMetadataReader.instance(stream);
Modified: trunk/extensions/dna-sequencer-xml/src/main/java/org/jboss/dna/sequencer/xml/XmlSequencer.java
===================================================================
--- trunk/extensions/dna-sequencer-xml/src/main/java/org/jboss/dna/sequencer/xml/XmlSequencer.java 2009-05-20 20:32:08 UTC (rev 915)
+++ trunk/extensions/dna-sequencer-xml/src/main/java/org/jboss/dna/sequencer/xml/XmlSequencer.java 2009-05-20 21:38:18 UTC (rev 916)
@@ -27,7 +27,7 @@
import org.jboss.dna.common.text.TextDecoder;
import org.jboss.dna.graph.JcrNtLexicon;
import org.jboss.dna.graph.property.Name;
-import org.jboss.dna.graph.sequencer.SequencerContext;
+import org.jboss.dna.graph.sequencer.StreamSequencerContext;
import org.jboss.dna.graph.sequencer.SequencerOutput;
import org.jboss.dna.graph.sequencer.StreamSequencer;
import org.xml.sax.InputSource;
@@ -84,11 +84,11 @@
/**
* {@inheritDoc}
*
- * @see org.jboss.dna.graph.sequencer.StreamSequencer#sequence(InputStream, SequencerOutput, SequencerContext)
+ * @see org.jboss.dna.graph.sequencer.StreamSequencer#sequence(InputStream, SequencerOutput, StreamSequencerContext)
*/
public void sequence( InputStream stream,
SequencerOutput output,
- SequencerContext context ) {
+ StreamSequencerContext context ) {
XMLReader reader;
try {
// Set up the XML handler ...
Modified: trunk/extensions/dna-sequencer-xml/src/main/java/org/jboss/dna/sequencer/xml/XmlSequencerHandler.java
===================================================================
--- trunk/extensions/dna-sequencer-xml/src/main/java/org/jboss/dna/sequencer/xml/XmlSequencerHandler.java 2009-05-20 20:32:08 UTC (rev 915)
+++ trunk/extensions/dna-sequencer-xml/src/main/java/org/jboss/dna/sequencer/xml/XmlSequencerHandler.java 2009-05-20 21:38:18 UTC (rev 916)
@@ -43,7 +43,7 @@
import org.jboss.dna.graph.property.PropertyFactory;
import org.jboss.dna.graph.property.ValueFormatException;
import org.jboss.dna.graph.property.basic.LocalNamespaceRegistry;
-import org.jboss.dna.graph.sequencer.SequencerContext;
+import org.jboss.dna.graph.sequencer.StreamSequencerContext;
import org.jboss.dna.graph.sequencer.SequencerOutput;
import org.xml.sax.Attributes;
import org.xml.sax.SAXParseException;
@@ -55,7 +55,7 @@
public class XmlSequencerHandler extends DefaultHandler2 {
private final SequencerOutput output;
- private final SequencerContext context;
+ private final StreamSequencerContext context;
/**
* Decoder for XML names, to turn '_xHHHH_' sequences in the XML element and attribute names into the corresponding UTF-16
@@ -138,7 +138,7 @@
* @param scoping
*/
XmlSequencerHandler( SequencerOutput output,
- SequencerContext context,
+ StreamSequencerContext context,
Name nameAttribute,
Name defaultPrimaryType,
TextDecoder textDecoder,
Modified: trunk/extensions/dna-sequencer-xml/src/test/java/org/jboss/dna/sequencer/xml/InheritingXmlSequencerTest.java
===================================================================
--- trunk/extensions/dna-sequencer-xml/src/test/java/org/jboss/dna/sequencer/xml/InheritingXmlSequencerTest.java 2009-05-20 20:32:08 UTC (rev 915)
+++ trunk/extensions/dna-sequencer-xml/src/test/java/org/jboss/dna/sequencer/xml/InheritingXmlSequencerTest.java 2009-05-20 21:38:18 UTC (rev 916)
@@ -33,7 +33,7 @@
import org.jboss.dna.graph.property.Name;
import org.jboss.dna.graph.sequencer.MockSequencerContext;
import org.jboss.dna.graph.sequencer.MockSequencerOutput;
-import org.jboss.dna.graph.sequencer.SequencerContext;
+import org.jboss.dna.graph.sequencer.StreamSequencerContext;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
@@ -49,7 +49,7 @@
private InputStream stream;
private MockSequencerOutput output;
private URL xsd;
- private SequencerContext context;
+ private StreamSequencerContext context;
@Before
public void beforeEach() {
Modified: trunk/extensions/dna-sequencer-xml/src/test/java/org/jboss/dna/sequencer/xml/XmlSequencerHandlerTest.java
===================================================================
--- trunk/extensions/dna-sequencer-xml/src/test/java/org/jboss/dna/sequencer/xml/XmlSequencerHandlerTest.java 2009-05-20 20:32:08 UTC (rev 915)
+++ trunk/extensions/dna-sequencer-xml/src/test/java/org/jboss/dna/sequencer/xml/XmlSequencerHandlerTest.java 2009-05-20 21:38:18 UTC (rev 916)
@@ -45,7 +45,7 @@
import org.jboss.dna.graph.property.Property;
import org.jboss.dna.graph.sequencer.MockSequencerContext;
import org.jboss.dna.graph.sequencer.MockSequencerOutput;
-import org.jboss.dna.graph.sequencer.SequencerContext;
+import org.jboss.dna.graph.sequencer.StreamSequencerContext;
import org.junit.Before;
import org.junit.Test;
import org.xml.sax.InputSource;
@@ -59,7 +59,7 @@
public class XmlSequencerHandlerTest {
private XmlSequencerHandler handler;
- private SequencerContext context;
+ private StreamSequencerContext context;
private MockSequencerOutput output;
private TextDecoder decoder;
private Name primaryType;
Modified: trunk/extensions/dna-sequencer-xml/src/test/java/org/jboss/dna/sequencer/xml/XmlSequencerTest.java
===================================================================
--- trunk/extensions/dna-sequencer-xml/src/test/java/org/jboss/dna/sequencer/xml/XmlSequencerTest.java 2009-05-20 20:32:08 UTC (rev 915)
+++ trunk/extensions/dna-sequencer-xml/src/test/java/org/jboss/dna/sequencer/xml/XmlSequencerTest.java 2009-05-20 21:38:18 UTC (rev 916)
@@ -33,7 +33,7 @@
import org.jboss.dna.graph.property.Name;
import org.jboss.dna.graph.sequencer.MockSequencerContext;
import org.jboss.dna.graph.sequencer.MockSequencerOutput;
-import org.jboss.dna.graph.sequencer.SequencerContext;
+import org.jboss.dna.graph.sequencer.StreamSequencerContext;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
@@ -66,7 +66,7 @@
private URL xml3;
private URL xml4;
private URL xsd;
- private SequencerContext context;
+ private StreamSequencerContext context;
@Before
public void beforeEach() {
Modified: trunk/extensions/dna-sequencer-zip/src/main/java/org/jboss/dna/sequencer/zip/ZipSequencer.java
===================================================================
--- trunk/extensions/dna-sequencer-zip/src/main/java/org/jboss/dna/sequencer/zip/ZipSequencer.java 2009-05-20 20:32:08 UTC (rev 915)
+++ trunk/extensions/dna-sequencer-zip/src/main/java/org/jboss/dna/sequencer/zip/ZipSequencer.java 2009-05-20 21:38:18 UTC (rev 916)
@@ -28,7 +28,7 @@
import java.io.InputStream;
import java.util.zip.ZipEntry;
import java.util.zip.ZipInputStream;
-import org.jboss.dna.graph.sequencer.SequencerContext;
+import org.jboss.dna.graph.sequencer.StreamSequencerContext;
import org.jboss.dna.graph.sequencer.SequencerOutput;
import org.jboss.dna.graph.sequencer.StreamSequencer;
@@ -42,11 +42,11 @@
* {@inheritDoc}
*
* @see org.jboss.dna.graph.sequencer.StreamSequencer#sequence(java.io.InputStream,
- * org.jboss.dna.graph.sequencer.SequencerOutput, org.jboss.dna.graph.sequencer.SequencerContext)
+ * org.jboss.dna.graph.sequencer.SequencerOutput, org.jboss.dna.graph.sequencer.StreamSequencerContext)
*/
public void sequence( InputStream stream,
SequencerOutput output,
- SequencerContext context ) {
+ StreamSequencerContext context ) {
try {
ZipInputStream in = new ZipInputStream(stream);
ZipEntry entry = in.getNextEntry();
Modified: trunk/extensions/dna-sequencer-zip/src/test/java/org/jboss/dna/sequencer/zip/ZipSequencerTest.java
===================================================================
--- trunk/extensions/dna-sequencer-zip/src/test/java/org/jboss/dna/sequencer/zip/ZipSequencerTest.java 2009-05-20 20:32:08 UTC (rev 915)
+++ trunk/extensions/dna-sequencer-zip/src/test/java/org/jboss/dna/sequencer/zip/ZipSequencerTest.java 2009-05-20 21:38:18 UTC (rev 916)
@@ -28,7 +28,7 @@
import static org.junit.Assert.assertThat;
import static org.mockito.Mockito.mock;
import java.io.InputStream;
-import org.jboss.dna.graph.sequencer.SequencerContext;
+import org.jboss.dna.graph.sequencer.StreamSequencerContext;
import org.junit.After;
import org.junit.Test;
@@ -58,7 +58,7 @@
InputStream is = getTestZip("testzip.zip");
ZipSequencer zs = new ZipSequencer();
SequencingOutputTestClass seqtest = new SequencingOutputTestClass();
- SequencerContext context = mock(SequencerContext.class);
+ StreamSequencerContext context = mock(StreamSequencerContext.class);
zs.sequence(is, seqtest, context);
assertThat(seqtest.properties.get(2).getPath(), is("zip:content/test subfolder/test2.txt/jcr:content"));
15 years, 1 month
DNA SVN: r915 - trunk/dna-graph/src/main/java/org/jboss/dna/graph/observe.
by dna-commits@lists.jboss.org
Author: rhauch
Date: 2009-05-20 16:32:08 -0400 (Wed, 20 May 2009)
New Revision: 915
Removed:
trunk/dna-graph/src/main/java/org/jboss/dna/graph/observe/ChangeFeed.java
trunk/dna-graph/src/main/java/org/jboss/dna/graph/observe/ChangeTimeline.java
Log:
DNA-252 Complete support for events to the connector framework
Removed the ChangeFeed and ChangeTimeline classes, since they really aren't required at the moment.
Deleted: trunk/dna-graph/src/main/java/org/jboss/dna/graph/observe/ChangeFeed.java
===================================================================
--- trunk/dna-graph/src/main/java/org/jboss/dna/graph/observe/ChangeFeed.java 2009-05-20 20:30:39 UTC (rev 914)
+++ trunk/dna-graph/src/main/java/org/jboss/dna/graph/observe/ChangeFeed.java 2009-05-20 20:32:08 UTC (rev 915)
@@ -1,52 +0,0 @@
-/*
- * JBoss DNA (http://www.jboss.org/dna)
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- * See the AUTHORS.txt file in the distribution for a full listing of
- * individual contributors.
- *
- * JBoss DNA is free software. Unless otherwise indicated, all code in JBoss DNA
- * is licensed to you under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * JBoss DNA is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.dna.graph.observe;
-
-import org.jboss.dna.graph.property.DateTime;
-
-/**
- * Interface used to poll for the changes that have occurred during a specified time period.
- */
-public interface ChangeFeed {
-
- /**
- * Get the changes that were made since the supplied timestamp.
- *
- * @param timestamp the timestamp after which all changes should be returned
- * @return the iterator over the changes that occurred after the supplied timestamp.
- */
- ChangeTimeline changesSince( DateTime timestamp );
-
- /**
- * Get the changes that were made since the supplied timestamp.
- *
- * @param beginning the timestamp at the beginning of the timeline (exclusive), or null if the earliest timestamp should be
- * used
- * @param end the timestamp at the end of the timeline (inclusive), or null if the current timestamp should be used
- * @return the iterator over the changes that occurred after the supplied timestamp.
- */
- ChangeTimeline changesBetween( DateTime beginning,
- DateTime end );
-
-}
Deleted: trunk/dna-graph/src/main/java/org/jboss/dna/graph/observe/ChangeTimeline.java
===================================================================
--- trunk/dna-graph/src/main/java/org/jboss/dna/graph/observe/ChangeTimeline.java 2009-05-20 20:30:39 UTC (rev 914)
+++ trunk/dna-graph/src/main/java/org/jboss/dna/graph/observe/ChangeTimeline.java 2009-05-20 20:32:08 UTC (rev 915)
@@ -1,93 +0,0 @@
-/*
- * JBoss DNA (http://www.jboss.org/dna)
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- * See the AUTHORS.txt file in the distribution for a full listing of
- * individual contributors.
- *
- * JBoss DNA is free software. Unless otherwise indicated, all code in JBoss DNA
- * is licensed to you under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * JBoss DNA is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.dna.graph.observe;
-
-import java.util.Collection;
-import java.util.Iterator;
-import net.jcip.annotations.Immutable;
-import org.jboss.dna.graph.property.DateTime;
-
-/**
- * The changes that were made since some time.
- */
-@Immutable
-public class ChangeTimeline implements Iterable<Changes> {
-
- private final Collection<Changes> changes;
- private final DateTime after;
- private final DateTime until;
-
- public ChangeTimeline( Collection<Changes> changes,
- DateTime after,
- DateTime until ) {
- this.changes = changes;
- this.after = after;
- this.until = until;
- }
-
- /**
- * Get the timestamp after which all the changes occur.
- *
- * @return the timestamp of the changes; never null
- */
- public DateTime after() {
- return after;
- }
-
- /**
- * Get the timestamp of the last change set.
- *
- * @return the timestamp of the changes; never null
- */
- public DateTime until() {
- return until;
- }
-
- /**
- * Get the number of change sets.
- *
- * @return the number of change sets
- */
- public int size() {
- return changes.size();
- }
-
- /**
- * Deterine if there were no changes durign this timeline.
- *
- * @return true if this timeline is empty, or false if there is at least one change
- */
- public boolean isEmpty() {
- return changes.isEmpty();
- }
-
- /**
- * {@inheritDoc}
- *
- * @see java.lang.Iterable#iterator()
- */
- public Iterator<Changes> iterator() {
- return changes.iterator();
- }
-}
15 years, 1 month