juddi-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From alexo...@apache.org
Subject svn commit: r1545515 - in /juddi/trunk: juddi-client/src/main/java/org/apache/juddi/v3/client/config/ juddi-examples/more-uddi-samples/src/main/java/org/apache/juddi/samples/ uddi-ws/src/main/java/org/uddi/api_v3/
Date Tue, 26 Nov 2013 02:44:38 GMT
Author: alexoree
Date: Tue Nov 26 02:44:37 2013
New Revision: 1545515

URL: http://svn.apache.org/r1545515
Log:
JUDDI-633 adding example code to find by binding with qos parameters
JUDDI-711 adding default settings to prevent npe when settings are not defined.

Added:
    juddi/trunk/juddi-examples/more-uddi-samples/src/main/java/org/apache/juddi/samples/SearchByQos.java
Modified:
    juddi/trunk/juddi-client/src/main/java/org/apache/juddi/v3/client/config/ClientConfig.java
    juddi/trunk/uddi-ws/src/main/java/org/uddi/api_v3/FindBinding.java

Modified: juddi/trunk/juddi-client/src/main/java/org/apache/juddi/v3/client/config/ClientConfig.java
URL: http://svn.apache.org/viewvc/juddi/trunk/juddi-client/src/main/java/org/apache/juddi/v3/client/config/ClientConfig.java?rev=1545515&r1=1545514&r2=1545515&view=diff
==============================================================================
--- juddi/trunk/juddi-client/src/main/java/org/apache/juddi/v3/client/config/ClientConfig.java
(original)
+++ juddi/trunk/juddi-client/src/main/java/org/apache/juddi/v3/client/config/ClientConfig.java
Tue Nov 26 02:44:37 2013
@@ -368,20 +368,20 @@ public class ClientConfig 
         p.setProperty(DigSigUtil.SIGNATURE_KEYSTORE_FILETYPE, this.config.getString("client.signature.signingKeyStoreType",""));
     
         if (this.config.getBoolean("client.signature.signingKeyPassword[@isPasswordEncrypted]",
false)) {
-            String enc = this.config.getString("client.signature.signingKeyPassword");
-            String prov = this.config.getString("client.signature.signingKeyPassword[@cryptoProvider]");
+            String enc = this.config.getString("client.signature.signingKeyPassword","");
+            String prov = this.config.getString("client.signature.signingKeyPassword[@cryptoProvider]","");
             p.setProperty(DigSigUtil.SIGNATURE_KEYSTORE_KEY_PASSWORD, CryptorFactory.getCryptor(prov).decrypt(enc));
         } else {
             log.warn("Hey, you should consider encrypting your key password!");
-            p.setProperty(DigSigUtil.SIGNATURE_KEYSTORE_KEY_PASSWORD, this.config.getString("client.signature.signingKeyPassword"));
+            p.setProperty(DigSigUtil.SIGNATURE_KEYSTORE_KEY_PASSWORD, this.config.getString("client.signature.signingKeyPassword",""));
         }
         if (this.config.getBoolean("client.signature.signingKeyStoreFilePassword[@isPasswordEncrypted]",
false)) {
-            String enc = this.config.getString("client.signature.signingKeyStoreFilePassword");
-            String prov = this.config.getString("client.signature.signingKeyStoreFilePassword[@cryptoProvider]");
+            String enc = this.config.getString("client.signature.signingKeyStoreFilePassword","");
+            String prov = this.config.getString("client.signature.signingKeyStoreFilePassword[@cryptoProvider]","");
             p.setProperty(DigSigUtil.SIGNATURE_KEYSTORE_FILE_PASSWORD, CryptorFactory.getCryptor(prov).decrypt(enc));
         } else {
             log.warn("Hey, you should consider encrypting your keystore password!");
-            p.setProperty(DigSigUtil.SIGNATURE_KEYSTORE_FILE_PASSWORD, this.config.getString("client.signature.signingKeyStoreFilePassword"));
+            p.setProperty(DigSigUtil.SIGNATURE_KEYSTORE_FILE_PASSWORD, this.config.getString("client.signature.signingKeyStoreFilePassword",""));
         }
 
         p.setProperty(DigSigUtil.SIGNATURE_KEYSTORE_KEY_ALIAS, this.config.getString("client.signature.signingKeyAlias",""));
