Package org.jboss.dna.graph

Examples of org.jboss.dna.graph.ExecutionContext


                logger.trace("  {0} {1}", ++i, contribution);
            }
        }

        // Create the node, and use the existing UUID if one is found in the cache ...
        ExecutionContext context = getExecutionContext();
        assert context != null;
        UUID uuid = null;
        if (fromCache != null) {
            Property uuidProperty = fromCache.getPropertiesByName().get(DnaLexicon.UUID);
            if (uuidProperty != null && !uuidProperty.isEmpty()) {
                uuid = context.getValueFactories().getUuidFactory().create(uuidProperty.getValues().next());
            }
        }
        if (uuid == null) uuid = UUID.randomUUID();
        FederatedNode mergedNode = new FederatedNode(path, uuid);
View Full Code Here


     */
    protected void loadContributionsFromSources( Path path,
                                                 Set<String> sourceNames,
                                                 List<Contribution> contributions ) throws RepositorySourceException {
        // At this point, there is no merge plan, so read information from the sources ...
        ExecutionContext context = getExecutionContext();
        PathFactory pathFactory = context.getValueFactories().getPathFactory();
        for (Projection projection : this.sourceProjections) {
            final String source = projection.getSourceName();
            if (sourceNames != null && !sourceNames.contains(source)) continue;
            final RepositoryConnection sourceConnection = getConnection(projection);
            if (sourceConnection == null) continue; // No source exists by this name
View Full Code Here

        Object value = mergePlanProperty.getValues().next();
        return value instanceof MergePlan ? (MergePlan)value : null;
    }

    protected void updateCache( FederatedNode mergedNode ) throws RepositorySourceException {
        final ExecutionContext context = getExecutionContext();
        final RepositoryConnection cacheConnection = getConnectionToCache();
        final Path path = mergedNode.getPath();

        NodeConflictBehavior conflictBehavior = NodeConflictBehavior.UPDATE;
        Collection<Property> properties = new ArrayList<Property>(mergedNode.getPropertiesByName().size() + 1);
        properties.add(new BasicSingleValueProperty(this.uuidPropertyName, mergedNode.getUuid()));
        BasicCreateNodeCommand newNode = new BasicCreateNodeCommand(path, properties, conflictBehavior);
        List<Segment> children = mergedNode.getChildren();
        GraphCommand[] intoCache = new GraphCommand[1 + children.size()];
        int i = 0;
        intoCache[i++] = newNode;
        List<Property> noProperties = Collections.emptyList();
        PathFactory pathFactory = context.getValueFactories().getPathFactory();
        for (Segment child : mergedNode.getChildren()) {
            newNode = new BasicCreateNodeCommand(pathFactory.create(path, child), noProperties, conflictBehavior);
            // newNode.setProperty(new BasicSingleValueProperty(this.uuidPropertyName, mergedNode.getUuid()));
            intoCache[i++] = newNode;
        }
View Full Code Here

     * @see javax.jcr.Repository#login(javax.jcr.Credentials, java.lang.String)
     */
    public synchronized Session login( Credentials credentials,
                                       String workspaceName ) throws RepositoryException {
        // Ensure credentials are either null or provide a JAAS method
        ExecutionContext execContext;
        if (credentials == null) {
            execContext = executionContextFactory.create();
        } else {
            try {
                // Check if credentials provide a login context
                try {
                    Method method = credentials.getClass().getMethod("getLoginContext");
                    if (method.getReturnType() != LoginContext.class) {
                        throw new IllegalArgumentException(JcrI18n.credentialsMustReturnLoginContext.text(credentials.getClass()));
                    }
                    LoginContext loginContext = (LoginContext)method.invoke(credentials);
                    if (loginContext == null) {
                        throw new IllegalArgumentException(JcrI18n.credentialsMustReturnLoginContext.text(credentials.getClass()));
                    }
                    execContext = executionContextFactory.create(loginContext);
                } catch (NoSuchMethodException error) {
                    // Check if credentials provide an access control context
                    try {
                        Method method = credentials.getClass().getMethod("getAccessControlContext");
                        if (method.getReturnType() != AccessControlContext.class) {
                            throw new IllegalArgumentException(
                                                               JcrI18n.credentialsMustReturnAccessControlContext.text(credentials.getClass()));
                        }
                        AccessControlContext accessControlContext = (AccessControlContext)method.invoke(credentials);
                        if (accessControlContext == null) {
                            throw new IllegalArgumentException(
                                                               JcrI18n.credentialsMustReturnAccessControlContext.text(credentials.getClass()));
                        }
                        execContext = executionContextFactory.create(accessControlContext);
                    } catch (NoSuchMethodException error2) {
                        throw new IllegalArgumentException(JcrI18n.credentialsMustProvideJaasMethod.text(credentials.getClass()),
                                                           error2);
                    }
                }
            } catch (RuntimeException error) {
                throw error;
            } catch (Exception error) {
                throw new RepositoryException(error);
            }
        }
        // Authenticate if possible
        assert execContext != null;
        LoginContext loginContext = execContext.getLoginContext();
        if (loginContext != null) {
            try {
                loginContext.login();
            } catch (javax.security.auth.login.LoginException error) {
                throw new LoginException(error);
View Full Code Here

                        boolean compatibleWithPreJcr2 ) {
        CheckArg.isNotNull(destination, "destination");
        CheckArg.isNotNull(parentPath, "parentPath");
        this.destination = destination;
        this.outputPath = parentPath;
        ExecutionContext context = destination.getExecutionContext();
        this.valueFactories = context.getValueFactories();
        this.propertyFactory = context.getPropertyFactory();
        this.pathFactory = valueFactories.getPathFactory();
        this.nameFactory = valueFactories.getNameFactory();
        this.jcr170 = compatibleWithPreJcr2;
    }
View Full Code Here

     * @see javax.jcr.Repository#login(javax.jcr.Credentials, java.lang.String)
     */
    public synchronized Session login( Credentials credentials,
                                       String workspaceName ) throws RepositoryException {
        // Ensure credentials are either null or provide a JAAS method
        ExecutionContext execContext;
        if (credentials == null) {
            execContext = executionContextFactory.create();
        } else {
            try {
                // Check if credentials provide a login context
                try {
                    Method method = credentials.getClass().getMethod("getLoginContext");
                    if (method.getReturnType() != LoginContext.class) {
                        throw new IllegalArgumentException(JcrI18n.credentialsMustReturnLoginContext.text(credentials.getClass()));
                    }
                    LoginContext loginContext = (LoginContext)method.invoke(credentials);
                    if (loginContext == null) {
                        throw new IllegalArgumentException(JcrI18n.credentialsMustReturnLoginContext.text(credentials.getClass()));
                    }
                    execContext = executionContextFactory.create(loginContext);
                } catch (NoSuchMethodException error) {
                    // Check if credentials provide an access control context
                    try {
                        Method method = credentials.getClass().getMethod("getAccessControlContext");
                        if (method.getReturnType() != AccessControlContext.class) {
                            throw new IllegalArgumentException(
                                                               JcrI18n.credentialsMustReturnAccessControlContext.text(credentials.getClass()));
                        }
                        AccessControlContext accessControlContext = (AccessControlContext)method.invoke(credentials);
                        if (accessControlContext == null) {
                            throw new IllegalArgumentException(
                                                               JcrI18n.credentialsMustReturnAccessControlContext.text(credentials.getClass()));
                        }
                        execContext = executionContextFactory.create(accessControlContext);
                    } catch (NoSuchMethodException error2) {
                        throw new IllegalArgumentException(JcrI18n.credentialsMustProvideJaasMethod.text(credentials.getClass()),
                                                           error2);
                    }
                }
            } catch (RuntimeException error) {
                throw error;
            } catch (Exception error) {
                throw new RepositoryException(error);
            }
        }
        // Authenticate if possible
        assert execContext != null;
        LoginContext loginContext = execContext.getLoginContext();
        if (loginContext != null) {
            try {
                loginContext.login();
            } catch (javax.security.auth.login.LoginException error) {
                throw new LoginException(error);
View Full Code Here

                configurator.setDataSource(this.dataSource);
            } else {
                // Set the context class loader, so that the driver could be found ...
                if (this.repositoryContext != null && this.driverClassloaderName != null) {
                    try {
                        ExecutionContext context = this.repositoryContext.getExecutionContext();
                        ClassLoader loader = context.getClassLoader(this.driverClassloaderName);
                        if (loader != null) {
                            Thread.currentThread().setContextClassLoader(loader);
                        }
                    } catch (Throwable t) {
                        I18n msg = JpaConnectorI18n.errorSettingContextClassLoader;
View Full Code Here

        this.stringFactory = new StringValueFactory(new SimpleNamespaceRegistry(), Path.URL_DECODER, Path.URL_ENCODER);
        this.longFactory = new LongValueFactory(Path.URL_DECODER, stringFactory);
    }

    public AstNodeFactory() {
        this.context = new ExecutionContext();
    }
View Full Code Here

                options.put(option, valueProperty.getFirstValue().toString());
            }
        }

        // Read the namespaces ...
        ExecutionContext context = getExecutionContext();
        Node namespacesNode = subgraph.getNode(DnaLexicon.NAMESPACES);
        if (namespacesNode != null) {
            GraphNamespaceRegistry registry = new GraphNamespaceRegistry(configuration, namespacesNode.getLocation().getPath(),
                                                                         DnaLexicon.NAMESPACE_URI);
            context = context.with(registry);
        }

        // Get the name of the source ...
        Property property = subgraph.getRoot().getProperty(DnaLexicon.SOURCE_NAME);
        if (property == null || property.isEmpty()) {
            String readableName = readable(DnaLexicon.SOURCE_NAME);
            String readablePath = readable(subgraph.getLocation());
            String msg = JcrI18n.propertyNotFoundOnNode.text(readableName, readablePath, configuration.getCurrentWorkspaceName());
            throw new RepositoryException(msg);
        }
        String sourceName = context.getValueFactories().getStringFactory().create(property.getFirstValue());

        // Find the capabilities ...
        RepositorySource source = getRepositorySource(sourceName);
        RepositorySourceCapabilities capabilities = source != null ? source.getCapabilities() : null;
        // Create the repository ...
View Full Code Here

        this.anonymousUserContext = anonymousUserContext;
    }

    protected void initializeSystemContent( Graph systemGraph ) {
        // Make sure the "/jcr:system" node exists ...
        ExecutionContext context = systemGraph.getContext();
        PathFactory pathFactory = context.getValueFactories().getPathFactory();
        Path systemPath = pathFactory.create(pathFactory.createRootPath(), JcrLexicon.SYSTEM);
        Property systemPrimaryType = context.getPropertyFactory().create(JcrLexicon.PRIMARY_TYPE, DnaLexicon.SYSTEM);
        systemGraph.create(systemPath, systemPrimaryType).ifAbsent().and();

        // Right now, the other nodes will be created as needed
    }
View Full Code Here

TOP

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

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.