Package com.hp.hpl.jena.sparql.util

Examples of com.hp.hpl.jena.sparql.util.Context


        if (serviceContextMap == null) {
            ARQ.getContext().put(Service.serviceContext, new HashMap<String, Context>());
            serviceContextMap = (Map<String, Context>) ARQ.getContext().get(Service.serviceContext);
        }
        if (serviceContextMap.get(SERVICE) == null) {
            serviceContextMap.put(SERVICE, new Context(ARQ.getContext()));
        }
        Context serviceContext = serviceContextMap.get(SERVICE);
        try {
            serviceContext.put(Service.queryAuthUser, "user");
            serviceContext.put(Service.queryAuthPwd, "password");

            UpdateRequest updates = UpdateFactory.create("CREATE GRAPH <http://example>");
            UpdateProcessRemoteBase engine = (UpdateProcessRemoteBase) UpdateExecutionFactory.createRemote(updates, SERVICE);
            Assert.assertNotNull(engine);

            // Check that auth settings were changed
            Assert.assertTrue(engine.isUsingAuthentication());

        } finally {
            serviceContext.remove(Service.queryAuthUser);
            serviceContext.remove(Service.queryAuthPwd);
        }
    }
View Full Code Here


        Assert.assertTrue(qe.execAsk());
    }

    @Test
    public void query_with_auth_10() {
        Context ctx = ARQ.getContext();
        try {
            QueryEngineHTTP qe = (QueryEngineHTTP) QueryExecutionFactory.sparqlService(serviceQuery, "ASK { }");

            // Auth credentials for valid user with correct password and scoped
            // to correct URI
            // Provided via Service Context and its associated authenticator
            Map<String, Context> serviceContext = new HashMap<String, Context>();
            Context authContext = new Context();
            authContext.put(Service.queryAuthUser, "allowed");
            authContext.put(Service.queryAuthPwd, "password");
            serviceContext.put(serviceQuery, authContext);
            ctx.put(Service.serviceContext, serviceContext);

            qe.setAuthenticator(new ServiceAuthenticator());
            Assert.assertTrue(qe.execAsk());
View Full Code Here

        }
    }
   
    @Test
    public void query_with_auth_11() {
        Context ctx = ARQ.getContext();
        try {
            QueryEngineHTTP qe = (QueryEngineHTTP) QueryExecutionFactory.sparqlService(serviceQuery, "ASK { }");

            // Auth credentials for valid user with correct password and scoped
            // to base URI of the actual service URL
            // Provided via Service Context and its associated authenticator
            Map<String, Context> serviceContext = new HashMap<String, Context>();
            Context authContext = new Context();
            authContext.put(Service.queryAuthUser, "allowed");
            authContext.put(Service.queryAuthPwd, "password");
            serviceContext.put(urlRoot, authContext);
            ctx.put(Service.serviceContext, serviceContext);

            qe.setAuthenticator(new ServiceAuthenticator());
            Assert.assertTrue(qe.execAsk());
View Full Code Here

    public static DatasetGraph create(DatasetGraph dsg, SpatialIndex spatialIndex)
    {
        SpatialDocProducer producer = new SpatialDocProducerTriples(spatialIndex) ;
        DatasetGraph dsgt = new DatasetGraphSpatial(dsg, spatialIndex, producer) ;
        // Also set on dsg
        Context c = dsgt.getContext() ;
       
        dsgt.getContext().set(SpatialQuery.spatialIndex, spatialIndex) ;
        return dsgt ;

    }
View Full Code Here

    }

    private static Plan makePlan(Query query, DatasetGraph dataset, Binding input, Context context)
    {
        if ( context == null )
            context = new Context(ARQ.getContext()) ;
        if ( input == null )
            input = BindingRoot.create() ;
        QueryEngineFactory f = findFactory(query, dataset, context) ;
        if ( f == null )
            return null ;
View Full Code Here

        SystemARQ.StrictDateTimeFO      = false ;
        SystemARQ.ValueExtensions       = true ;
        SystemARQ.SameValueAsString     = true ;
        SystemARQ.EnableRomanNumerals   = false ;

        Context context = new Context() ;
        context.unset(optimization) ;
        //context.set(hideNonDistiguishedVariables, true) ;
        context.set(strictSPARQL,                  false) ;
        context.set(constantBNodeLabels,           true) ;
        context.set(enablePropertyFunctions,       true) ;
        context.set(regexImpl,                     javaRegex) ;

        return context ;
    }
View Full Code Here

     *            the Query to execute.
     * @return An HttpQuery configured as per the context.
     */
    private static HttpQuery configureQuery(String uri, Context parentContext, Query query) {
        HttpQuery httpQuery = new HttpQuery(uri);
        Context context = new Context(parentContext);

        // add the context settings from the service context
        @SuppressWarnings("unchecked")
        Map<String, Context> serviceContextMap = (Map<String, Context>) context.get(serviceContext);
        if (serviceContextMap != null) {
            Context serviceContext = serviceContextMap.get(uri);
            if (serviceContext != null)
                context.putAll(serviceContext);
        }

        // configure the query object.
View Full Code Here

    private QueryEngineHTTP(String serviceURI, Query query, String queryString, HttpAuthenticator authenticator) {
        this.query = query;
        this.queryString = queryString;
        this.service = serviceURI;
        // Copy the global context to freeze it.
        this.context = new Context(ARQ.getContext());

        // Apply service configuration if relevant
        QueryEngineHTTP.applyServiceConfig(serviceURI, this);
       
        // Don't want to overwrite credentials we may have picked up from
View Full Code Here

            return;

        @SuppressWarnings("unchecked")
        Map<String, Context> serviceContextMap = (Map<String, Context>) engine.context.get(Service.serviceContext);
        if (serviceContextMap != null && serviceContextMap.containsKey(serviceURI)) {
            Context serviceContext = serviceContextMap.get(serviceURI);
            if (log.isDebugEnabled())
                log.debug("Endpoint URI {} has SERVICE Context: {} ", serviceURI, serviceContext);

            // Apply behavioral options
            engine.setAllowGZip(serviceContext.isTrueOrUndef(Service.queryGzip));
            engine.setAllowDeflate(serviceContext.isTrueOrUndef(Service.queryDeflate));
            applyServiceTimeouts(engine, serviceContext);

            // Apply authentication settings
            String user = serviceContext.getAsString(Service.queryAuthUser);
            String pwd = serviceContext.getAsString(Service.queryAuthPwd);

            if (user != null || pwd != null) {
                user = user == null ? "" : user;
                pwd = pwd == null ? "" : pwd;
                if (log.isDebugEnabled())
View Full Code Here

        }
    }

    private static TextIndex chooseTextIndex(DatasetGraph dsg) {
       
        Context c = dsg.getContext() ;
       
        Object obj = dsg.getContext().get(TextQuery.textIndex) ;

        if (obj != null) {
            try {
View Full Code Here

TOP

Related Classes of com.hp.hpl.jena.sparql.util.Context

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.