1 23 24 29 30 package com.sun.enterprise.admin.wsmgmt.registry; 31 32 import java.lang.reflect.Method ; 33 import java.net.InetAddress ; 34 import java.util.Arrays ; 35 import java.util.Enumeration ; 36 import java.util.HashMap ; 37 import java.util.Map ; 38 import java.util.Collection ; 39 import java.util.Iterator ; 40 import javax.naming.InitialContext ; 41 import javax.naming.NamingException ; 42 import java.util.List ; 43 import java.util.ArrayList ; 44 import java.io.FileInputStream ; 45 import java.io.FileReader ; 46 import java.io.BufferedReader ; 47 import javax.xml.registry.ConnectionFactory ; 48 import com.sun.appserv.management.ext.wsmgmt.WebServiceEndpointInfo; 49 import com.sun.enterprise.admin.wsmgmt.WebServiceMgrBackEnd; 50 import com.sun.enterprise.config.ConfigException; 51 import com.sun.logging.LogDomains; 52 import java.util.logging.Logger ; 53 import java.util.logging.Level ; 54 import javax.xml.registry.*; 55 import javax.xml.registry.infomodel.*; 56 import com.sun.appserv.management.ext.wsmgmt.WebServiceEndpointInfo; 57 58 69 public class RegistryAccessObjectImpl implements RegistryAccessObject{ 70 71 private static final Logger _logger = 72 Logger.getLogger(LogDomains.ADMIN_LOGGER); 73 74 private WebServiceMgrBackEnd mgrBE= null; 75 private Map webServiceInfoMap = null; 76 77 private static final String DEFAULT_ORGANIZATION = 78 "Sun Microsystems"; 79 private static final String DEFAULT_DESCRIPTION = 80 "Default Description for Sun Java Application Server Web Service"; 81 82 private boolean isUDDI = false; 83 private boolean isEbxml = false; 84 private static int MINUS_ONE = -1; 85 86 private static String JAXR_CONNECTION_FACTORY = 87 "com.sun.connector.jaxr.JaxrConnectionFactory"; 88 private static String EBXML_CONNECTION_FACTORY = 89 "com.sun.jaxr.ra.ebxml.JaxrConnectionFactory"; 90 95 private String MOCK_REGISTRY = "com.sun.appserv.admin.wsmgmt.registry.mock"; 96 private boolean mockRegistry = false; 97 98 99 public RegistryAccessObjectImpl() { 100 mgrBE = WebServiceMgrBackEnd.getManager(); 101 } 102 103 127 public boolean publish(String [] registryLocations, String webServiceName, 128 String lbhost, int lbport, int lbsslport, String [] categories, 129 String organization, String description) { 130 131 webServiceInfoMap = getWebServiceInfoMap(webServiceName); 132 if(!isWebServiceNameValid(webServiceName)){ 133 _logger.log(Level.SEVERE, 134 "registry.invalid_webservice_name_publish_failure", 135 webServiceName); 136 return false; 137 } 138 ConfigHelper ch = 139 ConfigHelper.getInstanceToUpdateConfig(webServiceInfoMap); 140 141 String [] duplicate = ch.checkForDuplicateRegistries(registryLocations); 142 if (duplicate != null) { 143 StringBuffer message = new StringBuffer ( 146 "Trying to publish Web Service with jndi entries pointing " + 147 "to the same " + 148 "registry. Remove jndi names that point to the same" + 149 " connector pool and retry. The" + 150 " duplicate entries are : "); 151 for (int i=0;i<duplicate.length; i++){ 152 message.append(duplicate[i] ); 153 if (i == (duplicate.length-1)) 154 message.append("."); 155 else 156 message.append(","); 157 } 158 throw new RuntimeException (message.toString()); 159 } 160 161 String [] alreadyPublishedRegistries = 162 ch.listAlreadyPublishedRegistryLocations(webServiceName, 163 registryLocations); 164 List <String > publishTo = new ArrayList <String > 165 (Arrays.asList(registryLocations)); 166 if (alreadyPublishedRegistries != null) 167 publishTo.removeAll( 168 new ArrayList <String > (Arrays.asList(alreadyPublishedRegistries))); 169 170 if(publishTo.size() == 0) { 171 String message = "Web Service " + webServiceName + 172 " already published to the registries! Unpublish and " + 173 "republish."; 174 _logger.log(Level.WARNING, message); 175 throw new RuntimeException (message); 176 } 177 String wsdlFile = getWSDL(webServiceName); 178 if(wsdlFile == null){ 179 _logger.log(Level.SEVERE, 180 "registry.wsdl_absent_publish_failure", 181 webServiceName); 182 return false; 183 } 184 185 Map <String , String > publishedTo = new HashMap <String , String >(); 186 for(String registryLocation : publishTo){ 187 try{ 188 boolean isPublished = false; 189 mockRegistry = Boolean.getBoolean(MOCK_REGISTRY); 190 if (!mockRegistry){ ConnectionFactory cf = lookupConnection(registryLocation); 193 if(cf != null){ 194 isPublished = 195 publishWSDL(wsdlFile, cf, lbhost, lbport, lbsslport, 196 categories, organization, description, 197 webServiceName); 198 } else{ 199 _logger.log(Level.WARNING, 200 "registry.registry_location_absent_publish_failure", 201 registryLocation); 202 } 203 } else { 204 isPublished = true; 205 } 206 if(isPublished) 207 publishedTo.put(registryLocation, organization); 208 209 } catch(NamingException ne){ 210 _logger.log(Level.SEVERE, 211 "registry.registry_location_absent_publish_failure", 212 registryLocation); 213 214 _logger.log(Level.SEVERE, 215 "registry.registry_location_naming_exception_publish_failure", 216 ne); 217 } 218 } 219 if(publishedTo.size() <= 0){ 220 _logger.log(Level.WARNING, 222 "registry.not_published", webServiceName); 223 return false; 224 } 225 ch.addToConfig(webServiceName, publishedTo); 226 return true; 227 } 228 229 235 public boolean unpublishFromRegistry(String [] registryLocations, 236 String webServiceName) { 237 238 webServiceInfoMap = getWebServiceInfoMap(webServiceName); 239 if(!isWebServiceNameValid(webServiceName)){ 240 _logger.log(Level.SEVERE, 241 "registry.invalid_webservice_name_unpublish_failure", 242 webServiceName); 243 return false; 244 } 245 List <String > unpublishedFrom = new ArrayList <String >(); 246 for(int i=0; i<registryLocations.length;i++){ 247 try{ 248 boolean unpublished = false; 249 mockRegistry = Boolean.getBoolean(MOCK_REGISTRY); 250 if (!mockRegistry){ ConnectionFactory cf = lookupConnection(registryLocations[i]); 252 unpublished = unpublishFromRegistry(cf, webServiceName, 253 registryLocations[i]); 254 }else { 255 unpublished = true; 256 } 257 if(unpublished) 258 unpublishedFrom.add(registryLocations[i]); 259 } catch(NamingException ne){ 260 _logger.log(Level.SEVERE, 261 "registry.registry_location_absent_unpublish_failure", 262 registryLocations[i]); 263 264 _logger.log(Level.SEVERE, 265 "registry.registry_location_naming_exception_unpublish_failure", 266 ne); 267 } 268 } 269 if(unpublishedFrom.size() <=0){ 270 _logger.log(Level.WARNING, 271 "registry.not_unpublished", webServiceName); 272 return false; 273 } 274 ConfigHelper ch = 275 ConfigHelper.getInstanceToUpdateConfig(webServiceInfoMap); 276 String [] unpublished = new String [unpublishedFrom.size()]; 277 unpublished = unpublishedFrom.toArray(unpublished); 278 ch.deleteFromConfig(webServiceName, unpublished); 279 return true; 280 } 281 282 288 public String [] listRegistryLocations(){ 289 ConfigHelper ch = ConfigHelper.getInstanceToQueryRegistryLocations(); 290 String [] list = null; 291 list = ch.listRegistryLocations(); 292 return list; 293 } 294 295 297 private boolean publishWSDL(String wsdlFile, ConnectionFactory cf, 299 String lbhost, int lbport, int lbsslport, 300 String [] categories, String organization, String description, 301 String webServiceName){ 302 303 boolean value = false; 304 try{ 305 306 String aURI = 307 (String )webServiceInfoMap.get(WebServiceEndpointInfo.END_POINT_URI_KEY); 308 StringBuffer sbuf = null; 309 StringBuffer secureSbuf = null; 310 if(lbport != -1){ 311 sbuf = new StringBuffer (); 312 sbuf.append("http://"+lbhost+":"+lbport); 313 if (!aURI.startsWith("/")) 314 sbuf.append("/"); 315 sbuf.append(aURI+"?wsdl"); 316 _logger.log(Level.INFO, "registry.access_url", 317 new Object [] {webServiceName, sbuf.toString()}); 318 319 } 320 if (lbsslport != -1){ 321 secureSbuf = new StringBuffer (); 322 secureSbuf.append("https://"+lbhost+":"+lbsslport); 323 if (!aURI.startsWith("/")) 324 secureSbuf.append("/"); 325 secureSbuf.append(aURI+"?wsdl"); 326 _logger.log(Level.INFO, "registry.access_url", 327 new Object [] {webServiceName, secureSbuf.toString()}); 328 } 329 String [] accessURI; 330 if ((lbport != MINUS_ONE ) && (lbsslport != MINUS_ONE)){ 331 accessURI = new String [2]; 332 accessURI[0] = sbuf.toString(); 333 accessURI[1] = secureSbuf.toString(); 334 } else { 335 accessURI = new String [1]; 336 accessURI[0] = (sbuf!=null)?sbuf.toString():secureSbuf.toString(); 337 } 338 339 Connection con = getConnection(cf); 340 RegistryService rs = con.getRegistryService(); 341 BusinessLifeCycleManager blcm = rs.getBusinessLifeCycleManager(); 342 BusinessQueryManager bqm = rs.getBusinessQueryManager(); 343 344 if (organization == null) 347 organization = DEFAULT_ORGANIZATION; 348 349 Organization org = blcm.createOrganization(organization); 350 if(description == null) 351 description = DEFAULT_DESCRIPTION; 352 353 org.setName(blcm.createInternationalString(organization)); 354 org.setDescription(blcm.createInternationalString(description)); 355 356 org = createClassificationSchemeAndClassification(blcm, bqm, org, 357 webServiceName); 358 org = createServiceAndServiceBindingsAndExternalLink(blcm, org, 359 description, accessURI, webServiceName); 360 361 org = categorizeCategoriesViaSlots(blcm, org, webServiceName, 362 categories); 363 value = publishOrg(blcm, org); 365 } catch (JAXRException je){ 366 _logger.log(Level.SEVERE, "registry.publish_failure_exception", je); 367 throw new RuntimeException (je); 368 } 369 return value; 370 } 371 372 private boolean publishOrg(BusinessLifeCycleManager blcm, 373 Organization org) throws JAXRException { 374 boolean value = false; 375 List <Organization> orgs = new ArrayList <Organization> (); 376 orgs.add(org); 377 BulkResponse response = blcm.saveOrganizations(orgs); 378 if (response.getStatus() == BulkResponse.STATUS_SUCCESS) { 379 _logger.log(Level.INFO, "registry.successful_publish", 380 org.getName().getValue()); 381 value = true; 382 } else{ 383 _logger.log(Level.SEVERE, "registry.organization_not_published", 384 org.getName().getValue()); 385 386 Collection exceptions = response.getExceptions(); 387 displayExceptions(exceptions, Level.SEVERE); 388 value = false; 389 } 390 return value; 391 } 392 401 402 private Organization createClassificationSchemeAndClassification( 403 BusinessLifeCycleManager blcm, BusinessQueryManager bqm, 404 Organization org, 405 String webServiceName) 406 throws JAXRException { 407 try{ 408 ClassificationScheme classScheme = null; 409 Collection findQualifiers = createFindQualifiers(); 410 411 classScheme = bqm.findClassificationSchemeByName(findQualifiers, 412 webServiceName); 413 414 if (classScheme == null){ 415 classScheme = blcm.createClassificationScheme(webServiceName, 416 webServiceName); 417 List <ClassificationScheme> classificationSchemeList = 418 new ArrayList <ClassificationScheme> (); 419 classificationSchemeList.add(classScheme); 420 if (this.isUDDI) blcm.saveClassificationSchemes(classificationSchemeList); 423 } 424 426 if (this.isUDDI) 428 classScheme = bqm.findClassificationSchemeByName(findQualifiers, 429 webServiceName); 430 431 if (classScheme == null){ 432 _logger.log(Level.SEVERE, 433 "registr.cannot_find_classification_scheme", 434 webServiceName); 435 return org; 436 } 437 Collection <Classification> classificationExists 438 = classScheme.getClassifications(); 439 Classification wsdlSpecClassification = null; 440 if (!classificationExists.isEmpty()){ 441 for (Classification classification : classificationExists){ 442 if (classification.getName().getValue().equals(webServiceName)){ 443 wsdlSpecClassification = classification; 444 break; 445 } 446 } 447 } 448 if(wsdlSpecClassification == null){ 449 if (this.isUDDI){ 450 wsdlSpecClassification = 451 blcm.createClassification(classScheme, "wsdlSpec", 452 "wsdlSpec"); 453 wsdlSpecClassification.setValue(webServiceName); 454 455 } else { 456 wsdlSpecClassification = 457 blcm.createClassification(classScheme, webServiceName, 458 webServiceName); 459 wsdlSpecClassification.setValue(webServiceName); 460 wsdlSpecClassification.setClassificationScheme(classScheme); 461 wsdlSpecClassification.setName 462 (blcm.createInternationalString(webServiceName)); 463 } 464 classScheme.addClassification(wsdlSpecClassification); 465 List <ClassificationScheme> classificationSchemeList = 468 new ArrayList <ClassificationScheme> (); 469 classificationSchemeList.add(classScheme); 470 if (this.isUDDI) 471 blcm.saveClassificationSchemes(classificationSchemeList); 472 } 473 org.addClassification(wsdlSpecClassification); 474 }catch (JAXRException je){ 475 _logger.log(Level.SEVERE, "registry.classification_creation_failed"); 476 throw je; 477 } 478 return org; 479 } 480 481 482 492 493 private Organization categorizeCategoriesViaSlots( 494 BusinessLifeCycleManager blcm, Organization org, 495 String webServiceName, String [] categories) 496 throws JAXRException{ 497 try{ 498 if (categories == null || categories.length <=0 ) 500 return org; 501 for (int i = 0; i< categories.length; i++){ 502 List <String > slotValues = new ArrayList <String > (); 503 slotValues.add(webServiceName); 504 Slot slot = blcm.createSlot(categories[i], slotValues, null); 505 org.addSlot(slot); 506 } 507 }catch (JAXRException je){ 508 _logger.log(Level.SEVERE, "registry.slot_creation_failed"); 509 throw je; 510 } 511 return org; 512 } 513 514 515 516 525 private ServiceBinding createServiceBinding( 526 BusinessLifeCycleManager blcm, String description, String accessURI, 527 String name) 528 throws JAXRException{ 529 ServiceBinding binding = null; 530 try{ 531 binding = blcm.createServiceBinding(); 532 binding.setDescription(blcm.createInternationalString(description)); 533 binding.setValidateURI(false); 534 binding.setAccessURI(accessURI); 535 binding.setName(blcm.createInternationalString(name+accessURI)); 536 }catch (JAXRException je){ 537 _logger.log(Level.SEVERE, "registry.service_binding_creation_failed"); 538 throw je; 539 } 540 return binding; 541 } 542 543 553 private Organization createServiceAndServiceBindingsAndExternalLink( 554 BusinessLifeCycleManager blcm, Organization org, 555 String description, String [] accessURI, String webServiceName) 556 throws JAXRException{ 557 try{ 558 String serviceName = org.getName().toString() + ":" + 559 webServiceName; 560 Service service = blcm.createService(serviceName); 564 service.setDescription(blcm.createInternationalString(description)); 565 for (String uri: accessURI){ 566 ServiceBinding binding = createServiceBinding(blcm, description, 567 uri, webServiceName ); 568 service.addServiceBinding(binding); 569 ExternalLink wsdlLink = 570 blcm.createExternalLink( uri, description); 571 wsdlLink.setValidateURI(false); 572 wsdlLink.setName(blcm.createInternationalString(serviceName)); 573 if (this.isUDDI == false) 576 service.addExternalLink(wsdlLink); 577 org.addExternalLink(wsdlLink); 578 } 579 org.addService(service); 580 } catch (JAXRException je){ 581 _logger.log(Level.SEVERE, "registry.service_creation_failed"); 582 throw je; 583 } 584 return org; 585 } 586 587 589 private boolean unpublishFromRegistry(ConnectionFactory cf, 591 String webServiceName, String registryLocation){ 592 593 boolean retvalue = false; 594 try{ 595 Connection con = getConnection(cf); 596 RegistryService rs = con.getRegistryService(); 597 BusinessLifeCycleManager blcm = rs.getBusinessLifeCycleManager(); 598 BusinessQueryManager bqm = rs.getBusinessQueryManager(); 599 Collection findQualifiers = createFindQualifiers(); 601 ClassificationScheme classificationScheme = 602 bqm.findClassificationSchemeByName(findQualifiers, 603 webServiceName); 604 605 if (classificationScheme == null){ 606 _logger.log(Level.SEVERE, 607 "registry.cannot_find_classification_scheme", 608 webServiceName); 609 retvalue = false; 610 } 611 Classification classification = null; 612 if (this.isUDDI){ 613 classification = 614 blcm.createClassification(classificationScheme, "wsdlSpec", 615 "wsdlSpec"); 616 classification.setValue(webServiceName); 617 618 } else { 619 classification = 620 blcm.createClassification(classificationScheme, 621 webServiceName, webServiceName); 622 classification.setValue(webServiceName); 623 } 624 classification.setName(blcm.createInternationalString(webServiceName)); 625 Collection <Classification> classList = null; 626 if (classificationScheme != null){ 627 classificationScheme.addClassification(classification); 628 classList = classificationScheme.getClassifications(); 629 } else { 630 classList = new ArrayList <Classification> (); 631 classList.add(classification); 632 } 633 webServiceInfoMap = getWebServiceInfoMap(webServiceName); 634 if(!isWebServiceNameValid(webServiceName)){ 635 _logger.log(Level.SEVERE, 636 "registry.invalid_webservice_name_unpublish_failure", 637 webServiceName); 638 return false; 639 } 640 ConfigHelper ch = 641 ConfigHelper.getInstanceToUpdateConfig(webServiceInfoMap); 642 String org = ch.getOrganizationName(webServiceName, 643 registryLocation); 644 if (org == null){ 645 _logger.log(Level.SEVERE, "Cannot find Organization Name for " + 646 "web service in the appserver"); 647 return false; 648 } 649 Collection orgs = new ArrayList <String >(); 650 orgs.add(org); 651 BulkResponse br = bqm.findOrganizations(findQualifiers, 652 (Collection ) orgs, 653 (Collection ) null, 654 (Collection ) null, 655 (Collection )null, (Collection )null); 656 657 boolean deletedOrg = true; 658 if (br.getStatus() == BulkResponse.STATUS_SUCCESS){ 659 Collection <Organization> orgCollection = br.getCollection(); 660 for (Organization organization : orgCollection){ 661 String orgName = organization.getName().getValue(); 662 if (orgName == null) 663 continue; 664 if(!orgName.equals(org)) 665 continue; 666 _logger.log(Level.INFO, "registry.about_to_unpublish", 667 new Object [] {webServiceName , orgName}); 668 669 deleteServicesAndServiceBindingsAndExternalLinks(organization, 670 webServiceName, blcm); 671 672 organization.removeClassifications( 673 organization.getClassifications()); 674 deleteOrg(blcm, organization, webServiceName); 676 break; 677 } 678 deleteClassificationScheme(blcm, classificationScheme, 679 webServiceName); 680 retvalue = true; 681 } 682 } catch(JAXRException je){ 683 _logger.log(Level.SEVERE, "registry.unpublish_failed", je); 684 retvalue = false; 685 } 686 return retvalue; 687 } 688 689 690 695 private void deleteServicesAndServiceBindingsAndExternalLinks( 696 Organization organization, 697 String webServiceName, BusinessLifeCycleManager blcm) 698 throws JAXRException { 699 Collection <Service> servicesCollection = organization.getServices(); 700 Collection <Key> servicesKey = new ArrayList <Key>(); 702 for (Service service : servicesCollection){ 703 Collection <ServiceBinding> binding = service.getServiceBindings(); 704 Collection <Key> bindingsKey = new ArrayList <Key>(); 706 for (ServiceBinding sb : binding){ 707 String bindingString = sb.getName().toString(); 708 bindingsKey.add(sb.getKey()); 709 } 710 service.removeServiceBindings(binding); 713 BulkResponse bulkResponse = blcm.deleteServiceBindings(bindingsKey); 715 Collection exceptions = bulkResponse.getExceptions(); 716 if ( exceptions != null){ 717 _logger.log(Level.WARNING, 718 "registry.delete_servicebindings_failed", 719 new Object []{webServiceName}); 720 displayExceptions(exceptions, Level.SEVERE); 721 } 722 if (this.isUDDI == false) 726 service.removeExternalLinks(service.getExternalLinks()); 727 servicesKey.add(service.getKey()); 728 } 729 730 deleteExternalLinks(organization, webServiceName, blcm); 732 733 organization.removeServices(servicesCollection); 735 BulkResponse bulkResponse = blcm.deleteServices(servicesKey); 737 Collection exceptions = bulkResponse.getExceptions(); 738 if ( exceptions != null){ 739 _logger.log(Level.SEVERE, "registry.delete_services_failed", 740 new Object []{webServiceName}); 741 displayExceptions(exceptions, Level.SEVERE); 742 } 743 744 } 745 746 private void deleteExternalLinks(Organization organization, 747 String webServiceName, BusinessLifeCycleManager blcm) { 748 try{ 749 Collection <ExternalLink> exlink = organization.getExternalLinks(); 750 Collection <Key> key = new ArrayList <Key>(); 752 for (ExternalLink link : exlink){ 753 key.add(link.getKey()); 754 } 755 organization.removeExternalLinks(exlink); 756 BulkResponse bulkResponse = blcm.deleteObjects(key); 757 Collection exceptions = bulkResponse.getExceptions(); 758 if ( exceptions != null){ 759 _logger.log(Level.SEVERE, "registry.delete_externallink_failed", 760 new Object []{webServiceName}); 761 displayExceptions(exceptions, Level.SEVERE); 762 } 763 } catch (JAXRException je){ 764 _logger.log(Level.INFO, "Could not lookup ExternalLinks (URI) for" + 766 " webservice " + webServiceName + ". Nothing to delete!"); 767 } 768 } 769 private boolean deleteClassificationScheme(BusinessLifeCycleManager blcm, 770 ClassificationScheme scheme, 771 String webServiceName) throws JAXRException { 772 773 Key key = scheme.getKey(); 774 Collection <Key> keysToDelete = new ArrayList <Key>(); 775 keysToDelete.add(key); 776 777 BulkResponse bulkResponse = blcm.deleteClassificationSchemes(keysToDelete); 778 Collection exceptions = bulkResponse.getExceptions(); 779 if ( exceptions != null){ 780 _logger.log(Level.SEVERE, 781 "registry.classification_scheme_delete_unsuccessful", 782 scheme.getName().getValue()); 783 displayExceptions(exceptions, Level.SEVERE); 784 return false; 785 } else { 786 _logger.log(Level.INFO, 787 "registry.classification_scheme_delete_successful", 788 new Object []{scheme.getName().getValue(), webServiceName}); 789 return true; 790 } 791 } 792 793 private boolean deleteOrg(BusinessLifeCycleManager blcm, Organization org, 794 String webServiceName) throws JAXRException { 795 Key orgKey = org.getKey(); 796 Collection services = org.getServices(); 797 if (!services.isEmpty()){ 798 _logger.log(Level.SEVERE, "registry.cleanup_services_first", 799 org.getName().getValue()); 800 return false; 801 } 802 Collection keysToDelete = new ArrayList (); 803 keysToDelete.add(orgKey); 804 BulkResponse bulkResponse = blcm.deleteOrganizations(keysToDelete); 805 Collection exceptions = bulkResponse.getExceptions(); 806 if ( exceptions != null){ 807 _logger.log(Level.SEVERE, "registry.delete_org_failed", 808 org.getName().getValue()); 809 displayExceptions(exceptions, Level.SEVERE); 810 return false; 811 } else { 812 _logger.log(Level.INFO, "registry.delete_org_succeeded", 813 new Object [] {org.getName().getValue(), webServiceName}); 814 return true; 815 } 816 } 817 818 private boolean deleteOrg(BusinessLifeCycleManager blcm, 819 String key, String webServiceName) throws JAXRException{ 820 Key orgKey = blcm.createKey(key); 821 Collection keysToDelete = new ArrayList (); 822 keysToDelete.add(orgKey); 823 BulkResponse bulkResponse = blcm.deleteOrganizations(keysToDelete); 824 Collection exceptions = bulkResponse.getExceptions(); 825 if ( exceptions != null){ 826 _logger.log(Level.SEVERE, "registry.delete_org_failed", 827 key); 828 displayExceptions(exceptions, Level.SEVERE); 829 return false; 830 } else { 831 _logger.log(Level.INFO, "registry.delete_org_succeeded", 832 new Object [] {key, webServiceName}); 833 return true; 834 } 835 } 836 837 839 private Connection getConnection(ConnectionFactory cf) 841 throws JAXRException { 842 Connection con = null; 843 try{ 844 Method method = cf.getClass().getMethod("getConnection", (java.lang.Class [])null); 845 con = (Connection)method.invoke(cf, (Object [])null); 846 if (JAXR_CONNECTION_FACTORY.equals(cf.getClass().getName())){ 847 isUDDI = true; 848 } else if (EBXML_CONNECTION_FACTORY.equals(cf.getClass().getName())){ 849 isEbxml = true; 850 } 851 if (con == null){ 852 con = cf.createConnection(); 853 } 854 }catch (java.lang.NoSuchMethodException nsme) { 855 con = cf.createConnection(); 856 } catch (java.lang.IllegalAccessException iae){ 857 con = cf.createConnection(); 858 } catch (java.lang.reflect.InvocationTargetException ite){ 859 con = cf.createConnection(); 860 } 861 return con; 862 } 863 870 private String getWSDL(String webServiceName){ 871 872 String wsdlFile = 873 (String )webServiceInfoMap.get(WebServiceEndpointInfo.WSDL_FILE_KEY); 874 return wsdlFile; 875 } 876 877 882 private boolean isWebServiceNameValid(String webServiceName){ 883 if(webServiceName == null) return false; 885 886 boolean retValue = (webServiceInfoMap == null)?false:true; 887 return retValue; 888 } 889 890 895 private Map getWebServiceInfoMap(String webServiceName){ 896 webServiceInfoMap = 897 (webServiceName == null)? null: 898 mgrBE.getWebServiceInfoMap(webServiceName); 899 return webServiceInfoMap; 900 } 901 902 905 private ConnectionFactory lookupConnection(String registryLocation) 906 throws NamingException { 907 908 InitialContext ic = new InitialContext (); 909 ConnectionFactory cf = (javax.xml.registry.ConnectionFactory ) 910 ic.lookup(registryLocation); 911 _logger.fine("RegistryAccessObject.lookupConnection : " + 912 "for registryLocation " +registryLocation); 913 return cf; 914 } 915 916 private Collection createFindQualifiers() { 917 List <String > findQualifiers = new ArrayList <String >(); 918 findQualifiers.add(FindQualifier.SORT_BY_NAME_DESC); 919 return findQualifiers; 921 } 922 923 private void displayExceptions(Collection exceptions, Level level) { 924 Iterator it = exceptions.iterator(); 925 while (it.hasNext()){ 926 Exception e = (Exception ) it.next(); 927 _logger.log(level, " JAXR Exception ", e); 928 } 929 } 930 } 933 | Popular Tags |