http://git-wip-us.apache.org/repos/asf/juddi/blob/06b2a02d/jacoco/juddi-client/jacoco-ut/org.apache.juddi.v3.client.config/UDDIClerk.java.html ---------------------------------------------------------------------- diff --git a/jacoco/juddi-client/jacoco-ut/org.apache.juddi.v3.client.config/UDDIClerk.java.html b/jacoco/juddi-client/jacoco-ut/org.apache.juddi.v3.client.config/UDDIClerk.java.html new file mode 100644 index 0000000..866be34 --- /dev/null +++ b/jacoco/juddi-client/jacoco-ut/org.apache.juddi.v3.client.config/UDDIClerk.java.html @@ -0,0 +1,1866 @@ +<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml" lang="en"><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/><link rel="stylesheet" href="../jacoco-resources/report.css" type="text/css"/><link rel="shortcut icon" href="../jacoco-resources/report.gif" type="image/gif"/><title>UDDIClerk.java</title><link rel="stylesheet" href="../jacoco-resources/prettify.css" type="text/css"/><script type="text/javascript" src="../jacoco-resources/prettify.js"></script></head><body onload="window['PR_TAB_WIDTH']=4;prettyPrint()"><div class="breadcrumb" id="breadcrumb"><span class="info"><a href="../jacoco-sessions.html" class="el_session">Sessions</a></span><a href="../index.html" class="el_report">jUDDI Client side Code</a> > <a href="index.source.html" class="el_package">org.apache.juddi.v3.client.config</a> > <span class="el_sourc e">UDDIClerk.java</span></div><h1>UDDIClerk.java</h1><pre class="source lang-java linenums">/* + * Copyright 2001-2010 The Apache Software Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.juddi.v3.client.config; + +import java.io.Serializable; +import java.lang.reflect.UndeclaredThrowableException; +import java.net.URL; +import java.rmi.RemoteException; +import java.util.ArrayList; +import java.util.Date; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Properties; +import java.util.Set; + +import javax.wsdl.Definition; +import javax.xml.ws.Holder; +import javax.xml.ws.soap.SOAPFaultException; + +import org.apache.commons.configuration.ConfigurationException; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.apache.juddi.api_v3.AccessPointType; +import org.apache.juddi.api_v3.Clerk; +import org.apache.juddi.api_v3.ClerkDetail; +import org.apache.juddi.api_v3.Node; +import org.apache.juddi.api_v3.NodeDetail; +import org.apache.juddi.api_v3.SaveClerk; +import org.apache.juddi.api_v3.SaveNode; +import org.apache.juddi.v3.client.UDDIConstants; +import org.apache.juddi.v3.client.cryptor.CryptorFactory; +import org.apache.juddi.v3.client.mapping.URLLocalizerDefaultImpl; +import org.apache.juddi.v3.client.mapping.wsdl.ReadWSDL; +import org.apache.juddi.v3.client.mapping.wsdl.WSDL2UDDI; +import org.apache.juddi.v3.client.transport.TransportException; +import org.uddi.api_v3.BindingDetail; +import org.uddi.api_v3.BindingTemplate; +import org.uddi.api_v3.BusinessDetail; +import org.uddi.api_v3.BusinessEntity; +import org.uddi.api_v3.BusinessService; +import org.uddi.api_v3.BusinessServices; +import org.uddi.api_v3.CategoryBag; +import org.uddi.api_v3.DeleteBinding; +import org.uddi.api_v3.DeleteBusiness; +import org.uddi.api_v3.DeleteService; +import org.uddi.api_v3.DeleteTModel; +import org.uddi.api_v3.Description; +import org.uddi.api_v3.DiscardAuthToken; +import org.uddi.api_v3.DispositionReport; +import org.uddi.api_v3.FindRelatedBusinesses; +import org.uddi.api_v3.FindTModel; +import org.uddi.api_v3.GetAuthToken; +import org.uddi.api_v3.GetBindingDetail; +import org.uddi.api_v3.GetBusinessDetail; +import org.uddi.api_v3.GetServiceDetail; +import org.uddi.api_v3.GetTModelDetail; +import org.uddi.api_v3.InstanceDetails; +import org.uddi.api_v3.KeyedReference; +import org.uddi.api_v3.Name; +import org.uddi.api_v3.OverviewDoc; +import org.uddi.api_v3.OverviewURL; +import org.uddi.api_v3.PublisherAssertion; +import org.uddi.api_v3.PublisherAssertions; +import org.uddi.api_v3.RelatedBusinessesList; +import org.uddi.api_v3.Result; +import org.uddi.api_v3.SaveBinding; +import org.uddi.api_v3.SaveBusiness; +import org.uddi.api_v3.SaveService; +import org.uddi.api_v3.SaveTModel; +import org.uddi.api_v3.ServiceDetail; +import org.uddi.api_v3.TModel; +import org.uddi.api_v3.TModelDetail; +import org.uddi.api_v3.TModelInstanceInfo; +import org.uddi.api_v3.TModelList; +import org.uddi.sub_v3.DeleteSubscription; +import org.uddi.sub_v3.Subscription; +import org.uddi.v3_service.DispositionReportFaultMessage; + +/** + * The UDDIClerk provides an easy way to access a UDDI service. The clerk can be + * configured programmatically, but it is recommended to specify the server + * endpoint and access credentials in a uddi.xml file. + * + * Recommended use: + * <pre> + * {@code + * UDDIClient uddiClient = new UDDIClient(); + * UDDIClerk clerk = uddiClient.getClerk(clerkName); + * } + * </pre> where the clerkName "MyClerk" is defined as attribute on the clerk + * element + * <pre> + * {@code + * <clerks registerOnStartup="true"> + * <clerk name="MyClerk" node="default" publisher="root" password="root" isPasswordEncrypted="false" cryptoProvider=""> + * <class>org.apache.juddi.example.HelloWorldImpl</class> + * </clerk> + * </clerks> + * } + * </pre> Credentials: In the clerk section you need to specify the publisher to + * be used, as well the password. The password can be encrypted and a + * cryptoProvider class can be set. + * + * UDDI Annotations: If you want to register classes containing UDDIAnnotations, + * then you need to set registerOnStartup="true" and you can list the classes + * with the annotations as subelements. See the HelloWorldImpl class above, as + * well as the uddi-annotations example. + * + * @author kstam + * + */ +public class UDDIClerk implements Serializable { + + private static final long serialVersionUID = -8597375975981358134L; + +<span class="fc" id="L132"> private static final Log log = LogFactory.getLog(UDDIClerk.class);</span> + protected String name; + protected UDDINode uddiNode; + protected String publisher; + protected String password; + private Date tokenBirthDate; + private String authToken; + private String cryptoProvider; +<span class="pc" id="L140"> private boolean isencrypted = false;</span> + private String[] classWithAnnotations; + private WSDL[] wsdls; + private String managerName; +<span class="pc" id="L144"> private Map<String, Properties> services = new HashMap<String, Properties>();</span> + + /** + * use caution calling the default constructor, many of the functions of + * the UDDI Clerk will not function unless manually set. The Node must + * be set for using most of the functions provided by this class. + */ + public UDDIClerk() { +<span class="fc" id="L152"> super();</span> +<span class="fc" id="L153"> }</span> + + public UDDIClerk(Clerk clerk) { +<span class="nc" id="L156"> super();</span> +<span class="nc" id="L157"> this.name = clerk.getName();</span> +<span class="nc" id="L158"> this.password = clerk.getPassword();</span> +<span class="nc" id="L159"> this.publisher = clerk.getPublisher();</span> +<span class="nc" id="L160"> this.uddiNode = new UDDINode(clerk.getNode());</span> +<span class="nc" id="L161"> }</span> + + /** + * A list of classes defined in the config file that have UDDI + * Annotations on them for automated registration + * <br>client.clerks.clerk(" + i + ").class + * + * @return classes with UDDI Annotations + * @see org.apache.juddi.v3.annotations.UDDIService + * @see org.apache.juddi.v3.annotations.UDDIServiceBinding + */ + public String[] getClassWithAnnotations() { +<span class="fc" id="L173"> return classWithAnnotations;</span> + } + + /** + * Returns the UDDI node that this clerk is associated with + * client.clerks.clerk(" + i + ")@node + * + * @return UDDINode + */ + public UDDINode getUDDINode() { +<span class="fc" id="L183"> return this.uddiNode;</span> + } + + public UDDINode getUDDINode(Node apinode) { +<span class="nc bnc" id="L187" title="All 2 branches missed."> if (apinode==null)</span> +<span class="nc" id="L188"> return this.uddiNode;</span> +<span class="nc bnc" id="L189" title="All 2 branches missed."> if (nodecache.containsKey(apinode.getClientName() + apinode+getName()))</span> +<span class="nc" id="L190"> return nodecache.get(apinode.getClientName() + apinode+getName());</span> +<span class="nc" id="L191"> UDDINode node = new UDDINode(apinode);</span> +<span class="nc" id="L192"> nodecache.put(apinode.getClientName() + apinode+getName(),node);</span> +<span class="nc" id="L193"> return node;</span> + } +<span class="pc" id="L195"> Map <String, UDDINode> nodecache = new HashMap<String, UDDINode>();</span> + /** + * A list of classes defined in the config file that have UDDI + * Annotations on them for automated registration + * <br>client.clerks.clerk(" + i + ").class + * + * @see org.apache.juddi.v3.annotations.UDDIService + * @see org.apache.juddi.v3.annotations.UDDIServiceBinding + */ + public void setClassWithAnnotations(String[] classWithAnnotations) { +<span class="fc" id="L205"> this.classWithAnnotations = classWithAnnotations;</span> +<span class="fc" id="L206"> }</span> + + /** + * This is not used within the jUDDI code base and will be removed in the next release + * + * @return a map + * @deprecated + */ + @Deprecated + public Map<String, Properties> getServices() { +<span class="nc" id="L216"> return services;</span> + } + + /** + * This is not used within the jUDDI code base and will be removed in the next release + * @param services + * @deprecated + */ + @Deprecated + public void setServices(Map<String, Properties> services) { +<span class="nc" id="L226"> this.services = services;</span> +<span class="nc" id="L227"> }</span> + + /** + * The client manager name as defined in the config file client[@name] + * + * @return the manager name + */ + public String getManagerName() { +<span class="nc" id="L235"> return managerName;</span> + } + + /** + * The client manager name as defined in the config file client[@name] + * + * @param managerName + */ + public void setManagerName(String managerName) { +<span class="fc" id="L244"> this.managerName = managerName;</span> +<span class="fc" id="L245"> }</span> + + /** + * Performans the process of parsing the configuration defined wsdls to + * UDDI. This is a convenience wrapper Note, if registration fails, no + * exception is thrown + */ + public void registerWsdls() { +<span class="nc" id="L253"> registerWsdls(null);</span> +<span class="nc" id="L254"> }</span> + + /** + * Registers the WSDL files referenced in the clerk onto the UDDI node + * referenced by the clerk. Note, if registration fails, no exception is + * thrown + * <pre> + * {@code + * <clerks registerOnStartup="false"> + * <clerk name="joe" node="default" publisher="joepublisher" password="joepublisher" isPasswordEncrypted="false" cryptoProvider=""> + * <wsdl businessName="WSDL-Business">wsdl/helloworld.wsdl</wsdl> + * </clerk> + * </clerks> + * } + * </pre> + * + * @param localizerBaseUrl - The baseUrl part which will be used when + * building the bindingTemplate. + */ + public void registerWsdls(URL localizerBaseUrl) { +<span class="nc bnc" id="L274" title="All 2 branches missed."> if (this.getWsdls() != null) {</span> +<span class="nc" id="L275"> Properties properties = new Properties();</span> +<span class="nc" id="L276"> properties.putAll(this.getUDDINode().getProperties());</span> + +<span class="nc bnc" id="L278" title="All 2 branches missed."> for (WSDL wsdl : this.getWsdls()) {</span> + try { +<span class="nc" id="L280"> URL wsdlUrl = this.getClass().getClassLoader().getResource(wsdl.getFileName());</span> +<span class="nc" id="L281"> ReadWSDL rw = new ReadWSDL();</span> +<span class="nc" id="L282"> Definition wsdlDefinition = rw.readWSDL(wsdlUrl);</span> +<span class="nc bnc" id="L283" title="All 2 branches missed."> if (wsdl.keyDomain != null) {</span> +<span class="nc" id="L284"> properties.setProperty("keyDomain", wsdl.keyDomain);</span> + } +<span class="nc bnc" id="L286" title="All 2 branches missed."> if (wsdl.businessKey != null) {</span> +<span class="nc" id="L287"> properties.setProperty("businessKey", wsdl.getBusinessKey());</span> + } + +<span class="nc" id="L290"> WSDL2UDDI wsdl2UDDI = new WSDL2UDDI(this, new URLLocalizerDefaultImpl(localizerBaseUrl), properties);</span> +<span class="nc" id="L291"> wsdl2UDDI.registerBusinessServices(wsdlDefinition);</span> +<span class="nc" id="L292"> } catch (Exception e) {</span> +<span class="nc" id="L293"> log.error("Unable to register wsdl " + wsdl.getFileName() + " ." + e.getMessage(), e);</span> +<span class="nc" id="L294"> } catch (Throwable t) {</span> +<span class="nc" id="L295"> log.error("Unable to register wsdl " + wsdl.getFileName() + " ." + t.getMessage(), t);</span> +<span class="nc" id="L296"> }</span> + } + } +<span class="nc" id="L299"> }</span> + + /** + * Registers a WSDL Definition onto the UDDI node referenced by the + * clerk. Note, if registration fails, no exception is thrown + * + * @param wsdlDefinition - the WSDL Definition + * @param keyDomain - the keyDomain which will be used to construct the + * UDDI key IDs. If left null the keyDomain defined in the node's + * properties will be used. + * @param businessKey - the key of the business to which this service + * belongs. If left null the businessKey defined in the node's + * properties will be used. + * + */ + public void registerWsdls(Definition wsdlDefinition, String keyDomain, String businessKey) { + + try { +<span class="nc" id="L317"> Properties properties = new Properties();</span> +<span class="nc" id="L318"> properties.putAll(this.getUDDINode().getProperties());</span> +<span class="nc bnc" id="L319" title="All 2 branches missed."> if (keyDomain != null) {</span> +<span class="nc" id="L320"> properties.setProperty("keyDomain", keyDomain);</span> + } +<span class="nc bnc" id="L322" title="All 2 branches missed."> if (businessKey != null) {</span> +<span class="nc" id="L323"> properties.setProperty("businessKey", businessKey);</span> + } + +<span class="nc" id="L326"> WSDL2UDDI wsdl2UDDI = new WSDL2UDDI(this, new URLLocalizerDefaultImpl(), properties);</span> +<span class="nc" id="L327"> wsdl2UDDI.registerBusinessServices(wsdlDefinition);</span> +<span class="nc" id="L328"> } catch (Exception e) {</span> +<span class="nc" id="L329"> log.error("Unable to register wsdl " + " ." + e.getMessage(), e);</span> +<span class="nc" id="L330"> } catch (Throwable t) {</span> +<span class="nc" id="L331"> log.error("Unable to register wsdl " + " ." + t.getMessage(), t);</span> +<span class="nc" id="L332"> }</span> +<span class="nc" id="L333"> }</span> + + /** + * Removes the UDDI data structures belonging to the WSDLs for this + * clerk from the UDDI node. Note, if registration fails, no exception + * is thrown + */ + public void unRegisterWsdls() { +<span class="nc bnc" id="L341" title="All 2 branches missed."> if (this.getWsdls() != null) {</span> +<span class="nc" id="L342"> Properties properties = new Properties();</span> +<span class="nc" id="L343"> properties.putAll(this.getUDDINode().getProperties());</span> + +<span class="nc bnc" id="L345" title="All 2 branches missed."> for (WSDL wsdl : this.getWsdls()) {</span> + try { +<span class="nc" id="L347"> URL wsdlUrl = this.getClass().getClassLoader().getResource(wsdl.getFileName());</span> +<span class="nc" id="L348"> ReadWSDL rw = new ReadWSDL();</span> +<span class="nc" id="L349"> Definition wsdlDefinition = rw.readWSDL(wsdlUrl);</span> +<span class="nc bnc" id="L350" title="All 2 branches missed."> if (wsdl.keyDomain != null) {</span> +<span class="nc" id="L351"> properties.setProperty("keyDomain", wsdl.keyDomain);</span> + } +<span class="nc bnc" id="L353" title="All 2 branches missed."> if (wsdl.businessKey != null) {</span> +<span class="nc" id="L354"> properties.setProperty("businessKey", wsdl.getBusinessKey());</span> + } + +<span class="nc" id="L357"> WSDL2UDDI wsdl2UDDI = new WSDL2UDDI(this, new URLLocalizerDefaultImpl(), properties);</span> +<span class="nc" id="L358"> wsdl2UDDI.unRegisterBusinessServices(wsdlDefinition);</span> +<span class="nc" id="L359"> } catch (Exception e) {</span> +<span class="nc" id="L360"> log.error("Unable to register wsdl " + wsdl.getFileName() + " ." + e.getMessage(), e);</span> +<span class="nc" id="L361"> } catch (Throwable t) {</span> +<span class="nc" id="L362"> log.error("Unable to register wsdl " + wsdl.getFileName() + " ." + t.getMessage(), t);</span> +<span class="nc" id="L363"> }</span> + } + } +<span class="nc" id="L366"> }</span> + + /** + * Registers the Subscription that is passed in to the UDDI node for + * this clerk. + * + * Note, if registration fails, no exception is thrown + * + * @param subscription + * @return a subscription object, or null if failed + */ + public Subscription register(Subscription subscription) { +<span class="nc" id="L378"> return register(subscription, this.getUDDINode().getApiNode());</span> + } + + /** + * Register a Subscription to UDDI node passed in. Make sure you use a + * clerk that has credentials for this node. Note, if registration + * fails, no exception is thrown + * + * @param subscription a UDDI subscription, remember only one filter + * type is allowed by UDDI + * @param node the UDDI node referenced from the config file + * @return the potentially UDDI server modified subscription + */ + public Subscription register(Subscription subscription, Node node) { + +<span class="nc" id="L393"> log.info("Registering subscription with key " + subscription.getSubscriptionKey());</span> +<span class="nc" id="L394"> Holder<List<Subscription>> holder = new Holder<List<Subscription>>();</span> + try { +<span class="nc" id="L396"> List<Subscription> subscriptions = new ArrayList<Subscription>();</span> +<span class="nc" id="L397"> subscriptions.add(subscription);</span> +<span class="nc" id="L398"> holder.value = subscriptions;</span> +<span class="nc" id="L399"> getUDDINode(node).getTransport().getUDDISubscriptionService(node.getSubscriptionUrl()).</span> +<span class="nc" id="L400"> saveSubscription(getAuthToken(node.getSecurityUrl()), holder);</span> +<span class="nc bnc" id="L401" title="All 2 branches missed."> if (log.isDebugEnabled()) {</span> +<span class="nc" id="L402"> log.debug("Registering subscription " + subscription.getSubscriptionKey() + " completed.");</span> + } +<span class="nc" id="L404"> } catch (Exception e) {</span> +<span class="nc" id="L405"> log.error("Unable to register subscription " + subscription.getSubscriptionKey()</span> +<span class="nc" id="L406"> + " ." + e.getMessage(), e);</span> +<span class="nc" id="L407"> } catch (Throwable t) {</span> +<span class="nc" id="L408"> log.error("Unable to register subscriptionl " + subscription.getSubscriptionKey()</span> +<span class="nc" id="L409"> + " ." + t.getMessage(), t);</span> +<span class="nc" id="L410"> }</span> +<span class="nc" id="L411"> subscription = holder.value.get(0);</span> +<span class="nc" id="L412"> return subscription;</span> + } + + /** + * Register a tModel, using the node of current clerk ('this'). Note, if + * registration fails, no exception is thrown + * + * @param tModel + * @return the TModelDetail of the newly registered TModel + */ + public TModelDetail register(TModel tModel) { +<span class="nc" id="L423"> return register(tModel, this.getUDDINode().getApiNode());</span> + } + + /** + * Register a tModel. Note, if registration fails, no exception is + * thrown + * + * @param tModel + * @param node + * @return a tModel object or null if registration failed + */ + public TModelDetail register(TModel tModel, Node node) { +<span class="nc" id="L435"> TModelDetail tModelDetail = null;</span> +<span class="nc" id="L436"> log.info("Registering tModel with key " + tModel.getTModelKey());</span> + try { +<span class="nc" id="L438"> SaveTModel saveTModel = new SaveTModel();</span> +<span class="nc" id="L439"> saveTModel.setAuthInfo(getAuthToken(node.getSecurityUrl()));</span> +<span class="nc" id="L440"> saveTModel.getTModel().add(tModel);</span> +<span class="nc" id="L441"> tModelDetail = getUDDINode(node).getTransport().getUDDIPublishService(node.getPublishUrl()).saveTModel(saveTModel);</span> +<span class="nc bnc" id="L442" title="All 2 branches missed."> if (log.isDebugEnabled()) {</span> +<span class="nc" id="L443"> log.debug("Registering tModel " + tModel.getTModelKey() + " completed.");</span> + } +<span class="nc" id="L445"> } catch (Exception e) {</span> +<span class="nc" id="L446"> log.error("Unable to register tModel " + tModel.getTModelKey()</span> +<span class="nc" id="L447"> + " ." + e.getMessage(), e);</span> +<span class="nc" id="L448"> } catch (Throwable t) {</span> +<span class="nc" id="L449"> log.error("Unable to register tModel " + tModel.getTModelKey()</span> +<span class="nc" id="L450"> + " ." + t.getMessage(), t);</span> +<span class="nc" id="L451"> }</span> +<span class="nc" id="L452"> return tModelDetail;</span> + } + + /** + * Register a BindingTemplate, using the node of current clerk ('this'). + * Note, if registration fails, no exception is thrown + * + * @param binding + * @return a binding object or null + */ + public BindingTemplate register(BindingTemplate binding) { +<span class="nc" id="L463"> return register(binding, this.getUDDINode().getApiNode());</span> + } + + /** + * Register a BindingTemplate. Note, if registration fails, no exception + * is thrown + * + * @param binding + * @param node + * @return a binding object or null + */ + public BindingTemplate register(BindingTemplate binding, Node node) { + +<span class="nc" id="L476"> BindingTemplate bindingTemplate = null;</span> +<span class="nc" id="L477"> log.info("Registering bindingTemplate with key " + binding.getBindingKey());</span> + try { +<span class="nc" id="L479"> SaveBinding saveBinding = new SaveBinding();</span> +<span class="nc" id="L480"> saveBinding.setAuthInfo(getAuthToken(node.getSecurityUrl()));</span> +<span class="nc" id="L481"> saveBinding.getBindingTemplate().add(binding);</span> +<span class="nc" id="L482"> BindingDetail bindingDetail = getUDDINode(node).getTransport().getUDDIPublishService(node.getPublishUrl()).saveBinding(saveBinding);</span> +<span class="nc" id="L483"> bindingTemplate = bindingDetail.getBindingTemplate().get(0);</span> +<span class="nc bnc" id="L484" title="All 2 branches missed."> if (log.isDebugEnabled()) {</span> +<span class="nc" id="L485"> log.debug("Registering template binding " + bindingTemplate.getBindingKey() + " completed.");</span> + } +<span class="nc" id="L487"> } catch (Exception e) {</span> +<span class="nc" id="L488"> log.error("Unable to register template binding " + binding.getBindingKey()</span> +<span class="nc" id="L489"> + " ." + e.getMessage(), e);</span> +<span class="nc" id="L490"> } catch (Throwable t) {</span> +<span class="nc" id="L491"> log.error("Unable to register template binding " + binding.getBindingKey()</span> +<span class="nc" id="L492"> + " ." + t.getMessage(), t);</span> +<span class="nc" id="L493"> }</span> +<span class="nc" id="L494"> return bindingTemplate;</span> + } + + /** + * Register a service, using the node of current clerk ('this'). Note, + * if registration fails, no exception is thrown and null is returned + * + * @param service + * @return a service object or null + */ + public BusinessService register(BusinessService service) { +<span class="nc" id="L505"> return register(service, this.getUDDINode().getApiNode());</span> + } + + /** + * Register a service. + * + * Note, if registration fails, no exception is thrown + * + * @param service the element returned by the server, it may be modified + * from the original + * @param node + * @return the potentially modified service by the UDDI server or NULL if save failed + */ + public BusinessService register(BusinessService service, Node node) { + +<span class="nc" id="L520"> BusinessService businessService = null;</span> +<span class="nc bnc" id="L521" title="All 2 branches missed."> if (service.getName().isEmpty()){</span> +<span class="nc" id="L522"> log.error("Unable to register service, a 'name' element is required");</span> +<span class="nc" id="L523"> return null;</span> + } +<span class="nc" id="L525"> log.info("Registering service " + service.getName().get(0).getValue()</span> +<span class="nc" id="L526"> + " with key " + service.getServiceKey());</span> + try { +<span class="nc" id="L528"> SaveService saveService = new SaveService();</span> +<span class="nc" id="L529"> saveService.setAuthInfo(getAuthToken(node.getSecurityUrl()));</span> +<span class="nc" id="L530"> saveService.getBusinessService().add(service);</span> +<span class="nc" id="L531"> ServiceDetail serviceDetail = getUDDINode(node).getTransport().getUDDIPublishService(node.getPublishUrl()).saveService(saveService);</span> +<span class="nc" id="L532"> businessService = serviceDetail.getBusinessService().get(0);</span> +<span class="nc bnc" id="L533" title="All 2 branches missed."> if (log.isDebugEnabled()) {</span> +<span class="nc" id="L534"> log.debug("Registering service " + service.getName().get(0).getValue() + " completed.");</span> + } +<span class="nc" id="L536"> } catch (Exception e) {</span> +<span class="nc" id="L537"> log.error("Unable to register service " + service.getName().get(0).getValue()</span> +<span class="nc" id="L538"> + " ." + e.getMessage(), e);</span> +<span class="nc" id="L539"> } catch (Throwable t) {</span> +<span class="nc" id="L540"> log.error("Unable to register service " + service.getName().get(0).getValue()</span> +<span class="nc" id="L541"> + " ." + t.getMessage(), t);</span> +<span class="nc" id="L542"> }</span> +<span class="nc" id="L543"> return businessService;</span> + } + + /** + * registers a UDDI business. This is a convenience wrapper + * + * @param business + * @return a possibility modified business entity as registered or NULL if the save failed + */ + public BusinessEntity register(BusinessEntity business) { +<span class="nc" id="L553"> return register(business, this.getUDDINode().getApiNode());</span> + } + + /** + * Registers a UDDI Business referencing the specified Node from the + * config file + * + * @param business + * @param node + * @return a possibility modified business entity as registered or NULL if the save failed + */ + public BusinessEntity register(BusinessEntity business, Node node) { + +<span class="nc bnc" id="L566" title="All 2 branches missed."> if (business.getName().get(0) == null) {</span> +<span class="nc" id="L567"> log.error("Unable to register business because no Name elements have been added.");</span> +<span class="nc" id="L568"> return null;</span> + } +<span class="nc" id="L570"> BusinessEntity businessEntity = null;</span> +<span class="nc" id="L571"> log.info("Registering business " + business.getName().get(0).getValue()</span> +<span class="nc" id="L572"> + " with key " + business.getBusinessKey());</span> + try { +<span class="nc" id="L574"> SaveBusiness saveBusiness = new SaveBusiness();</span> +<span class="nc" id="L575"> saveBusiness.setAuthInfo(getAuthToken(node.getSecurityUrl()));</span> +<span class="nc" id="L576"> saveBusiness.getBusinessEntity().add(business);</span> +<span class="nc" id="L577"> BusinessDetail businessDetail = getUDDINode(node).getTransport().getUDDIPublishService(node.getPublishUrl()).saveBusiness(saveBusiness);</span> +<span class="nc" id="L578"> businessEntity = businessDetail.getBusinessEntity().get(0);</span> +<span class="nc bnc" id="L579" title="All 2 branches missed."> if (log.isDebugEnabled()) {</span> +<span class="nc" id="L580"> log.debug("Registering businessEntity " + businessEntity.getName().get(0).getValue() + " completed.");</span> + } +<span class="nc" id="L582"> } catch (Exception e) {</span> +<span class="nc" id="L583"> log.error("Unable to register business " + business.getName().get(0).getValue()</span> +<span class="nc" id="L584"> + " ." + e.getMessage(), e);</span> +<span class="nc" id="L585"> } catch (Throwable t) {</span> +<span class="nc" id="L586"> log.error("Unable to register business " + business.getName().get(0).getValue()</span> +<span class="nc" id="L587"> + " ." + t.getMessage(), t);</span> +<span class="nc" id="L588"> }</span> +<span class="nc" id="L589"> return businessEntity;</span> + } + + /** + * removes a business from UDDI. This is a convenience wrapper Note, if + * registration fails, no exception is thrown + * + * @param businessKey + */ + public void unRegisterBusiness(String businessKey) { +<span class="nc" id="L599"> unRegisterBusiness(businessKey, this.getUDDINode().getApiNode());</span> +<span class="nc" id="L600"> }</span> + + /** + * Unregisters the service with specified serviceKey using the specified + * Node, as defined in the config file Note, if registration fails, no + * exception is thrown + * + * @param businessKey + * @param node + */ + public void unRegisterBusiness(String businessKey, Node node) { +<span class="nc" id="L611"> log.info("UnRegistering the business " + businessKey);</span> + try { +<span class="nc" id="L613"> DeleteBusiness deleteBusiness = new DeleteBusiness();</span> +<span class="nc" id="L614"> deleteBusiness.setAuthInfo(getAuthToken(node.getSecurityUrl()));</span> +<span class="nc" id="L615"> deleteBusiness.getBusinessKey().add(businessKey);</span> +<span class="nc" id="L616"> getUDDINode(node).getTransport().getUDDIPublishService(node.getPublishUrl()).deleteBusiness(deleteBusiness);</span> +<span class="nc" id="L617"> } catch (Exception e) {</span> +<span class="nc" id="L618"> log.error("Unable to register service " + businessKey</span> +<span class="nc" id="L619"> + " ." + e.getMessage(), e);</span> +<span class="nc" id="L620"> }</span> +<span class="nc" id="L621"> }</span> + + /** + * removes a service by key. This is a convenience wrapper Note, if + * registration fails, no exception is thrown + * + * @param serviceKey + */ + public void unRegisterService(String serviceKey) { +<span class="nc" id="L630"> unRegisterService(serviceKey, this.getUDDINode().getApiNode());</span> +<span class="nc" id="L631"> }</span> + + /** + * Unregisters the service with specified serviceKey. Note, if + * registration fails, no exception is thrown + * + * @param serviceKey + * @param node + */ + public void unRegisterService(String serviceKey, Node node) { +<span class="nc" id="L641"> log.info("UnRegistering the service " + serviceKey);</span> + try { +<span class="nc" id="L643"> DeleteService deleteService = new DeleteService();</span> +<span class="nc" id="L644"> deleteService.setAuthInfo(getAuthToken(node.getSecurityUrl()));</span> +<span class="nc" id="L645"> deleteService.getServiceKey().add(serviceKey);</span> +<span class="nc" id="L646"> getUDDINode(node).getTransport().getUDDIPublishService(node.getPublishUrl()).deleteService(deleteService);</span> +<span class="nc" id="L647"> } catch (Exception e) {</span> +<span class="nc" id="L648"> log.error("Unable to register service " + serviceKey</span> +<span class="nc" id="L649"> + " ." + e.getMessage(), e);</span> +<span class="nc" id="L650"> }</span> +<span class="nc" id="L651"> }</span> + + /** + * removes a binding by key. This is a convenience wrapper Note, if + * registration fails, no exception is thrown + * + * @param bindingKey + */ + public void unRegisterBinding(String bindingKey) { +<span class="nc" id="L660"> unRegisterBinding(bindingKey, this.getUDDINode().getApiNode());</span> +<span class="nc" id="L661"> }</span> + + /** + * Unregisters the BindingTemplate with specified bindingKey and + * referenced node defined in the config file Note, if registration + * fails, no exception is thrown + * + * @param bindingKey + * @param node + */ + public void unRegisterBinding(String bindingKey, Node node) { +<span class="nc" id="L672"> log.info("UnRegistering binding key " + bindingKey);</span> + try { +<span class="nc" id="L674"> DeleteBinding deleteBinding = new DeleteBinding();</span> +<span class="nc" id="L675"> deleteBinding.setAuthInfo(getAuthToken(node.getSecurityUrl()));</span> +<span class="nc" id="L676"> deleteBinding.getBindingKey().add(bindingKey);</span> +<span class="nc" id="L677"> getUDDINode(node).getTransport().getUDDIPublishService(node.getPublishUrl()).deleteBinding(deleteBinding);</span> +<span class="nc" id="L678"> } catch (Exception e) {</span> +<span class="nc" id="L679"> log.error("Unable to unregister bindingkey " + bindingKey</span> +<span class="nc" id="L680"> + " ." + e.getMessage(), e);</span> +<span class="nc" id="L681"> }</span> +<span class="nc" id="L682"> }</span> + + /** + * removes a tModel. Note, UDDI just flags tModels as deleted, it will + * still be accessible but not returned in a search. This is a + * convenience wrapper Note, if registration fails, no exception is + * thrown + * + * @param tModelKey + */ + public void unRegisterTModel(String tModelKey) { +<span class="nc" id="L693"> unRegisterTModel(tModelKey, this.getUDDINode().getApiNode());</span> +<span class="nc" id="L694"> }</span> + + /** + * Unregisters the BindingTemplate with specified bindingKey. Note, if + * registration fails, no exception is thrown + * + * @param tModelKey + * @param node + */ + public void unRegisterTModel(String tModelKey, Node node) { +<span class="nc" id="L704"> log.info("UnRegistering tModel key " + tModelKey);</span> + try { +<span class="nc" id="L706"> String authToken = getAuthToken(node.getSecurityUrl());</span> +<span class="nc" id="L707"> DeleteTModel deleteTModel = new DeleteTModel();</span> +<span class="nc" id="L708"> deleteTModel.setAuthInfo(authToken);</span> +<span class="nc" id="L709"> deleteTModel.getTModelKey().add(tModelKey);</span> +<span class="nc" id="L710"> getUDDINode(node).getTransport().getUDDIPublishService(node.getPublishUrl()).deleteTModel(deleteTModel);</span> +<span class="nc" id="L711"> } catch (Exception e) {</span> +<span class="nc" id="L712"> log.error("Unable to unregister tModelkey " + tModelKey</span> +<span class="nc" id="L713"> + " ." + e.getMessage(), e);</span> +<span class="nc" id="L714"> }</span> +<span class="nc" id="L715"> }</span> + + /** + * removes a subscription by key. This is a convenience wrapper Note, if + * registration fails, no exception is thrown + * + * @param subscriptionKey + */ + public void unRegisterSubscription(String subscriptionKey) { +<span class="nc" id="L724"> unRegisterSubscription(subscriptionKey, this.getUDDINode().getApiNode());</span> +<span class="nc" id="L725"> }</span> + + /** + * removes a subscription by key, referencing the specified node in the + * config file Note, if registration fails, no exception is thrown + * + * @param subscriptionKey + * @param node + */ + public void unRegisterSubscription(String subscriptionKey, Node node) { +<span class="nc" id="L735"> log.info("UnRegistering subscription with key " + subscriptionKey);</span> + try { +<span class="nc" id="L737"> String authToken = getAuthToken(node.getSecurityUrl());</span> +<span class="nc" id="L738"> DeleteSubscription deleteSubscription = new DeleteSubscription();</span> +<span class="nc" id="L739"> deleteSubscription.setAuthInfo(authToken);</span> +<span class="nc" id="L740"> deleteSubscription.getSubscriptionKey().add(subscriptionKey);</span> +<span class="nc" id="L741"> getUDDINode(node).getTransport().getUDDISubscriptionService(node.getSubscriptionUrl()).deleteSubscription(deleteSubscription);</span> +<span class="nc" id="L742"> } catch (Exception e) {</span> +<span class="nc" id="L743"> log.error("Unable to unregister subscription key " + subscriptionKey</span> +<span class="nc" id="L744"> + " ." + e.getMessage(), e);</span> +<span class="nc" id="L745"> }</span> +<span class="nc" id="L746"> }</span> + + /** + * finds a tmodel. This is a convenience wrapper + * + * @param findTModel + * @return null if not found or error + * @throws RemoteException + * @throws ConfigurationException + * @throws TransportException + */ + public TModelList findTModel(FindTModel findTModel) throws RemoteException, ConfigurationException, TransportException { +<span class="nc" id="L758"> return findTModel(findTModel, this.getUDDINode().getApiNode());</span> + } + + /** + * finds a tModel + * + * @param findTModel + * @param node + * @return null if not found or error + * @throws RemoteException + * @throws TransportException + * @throws ConfigurationException + */ + public TModelList findTModel(FindTModel findTModel, Node node) throws RemoteException, + TransportException, ConfigurationException { + +<span class="nc" id="L774"> findTModel.setAuthInfo(getAuthToken(node.getSecurityUrl()));</span> + try { +<span class="nc" id="L776"> TModelList tModelList = getUDDINode(node).getTransport().getUDDIInquiryService(node.getInquiryUrl()).findTModel(findTModel);</span> +<span class="nc" id="L777"> return tModelList;</span> +<span class="nc" id="L778"> } catch (DispositionReportFaultMessage dr) {</span> +<span class="nc" id="L779"> DispositionReport report = DispositionReportFaultMessage.getDispositionReport(dr);</span> +<span class="nc" id="L780"> checkForErrorInDispositionReport(report, null, null);</span> +<span class="nc" id="L781"> } catch (SOAPFaultException sfe) {</span> +<span class="nc" id="L782"> DispositionReport report = DispositionReportFaultMessage.getDispositionReport(sfe);</span> +<span class="nc" id="L783"> checkForErrorInDispositionReport(report, null, null);</span> +<span class="nc" id="L784"> } catch (UndeclaredThrowableException ute) {</span> +<span class="nc" id="L785"> DispositionReport report = DispositionReportFaultMessage.getDispositionReport(ute);</span> +<span class="nc" id="L786"> checkForErrorInDispositionReport(report, null, null);</span> +<span class="nc" id="L787"> }catch (Throwable t){</span> +<span class="nc" id="L788"> throw new RemoteException("Unhandled exception", t);</span> +<span class="nc" id="L789"> }</span> +<span class="nc" id="L790"> return null;</span> + } + + /** + * Gets the details of a tModel by the key. This is a convenience + * wrapper + * + * @param tModelKey + * @return null if not found or error, otherwise the details of the + * tModel(s) + * @throws RemoteException + * @throws ConfigurationException + * @throws TransportException + */ + public TModelDetail getTModelDetail(String tModelKey) throws RemoteException, ConfigurationException, TransportException { +<span class="nc" id="L805"> GetTModelDetail getTModelDetail = new GetTModelDetail();</span> +<span class="nc" id="L806"> getTModelDetail.getTModelKey().add(tModelKey);</span> +<span class="nc" id="L807"> return getTModelDetail(getTModelDetail);</span> + } + + /** + * Gets the details of a tModel by the key. This is a convenience + * wrapper + * + * @param getTModelDetail + * @return null if not found or error + * @throws RemoteException + * @throws ConfigurationException + * @throws TransportException + */ + public TModelDetail getTModelDetail(GetTModelDetail getTModelDetail) throws RemoteException, ConfigurationException, TransportException { +<span class="nc" id="L821"> return getTModelDetail(getTModelDetail, this.getUDDINode().getApiNode());</span> + } + + /** + * Gets the details of a tModel by the key using the referenced Node + * from the config file + * + * @param getTModelDetail + * @param node + * @return null if not found or error + * @throws RemoteException + * @throws TransportException + * @throws ConfigurationException + */ + public TModelDetail getTModelDetail(GetTModelDetail getTModelDetail, Node node) throws RemoteException, + TransportException, ConfigurationException { + +<span class="nc" id="L838"> getTModelDetail.setAuthInfo(getAuthToken(node.getSecurityUrl()));</span> + try { +<span class="nc" id="L840"> TModelDetail tModelDetail = getUDDINode(node).getTransport().getUDDIInquiryService(node.getInquiryUrl()).getTModelDetail(getTModelDetail);</span> +<span class="nc" id="L841"> return tModelDetail;</span> +<span class="nc" id="L842"> } catch (DispositionReportFaultMessage dr) {</span> +<span class="nc" id="L843"> DispositionReport report = DispositionReportFaultMessage.getDispositionReport(dr);</span> +<span class="nc" id="L844"> checkForErrorInDispositionReport(report, null, null);</span> +<span class="nc" id="L845"> } catch (SOAPFaultException sfe) {</span> +<span class="nc" id="L846"> DispositionReport report = DispositionReportFaultMessage.getDispositionReport(sfe);</span> +<span class="nc" id="L847"> checkForErrorInDispositionReport(report, null, null);</span> +<span class="nc" id="L848"> } catch (UndeclaredThrowableException ute) {</span> +<span class="nc" id="L849"> DispositionReport report = DispositionReportFaultMessage.getDispositionReport(ute);</span> +<span class="nc" id="L850"> checkForErrorInDispositionReport(report, null, null);</span> +<span class="nc" id="L851"> }catch (Throwable t){</span> +<span class="nc" id="L852"> throw new RemoteException("Unhandled exception", t);</span> +<span class="nc" id="L853"> }</span> +<span class="nc" id="L854"> return null;</span> + } + + /** + * Finds a service by the key, . This is a convenience wrapper + * + * @param serviceKey + * @return null if not found or error + * @throws RemoteException + * @throws TransportException + * @throws ConfigurationException + */ + public BusinessService getServiceDetail(String serviceKey) throws RemoteException, + TransportException, ConfigurationException { +<span class="nc" id="L868"> return getServiceDetail(serviceKey, this.getUDDINode().getApiNode());</span> + } + + /** + * Finds a service by the key, . This is a convenience wrapper + * + * @param serviceKey + * @return null if not found or error + * @throws RemoteException + * @throws TransportException + * @throws ConfigurationException + * @deprecated see getServiceDetail + */ + @Deprecated + public BusinessService findService(String serviceKey) throws RemoteException, + TransportException, ConfigurationException { +<span class="nc" id="L884"> return getServiceDetail(serviceKey, this.getUDDINode().getApiNode());</span> + } + + /** + * Finds a service by the key, referencing the specific Node from the + * configuration file + * + * @param serviceKey + * @param node + * @return null if not found or error + * @throws RemoteException + * @throws TransportException + * @throws ConfigurationException + * @deprecated see getServiceDetail + */ + @Deprecated + public BusinessService findService(String serviceKey, Node node) throws RemoteException, + TransportException, ConfigurationException { +<span class="nc" id="L902"> return getServiceDetail(serviceKey, node);</span> + } + + /** + * Finds a service by the key, referencing the specific Node from the + * configuration file + * + * @param serviceKey + * @param node + * @return null if not found or error + * @throws RemoteException + * @throws TransportException + * @throws ConfigurationException + */ + public BusinessService getServiceDetail(String serviceKey, Node node) throws RemoteException, + TransportException, ConfigurationException { +<span class="nc" id="L918"> GetServiceDetail getServiceDetail = new GetServiceDetail();</span> +<span class="nc" id="L919"> getServiceDetail.getServiceKey().add(serviceKey);</span> +<span class="nc" id="L920"> getServiceDetail.setAuthInfo(getAuthToken(node.getSecurityUrl()));</span> + try { +<span class="nc" id="L922"> ServiceDetail sd = getUDDINode(node).getTransport().getUDDIInquiryService(node.getInquiryUrl()).getServiceDetail(getServiceDetail);</span> +<span class="nc" id="L923"> List<BusinessService> businessServiceList = sd.getBusinessService();</span> +<span class="nc bnc" id="L924" title="All 2 branches missed."> if (businessServiceList.size() == 0) {</span> +<span class="nc" id="L925"> throw new ConfigurationException("Could not find Service with key=" + serviceKey);</span> + } +<span class="nc" id="L927"> return businessServiceList.get(0);</span> +<span class="nc" id="L928"> } catch (DispositionReportFaultMessage dr) {</span> +<span class="nc" id="L929"> DispositionReport report = DispositionReportFaultMessage.getDispositionReport(dr);</span> +<span class="nc" id="L930"> checkForErrorInDispositionReport(report, DispositionReport.E_INVALID_KEY_PASSED, serviceKey);</span> +<span class="nc" id="L931"> } catch (SOAPFaultException sfe) {</span> +<span class="nc" id="L932"> DispositionReport report = DispositionReportFaultMessage.getDispositionReport(sfe);</span> +<span class="nc" id="L933"> checkForErrorInDispositionReport(report, DispositionReport.E_INVALID_KEY_PASSED, serviceKey);</span> +<span class="nc" id="L934"> } catch (UndeclaredThrowableException ute) {</span> +<span class="nc" id="L935"> DispositionReport report = DispositionReportFaultMessage.getDispositionReport(ute);</span> +<span class="nc" id="L936"> checkForErrorInDispositionReport(report, DispositionReport.E_INVALID_KEY_PASSED, serviceKey);</span> +<span class="nc" id="L937"> }catch (Throwable t){</span> +<span class="nc" id="L938"> throw new RemoteException("Unhandled exception", t);</span> +<span class="nc" id="L939"> }</span> +<span class="nc" id="L940"> return null;</span> + } + + /** + * + * @param bindingKey + * @return returns a binding template or null if not found + * @throws DispositionReportFaultMessage + * @throws RemoteException + * @throws TransportException + * @throws ConfigurationException + * @deprecated see getServiceBindingDetail + */ + @Deprecated + public BindingTemplate findServiceBinding(String bindingKey) throws DispositionReportFaultMessage, RemoteException, + TransportException, ConfigurationException { +<span class="nc" id="L956"> return getServiceBindingDetail(bindingKey, this.getUDDINode().getApiNode());</span> + } + + /** + * gets a binding detail by key + * + * @param bindingKey + * @return null if not found or error, or the binding template + * @throws DispositionReportFaultMessage + * @throws RemoteException + * @throws TransportException + * @throws ConfigurationException + */ + public BindingTemplate getServiceBindingDetail(String bindingKey) throws DispositionReportFaultMessage, RemoteException, + TransportException, ConfigurationException { +<span class="nc" id="L971"> return getServiceBindingDetail(bindingKey, this.getUDDINode().getApiNode());</span> + } + + /** + * @deprecated use getServiceBindingDetail instead + * @param bindingKey + * @param node + * @return null if not found + * @throws DispositionReportFaultMessage + * @throws RemoteException + * @throws TransportException + * @throws ConfigurationException + * @deprecated + */ + @Deprecated + public BindingTemplate findServiceBinding(String bindingKey, Node node) throws DispositionReportFaultMessage, RemoteException, + TransportException, ConfigurationException { +<span class="nc" id="L988"> return getServiceBindingDetail(bindingKey, node);</span> + + } + + /** + * Gets the details of a specific service binding key + * + * @param bindingKey + * @param node + * @return null if not found, or error, or the details of the binding + * @throws DispositionReportFaultMessage + * @throws RemoteException + * @throws TransportException + * @throws ConfigurationException + */ + public BindingTemplate getServiceBindingDetail(String bindingKey, Node node) throws DispositionReportFaultMessage, RemoteException, + TransportException, ConfigurationException { +<span class="nc" id="L1005"> GetBindingDetail getBindingDetail = new GetBindingDetail();</span> +<span class="nc" id="L1006"> getBindingDetail.getBindingKey().add(bindingKey);</span> +<span class="nc" id="L1007"> getBindingDetail.setAuthInfo(getAuthToken(node.getSecurityUrl()));</span> + try { +<span class="nc" id="L1009"> BindingDetail bd = getUDDINode(node).getTransport().getUDDIInquiryService(node.getInquiryUrl()).getBindingDetail(getBindingDetail);</span> +<span class="nc" id="L1010"> List<BindingTemplate> bindingTemplateList = bd.getBindingTemplate();</span> +<span class="nc bnc" id="L1011" title="All 2 branches missed."> if (bindingTemplateList.size() == 0) {</span> +<span class="nc" id="L1012"> throw new ConfigurationException("Could not find ServiceBinding with key=" + bindingKey);</span> + } +<span class="nc" id="L1014"> return bindingTemplateList.get(0);</span> +<span class="nc" id="L1015"> } catch (DispositionReportFaultMessage dr) {</span> +<span class="nc" id="L1016"> DispositionReport report = DispositionReportFaultMessage.getDispositionReport(dr);</span> +<span class="nc" id="L1017"> checkForErrorInDispositionReport(report, DispositionReport.E_INVALID_KEY_PASSED, bindingKey);</span> +<span class="nc" id="L1018"> } catch (SOAPFaultException sfe) {</span> +<span class="nc" id="L1019"> DispositionReport report = DispositionReportFaultMessage.getDispositionReport(sfe);</span> +<span class="nc" id="L1020"> checkForErrorInDispositionReport(report, DispositionReport.E_INVALID_KEY_PASSED, bindingKey);</span> +<span class="nc" id="L1021"> } catch (UndeclaredThrowableException ute) {</span> +<span class="nc" id="L1022"> DispositionReport report = DispositionReportFaultMessage.getDispositionReport(ute);</span> +<span class="nc" id="L1023"> checkForErrorInDispositionReport(report, DispositionReport.E_INVALID_KEY_PASSED, bindingKey);</span> +<span class="nc" id="L1024"> }catch (Throwable t){</span> +<span class="nc" id="L1025"> throw new RemoteException("Unhandled exception", t);</span> +<span class="nc" id="L1026"> }</span> +<span class="nc" id="L1027"> return null;</span> + } + + /** + * finds a business + * + * @deprecated Use getBusinessDetail instead + * @param businessKey + * @return BusinessEntity if found, or null if not found. + * @throws RemoteException + * @throws TransportException + * @throws ConfigurationException + */ + @Deprecated + public BusinessEntity findBusiness(String businessKey) throws RemoteException, + TransportException, ConfigurationException { +<span class="nc" id="L1043"> return getBusinessDetail(businessKey, this.getUDDINode().getApiNode());</span> + } + + /** + * Looks up the BusinessEntiry in the registry, will return null if is + * not found. + * + * @deprecated Use getBusinessDetail instead + * @param businessKey - the key we are looking for + * @param node - the node which is going to be queried + * @return BusinessEntity if found, or null if not found. + * @throws RemoteException + * @throws TransportException + * @throws ConfigurationException + */ + @Deprecated + public BusinessEntity findBusiness(String businessKey, Node node) throws RemoteException, + TransportException, ConfigurationException { +<span class="nc" id="L1061"> return getBusinessDetail(businessKey, node);</span> + } + + /** + * Looks up the BusinessEntiry in the registry, will return null if is + * not found. + * + * @param businessKey - the key we are looking for + * @return BusinessEntity is found, or null if not found. + * @throws RemoteException + * @throws TransportException + * @throws ConfigurationException + */ + public BusinessEntity getBusinessDetail(String businessKey) throws RemoteException, + TransportException, ConfigurationException { +<span class="nc" id="L1076"> return getBusinessDetail(businessKey, this.getUDDINode().getApiNode());</span> + } + + /** + * Looks up the BusinessEntiry in the registry, will return null if is + * not found. + * + * @param businessKey - the key we are looking for + * @param node - the node which is going to be queried + * @return BusinessEntity is found, or null if not found. + * @throws RemoteException + * @throws TransportException + * @throws ConfigurationException + */ + public BusinessEntity getBusinessDetail(String businessKey, Node node) throws RemoteException, + TransportException, ConfigurationException { +<span class="nc" id="L1092"> GetBusinessDetail getBusinessDetail = new GetBusinessDetail();</span> +<span class="nc" id="L1093"> getBusinessDetail.getBusinessKey().add(businessKey);</span> +<span class="nc" id="L1094"> getBusinessDetail.setAuthInfo(node.getSecurityUrl());</span> + try { +<span class="nc" id="L1096"> BusinessDetail bd = getUDDINode(node).getTransport().getUDDIInquiryService(node.getInquiryUrl()).getBusinessDetail(getBusinessDetail);</span> +<span class="nc" id="L1097"> return bd.getBusinessEntity().get(0);</span> +<span class="nc" id="L1098"> } catch (DispositionReportFaultMessage dr) {</span> +<span class="nc" id="L1099"> DispositionReport report = DispositionReportFaultMessage.getDispositionReport(dr);</span> +<span class="nc" id="L1100"> checkForErrorInDispositionReport(report, DispositionReport.E_INVALID_KEY_PASSED, businessKey);</span> +<span class="nc" id="L1101"> } catch (SOAPFaultException sfe) {</span> +<span class="nc" id="L1102"> DispositionReport report = DispositionReportFaultMessage.getDispositionReport(sfe);</span> +<span class="nc" id="L1103"> checkForErrorInDispositionReport(report, DispositionReport.E_INVALID_KEY_PASSED, businessKey);</span> +<span class="nc" id="L1104"> } catch (UndeclaredThrowableException ute) {</span> +<span class="nc" id="L1105"> DispositionReport report = DispositionReportFaultMessage.getDispositionReport(ute);</span> +<span class="nc" id="L1106"> checkForErrorInDispositionReport(report, DispositionReport.E_INVALID_KEY_PASSED, businessKey);</span> +<span class="nc" id="L1107"> }catch (Throwable t){</span> +<span class="nc" id="L1108"> throw new RemoteException("Unhandled exception", t);</span> +<span class="nc" id="L1109"> }</span> +<span class="nc" id="L1110"> return null;</span> + } + + /** + * Looks up the BusinessEntity in the registry for "related" businesses. + * This means that there is a business relationship defined. This is + * also referred to as a "Publisher Assertion", + * + * @see PublisherAssertion + * @see PublisherAssertions + * @param businessKey - the key we are looking for + * @param node - the node which is going to be queried + * @return BusinessEntity is found, or null if not found. + * @throws RemoteException + * @throws TransportException + * @throws ConfigurationException + */ + public RelatedBusinessesList findRelatedBusinesses(String businessKey, Node node) throws RemoteException, + TransportException, ConfigurationException { +<span class="nc" id="L1129"> FindRelatedBusinesses findRelatedBusinesses = new FindRelatedBusinesses();</span> +<span class="nc" id="L1130"> findRelatedBusinesses.setBusinessKey(businessKey);</span> +<span class="nc" id="L1131"> findRelatedBusinesses.setAuthInfo(node.getSecurityUrl());</span> + try { +<span class="nc" id="L1133"> RelatedBusinessesList rbl = getUDDINode(node).getTransport().getUDDIInquiryService(node.getInquiryUrl()).findRelatedBusinesses(findRelatedBusinesses);</span> +<span class="nc" id="L1134"> return rbl;</span> +<span class="nc" id="L1135"> } catch (DispositionReportFaultMessage dr) {</span> +<span class="nc" id="L1136"> DispositionReport report = DispositionReportFaultMessage.getDispositionReport(dr);</span> +<span class="nc" id="L1137"> checkForErrorInDispositionReport(report, DispositionReport.E_INVALID_KEY_PASSED, businessKey);</span> +<span class="nc" id="L1138"> } catch (SOAPFaultException sfe) {</span> +<span class="nc" id="L1139"> DispositionReport report = DispositionReportFaultMessage.getDispositionReport(sfe);</span> +<span class="nc" id="L1140"> checkForErrorInDispositionReport(report, DispositionReport.E_INVALID_KEY_PASSED, businessKey);</span> +<span class="nc" id="L1141"> } catch (UndeclaredThrowableException ute) {</span> +<span class="nc" id="L1142"> DispositionReport report = DispositionReportFaultMessage.getDispositionReport(ute);</span> +<span class="nc" id="L1143"> checkForErrorInDispositionReport(report, DispositionReport.E_INVALID_KEY_PASSED, businessKey);</span> +<span class="nc" id="L1144"> }catch (Throwable t){</span> +<span class="nc" id="L1145"> throw new RemoteException("Unhandled exception", t);</span> +<span class="nc" id="L1146"> }</span> +<span class="nc" id="L1147"> return null;</span> + } + + private void checkForErrorInDispositionReport(DispositionReport report, String Error, String entityKey) { + +<span class="nc bnc" id="L1152" title="All 6 branches missed."> if (entityKey != null && report != null && report.countainsErrorCode(DispositionReport.E_INVALID_KEY_PASSED)) {</span> +<span class="nc" id="L1153"> log.info("entityKey " + entityKey + " was not found in the registry");</span> + } else { +<span class="nc bnc" id="L1155" title="All 2 branches missed."> if (report == null) {</span> +<span class="nc" id="L1156"> log.info("Missing DispositionReport");</span> + } else { +<span class="nc bnc" id="L1158" title="All 2 branches missed."> for (Result result : report.getResult()) {</span> +<span class="nc" id="L1159"> log.error(result.getErrInfo().getErrCode() + " " + result.getErrInfo().getValue());</span> +<span class="nc" id="L1160"> }</span> + } + } +<span class="nc" id="L1163"> }</span> + + /** + * kills the current auth token, aka Logout current Node + */ + public void discardAuthToken() { +<span class="nc" id="L1169"> discardAuthToken(authToken);</span> +<span class="nc" id="L1170"> }</span> + + /** + * kills the provided auth token, aka Logout + * + * @param token + */ + public void discardAuthToken(String token) { +<span class="nc bnc" id="L1178" title="All 2 branches missed."> if (token != null) {</span> + try { +<span class="nc" id="L1180"> DiscardAuthToken discardAuthToken = new DiscardAuthToken();</span> +<span class="nc" id="L1181"> discardAuthToken.setAuthInfo(token);</span> +<span class="nc" id="L1182"> getUDDINode().getTransport().getUDDISecurityService(getUDDINode().getSecurityUrl()).discardAuthToken(discardAuthToken);</span> +<span class="nc" id="L1183"> token = null;</span> +<span class="nc" id="L1184"> } catch (Exception ex) {</span> +<span class="nc" id="L1185"> log.warn("Error discarding auth token: " + ex.getMessage());</span> +<span class="nc" id="L1186"> log.debug("Error discarding auth token: " + ex.getMessage(), ex);</span> +<span class="nc" id="L1187"> }</span> + } +<span class="nc" id="L1189"> }</span> + + /** + * kills the provided auth token, aka Logout + * + * @param token + * @param endpoint + */ + public void discardAuthToken(String token, String endpoint) { +<span class="nc bnc" id="L1198" title="All 2 branches missed."> if (token != null) {</span> + try { +<span class="nc" id="L1200"> DiscardAuthToken discardAuthToken = new DiscardAuthToken();</span> +<span class="nc" id="L1201"> discardAuthToken.setAuthInfo(token);</span> +<span class="nc" id="L1202"> getUDDINode().getTransport().getUDDISecurityService(endpoint).discardAuthToken(discardAuthToken);</span> +<span class="nc" id="L1203"> token = null;</span> +<span class="nc" id="L1204"> } catch (Exception ex) {</span> +<span class="nc" id="L1205"> log.warn("Error discarding auth token: " + ex.getMessage());</span> +<span class="nc" id="L1206"> log.debug("Error discarding auth token: " + ex.getMessage(), ex);</span> +<span class="nc" id="L1207"> }</span> + } +<span class="nc" id="L1209"> }</span> + + /** + * Gets an auth token from the uddi server using the uddi auth token + * <br> + * Notice: never log auth tokens! Treat it like a password + * + * Calls + * @return getAuthToken(getUDDINode().getSecurityUrl()); + * @throws TransportException + * @throws DispositionReportFaultMessage + * @throws RemoteException + * @since 3.2 + */ + public String getAuthToken() throws TransportException, DispositionReportFaultMessage, RemoteException { +<span class="nc" id="L1224"> return getAuthToken(getUDDINode().getSecurityUrl());</span> + } + /** + * Gets an auth token from the uddi server using the uddi auth token + * <br> + * Notice: never log auth tokens! Treat it like a password + * + * notes: changed to public to have access from the subscription + * callback API 8/20/2013 AO + * + * @param endpointURL + * @return an auth token + * @throws TransportException + * @throws DispositionReportFaultMessage + * @throws RemoteException + */ + public String getAuthToken(String endpointURL) throws TransportException, DispositionReportFaultMessage, RemoteException { + //if the token is older then 10 minutes discard it, and create a new one. +<span class="nc bnc" id="L1242" title="All 8 branches missed."> if ((authToken != null && !"".equals(authToken)) && (tokenBirthDate != null && System.currentTimeMillis() > tokenBirthDate.getTime() + 600000)) {</span> +<span class="nc" id="L1243"> DiscardAuthToken discardAuthToken = new DiscardAuthToken();</span> +<span class="nc" id="L1244"> discardAuthToken.setAuthInfo(authToken);</span> +<span class="nc" id="L1245"> getUDDINode().getTransport().getUDDISecurityService(endpointURL).discardAuthToken(discardAuthToken);</span> +<span class="nc" id="L1246"> authToken = null;</span> + } +<span class="nc bnc" id="L1248" title="All 4 branches missed."> if (authToken == null || "".equals(authToken)) {</span> +<span class="nc bnc" id="L1249" title="All 4 branches missed."> if (getPublisher()==null || getPassword()==null){</span> +<span class="nc" id="L1250"> log.warn("No credentials provided for login!");</span> +<span class="nc" id="L1251"> return null;</span> + } +<span class="nc" id="L1253"> tokenBirthDate = new Date();</span> +<span class="nc" id="L1254"> GetAuthToken getAuthToken = new GetAuthToken();</span> +<span class="nc" id="L1255"> getAuthToken.setUserID(getPublisher());</span> +<span class="nc bnc" id="L1256" title="All 2 branches missed."> if (isencrypted) {</span> +<span class="nc bnc" id="L1257" title="All 2 branches missed."> if (cryptoProvider == null) {</span> +<span class="nc" id="L1258"> log.fatal("Credentials are encrypted but no cryptoProvider was defined in the config file!");</span> + } else { + try { +<span class="nc" id="L1261"> getAuthToken.setCred(CryptorFactory.getCryptor(this.cryptoProvider).decrypt(getPassword()));</span> +<span class="nc" id="L1262"> } catch (Exception ex) {</span> +<span class="nc" id="L1263"> log.fatal("Unable to decrypt credentials! sending it as is", ex);</span> +<span class="nc" id="L1264"> getAuthToken.setCred(getPassword());</span> +<span class="nc" id="L1265"> }</span> + } + } else { +<span class="nc" id="L1268"> log.warn("Hey, I couldn't help but notice that your credentials aren't encrypted. Please consider doing so");</span> +<span class="nc" id="L1269"> getAuthToken.setCred(getPassword());</span> + } +<span class="nc" id="L1271"> authToken = getUDDINode().getTransport().getUDDISecurityService(endpointURL).getAuthToken(getAuthToken).getAuthInfo();</span> + } +<span class="nc" id="L1273"> return authToken;</span> + } + + /** + * This calls a jUDDI implementation specific API call and is used to + * help configure internode communication between jUDDI servers. This is + * NOT part of the UDDI specification.<br> + * Note: this API call should only be used with secure ports (SSL/TLS) + * + * @param node + * @return a node or null if registration fails + */ + public NodeDetail saveNode(Node node) { +<span class="nc" id="L1286"> NodeDetail nodeDetail = null;</span> + try { +<span class="nc" id="L1288"> log.info("Sending Node " + node.getName() + " info to jUDDI " + getUDDINode(node).getName());</span> +<span class="nc" id="L1289"> SaveNode saveNode = new SaveNode();</span> +<span class="nc" id="L1290"> saveNode.setAuthInfo(getAuthToken(node.getSecurityUrl()));</span> +<span class="nc" id="L1291"> saveNode.getNode().add(node);</span> +<span class="nc" id="L1292"> nodeDetail = getUDDINode(node).getTransport().getJUDDIApiService(node.getJuddiApiUrl()).saveNode(saveNode);</span> +<span class="nc" id="L1293"> } catch (Exception e) {</span> +<span class="nc" id="L1294"> log.error("Unable to save node " + node.getName()</span> +<span class="nc" id="L1295"> + " ." + e.getMessage(), e);</span> +<span class="nc" id="L1296"> } catch (Throwable t) {</span> +<span class="nc" id="L1297"> log.error("Unable to save node " + node.getName()</span> +<span class="nc" id="L1298"> + " ." + t.getMessage(), t);</span> +<span class="nc" id="L1299"> }</span> +<span class="nc" id="L1300"> return nodeDetail;</span> + } + + /** + * This calls a jUDDI implementation specific API call and is used to + * help configure internode communication between jUDDI servers. This is + * NOT part of the UDDI specification.<br> + * Note: this API call should only be used with secure ports (SSL/TLS) + * + * @param senderClerk + * @return null if registration fails + */ + public ClerkDetail saveClerk(UDDIClerk senderClerk) { +<span class="nc" id="L1313"> ClerkDetail clerkDetail = null;</span> + try { +<span class="nc" id="L1315"> log.debug("Sending Clerk " + senderClerk.getName() + " info to jUDDI " + getUDDINode().getName());</span> +<span class="nc" id="L1316"> SaveClerk saveClerk = new SaveClerk();</span> +<span class="nc" id="L1317"> saveClerk.setAuthInfo(getAuthToken(senderClerk.getUDDINode().getSecurityUrl()));</span> +<span class="nc" id="L1318"> saveClerk.getClerk().add(getApiClerk());</span> +<span class="nc" id="L1319"> clerkDetail = getUDDINode().getTransport().getJUDDIApiService(senderClerk.getUDDINode().getJuddiApiUrl()).saveClerk(saveClerk);</span> +<span class="nc" id="L1320"> } catch (Exception e) {</span> +<span class="nc" id="L1321"> log.error("Unable to save clerk " + getName()</span> +<span class="nc" id="L1322"> + " ." + e.getMessage(), e);</span> +<span class="nc" id="L1323"> } catch (Throwable t) {</span> +<span class="nc" id="L1324"> log.error("Unable to save clerk " + getName()</span> +<span class="nc" id="L1325"> + " ." + t.getMessage(), t);</span> +<span class="nc" id="L1326"> }</span> +<span class="nc" id="L1327"> return clerkDetail;</span> + } + + /** + * The API Clerk is the JAXWS generated "Clerk" element that is used + * both on the jUDDI Client and on the jUDDI Web Service (not part of + * the UDDI spec). + * + * @return the config file defined clerk + */ + public Clerk getApiClerk() { +<span class="nc" id="L1338"> Clerk apiClerk = new Clerk();</span> +<span class="nc" id="L1339"> apiClerk.setName(name);</span> +<span class="nc" id="L1340"> apiClerk.setNode(uddiNode.getApiNode());</span> +<span class="nc" id="L1341"> apiClerk.setPassword(password);</span> +<span class="nc" id="L1342"> apiClerk.setPublisher(publisher);</span> +<span class="nc" id="L1343"> return apiClerk;</span> + } + + /** + * client.clerks.clerk(" + i + ")[@name] + * + * @return name + */ + public String getName() { +<span class="fc" id="L1352"> return name;</span> + } + + /** + * client.clerks.clerk(" + i + ")[@name] + * + * @param name + */ + public void setName(String name) { +<span class="fc" id="L1361"> this.name = name;</span> +<span class="fc" id="L1362"> }</span> + + /** + * client.clerks.clerk(" + i + ")[@node] reference to UDDI Node + * + * @param uddiNode + */ + public void setUDDINode(UDDINode uddiNode) { +<span class="fc" id="L1370"> this.uddiNode = uddiNode;</span> +<span class="fc" id="L1371"> }</span> + + /** + * This is the username client.clerks.clerk(" + i + ")[@publisher] + * + * @return the username + */ + public String getPublisher() { +<span class="fc" id="L1379"> return publisher;</span> + } + + /** + * This is the username client.clerks.clerk(" + i + ")[@publisher] + * + * @param publisher + */ + public void setPublisher(String publisher) { +<span class="fc" id="L1388"> this.publisher = publisher;</span> +<span class="fc" id="L1389"> }</span> + + /** + * If the password is encrypted, it will be decrypted if possible, + * otherwise the cipher text will be returned. client.clerks.clerk(" + i + * + ")[@password] + * + * @return unencrypted password + */ + public String getPassword() { +<span class="pc bpc" id="L1399" title="1 of 2 branches missed."> if (isencrypted) {</span> + try { +<span class="fc" id="L1401"> return CryptorFactory.getCryptor(cryptoProvider).decrypt(password);</span> +<span class="nc" id="L1402"> } catch (Exception ex) {</span> +<span class="nc" id="L1403"> log.fatal("Unable to decrypt the password", ex);</span> + } + } +<span class="nc" id="L1406"> return password;</span> + } + + /** + * If the password is encrypted, it cipher text is returned, otherwise + * the clear text will be returned. client.clerks.clerk(" + i + + * ")[@password] + * + * @return password as is in the config file + */ + public String getRawPassword() { +<span class="fc" id="L1417"> return password;</span> + } + + /** + * Use with caution, don't forget to set the IsEncrypted and Crypto + * provider client.clerks.clerk(" + i + ")[@password] + * + * @param password + */ + public void setPassword(String password) { +<span class="fc" id="L1427"> this.password = password;</span> +<span class="fc" id="L1428"> }</span> + + /** + * Used for the automated registration of services via WSDL2UDDI<br> + * config file: client.clerks.clerk(" + i + ").wsdl + * + * @return a WSDL array + * @see WSDL2UDDI + */ + public WSDL[] getWsdls() { +<span class="fc" id="L1438"> return wsdls;</span> + } + + /** + * Used for the automated registration of services via WSDL2UDDI<br> + * config file: client.clerks.clerk(" + i + ").wsdl + * + * @param wsdls + * @see WSDL2UDDI + */ + public void setWsdls(WSDL[] wsdls) { +<span class="fc" id="L1449"> this.wsdls = wsdls;</span> +<span class="fc" id="L1450"> }</span> + + /** + * client.clerks.clerk(" + i + ")[@cryptoProvider] + * + * @param clazz + */ + public void setCryptoProvider(String clazz) { +<span class="fc" id="L1458"> this.cryptoProvider = clazz;</span> +<span class="fc" id="L1459"> }</span> + + /** + * client.clerks.clerk(" + i + ")[@isPasswordEncrypted] default is false + * + * @param option + */ + public void setIsPasswordEncrypted(boolean option) { +<span class="fc" id="L1467"> this.isencrypted = option;</span> +<span class="fc" id="L1468"> }</span> + + /** + * client.clerks.clerk(" + i + ")[@cryptoProvider] + * + * @return may be null if not defined + */ + public String getCryptoProvider() { +<span class="fc" id="L1476"> return this.cryptoProvider;</span> + } + + /** + * client.clerks.clerk(" + i + ")[@isPasswordEncrypted] + * + * @return true/false + */ + pub
<TRUNCATED> --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
