This project has retired. For details please refer to its Attic page.
Coverage Report
Coverage Report - org.apache.ws.scout.registry.RegistryServiceImpl
 
Classes in this File Line Coverage Branch Coverage Complexity
RegistryServiceImpl
60%
23/38
30%
3/10
1.714
 
 1  
 /**
 2  
  *
 3  
  * Copyright 2004 The Apache Software Foundation
 4  
  *
 5  
  *  Licensed under the Apache License, Version 2.0 (the "License");
 6  
  *  you may not use this file except in compliance with the License.
 7  
  *  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  
 package org.apache.ws.scout.registry;
 18  
 
 19  
 import javax.xml.registry.BulkResponse;
 20  
 import javax.xml.registry.BusinessLifeCycleManager;
 21  
 import javax.xml.registry.BusinessQueryManager;
 22  
 import javax.xml.registry.CapabilityProfile;
 23  
 import javax.xml.registry.DeclarativeQueryManager;
 24  
 import javax.xml.registry.InvalidRequestException;
 25  
 import javax.xml.registry.JAXRException;
 26  
 import javax.xml.registry.RegistryService;
 27  
 import javax.xml.registry.UnsupportedCapabilityException;
 28  
 import javax.xml.registry.infomodel.ClassificationScheme;
 29  
 
 30  
 import org.apache.ws.scout.registry.infomodel.ClassificationSchemeImpl;
 31  
 import org.apache.ws.scout.registry.infomodel.KeyImpl;
 32  
 import org.apache.ws.scout.transport.TransportException;
 33  
 
 34  
 /**
 35  
  * Scout implementation of javax.xml.registry.RegistryService
 36  
  * For futher details, look into the JAXR API Javadoc.
 37  
  *
 38  
  * @author Anil Saldhana  <anil@apache.org>
 39  
  * @author Jeremy Boynes <jboynes@apache.org>
 40  
  * @author Tom Cunningham <tcunning@apache.org>
 41  
  */
 42  
 public class RegistryServiceImpl implements RegistryService
 43  
 {
 44  
     private final IRegistryBase registry;
 45  
     private final BusinessQueryManager queryManager;
 46  
     private final BusinessLifeCycleManager lifeCycleManager;
 47  
     
 48  
     private final ClassificationSchemeImpl postalScheme;
 49  
     private final int maxRows;
 50  
     private final String uddiVersion;
 51  
 
 52  
     private ConnectionImpl connection;
 53  
 
 54  
     public RegistryServiceImpl(IRegistryBase registry, String postalScheme, int maxRows, String uddiVersion)
 55  194
     {
 56  194
         this.registry = registry;
 57  194
         this.maxRows = maxRows;
 58  194
         this.uddiVersion = uddiVersion;
 59  194
         if ("3.0".equals(uddiVersion)) {
 60  58
                 queryManager = new BusinessQueryManagerV3Impl(this);
 61  58
                 lifeCycleManager = new BusinessLifeCycleManagerV3Impl(this);
 62  
         } else {
 63  136
                 queryManager = new BusinessQueryManagerImpl(this);
 64  136
                 lifeCycleManager = new BusinessLifeCycleManagerImpl(this);
 65  
         }
 66  194
         if (postalScheme == null)
 67  
         {
 68  194
             this.postalScheme = null;
 69  
         } else
 70  
         {
 71  0
             this.postalScheme = new ClassificationSchemeImpl(lifeCycleManager);
 72  0
             this.postalScheme.setKey(new KeyImpl(postalScheme));
 73  
         }
 74  194
     }
 75  
  
 76  
     IRegistryBase getRegistry()
 77  
     {
 78  312
         return registry;
 79  
     }
 80  
 
 81  
     BusinessLifeCycleManager getLifeCycleManagerImpl()
 82  
     {
 83  291
         return lifeCycleManager;
 84  
     }
 85  
 
 86  
     int getMaxRows()
 87  
     {
 88  36
         return maxRows;
 89  
     }
 90  
 
 91  
     public CapabilityProfile getCapabilityProfile()
 92  
     {
 93  2
         return new CapabilityProfileImpl();
 94  
     }
 95  
 
 96  
     public String getUddiVersion() {
 97  0
             return uddiVersion;
 98  
     }
 99  
     
 100  
     public BusinessQueryManager getBusinessQueryManager() throws JAXRException
 101  
     {
 102  120
         return queryManager;
 103  
     }
 104  
 
 105  
     public BusinessLifeCycleManager getBusinessLifeCycleManager() throws JAXRException
 106  
     {
 107  174
         return lifeCycleManager;
 108  
     }
 109  
 
 110  
     public BulkResponse getBulkResponse(String s) throws JAXRException, InvalidRequestException
 111  
     {
 112  0
         if (s == "" || s == null)
 113  0
             throw new InvalidRequestException();
 114  0
         return null;
 115  
     }
 116  
 
 117  
     public DeclarativeQueryManager getDeclarativeQueryManager() throws JAXRException, UnsupportedCapabilityException
 118  
     {
 119  2
         throw new UnsupportedCapabilityException();
 120  
     }
 121  
 
 122  
     public ClassificationScheme getDefaultPostalScheme() throws JAXRException
 123  
     {
 124  2
         return postalScheme;
 125  
     }
 126  
 
 127  
     public String makeRegistrySpecificRequest(String s) throws JAXRException
 128  
     {
 129  0
        String inquiry = "INQUIRY";
 130  0
        String publish = "PUBLISH";
 131  0
        String type = "";
 132  
 
 133  
        //TODO: Need a better way to do this
 134  0
        String snippet = s.substring(0,20);
 135  0
        if( snippet.indexOf("save") > -1) type = publish;
 136  
        else
 137  0
        type = inquiry;
 138  
 
 139  
        try {
 140  0
                return registry.execute(s,type);
 141  0
            } catch (TransportException e) {
 142  0
                    throw new JAXRException(e.getLocalizedMessage());
 143  
            } 
 144  
      }
 145  
 
 146  
     public ConnectionImpl getConnection()
 147  
     {
 148  202
         return connection;
 149  
     }
 150  
 
 151  
     public void setConnection(ConnectionImpl connection)
 152  
     {
 153  136
         this.connection = connection;
 154  136
     }
 155  
 
 156  
 }