@@ -397,12 +397,12 @@ public class ClientConfig 
       
 
         if (this.config.getBoolean("client.signature.trustStorePassword[@isPasswordEncrypted]",
false)) {
-            String enc = this.config.getString("client.signature.trustStorePassword");
-            String prov = this.config.getString("client.signature.trustStorePassword[@cryptoProvider]");
+            String enc = this.config.getString("client.signature.trustStorePassword","");
+            String prov = this.config.getString("client.signature.trustStorePassword[@cryptoProvider]","");
             p.setProperty(DigSigUtil.TRUSTSTORE_FILE_PASSWORD, CryptorFactory.getCryptor(prov).decrypt(enc));
         } else {
             log.warn("Hey, you should consider encrypting your trust store password!");
-            p.setProperty(DigSigUtil.TRUSTSTORE_FILE_PASSWORD, this.config.getString("client.signature.trustStorePassword"));
+            p.setProperty(DigSigUtil.TRUSTSTORE_FILE_PASSWORD, this.config.getString("client.signature.trustStorePassword",""));
         }
 
         return p;

Added: juddi/trunk/juddi-examples/more-uddi-samples/src/main/java/org/apache/juddi/samples/SearchByQos.java
URL: http://svn.apache.org/viewvc/juddi/trunk/juddi-examples/more-uddi-samples/src/main/java/org/apache/juddi/samples/SearchByQos.java?rev=1545515&view=auto
==============================================================================
--- juddi/trunk/juddi-examples/more-uddi-samples/src/main/java/org/apache/juddi/samples/SearchByQos.java
(added)
+++ juddi/trunk/juddi-examples/more-uddi-samples/src/main/java/org/apache/juddi/samples/SearchByQos.java
Tue Nov 26 02:44:37 2013
@@ -0,0 +1,272 @@
+/*
+ * Copyright 2013 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.samples;
+
+import java.util.Properties;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+import org.apache.juddi.api_v3.AccessPointType;
+import org.apache.juddi.jaxb.PrintUDDI;
+import org.apache.juddi.v3.client.UDDIConstants;
+import org.apache.juddi.v3.client.config.UDDIClerk;
+import org.apache.juddi.v3.client.config.UDDIClient;
+import org.apache.juddi.v3.client.config.UDDIClientContainer;
+import org.apache.juddi.v3.client.ext.wsdm.WSDMQosConstants;
+import org.apache.juddi.v3.client.transport.Transport;
+import org.apache.juddi.v3_service.JUDDIApiPortType;
+import org.uddi.api_v3.AccessPoint;
+import org.uddi.api_v3.BindingDetail;
+import org.uddi.api_v3.BindingTemplate;
+import org.uddi.api_v3.BindingTemplates;
+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.Contact;
+import org.uddi.api_v3.Contacts;
+import org.uddi.api_v3.DeleteBusiness;
+import org.uddi.api_v3.Description;
+import org.uddi.api_v3.DiscoveryURL;
+import org.uddi.api_v3.DiscoveryURLs;
+import org.uddi.api_v3.FindBinding;
+import org.uddi.api_v3.FindService;
+import org.uddi.api_v3.FindTModel;
+import org.uddi.api_v3.GetAuthToken;
+import org.uddi.api_v3.GetBusinessDetail;
+import org.uddi.api_v3.IdentifierBag;
+import org.uddi.api_v3.InstanceDetails;
+import org.uddi.api_v3.KeyedReference;
+import org.uddi.api_v3.Name;
+import org.uddi.api_v3.PersonName;
+import org.uddi.api_v3.SaveBusiness;
+import org.uddi.api_v3.SaveTModel;
+import org.uddi.api_v3.ServiceInfos;
+import org.uddi.api_v3.ServiceList;
+import org.uddi.api_v3.TModel;
+import org.uddi.api_v3.TModelBag;
+import org.uddi.api_v3.TModelInstanceDetails;
+import org.uddi.api_v3.TModelInstanceInfo;
+import org.uddi.v3_service.UDDIInquiryPortType;
+import org.uddi.v3_service.UDDIPublicationPortType;
+import org.uddi.v3_service.UDDISecurityPortType;
+
+/**
+ *
+ * @author Alex O'Ree
+ */
+public class SearchByQos {
+
+    static PrintUDDI<TModel> pTModel = new PrintUDDI<TModel>();
+    static Properties properties = new Properties();
+    static String wsdlURL = null;
+    private static UDDISecurityPortType security = null;
+    private static JUDDIApiPortType juddiApi = null;
+    private static UDDIPublicationPortType publish = null;
+    private static UDDIInquiryPortType inquiry;
+
+    public static void main(String[] args) throws Exception {
+
+        // create a manager and read the config in the archive; 
+        // you can use your config file name
+        UDDIClient clerkManager = new UDDIClient("META-INF/simple-publish-uddi.xml");
+        UDDIClerk clerk = clerkManager.getClerk("default");
+        // register the clerkManager with the client side container
+        UDDIClientContainer.addClient(clerkManager);            // a ClerkManager can be
a client to multiple UDDI nodes, so 
+        // a ClerkManager can be a client to multiple UDDI nodes, so 
+        // supply the nodeName (defined in your uddi.xml.
+        // The transport can be WS, inVM, RMI etc which is defined in the uddi.xml
+        Transport transport = clerkManager.getTransport("default");
+        // Now you create a reference to the UDDI API
+        security = transport.getUDDISecurityService();
+        publish = transport.getUDDIPublishService();
+        inquiry = transport.getUDDIInquiryService();
+        //step one, get a token
+        GetAuthToken getAuthTokenRoot = new GetAuthToken();
+        getAuthTokenRoot.setUserID("uddi");
+        getAuthTokenRoot.setCred("uddi");
+
+        // Making API call that retrieves the authentication token for the 'root' user.
+        //String rootAuthToken = clerk.getAuthToken(clerk.getUDDINode().getSecurityUrl());
+        String uddi = security.getAuthToken(getAuthTokenRoot).getAuthInfo();
+
+        System.out.println("killing mary's business if it exists");
+        //first check is Mary's business exists and delete
+        DeleteIfExists("uddi:uddi.marypublisher.com:marybusinessone", uddi);
+
+        System.out.println("making mary's tmodel key gen");
+        //make the key gen since our test case uses some custom keys
+        TModel createKeyGenator = UDDIClerk.createKeyGenator("uddi.marypublisher.com", "mary
key gen", "en");
+        //clerk.register(createKeyGenator);
+        System.out.println("saving...");
+        SaveTM(createKeyGenator, uddi);
+
+
+        System.out.println("fetching business list");
+        BindingDetail before = getBindingList(uddi);
+        if (before.getBindingTemplate()== null) {
+            System.out.println("before no service returned!");
+           // before.setServiceInfos(new ServiceInfos());
+        } else {
+            System.out.println(before.getBindingTemplate().size() + " service returned before");
+        }
+
+        System.out.println("saving mary");
+        SaveMary(uddi);
+
+        BindingDetail after = getBindingList(uddi);
+        if (after.getBindingTemplate()== null) {
+            System.out.println("after no service returned!");
+            //after.setServiceInfos(new ServiceInfos());
+        } else {
+            System.out.println(after.getBindingTemplate().size() + " service returned after");
+        }
+        PrintUDDI<BindingDetail> p = new PrintUDDI<BindingDetail>();
+        if (before.getBindingTemplate().size()
+                < after.getBindingTemplate().size()) {
+            System.out.println("hey it worked as advertised, double checking");
+            /*if (CheckFor(after, "uddi:uddi.marypublisher.com:marybusinessone")) {
+                System.out.println("ok!");
+            } else {
+                System.out.println("no good!");
+            }*/
+        } else {
+
+            System.out.println("something's not right, here's the before service listing");
+            System.out.println(p.print(before));
+            System.out.println(p.print(after));
+        }
+
+    }
+
+    private static void DeleteIfExists(String key, String authInfo) {
+        GetBusinessDetail gbd = new GetBusinessDetail();
+        gbd.setAuthInfo(authInfo);
+        gbd.getBusinessKey().add(key);
+        boolean found = false;
+        try {
+            BusinessDetail businessDetail = inquiry.getBusinessDetail(gbd);
+            if (businessDetail != null
+                    && !businessDetail.getBusinessEntity().isEmpty()
+                    && businessDetail.getBusinessEntity().get(0).getBusinessKey().equals(key))
{
+                found = true;
+            }
+        } catch (Exception ex) {
+        }
+        if (found) {
+            DeleteBusiness db = new DeleteBusiness();
+            db.setAuthInfo(authInfo);
+            db.getBusinessKey().add(key);
+            try {
+                publish.deleteBusiness(db);
+            } catch (Exception ex) {
+                Logger.getLogger(FindBusinessBugHunt.class.getName()).log(Level.SEVERE, null,
ex);
+            }
+        }
+    }
+
+    
+     private static ServiceList getServiceList(String token) throws Exception {
+        FindService fb = new FindService();
+        fb.setAuthInfo(token);
+        org.uddi.api_v3.FindQualifiers fq = new org.uddi.api_v3.FindQualifiers();
+        fq.getFindQualifier().add(UDDIConstants.APPROXIMATE_MATCH);
+        fb.setFindQualifiers(fq);
+        //fb.getName().add((new Name(UDDIConstants.WILDCARD, null)));
+        
+        fb.setCategoryBag(new CategoryBag());
+        fb.getCategoryBag().getKeyedReference().add(
+                new KeyedReference(WSDMQosConstants.METRIC_FAULT_COUNT_KEY, WSDMQosConstants.METRIC_FaultCount,
"400"));
+        
+        return inquiry.findService(fb);
+    }
+     
+         
+     private static BindingDetail getBindingList(String token) throws Exception {
+        FindBinding fb = new FindBinding();
+        
+        
+        fb.setAuthInfo(token);
+        org.uddi.api_v3.FindQualifiers fq = new org.uddi.api_v3.FindQualifiers();
+        fq.getFindQualifier().add(UDDIConstants.APPROXIMATE_MATCH);
+       // fb.setFindQualifiers(fq);
+        
+        fb.setTModelBag(new TModelBag());
+        fb.getTModelBag().getTModelKey().add(WSDMQosConstants.METRIC_FAULT_COUNT_KEY);
+        return inquiry.findBinding(fb);
+    }
+
+    /**
+     * adds a business, service, bt with tmodel instance details with qos parameters
+     * @param rootAuthToken
+     * @throws Exception 
+     */
+    private static void SaveMary(String rootAuthToken) throws Exception {
+        BusinessEntity be = new BusinessEntity();
+        be.setBusinessKey("uddi:uddi.marypublisher.com:marybusinessone");
+        be.setDiscoveryURLs(new DiscoveryURLs());
+        be.getDiscoveryURLs().getDiscoveryURL().add(new DiscoveryURL("home", "http://www.marybusinessone.com"));
+        be.getDiscoveryURLs().getDiscoveryURL().add(new DiscoveryURL("serviceList", "http://www.marybusinessone.com/services"));
+        be.getName().add(new Name("Mary Doe Enterprises", "en"));
+        be.getName().add(new Name("Maria Negocio Uno", "es"));
+        be.getDescription().add(new Description("This is the description for Mary Business
One.", "en"));
+        be.setContacts(new Contacts());
+        Contact c = new Contact();
+        c.setUseType("administrator");
+        c.getPersonName().add(new PersonName("Mary Doe", "en"));
+        c.getPersonName().add(new PersonName("Juan Doe", "es"));
+        c.getDescription().add(new Description("This is the administrator of the service
offerings.", "en"));
+        be.getContacts().getContact().add(c);
+        be.setBusinessServices(new BusinessServices());
+        BusinessService bs = new BusinessService();
+        bs.setBusinessKey("uddi:uddi.marypublisher.com:marybusinessone");
+        bs.setServiceKey("uddi:uddi.marypublisher.com:marybusinessoneservice");
+        bs.getName().add(new Name("name!","en"));
+        bs.setBindingTemplates(new BindingTemplates());
+        BindingTemplate bt = new BindingTemplate();
+        bt.setAccessPoint(new AccessPoint("http://localhost", AccessPointType.WSDL_DEPLOYMENT.toString()));
+        bt.setTModelInstanceDetails(new TModelInstanceDetails());
+        TModelInstanceInfo tii = new TModelInstanceInfo();
+        tii.setTModelKey(WSDMQosConstants.METRIC_FAULT_COUNT_KEY);
+        
+        tii.setInstanceDetails(new InstanceDetails());
+        tii.getInstanceDetails().setInstanceParms("400");
+        bt.getTModelInstanceDetails().getTModelInstanceInfo().add(tii);
+        bs.getBindingTemplates().getBindingTemplate().add(bt);
+        be.getBusinessServices().getBusinessService().add(bs);
+        SaveBusiness sb = new SaveBusiness();
+        sb.setAuthInfo(rootAuthToken);
+        sb.getBusinessEntity().add(be);
+        publish.saveBusiness(sb);
+    }
+
+    private static boolean CheckFor(ServiceList list, String key) {
+        for (int i = 0; i < list.getServiceInfos().getServiceInfo().size(); i++) {
+            if (list.getServiceInfos().getServiceInfo().get(i).getServiceKey().equalsIgnoreCase(key))
{
+                return true;
+            }
+        }
+        return false;
+    }
+
+    private static void SaveTM(TModel createKeyGenator, String uddi) throws Exception {
+        SaveTModel stm = new SaveTModel();
+        stm.setAuthInfo(uddi);
+        stm.getTModel().add(createKeyGenator);
+        publish.saveTModel(stm);
+    }
+}

Modified: juddi/trunk/uddi-ws/src/main/java/org/uddi/api_v3/FindBinding.java
URL: http://svn.apache.org/viewvc/juddi/trunk/uddi-ws/src/main/java/org/uddi/api_v3/FindBinding.java?rev=1545515&r1=1545514&r2=1545515&view=diff
==============================================================================
--- juddi/trunk/uddi-ws/src/main/java/org/uddi/api_v3/FindBinding.java (original)
+++ juddi/trunk/uddi-ws/src/main/java/org/uddi/api_v3/FindBinding.java Tue Nov 26 02:44:37
2013
@@ -29,10 +29,86 @@ import javax.xml.bind.annotation.XmlType
 
 
 /**
+ * The find_binding API is used to find UDDI bindingTemplate elements. The
+ * find_binding API call returns a bindingDetail that contains zero or more
+ * bindingTemplate structures matching the criteria specified in the argument
+ * list.
+ * * <br><br>
+ * authInfo: This optional argument is an element that contains an
+ * authentication token. Registries that wish to restrict who can perform an
+ * inquiry typically require authInfo for this call.
+ * <br><br>
+ * · categoryBag: This optional argument is a list of category references in the
+ * form of keyedReference elements and keyedReferenceGroup structures. When
+ * used, the returned bindingDetail for this API will contain elements matching
+ * all of the categories passed (logical AND by default). Specifying the
+ * appropriate findQualifiers can override this behavior. Matching rules for
+ * each can be found in Section 5.1.7 Matching Rules for keyedReferences and
+ * keyedReferenceGroups.
+ * <br><br>
+ * · findQualifiers: This optional collection of findQualifier elements can be
+ * used to alter the default behavior of search functionality. See Section 5.1.4
+ * Find Qualifiers, for more information.
+ * <br><br>
+ * · find_tModel: This argument provides an alternative or additional way of
+ * specifying tModelKeys that are to be used to find the bindingTemplate
+ * elements. When specified, the find_tModel argument is treated as an embedded
+ * inquiry that is performed prior to searching for bindingTemplate elements.
+ * The tModelKeys found are those whose tModels match the criteria contained
+ * within the find_tModel element. The tModelKeys found are added to the
+ * (possibly empty) collection specified by the tModelBag prior to finding
+ * qualified bindingTemplates. Note that the authInfo argument to this embedded
+ * find_tModel argument is always ignored. Large result set behavior involving
+ * the return of a listDescription does not apply within an embedded argument.
+ * If the intermediate result set produced is too large, then the overall query
+ * will return E_resultSetTooLarge with an indication that the embedded query
+ * returned too many results. If an E_unsupported error occurs as part of
+ * processing this embedded argument, it is propagated up to the containing
+ * (calling) API.
+ * <br><br>
+ * · listHead: This optional integer value is used to indicate which item SHOULD
+ * be returned as the head of the list. The client may request a subset of the
+ * matching data by indicating which item in the resultant set constitutes the
+ * beginning of the returned data. The use of the listDescription element is
+ * mutually exclusive to the use of the truncated attribute that simply
+ * indicates a truncated result list in the Inquiry APIs. See Section 5.1.5 Use
+ * of listDescription, for a detailed description of the listHead argument.
+ * <br><br>
+ * · maxRows: This optional integer value allows the requesting program to limit
+ * the number of results returned. This argument can be used in conjunction with
+ * the listHead argument.
+ * <br><br>
+ * · serviceKey: This optional uddi_key is used to specify a particular instance
+ * of a businessService element in the registered data. Only bindings in the
+ * specific businessService data identified by the serviceKey passed are
+ * searched. When it is either omitted or specified as empty (i.e.,
+ * serviceKey=""), this indicates that all businessServices are to be searched
+ * for bindings that meet the other criteria supplied without regard to the
+ * service that provides them, and "projected" services are suppressed.
+ * <br><br>
+ * · tModelBag: This collection of tModelKey elements represent in part or in
+ * whole the technical fingerprint of the bindingTemplate structures for which
+ * the search is being performed. At least one of either a tModelBag or a
+ * find_tModel argument SHOULD be supplied, unless a categoryBag based search is
+ * being used.
+ * <br><br>
+ * If a find_tModel argument is specified (see above), it is treated as an
+ * embedded inquiry. The tModelKeys returned as a result of this embedded
+ * find_tModel argument are used as if they had been supplied in a tModelBag
+ * argument. Changing the order of the keys in the collection or specifying the
+ * same tModelKey more than once does not change the behavior of the find.
+ * <br><br>
+ * By default, only bindingTemplates that have a technical fingerprint
+ * containing all of the supplied tModelKeys match (logical AND). Specifying
+ * appropriate findQualifiers can override this behavior so that
+ * bindingTemplates with a technical fingerprint containing any of the specified
+ * tModelKeys are returned (logical OR).
+ * <br><br>
  * <p>Java class for find_binding complex type.
- * 
- * <p>The following schema fragment specifies the expected content contained within
this class.
- * 
+ *
+ * <p>The following schema fragment specifies the expected content contained
+ * within this class.
+ *
  * <pre>
  * &lt;complexType name="find_binding">
  *   &lt;complexContent>
@@ -51,8 +127,8 @@ import javax.xml.bind.annotation.XmlType
  *   &lt;/complexContent>
  * &lt;/complexType>
  * </pre>
- * 
- * 
+ *
+ *
  */
 @XmlAccessorType(XmlAccessType.FIELD)
 @XmlType(name = "find_binding", propOrder = {



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@juddi.apache.org
For additional commands, e-mail: commits-help@juddi.apache.org


Mime
View raw message