Esempio n. 1
0
        public void testCompareToDateLT()
        {
            System.Console.Out.WriteLine("TModelInstanceDetailsComparator.compare testCompareToDateLT");
            tModelInstanceInfo[] lhs = new tModelInstanceInfo[1] {
                new tModelInstanceInfo()
            };

            lhs[0].tModelKey       = ("hi");
            lhs[0].instanceDetails = new instanceDetails();
            lhs[0].instanceDetails.instanceParms = ("2002-05-30T09:30:10-06:00");
            tModelInstanceInfo[] rhs = new tModelInstanceInfo[1] {
                new tModelInstanceInfo()
            };


            rhs[0].tModelKey       = ("hi");
            rhs[0].instanceDetails = new instanceDetails();
            rhs[0].instanceDetails.instanceParms = ("2005-05-30T09:30:10-06:00");
            TModelInstanceDetailsComparator instance = new TModelInstanceDetailsComparator("hi", false, true, false);

            int result = instance.compare(lhs, rhs);

            Assert.True(result < 0, "result " + lhs[0].instanceDetails.instanceParms + " compare to " +
                        rhs[0].instanceDetails.instanceParms + " " + result);
        }
Esempio n. 2
0
        public void testCompareToDurationEQ()
        {
            System.Console.Out.WriteLine("TModelInstanceDetailsComparator.compare testCompareToDurationEQ");
            tModelInstanceInfo[] lhs = new tModelInstanceInfo[1] {
                new tModelInstanceInfo()
            };

            lhs[0].tModelKey       = ("hi");
            lhs[0].instanceDetails = new instanceDetails();
            lhs[0].instanceDetails.instanceParms = ("P5Y");
            tModelInstanceInfo[] rhs = new tModelInstanceInfo[1] {
                new tModelInstanceInfo()
            };


            rhs[0].tModelKey       = ("hi");
            rhs[0].instanceDetails = new instanceDetails();
            rhs[0].instanceDetails.instanceParms = ("P5Y");
            TModelInstanceDetailsComparator instance = new TModelInstanceDetailsComparator("hi", false, false, true);
            int result = instance.compare(lhs, rhs);

            Assert.True(result == 0, "result " + lhs[0].instanceDetails.instanceParms + " compare to " +
                        lhs[0].instanceDetails.instanceParms + " " +
                        result);
        }
Esempio n. 3
0
 public void testCompareToNulls5()
 {
     System.Console.Out.WriteLine("TModelInstanceDetailsComparator.compare nulls5");
     tModelInstanceInfo[] lhs = new tModelInstanceInfo[1] {
         new tModelInstanceInfo()
     };
     tModelInstanceInfo[] rhs = new tModelInstanceInfo[1] {
         new tModelInstanceInfo()
     };
     TModelInstanceDetailsComparator instance = new TModelInstanceDetailsComparator("hi", true, false, false);
     int expResult = 0;
     int result    = instance.compare(lhs, rhs);
 }
Esempio n. 4
0
 public void testCompareToNotFound()
 {
     System.Console.Out.WriteLine("TModelInstanceDetailsComparator.compare notfound");
     tModelInstanceInfo[] lhs = new tModelInstanceInfo[1] {
         new tModelInstanceInfo()
     };
     lhs[0].tModelKey = ("asd");
     tModelInstanceInfo[] rhs = new tModelInstanceInfo[1] {
         new tModelInstanceInfo()
     };
     rhs[0].tModelKey       = ("asd");
     rhs[0].instanceDetails = new instanceDetails();
     TModelInstanceDetailsComparator instance = new TModelInstanceDetailsComparator("hi", true, false, false);
     int expResult = 0;
     int result    = instance.compare(lhs, rhs);
 }
        public static tModelInstanceInfo[] MapTmodelInstanceDetail(uddi.apiv2.tModelInstanceInfo[] tModelInstanceInfo)
        {
            if (tModelInstanceInfo == null)
            {
                return(null);
            }
            List <tModelInstanceInfo> r = new List <tModelInstanceInfo>();

            for (int i = 0; i < tModelInstanceInfo.Length; i++)
            {
                tModelInstanceInfo x = new tModelInstanceInfo();
                x.description     = MapDescription(tModelInstanceInfo[i].description);
                x.tModelKey       = tModelInstanceInfo[i].tModelKey;
                x.instanceDetails = MapInstanceDetails(tModelInstanceInfo[i].instanceDetails);
                r.Add(x);
            }
            return(r.ToArray());
        }
