View Javadoc
1 /* 2 * $Header: /cvsroot/ebxmlrr/jaxr/src/com/sun/xml/registry/ebxml/DeclarativeQueryManagerImpl.java,v 1.21 2002/10/08 22:56:57 edwingo Exp $ 3 * 4 * 5 */ 6 7 package com.sun.xml.registry.ebxml; 8 9 import javax.xml.registry.*; 10 11 import java.util.*; 12 import java.io.*; 13 14 import org.oasis.ebxml.registry.bindings.query.AdhocQueryRequestChoice; 15 import org.oasis.ebxml.registry.bindings.query.AdhocQueryRequest; 16 import org.oasis.ebxml.registry.bindings.query.ResponseOption; 17 import org.oasis.ebxml.registry.bindings.query.types.ReturnTypeType; 18 19 import org.apache.commons.logging.Log; 20 21 /*** 22 * Class Declaration for Class1 23 * 24 */ 25 public class DeclarativeQueryManagerImpl extends QueryManagerImpl 26 implements DeclarativeQueryManager 27 { 28 private Log log; 29 30 DeclarativeQueryManagerImpl(RegistryServiceImpl regService, 31 BusinessLifeCycleManagerImpl lcm) throws JAXRException 32 { 33 super(regService, lcm, null); 34 log = regService.getConnection().getConnectionFactory().getLog(); 35 } 36 37 /*** 38 * Creates a Query object given a queryType (e.g. SQL) and a String 39 * that represents a query in the syntax appropriate for queryType. 40 * Must throw and InvalidRequestException if the sqlQuery is not valid. 41 * 42 * 43 * <p><DL><DT><B>Capability Level: 0 (optional) </B></DL> 44 * 45 * @see Query#QUERY_TYPE_SQL 46 * @see Query#QUERY_TYPE_XQUERY 47 */ 48 public Query createQuery(int queryType, String queryString) 49 throws InvalidRequestException, JAXRException 50 { 51 if (queryType != Query.QUERY_TYPE_SQL) { 52 throw new InvalidRequestException( 53 "Type must be Query.QUERY_TYPE_SQL"); 54 } 55 // Todo: check queryString syntax 56 return new QueryImpl(queryType, queryString); 57 } 58 59 /*** 60 * Execute a query as specified by query paramater. 61 * 62 * <p><DL><DT><B>Capability Level: 0 (optional) </B></DL> 63 * 64 */ 65 public BulkResponse executeQuery(Query query) throws JAXRException 66 { 67 // Place SQL string into a Castor content tree and marshal it out to 68 // a String representation of the request. Call SoapMessenger to 69 // send the request to the server. 70 String sqlString = query.toString(); 71 72 AdhocQueryRequestChoice aqrc = new AdhocQueryRequestChoice(); 73 aqrc.setSQLQuery(sqlString); 74 log.debug("sqlString=\"" + sqlString + "\""); 75 76 AdhocQueryRequest aqr = new AdhocQueryRequest(); 77 aqr.setAdhocQueryRequestChoice(aqrc); 78 79 ResponseOption ro = new ResponseOption(); 80 ro.setReturnComposedObjects(true); 81 ro.setReturnType(ReturnTypeType.LEAFCLASSWITHREPOSITORYITEM); 82 aqr.setResponseOption(ro); 83 84 StringWriter sw = new StringWriter(); 85 try { 86 aqr.marshal(sw); 87 } catch (org.exolab.castor.xml.MarshalException x) { 88 throw new JAXRException(x); 89 } catch (org.exolab.castor.xml.ValidationException x) { 90 throw new JAXRException(x); 91 } 92 return regService.getSoapMessenger().sendSoapRequest(sw.toString()); 93 } 94 }

This page was automatically generated by Maven