KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > juddi > datastore > jdbc > JDBCDataStore


1 /*
2  * Copyright 2001-2004 The Apache Software Foundation.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */

16 package org.apache.juddi.datastore.jdbc;
17
18 import java.sql.Connection JavaDoc;
19 import java.sql.SQLException JavaDoc;
20 import java.util.Vector JavaDoc;
21
22 import org.apache.commons.logging.Log;
23 import org.apache.commons.logging.LogFactory;
24 import org.apache.juddi.datastore.DataStore;
25 import org.apache.juddi.datatype.Address;
26 import org.apache.juddi.datatype.CategoryBag;
27 import org.apache.juddi.datatype.DiscoveryURLs;
28 import org.apache.juddi.datatype.IdentifierBag;
29 import org.apache.juddi.datatype.KeyedReference;
30 import org.apache.juddi.datatype.OverviewDoc;
31 import org.apache.juddi.datatype.SharedRelationships;
32 import org.apache.juddi.datatype.TModelBag;
33 import org.apache.juddi.datatype.assertion.PublisherAssertion;
34 import org.apache.juddi.datatype.binding.BindingTemplate;
35 import org.apache.juddi.datatype.binding.BindingTemplates;
36 import org.apache.juddi.datatype.binding.InstanceDetails;
37 import org.apache.juddi.datatype.binding.TModelInstanceDetails;
38 import org.apache.juddi.datatype.binding.TModelInstanceInfo;
39 import org.apache.juddi.datatype.business.BusinessEntity;
40 import org.apache.juddi.datatype.business.Contact;
41 import org.apache.juddi.datatype.business.Contacts;
42 import org.apache.juddi.datatype.publisher.Publisher;
43 import org.apache.juddi.datatype.request.FindQualifiers;
44 import org.apache.juddi.datatype.response.AssertionStatusItem;
45 import org.apache.juddi.datatype.response.BusinessInfo;
46 import org.apache.juddi.datatype.response.CompletionStatus;
47 import org.apache.juddi.datatype.response.PublisherInfo;
48 import org.apache.juddi.datatype.response.RelatedBusinessInfo;
49 import org.apache.juddi.datatype.response.ServiceInfo;
50 import org.apache.juddi.datatype.response.ServiceInfos;
51 import org.apache.juddi.datatype.response.TModelInfo;
52 import org.apache.juddi.datatype.service.BusinessService;
53 import org.apache.juddi.datatype.service.BusinessServices;
54 import org.apache.juddi.datatype.tmodel.TModel;
55 import org.apache.juddi.error.RegistryException;
56 import org.apache.juddi.error.UnknownUserException;
57 import org.apache.juddi.util.Config;
58 import org.apache.juddi.util.jdbc.ConnectionManager;
59 import org.apache.juddi.util.jdbc.Transaction;
60 import org.apache.juddi.uuidgen.UUIDGen;
61 import org.apache.juddi.uuidgen.UUIDGenFactory;
62
63 /**
64  * @author Steve Viens (sviens@apache.org)
65  * @author Anil Saldhana (anil@apache.org)
66  */