Esempio n. 6
0
        /**
         * adds the typical REST tmodel references, but only if they aren't already present
         * @param bt
         * @return
         */
        public static bindingTemplate addRESTtModels(bindingTemplate bt)
        {
            List <tModelInstanceInfo> data = new List <tModelInstanceInfo>();

            if (bt.tModelInstanceDetails != null)
            {
                data.AddRange(bt.tModelInstanceDetails);
            }
            accessPoint ap = null;

            if (bt.Item is accessPoint)
            {
                ap = (accessPoint)bt.Item;
            }
            tModelInstanceInfo tModelInstanceInfo;

            if (!Exists(data, UDDIConstants.PROTOCOL_REST))
            {
                tModelInstanceInfo           = new tModelInstanceInfo();
                tModelInstanceInfo.tModelKey = (UDDIConstants.PROTOCOL_REST);
                data.Add(tModelInstanceInfo);
            }

            if (ap != null && ap.Value != null && ap.Value.StartsWith("http:"))
            {
                if (!Exists(data, UDDIConstants.TRANSPORT_HTTP))
                {
                    tModelInstanceInfo           = new tModelInstanceInfo();
                    tModelInstanceInfo.tModelKey = (UDDIConstants.TRANSPORT_HTTP);
                    data.Add(tModelInstanceInfo);
                }
            }
            if (ap != null && ap.Value != null && ap.Value.StartsWith("https:"))
            {
                if (!Exists(data, UDDIConstants.PROTOCOL_SSLv3))
                {
                    tModelInstanceInfo           = new tModelInstanceInfo();
                    tModelInstanceInfo.tModelKey = (UDDIConstants.PROTOCOL_SSLv3);
                    data.Add(tModelInstanceInfo);
                }
            }
            bt.tModelInstanceDetails = data.ToArray();
            return(bt);
        }
Esempio n. 7
0
        public void testCompareToLHSNull()
        {
            System.Console.Out.WriteLine("TModelInstanceDetailsComparator.compare testCompareToLHSNull");
            tModelInstanceInfo[] lhs = new tModelInstanceInfo[1] {
                new tModelInstanceInfo()
            };

            lhs[0].tModelKey       = ("hi");
            lhs[0].instanceDetails = new instanceDetails();
            tModelInstanceInfo[] rhs = new tModelInstanceInfo[1] {
                new tModelInstanceInfo()
            };

            rhs[0].tModelKey       = ("hi");
            rhs[0].instanceDetails = new instanceDetails();

            rhs[0].instanceDetails.instanceParms = ("xyz");
            TModelInstanceDetailsComparator instance = new TModelInstanceDetailsComparator("hi", true, false, false);
            int expResult = 0;
            int result    = instance.compare(lhs, rhs);
        }
