KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > joseki > server > processors > QueryProcessorGET


1 /*
2  * (c) Copyright 2003, 2004 Hewlett-Packard Development Company, LP
3  * [See end of file]
4  */

5
6 package org.joseki.server.processors;
7
8 import java.util.* ;
9
10 import org.apache.commons.logging.*;
11
12 import org.joseki.server.*;
13 import org.joseki.vocabulary.*;
14
15 import com.hp.hpl.jena.rdf.model.*;
16 import com.hp.hpl.jena.rdf.model.RDFException;
17
18 /** Query processor that returns the whole model.
19  *
20  * @author Andy Seaborne
21  * @version $Id: QueryProcessorGET.java,v 1.7 2004/04/30 14:13:11 andy_seaborne Exp $
22  */

23 public class QueryProcessorGET extends QueryProcessorCom
24 {
25     static Log log = LogFactory.getLog(QueryProcessorGET.class) ;
26     
27     public QueryProcessorGET()
28     {
29         super() ;
30     }
31
32     public String JavaDoc getInterfaceURI() { return JosekiVocab.queryOperationGET ; }
33
34     public Model execQuery(ModelSource src, String JavaDoc queryString, Request request)
35         throws RDFException, QueryExecutionException
36     {
37         if (!(src instanceof ModelSourceJena))
38             throw new QueryExecutionException(
39                 ExecutionError.rcOperationNotSupported,
40                 "Wrong implementation - this GET processor works with Jena models");
41         Model model = ((ModelSourceJena)src).getModel() ;
42
43         if ( src.isImmutable() )
44             return model ;
45
46         // Mutable model - need to take a copy as it may change
47
// or be chaning when the reply is sent.
48
Model resultModel = ModelFactory.createDefaultModel() ;
49         resultModel.add(model) ;
50         resultModel.setNsPrefixes(model) ;
51         Map m = src.getPrefixes() ;
52         if ( m!= null )
53             resultModel.setNsPrefixes(src.getPrefixes()) ;
54         return resultModel ;
55     }
56
57     public Model execQuery(ModelSource aModel, Model queryModel, Request request)
58         throws RDFException, QueryExecutionException
59     {
60         throw new QueryExecutionException(ExecutionError.rcOperationNotSupported,
61                                      "Can't GET a model this way") ;
62     }
63
64 }
65
66 /*
67  * (c) Copyright 2003, 2004 Hewlett-Packard Development Company, LP
68  * All rights reserved.
69  *
70  * Redistribution and use in source and binary forms, with or without
71  * modification, are permitted provided that the following conditions
72  * are met:
73  * 1. Redistributions of source code must retain the above copyright
74  * notice, this list of conditions and the following disclaimer.
75  * 2. Redistributions in binary form must reproduce the above copyright
76  * notice, this list of conditions and the following disclaimer in the
77  * documentation and/or other materials provided with the distribution.
78  * 3. The name of the author may not be used to endorse or promote products
79  * derived from this software without specific prior written permission.
80  *
81  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
82  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
83  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
84  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
85  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
86  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
87  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
88  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
89  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
90  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
91  */

92
Popular Tags