Exemple #1
0
        /// <summary>
        /// Opensearch parameters.
        /// </summary>
        /// <returns>The search parameters.</returns>
        /// <param name="mimeType">MIME type.</param>
        /// \ingroup Series
        public virtual NameValueCollection GetOpenSearchParameters(string mimeType)
        {
            OpenSearchDescription osd = this.GetOpenSearchDescription();
            Uri uri = new Uri(OpenSearchFactory.GetOpenSearchUrlByType(osd, mimeType).Template);

            return(HttpUtility.ParseQueryString(uri.Query));
        }
Exemple #2
0
        string EntrySelfLinkTemplate(string identifier, OpenSearchDescription osd, string mimeType)
        {
            if (identifier == null)
            {
                return(null);
            }
            NameValueCollection nvc = OpenSearchFactory.GetOpenSearchParameters(OpenSearchFactory.GetOpenSearchUrlByType(osd, mimeType));

            nvc.Set("uid", string.Format("{0}", identifier));
            nvc.AllKeys.FirstOrDefault(k => {
                if (nvc[k] == "{geo:uid?}")
                {
                    nvc[k] = identifier;
                }
                var matchParamDef = System.Text.RegularExpressions.Regex.Match(nvc[k], @"^{([^?]+)\??}$");
                if (matchParamDef.Success)
                {
                    nvc.Remove(k);
                }
                return(false);
            });
            UriBuilder template = new UriBuilder(OpenSearchFactory.GetOpenSearchUrlByType(osd, mimeType).Template);

            string[] queryString = Array.ConvertAll(nvc.AllKeys, key => string.Format("{0}={1}", key, nvc[key]));
            template.Query = string.Join("&", queryString);
            return(template.ToString());
        }
Exemple #3
0
        /// <summary>
        /// Gets the local open search description.
        /// </summary>
        /// <returns>The local open search description.</returns>
        public OpenSearchDescription GetProxyOpenSearchDescription()
        {
            OpenSearchDescription OSDD = base.GetOpenSearchDescription();

            OSDD.ShortName        = "E-CEO Catalogue";
            OSDD.Attribution      = "European Space Agency";
            OSDD.Contact          = "*****@*****.**";
            OSDD.Developer        = "Terradue GeoSpatial Development Team";
            OSDD.SyndicationRight = "open";
            OSDD.AdultContent     = "false";
            OSDD.Language         = "en-us";
            OSDD.OutputEncoding   = "UTF-8";
            OSDD.InputEncoding    = "UTF-8";
            OSDD.Description      = "This Search Service performs queries in the available data series of Terradue catalogue. There are several URL templates that return the results in different formats (RDF, ATOM or KML). This search service is in accordance with the OGC 10-032r3 specification.";

            OSDD.ExtraNamespace.Add("geo", "http://a9.com/-/opensearch/extensions/geo/1.0/");
            OSDD.ExtraNamespace.Add("time", "http://a9.com/-/opensearch/extensions/time/1.0/");
            OSDD.ExtraNamespace.Add("dct", "http://purl.org/dc/terms/");

            // The new URL template list
            Hashtable           newUrls = new Hashtable();
            UriBuilder          urib;
            NameValueCollection query = OpenSearchFactory.GetOpenSearchParameters(OpenSearchFactory.GetOpenSearchUrlByType(OSDD, "application/atom+xml"));

            string[] queryString = Array.ConvertAll(query.AllKeys, key => string.Format("{0}={1}", key, query[key]));

            urib       = new UriBuilder(context.BaseUrl);
            urib.Path += string.Format("/data/collection/{0}/search", this.Identifier);

            query.Set("format", "atom");
            queryString = Array.ConvertAll(query.AllKeys, key => string.Format("{0}={1}", key, query[key]));
            urib.Query  = string.Join("&", queryString);
            newUrls.Add("application/atom+xml", new OpenSearchDescriptionUrl("application/atom+xml", urib.ToString(), "search", OSDD.ExtraNamespace));

            query.Set("format", "json");
            queryString = Array.ConvertAll(query.AllKeys, key => string.Format("{0}={1}", key, query[key]));
            urib.Query  = string.Join("&", queryString);
            newUrls.Add("application/json", new OpenSearchDescriptionUrl("application/json", urib.ToString(), "search", OSDD.ExtraNamespace));

            query.Set("format", "html");
            queryString = Array.ConvertAll(query.AllKeys, key => string.Format("{0}={1}", key, query[key]));
            urib.Query  = string.Join("&", queryString);
            newUrls.Add("text/html", new OpenSearchDescriptionUrl("application/html", urib.ToString(), "search", OSDD.ExtraNamespace));

            OSDD.Url = new OpenSearchDescriptionUrl[newUrls.Count];

            newUrls.Values.CopyTo(OSDD.Url, 0);

            return(OSDD);
        }
        public static string EntrySelfLinkTemplate(IOpenSearchResultItem item, OpenSearchDescription osd, string mimeType)
        {
            if (item == null)
            {
                return(null);
            }

            string identifier = item.Identifier;

            NameValueCollection nvc = new NameValueCollection();

            nvc.Set("q", string.Format("_id:{0}", item.Identifier));

            UriBuilder template = new UriBuilder(OpenSearchFactory.GetOpenSearchUrlByType(osd, mimeType).Template);

            string[] queryString = Array.ConvertAll(nvc.AllKeys, key => string.Format("{0}={1}", key, nvc[key]));
            template.Query = string.Join("&", queryString);
            return(template.ToString());
        }