GetExtensionByExtensionName() public method

public GetExtensionByExtensionName ( string resultName ) : IOpenSearchEngineExtension
resultName string
return IOpenSearchEngineExtension
        public override IOpenSearchable CreateOpenSearchable(IEnumerable<Uri> baseUrls, string queryFormatArg, OpenSearchEngine ose, IEnumerable<NetworkCredential> netCreds, bool lax)
        {
            List<IOpenSearchable> entities = new List<IOpenSearchable>();

            IOpenSearchEngineExtension ext;

            if (string.IsNullOrEmpty(queryFormatArg)) {
                ext = ose.GetExtensionByExtensionName("atom");
            } else {
                ext = ose.GetExtensionByExtensionName(queryFormatArg);
            }

            foreach (var url in baseUrls) {
                IOpenSearchable e = null;
                // QC Sentinel1 case
                if (url.Host == "qc.sentinel1.eo.esa.int")
                {
                    log.DebugFormat("QC Sentinel1 source. Trying to get the earthobservation profile");
                    e = new Sentinel1QcOpenSearchable(url, ose);
                    entities.Add(e);
                    continue;
                }
                e = OpenSearchFactory.FindOpenSearchable(ose, url, ext.DiscoveryContentType, lax);
                if (!e.DefaultMimeType.Contains("profile=http://earth.esa.int/eop")) {
                    try {
                        e = OpenSearchFactory.FindOpenSearchable(ose, url, "application/atom+xml; profile=http://earth.esa.int/eop/2.1", lax);
                    } catch (InvalidOperationException){
                        e = OpenSearchFactory.FindOpenSearchable(ose, url, "application/atom+xml", lax);
                    }
                    if (!e.DefaultMimeType.Contains("xml"))
                        throw new InvalidOperationException("No Url in the OpenSearch Description Document that could fit the EOP data model");
                }
                // Fedeo case
                if (url.Host == "fedeo.esa.int" && e.DefaultMimeType == "application/atom+xml" && e is Terradue.OpenSearch.GenericOpenSearchable) {
                    log.DebugFormat("Fedeo source. Trying to get the earthobservation profile");
                    e = FedeoOpenSearchable.CreateFrom(url, ose);
                }
                // Cwic case
                if (url.Host == "cwic.wgiss.ceos.org" && e.DefaultMimeType == "application/atom+xml" && e is Terradue.OpenSearch.GenericOpenSearchable) {
                    log.DebugFormat("Cwic source. Trying to get the earthobservation profile");
                    e = CwicOpenSearchable.CreateFrom((Terradue.OpenSearch.GenericOpenSearchable)e, ose);
                }

                entities.Add(e);
            }

            IOpenSearchable entity;

            if (entities.Count > 1) {
                entity = new MultiGenericOpenSearchable(entities, ose);
            } else {
                entity = entities[0];
            }

            return entity;
        }
Ejemplo n.º 2
0
        public static Type ResolveTypeFromRequest(HttpRequest request, OpenSearchEngine ose)
        {
            Type type = ose.Extensions.First().Value.GetTransformType();

            if (request.Params["format"] != null) {
                var osee = ose.GetExtensionByExtensionName(request.Params["format"]);
                if (osee != null) {
                    type = osee.GetTransformType();
                }
            } else {
                if (request.AcceptTypes != null) {
                    foreach (string contentType in request.AcceptTypes) {
                        var osee = ose.GetExtensionByContentTypeAbility(contentType);
                        if (osee != null) {
                            type = osee.GetTransformType();
                            break;
                        }
                    }
                }
            }

            return type;
        }
        public virtual IOpenSearchable CreateOpenSearchable(IEnumerable<Uri> baseUrls, string queryFormatArg, OpenSearchEngine ose, IEnumerable<NetworkCredential> netCreds, bool lax)
        {
            List<IOpenSearchable> entities = new List<IOpenSearchable>();
            foreach (var url in baseUrls) {
                if (string.IsNullOrEmpty(queryFormatArg))
                    try {
                        entities.Add(OpenSearchFactory.FindOpenSearchable(ose, url, null, lax));
                    } catch (Exception e) {
                        throw e;
                    } else {
                    var e = OpenSearchFactory.FindOpenSearchable(ose, url, ose.GetExtensionByExtensionName(queryFormatArg).DiscoveryContentType, lax);
                    entities.Add(e);
                }
            }

            IOpenSearchable entity;

            if (entities.Count > 1) {
                entity = new MultiGenericOpenSearchable(entities, ose);
            } else {
                entity = entities[0];
            }

            return entity;
        }