Clover coverage report -
Coverage timestamp: Sun Nov 1 2009 23:08:24 UTC
file stats: LOC: 254   Methods: 16
NCLOC: 96   Classes: 1
 
 Source file Conditionals Statements Methods TOTAL
CollectionManagementServiceImpl.java 33.3% 53.3% 56.2% 51.9%
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: CollectionManagementServiceImpl.java 541508 2007-05-25 01:54:12Z vgritsenko $
 18    */
 19   
 20    package org.apache.xindice.client.xmldb.services;
 21   
 22    import org.apache.xindice.client.xmldb.CommonConfigurable;
 23    import org.apache.xindice.client.xmldb.XindiceCollection;
 24    import org.apache.xindice.core.FaultCodes;
 25   
 26    import org.w3c.dom.Document;
 27    import org.xmldb.api.base.Collection;
 28    import org.xmldb.api.base.ErrorCodes;
 29    import org.xmldb.api.base.XMLDBException;
 30    import org.xmldb.api.modules.CollectionManagementService;
 31   
 32    /**
 33    * XML:DB CollectionManagementService implementation using XML-RPC to
 34    * communicate with Xindice.
 35    *
 36    * @author <a href="mailto:james.bates@amplexor.com">James Bates</a>
 37    * @author <a href="mailto:kstaken@xmldatabases.org">Kimbro Staken</a>
 38    * @version $Revision: 541508 $, $Date: 2007-05-24 18:54:12 -0700 (Thu, 24 May 2007) $
 39    */
 40    public class CollectionManagementServiceImpl extends CommonConfigurable
 41    implements CollectionManagementService, CollectionManager, DatabaseInstanceManager {
 42   
 43    /* The collection this service operates on */
 44    private Collection coll = null;
 45   
 46    /* service version */
 47    private final static String SERVICE_VERSION = "1.0";
 48   
 49    /* service name */
 50    private final static String SERVICE_NAME = "CollectionManagementService";
 51   
 52    /**
 53    * Returns service version
 54    *
 55    * @return <code>1.0</code>
 56    */
 57  10254 public String getVersion() throws XMLDBException {
 58   
 59  10254 return SERVICE_VERSION;
 60    }
 61   
 62    /**
 63    * Inserts new child collection into this collection
 64    *
 65    * @param childCollName name for new child collection
 66    * @return the newly created child
 67    */
 68  0 public Collection createCollection(String childCollName)
 69    throws XMLDBException {
 70   
 71  0 if (coll == null) {
 72   
 73  0 throw new XMLDBException(ErrorCodes.INVALID_COLLECTION,
 74    "Must set collection for this service");
 75    }
 76   
 77  0 return ((XindiceCollection) coll).createCollection(childCollName);
 78    }
 79   
 80    /**
 81    * Removes child collection from this collection
 82    *
 83    * @param childCollName name of child collection to remove
 84    */
 85  387 public void removeCollection(String childCollName) throws XMLDBException {
 86  387 if (coll == null) {
 87   
 88  0 throw new XMLDBException(ErrorCodes.INVALID_COLLECTION,
 89    "Must set collection for this service");
 90    }
 91   
 92  387 ((XindiceCollection) coll).removeCollection(childCollName);
 93    }
 94   
 95    /**
 96    * Returns service name
 97    *
 98    * @return <code>CollectionManagementService</code>
 99    */
 100  3418 public String getName() {
 101   
 102  3418 return SERVICE_NAME;
 103    }
 104   
 105    /**
 106    * Sets collection this service should operate on
 107    *
 108    * @param collection the collection this service should operate on
 109    */
 110  3418 public void setCollection(Collection collection) {
 111   
 112  3418 this.coll = collection;
 113    }
 114   
 115    /**
 116    * Returns the name of the collection that this manager is associated with.
 117    *
 118    * @return the name of the collection
 119    * @exception XMLDBException
 120    */
 121  0 public String getCollectionName() throws XMLDBException {
 122  0 try {
 123  0 return coll.getName();
 124    } catch (Exception e) {
 125  0 throw FaultCodes.createXMLDBException(e);
 126    }
 127    }
 128   
 129    /**
 130    * Returns the fully qualified name of the collection that this manager is
 131    * associated with. This name includes all parent collections.
 132    *
 133    * @return the fully qualified name for this collection.
 134    * @exception XMLDBException
 135    */
 136  0 public String getCanonicalName() throws XMLDBException {
 137  0 try {
 138  0 return ((XindiceCollection) coll).getCanonicalName();
 139    } catch (Exception e) {
 140  0 throw FaultCodes.createXMLDBException(e);
 141    }
 142    }
 143   
 144    /**
 145    * Creates a new collection in the database identified by name and using
 146    * the provided configuration.
 147    *
 148    * @param path the path of the new collection
 149    * @param configuration the XML collection configuration to use for
 150    * creating this collection.
 151    * @return The newly created collection
 152    * @exception XMLDBException
 153    */
 154  390 public Collection createCollection(String path, Document configuration)
 155    throws XMLDBException {
 156  390 if (coll == null) {
 157  0 throw new XMLDBException(ErrorCodes.INVALID_COLLECTION,
 158    "Must set collection for this service");
 159    }
 160   
 161  390 return ((XindiceCollection) coll).createCollection(path, configuration);
 162    }
 163   
 164    /**
 165    * Drops a child collection from this collection.
 166    *
 167    * @param name The name of the child collection to drop.
 168    * @exception XMLDBException
 169    */
 170  387 public void dropCollection(String name) throws XMLDBException {
 171  387 this.removeCollection(name);
 172    }
 173   
 174    /**
 175    * Returns a list of all indexers for this collection.
 176    *
 177    * @return the list of indexers
 178    * @exception XMLDBException
 179    */
 180  15 public String[] listIndexers() throws XMLDBException {
 181  15 try {
 182  15 return ((XindiceCollection) coll).listIndexers();
 183    } catch (Exception e) {
 184  0 throw FaultCodes.createXMLDBException(e);
 185    }
 186    }
 187   
 188    /**
 189    * Creates a new Indexer for this collection.
 190    *
 191    * @param configuration The configuration to use for this indexer.
 192    * @exception XMLDBException
 193    */
 194  90 public void createIndexer(Document configuration) throws XMLDBException {
 195  90 try {
 196  90 ((XindiceCollection) coll).createIndexer(configuration);
 197    } catch (Exception e) {
 198  12 throw FaultCodes.createXMLDBException(e);
 199    }
 200    }
 201   
 202    /* see superclass for documentation */
 203  66 public void dropIndexer(String name) throws XMLDBException {
 204  66 try {
 205  66 ((XindiceCollection) coll).dropIndexer(name);
 206    } catch (Exception e) {
 207  9 throw FaultCodes.createXMLDBException(e);
 208    }
 209    }
 210   
 211    /**
 212    * Shutsdown the Database instance
 213    *
 214    * @exception XMLDBException
 215    */
 216  0 public void shutdown() throws XMLDBException {
 217  0 ((XindiceCollection) coll).shutdown();
 218   
 219    }
 220   
 221   
 222    /**
 223    * Returns a list of all collection level XMLObjects for this collection.
 224    *
 225    * @return the list of XMLObjects.
 226    * @exception XMLDBException
 227    */
 228  0 public String[] listXMLObjects() throws XMLDBException {
 229  0 return null;
 230    }
 231   
 232    /**
 233    * Creates a new collection level XMLObject using the provided configuration.
 234    * The XMLObject will be added to the collection using the provided name as
 235    * a key.
 236    *
 237    * @param configuration The XML configuration to use
 238    * @exception XMLDBException
 239    */
 240  0 public void createXMLObject(Document configuration) throws XMLDBException {
 241   
 242    }
 243   
 244    /**
 245    * Drops a collection level XMLObject from the collection.
 246    *
 247    * @param name The name of the XMLObject to drop.
 248    * @exception XMLDBException
 249    */
 250  0 public void dropXMLObject(String name)
 251    throws XMLDBException {
 252   
 253    }
 254    }