Package org.jboss.dna.graph.connector.federation.FederatedRequest

Examples of org.jboss.dna.graph.connector.federation.FederatedRequest.ProjectedRequest


    }

    protected final void process( FederatedRequest forked ) {
        // Determine whether this is a single mirror request ...
        Request original = forked.original();
        ProjectedRequest projectedRequest = forked.getFirstProjectedRequest();
        boolean sameLocation = projectedRequest != null && !projectedRequest.hasNext() && projectedRequest.isSameLocation();

        // Set the cachable information ...
        if (original instanceof CacheableRequest) {
            CacheableRequest cacheableOriginal = (CacheableRequest)original;
            cacheableOriginal.setCachePolicy(getDefaultCachePolicy());
            while (projectedRequest != null) {
                Request requestToSource = projectedRequest.getRequest();
                if (cacheableOriginal != null) {
                    setCacheableInfo(cacheableOriginal, ((CacheableRequest)requestToSource).getCachePolicy());
                }
                projectedRequest = projectedRequest.next();
            }
        }

        // Now do the join on this request ...
        if (sameLocation) {
View Full Code Here


     *
     * @see org.jboss.dna.graph.request.processor.RequestProcessor#process(org.jboss.dna.graph.request.VerifyNodeExistsRequest)
     */
    @Override
    public void process( VerifyNodeExistsRequest request ) {
        ProjectedRequest projectedRequest = federatedRequest.getFirstProjectedRequest();

        request.setCachePolicy(getDefaultCachePolicy());
        Location actualLocation = request.at();
        int numMerged = 0;
        while (projectedRequest != null) {
            VerifyNodeExistsRequest readFromSource = (VerifyNodeExistsRequest)projectedRequest.getRequest();
            if (readFromSource.hasError()) {
                projectedRequest = projectedRequest.next();
                continue;
            }
            if (readFromSource.isCancelled()) {
                request.cancel();
                return;
            }

            // Make sure we have an actual location ...
            Location sourceLocation = readFromSource.getActualLocationOfNode();
            actualLocation = determineActualLocation(actualLocation, sourceLocation, projectedRequest.getProjection());

            if (sourceLocation.hasIdProperties()) {
                // Accumulate the identification properties ...
                for (Property propertyInSource : sourceLocation.getIdProperties()) {
                    Name name = propertyInSource.getName();
                    Property existing = actualLocation.getIdProperty(name);
                    if (existing != null) {
                        // Merge the property values ...
                        propertyInSource = merge(existing, propertyInSource, propertyFactory, true);
                    }
                    actualLocation = actualLocation.with(propertyInSource);
                }
            }
            setCacheableInfo(request, readFromSource.getCachePolicy());
            projectedRequest = projectedRequest.next();
            ++numMerged;
        }
        if (numMerged == 0) {
            // No source requests had results ...
            setPathNotFound(request, request.at(), federatedRequest.getFirstProjectedRequest());
View Full Code Here

    @Override
    public void process( ReadNodeRequest request ) {
        Path federatedPath = request.at().getPath();
        Map<Name, Property> properties = request.getPropertiesByName();
        Map<Name, Integer> childSnsIndexes = new HashMap<Name, Integer>();
        ProjectedRequest projectedRequest = federatedRequest.getFirstProjectedRequest();

        request.setCachePolicy(getDefaultCachePolicy());
        Location actualLocation = request.at();
        int numMerged = 0;
        while (projectedRequest != null) {
            Request sourceRequest = projectedRequest.getRequest();
            if (sourceRequest.hasError()) {
                projectedRequest = projectedRequest.next();
                continue;
            }
            if (sourceRequest.isCancelled()) {
                request.cancel();
                return;
            }

            Projection projection = projectedRequest.getProjection();
            if (sourceRequest instanceof VerifyNodeExistsRequest) {
                // We needed to verify the existance of a child node ...
                VerifyNodeExistsRequest verify = (VerifyNodeExistsRequest)sourceRequest;
                Location childInSource = verify.getActualLocationOfNode();
                Location childInRepos = getChildLocationWithCorrectSnsIndex(childInSource,
                                                                            federatedPath,
                                                                            childSnsIndexes,
                                                                            projection);
                request.addChild(childInRepos);
                if (federatedPath == null) federatedPath = childInRepos.getPath().getParent();
            } else {
                ReadNodeRequest readFromSource = (ReadNodeRequest)sourceRequest;
                Location sourceLocation = readFromSource.getActualLocationOfNode();
                if (sourceLocation.hasIdProperties()) {
                    // Accumulate the identification properties ...
                    for (Property propertyInSource : sourceLocation.getIdProperties()) {
                        Name name = propertyInSource.getName();
                        Property existing = actualLocation.getIdProperty(name);
                        if (existing != null) {
                            // Merge the property values ...
                            propertyInSource = merge(existing, propertyInSource, propertyFactory, true);
                        }
                        actualLocation = actualLocation.with(propertyInSource);
                    }
                }

                // Make sure we have an actual location ...
                actualLocation = determineActualLocation(actualLocation, sourceLocation, projection);
                if (federatedPath == null) federatedPath = actualLocation.getPath();

                // Add all the children from the source ...
                for (Location childInSource : readFromSource.getChildren()) {
                    request.addChild(getChildLocationWithCorrectSnsIndex(childInSource,
                                                                         federatedPath,
                                                                         childSnsIndexes,
                                                                         projection));
                }

                // Add all the properties ...
                for (Property propertyInSource : readFromSource.getProperties()) {
                    Name name = propertyInSource.getName();
                    Property existing = properties.get(name);
                    if (existing != null) {
                        // Merge the property values ...
                        propertyInSource = merge(existing, propertyInSource, propertyFactory, true);
                    }
                    properties.put(name, propertyInSource);
                }
                setCacheableInfo(request, readFromSource.getCachePolicy());
            }
            projectedRequest = projectedRequest.next();
            ++numMerged;
        }
        if (numMerged == 0) {
            // No source requests had results ...
            setPathNotFound(request, request.at(), federatedRequest.getFirstProjectedRequest());
View Full Code Here

     */
    @Override
    public void process( ReadAllChildrenRequest request ) {
        Path federatedPath = request.of().getPath();
        Map<Name, Integer> childSnsIndexes = new HashMap<Name, Integer>();
        ProjectedRequest projectedRequest = federatedRequest.getFirstProjectedRequest();

        request.setCachePolicy(getDefaultCachePolicy());
        Location actualLocation = request.of();
        int numMerged = 0;
        while (projectedRequest != null) {
            Request sourceRequest = projectedRequest.getRequest();
            if (sourceRequest.hasError()) {
                projectedRequest = projectedRequest.next();
                continue;
            }
            if (sourceRequest.isCancelled()) {
                request.cancel();
                return;
            }

            Projection projection = projectedRequest.getProjection();
            if (sourceRequest instanceof VerifyNodeExistsRequest) {
                // We needed to verify the existance of a child node ...
                VerifyNodeExistsRequest verify = (VerifyNodeExistsRequest)sourceRequest;
                Location childInSource = verify.getActualLocationOfNode();
                Location childInRepos = getChildLocationWithCorrectSnsIndex(childInSource,
                                                                            federatedPath,
                                                                            childSnsIndexes,
                                                                            projection);
                request.addChild(childInRepos);
                if (federatedPath == null) federatedPath = childInRepos.getPath().getParent();
            } else {
                ReadAllChildrenRequest readFromSource = (ReadAllChildrenRequest)sourceRequest;
                Location sourceLocation = readFromSource.getActualLocationOfNode();
                if (sourceLocation.hasIdProperties()) {
                    // Accumulate the identification properties ...
                    for (Property propertyInSource : sourceLocation.getIdProperties()) {
                        Name name = propertyInSource.getName();
                        Property existing = actualLocation.getIdProperty(name);
                        if (existing != null) {
                            // Merge the property values ...
                            propertyInSource = merge(existing, propertyInSource, propertyFactory, true);
                        }
                        actualLocation = actualLocation.with(propertyInSource);
                    }
                }

                // Make sure we have an actual location ...
                actualLocation = determineActualLocation(actualLocation, readFromSource.getActualLocationOfNode(), projection);
                if (federatedPath == null) federatedPath = actualLocation.getPath();

                // Add all the children from the source ...
                for (Location childInSource : readFromSource.getChildren()) {
                    request.addChild(getChildLocationWithCorrectSnsIndex(childInSource,
                                                                         federatedPath,
                                                                         childSnsIndexes,
                                                                         projection));
                }
                setCacheableInfo(request, readFromSource.getCachePolicy());
            }

            projectedRequest = projectedRequest.next();
            ++numMerged;
        }
        if (numMerged == 0) {
            // No source requests had results ...
            setPathNotFound(request, request.of(), federatedRequest.getFirstProjectedRequest());
View Full Code Here

     * @see org.jboss.dna.graph.request.processor.RequestProcessor#process(org.jboss.dna.graph.request.ReadAllPropertiesRequest)
     */
    @Override
    public void process( ReadAllPropertiesRequest request ) {
        Map<Name, Property> properties = request.getPropertiesByName();
        ProjectedRequest projectedRequest = federatedRequest.getFirstProjectedRequest();

        request.setCachePolicy(getDefaultCachePolicy());
        Location actualLocation = request.at();
        int numMerged = 0;
        while (projectedRequest != null) {
            ReadAllPropertiesRequest readFromSource = (ReadAllPropertiesRequest)projectedRequest.getRequest();
            if (readFromSource.hasError()) {
                projectedRequest = projectedRequest.next();
                continue;
            }
            if (readFromSource.isCancelled()) {
                request.cancel();
                return;
            }

            // Make sure we have an actual location ...
            Location sourceLocation = readFromSource.getActualLocationOfNode();
            actualLocation = determineActualLocation(actualLocation, sourceLocation, projectedRequest.getProjection());

            if (sourceLocation.hasIdProperties()) {
                // Accumulate the identification properties ...
                for (Property propertyInSource : sourceLocation.getIdProperties()) {
                    Name name = propertyInSource.getName();
                    Property existing = actualLocation.getIdProperty(name);
                    if (existing != null) {
                        // Merge the property values ...
                        propertyInSource = merge(existing, propertyInSource, propertyFactory, true);
                    }
                    actualLocation = actualLocation.with(propertyInSource);
                }
            }

            // Add all the properties ...
            for (Property propertyInSource : readFromSource.getProperties()) {
                Name name = propertyInSource.getName();
                Property existing = properties.get(name);
                if (existing != null) {
                    // Merge the property values ...
                    propertyInSource = merge(existing, propertyInSource, propertyFactory, true);
                }
                properties.put(name, propertyInSource);
            }
            setCacheableInfo(request, readFromSource.getCachePolicy());
            projectedRequest = projectedRequest.next();
            ++numMerged;
        }
        if (numMerged == 0) {
            // No source requests had results ...
            setPathNotFound(request, request.at(), federatedRequest.getFirstProjectedRequest());
View Full Code Here

     *
     * @see org.jboss.dna.graph.request.processor.RequestProcessor#process(org.jboss.dna.graph.request.ReadPropertyRequest)
     */
    @Override
    public void process( ReadPropertyRequest request ) {
        ProjectedRequest projectedRequest = federatedRequest.getFirstProjectedRequest();

        request.setCachePolicy(getDefaultCachePolicy());
        Location actualLocation = request.on();
        int numMerged = 0;
        while (projectedRequest != null) {
            ReadPropertyRequest readFromSource = (ReadPropertyRequest)projectedRequest.getRequest();
            if (readFromSource.hasError()) {
                projectedRequest = projectedRequest.next();
                continue;
            }
            if (readFromSource.isCancelled()) {
                request.cancel();
                return;
            }

            // Make sure we have an actual location ...
            Location sourceLocation = readFromSource.getActualLocationOfNode();
            actualLocation = determineActualLocation(actualLocation, sourceLocation, projectedRequest.getProjection());

            if (sourceLocation.hasIdProperties()) {
                // Accumulate the identification properties ...
                for (Property propertyInSource : sourceLocation.getIdProperties()) {
                    Name name = propertyInSource.getName();
                    Property existing = actualLocation.getIdProperty(name);
                    if (existing != null) {
                        // Merge the property values ...
                        propertyInSource = merge(existing, propertyInSource, propertyFactory, true);
                    }
                    actualLocation = actualLocation.with(propertyInSource);
                }
            }

            // Add all the properties ...
            Property read = readFromSource.getProperty();
            if (read != null) {
                Property existing = request.getProperty();
                if (existing != null) {
                    // Merge the property values ...
                    request.setProperty(merge(existing, read, propertyFactory, true));
                } else {
                    request.setProperty(read);
                }
            }
            setCacheableInfo(request, readFromSource.getCachePolicy());
            projectedRequest = projectedRequest.next();
            ++numMerged;
        }
        if (numMerged == 0) {
            // No source requests had results ...
            setPathNotFound(request, request.on(), federatedRequest.getFirstProjectedRequest());
View Full Code Here

     *
     * @see org.jboss.dna.graph.request.processor.RequestProcessor#process(org.jboss.dna.graph.request.ReadBranchRequest)
     */
    @Override
    public void process( ReadBranchRequest request ) {
        ProjectedRequest projectedRequest = federatedRequest.getFirstProjectedRequest();

        request.setCachePolicy(getDefaultCachePolicy());
        Location actualLocation = request.at();
        int numMerged = 0;
        // The first pass will only capture the actual ReadBranchRequests to the underlying sources ...
        Map<Path, Location> actualLocationsOfProxyNodes = new HashMap<Path, Location>();
        while (projectedRequest != null) {
            CacheableRequest fromSource = (CacheableRequest)projectedRequest.getRequest();
            if (fromSource.hasError()) {
                projectedRequest = projectedRequest.next();
                continue;
            }
            if (fromSource.isCancelled()) {
                request.cancel();
                return;
            }

            Projection projection = projectedRequest.getProjection();
            if (fromSource instanceof ReadBranchRequest) {
                ReadBranchRequest readFromSource = (ReadBranchRequest)fromSource;
                for (Location parent : readFromSource) {
                    List<Location> children = readFromSource.getChildren(parent);
                    Map<Name, Property> properties = readFromSource.getPropertiesFor(parent);
                    projectToFederated(actualLocation, projection, request, parent, children, properties);
                }
                Location locationOfProxy = readFromSource.getActualLocationOfNode();
                // The location is in terms of the source, so get the projected location ...
                locationOfProxy = determineActualLocation(locationOfProxy, projection);
                actualLocationsOfProxyNodes.put(locationOfProxy.getPath(), locationOfProxy);
            }
            setCacheableInfo(request, fromSource.getCachePolicy());
            projectedRequest = projectedRequest.next();
            ++numMerged;
        }
        // Go through the requests and process the ReadNodeRequests (which were reading children of placeholders)...
        projectedRequest = federatedRequest.getFirstProjectedRequest();
        while (projectedRequest != null) {
            CacheableRequest fromSource = (CacheableRequest)projectedRequest.getRequest();
            Projection projection = projectedRequest.getProjection();
            if (fromSource instanceof ReadNodeRequest) {
                ReadNodeRequest readFromSource = (ReadNodeRequest)fromSource;
                Location parent = readFromSource.getActualLocationOfNode();
                List<Location> children = readFromSource.getChildren();
                for (int i = 0; i != children.size(); ++i) {
                    Location child = children.get(i);
                    if (!child.hasIdProperties()) {
                        // The the child must have been a proxy node ...
                        Location actual = actualLocationsOfProxyNodes.get(child.getPath());
                        assert actual != null;
                        children.set(i, actual);
                    }
                }
                Map<Name, Property> properties = readFromSource.getPropertiesByName();
                projectToFederated(actualLocation, projection, request, parent, children, properties);
            }
            setCacheableInfo(request, fromSource.getCachePolicy());
            projectedRequest = projectedRequest.next();
        }

        if (numMerged == 0) {
            // No source requests had results ...
            setPathNotFound(request, request.at(), federatedRequest.getFirstProjectedRequest());
View Full Code Here

     *
     * @see org.jboss.dna.graph.request.processor.RequestProcessor#process(org.jboss.dna.graph.request.CreateNodeRequest)
     */
    @Override
    public void process( CreateNodeRequest request ) {
        ProjectedRequest projected = federatedRequest.getFirstProjectedRequest();
        // Check the projection first ...
        if (checkErrorOrCancel(request, federatedRequest)) return;

        Request projectedRequest = projected.getRequest();
        // Check the error on the projected request ...
        if (checkErrorOrCancel(request, projectedRequest)) return;

        // No error, so project the results back to the federated repository ...
        Location sourceLocation = null;
        if (projectedRequest instanceof CreateNodeRequest) {
            CreateNodeRequest source = (CreateNodeRequest)projectedRequest;
            sourceLocation = source.getActualLocationOfNode();
        } else if (projectedRequest instanceof ReadNodeRequest) {
            // In this case, the original request was to create the node only if it was missing,
            // but we knew it already exists because the parent was a placeholder and the child
            // mapped to an existing proxy node. Therefore, record the location...
            ReadNodeRequest source = (ReadNodeRequest)projectedRequest;
            sourceLocation = source.getActualLocationOfNode();
        }
        request.setActualLocationOfNode(projectToFederated(request.under(), projected.getProjection(), sourceLocation, request));
    }
View Full Code Here

     *
     * @see org.jboss.dna.graph.request.processor.RequestProcessor#process(org.jboss.dna.graph.request.UpdatePropertiesRequest)
     */
    @Override
    public void process( UpdatePropertiesRequest request ) {
        ProjectedRequest projected = federatedRequest.getFirstProjectedRequest();
        // Check the projection first ...
        if (checkErrorOrCancel(request, federatedRequest)) return;

        UpdatePropertiesRequest source = (UpdatePropertiesRequest)projected.getRequest();
        if (checkErrorOrCancel(request, source)) return;
        Location sourceLocation = source.getActualLocationOfNode();
        request.setActualLocationOfNode(projectToFederated(request.on(), projected.getProjection(), sourceLocation, request));
        request.setNewProperties(source.getNewPropertyNames());
    }
View Full Code Here

     *
     * @see org.jboss.dna.graph.request.processor.RequestProcessor#process(org.jboss.dna.graph.request.SetPropertyRequest)
     */
    @Override
    public void process( SetPropertyRequest request ) {
        ProjectedRequest projected = federatedRequest.getFirstProjectedRequest();
        // Check the projection first ...
        if (checkErrorOrCancel(request, federatedRequest)) return;

        SetPropertyRequest source = (SetPropertyRequest)projected.getRequest();
        if (checkErrorOrCancel(request, source)) return;
        // Set the actual location and created flags ...
        Location sourceLocation = source.getActualLocationOfNode();
        request.setActualLocationOfNode(projectToFederated(request.on(), projected.getProjection(), sourceLocation, request));
        request.setNewProperty(source.isNewProperty());
    }
View Full Code Here

TOP

Related Classes of org.jboss.dna.graph.connector.federation.FederatedRequest.ProjectedRequest

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.