Esempio n. 8
0
        protected bindingTemplate createWADLBinding(QName serviceQName, String portName, Uri serviceUrl, resources res)
        {
            bindingTemplate bindingTemplate = new bindingTemplate();

            // Set BusinessService Key
            bindingTemplate.serviceKey = (UDDIKeyConvention.getServiceKey(properties, serviceQName.getLocalPart()));
            List <tModelInstanceInfo> items = new List <tModelInstanceInfo>();

            if (serviceUrl != null)
            {
                // Set AccessPoint
                accessPoint accessPoint = new accessPoint();
                accessPoint.useType  = (AccessPointType.endPoint.ToString());
                accessPoint.Value    = ((serviceUrl.ToString()));
                bindingTemplate.Item = (accessPoint);
                // Set Binding Key
                String bindingKey = UDDIKeyConvention.getBindingKey(properties, serviceQName, portName, serviceUrl);
                bindingTemplate.bindingKey = (bindingKey);

                bindingTemplate.description = Common2UDDI.mapdescription(getDescription(res.doc), lang).ToArray();

                // reference wsdl:binding tModel
                tModelInstanceInfo tModelInstanceInfoBinding = new tModelInstanceInfo();
                tModelInstanceInfoBinding.tModelKey = (keyDomainURI + "binding");
                instanceDetails id = new instanceDetails();
                id.instanceParms = portName;
                tModelInstanceInfoBinding.instanceDetails = (id);

                tModelInstanceInfoBinding.description = Common2UDDI.mapdescription("The binding that this endpoint implements. " + bindingTemplate.description[0].Value
                                                                                   + " The instanceParms specifies the port local name.", lang).ToArray();
                items.Add(tModelInstanceInfoBinding);

                tModelInstanceInfo tModelInstanceInfoPortType = new tModelInstanceInfo();
                tModelInstanceInfoPortType.tModelKey   = (keyDomainURI + "rest");
                tModelInstanceInfoPortType.description = Common2UDDI.mapdescription("The wadl:Resource:base implements.", lang).ToArray();
                items.Add(tModelInstanceInfoPortType);
            }
            bindingTemplate.tModelInstanceDetails = items.ToArray();
            return(bindingTemplate);
        }
Esempio n. 9
0
        public void testCompareToDate()
        {
            System.Console.Out.WriteLine("TModelInstanceDetailsComparator.compare testCompareToDate");
            tModelInstanceInfo[] lhs = new tModelInstanceInfo[1] {
                new tModelInstanceInfo()
            };

            lhs[0].tModelKey       = ("hi");
            lhs[0].instanceDetails = new instanceDetails();
            lhs[0].instanceDetails.instanceParms = ("asdasd");
            tModelInstanceInfo[] rhs = new tModelInstanceInfo[1] {
                new tModelInstanceInfo()
            };


            rhs[0].tModelKey       = ("hi");
            rhs[0].instanceDetails = new instanceDetails();
            rhs[0].instanceDetails.instanceParms = ("asdasdasd");
            TModelInstanceDetailsComparator instance = new TModelInstanceDetailsComparator("hi", false, true, false);

            int result = instance.compare(lhs, rhs);
            //Assert.assertTrue("result " + result,result < 0);
        }
Esempio n. 10
0
        public void testCompareToNumberDataLT()
        {
            System.Console.Out.WriteLine("TModelInstanceDetailsComparator.compare testCompareToNumberDataLT");
            tModelInstanceInfo[] lhs = new tModelInstanceInfo[1] {
                new tModelInstanceInfo()
            };

            lhs[0].tModelKey       = ("hi");
            lhs[0].instanceDetails = new instanceDetails();
            lhs[0].instanceDetails.instanceParms = ("3.10");
            tModelInstanceInfo[] rhs = new tModelInstanceInfo[1] {
                new tModelInstanceInfo()
            };


            rhs[0].tModelKey       = ("hi");
            rhs[0].instanceDetails = new instanceDetails();
            rhs[0].instanceDetails.instanceParms = ("3.14");
            TModelInstanceDetailsComparator instance = new TModelInstanceDetailsComparator("hi", true, false, false);

            int result = instance.compare(lhs, rhs);

            Assert.True(result < 0, "result " + result);
        }
