Package org.jboss.dna.graph

Examples of org.jboss.dna.graph.Node


        AbstractJcrNode system = (AbstractJcrNode)root.getNode("jcr:system");
        UUID uuid = system.location.getUuid();

        for (int i = 0; i != 3; ++i) {
            // Get the same node via the direct graph ...
            Node dnaSystem = systemGraph.getNodeAt("/jcr:system");
            UUID dnaSystemUuid = dnaSystem.getLocation().getUuid();

            // They should have the same UUID ...
            assertThat(uuid, is(dnaSystemUuid));
        }
    }
View Full Code Here


        // 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

        List<JcrNodeType> typesPendingRegistration = new ArrayList<JcrNodeType>(nodeTypeLocations.size());

        try {
            nodeTypeManagerLock.writeLock().lock();
            for (Location location : nodeTypeLocations) {
                Node nodeTypeNode = nodeTypeSubgraph.getNode(location);
                assert location.getPath() != null;

                Name internalName = location.getPath().getLastSegment().getName();
                if (internalName == null || internalName.getLocalName().length() == 0) {
                    throw new InvalidNodeTypeDefinitionException(JcrI18n.invalidNodeTypeName.text());
View Full Code Here

    }

    private JcrNodeType nodeTypeFrom( Subgraph nodeTypeGraph,
                                      Location nodeTypeLocation,
                                      List<JcrNodeType> supertypes ) {
        Node nodeTypeNode = nodeTypeGraph.getNode(nodeTypeLocation);
        List<Location> children = nodeTypeNode.getChildren();

        List<JcrPropertyDefinition> properties = new ArrayList<JcrPropertyDefinition>(children.size());
        List<JcrNodeDefinition> childNodes = new ArrayList<JcrNodeDefinition>(children.size());

        for (Location childLocation : children) {
            if (JcrLexicon.PROPERTY_DEFINITION.equals(childLocation.getPath().getLastSegment().getName())) {
                properties.add(this.propertyDefinitionFrom(nodeTypeGraph, childLocation));
            } else if (JcrLexicon.CHILD_NODE_DEFINITION.equals(childLocation.getPath().getLastSegment().getName())) {
                childNodes.add(this.childNodeDefinitionFrom(nodeTypeGraph, childLocation));
            } else {
                throw new IllegalStateException("Unexpected child of node type at: " + childLocation);
            }
        }

        Map<Name, Property> nodeProperties = nodeTypeNode.getPropertiesByName();

        ValueFactories valueFactories = context.getValueFactories();
        NameFactory nameFactory = valueFactories.getNameFactory();
        ValueFactory<Boolean> booleanFactory = valueFactories.getBooleanFactory();
View Full Code Here

                               orderableChildNodes);
    }

    private JcrPropertyDefinition propertyDefinitionFrom( Subgraph nodeTypeGraph,
                                                          Location propertyLocation ) {
        Node propertyDefinitionNode = nodeTypeGraph.getNode(propertyLocation);
        Map<Name, Property> properties = propertyDefinitionNode.getPropertiesByName();

        ValueFactories valueFactories = context.getValueFactories();
        NameFactory nameFactory = valueFactories.getNameFactory();
        ValueFactory<Boolean> booleanFactory = valueFactories.getBooleanFactory();
View Full Code Here

                                         isProtected, defaultValues, requiredType, valueConstraints, multiple, fullTextSearchable);
    }

    private JcrNodeDefinition childNodeDefinitionFrom( Subgraph nodeTypeGraph,
                                                       Location childNodeLocation ) {
        Node childNodeDefinitionNode = nodeTypeGraph.getNode(childNodeLocation);
        Map<Name, Property> properties = childNodeDefinitionNode.getPropertiesByName();

        ValueFactories valueFactories = context.getValueFactories();
        NameFactory nameFactory = valueFactories.getNameFactory();
        ValueFactory<Boolean> booleanFactory = valueFactories.getBooleanFactory();
View Full Code Here

                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

                skipNamespaces.add(JcrLexicon.Namespace.URI);
                skipNamespaces.add(JcrNtLexicon.Namespace.URI);
                skipNamespaces.add(JcrMixLexicon.Namespace.URI);

                for (Location detectorLocation : subgraph.getRoot().getChildren()) {
                    Node node = subgraph.getNode(detectorLocation);
                    String name = stringValueOf(node, DnaLexicon.READABLE_NAME);
                    if (name == null) name = stringValueOf(node);
                    String desc = stringValueOf(node, DnaLexicon.DESCRIPTION);
                    String classname = stringValueOf(node, DnaLexicon.CLASSNAME);
                    String[] classpath = stringValuesOf(node, DnaLexicon.CLASSPATH);
                    Map<String, Object> properties = new HashMap<String, Object>();
                    for (Property property : node.getProperties()) {
                        Name propertyName = property.getName();
                        if (skipNamespaces.contains(propertyName.getNamespaceUri())) continue;
                        if (skipProperties.contains(propertyName)) continue;
                        if (property.isSingle()) {
                            properties.put(propertyName.getLocalName(), property.getFirstValue());
View Full Code Here

                skipNamespaces.add(JcrLexicon.Namespace.URI);
                skipNamespaces.add(JcrNtLexicon.Namespace.URI);
                skipNamespaces.add(JcrMixLexicon.Namespace.URI);

                for (Location sequencerLocation : subgraph.getRoot().getChildren()) {
                    Node sequencerNode = subgraph.getNode(sequencerLocation);
                    String name = stringValueOf(sequencerNode, DnaLexicon.READABLE_NAME);
                    if (name == null) name = stringValueOf(sequencerNode);
                    String desc = stringValueOf(sequencerNode, DnaLexicon.DESCRIPTION);
                    String classname = stringValueOf(sequencerNode, DnaLexicon.CLASSNAME);
                    String[] classpath = stringValuesOf(sequencerNode, DnaLexicon.CLASSPATH);
                    String[] expressionStrings = stringValuesOf(sequencerNode, DnaLexicon.PATH_EXPRESSION);
                    List<PathExpression> pathExpressions = new ArrayList<PathExpression>();
                    if (expressionStrings != null) {
                        for (String expressionString : expressionStrings) {
                            try {
                                pathExpressions.add(PathExpression.compile(expressionString));
                            } catch (Throwable t) {
                                problems.addError(t,
                                                  RepositoryI18n.pathExpressionIsInvalidOnSequencer,
                                                  expressionString,
                                                  name,
                                                  t.getLocalizedMessage());
                            }
                        }
                    }
                    String[] goodExpressionStrings = new String[pathExpressions.size()];
                    for (int i = 0; i != pathExpressions.size(); ++i) {
                        PathExpression expression = pathExpressions.get(i);
                        goodExpressionStrings[i] = expression.getExpression();
                    }
                    Map<String, Object> properties = new HashMap<String, Object>();
                    for (Property property : sequencerNode.getProperties()) {
                        Name propertyName = property.getName();
                        if (skipNamespaces.contains(propertyName.getNamespaceUri())) continue;
                        if (skipProperties.contains(propertyName)) continue;
                        if (property.isSingle()) {
                            properties.put(propertyName.getLocalName(), property.getFirstValue());
View Full Code Here

            assert workspace.getRoot() != null;
        }

        // Verify the path ...
        Path path = pathInWorkspace != null ? path(pathInWorkspace) : path(DEFAULT_PATH);
        Node parent = graph.getNodeAt(path);
        assert parent != null;

        // Now create the content information ...
        configurationContent = new ConfigurationDefinition(source, workspaceName, path, context, null);
        return this;
View Full Code Here

TOP

Related Classes of org.jboss.dna.graph.Node

Copyright © 2018 www.massapicom. 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.