// lookup the appropriate xml handler, throw
// an UnsupportedException if one could not be
// located.
IHandler requestHandler = maker.lookup(function);
if (requestHandler == null)
throw new UnsupportedException("The request " +
"type is unknown: " +function);
// unmarshal the raw xml into an associated
// jUDDI request object.
RegistryObject uddiRequest = requestHandler.unmarshal(request);
// make the monitor inspect the UDDI request
// object
if (monitor != null)
monitor.inspectRegistryObject(uddiRequest);
// Determine if this message came from through
// the Publish, Inquiry or Admin API and handle
// it appropriately.
Object juddiServlet = messageContext.getProperty("transport.http.servlet");
// confirm that the the appropriate endpoint
// was used to invoke the selected jUDDI/UDDI
// function.
if((juddiServlet instanceof InquiryServlet) &&
(!(uddiRequest instanceof org.apache.juddi.datatype.request.Inquiry)))
{
throw new RegistryException("Inquiry API " +
"does not support function: "+function);
}
else if (juddiServlet instanceof PublishServlet &&
(!(uddiRequest instanceof org.apache.juddi.datatype.request.Publish) &&
!(uddiRequest instanceof org.apache.juddi.datatype.request.SecurityPolicy)))
{
throw new RegistryException("Publish API " +
"does not support function: "+function);
}
else if ((juddiServlet instanceof AdminServlet) && // Admin
(!(uddiRequest instanceof org.apache.juddi.datatype.request.Admin)))
{
throw new RegistryException("Admin API " +
"does not support function: "+function);
}
// grab a reference to the shared jUDDI registry
// instance (make sure it's running) and execute
// the requested UDDI function.
RegistryObject uddiResponse = null;
RegistryEngine registry = RegistryServlet.getRegistry();
if ((registry != null) && (registry.isAvailable()))
uddiResponse = registry.execute(uddiRequest);
else
throw new BusyException("The Registry is unavailable");
// create a new 'temp' XML element. This
// element is used as a container in which
// to marshal the UDDI response into.
Document document = XMLUtils.createDocument();
Element element = document.createElement("temp");
// lookup the appropriate response handler
// and marshal the juddi object into the
// appropriate xml format (we only support
// uddi v2.0 at this time) attaching results
// to the temporary 'temp' element.
IHandler responseHandler = maker.lookup(uddiResponse.getClass().getName());
responseHandler.marshal(uddiResponse,element);
// grab a reference to the 'temp' element's
// only child here (this has the effect of
// discarding the temp element) and appending
// this child to the soap response body.