KickJava   Java API By Example, From Geeks To Geeks.

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


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 org.apache.commons.logging.* ;
9 import org.joseki.server.*;
10 import com.hp.hpl.jena.rdf.model.*;
11
12 /** General template for any operation that takes no models
13  * (in the request body) as arguments - they can have parameters.
14  *
15  * @author Andy Seaborne
16  * @version $Id: ZeroArgProcessor.java,v 1.6 2004/04/30 14:13:11 andy_seaborne Exp $
17  */

18 public abstract class ZeroArgProcessor extends ProcessorCom
19 {
20     static final Log logger = LogFactory.getLog(ZeroArgProcessor.class.getName()) ;
21  
22     public ZeroArgProcessor(String JavaDoc n, int lockNeeded, int mutating)
23     {
24         super(n, lockNeeded, mutating) ;
25     }
26
27     public int argsNeeded() { return Processor.ARGS_ZERO ; }
28     
29     /**
30      * @see org.joseki.server.Processor#exec(Request)
31      */

32     public Model exec(Request request) throws ExecutionException
33     {
34         ModelSource src = request.getModelSource() ;
35         if ( super.mutatingOp && src.isImmutable() )
36             throw new ExecutionException(ExecutionError.rcImmutableModel, "Immutable Model") ;
37         
38         try {
39             src.startOperation(readOnlyLock) ;
40             try {
41                 Model resultModel = execZeroArg(src, request) ;
42                 return resultModel ;
43             } catch (RDFException ex)
44             {
45                 src.abortOperation() ;
46                 logger.trace("RDFException: "+ex.getMessage() ) ;
47                 throw new ExecutionException(ExecutionError.rcInternalError, null) ;
48             }
49             catch (Exception JavaDoc ex)
50             {
51                 src.abortOperation() ;
52                 logger.trace("Exception: "+ex.getMessage() ) ;
53                 throw new ExecutionException(ExecutionError.rcInternalError, null) ;
54             }
55         } finally {src.endOperation(); }
56         //return emptyModel ;
57
}
58     
59     public abstract Model execZeroArg(ModelSource target, Request request)
60         throws RDFException, ExecutionException ;
61 }
62
63
64 /*
65  * (c) Copyright 2003, 2004 Hewlett-Packard Development Company, LP
66  * All rights reserved.
67  *
68  * Redistribution and use in source and binary forms, with or without
69  * modification, are permitted provided that the following conditions
70  * are met:
71  * 1. Redistributions of source code must retain the above copyright
72  * notice, this list of conditions and the following disclaimer.
73  * 2. Redistributions in binary form must reproduce the above copyright
74  * notice, this list of conditions and the following disclaimer in the
75  * documentation and/or other materials provided with the distribution.
76  * 3. The name of the author may not be used to endorse or promote products
77  * derived from this software without specific prior written permission.
78  *
79  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
80  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
81  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
82  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
83  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
84  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
85  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
86  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
87  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
88  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
89  */

90
Popular Tags