67 public class JDBCDataStore implements DataStore
68 {
69   // private reference to the jUDDI logger
70
private static Log log = LogFactory.getLog(JDBCDataStore.class);
71
72   // private db connection associated with this datastore
73
private Connection JavaDoc connection = null;
74
75   // private XA transaxtion object
76
private Transaction transaction = null;
77
78   /**
79    * Create a new JDBCDataStore and aquire a JDBC
80    * connection from the connection pool.
81    */

82   public JDBCDataStore()
83   {
84     try {
85       this.connection = ConnectionManager.aquireConnection();
86     }
87     catch(SQLException JavaDoc sqlex) {
88       log.error("Exception occured while attempting to " +
89         "aquire a JDBC connection: "+sqlex.getMessage());
90     }
91   }
92
93   /**
94    * Release all JDBC connections used by this
95    * JDBCDataStore back into the connection pool.
96    */

97   public void release()
98   {
99     try {
100       if (connection != null)
101       {
102         this.connection.close();
103         this.connection = null;
104       }
105     }
106     catch(SQLException JavaDoc sqlex) {
107       log.error("Exception occured while attempting to " +
108         "close a JDBC connection: "+sqlex.getMessage());
109     }
110   }
111
112   /**
113    *
114    */

115   public Connection JavaDoc getConnection()
116   {
117     return this.connection;
118   }
119
120  /**
121   * begin a new transaction
122   */

123   public void beginTrans()
124     throws org.apache.juddi.error.RegistryException
125   {
126     try {
127       this.transaction = new Transaction();
128       this.transaction.begin(connection);
129     }
130     catch(SQLException JavaDoc sqlex) {
131       throw new RegistryException(sqlex);
132     }
133   }
134
135  /**
136   * commit on all connections.
137   */

138   public void commit()
139     throws org.apache.juddi.error.RegistryException
140   {
141     try {
142       this.transaction.commit();
143     }
144     catch(SQLException JavaDoc sqlex) {
145       throw new RegistryException(sqlex);
146     }
147   }
148
149  /**
150   * rollback on all connections.
151   */

152   public void rollback()
153     throws org.apache.juddi.error.RegistryException
154   {
155     try {
156       this.transaction.rollback();
157     }
158     catch(SQLException JavaDoc sqlex) {
159       throw new RegistryException(sqlex);
160     }
161   }
162
163   /**
164    * verify that the individual or system identified by
165    * the 'publisherID' is a valid jUDDI user (aka publisher).
166    *
167    * @param publisherID
168    * @return publisher
169    * @throws RegistryException
170    */

171   public Publisher getPublisher(String JavaDoc publisherID)
172     throws RegistryException
173   {
174     // a publisherID must be specified.
175
if (publisherID == null)
176       return null;
177
178     Publisher publisher = null;
179
180     try {
181       publisher = PublisherTable.select(publisherID,connection);
182     }
183     catch(java.sql.SQLException JavaDoc sqlex) {
184       throw new RegistryException(sqlex);
185     }
186
187     return publisher;
188   }
189
190   /**
191    * Will return true if the publisherID parameter specified has been tagged
192    * with registry administrator priviledges otherwise returns false. An
193    * Unknown user exception is thrown if the publisherID specified is null,
194    * blank or does not exist (can't be found in the PUBLISHER table).
195    *
196    * @param publisherID
197    * @return Returns true if publisherID parameter specified has jUDDI
198    * administrator priv's otherwise returns false.
199    * @throws RegistryException
200    */

201   public boolean isAdministrator(String JavaDoc publisherID)
202     throws org.apache.juddi.error.RegistryException
203   {
204     if ((publisherID == null) || (publisherID.length() == 0))
205       throw new UnknownUserException("publisherID = "+publisherID);
206
207     try
208     {
209       Publisher publisher = PublisherTable.select(publisherID,connection);
210       if (publisher == null)
211         throw new UnknownUserException("publisherID = "+publisherID);
212       else
213         return publisher.isAdmin();
214     }
215     catch(java.sql.SQLException JavaDoc sqlex)
216     {
217       log.error(sqlex.getMessage());
218       throw new RegistryException(sqlex);
219     }
220   }
221
222   /**
223    * Will return true if the publisherID parameter specified is
224    * currently enabled otherwise returns false. An UnknownUserException
225    * is thrown if the publisherID specified is null, blank or does not
226    * exist (can't be found in the PUBLISHER table).
227    *
228    * @param publisherID
229    * @return Returns true if publisherID parameter specified has jUDDI
230    * administrator priv's otherwise returns false.
231    * @throws RegistryException
232    */

233   public boolean isEnabled(String JavaDoc publisherID)
234     throws org.apache.juddi.error.RegistryException
235   {
236     if ((publisherID == null) || (publisherID.length() == 0))
237       throw new UnknownUserException("publisherID = "+publisherID);
238
239     try
240     {
241       Publisher publisher = PublisherTable.select(publisherID,connection);
242       if (publisher == null)
243         throw new UnknownUserException("publisherID = "+publisherID);
244       else
245         return publisher.isEnabled();
246     }
247     catch(java.sql.SQLException JavaDoc sqlex)
248     {
249       log.error(sqlex.getMessage());
250       throw new RegistryException(sqlex);
251     }
252   }
253
254   /**
255    *
256    * @param publisher
257    * @return String
258    * @throws RegistryException
259    */

260   public String JavaDoc generateToken(Publisher publisher)
261     throws RegistryException
262   {
263     UUIDGen uuidgen = UUIDGenFactory.getUUIDGen();
264
265     String JavaDoc token = "authToken:"+uuidgen.uuidgen();
266
267     log.info("Generated token '"+token+"' for user: '" +
268       publisher.getPublisherID()+"/"+publisher.getName()+"'");
269
270     return token;
271   }
272
273   /**
274    *
275    */

276   public void storeAuthToken(String JavaDoc token,Publisher publisher)
277     throws org.apache.juddi.error.RegistryException
278   {
279     if ((token != null) && (publisher != null))
280     {
281       try {
282         AuthTokenTable.insert(token,publisher,connection);
283       }
284       catch(java.sql.SQLException JavaDoc sqlex) {
285         throw new RegistryException(sqlex);
286       }
287     }
288   }
289
290   /**
291    *
292    */

293   public void retireAuthToken(String JavaDoc token)
294     throws org.apache.juddi.error.RegistryException
295   {
296     if (token != null)
297     {
298       try {
299         AuthTokenTable.invalidate(token,connection);
300         AuthTokenTable.touch(token,connection);
301       }
302       catch(java.sql.SQLException JavaDoc sqlex) {
303         throw new RegistryException(sqlex);
304       }
305     }
306   }
307
308   /**
309    *
310    */

311   public Publisher getAuthTokenPublisher(String JavaDoc token)
312     throws org.apache.juddi.error.RegistryException
313   {
314     Publisher publisher = null;
315
316     if (token != null)
317     {
318       try {
319         publisher = AuthTokenTable.selectPublisher(token,connection);
320       }
321       catch(java.sql.SQLException JavaDoc sqlex) {
322         throw new RegistryException(sqlex);
323       }
324     }
325
326     return publisher;
327   }
328
329   /**
330    *
331    */

332   public boolean isAuthTokenExpired(String JavaDoc token)
333     throws org.apache.juddi.error.RegistryException
334   {
335     boolean expired = false;
336
337     if (token != null)
338     {
339       try
340       {
341         long tokenState = AuthTokenTable.selectTokenState(token, connection);
342         if (tokenState <= 0) {
343           return expired = true;
344         }
345
346         long lastUsed = AuthTokenTable.selectLastUsed(token,connection);
347         if (lastUsed > 0) // -1 is returned when token isn't found
348
{
349           long timeOut = Config.getLongProperty("juddi.authTokenTimeout",3600) * 1000L; // convert from seconds to milliseconds
350
long currTime = System.currentTimeMillis();
351           if ((currTime-lastUsed) >= timeOut)
352             expired = true;
353         }
354       }
355       catch(java.sql.SQLException JavaDoc sqlex) {
356         throw new RegistryException(sqlex);
357       }
358     }
359
360     return expired;
361   }
362
363   /**
364    *
365    */

366   public void touchAuthToken(String JavaDoc token)
367     throws org.apache.juddi.error.RegistryException
368   {
369     if (token != null)
370     {
371       try {
372         AuthTokenTable.touch(token,connection);
373       }
374       catch(java.sql.SQLException JavaDoc sqlex) {
375         throw new RegistryException(sqlex);
376       }
377     }
378   }
379
380   /**
381    *
382    */

383   public void saveBusiness(BusinessEntity business,String JavaDoc publisherID)
384     throws org.apache.juddi.error.RegistryException
385   {
386     try
387     {
388       if ((business != null) && (connection != null))
389       {
390         String JavaDoc businessKey = business.getBusinessKey();
391
392         // insert the BusinessEntity object
393
BusinessEntityTable.insert(business,publisherID,connection);
394
395         // insert all of the BusinessEntity Name objects
396
if (business.getNameVector() != null)
397           BusinessNameTable.insert(businessKey,business.getNameVector(),connection);
398
399         // insert all of the BusinessEntity Description objects
400
if (business.getDescriptionVector() != null)
401           BusinessDescTable.insert(businessKey,business.getDescriptionVector(),connection);
402
403         // insert the BusinessEntity's IdentiferBag KeyedReferences
404
IdentifierBag idBag = business.getIdentifierBag();
405         if ((idBag != null) && (idBag.getKeyedReferenceVector() != null))
406           BusinessIdentifierTable.insert(businessKey,idBag.getKeyedReferenceVector(),connection);
407
408         // insert the BusinessEntity's CategoryBag KeyedReferences
409
CategoryBag catBag = business.getCategoryBag();
410         if ((catBag != null) && (catBag.getKeyedReferenceVector() != null))
411           BusinessCategoryTable.insert(businessKey,catBag.getKeyedReferenceVector(),connection);
412
413         // insert the BusinessEntity's DiscoveryURLs
414
DiscoveryURLs discURLs = business.getDiscoveryURLs();
415         if ((discURLs != null) && (discURLs.getDiscoveryURLVector() != null))
416           DiscoveryURLTable.insert(businessKey,discURLs.getDiscoveryURLVector(),connection);
417
418         // insert the BusinessEntity's Contact objects & information
419
Contacts contacts = business.getContacts();
420         if (contacts != null)
421         {
422           Vector JavaDoc contactVector = contacts.getContactVector();
423           if ((contactVector != null) && (contactVector.size() > 0))
424           {
425             // insert the BusinessEntity's Contact objects
426
ContactTable.insert(businessKey,contacts.getContactVector(),connection);
427
428             // insert the BusinessEntity's Contact Phone, Address and Email Info
429
int listSize = contactVector.size();
430             for (int contactID=0; contactID<listSize; contactID++)
431             {
432               Contact contact = (Contact)contactVector.elementAt(contactID);
433               ContactDescTable.insert(businessKey,contactID,contact.getDescriptionVector(),connection);
434               EmailTable.insert(businessKey,contactID,contact.getEmailVector(),connection);
435               PhoneTable.insert(businessKey,contactID,contact.getPhoneVector(),connection);
436
437               // insert the Contact's AddressLine objects
438
Vector JavaDoc addrList = contact.getAddressVector();
439               if ((addrList != null) && (addrList.size() > 0))
440               {
441                 AddressTable.insert(businessKey,contactID,addrList,connection);
442                 for (int addrID=0; addrID<addrList.size(); addrID++)
443                 {
444                   Address address = (Address)addrList.elementAt(addrID);
445                   AddressLineTable.insert(businessKey,contactID,addrID,address.getAddressLineVector(),connection);
446                 }
447               }
448             }
449           }
450         }
451
452         // 'save' the BusinessEntity's BusinessService objects
453
BusinessServices services = business.getBusinessServices();
454         if ((services != null) && (services.getBusinessServiceVector() != null))
455         {
456           UUIDGen uuidgen = UUIDGenFactory.getUUIDGen();
457           Vector JavaDoc serviceVector = services.getBusinessServiceVector();
458           int serviceListSize = serviceVector.size();
459           for (int j=0; j<serviceListSize; j++)
460           {
461             BusinessService service = (BusinessService)serviceVector.elementAt(j);
462             service.setBusinessKey(businessKey);
463
464             // create a new key if serviceKey isn't specified
465
String JavaDoc serviceKey = service.getServiceKey();
466             if ((serviceKey == null) || (serviceKey.length() == 0)) {
467               service.setServiceKey(uuidgen.uuidgen());
468             }
469             
470             saveService(service);
471           }
472         }
473       }
474     }
475     catch(java.sql.SQLException JavaDoc sqlex)
476     {
477       throw new RegistryException(sqlex);
478     }
479   }
480
481   /**
482    *
483    */

484   public BusinessEntity fetchBusiness(String JavaDoc businessKey)
485     throws org.apache.juddi.error.RegistryException
486   {
487     BusinessEntity business = null;
488
489     try
490     {
491       if ((businessKey != null) && (connection != null))
492       {
493         business = BusinessEntityTable.select(businessKey,connection);
494         business.setNameVector(BusinessNameTable.select(businessKey,connection));
495         business.setDescriptionVector(BusinessDescTable.select(businessKey,connection));
496
497         Vector JavaDoc idVector = BusinessIdentifierTable.select(businessKey,connection);
498         if (idVector.size() > 0)
499         {
500           IdentifierBag identifierBag = new IdentifierBag();
501           identifierBag.setKeyedReferenceVector(idVector);
502           business.setIdentifierBag(identifierBag);
503         }
504
505         Vector JavaDoc catVector = BusinessCategoryTable.select(businessKey,connection);
506         if (catVector.size() > 0)
507         {
508           CategoryBag categoryBag = new CategoryBag();
509           categoryBag.setKeyedReferenceVector(catVector);
510           business.setCategoryBag(categoryBag);
511         }
512
513         DiscoveryURLs discoveryURLs = new DiscoveryURLs();
514         discoveryURLs.setDiscoveryURLVector(DiscoveryURLTable.select(businessKey,connection));
515         business.setDiscoveryURLs(discoveryURLs);
516
517         // 'select' the BusinessEntity's Contact objects
518
Vector JavaDoc contactList = ContactTable.select(businessKey,connection);
519         for (int contactID=0; contactID<contactList.size(); contactID++)
520         {
521           Contact contact = (Contact)contactList.elementAt(contactID);
522           contact.setPhoneVector(PhoneTable.select(businessKey,contactID,connection));
523           contact.setEmailVector(EmailTable.select(businessKey,contactID,connection));
524
525           Vector JavaDoc addressList = AddressTable.select(businessKey,contactID,connection);
526           for (int addressID=0; addressID<addressList.size(); addressID++)
527           {
528             Address address = (Address)addressList.elementAt(addressID);
529             address.setAddressLineVector(AddressLineTable.select(businessKey,contactID,addressID,connection));
530           }
531           contact.setAddressVector(addressList);
532         }
533
534         Contacts contacts = new Contacts();
535         contacts.setContactVector(contactList);
536         business.setContacts(contacts);
537
538         // 'fetch' the BusinessEntity's BusinessService objects
539
Vector JavaDoc serviceVector = fetchServiceByBusinessKey(businessKey);
540         BusinessServices services = new BusinessServices();
541         services.setBusinessServiceVector(serviceVector);
542         business.setBusinessServices(services);
543       }
544     }
545     catch(java.sql.SQLException JavaDoc sqlex)
546     {
547       throw new RegistryException(sqlex);
548     }
549
550     return business;
551   }
552
553   /**
554    *
555    */

556   public void deleteBusiness(String JavaDoc businessKey)
557     throws org.apache.juddi.error.RegistryException
558   {
559     try
560     {
561       if ((businessKey != null) && (connection != null))
562       {
563         // delete the BusinessEntity's Services (and dependents)
564
deleteServiceByBusinessKey(businessKey);
565
566         // delete the dependents of BusinessEntity
567
AddressLineTable.delete(businessKey,connection);
568         AddressTable.delete(businessKey,connection);
569         EmailTable.delete(businessKey,connection);
570         PhoneTable.delete(businessKey,connection);
571         ContactDescTable.delete(businessKey,connection);
572         ContactTable.delete(businessKey,connection);
573         DiscoveryURLTable.delete(businessKey,connection);
574         BusinessIdentifierTable.delete(businessKey,connection);
575         BusinessCategoryTable.delete(businessKey,connection);
576         BusinessDescTable.delete(businessKey,connection);
577         BusinessNameTable.delete(businessKey,connection);
578
579         // finally, delete the BusinessEntity itself.
580
BusinessEntityTable.delete(businessKey,connection);
581       }
582     }
583     catch(java.sql.SQLException JavaDoc sqlex)
584     {
585       log.error(sqlex.getMessage(),sqlex);
586       throw new RegistryException(sqlex);
587     }
588   }
589
590   /**
591    *
592    */

593   public boolean isBusinessPublisher(String JavaDoc businessKey,String JavaDoc publisherID)
594     throws org.apache.juddi.error.RegistryException
595   {
596     try
597     {
598       if ((publisherID != null) && (businessKey != null) && (connection != null))
599         return BusinessEntityTable.verifyOwnership(businessKey,publisherID,connection);
600     }
601     catch(java.sql.SQLException JavaDoc sqlex)
602     {
603       throw new RegistryException(sqlex);
604     }
605
606     // default to false
607
return false;
608   }
609
610   /**
611    *
612    */

613   public boolean isValidBusinessKey(String JavaDoc businessKey)
614     throws org.apache.juddi.error.RegistryException
615   {
616     try
617     {
618       if ((businessKey != null) && (connection != null) &&
619           (BusinessEntityTable.select(businessKey,connection) != null))
620         return true;
621     }
622     catch(java.sql.SQLException JavaDoc sqlex)
623     {
624       throw new RegistryException(sqlex);
625     }
626
627     // default to false
628
return false;
629   }
630
631   /**
632    *
633    */

634   public void saveService(BusinessService service)
635     throws org.apache.juddi.error.RegistryException
636   {
637     try
638     {
639       if ((service != null) && (connection != null))
640       {
641         String JavaDoc serviceKey = service.getServiceKey();
642
643         // insert the BusinessService object
644
BusinessServiceTable.insert(service,connection);
645
646         // insert all of the BusinessService's Name objects
647
if (service.getNameVector() != null)
648           ServiceNameTable.insert(serviceKey,service.getNameVector(),connection);
649
650         // insert all of the BusinessService's Description objects
651
if (service.getDescriptionVector() != null)
652           ServiceDescTable.insert(serviceKey,service.getDescriptionVector(),connection);
653
654         // insert the BusinessService's CategoryBag KeyedReferences
655
CategoryBag catBag = service.getCategoryBag();
656         if ((catBag != null) && (catBag.getKeyedReferenceVector() != null))
657           ServiceCategoryTable.insert(serviceKey,catBag.getKeyedReferenceVector(),connection);
658
659         // extract the binding template objects
660
BindingTemplates bindings = service.getBindingTemplates();
661         if (bindings == null)
662           return; // no binding templates were present
663

664         // convert the binding templates to a vector of templates
665
Vector JavaDoc bindingList = bindings.getBindingTemplateVector();
666         if (bindingList == null)
667           return; // a binding template vector wasn't found
668

669         // aquire a reference to the shared UUIDGen instance
670
UUIDGen uuidgen = UUIDGenFactory.getUUIDGen();
671
672         // save all of the binding templates that were found
673
int listSize = bindingList.size();
674         for (int i=0; i<listSize; i++)
675         {
676           BindingTemplate binding = (BindingTemplate)bindingList.elementAt(i);
677           binding.setServiceKey(serviceKey);
678           
679           // create a new key if bindingKey isn't specified
680
String JavaDoc bindingKey = binding.getBindingKey();
681           if ((bindingKey == null) || (bindingKey.length() == 0)) {
682              binding.setBindingKey(uuidgen.uuidgen());
683           }
684
685           saveBinding(binding);
686         }
687       }
688     }
689     catch(java.sql.SQLException JavaDoc sqlex)
690     {
691       throw new RegistryException(sqlex);
692     }
693   }
694
695   /**
696    *
697    */

698   public BusinessService fetchService(String JavaDoc serviceKey)
699     throws org.apache.juddi.error.RegistryException
700   {
701     BusinessService service = null;
702
703     try
704     {
705       if ((serviceKey != null) && (connection != null))
706       {
707         service = BusinessServiceTable.select(serviceKey,connection);
708         service.setNameVector(ServiceNameTable.select(serviceKey,connection));
709         service.setDescriptionVector(ServiceDescTable.select(serviceKey,connection));
710
711         Vector JavaDoc catVector = ServiceCategoryTable.select(serviceKey,connection);
712         if (catVector.size() > 0)
713         {
714           CategoryBag bag = new CategoryBag();
715           bag.setKeyedReferenceVector(catVector);
716           service.setCategoryBag(bag);
717         }
718
719         // 'fetch' the BusinessService's BindingTemplate objects
720
Vector JavaDoc bindingVector = fetchBindingByServiceKey(serviceKey);
721         BindingTemplates bindings = new BindingTemplates();
722         bindings.setBindingTemplateVector(bindingVector);
723         service.setBindingTemplates(bindings);
724       }
725     }
726     catch(java.sql.SQLException JavaDoc sqlex)
727     {
728       throw new RegistryException(sqlex);
729     }
730
731     return service;
732   }
733
734   /**
735    *
736    */

737   public void deleteService(String JavaDoc serviceKey)
738     throws org.apache.juddi.error.RegistryException
739   {
740     try
741     {
742       if ((serviceKey != null) && (connection != null))
743       {
744         // delete the BusinessService's BindingTemplates (and dependents)
745
deleteBindingByServiceKey(serviceKey);
746
747         // delete the immediate dependents of BusinessService
748
ServiceNameTable.delete(serviceKey,connection);
749         ServiceDescTable.delete(serviceKey,connection);
750         ServiceCategoryTable.delete(serviceKey,connection);
751
752         // finally, delete the BusinessService itself.
753
BusinessServiceTable.delete(serviceKey,connection);
754       }
755     }
756     catch(java.sql.SQLException JavaDoc sqlex)
757     {
758       throw new RegistryException(sqlex);
759     }
760   }
761
762   /**
763    *
764    */

765   private Vector JavaDoc fetchServiceByBusinessKey(String JavaDoc businessKey)
766     throws org.apache.juddi.error.RegistryException
767   {
768     Vector JavaDoc serviceList = new Vector JavaDoc();
769
770     try
771     {
772       if ((businessKey != null) && (connection != null))
773       {
774         Vector JavaDoc tempList = BusinessServiceTable.selectByBusinessKey(businessKey,connection);
775         for (int i=0; i<tempList.size(); i++)
776         {
777           BusinessService service = (BusinessService)tempList.elementAt(i);
778           serviceList.add(fetchService(service.getServiceKey()));
779         }
780       }
781     }
782     catch(java.sql.SQLException JavaDoc sqlex)
783     {
784       throw new RegistryException(sqlex);
785     }
786
787     return serviceList;
788   }
789
790   /**
791    *
792    */

793   private void deleteServiceByBusinessKey(String JavaDoc businessKey)
794     throws org.apache.juddi.error.RegistryException
795   {
796     try
797     {
798       if ((businessKey != null) && (connection != null))
799       {
800         // obtain a vector of BusinessServices associated with the BusinessKey
801
Vector JavaDoc services = BusinessServiceTable.selectByBusinessKey(businessKey,connection);
802
803         // loop through the vector deleting each server in turn
804
int listSize = services.size();
805         for (int i=0; i<listSize; i++)
806         {
807           BusinessService service = (BusinessService)services.elementAt(i);
808           deleteService(service.getServiceKey());
809         }
810       }
811     }
812     catch(java.sql.SQLException JavaDoc sqlex)
813     {
814       throw new RegistryException(sqlex);
815     }
816
817   }
818
819   /**
820    *
821    */

822   public boolean isValidServiceKey(String JavaDoc serviceKey)
823     throws org.apache.juddi.error.RegistryException
824   {
825     try
826     {
827       if ((serviceKey != null) && (connection != null) &&
828           (BusinessServiceTable.select(serviceKey,connection) != null))
829         return true;
830     }
831     catch(java.sql.SQLException JavaDoc sqlex)
832     {
833       throw new RegistryException(sqlex);
834     }
835
836     // default to false
837
return false;
838   }
839
840   /**
841    *
842    */

843   public boolean isServicePublisher(String JavaDoc serviceKey,String JavaDoc publisherID)
844     throws org.apache.juddi.error.RegistryException
845   {
846     try
847     {
848       if ((publisherID != null) && (serviceKey != null) && (connection != null))
849         return BusinessServiceTable.verifyOwnership(serviceKey,publisherID,connection);
850     }
851     catch(java.sql.SQLException JavaDoc sqlex)
852     {
853       throw new RegistryException(sqlex);
854     }
855
856     // default to false
857
return false;
858   }
859
860   /**
861    *
862    */

863   public void saveBinding(BindingTemplate binding)
864     throws org.apache.juddi.error.RegistryException
865   {
866     try
867     {
868       if ((binding != null) && (connection != null))
869       {
870         String JavaDoc bindingKey = binding.getBindingKey();
871
872         // insert the BindingTemplate object
873
BindingTemplateTable.insert(binding,connection);
874
875         // insert the BindingTemplate's CategoryBag KeyedReferences (UDDI v3.0)
876
CategoryBag catBag = binding.getCategoryBag();
877         if ((catBag != null) && (catBag.getKeyedReferenceVector() != null))
878           BindingCategoryTable.insert(bindingKey,catBag.getKeyedReferenceVector(),connection);
879
880         // insert all of the BindingTemplate's Description objects
881
if (binding.getDescriptionVector() != null)
882           BindingDescTable.insert(bindingKey,binding.getDescriptionVector(),connection);
883
884         TModelInstanceDetails details = binding.getTModelInstanceDetails();
885         if (details == null)
886           return;
887
888         Vector JavaDoc detailsVector = details.getTModelInstanceInfoVector();
889         if (detailsVector == null)
890           return;
891
892         TModelInstanceInfoTable.insert(bindingKey,detailsVector,connection);
893
894         // save all of the BindingTemplate objects
895
Vector JavaDoc infoList = details.getTModelInstanceInfoVector();
896
897         int listSize = infoList.size();
898         for (int infoID=0; infoID<listSize; infoID++)
899         {
900           TModelInstanceInfo info = (TModelInstanceInfo)infoList.elementAt(infoID);
901           TModelInstanceInfoDescTable.insert(binding.getBindingKey(),infoID,info.getDescriptionVector(),connection);
902
903           InstanceDetails instDetails = info.getInstanceDetails();
904           if (instDetails != null)
905           {
906             InstanceDetailsDescTable.insert(binding.getBindingKey(),infoID,instDetails.getDescriptionVector(),connection);
907
908             OverviewDoc overDoc = instDetails.getOverviewDoc();
909             if (overDoc != null)
910               InstanceDetailsDocDescTable.insert(binding.getBindingKey(),infoID,overDoc.getDescriptionVector(),connection);
911           }
912         }
913       }
914     }
915     catch(java.sql.SQLException JavaDoc sqlex)
916     {
917       throw new RegistryException(sqlex);
918     }
919   }
920
921   /**
922    *
923    */

924   public BindingTemplate fetchBinding(String JavaDoc bindingKey)
925     throws org.apache.juddi.error.RegistryException
926   {
927     BindingTemplate binding = null;
928
929     try
930     {
931       if ((bindingKey != null) && (connection != null))
932       {
933         // fetch the BindingTempate and it's Description Vector
934
binding = BindingTemplateTable.select(bindingKey,connection);
935         binding.setDescriptionVector(BindingDescTable.select(bindingKey,connection));
936
937         // fetch the BindingTemplate's CategoryBag (UDDI v3.0)
938
CategoryBag bag = new CategoryBag();
939         bag.setKeyedReferenceVector(BindingCategoryTable.select(bindingKey,connection));
940         binding.setCategoryBag(bag);
941
942         // fetch the BindingTemplate's TModelInstanceInfos
943
Vector JavaDoc infoVector = TModelInstanceInfoTable.select(bindingKey,connection);
944         if (infoVector != null)
945         {
946           int vectorSize = infoVector.size();
947           for (int infoID=0; infoID<vectorSize; infoID++)
948           {
949             TModelInstanceInfo info = (TModelInstanceInfo)infoVector.elementAt(infoID);
950
951             // fetch the TModelInstanceInfo Descriptions
952
info.setDescriptionVector(TModelInstanceInfoDescTable.select(bindingKey,infoID,connection));
953
954             InstanceDetails instDetails = info.getInstanceDetails();
955             if (instDetails != null)
956             {
957               // fetch the InstanceDetail Descriptions
958
instDetails.setDescriptionVector(InstanceDetailsDescTable.select(bindingKey,infoID,connection));
959
960               // fetch the InstanceDetail OverviewDoc Descrptions
961
OverviewDoc overDoc = instDetails.getOverviewDoc();
962               if (overDoc != null)
963               {
964                 overDoc.setDescriptionVector(InstanceDetailsDocDescTable.select(bindingKey,infoID,connection));
965                 instDetails.setOverviewDoc(overDoc);
966               }
967             }
968           }
969
970           TModelInstanceDetails details = new TModelInstanceDetails();
971           details.setTModelInstanceInfoVector(infoVector);
972           binding.setTModelInstanceDetails(details);
973         }
974       }
975     }
976     catch(java.sql.SQLException JavaDoc sqlex)
977     {
978       throw new RegistryException(sqlex);
979     }
980
981     return binding;
982   }
983
984   /**
985    *
986    */

987   public void deleteBinding(String JavaDoc bindingKey)
988     throws org.apache.juddi.error.RegistryException
989   {
990     try
991     {
992       if ((bindingKey != null) && (connection != null))
993       {
994         // delete the immediate dependents of BindingTemplate
995
BindingDescTable.delete(bindingKey,connection);
996         BindingCategoryTable.delete(bindingKey,connection); // UDDI v3.0
997
TModelInstanceInfoDescTable.delete(bindingKey,connection);
998         InstanceDetailsDocDescTable.delete(bindingKey,connection);
999         InstanceDetailsDescTable.delete(bindingKey,connection);
1000        TModelInstanceInfoTable.delete(bindingKey,connection);
1001
1002        // finally, delete the BindingTemplate itself.
1003
BindingTemplateTable.delete(bindingKey,connection);
1004      }
1005    }
1006    catch(java.sql.SQLException JavaDoc sqlex)
1007    {
1008      throw new RegistryException(sqlex);
1009    }
1010  }
1011
1012  /**
1013   *
1014   */

1015  private Vector JavaDoc fetchBindingByServiceKey(String JavaDoc serviceKey)
1016    throws org.apache.juddi.error.RegistryException
1017  {
1018    Vector JavaDoc bindingList = new Vector JavaDoc();
1019
1020    try
1021    {
1022      if ((serviceKey != null) && (connection != null))
1023      {
1024        Vector JavaDoc tempList = BindingTemplateTable.selectByServiceKey(serviceKey,connection);
1025        for (int i=0; i<tempList.size(); i++)
1026        {
1027          BindingTemplate binding = (BindingTemplate)tempList.elementAt(i);
1028          bindingList.add(fetchBinding(binding.getBindingKey()));
1029        }
1030      }
1031    }
1032    catch(java.sql.SQLException JavaDoc sqlex)
1033    {
1034      throw new RegistryException(sqlex);
1035    }
1036
1037    return bindingList;
1038  }
1039
1040  /**
1041   *
1042   */

1043  private void deleteBindingByServiceKey(String JavaDoc serviceKey)
1044    throws org.apache.juddi.error.RegistryException
1045  {
1046    try
1047    {
1048      if ((serviceKey != null) && (connection != null))
1049      {
1050        // obtain a vector of BusinessServices associated with the BusinessKey
1051
Vector JavaDoc bindings = BindingTemplateTable.selectByServiceKey(serviceKey,connection);
1052
1053        // loop through the vector deleting each server in turn
1054
int listSize = bindings.size();
1055        for (int i=0; i<listSize; i++)
1056        {
1057          BindingTemplate binding = (BindingTemplate)bindings.elementAt(i);
1058          deleteBinding(binding.getBindingKey());
1059        }
1060      }
1061    }
1062    catch(java.sql.SQLException JavaDoc sqlex)
1063    {
1064      throw new RegistryException(sqlex);
1065    }
1066  }
1067
1068  /**
1069   *
1070   */

1071  public boolean isValidBindingKey(String JavaDoc bindingKey)
1072    throws org.apache.juddi.error.RegistryException
1073  {
1074    try
1075    {
1076      if ((bindingKey != null) && (connection != null) &&
1077          (BindingTemplateTable.select(bindingKey,connection) != null))
1078        return true;
1079    }
1080    catch(java.sql.SQLException JavaDoc sqlex)
1081    {
1082      throw new RegistryException(sqlex);
1083    }
1084    // default to false
1085
return false;
1086  }
1087
1088  /**
1089   *
1090   */

1091  public boolean isBindingPublisher(String JavaDoc bindingKey,String JavaDoc publisherID)
1092    throws org.apache.juddi.error.RegistryException
1093  {
1094    try
1095    {
1096      if ((publisherID != null) && (bindingKey != null) && (connection != null))
1097        return BindingTemplateTable.verifyOwnership(bindingKey,publisherID,connection);
1098    }
1099    catch(java.sql.SQLException JavaDoc sqlex)
1100    {
1101      throw new RegistryException(sqlex);
1102    }
1103
1104    // default to false
1105
return false;
1106  }
1107
1108  /**
1109   *
1110   */

1111  public void saveTModel(TModel tModel,String JavaDoc authorizedUserID)
1112    throws org.apache.juddi.error.RegistryException
1113  {
1114    try
1115    {
1116      if ((tModel != null) && (connection != null))
1117      {
1118        String JavaDoc tModelKey = tModel.getTModelKey();
1119
1120        // insert the TModel object
1121
TModelTable.insert(tModel,authorizedUserID,connection);
1122
1123        // insert all of the TModel Description objects
1124
if (tModel.getDescriptionVector() != null)
1125          TModelDescTable.insert(tModelKey,tModel.getDescriptionVector(),connection);
1126
1127        // insert the TModel's IdentiferBag KeyedReferences
1128
IdentifierBag idBag = tModel.getIdentifierBag();
1129        if ((idBag != null) && (idBag.getKeyedReferenceVector() != null))
1130          TModelIdentifierTable.insert(tModelKey,idBag.getKeyedReferenceVector(),connection);
1131
1132        // insert the TModel's CategoryBag KeyedReferences
1133
CategoryBag catBag = tModel.getCategoryBag();
1134        if ((catBag != null) && (catBag.getKeyedReferenceVector() != null))
1135          TModelCategoryTable.insert(tModelKey,catBag.getKeyedReferenceVector(),connection);
1136
1137        // insert the TModel's OverviewDoc & Descriptions
1138
OverviewDoc overDoc = tModel.getOverviewDoc();
1139        if ((overDoc != null) && (overDoc.getDescriptionVector() != null))
1140        {
1141          // insert the TModel's OverviewDoc Descriptions
1142
Vector JavaDoc descVector = overDoc.getDescriptionVector();
1143          if ((descVector != null) && (descVector.size() > 0))
1144            TModelDocDescTable.insert(tModelKey,descVector,connection);
1145        }
1146      }
1147    }
1148    catch(java.sql.SQLException JavaDoc sqlex)
1149    {
1150      throw new RegistryException(sqlex);
1151    }
1152  }
1153
1154  /**
1155   *
1156   */

1157  public TModel fetchTModel(String JavaDoc tModelKey)
1158    throws org.apache.juddi.error.RegistryException
1159  {
1160    TModel tModel = null;
1161
1162    try
1163    {
1164      if ((tModelKey != null) && (connection != null))
1165      {
1166        tModel = TModelTable.select(tModelKey,connection);
1167        if (tModel != null)
1168        {
1169          tModel.setDescriptionVector(TModelDescTable.select(tModelKey,connection));
1170
1171          // fetch the TModel CategoryBag
1172
Vector JavaDoc catVector = TModelCategoryTable.select(tModelKey,connection);
1173          if ((catVector != null) && (catVector.size() != 0))
1174          {
1175            CategoryBag catBag = new CategoryBag();
1176            catBag.setKeyedReferenceVector(catVector);
1177            tModel.setCategoryBag(catBag);
1178          }
1179
1180          // fetch the TModel IdentifierBag
1181
Vector JavaDoc idVector = TModelIdentifierTable.select(tModelKey,connection);
1182          if ((idVector != null) && (idVector.size() != 0))
1183          {
1184            IdentifierBag idBag = new IdentifierBag();
1185            idBag.setKeyedReferenceVector(idVector);
1186            tModel.setIdentifierBag(idBag);
1187          }
1188
1189          // fetch the TModel OverviewDoc & OverviewDoc Descrptions
1190
OverviewDoc overDoc = tModel.getOverviewDoc();
1191          if (overDoc != null)
1192          {
1193            overDoc.setDescriptionVector(TModelDocDescTable.select(tModelKey,connection));
1194            tModel.setOverviewDoc(overDoc);
1195          }
1196        }
1197      }
1198    }
1199    catch(java.sql.SQLException JavaDoc sqlex)
1200    {
1201      throw new RegistryException(sqlex);
1202    }
1203
1204    return tModel;
1205  }
1206
1207  /**
1208   *
1209   */

1210  public void deleteTModel(String JavaDoc tModelKey)
1211    throws org.apache.juddi.error.RegistryException
1212  {
1213    try
1214    {
1215      if ((tModelKey != null) && (connection != null))
1216      {
1217        // delete the dependents of TModel
1218
TModelCategoryTable.delete(tModelKey,connection);
1219        TModelDescTable.delete(tModelKey,connection);
1220        TModelDocDescTable.delete(tModelKey,connection);
1221        TModelIdentifierTable.delete(tModelKey,connection);
1222
1223        // delete the TModel
1224
TModelTable.delete(tModelKey,connection);
1225      }
1226    }
1227    catch(java.sql.SQLException JavaDoc sqlex)
1228    {
1229      throw new RegistryException(sqlex);
1230    }
1231  }
1232
1233  /**
1234   *
1235   */

1236  public void markTModelAsDeleted(String JavaDoc tModelKey)
1237    throws org.apache.juddi.error.RegistryException
1238  {
1239    try
1240    {
1241      if ((tModelKey != null) && (connection != null))
1242      {
1243        // mark the TModel as deleted
1244
TModelTable.markAsDeleted(tModelKey,connection);
1245      }
1246    }
1247    catch(java.sql.SQLException JavaDoc sqlex)
1248    {
1249      throw new RegistryException(sqlex);
1250    }
1251  }
1252
1253  /**
1254   *
1255   */

1256  public boolean isValidTModelKey(String JavaDoc tModelKey)
1257    throws org.apache.juddi.error.RegistryException
1258  {
1259    try
1260    {
1261      if ((tModelKey != null) && (connection != null) &&
1262          (TModelTable.select(tModelKey,connection) != null))
1263        return true;
1264    }
1265    catch(java.sql.SQLException JavaDoc sqlex)
1266    {
1267      throw new RegistryException(sqlex);
1268    }
1269
1270    // default to false
1271
return false;
1272  }
1273
1274  /**
1275   *
1276   */

1277  public boolean isTModelPublisher(String JavaDoc tModelKey,String JavaDoc publisherID)
1278    throws org.apache.juddi.error.RegistryException
1279  {
1280    try
1281    {
1282      if ((publisherID != null) && (tModelKey != null) && (connection != null))
1283        return TModelTable.verifyOwnership(tModelKey,publisherID,connection);
1284    }
1285    catch(java.sql.SQLException JavaDoc sqlex)
1286    {
1287      throw new RegistryException(sqlex);
1288    }
1289
1290    // default to false
1291
return false;
1292  }
1293
1294  /**
1295   *
1296   */

1297  public BusinessInfo fetchBusinessInfo(String JavaDoc businessKey)
1298    throws org.apache.juddi.error.RegistryException
1299  {
1300    BusinessInfo info = null;
1301
1302    if ((businessKey != null) && (connection != null))
1303    {
1304      try
1305      {
1306        info = new BusinessInfo();
1307        info.setBusinessKey(businessKey);
1308        info.setNameVector(BusinessNameTable.select(businessKey,connection));
1309        info.setDescriptionVector(BusinessDescTable.select(businessKey,connection));
1310        info.setServiceInfos(fetchServiceInfosByBusinessKey(businessKey));
1311      }
1312      catch(java.sql.SQLException JavaDoc sqlex)
1313      {
1314        throw new RegistryException(sqlex);
1315      }
1316    }
1317
1318    return info;
1319  }
1320
1321  /**
1322   *
1323   */

1324  private ServiceInfos fetchServiceInfosByBusinessKey(String JavaDoc businessKey)
1325    throws org.apache.juddi.error.RegistryException
1326  {
1327    Vector JavaDoc serviceInfoVector = new Vector JavaDoc();
1328
1329    if ((businessKey != null) && (connection != null))
1330    {
1331      try
1332      {
1333        Vector JavaDoc services = BusinessServiceTable.selectByBusinessKey(businessKey,connection);
1334        for (int i=0; i<services.size(); i++)
1335        {
1336          // make a reference to this BusinessServce to
1337
// easily harvest ServiceInfo data from it.
1338
BusinessService service = (BusinessService)services.elementAt(i);
1339          String JavaDoc serviceKey = service.getServiceKey();
1340
1341          // okay, create a new ServiceInfo
1342
ServiceInfo info = new ServiceInfo();
1343          info.setServiceKey(serviceKey);
1344          info.setBusinessKey(businessKey);
1345          info.setNameVector(ServiceNameTable.select(serviceKey,connection));
1346
1347          // add this ServiceInfo to the ServiceInfo vector
1348
serviceInfoVector.add(info);
1349        }
1350      }
1351      catch(java.sql.SQLException JavaDoc sqlex)
1352      {
1353        throw new RegistryException(sqlex);
1354      }
1355    }
1356
1357    ServiceInfos serviceInfos = new ServiceInfos();
1358    serviceInfos.setServiceInfoVector(serviceInfoVector);
1359    return serviceInfos;
1360  }
1361
1362  /**
1363   *
1364   */

1365  public ServiceInfo fetchServiceInfo(String JavaDoc serviceKey)
1366    throws org.apache.juddi.error.RegistryException
1367  {
1368    ServiceInfo info = null;
1369
1370    if ((serviceKey != null) && (connection != null))
1371    {
1372      try
1373      {
1374        BusinessService service = BusinessServiceTable.select(serviceKey,connection);
1375        if (service != null)
1376        {
1377          info = new ServiceInfo();
1378          info.setServiceKey(service.getServiceKey());
1379          info.setBusinessKey(service.getBusinessKey());
1380          info.setNameVector(ServiceNameTable.select(serviceKey,connection));
1381        }
1382      }
1383      catch(java.sql.SQLException JavaDoc sqlex)
1384      {
1385        throw new RegistryException(sqlex);
1386      }
1387    }
1388
1389    return info;
1390  }
1391
1392  /**
1393   *
1394   */

1395  public TModelInfo fetchTModelInfo(String JavaDoc tModelKey)
1396    throws org.apache.juddi.error.RegistryException
1397  {
1398    TModelInfo info = null;
1399
1400    if ((tModelKey != null) && (connection != null))
1401    {
1402      try
1403      {
1404        TModel tModel = TModelTable.select(tModelKey,connection);
1405        info = new TModelInfo();
1406        info.setTModelKey(tModelKey);
1407        info.setNameValue(tModel.getName());
1408      }
1409      catch(java.sql.SQLException JavaDoc sqlex)
1410      {
1411        throw new RegistryException(sqlex);
1412      }
1413    }
1414
1415    return info;
1416  }
1417
1418  /**
1419   *
1420   */

1421  public Vector JavaDoc findBusiness( Vector JavaDoc nameVector,
1422                              DiscoveryURLs discoveryURLs,
1423                              IdentifierBag identifierBag,
1424                              CategoryBag categoryBag,
1425                              TModelBag tModelBag,
1426                              FindQualifiers findQualifiers)
1427    throws org.apache.juddi.error.RegistryException
1428  {
1429    Vector JavaDoc keyVector = null;
1430
1431    try
1432    {
1433      if ((discoveryURLs != null) && (discoveryURLs.size() > 0))
1434        keyVector = FindBusinessByDiscoveryURLQuery.select(discoveryURLs,keyVector,findQualifiers,connection);
1435
1436      if ((findQualifiers != null) && (findQualifiers.orAllKeys))
1437      {
1438        // orAllKeys = Use logical "OR" when searching by categoryBag
1439
// or tModelBag. See UDDI v2.04 API Specification - Appendix E.
1440

1441        if ((tModelBag != null) && (tModelBag.size() > 0))
1442          keyVector = FindBusinessByTModelKeyQuery.select(tModelBag,keyVector,findQualifiers,connection);
1443        
1444        if ((categoryBag != null) && (categoryBag.size() > 0))
1445          keyVector = FindBusinessByCategoryQuery.select(categoryBag,keyVector,findQualifiers,connection);
1446      }
1447      else
1448      {
1449        // Default UDDI v2 behavior: Use logical "AND" when searching
1450
// by categoryBagor tModelBag. See Appendix E of the UDDI v2.04
1451
// API Specification.
1452

1453        if ((tModelBag != null) && (tModelBag.size() > 0))
1454        {
1455          Vector JavaDoc tModelKeyVector = tModelBag.getTModelKeyVector();
1456          if (tModelKeyVector != null)
1457          {
1458            for (int i=0; i<tModelKeyVector.size(); i++)
1459            {
1460              String JavaDoc tModelKey = (String JavaDoc)tModelKeyVector.elementAt(i);
1461              keyVector = FindBusinessByTModelKeyQuery.select(tModelKey,keyVector,findQualifiers,connection);
1462            }
1463          }
1464        }
1465
1466        if ((categoryBag != null) && (categoryBag.size() > 0))
1467        {
1468          Vector JavaDoc keyedRefVector = categoryBag.getKeyedReferenceVector();
1469          if (keyedRefVector != null)
1470          {
1471            for (int i=0; i<keyedRefVector.size(); i++)
1472            {
1473              KeyedReference keyedRef = (KeyedReference)keyedRefVector.elementAt(i);
1474              keyVector = FindBusinessByCategoryQuery.select(keyedRef,keyVector,findQualifiers,connection);
1475            }
1476          }
1477        }
1478      } // end else
1479

1480      if ((identifierBag != null) && (identifierBag.size() > 0))
1481        keyVector = FindBusinessByIdentifierQuery.select(identifierBag,keyVector,findQualifiers,connection);
1482
1483      // always perform this query - even when not searching by Name!!!
1484
keyVector = FindBusinessByNameQuery.select(nameVector,keyVector,findQualifiers,connection);
1485    }
1486    catch(java.sql.SQLException JavaDoc sqlex)
1487    {
1488      throw new RegistryException(sqlex);
1489    }
1490
1491    return keyVector;
1492  }
1493
1494  /**
1495   *
1496   */

1497  public Vector JavaDoc findService(String JavaDoc businessKey,
1498                            Vector JavaDoc nameVector,
1499                            CategoryBag categoryBag,
1500                            TModelBag tModelBag,
1501                            FindQualifiers findQualifiers)
1502    throws org.apache.juddi.error.RegistryException
1503  {
1504    Vector JavaDoc keyVector = null;
1505
1506    try
1507    {
1508      if (businessKey != null)
1509        keyVector = FindServiceByBusinessKeyQuery.select(businessKey,keyVector,findQualifiers,connection);
1510            
1511      if ((findQualifiers != null) && (findQualifiers.orAllKeys))
1512      {
1513        // orAllKeys = Use logical "OR" when searching by categoryBag
1514
// or tModelBag. See UDDI v2.04 API Specification - Appendix E.
1515

1516        if ((tModelBag != null) && (tModelBag.size() > 0))
1517          keyVector = FindServiceByTModelKeyQuery.select(businessKey,tModelBag,keyVector,findQualifiers,connection);
1518
1519        if ((categoryBag != null) && (categoryBag.size() > 0))
1520          keyVector = FindServiceByCategoryQuery.select(businessKey,categoryBag,keyVector,findQualifiers,connection);
1521      }
1522      else
1523      {
1524        // Default UDDI v2 behavior: Use logical "AND" when searching
1525
// by categoryBagor tModelBag. See Appendix E of the UDDI v2.04
1526
// API Specification.
1527

1528        if ((tModelBag != null) && (tModelBag.size() > 0))
1529        {
1530          Vector JavaDoc tModelKeyVector = tModelBag.getTModelKeyVector();
1531          if (tModelKeyVector != null)
1532          {
1533            for (int i=0; i<tModelKeyVector.size(); i++)
1534            {
1535              String JavaDoc tModelKey = (String JavaDoc)tModelKeyVector.elementAt(i);
1536              keyVector = FindServiceByTModelKeyQuery.select(businessKey,tModelKey,keyVector,findQualifiers,connection);
1537            }
1538          }
1539        }
1540
1541        if ((categoryBag != null) && (categoryBag.size() > 0))
1542        {
1543          Vector JavaDoc keyedRefVector = categoryBag.getKeyedReferenceVector();
1544          if (keyedRefVector != null)
1545          {
1546            for (int i=0; i<keyedRefVector.size(); i++)
1547            {
1548              KeyedReference keyedRef = (KeyedReference)keyedRefVector.elementAt(i);
1549              keyVector = FindServiceByCategoryQuery.select(businessKey,keyedRef,keyVector,findQualifiers,connection);
1550            }
1551          }
1552        }
1553      } // end else
1554

1555      // always perform this query - even when not searching by Name!!!
1556
keyVector = FindServiceByNameQuery.select(businessKey,nameVector,keyVector,findQualifiers,connection);
1557    }
1558    catch(java.sql.SQLException JavaDoc sqlex)
1559    {
1560      throw new RegistryException(sqlex);
1561    }
1562
1563    return keyVector;
1564  }
1565
1566  /**
1567   *
1568   */

1569  public Vector JavaDoc findTModel( String JavaDoc name,
1570                            CategoryBag categoryBag,
1571                            IdentifierBag identifierBag,
1572                            FindQualifiers findQualifiers)
1573    throws org.apache.juddi.error.RegistryException
1574  {
1575    Vector JavaDoc keyVector = null;
1576
1577    try
1578    {
1579      if ((findQualifiers != null) && (findQualifiers.orAllKeys))
1580      {
1581        // orAllKeys = Use logical "OR" when searching by category
1582
// bag. See UDDI v2.04 API Specification - Appendix E.
1583
//
1584
if ((categoryBag != null) && (categoryBag.size() > 0))
1585          keyVector = FindTModelByCategoryQuery.select(categoryBag,keyVector,findQualifiers,connection);
1586      }
1587      else
1588      {
1589        // Default UDDI v2 behavior: Use logical "AND" when searching
1590
// by category bag. See UDDI v2.04 API Specification - Appendix E.
1591
//
1592
if ((categoryBag != null) && (categoryBag.size() > 0))
1593        {
1594          Vector JavaDoc keyedRefVector = categoryBag.getKeyedReferenceVector();
1595          if (keyedRefVector != null)
1596          {
1597            for (int i=0; i<keyedRefVector.size(); i++)
1598            {
1599              KeyedReference keyedRef = (KeyedReference)keyedRefVector.elementAt(i);
1600              keyVector = FindTModelByCategoryQuery.select(keyedRef,keyVector,findQualifiers,connection);
1601            }
1602          }
1603        }
1604      }
1605
1606      if ((identifierBag != null) && (identifierBag.size() > 0))
1607        keyVector = FindTModelByIdentifierQuery.select(identifierBag,keyVector,findQualifiers,connection);
1608
1609      // always perform this query - even when not searching by Name!!!
1610
keyVector = FindTModelByNameQuery.select(name,keyVector,findQualifiers,connection);
1611    }
1612    catch(java.sql.SQLException JavaDoc sqlex)
1613    {
1614      throw new RegistryException(sqlex);
1615    }
1616
1617    return keyVector;
1618  }
1619
1620  /**
1621   *
1622   */

1623  public Vector JavaDoc findBinding(String JavaDoc serviceKey,
1624                            CategoryBag categoryBag,
1625                            TModelBag tModelBag,
1626                            FindQualifiers findQualifiers)
1627     throws org.apache.juddi.error.RegistryException
1628  {
1629    Vector JavaDoc keyVector = null;
1630
1631    try
1632    {
1633      if (serviceKey != null)
1634        keyVector = FindBindingByServiceKeyQuery.select(serviceKey,keyVector,findQualifiers,connection);
1635        
1636      if ((findQualifiers != null) && (findQualifiers.orAllKeys))
1637      {
1638        // orAllKeys = Use logical "OR" when searching by TModel bag
1639
// or category bag. See UDDI v2.04 API Specification - Appendix E.
1640

1641        if ((tModelBag != null) && (tModelBag.size() > 0))
1642          keyVector = FindBindingByTModelKeyQuery.select(serviceKey,tModelBag,keyVector,findQualifiers,connection);
1643
1644        if ((categoryBag != null) && (categoryBag.size() > 0))
1645          keyVector = FindBindingByCategoryQuery.select(serviceKey,categoryBag,keyVector,findQualifiers,connection);
1646      }
1647      else
1648      {
1649        // Default UDDI v2 behavior: Use logical "AND" when searching
1650
// by tModel bag. See UDDI v2.04 API Specification - Appendix E.
1651

1652        if ((tModelBag != null) && (tModelBag.size() > 0))
1653        {
1654          Vector JavaDoc tModelKeyVector = tModelBag.getTModelKeyVector();
1655          if (tModelKeyVector != null)
1656          {
1657            for (int i=0; i<tModelKeyVector.size(); i++)
1658            {
1659                String JavaDoc tModelKey = (String JavaDoc)tModelKeyVector.elementAt(i);
1660              keyVector = FindBindingByTModelKeyQuery.select(serviceKey,tModelKey,keyVector,findQualifiers,connection);
1661            }
1662          }
1663        }
1664
1665        if ((categoryBag != null) && (categoryBag.size() > 0))
1666        {
1667          Vector JavaDoc keyedRefVector = categoryBag.getKeyedReferenceVector();
1668          if (keyedRefVector != null)
1669          {
1670            for (int i=0; i<keyedRefVector.size(); i++)
1671            {
1672              KeyedReference keyedRef = (KeyedReference)keyedRefVector.elementAt(i);
1673              keyVector = FindBindingByCategoryQuery.select(serviceKey,keyedRef,keyVector,findQualifiers,connection);
1674            }
1675          }
1676        }
1677      }
1678  
1679// Steve: This fix has been replaced with the call to
1680
// FindBindingByServiceKeyQuery found at the start of
1681
// this method.
1682
//
1683
// /**
1684
// * Anil: Only if the serviceKey is passed
1685
// */
1686
//
1687
// if((serviceKey != null) && (tModelBag == null) && (categoryBag == null))
1688
// {
1689
// Vector bindtempVect= BindingTemplateTable.selectByServiceKey(serviceKey,connection);
1690
// for(int i=0; bindtempVect != null && i < bindtempVect.size();i++)
1691
// {
1692
// BindingTemplate bt = (BindingTemplate)bindtempVect.elementAt(i);
1693
// if(keyVector == null ) keyVector = new Vector(bindtempVect.size());
1694
// keyVector.add(bt.getBindingKey());
1695
// }
1696
// }
1697
}
1698    catch(java.sql.SQLException JavaDoc sqlex)
1699    {
1700      throw new RegistryException(sqlex);
1701    }
1702
1703    return keyVector;
1704  }
1705
1706  /**
1707   *
1708   * 1. Retrieve a Vector of BusinessKeys for related BusinessEntities by calling
1709   * FindRelatedBusinessQuery.select(businessKey) or if a KeyedReference was
1710   * specified in the query call FindRelatedBusinessQuery.selectWithKeyedRef(businessKey,KeyedReference)
1711   *
1712   * 2. Call FindBusinessByNameQuery.select(null,keyVector,qualifiers,connection)
1713   * to return the Vector of relatedBusinessKeys from step 1 in the requested
1714   * order as specified by any FindQualifiers supplied with the UDDI Request.
1715   *
1716   * 3. For each relatedBusinessKey returned in step 2 perform the following:
1717   *
1718   * 4. Create a new RelatedBusinessInfo instance.
1719   *
1720   * 5. Fetch the related businesses BusinessInfo instance by calling
1721   * DataStore.fetchBusinessInfo(relatedBusinessKey) and save the Name
1722   * Vector and Description Vector to the RelatedBusinessInfo created in
1723   * step 4.
1724   *
1725   * 6. Using the businessKey passed in to the query and the relatedBusinessKey
1726   * from the BusinessInfo fetched (step 4) get all KeyedReference instances
1727   * for this pair of keys and add them to the RelatedBusinessInfo created
1728   * in step 4. (only grab KeyedReference values from rows where both
1729   * FROM_CHECK and TO_CHECK columns are = 'true'. Do this by making a call to
1730   * PublisherAssertionTable.selectBusinessRelationships(businessKey,relatedKey)
1731   */

1732  public Vector JavaDoc findRelatedBusinesses(String JavaDoc businessKey,KeyedReference keyedRef,FindQualifiers findQualifiers)
1733    throws org.apache.juddi.error.RegistryException
1734  {
1735    Vector JavaDoc keyVector = null;
1736    Vector JavaDoc infoVector = null;
1737
1738    try
1739    {
1740      // grab the keys of all businesses related to businessKey.
1741
if (keyedRef == null)
1742        keyVector = FindRelatedBusinessQuery.select(businessKey,connection);
1743      else
1744        keyVector = FindRelatedBusinessQuery.selectWithKeyedRef(businessKey,keyedRef,connection);
1745
1746      // returns the keys found above in the approriate order
1747
keyVector = FindBusinessByNameQuery.select(null,keyVector,findQualifiers,connection);
1748
1749      // iterate through the business entity keys fetching each associated BusinessInfo.
1750
int rowCount = keyVector.size();
1751
1752      infoVector = new Vector JavaDoc(rowCount);
1753      for (int i=0; i<rowCount; i++)
1754      {
1755        String JavaDoc relatedKey = (String JavaDoc)keyVector.elementAt(i);
1756        BusinessInfo bizInfo = fetchBusinessInfo(relatedKey);
1757
1758        if(bizInfo != null)
1759        {
1760          RelatedBusinessInfo relatedBizInfo = new RelatedBusinessInfo();
1761
1762          relatedBizInfo.setBusinessKey(bizInfo.getBusinessKey());
1763          relatedBizInfo.setNameVector( bizInfo.getNameVector() );
1764          relatedBizInfo.setDescriptionVector( bizInfo.getDescriptionVector() );
1765
1766          Vector JavaDoc keyedReferences = PublisherAssertionTable.selectRelatedBusinesses(businessKey,relatedKey,connection);
1767          relatedBizInfo.setSharedRelationships(new SharedRelationships(keyedReferences));
1768
1769          infoVector.addElement(relatedBizInfo);
1770        }
1771      }
1772    }
1773    catch(java.sql.SQLException JavaDoc sqlex)
1774    {
1775      throw new RegistryException(sqlex);
1776    }
1777
1778    return infoVector;
1779  }
1780
1781  /**
1782   *
1783   */

1784  public Vector JavaDoc findRegisteredBusinesses(String JavaDoc publisherID)
1785    throws org.apache.juddi.error.RegistryException
1786  {
1787    Vector JavaDoc keyVector = null;
1788
1789    try
1790    {
1791      // grab the keys of all BusinessEntities published by 'publisherID'.
1792
keyVector = BusinessEntityTable.selectByPublisherID(publisherID,connection);
1793    }
1794    catch(java.sql.SQLException JavaDoc sqlex)
1795    {
1796      throw new RegistryException(sqlex);
1797    }
1798
1799    return keyVector;
1800  }
1801
1802  /**
1803   *
1804   */

1805  public Vector JavaDoc findRegisteredTModels(String JavaDoc publisherID)
1806    throws org.apache.juddi.error.RegistryException
1807  {
1808    Vector JavaDoc keyVector = null;
1809
1810    try
1811    {
1812      // grab the keys of all TModels published by 'publisherID'.
1813
keyVector = TModelTable.selectByPublisherID(publisherID,connection);
1814    }
1815    catch(java.sql.SQLException JavaDoc sqlex)
1816    {
1817      throw new RegistryException(sqlex);
1818    }
1819
1820    return keyVector;
1821  }
1822
1823  /**
1824   *
1825   * For each PublisherAssertion in the Vector of PublisherAssertions passed
1826   * in perform the following steps:
1827   *
1828   * 1. Determine if the BusinessEntity specified in the 'fromKey' is
1829   * managed by publisherID retrieved in step 1. Do this by calling:
1830   * BusinessEntityTable.selectPublisherID(fromKey);
1831   *
1832   * 2. Determine if the BusinessEntity specified in the 'toKey' is
1833   * managed by publisherID retrieved in step 1. Do this by calling:
1834   * BusinessEntityTable.selectPublisherID(toKey);
1835   *
1836   * 3. If at least one of the two BusinessKeys specified in this
1837   * PublisherAssertion is managed by providerID then check to see if
1838   * a row already exists in the PUBLISHER_ASSERTION table by calling:
1839   * PublisherAssertionTable.select(PublisherAssertion assertionIn)
1840   *
1841   * 4. If a row doesn't exist then insert a new one (set the values of the
1842   * to_check and from_check columns appropriately based on info returned
1843   * in steps 3 & 4.) Insert the row by calling:
1844   * PublisherAssertionTable.insert(PublisherAssertion,fromCheck,toCheck)
1845   *
1846   * 5. If a row does exist and publisherID is responsible for the
1847   * BusinessEntity identified by 'fromKey' then update the row by calling:
1848   * PublisherAssertionTable.updateFromCheck(PublisherAssertion,true)
1849   *
1850   * 6. If a row does exist and publisherID is responsible for the
1851   * BusinessEntity identified by 'toKey' then update the row by calling:
1852   * PublisherAssertionTable.updateToCheck(PublisherAssertion,true)
1853   */

1854  public void saveAssertions(String JavaDoc publisherID,Vector JavaDoc assertions)
1855    throws org.apache.juddi.error.RegistryException
1856  {
1857    try
1858    {
1859      // iterate through the PublisherAssertion Vector
1860
for (int i=0; i<assertions.size(); i++)
1861      {
1862        // grab the next PublisherAssertion and it's 'fromKey' & 'toKey' values
1863
PublisherAssertion assertion = (PublisherAssertion)assertions.elementAt(i);
1864        String JavaDoc fromKey = assertion.getFromKey();
1865        String JavaDoc toKey = assertion.getToKey();
1866
1867        // determine if this assertion's 'fromKey' and/or 'toKey' values are
1868
// managed by the PublisherID specified.
1869
boolean fromCheck = BusinessEntityTable.verifyOwnership(fromKey,publisherID,connection);
1870        boolean toCheck = BusinessEntityTable.verifyOwnership(toKey,publisherID,connection);
1871
1872        // if a row in the PUBLISHER_ASSERTION table doesn't yet exist then
1873
// insert one. If a row does already exist then simply update the appropriate
1874
// 'fromKey' and 'toKey' values.
1875
if (PublisherAssertionTable.select(assertion,connection) == null)
1876          PublisherAssertionTable.insert(assertion,fromCheck,toCheck,connection);
1877        else
1878        {
1879          if (fromCheck)
1880            PublisherAssertionTable.updateFromCheck(assertion,fromCheck,connection);
1881          if (toCheck)
1882            PublisherAssertionTable.updateToCheck(assertion,toCheck,connection);
1883        }
1884      }
1885    }
1886    catch(java.sql.SQLException JavaDoc sqlex)
1887    {
1888      throw new RegistryException(sqlex);
1889    }
1890  }
1891
1892  /**
1893   *
1894   * For each PublisherAssertion in the Vector of PublisherAssertions passed
1895   * in perform the following steps:
1896   *
1897   * 1. Determine if the BusinessEntity specified in the 'fromKey' is
1898   * managed by publisherID retrieved in step 1. Do this by calling:
1899   * BusinessEntityTable.selectPublisherID(fromKey);
1900   *
1901   * 2. If the publisherID does manage the BusinessEntity identified by
1902   * the PublisherAssertions 'fromKey' then call the following method:
1903   * PublisherAssertionTable.updateFromCheck(PublisherAssertion,false)
1904   *
1905   * 3. Determine if the BusinessEntity specified in the 'toKey' is
1906   * managed by publisherID retrieved in step 1. Do this by calling:
1907   * BusinessEntityTable.selectPublisherID(toKey);
1908   *
1909   * 4. If the publisherID does manage the BusinessEntity identified by
1910   * the PublisherAssertions 'toKey then call the following method:
1911   * PublisherAssertionTable.updateToCheck(PublisherAssertion,false)
1912   *
1913   * 5. After iterating through the entire Vector of PublisherAssertions
1914   * call the following method: PublisherAssertionTable.deleteDeadAssertions()
1915   */

1916  public void deleteAssertions(String JavaDoc publisherID,Vector JavaDoc assertions)
1917    throws org.apache.juddi.error.RegistryException
1918  {
1919    try
1920    {
1921      // iterate through the PublisherAssertion Vector
1922
for (int i=0; i<assertions.size(); i++)
1923      {
1924        // grab a reference to the next PublisherAssertion
1925
PublisherAssertion assertion = (PublisherAssertion)assertions.elementAt(i);
1926
1927        // if the PublisherID is equal to the PublisherID of the BusinessEntity
1928
// specified by the 'fromKey' then set the FROM_CHECK column to 'false'
1929
String JavaDoc fromID = BusinessEntityTable.selectPublisherID(assertion.getFromKey(),connection);
1930        if (publisherID.equalsIgnoreCase(fromID))
1931          PublisherAssertionTable.updateFromCheck(assertion,false,connection);
1932
1933        // if the PublisherID is equal to the PublisherID of the BusinessEntity
1934
// specified by the 'toKey' then set the TO_CHECK column to 'false'
1935
String JavaDoc toID = BusinessEntityTable.selectPublisherID(assertion.getToKey(),connection);
1936        if (publisherID.equalsIgnoreCase(toID))
1937          PublisherAssertionTable.updateToCheck(assertion,false,connection);
1938      }
1939
1940      // remove any invalidated rows from the PUBLISHER_ASSERTION table. An
1941
// invalidated row is any row with a value of 'false' in both the
1942
// FROM_KEY and TO_KEY columns.
1943
if (assertions.size() > 0)
1944        PublisherAssertionTable.deleteDeadAssertions(connection);
1945    }
1946    catch(java.sql.SQLException JavaDoc sqlex)
1947    {
1948      throw new RegistryException(sqlex);
1949    }
1950  }
1951
1952  /**
1953   *
1954   * 1. Retrieve all BusinessKey's that the publisherID is responsible for
1955   * managing by calling: BusinessEntityTable.selectByPublisherID(publisherID)
1956   *
1957   * 2. Retrieve all PublisherAssertion's that publisherID has made by
1958   * calling: PublisherAssertionTable.selectAssertions(Vector) where
1959   * 'Vector' is the collection of BusinessKey's returned in step 2.
1960   */

1961  public Vector JavaDoc getAssertions(String JavaDoc publisherID)
1962    throws org.apache.juddi.error.RegistryException
1963  {
1964    Vector JavaDoc assertions = null;
1965
1966    try
1967    {
1968      Vector JavaDoc keys = BusinessEntityTable.selectByPublisherID(publisherID,connection);
1969      assertions = PublisherAssertionTable.selectAssertions(keys,connection);
1970    }
1971    catch(java.sql.SQLException JavaDoc sqlex)
1972    {
1973      throw new RegistryException(sqlex);
1974    }
1975
1976    return assertions;
1977  }
1978
1979  /**
1980   *
1981   * 1. Retrieve all PublisherAssertions associated with the publisherID
1982   * passed in by calling DataSource.getAssertions(publisherID)
1983   *
1984   * 2. With the Vector of PublisherAssertions retrieved in step 1 call
1985   * DataSource.deleteAssertions(publisherID,Vector)
1986   *
1987   * 3. With the Vector of PublisherAssertions passed into this method
1988   * call: DataSource.addAssertions(publisherID,Vector)
1989   */

1990  public Vector JavaDoc setAssertions(String JavaDoc publisherID,Vector JavaDoc newAssertions)
1991    throws org.apache.juddi.error.RegistryException
1992  {
1993    // grab all existing PublisherAssertions with this publisherID
1994
Vector JavaDoc oldAssertions = getAssertions(publisherID);
1995
1996    // delete all existing PublisherAsssertions with this publisherID
1997
deleteAssertions(publisherID,oldAssertions);
1998
1999    // save all of the new PublisherAssertions
2000
saveAssertions(publisherID,newAssertions);
2001
2002    return newAssertions;
2003  }
2004
2005  /**
2006   *
2007   * 1. Retrieve Vector of BusinessKeys for BusinessEntities managed by
2008   * publisherID by calling: BusinessEntityTable.selectByPublisherID(publisherID)
2009   *
2010   * 2. Call PublisherAssertionTable.selectBothKeysOwnedAssertions(Vector of BusinessKeys)
2011   *
2012   * 3. Call PublisherAssertionTable.selectFromKeyOwnedAssertions(Vector of BusinessKeys)
2013   *
2014   * 4. Call PublisherAssertionTable.selectToKeyOwnedAssertions(Vector of BusinessKeys)
2015   *
2016   * 5. Combine Vectors from steps 3, 4 and 5 above into one Vector of
2017   * AssertionStatusItem instances
2018   *
2019   * 5. Loop through Vector from step 6 copying only AssertionStatusItem instances
2020   * that have a CompletionStatus that matches the completionStatus requested.
2021   */

2022  public Vector JavaDoc getAssertionStatusItems(String JavaDoc publisherID,String JavaDoc completionStatus)
2023    throws org.apache.juddi.error.RegistryException
2024  {
2025    Vector JavaDoc items = null;
2026
2027    try
2028    {
2029      // grab a Vector of BusinessKeys managed by PublisherID
2030
Vector JavaDoc keys = BusinessEntityTable.selectByPublisherID(publisherID,connection);
2031
2032      // grab any PublisherAssertion (as an AssertionStatusItem) that includes
2033
// any of the BusinessKeys returned above in the TO_KEY or FROM_KEY field.
2034
Vector JavaDoc allItems = new Vector JavaDoc();
2035      allItems.addAll(PublisherAssertionTable.selectBothKeysOwnedAssertion(keys,connection));
2036      allItems.addAll(PublisherAssertionTable.selectFromKeyOwnedAssertion(keys,connection));
2037      allItems.addAll(PublisherAssertionTable.selectToKeyOwnedAssertion(keys,connection));
2038
2039      // if no completionStatua was passed in then simply return all
2040
// AssertionStatusItems. Otherwise only return the ones that have
2041
// the 'completionStatus' specified.
2042
if ((completionStatus == null) || (completionStatus.length() == 0))
2043        items = allItems;
2044      else
2045      {
2046        // create the Vector to return
2047
if (allItems.size() > 0)
2048          items = new Vector JavaDoc();
2049
2050        // evaluate every AssertionStatusItem
2051
for (int i=0; i<allItems.size(); i++)
2052        {
2053          AssertionStatusItem item = (AssertionStatusItem)allItems.elementAt(i);
2054          CompletionStatus status = item.getCompletionStatus();
2055          if (status.getValue().equalsIgnoreCase(completionStatus))
2056            items.addElement(item);
2057        }
2058      }
2059    }
2060    catch(java.sql.SQLException JavaDoc sqlex)
2061    {
2062      throw new RegistryException(sqlex);
2063    }
2064
2065    return items;
2066  }
2067
2068  /**
2069   *
2070   */

2071  public void savePublisher(Publisher publisher)
2072    throws org.apache.juddi.error.RegistryException
2073  {
2074    try
2075    {
2076      if ((publisher != null) && (connection != null))
2077      {
2078        // create the Publisher account
2079
PublisherTable.insert(publisher,connection);
2080      }
2081    }
2082    catch(java.sql.SQLException JavaDoc sqlex)
2083    {
2084      throw new RegistryException(sqlex);
2085    }
2086  }
2087
2088  /**
2089   *
2090   */

2091  public void deletePublisher(String JavaDoc publisherID)
2092    throws org.apache.juddi.error.RegistryException
2093  {
2094    try
2095    {
2096      if ((publisherID != null) && (connection != null))
2097      {
2098        // delete the Publisher account
2099
PublisherTable.delete(publisherID,connection);
2100      }
2101    }
2102    catch(java.sql.SQLException JavaDoc sqlex)
2103    {
2104      throw new RegistryException(sqlex);
2105    }
2106  }
2107
2108  /**
2109   *
2110   */

2111  public PublisherInfo fetchPublisherInfo(String JavaDoc publisherID)
2112    throws org.apache.juddi.error.RegistryException
2113  {
2114    PublisherInfo info = null;
2115
2116    if ((publisherID != null) && (connection != null))
2117    {
2118      try
2119      {
2120        Publisher publisher = PublisherTable.select(publisherID,connection);
2121        info = new PublisherInfo();
2122        info.setPublisherID(publisherID);
2123        info.setNameValue(publisher.getName());
2124      }
2125      catch(java.sql.SQLException JavaDoc sqlex)
2126      {
2127        throw new RegistryException(sqlex);
2128      }
2129    }
2130
2131    return info;
2132  }
2133
2134  /**
2135   *
2136   */

2137  public Vector JavaDoc findPublisher(String JavaDoc name,FindQualifiers findQualifiers)
2138    throws org.apache.juddi.error.RegistryException
2139  {
2140    Vector JavaDoc keyVector = null;
2141
2142    try
2143    {
2144      // always perform this query - even when not searching by Name!!!
2145
keyVector = FindPublisherByNameQuery.select(name,keyVector,findQualifiers,connection);
2146    }
2147    catch(java.sql.SQLException JavaDoc sqlex)
2148    {
2149      throw new RegistryException(sqlex);
2150    }
2151
2152    return keyVector;
2153  }
2154}
2155
2156
Popular Tags