/* * @(#)BookLister.java * * Copyright 2002 Sun Microsystems, Inc. All rights reserved. * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms * */ package com.sun.eportal.bookordering; import com.sun.eportal.*; import java.util.*; import java.io.*; /** * BookLister.java is a class which will query for all endpoints * based on the classification scheme "ntis-gov:naics" for "Book Stores" * * @author Ramesh Mandava * */ public class BookLister { Vector bookVector; public BookLister( ) { bookVector = new Vector(); } public Vector getBookVector( ) { return bookVector; } /* * This method will call the ClientQuery to find businesses classified * by as Book stores. It gets all the information about the service * providers * If the commumnication type is of type JAXM then it adds it to * the jaxmEndpointVector and then the BookClient send the query message * to those endpoints */ public Vector populateAvailableBooks ( String queryType, String queryValue ) { bookVector = new Vector(); try { String cScheme="ntis-gov:naics"; String keyName="Book Stores"; String keyValue="451211"; String serviceName="Online Book Ordering"; System.out.println("Now trying to run query"); ClientQuery clientQuery = new ClientQuery( ); Vector serviceProviderInfoVector = clientQuery.query( cScheme, keyName, keyValue); System.err.println("ServiceProviderInfoVector Size -> " + serviceProviderInfoVector.size() ); Vector jaxmEndpointVector= new Vector(); for ( int i=0; i< serviceProviderInfoVector.size(); i++ ) { ServiceProviderInfo spi = (ServiceProviderInfo) serviceProviderInfoVector.elementAt(i); /* * Collect all JAXM related endpoints and * communicate with them using BookClient */ if ( spi.getCommunicationType().equals("JAXM") ) { jaxmEndpointVector.addElement( spi.getEndpoint() ); } } if ( serviceProviderInfoVector.size() == 0 ) { //Potential Registry/JAXR bug System.out.println("Potential Registry/JAXR bug?"+ " Using default endpoints"); jaxmEndpointVector.addElement( "http://localhost:8080/ancbooks/bookordering"); jaxmEndpointVector.addElement( "http://localhost:8080/funbooks/bookordering"); } BookClient bookClient = new BookClient(); bookClient.constructMessage ( queryType, queryValue ); System.out.println("JAXMEndopint vector"+ jaxmEndpointVector.size()); bookVector = bookClient.getAllAvailableBooks ( jaxmEndpointVector ); } catch ( Exception e ) { System.err.println("Exception : In populateAvailableBooks" ); e.printStackTrace(); } return bookVector; } }