Пример #1
0
 public static keyedReference[] MapIdentifierBag(uddi.apiv2.keyedReference[] keyedReference)
 {
     if (keyedReference == null)
         return null;
     List<keyedReference> r = new List<keyedReference>();
     for (int i = 0; i < keyedReference.Length; i++)
     {
         keyedReference x = new keyedReference();
         x.tModelKey = keyedReference[i].tModelKey;
         x.keyValue = keyedReference[i].keyValue;
         x.keyName = keyedReference[i].keyName;
         r.Add(x);
     }
     return r.ToArray();
 }
Пример #2
0
 /// <summary>
 /// a simple convenience wrapper
 /// </summary>
 /// <param name="tModelKey"></param>
 /// <param name="keyName"></param>
 /// <param name="value"></param>
 /// <returns></returns>
 protected static keyedReference newKeyedReference(String tModelKey, String keyName, String value)
 {
     keyedReference typesReference = new keyedReference();
     typesReference.tModelKey = (tModelKey);
     typesReference.keyName = (keyName);
     typesReference.keyValue = (value);
     return typesReference;
 }
Пример #3
0
 private categoryBag parseCategoryBag(string categoryBagStr)
 {
     categoryBag cb = new categoryBag();
     log.debug("CategoryBag Annotation=" + cb);
     if (!"".Equals(categoryBagStr))
     {
         List<keyedReference> cbs = new List<keyedReference>();
         String[] sections = categoryBagStr.Split(',');
         foreach (String section in sections)
         {
             if (section.StartsWith(KEYED_REFERENCE))
             {
                 String keyedReferenceStr = section.Substring(KEYED_REFERENCE.Length, section.Length);
                 log.debug("Found KeyedReference=" + keyedReferenceStr);
                 String[] keyedReferences = keyedReferenceStr.Split(';');
                 keyedReference keyedReference = new keyedReference();
                 foreach (String key in keyedReferences)
                 {
                     if (key.StartsWith(KEY_NAME)) keyedReference.keyName = (key.Substring(KEY_NAME.Length, key.Length));
                     if (key.StartsWith(KEY_VALUE)) keyedReference.keyValue = (key.Substring(KEY_VALUE.Length, key.Length));
                     if (key.StartsWith(TMODEL_KEY)) keyedReference.tModelKey = (key.Substring(TMODEL_KEY.Length, key.Length));
                 }
                 log.debug("KeyedReference = " + KEY_NAME + keyedReference.keyName + " "
                                               + KEY_VALUE + keyedReference.keyValue + " "
                                               + TMODEL_KEY + keyedReference.tModelKey);
                 cbs.Add(keyedReference);
             }
             else
             {
                 log.warn("Ignoring " + section);
                 //TODO add support for KeyedReferenceGroups?
             }
         }
         cb.Items = cbs.ToArray();
     }
     return cb;
 }
Пример #4
0
        /// <summary>
        /// 
        /// A helper function to create a tModel key generator.&lt;br&gt;
        /// Why would I want a key generator? In UDDIv3, you&#39;re suppose to specify what you want the keys (unique identifiers) to be, however there&#39;s
        /// a number of naming rules associated with the keys. Generally, use the FQDN of your business or organization.
        /// Optionally, when saving an UDDI entity, you can just leave the key name blank and the server
        /// should generate one for you. It&#39;s normally a UUID that&#39;s not easy to remember. In this case, there&#39;s no need to call this method. &lt;br&gt;&lt;br&gt;
        /// In addition, no changes are made to the UDDI server. You&#39;ll have to do that one using code similar to this:
        /// &lt;pre&gt;
        /// UDDIClerk clerk = ...
        /// TModel keygen = UDDIClerk.createKeyGenator(&quot;uddi:mydomain.com:keygenerator&quot;, &quot;my domain&quot;, &quot;en&quot;);
        /// clerk.register(keygen);
        /// 
        /// </summary>
        /// <param name="partitionName">think of this as the domain, i.e. juddi.apache.org, but it can really be anything you want. This will become part of the</param>
        /// key associated with the tModel generator (uddi:juddi.apache.org:keygenerator)
        /// <param name="DescriptiveName">required. max length is 255 char</param>
        /// <param name="DescriptiveNameLanguage">optional, max length is 26 char</param>
        /// <returns>a populated tModel entity representing a tModel key generator. No changes are made to any connect UDDI service</returns>
        /// @since 3.2
        public static tModel createKeyGenator(String partitionName, String DescriptiveName, String DescriptiveNameLanguage)
        {
            if (partitionName == null || partitionName.Length == 0)
            {
                throw new ArgumentOutOfRangeException();
            }

            if (DescriptiveName == null || DescriptiveName.Length == 0)
            {
                throw new ArgumentOutOfRangeException();
            }
            if (!partitionName.StartsWith("uddi:"))
            {
                partitionName = "uddi:" + partitionName;
               // throw new ArgumentOutOfRangeException("partitionName must have a 'uddi:' prefix");

            }
            if (!partitionName.EndsWith(":keygenerator"))
            {
                partitionName = partitionName + "keygenerator";
                //throw new ArgumentOutOfRangeException("partitionName must have a ':keyGenerator' postfix");
            }
            tModel tm = new tModel();
            tm.name = new name();
            tm.name.Value = (DescriptiveName);
            tm.name.lang = (DescriptiveNameLanguage);
            tm.categoryBag = new categoryBag();
            keyedReference kr = new keyedReference();
            kr.tModelKey = (UDDIConstants.KEY_GENERATOR_TMODEL);
            kr.keyName = (UDDIConstants.KEY_GENERATOR);
            kr.keyValue = (UDDIConstants.KEY_GENERATOR_VALUE);
            tm.categoryBag.Items = new object[] { kr };
            overviewDoc
                overviewDoc = new overviewDoc();
            overviewURL overviewUrl = new overviewURL();
            overviewUrl.useType = ("text");
            overviewUrl.Value = ("http://uddi.org/pubs/uddi_v3.htm#keyGen");
            overviewDoc.overviewURLs = new overviewURL[] { overviewUrl };
            tm.overviewDoc = new overviewDoc[] { overviewDoc };
            tm.tModelKey = (partitionName.ToLower());
            return tm;
        }
Пример #5
0
        /**
         * Creates a UDDI Business Service.
         *
         * @param serviceQName This must be specified to identify the namespace of
         * the service, which is used to set the service uddi key
         * @param waldDefinition
         * @return
         */
        public businessService createBusinessService(QName serviceQName, application wadlDefinition)
        {
            log.debug("Constructing Service UDDI Information for " + serviceQName);
            businessService service = new businessService();
            // BusinessKey
            service.businessKey = (businessKey);
            // ServiceKey
            service.serviceKey = (UDDIKeyConvention.getServiceKey(properties, serviceQName.getLocalPart()));
            // Description
            String serviceDescription = properties.getProperty(Property.SERVICE_DESCRIPTION, Property.DEFAULT_SERVICE_DESCRIPTION);
            // Override with the service description from the WSDL if present
            bool lengthwarn = false;
            List<description> ds = new List<description>();
            if (wadlDefinition.doc != null)
            {

                for (int i = 0; i < wadlDefinition.doc.Length; i++)
                {

                    String locallang = lang;
                    description description = new description();
                    if (wadlDefinition.doc[i].lang != null)
                    {
                        locallang = (wadlDefinition.doc[i].lang);
                    }

                    if (locallang.Length > UDDIConstants.MAX_xml_lang_length)
                    {
                        lengthwarn = true;
                        locallang = (locallang.Substring(0, UDDIConstants.MAX_xml_lang_length - 1));
                    }

                    StringBuilder sb = new StringBuilder();
                    sb.Append(wadlDefinition.doc[i].title).Append(" ");
                    sb.Append(ContentToString(wadlDefinition.doc[i].Any));

                    ds.AddRange(Common2UDDI.mapdescription(sb.ToString(), locallang));

                }
            }
            else
            {
                ds.AddRange(Common2UDDI.mapdescription(serviceDescription, lang));

            }
            service.description = ds.ToArray();

            // Service name
            name sName = new name();
            sName.lang = (lang);
            if (wadlDefinition.doc != null && wadlDefinition.doc.Length > 0)
            {
                sName.Value = (wadlDefinition.doc[0].title);
            }
            if (sName.Value == null)
            {
                sName.Value = (serviceQName.getLocalPart());
            }
            service.name = new name[] { sName };

            categoryBag cb = new categoryBag();
            List<keyedReference> krs = new List<keyedReference>();
            String ns = serviceQName.getNamespaceURI();
            if (ns != null && ns != "")
            {
                keyedReference namespaceReference = new keyedReference(
                        "uddi:uddi.org:xml:namespace", "uddi-org:xml:namespace", ns);
                krs.Add(namespaceReference);
            }

            keyedReference serviceReference = new keyedReference(
                    "uddi:uddi.org:wadl:types", "uddi-org:wadl:types", "service");
            krs.Add(serviceReference);

            keyedReference localNameReference = new keyedReference(
                    "uddi:uddi.org:xml:localname", "uddi-org:xml:localName", serviceQName.getLocalPart());
            krs.Add(localNameReference);
            cb.Items = krs.ToArray();
            service.categoryBag = (cb);
            if (wadlDefinition.resources != null)
                for (int i = 0; i < wadlDefinition.resources.Length; i++)
                {
                    bindingTemplate bindingTemplate = createWADLBinding(serviceQName, getDocTitle(wadlDefinition.resources[i].doc),
                        new Uri(wadlDefinition.resources[i].@base), wadlDefinition.resources[i]);
                    service.bindingTemplates = new bindingTemplate[] { bindingTemplate };
                }

            if (lengthwarn)
            {
                log.warn("Some object descriptions are longer than the maximum allowed by UDDI and have been truncated.");
            }
            return service;
        }