Esempio n. 11
0
        /**
         * adds the typical SOAP tmodel references, but only if they aren't already present
         * @param bt
         * @return
         */
        public static bindingTemplate addSOAPtModels(bindingTemplate bt)
        {
            bool          found = false;
            List <object> cbags = new List <object>();

            if (bt.categoryBag != null)
            {
                cbags.AddRange(bt.categoryBag.Items);
            }

            for (int i = 0; i < cbags.Count; i++)
            {
                if (cbags[i] is keyedReference)
                {
                    keyedReference kr = (keyedReference)cbags[i];
                    if (kr.tModelKey != null &&
                        kr.tModelKey.Equals("uddi:uddi.org:categorization:types", StringComparison.CurrentCultureIgnoreCase))
                    {
                        if (kr.keyName != null &&
                            kr.keyName.Equals("uddi-org:types:wsdl", StringComparison.CurrentCultureIgnoreCase))
                        {
                            found = true;
                        }
                    }
                }
            }
            if (!found)
            {
                cbags.Add(new keyedReference("uddi:uddi.org:categorization:types", "uddi-org:types:wsdl", "wsdlDeployment"));
            }
            if (cbags.Count > 0)
            {
                if (bt.categoryBag == null)
                {
                    bt.categoryBag = new categoryBag();
                }
                bt.categoryBag.Items = cbags.ToArray();
            }

            List <tModelInstanceInfo> data = new List <tModelInstanceInfo>();

            if (bt.tModelInstanceDetails != null)
            {
                data.AddRange(bt.tModelInstanceDetails);
            }
            accessPoint ap = null;

            if (bt.Item is accessPoint)
            {
                ap = (accessPoint)bt.Item;
            }
            tModelInstanceInfo tModelInstanceInfo;

            if (!Exists(data, UDDIConstants.PROTOCOL_SOAP))
            {
                tModelInstanceInfo           = new tModelInstanceInfo();
                tModelInstanceInfo.tModelKey = (UDDIConstants.PROTOCOL_SOAP);
                data.Add(tModelInstanceInfo);
            }

            if (ap != null && ap.Value != null && ap.Value.StartsWith("http:"))
            {
                if (!Exists(data, UDDIConstants.TRANSPORT_HTTP))
                {
                    tModelInstanceInfo           = new tModelInstanceInfo();
                    tModelInstanceInfo.tModelKey = (UDDIConstants.TRANSPORT_HTTP);
                    data.Add(tModelInstanceInfo);
                }
            }
            if (ap != null && ap.Value != null && ap.Value.StartsWith("jms:"))
            {
                if (!Exists(data, UDDIConstants.TRANSPORT_JMS))
                {
                    tModelInstanceInfo           = new tModelInstanceInfo();
                    tModelInstanceInfo.tModelKey = (UDDIConstants.TRANSPORT_JMS);
                    data.Add(tModelInstanceInfo);
                }
            }
            if (ap != null && ap.Value != null && ap.Value.StartsWith("rmi:"))
            {
                if (!Exists(data, UDDIConstants.TRANSPORT_RMI))
                {
                    tModelInstanceInfo           = new tModelInstanceInfo();
                    tModelInstanceInfo.tModelKey = (UDDIConstants.TRANSPORT_RMI);
                    data.Add(tModelInstanceInfo);
                }
            }
            if (ap != null && ap.Value != null && ap.Value.StartsWith("udp:"))
            {
                if (!Exists(data, UDDIConstants.TRANSPORT_UDP))
                {
                    tModelInstanceInfo           = new tModelInstanceInfo();
                    tModelInstanceInfo.tModelKey = (UDDIConstants.TRANSPORT_UDP);
                    data.Add(tModelInstanceInfo);
                }
            }
            if (ap != null && ap.Value != null && ap.Value.StartsWith("amqp:"))
            {
                if (!Exists(data, UDDIConstants.TRANSPORT_AMQP))
                {
                    tModelInstanceInfo           = new tModelInstanceInfo();
                    tModelInstanceInfo.tModelKey = (UDDIConstants.TRANSPORT_AMQP);
                    data.Add(tModelInstanceInfo);
                }
            }
            if (ap != null && ap.Value != null && ap.Value.StartsWith("mailto:"))
            {
                if (!Exists(data, UDDIConstants.TRANSPORT_EMAIL))
                {
                    tModelInstanceInfo           = new tModelInstanceInfo();
                    tModelInstanceInfo.tModelKey = (UDDIConstants.TRANSPORT_EMAIL);
                    data.Add(tModelInstanceInfo);
                }
            }
            if (ap != null && ap.Value != null && ap.Value.StartsWith("ftp:"))
            {
                if (!Exists(data, UDDIConstants.TRANSPORT_FTP))
                {
                    tModelInstanceInfo           = new tModelInstanceInfo();
                    tModelInstanceInfo.tModelKey = (UDDIConstants.TRANSPORT_FTP);
                    data.Add(tModelInstanceInfo);
                }
            }
            if (ap != null && ap.Value != null && ap.Value.StartsWith("https:"))
            {
                if (!Exists(data, UDDIConstants.PROTOCOL_SSLv3))
                {
                    tModelInstanceInfo           = new tModelInstanceInfo();
                    tModelInstanceInfo.tModelKey = (UDDIConstants.PROTOCOL_SSLv3);
                    data.Add(tModelInstanceInfo);
                }
            }
            if (ap != null && ap.Value != null && ap.Value.StartsWith("ftps:"))
            {
                if (!Exists(data, UDDIConstants.PROTOCOL_SSLv3))
                {
                    tModelInstanceInfo           = new tModelInstanceInfo();
                    tModelInstanceInfo.tModelKey = (UDDIConstants.PROTOCOL_SSLv3);
                    data.Add(tModelInstanceInfo);
                }
            }
            if (ap != null && ap.Value != null && ap.Value.StartsWith("jndi:"))
            {
                if (!Exists(data, UDDIConstants.TRANSPORT_JNDI_RMI))
                {
                    tModelInstanceInfo           = new tModelInstanceInfo();
                    tModelInstanceInfo.tModelKey = (UDDIConstants.TRANSPORT_JNDI_RMI);
                    data.Add(tModelInstanceInfo);
                }
            }
            bt.tModelInstanceDetails = data.ToArray();
            return(bt);
        }
        public static bindingTemplate start(UDDIClient client, String cfg_node_name, String endpoint,
                                            String keydomain, bool autoregister, String serviceKey,
                                            SignatureBehavior behavior)
        {
            if (instance == null)
            {
                instance = new SubscriptionCallbackListener();
            }

            if (ep != null && ep.State == CommunicationState.Opened)
            {
                throw new ServiceAlreadyStartedException();
            }


            Uri url = null;

            try
            {
                url = new Uri(endpoint);
            }
            catch (Exception ex)
            {
                log.warn("Callback endpoint couldn't be parsed, generating a random one: " + ex.Message);
                url = new Uri("http://" + GetHostname() + ":" + GetRandomPort(4000) + "/" + Guid.NewGuid().ToString());
            }
            endpoint = url.ToString();
            //if (endpoint == null || endpoint.equals("")) {
            //    endpoint = "http://" + GetHostname() + ":" + GetRandomPort(url.getPort()) + "/" + UUID.randomUUID().toString();

            int attempts = 5;

            if (ep == null)
            {
                while ((ep == null || ep.State != CommunicationState.Opened) && attempts > 0)
                {
                    try
                    {
                        if (endpoint.Contains("localhost"))
                        {
                            endpoint = endpoint.Replace("localhost", GetHostname());
                        }
                        ep = new ServiceHost(instance, new Uri[] { new Uri(endpoint) });
                        //ep = Endpoint.publish(endpoint, instance);
                        ep.Open();
                        callback = endpoint;
                    }
                    catch (Exception be)
                    {
                        log.info("trouble starting callback at " + endpoint + ", trying again with a random port: " + be.Message);
                        log.debug(be);
                        attempts--;
                        //if (be instanceof java.net.BindException) {
                        url      = new Uri("http://" + url.Host + ":" + GetRandomPort(url.Port) + "/" + url.PathAndQuery);
                        endpoint = url.ToString();
                    }
                }
            }
            if (ep == null || ep.State != CommunicationState.Opened)
            {
                log.warn("Unable to start callback endpoint, aborting");
                throw new SecurityException("unable to start endpoint, view previous errors for reason");
            }

            log.info("Endpoint started at " + callback);

            bindingTemplate bt = new bindingTemplate();

            bt.Item = (new accessPoint(callback, "endPoint"));

            tModelInstanceInfo instanceInfo = new tModelInstanceInfo();

            instanceInfo.tModelKey   = ("uddi:uddi.org:transport:http");
            bt.tModelInstanceDetails = new tModelInstanceInfo[] { instanceInfo };

            bt.serviceKey = (serviceKey);
            if (keydomain.EndsWith(":"))
            {
                bt.bindingKey = (keydomain + GetHostname() + "_Subscription_Callback");
            }
            else
            {
                bt.bindingKey = (keydomain + ":" + GetHostname() + "_Subscription_Callback");
            }

            if (autoregister)
            {
                bt = registerBinding(client, cfg_node_name, bt, behavior);
            }

            return(bt);
        }
Esempio n. 13
0
        private bindingTemplate parseServiceBinding(string classWithAnnotations, string lang, WebServiceBindingAttribute webServiceAnnotation, Properties properties)
        {
            bindingTemplate    bindingTemplate = null;
            Type               t = Type.GetType(classWithAnnotations, false, false);
            UDDIServiceBinding uddiServiceBinding = null;

            object[] attrib = t.GetCustomAttributes(typeof(UDDIServiceBinding), true);
            if (attrib != null && attrib.Length > 0)
            {
                uddiServiceBinding = attrib[0] as UDDIServiceBinding;
            }

            //= (UDDIServiceBinding) classWithAnnotations.getAnnotation(UDDIServiceBinding.class);
            //binding
            if (uddiServiceBinding != null)
            {
                bindingTemplate = new bindingTemplate();

                bindingTemplate.bindingKey = (TokenResolver.replaceTokens(uddiServiceBinding.bindingKey, properties));

                String bindingLang = (lang);
                if (uddiServiceBinding.lang != null)
                {
                    bindingLang = TokenResolver.replaceTokens(uddiServiceBinding.lang, properties);
                }
                description bindingDescription = new description();
                bindingDescription.lang     = (bindingLang);
                bindingDescription.Value    = (TokenResolver.replaceTokens(uddiServiceBinding.description, properties));
                bindingTemplate.description = new description[] { (bindingDescription) };

                accessPoint accessPoint = new accessPoint();
                accessPoint.useType = (AccessPointType.wsdlDeployment.ToString());
                if (!"".Equals(uddiServiceBinding.accessPointType))
                {
                    accessPoint.useType = (uddiServiceBinding.accessPointType);
                }
                if (!"".Equals(uddiServiceBinding.accessPoint))
                {
                    String endPoint = uddiServiceBinding.accessPoint;
                    endPoint = TokenResolver.replaceTokens(endPoint, properties);
                    log.debug("AccessPoint EndPoint=" + endPoint);
                    accessPoint.Value = (endPoint);
                }
                else if (webServiceAnnotation != null && webServiceAnnotation.Location != null)
                {
                    accessPoint.Value = (webServiceAnnotation.Location);
                }
                bindingTemplate.Item = (accessPoint);

                //tModelKeys on the binding
                if (!"".Equals(uddiServiceBinding.tModelKeys))
                {
                    String[] tModelKeys = uddiServiceBinding.tModelKeys.Split(',');
                    foreach (String tModelKey in tModelKeys)
                    {
                        tModelInstanceInfo instanceInfo = new tModelInstanceInfo();
                        instanceInfo.tModelKey = (tModelKey);
                        if (bindingTemplate.tModelInstanceDetails == null)
                        {
                            bindingTemplate.tModelInstanceDetails = (new tModelInstanceInfo[] { instanceInfo });
                        }
                        List <tModelInstanceInfo> l = new List <tModelInstanceInfo>();
                        l.AddRange(bindingTemplate.tModelInstanceDetails);
                        l.Add(instanceInfo);
                        bindingTemplate.tModelInstanceDetails = l.ToArray();
                    }
                }
                //categoryBag on the binding
                if (!"".Equals(uddiServiceBinding.categoryBag))
                {
                    categoryBag categoryBag = parseCategoryBag(uddiServiceBinding.categoryBag);
                    bindingTemplate.categoryBag = (categoryBag);
                }
            }
            else
            {
                log.error("Missing UDDIServiceBinding annotation in class " + classWithAnnotations);
            }
            return(bindingTemplate);
        }