Clover coverage report -
Coverage timestamp: Sun Nov 1 2009 23:08:24 UTC
file stats: LOC: 93   Methods: 3
NCLOC: 48   Classes: 1
 
 Source file Conditionals Statements Methods TOTAL
RPCMessageInterface.java 33.3% 66.7% 100% 62.5%
coverage coverage
 1    /*
 2    * Licensed to the Apache Software Foundation (ASF) under one or more
 3    * contributor license agreements. See the NOTICE file distributed with
 4    * this work for additional information regarding copyright ownership.
 5    * The ASF licenses this file to You under the Apache License, Version 2.0
 6    * (the "License"); you may not use this file except in compliance with
 7    * the License. You may obtain a copy of the License at
 8    *
 9    * http://www.apache.org/licenses/LICENSE-2.0
 10    *
 11    * Unless required by applicable law or agreed to in writing, software
 12    * distributed under the License is distributed on an "AS IS" BASIS,
 13    * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 14    * See the License for the specific language governing permissions and
 15    * limitations under the License.
 16    *
 17    * $Id: RPCMessageInterface.java 595817 2007-11-16 20:49:03Z vgritsenko $
 18    */
 19   
 20    package org.apache.xindice.server.rpc;
 21   
 22    import org.apache.commons.logging.Log;
 23    import org.apache.commons.logging.LogFactory;
 24    import org.apache.xindice.core.Collection;
 25    import org.apache.xindice.core.DBException;
 26    import org.apache.xindice.core.FaultCodes;
 27    import org.apache.xmlrpc.XmlRpcException;
 28    import org.apache.xmlrpc.XmlRpcHandler;
 29    import org.apache.xmlrpc.XmlRpcRequest;
 30   
 31    import org.xmldb.api.base.ErrorCodes;
 32    import org.xmldb.api.base.XMLDBException;
 33   
 34    import java.util.Map;
 35   
 36    /**
 37    *
 38    * @version $Revision: 595817 $, $Date: 2007-11-16 20:49:03 +0000 (Fri, 16 Nov 2007) $
 39    */
 40    public final class RPCMessageInterface implements XmlRpcHandler {
 41   
 42    private static final Log log = LogFactory.getLog(Collection.class);
 43   
 44    public static final String MESSAGE_PARAM = "message";
 45   
 46    /**
 47    * Single instance of handler is enough
 48    */
 49    private static final XmlRpcHandler INSTANCE = new RPCMessageInterface();
 50   
 51   
 52  2381 public static XmlRpcHandler getHandler() {
 53  2381 return INSTANCE;
 54    }
 55   
 56   
 57  1 private RPCMessageInterface() {
 58    }
 59   
 60  2381 public Object execute(XmlRpcRequest xmlRpcRequest) throws XmlRpcException {
 61  2381 Map message = (Map) xmlRpcRequest.getParameter(0);
 62   
 63    // The method determines what class we load to handle the message.
 64  2381 String type = (String) message.get(MESSAGE_PARAM);
 65  2381 try {
 66  2381 RPCMessage handler = (RPCMessage) Class.forName("org.apache.xindice.server.rpc.messages." + type).newInstance();
 67  2381 return handler.execute(message);
 68    } catch (XMLDBException e) {
 69  1 if (log.isDebugEnabled()) {
 70  0 log.debug("Exception while processing XmlRpc command " + type, e);
 71    }
 72   
 73  1 throw new XmlRpcException(e.errorCode * FaultCodes.MAX_CODE + e.vendorErrorCode,
 74    e.getMessage());
 75    } catch (DBException e) {
 76  13 if (log.isDebugEnabled()) {
 77  0 log.debug("Exception while processing XmlRpc command " + type, e);
 78    }
 79   
 80    //noinspection PointlessArithmeticExpression
 81  13 throw new XmlRpcException(ErrorCodes.VENDOR_ERROR * FaultCodes.MAX_CODE + e.faultCode,
 82    e.getMessage());
 83    } catch (Exception e) {
 84  0 if (log.isDebugEnabled()) {
 85  0 log.debug("Exception while processing XmlRpc command " + type, e);
 86    }
 87   
 88    //noinspection PointlessArithmeticExpression
 89  0 throw new XmlRpcException(ErrorCodes.UNKNOWN_ERROR * FaultCodes.MAX_CODE + FaultCodes.GEN_UNKNOWN,
 90    e.getMessage());
 91    }
 92    }
 93    }