Uploaded image for project: 'ModeShape'
  1. ModeShape
  2. MODE-460

filesystem source doesn't appear on federate source projection

    XMLWordPrintable

Details

    Description

      When I create a filesystem source I can access its contents using the graph api. But the same content doesn't appear on a federated source with the filesystem source on a projection path. I used the same logic on the docs/examples/repository project configuration, just adding the /tmp to a filesystem source. I've tested the same scenario using the JAAS configuration. The test case and configuration file is here:

      – configuration file: configRepositoryWithFileSystemConnector.xml –
      <?xml version="1.0" encoding="UTF-8"?>
      <!--
      ~ JBoss DNA (http://www.jboss.org/dna)
      ~
      ~ See the COPYRIGHT.txt file distributed with this work for information
      ~ regarding copyright ownership. Some portions may be licensed
      ~ to Red Hat, Inc. under one or more contributor license agreements.
      ~ See the AUTHORS.txt file in the distribution for a full listing of
      ~ individual contributors.
      ~
      ~ JBoss DNA is free software. Unless otherwise indicated, all code in JBoss DNA
      ~ is licensed to you under the terms of the GNU Lesser General Public License as
      ~ published by the Free Software Foundation; either version 2.1 of
      ~ the License, or (at your option) any later version.
      ~
      ~ JBoss DNA is distributed in the hope that it will be useful,
      ~ but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
      ~ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
      ~ for more details.
      ~
      ~ You should have received a copy of the GNU Lesser General Public License
      ~ along with this distribution; if not, write to:
      ~ Free Software Foundation, Inc.
      ~ 51 Franklin Street, Fifth Floor
      ~ Boston, MA 02110-1301 USA
      -->
      <configuration xmlns:dna="http://www.jboss.org/dna/1.0" xmlns:jcr="http://www.jcp.org/jcr/1.0">
      <!--
      Define the sources for the content. These sources are directly accessible using the DNA-specific Graph API.
      In fact, this is how the DNA JCR implementation works. You can think of these as being similar to
      JDBC DataSource objects, except that they expose graph content via the Graph API instead of records via SQL or JDBC.
      -->
      <dna:sources jcr:primaryType="nt:unstructured">

      <dna:source jcr:name="FileSystem" dna:classname="org.jboss.dna.connector.filesystem.FileSystemSource">
      <defaultWorkspaceName>workspace2</defaultWorkspaceName>
      <directoryForDefaultWorkspace>/tmp/</directoryForDefaultWorkspace>
      </dna:source>

      <!--
      The 'Cars' repository is an in-memory source with a single default workspace (though others could be created, too).
      -->
      <dna:source jcr:name="Cars" dna:classname="org.jboss.dna.graph.connector.inmemory.InMemoryRepositorySource" dna:retryLimit="3" dna:defaultWorkspaceName="workspace1"/>
      <!--
      The 'Aircraft' repository is also an in-memory source with a single default workspace.
      By defining a default workspace, the clients using the Graph API will by default use that workspace,
      but can easily say to use other workspaces (or create, clone, or destroy workspaces).
      -->
      <dna:source jcr:name="Aircraft" dna:classname="org.jboss.dna.graph.connector.inmemory.InMemoryRepositorySource">
      <!-- Define the name of the workspace used by default. Optional, but convenient. -->
      <defaultWorkspaceName>workspace2</defaultWorkspaceName>
      </dna:source>
      <!--
      The 'Vehicles' repository is a federated source that owns none of its own content, but instead
      projects (in this case) all of the content from the 'Cars' source as if it appears
      under '/Vehicles/Cars', while all the 'Aircraft' content appears under '/Vehicles/Aircraft'.
      -->
      <dna:source jcr:name="Vehicles">
      <dna:classname>org.jboss.dna.graph.connector.federation.FederatedRepositorySource</dna:classname>
      <dna:workspaces>
      <!--
      Unlike some other repository sources, federated sources have to define all of their workspaces,
      including how and where the content is projected. So, we only need a single workspace,
      but we could actually define additional workspaces that expose various combinations or portions
      of 'Cars' and/or 'Aircraft' content.
      -->
      <dna:workspace jcr:name="virtual">
      <dna:projections>
      <dna:projection jcr:name="TempFiles projection" dna:source="FileSystem" dna:workspaceName="workspace2">
      <dna:projectionRules>/Vehicles/FileSystem => /</dna:projectionRules>
      </dna:projection>

      <!-- Project the 'Cars' content, starting with the '/Cars' node. -->
      <dna:projection jcr:name="Cars projection" dna:source="Cars" dna:workspaceName="workspace1">
      <dna:projectionRules>/Vehicles/Cars => /Cars</dna:projectionRules>
      </dna:projection>
      <!-- Project the 'Aicraft' content, starting with the '/Aircraft' node. -->
      <dna:projection jcr:name="Aircarft projection" dna:source="Aircraft" dna:workspaceName="workspace2">
      <dna:projectionRules>/Vehicles/Aircraft => /Aircraft</dna:projectionRules>
      </dna:projection>
      <!-- Project the 'System' content. Only needed when this source is accessed through JCR. -->
      <dna:projection jcr:name="System projection" dna:source="System" dna:workspaceName="default">
      <dna:projectionRules>/jcr:system => /</dna:projectionRules>
      </dna:projection>
      </dna:projections>
      </dna:workspace>
      </dna:workspaces>
      </dna:source>
      <!--
      A 'System' source needed for the '/jcr:system' branch of the Vehicles source when it is access through JCR.
      -->
      <dna:source jcr:name="System" dna:classname="org.jboss.dna.graph.connector.inmemory.InMemoryRepositorySource" dna:retryLimit="3" dna:defaultWorkspaceName="default"/>
      </dna:sources>
      <!--
      Define the sequencers. This is an optional section. For this example, we're not using any sequencers.
      -->
      <dna:sequencers>
      <!--dna:sequencer jcr:name="Image Sequencer" dna:classname="org.jboss.dna.sequencer.image.ImageMetadataSequencer">
      <dna:description>Image metadata sequencer</dna:description>
      <dna:pathExpression>/foo/source => /foo/target</dna:pathExpression>
      <dna:pathExpression>/bar/source => /bar/target</dna:pathExpression>
      </dna:sequencer-->
      </dna:sequencers>
      <!--
      Define the mime type detectors. This is an optional section. By default, each engine will use the
      MIME type detector that uses filename extensions. So we wouldn't need to define the same detector again,
      but this is how you'd define another extension.
      -->
      <dna:mimeTypeDetectors>
      <dna:mimeTypeDetector jcr:name="Detector">
      <dna:description>Standard extension-based MIME type detector</dna:description>
      <!--
      Specify the implementation class (required), as a child element or attribute on parent element.
      -->
      <dna:classname>org.jboss.dna.graph.mimetype.ExtensionBasedMimeTypeDetector</dna:classname>
      <!--
      Specify the classpath (optional) as an ordered list of 'names', where each name is significant to
      the classpath factory. For example, a name could be an OSGI identifier or a Maven coordinate,
      depending upon the classpath factory being used. If there is only one 'name' in the classpath,
      it may be specified as an attribute on the 'mimeTypeDetector' element. If there is more than one
      'name', then they must be specified as child 'classpath' elements. Blank or empty values are ignored.
      -->
      <dna:classpath></dna:classpath>
      <dna:classpath></dna:classpath>
      </dna:mimeTypeDetector>
      </dna:mimeTypeDetectors>
      <!--
      Define the JCR repositories
      -->
      <dna:repositories>
      <!--
      Define a JCR repository that accesses the 'Cars' source directly.
      This of course is optional, since we could access the same content through 'vehicles'.
      -->
      <dna:repository jcr:name="Cars">
      <!-- Specify the source that should be used for the repository -->
      <dna:source>Cars</dna:source>
      <!-- Define the options for the JCR repository, using camelcase version of JcrRepository.Option names -->
      <dna:options jcr:primaryType="dna:options">
      <jaasLoginConfigName jcr:primaryType="dna:option" dna:value="dna-jcr"/>
      </dna:options>
      <!-- Define any custom node types. Importing CND files via JcrConfiguration is equivalent to specifying here. -->
      <dna:nodeTypes jcr:primaryType="dna:nodeTypes"/>
      <!-- Define any namespaces for this repository, other than those already defined by JCR or DNA -->
      <namespaces jcr:primaryType="dna:namespaces">
      <car jcr:primaryType="dna:namespace" dna:uri="http://jboss.org/dna/examples/cars/1.0"/>
      </namespaces>
      </dna:repository>
      <!--
      Define a JCR repository that accesses the 'Aircraft' source directly.
      This of course isn't really necessary for this example, since we could access the same content through 'vehicles'.
      -->
      <dna:repository jcr:name="Aircraft">
      <!-- Specify the source that should be used for the repository -->
      <dna:source>Aircraft</dna:source>
      <!-- Define the options for the JCR repository, using camelcase version of JcrRepository.Option names -->
      <dna:options jcr:primaryType="dna:options">
      <jaasLoginConfigName jcr:primaryType="dna:option" dna:value="dna-jcr"/>
      </dna:options>
      </dna:repository>
      <!--
      Define a JCR repository that accesses the 'Vehicles' federated source directly,
      which is defined in the sources to be a projection of the 'Cars' and 'Vehicles' content.
      -->
      <!-- Define a JCR repository that accesses the 'Vehicles' federated source directly -->
      <dna:repository jcr:name="Vehicles">
      <!-- Specify the source that should be used for the repository -->
      <dna:source>Vehicles</dna:source>
      <!-- Define the options for the JCR repository, using camelcase version of JcrRepository.Option names -->
      <dna:options jcr:primaryType="dna:options">
      <projectNodeTypes jcr:primaryType="dna:option" dna:value="false"/>
      <jaasLoginConfigName jcr:primaryType="dna:option" dna:value="dna-jcr"/>
      </dna:options>
      <!-- Define any custom node types. Importing CND files via JcrConfiguration is equivalent to specifying here. -->
      <dna:nodeTypes jcr:primaryType="dna:nodeTypes"/>
      <!-- Define any namespaces for this repository, other than those already defined by JCR, DNA or by imported content. -->
      <dna:namespaces jcr:primaryType="dna:namespaces">
      <car jcr:primaryType="dna:namespace" dna:uri="http://jboss.org/dna/examples/cars/1.0"/>
      <air jcr:primaryType="dna:namespace" dna:uri="http://jboss.org/dna/examples/aircraft/1.0"/>
      </dna:namespaces>
      </dna:repository>
      </dna:repositories>
      </configuration>

      – test case –

      package org.jboss.example.dna.repository;

      import static org.hamcrest.core.Is.is;
      import static org.hamcrest.core.IsNull.notNullValue;
      import static org.junit.Assert.assertThat;

      import java.net.URL;

      import org.jboss.dna.graph.Graph;
      import org.jboss.dna.jcr.JcrConfiguration;
      import org.jboss.dna.jcr.JcrEngine;
      import org.junit.Test;

      public class FileSystemConnectorUnderFederatedSourceTest {

      @Test
      public void shouldHaveProjectionOfFileSystemSourceInsideFederatedSource()
      throws Exception

      { JcrConfiguration configuration = new JcrConfiguration(); URL configUrl = Thread.currentThread().getContextClassLoader() .getResource("configRepositoryWithFileSystemConnector.xml"); assertThat(configUrl, is(notNullValue())); configuration.loadFrom(configUrl); JcrEngine engine = configuration.build(); engine.start(); Graph vehiclesGraph = engine.getGraph("Vehicles"); assertThat(vehiclesGraph.getNodeAt("/FileSystem"), is(notNullValue())); }

      }

      Attachments

        Activity

          People

            rhauch Randall Hauch (Inactive)
            feuteston_jira Luiz Fernando Teston (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: