This project has retired. For details please refer to its Attic page.
RegistryServiceImpl xref
View Javadoc
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      {
56          this.registry = registry;
57          this.maxRows = maxRows;
58          this.uddiVersion = uddiVersion;
59          if ("3.0".equals(uddiVersion)) {
60          	queryManager = new BusinessQueryManagerV3Impl(this);
61          	lifeCycleManager = new BusinessLifeCycleManagerV3Impl(this);
62          } else {
63          	queryManager = new BusinessQueryManagerImpl(this);
64          	lifeCycleManager = new BusinessLifeCycleManagerImpl(this);
65          }
66          if (postalScheme == null)
67          {
68              this.postalScheme = null;
69          } else
70          {
71              this.postalScheme = new ClassificationSchemeImpl(lifeCycleManager);
72              this.postalScheme.setKey(new KeyImpl(postalScheme));
73          }
74      }
75   
76      IRegistryBase getRegistry()
77      {
78          return registry;
79      }
80  
81      BusinessLifeCycleManager getLifeCycleManagerImpl()
82      {
83          return lifeCycleManager;
84      }
85  
86      int getMaxRows()
87      {
88          return maxRows;
89      }
90  
91      public CapabilityProfile getCapabilityProfile()
92      {
93          return new CapabilityProfileImpl();
94      }
95  
96      public String getUddiVersion() {
97      	return uddiVersion;
98      }
99      
100     public BusinessQueryManager getBusinessQueryManager() throws JAXRException
101     {
102         return queryManager;
103     }
104 
105     public BusinessLifeCycleManager getBusinessLifeCycleManager() throws JAXRException
106     {
107         return lifeCycleManager;
108     }
109 
110     public BulkResponse getBulkResponse(String s) throws JAXRException, InvalidRequestException
111     {
112         if (s == "" || s == null)
113             throw new InvalidRequestException();
114         return null;
115     }
116 
117     public DeclarativeQueryManager getDeclarativeQueryManager() throws JAXRException, UnsupportedCapabilityException
118     {
119         throw new UnsupportedCapabilityException();
120     }
121 
122     public ClassificationScheme getDefaultPostalScheme() throws JAXRException
123     {
124         return postalScheme;
125     }
126 
127     public String makeRegistrySpecificRequest(String s) throws JAXRException
128     {
129        String inquiry = "INQUIRY";
130        String publish = "PUBLISH";
131        String type = "";
132 
133        //TODO: Need a better way to do this
134        String snippet = s.substring(0,20);
135        if( snippet.indexOf("save") > -1) type = publish;
136        else
137        type = inquiry;
138 
139        try {
140     	   return registry.execute(s,type);
141 	   } catch (TransportException e) {
142 		   throw new JAXRException(e.getLocalizedMessage());
143 	   } 
144      }
145 
146     public ConnectionImpl getConnection()
147     {
148         return connection;
149     }
150 
151     public void setConnection(ConnectionImpl connection)
152     {
153         this.connection = connection;
154     }
155 
156 }