Examples of Subgraph


Examples of org.jboss.dna.graph.Subgraph

        DateTime now = dateFactory.create();
        DateTime newExpirationDate = now.plusMillis(JcrEngine.LOCK_EXTENSION_INTERVAL_IN_MILLIS);

        Path locksPath = pathFactory.createAbsolutePath(JcrLexicon.SYSTEM, DnaLexicon.LOCKS);

        Subgraph locksGraph = null;
        try {
            locksGraph = systemGraph.getSubgraphOfDepth(2).at(locksPath);
        } catch (PathNotFoundException pnfe) {
            // It's possible for this to run before the dna:locks child node gets added to the /jcr:system node.
            return;
        }

        for (Location lockLocation : locksGraph.getRoot().getChildren()) {
            Node lockNode = locksGraph.getNode(lockLocation);

            Boolean isSessionScoped = booleanFactory.create(lockNode.getProperty(DnaLexicon.IS_SESSION_SCOPED).getFirstValue());

            if (!isSessionScoped) continue;
            String lockingSession = stringFactory.create(lockNode.getProperty(DnaLexicon.LOCKING_SESSION).getFirstValue());
View Full Code Here

Examples of org.jboss.dna.graph.Subgraph

                                     Name... names ) {
            super(returnObject, batch, path, names);
            // Load the current options ...
            try {
                Path optionsPath = context.getValueFactories().getPathFactory().create(path, DnaLexicon.OPTIONS);
                Subgraph options = batch.getGraph().getSubgraphOfDepth(2).at(optionsPath);
                for (Location optionChild : options.getRoot().getChildren()) {
                    Node option = options.getNode(optionChild);
                    Property property = option.getProperty(DnaLexicon.VALUE);
                    if (property != null && property.isEmpty()) {
                        try {
                            Option key = Option.findOption(optionChild.getPath()
                                                                      .getLastSegment()
View Full Code Here

Examples of org.jboss.dna.graph.Subgraph

    protected Set<UUID> getUuidsInBranch( Path sourcePath,
                                          String workspace ) {
        String existingWorkspace = graph.getCurrentWorkspaceName();
        try {
            graph.useWorkspace(workspace);
            Subgraph subgraph = graph.getSubgraphOfDepth(ReadBranchRequest.NO_MAXIMUM_DEPTH).at(sourcePath);
            // Collect up the UUIDs; we use UUID here because that's what JCR requires ...
            Set<UUID> uuids = new HashSet<UUID>();
            for (SubgraphNode nodeInSubgraph : subgraph) {
                UUID uuid = nodeInSubgraph.getLocation().getUuid();
                if (uuid != null) uuids.add(uuid);
View Full Code Here

Examples of org.jboss.dna.graph.Subgraph

                     .and()
                     .save();

        // Verify that the graph has been updated correctly ...
        DnaConfiguration.ConfigurationDefinition content = configuration.getConfigurationDefinition();
        Subgraph subgraph = content.graph().getSubgraphOfDepth(3).at("/");
        assertThat(subgraph.getNode("/dna:sources"), is(notNullValue()));
        assertThat(subgraph.getNode("/dna:sources/name"), is(notNullValue()));
        assertThat(subgraph.getNode("/dna:sources/name"), hasProperty(DnaLexicon.RETRY_LIMIT, 100));
        assertThat(subgraph.getNode("/dna:sources/name"), hasProperty("defaultCachePolicy", cachePolicy));
        assertThat(subgraph.getNode("/dna:sources/name"), hasProperty("defaultWorkspaceName", "default workspace name"));
        assertThat(subgraph.getNode("/dna:sources/name"), hasProperty("rootNodeUuid", rootUuid));
    }
View Full Code Here

Examples of org.jboss.dna.graph.Subgraph

        engine = configuration.build();
        engine.start();

        // Verify that the graph has been updated correctly ...
        Graph config = engine.getGraph(JcrConfiguration.DEFAULT_CONFIGURATION_SOURCE_NAME);
        Subgraph subgraph = config.getSubgraphOfDepth(6).at("/");
        assertThat(subgraph.getNode("/dna:sources"), is(notNullValue()));
        assertThat(subgraph.getNode("/dna:sources/Source2"), is(notNullValue()));
        assertThat(subgraph.getNode("/dna:sources/Source2"), hasProperty(DnaLexicon.CLASSNAME,
                                                                         InMemoryRepositorySource.class.getName()));
        assertThat(subgraph.getNode("/dna:repositories"), is(notNullValue()));
        assertThat(subgraph.getNode("/dna:repositories/JCR Repository"), is(notNullValue()));
        assertThat(subgraph.getNode("/dna:repositories/JCR Repository"), hasProperty(DnaLexicon.SOURCE_NAME, "Source2"));
        assertThat(subgraph.getNode("/dna:repositories/JCR Repository/dna:options"), is(notNullValue()));
        assertThat(subgraph.getNode("/dna:repositories/JCR Repository/dna:options/JAAS_LOGIN_CONFIG_NAME"),
                   hasProperty(DnaLexicon.VALUE, "test"));

        JcrRepository repository = engine.getRepository("JCR Repository");

        Map<Option, String> options = new HashMap<Option, String>();
View Full Code Here

Examples of org.jboss.dna.graph.Subgraph

        assertThat(configuration.getProblems().isEmpty(), is(true));

        // Verify that the graph has been updated correctly ...
        DnaConfiguration.ConfigurationDefinition content = configuration.getConfigurationDefinition();
        Subgraph subgraph = content.graph().getSubgraphOfDepth(6).at("/");

        assertThat(subgraph.getNode("/dna:sources"), is(notNullValue()));
        assertThat(subgraph.getNode("/dna:sources/Cars"), is(notNullValue()));
        assertThat(subgraph.getNode("/dna:sources/Cars"), hasProperty(DnaLexicon.RETRY_LIMIT, "3"));
        assertThat(subgraph.getNode("/dna:sources/Cars"), hasProperty(DnaLexicon.CLASSNAME,
                                                                      InMemoryRepositorySource.class.getName()));
        assertThat(subgraph.getNode("/dna:sources/Aircraft"), is(notNullValue()));
        assertThat(subgraph.getNode("/dna:sources/Aircraft"), hasProperty("defaultWorkspaceName", "default"));
        assertThat(subgraph.getNode("/dna:sources/Aircraft"), hasProperty(DnaLexicon.CLASSNAME,
                                                                          InMemoryRepositorySource.class.getName()));
        assertThat(subgraph.getNode("/dna:sources/Cache"), is(notNullValue()));
        assertThat(subgraph.getNode("/dna:sources/Cache"), hasProperty(DnaLexicon.CLASSNAME,
                                                                       InMemoryRepositorySource.class.getName()));

        assertThat(subgraph.getNode("/dna:mimeTypeDetectors").getChildren(), hasChild(segment("Detector")));
        assertThat(subgraph.getNode("/dna:mimeTypeDetectors/Detector"), is(notNullValue()));
        assertThat(subgraph.getNode("/dna:mimeTypeDetectors/Detector"),
                   hasProperty(DnaLexicon.DESCRIPTION, "Standard extension-based MIME type detector"));
        assertThat(subgraph.getNode("/dna:mimeTypeDetectors/Detector"),
                   hasProperty(DnaLexicon.CLASSNAME, ExtensionBasedMimeTypeDetector.class.getName()));

        assertThat(subgraph.getNode("/dna:repositories").getChildren(), hasChild(segment("Car Repository")));
        assertThat(subgraph.getNode("/dna:repositories/Car Repository"), is(notNullValue()));
        assertThat(subgraph.getNode("/dna:repositories/Car Repository"), hasProperty(DnaLexicon.SOURCE_NAME, "Cars"));
        assertThat(subgraph.getNode("/dna:repositories/Car Repository").getChildren(), hasChild(segment("dna:options")));
        assertThat(subgraph.getNode("/dna:repositories/Car Repository/dna:options"), is(notNullValue()));
        assertThat(subgraph.getNode("/dna:repositories/Car Repository/dna:options").getChildren(),
                   hasChild(segment("jaasLoginConfigName")));
        assertThat(subgraph.getNode("/dna:repositories/Car Repository/dna:options/jaasLoginConfigName"), is(notNullValue()));
        assertThat(subgraph.getNode("/dna:repositories/Car Repository/dna:options/jaasLoginConfigName"),
                   hasProperty(DnaLexicon.VALUE, "dna-jcr"));

        // Initialize IDTrust and a policy file (which defines the "dna-jcr" login config name)
        String configFile = "security/jaas.conf.xml";
        IDTrustConfiguration idtrustConfig = new IDTrustConfiguration();
View Full Code Here

Examples of org.jboss.dna.graph.Subgraph

                                .getNamespaceRegistry()
                                .isRegisteredNamespaceUri("http://www.jboss.org/dna/test/1.0"), is(true));

        // Verify that the graph has been updated correctly ...
        DnaConfiguration.ConfigurationDefinition content = configuration.getConfigurationDefinition();
        Subgraph subgraph = content.graph().getSubgraphOfDepth(6).at("/");

        assertThat(subgraph.getNode("/dna:repositories").getChildren(), hasChild(segment("Car Repository")));
        assertThat(subgraph.getNode("/dna:repositories/Car Repository"), is(notNullValue()));
        assertThat(subgraph.getNode("/dna:repositories/Car Repository"), hasProperty(DnaLexicon.SOURCE_NAME, "Cars"));
        assertThat(subgraph.getNode("/dna:repositories/Car Repository").getChildren(), hasChild(segment("dna:options")));
        assertThat(subgraph.getNode("/dna:repositories/Car Repository/jcr:nodeTypes"), is(notNullValue()));
        // for (Location child : subgraph.getNode("/dna:repositories/Car Repository/dna:nodeTypes").getChildren()) {
        // System.out.println(child.getPath().getLastSegment().getString(context().getNamespaceRegistry()));
        // }
        assertThat(subgraph.getNode("/dna:repositories/Car Repository/jcr:nodeTypes").getChildren(),
                   hasChildren(segment("dnatest:noSameNameSibs"),
                               segment("dnatest:referenceableUnstructured"),
                               segment("dnatest:nodeWithMandatoryProperty"),
                               segment("dnatest:nodeWithMandatoryChild"),
                               segment("dnatest:unorderableUnstructured")));
        assertThat(subgraph.getNode("/dna:repositories/Car Repository/dna:namespaces"), is(notNullValue()));

        // Check that the namespace in the CND file was persisted correctly ...
        assertThat(subgraph.getNode("/dna:repositories/Car Repository/dna:namespaces").getChildren(),
                   hasChild(segment("dnatest")));
        assertThat(subgraph.getNode("/dna:repositories/Car Repository/dna:namespaces/dnatest"),
                   hasProperty(DnaLexicon.NAMESPACE_URI, "http://www.jboss.org/dna/test/1.0"));

        // Initialize IDTrust and a policy file (which defines the "dna-jcr" login config name)
        String configFile = "security/jaas.conf.xml";
        IDTrustConfiguration idtrustConfig = new IDTrustConfiguration();
View Full Code Here

Examples of org.jboss.dna.graph.Subgraph

        // Create a graph to access the configuration ...
        Graph config = Graph.create(configurationSourceName, connectionFactory, context);

        // Read the federated repositories subgraph (of max depth 4)...
        Subgraph repositories = config.getSubgraphOfDepth(4).at(getConfigurationSourcePath());

        // Set up the default cache policy by reading the "dna:federation" node ...
        CachePolicy defaultCachePolicy = null;
        Node federation = repositories.getNode(DNA_FEDERATION_SEGMENT);
        if (federation == null) {
            I18n msg = FederationI18n.requiredNodeDoesNotExistRelativeToNode;
            throw new FederationException(msg.text(DNA_FEDERATION_SEGMENT, repositories.getLocation().getPath()));
        }
        Property timeToLiveProperty = federation.getProperty(nameFactory.create(CACHE_POLICY_TIME_TO_LIVE_CONFIG_PROPERTY_NAME));
        if (timeToLiveProperty != null && !timeToLiveProperty.isEmpty()) {
            long timeToCacheInMillis = longFactory.create(timeToLiveProperty.getValues().next());
            BasicCachePolicy policy = new BasicCachePolicy(timeToCacheInMillis, TimeUnit.MILLISECONDS);
            defaultCachePolicy = policy.getUnmodifiable();
        }

        // Read the "dna:cache" and its projection ...
        String cacheNodePath = DNA_FEDERATION_SEGMENT + "/" + DNA_CACHE_SEGMENT;
        Node cacheNode = repositories.getNode(cacheNodePath);
        if (cacheNode == null) {
            I18n msg = FederationI18n.requiredNodeDoesNotExistRelativeToNode;
            throw new FederationException(msg.text(cacheNodePath, repositories.getLocation().getPath()));
        }
        Projection cacheProjection = null;
        for (Location cacheProjectionLocation : cacheNode) {
            Node projection = repositories.getNode(cacheProjectionLocation);
            cacheProjection = createProjection(context, projectionParser, projection, problems);
        }

        // Read the "dna:projections" and create a projection for each ...
        String projectionsPath = DNA_FEDERATION_SEGMENT + "/" + DNA_PROJECTIONS_SEGMENT;
        Node projectionsNode = repositories.getNode(projectionsPath);
        if (projectionsNode == null) {
            I18n msg = FederationI18n.requiredNodeDoesNotExistRelativeToNode;
            throw new FederationException(msg.text(projectionsNode, repositories.getLocation().getPath()));
        }
        List<Projection> sourceProjections = new LinkedList<Projection>();
        for (Location location : projectionsNode) {
            Node projection = repositories.getNode(location);
            sourceProjections.add(createProjection(context, projectionParser, projection, problems));
        }

        return new FederatedRepositoryConfig(repositoryName, cacheProjection, sourceProjections, defaultCachePolicy);
    }
View Full Code Here

Examples of org.jboss.dna.graph.Subgraph

     */
    List<JcrNodeType> registerNodeTypes( JcrNodeTypeSource nodeTypeSource )
        throws InvalidNodeTypeDefinitionException, NodeTypeExistsException, RepositoryException {
        assert nodeTypeSource != null;
        Graph nodeTypesGraph = nodeTypeSource.getNodeTypes();
        Subgraph nodeTypesSubgraph = nodeTypesGraph.getSubgraphOfDepth(3).at("/");
        return registerNodeTypes(nodeTypesSubgraph, nodeTypesSubgraph.getLocation());
    }
View Full Code Here

Examples of org.jboss.dna.graph.Subgraph

            // Level 2: the "dna:workspaces" node
            // Level 3: a node for each workspace in the federated repository
            // Level 4: the "dna:projections" nodes
            // Level 5: a node below "dna:projections" for each projection, with properties for the source name,
            // workspace name, cache expiration time, and projection rules
            Subgraph repositories = repositoryContext.getConfiguration(5);

            // Get the name of the default workspace ...
            String defaultWorkspaceName = null;
            Property defaultWorkspaceNameProperty = repositories.getRoot().getProperty(DnaLexicon.DEFAULT_WORKSPACE_NAME);
            if (defaultWorkspaceNameProperty != null) {
                // Set the name using the property if there is one ...
                defaultWorkspaceName = strings.create(defaultWorkspaceNameProperty.getFirstValue());
            }

            // Get the default expiration time for the repository ...
            CachePolicy defaultCachePolicy = null;
            Property timeToExpire = repositories.getRoot().getProperty(DnaLexicon.TIME_TO_EXPIRE);
            if (timeToExpire != null && !timeToExpire.isEmpty()) {
                long timeToCacheInMillis = longs.create(timeToExpire.getFirstValue());
                defaultCachePolicy = new BasicCachePolicy(timeToCacheInMillis, TimeUnit.MILLISECONDS).getUnmodifiable();
            }

            // Level 2: The "dna:workspaces" node ...
            Node workspacesNode = repositories.getNode(DnaLexicon.WORKSPACES);
            if (workspacesNode == null) {
                I18n msg = GraphI18n.requiredNodeDoesNotExistRelativeToNode;
                throw new RepositorySourceException(msg.text(DnaLexicon.WORKSPACES.getString(registry),
                                                             repositories.getLocation().getPath().getString(registry),
                                                             repositories.getGraph().getCurrentWorkspaceName(),
                                                             repositories.getGraph().getSourceName()));
            }

            // Level 3: The workspace nodes ...
            LinkedList<FederatedWorkspace> workspaces = new LinkedList<FederatedWorkspace>();
            for (Location workspace : workspacesNode) {

                // Get the name of the workspace ...
                String workspaceName = null;
                SubgraphNode workspaceNode = repositories.getNode(workspace);
                Property workspaceNameProperty = workspaceNode.getProperty(DnaLexicon.WORKSPACE_NAME);
                if (workspaceNameProperty != null) {
                    // Set the name using the property if there is one ...
                    workspaceName = strings.create(workspaceNameProperty.getFirstValue());
                }
                if (workspaceName == null) {
                    // Otherwise, set the name using the local name of the workspace node ...
                    workspaceName = workspace.getPath().getLastSegment().getName().getLocalName();
                }

                // Level 4: the "dna:projections" node ...
                Node projectionsNode = workspaceNode.getNode(DnaLexicon.PROJECTIONS);
                if (projectionsNode == null) {
                    I18n msg = GraphI18n.requiredNodeDoesNotExistRelativeToNode;
                    throw new RepositorySourceException(getName(), msg.text(DnaLexicon.PROJECTIONS.getString(registry),
                                                                            workspaceNode.getLocation()
                                                                                         .getPath()
                                                                                         .getString(registry),
                                                                            repositories.getGraph().getCurrentWorkspaceName(),
                                                                            repositories.getGraph().getSourceName()));
                }

                // Level 5: the projection nodes ...
                List<Projection> sourceProjections = new LinkedList<Projection>();
                for (Location projection : projectionsNode) {
                    Node projectionNode = repositories.getNode(projection);
                    sourceProjections.add(createProjection(executionContext, projectionParser, projectionNode));
                }

                // Create the federated workspace configuration ...
                FederatedWorkspace space = new FederatedWorkspace(repositoryContext, name, workspaceName, sourceProjections,
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.