Example #1
0
        public NameValueCollection GetOpenSearchParameters()
        {
            NameValueCollection nvc = OpenSearchFactory.GetBaseOpenSearchParameter();

            nvc.Set("uid", "{geo:uid}");
            return(nvc);
        }
Example #2
0
        public object Get(DomainSearchRequestTep request)
        {
            var context = TepWebContext.GetWebContext(PagePrivileges.EverybodyView);

            context.Open();
            context.LogInfo(this, string.Format("/domain/search GET"));

            EntityList <Domain> domains = new EntityList <Domain> (context);

            domains.Load();

            // Load the complete request
            HttpRequest httpRequest = HttpContext.Current.Request;

            OpenSearchEngine ose = MasterCatalogue.OpenSearchEngine;

            string format;

            if (Request.QueryString ["format"] == null)
            {
                format = "atom";
            }
            else
            {
                format = Request.QueryString ["format"];
            }

            Type responseType = OpenSearchFactory.ResolveTypeFromRequest(httpRequest.QueryString, httpRequest.Headers, ose);
            IOpenSearchResultCollection osr = ose.Query(domains, httpRequest.QueryString, responseType);

            OpenSearchFactory.ReplaceOpenSearchDescriptionLinks(domains, osr);

            context.Close();
            return(new HttpResult(osr.SerializeToString(), osr.ContentType));
        }
Example #3
0
        /// <summary>
        /// Get the specified request.
        /// </summary>
        /// <param name="request">Request.</param>
        public object Get(GetOpensearchSearchs request)
        {
            // This page is public

            // But its content will be adapted accrding to context (user id, ...)

            // Load the complete request
            HttpRequest httpRequest            = HttpContext.Current.Request;
            var         context                = TepWebContext.GetWebContext(PagePrivileges.EverybodyView);
            IOpenSearchResultCollection result = null;

            try{
                context.Open();
                context.LogInfo(this, string.Format("/data/collection/search GET"));

                EntityList <Collection> collections = new EntityList <Collection>(context);
                collections.AddSort("Name", SortDirection.Ascending);
                OpenSearchEngine ose = MasterCatalogue.OpenSearchEngine;

                Type responseType = OpenSearchFactory.ResolveTypeFromRequest(httpRequest.QueryString, httpRequest.Headers, ose);
                result = ose.Query(collections, httpRequest.QueryString, responseType);

                context.Close();
            }catch (Exception e) {
                context.LogError(this, e.Message, e);
                context.Close();
                throw e;
            }

            return(new HttpResult(result.SerializeToString(), result.ContentType));
        }
Example #4
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());
        }
        public System.Collections.Specialized.NameValueCollection GetOpenSearchParameters(string mimeType)
        {
            NameValueCollection nvc = OpenSearchFactory.GetBaseOpenSearchParameter();

            nvc.Set("uid", "{geo:uid?}");
            return(nvc);
        }
Example #6
0
        public object Get(CommunitySearchRequestTep request)
        {
            var context = TepWebContext.GetWebContext(PagePrivileges.EverybodyView);

            context.Open();
            context.LogInfo(this, string.Format("/community/search GET"));

            CommunityCollection domains = new CommunityCollection(context);

            domains.UserStatus = Request.QueryString != null ? Request.QueryString["status"] : null;
            domains.SetFilter("Kind", (int)DomainKind.Public + "," + (int)DomainKind.Private + "," + (int)DomainKind.Hidden);

            // Load the complete request
            HttpRequest      httpRequest  = HttpContext.Current.Request;
            OpenSearchEngine ose          = MasterCatalogue.OpenSearchEngine;
            Type             responseType = OpenSearchFactory.ResolveTypeFromRequest(httpRequest.QueryString, httpRequest.Headers, ose);

            // the opensearch cache system uses the query parameters
            // we add to the parameters the filters added to the load in order to avoir wrong cache
            // we use 't2-' in order to not interfer with possibly used query parameters
            var qs = new NameValueCollection(Request.QueryString);

            foreach (var filter in domains.FilterValues)
            {
                qs.Add("t2-" + filter.Key.FieldName, filter.Value.ToString());
            }

            IOpenSearchResultCollection osr = ose.Query(domains, httpRequest.QueryString, responseType);

            OpenSearchFactory.ReplaceOpenSearchDescriptionLinks(domains, osr);

            context.Close();
            return(new HttpResult(osr.SerializeToString(), osr.ContentType));
        }
Example #7
0
        public object Get(ServiceServiceTep request)
        {
            var context = TepWebContext.GetWebContext(PagePrivileges.UserView);

            context.Open();
            EntityList <Terradue.Portal.Service> services = new EntityList <Terradue.Portal.Service>(context);

            services.Load();

            // Load the complete request
            HttpRequest httpRequest = HttpContext.Current.Request;

            OpenSearchEngine ose = MasterCatalogue.OpenSearchEngine;

            string format;

            if (Request.QueryString["format"] == null)
            {
                format = "atom";
            }
            else
            {
                format = Request.QueryString["format"];
            }

            Type responseType = OpenSearchFactory.ResolveTypeFromRequest(httpRequest.QueryString, httpRequest.Headers, ose);
            IOpenSearchResultCollection osr = ose.Query(services, httpRequest.QueryString, responseType);

            context.Close();

            return(new HttpResult(osr.SerializeToString(), osr.ContentType));
        }
Example #8
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));
        }
Example #9
0
        public object Get(UserSearchRequest request)
        {
            var context = TepWebContext.GetWebContext(PagePrivileges.UserView);

            context.Open();
            context.LogInfo(this, string.Format("/user/search GET"));

            EntityList <UserTep> users = new EntityList <UserTep> (context);

            users.AddSort("Identifier", SortDirection.Ascending);

            // Load the complete request
            HttpRequest httpRequest = HttpContext.Current.Request;

            OpenSearchEngine ose = MasterCatalogue.OpenSearchEngine;

            string format;

            if (Request.QueryString ["format"] == null)
            {
                format = "atom";
            }
            else
            {
                format = Request.QueryString ["format"];
            }

            Type responseType = OpenSearchFactory.ResolveTypeFromRequest(httpRequest.QueryString, httpRequest.Headers, ose);
            IOpenSearchResultCollection osr = ose.Query(users, httpRequest.QueryString, responseType);

            OpenSearchFactory.ReplaceOpenSearchDescriptionLinks(users, osr);

            context.Close();
            return(new HttpResult(osr.SerializeToString(), osr.ContentType));
        }
Example #10
0
        /// <summary>
        /// Get the specified request.
        /// </summary>
        /// <param name="request">Request.</param>
        public object Get(DataPackageSearchDefaultRequestTep request)
        {
            var context = TepWebContext.GetWebContext(PagePrivileges.EverybodyView);
            IOpenSearchResultCollection result = null;

            try {
                context.Open();
                context.LogInfo(this, string.Format("/data/package/default/search GET"));
                Terradue.Tep.DataPackage datapackage = DataPackage.GetTemporaryForCurrentUser(context);
                datapackage.SetOpenSearchEngine(MasterCatalogue.OpenSearchEngine);

                OpenSearchEngine ose = MasterCatalogue.OpenSearchEngine;

                Type responseType = OpenSearchFactory.ResolveTypeFromRequest(HttpContext.Current.Request.QueryString, HttpContext.Current.Request.Headers, ose);

                List <Terradue.OpenSearch.IOpenSearchable> osentities = new List <Terradue.OpenSearch.IOpenSearchable>();
                osentities.AddRange(datapackage.GetOpenSearchableArray());

                var settings = MasterCatalogue.OpenSearchFactorySettings;
                MultiGenericOpenSearchable multiOSE = new MultiGenericOpenSearchable(osentities, settings);
                result = ose.Query(multiOSE, Request.QueryString, responseType);

                MasterCatalogue.ReplaceSelfLinksFormat(result, Request.QueryString);

                context.Close();
            } catch (Exception e) {
                context.LogError(this, e.Message, e);
                context.Close();
                throw e;
            }

            return(new HttpResult(result.SerializeToString(), result.ContentType));
        }
Example #11
0
        public object Get(SearchRssNews request)
        {
            var context = TepWebContext.GetWebContext(PagePrivileges.EverybodyView);
            IOpenSearchResultCollection result = null;

            try{
                context.Open();
                context.LogInfo(this, string.Format("/news/rss/search GET"));

                // Load the complete request
                HttpRequest httpRequest = HttpContext.Current.Request;

                OpenSearchEngine ose = MasterCatalogue.OpenSearchEngine;

                Type type = OpenSearchFactory.ResolveTypeFromRequest(httpRequest.QueryString, httpRequest.Headers, ose);

                EntityList <RssNews> rss = new EntityList <RssNews>(context);
                rss.Load();

                var settings = MasterCatalogue.OpenSearchFactorySettings;
                MultiGenericOpenSearchable multiOSE = new MultiGenericOpenSearchable(rss.Cast <IOpenSearchable>().ToList(), settings);

                result = ose.Query(multiOSE, httpRequest.QueryString, type);

                context.Close();
            }catch (Exception e) {
                context.LogError(this, e.Message, e);
                context.Close();
                throw e;
            }

            return(new HttpResult(result.SerializeToString(), result.ContentType));
        }
Example #12
0
        public object Get(ActivitySearchRequestTep request)
        {
            var context = TepWebContext.GetWebContext(PagePrivileges.UserView);

            context.AccessLevel = EntityAccessLevel.Administrator;
            context.Open();
            context.LogInfo(this, string.Format("/activity/search GET nologin='******'", request.nologin));

            EntityList <ActivityTep> activities = new EntityList <ActivityTep>(context);

            activities.AddSort("CreationTime", SortDirection.Descending);

            // Load the complete request
            HttpRequest      httpRequest = HttpContext.Current.Request;
            OpenSearchEngine ose         = MasterCatalogue.OpenSearchEngine;

            Type responseType = OpenSearchFactory.ResolveTypeFromRequest(httpRequest.QueryString, httpRequest.Headers, ose);
            IOpenSearchResultCollection osr = ose.Query(activities, httpRequest.QueryString, responseType);

            activities.Identifier = "activity";

            OpenSearchFactory.ReplaceOpenSearchDescriptionLinks(activities, osr);

            context.Close();
            return(new HttpResult(osr.SerializeToString(), osr.ContentType));
        }
        public OpenSearchDescription GetProxyOpenSearchDescription()
        {
            OpenSearchDescription osd = new OpenSearchDescription();

            osd.ShortName        = string.IsNullOrEmpty(Wpsjob.Name) ? Wpsjob.Identifier : Wpsjob.Name;
            osd.Attribution      = "European Space Agency";
            osd.Contact          = "*****@*****.**";
            osd.Developer        = "Terradue GeoSpatial Development Team";
            osd.SyndicationRight = "open";
            osd.AdultContent     = "false";
            osd.Language         = "en-us";
            osd.OutputEncoding   = "UTF-8";
            osd.InputEncoding    = "UTF-8";
            osd.Description      = "This Search Service performs queries in the available results of a job process. 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.";

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

            var searchExtensions = MasterCatalogue.OpenSearchEngine.Extensions;
            List <OpenSearchDescriptionUrl> urls = new List <OpenSearchDescriptionUrl>();

            NameValueCollection parameters = GetOpenSearchParameters(this.DefaultMimeType);

            UriBuilder searchUrl = new UriBuilder(context.BaseUrl);

            searchUrl.Path += string.Format("/job/wps/{0}/products/search", Wpsjob.Identifier);
            NameValueCollection queryString = HttpUtility.ParseQueryString("");

            parameters.Add("key", this.Wpsjob.AccessKey);
            parameters.AllKeys.FirstOrDefault(k =>
            {
                queryString.Add(k, parameters[k]);
                return(false);
            });

            List <OpenSearchDescriptionUrlParameter> paramdesc = OpenSearchFactory.GetDefaultParametersDescription(10);

            foreach (int code in searchExtensions.Keys)
            {
                queryString.Set("format", searchExtensions[code].Identifier);
                string[] queryStrings = Array.ConvertAll(queryString.AllKeys, key => string.Format("{0}={1}", key, queryString[key]));
                searchUrl.Query = string.Join("&", queryStrings);
                var url = new OpenSearchDescriptionUrl(searchExtensions[code].DiscoveryContentType,
                                                       searchUrl.ToString(),
                                                       "results", osd.ExtraNamespace);
                url.Parameters = paramdesc.ToArray();
                urls.Add(url);
            }
            UriBuilder descriptionUrl = new UriBuilder(context.BaseUrl);

            descriptionUrl.Path += string.Format("/job/wps/{0}/products/description", Wpsjob.Identifier);
            urls.Add(new OpenSearchDescriptionUrl("application/opensearchdescription+xml",
                                                  searchUrl.ToString(),
                                                  "self", osd.ExtraNamespace));
            osd.Url = urls.ToArray();

            return(osd);
        }
        public virtual NameValueCollection GetOpenSearchParameters()
        {
            NameValueCollection nvc = OpenSearchFactory.GetBaseOpenSearchParameter();

            nvc.Add("author", "{t2:author?}");
            nvc.Add("domain", "{t2:domain?}");
            return(nvc);
        }
Example #15
0
 /// <summary>
 /// Gets the open search parameters.
 /// </summary>
 /// <returns>The open search parameters.</returns>
 /// <param name="mimeType">MIME type.</param>
 public NameValueCollection GetOpenSearchParameters(string mimeType)
 {
     if (mimeType != "application/atom+xml")
     {
         return(null);
     }
     return(OpenSearchFactory.GetBaseOpenSearchParameter());
 }
Example #16
0
        public new NameValueCollection GetOpenSearchParameters()
        {
            var parameters = OpenSearchFactory.GetBaseOpenSearchParameter();

            parameters.Set("grouped", "{t2:grouped?}");
            parameters.Set("tag", "{t2:tag?}");
            return(parameters);
        }
Example #17
0
        public object Get(SearchNews request)
        {
            var context = TepWebContext.GetWebContext(PagePrivileges.EverybodyView);
            IOpenSearchResultCollection result = null;

            try{
                context.Open();
                context.LogInfo(this, string.Format("/news/search GET"));

                // Load the complete request
                HttpRequest httpRequest = HttpContext.Current.Request;

                OpenSearchEngine ose = MasterCatalogue.OpenSearchEngine;

                Type type = OpenSearchFactory.ResolveTypeFromRequest(httpRequest.QueryString, httpRequest.Headers, ose);

                List <Terradue.OpenSearch.IOpenSearchable> osentities = new List <Terradue.OpenSearch.IOpenSearchable>();

                //try{
                //    EntityList<Article> articles = new EntityList<Article>(context);
                //    articles.Load();
                //    osentities.Add(articles);
                //}catch(Exception){}

                try{
                    var twitters = TwitterNews.LoadTwitterCollection(context);
                    osentities.Add(twitters);
                }catch (Exception) {}

                try{
                    EntityList <RssNews> rsss = new EntityList <RssNews>(context);
                    rsss.Load();
                    if (rsss != null)
                    {
                        foreach (RssNews rss in rsss)
                        {
                            osentities.Add(rss);
                        }
                    }
                }catch (Exception) {}

                var settings = MasterCatalogue.OpenSearchFactorySettings;
                MultiGenericOpenSearchable multiOSE = new MultiGenericOpenSearchable(osentities, settings);

                result = ose.Query(multiOSE, httpRequest.QueryString, type);


                context.Close();
            }catch (Exception e) {
                context.LogError(this, e.Message, e);
                context.Close();
                throw e;
            }

            return(new HttpResult(result.SerializeToString(), result.ContentType));
        }
Example #18
0
        public static void ProxyOpenSearchResult(IOpenSearchable entity, OpenSearchRequest request, IOpenSearchResultCollection osr)
        {
            if (!(entity is IProxiedOpenSearchable))
            {
                return;
            }

            OpenSearchFactory.ReplaceSelfLinks(entity, request, osr, Terradue.Metadata.EarthObservation.OpenSearch.Helpers.OpenSearchParametersHelper.EntrySelfLinkTemplate);
            OpenSearchFactory.ReplaceOpenSearchDescriptionLinks(entity, osr);
        }
        //---------------------------------------------------------------------------------------------------------------------

        public virtual System.Collections.Specialized.NameValueCollection GetOpenSearchParameters(string mimeType)
        {
            if (mimeType != "application/atom+xml")
            {
                return(null);
            }
            var parameters = OpenSearchFactory.MergeOpenSearchParameters(GetOpenSearchableArray(), mimeType);

            parameters.Set("grouped", "{t2:grouped?}");
            return(parameters);
        }
Example #20
0
        public System.Collections.Specialized.NameValueCollection GetOpenSearchParameters(string mimeType)
        {
            var osdic = OpenSearchFactory.GetBaseOpenSearchParameter();

            osdic.Add("uid", "{geo:uid?}");
            osdic.Add("start", "{time:start?}");
            osdic.Add("stop", "{time:end?}");
            osdic.Add("ills", "{t2:ills?}");
            osdic.Add("auxtype", "{t2:auxtype?}");
            osdic.Add("orbits", "{t2:orbits?}");
            return(osdic);
        }
Example #21
0
        /// <summary>
        /// Get the specified request.
        /// </summary>
        /// <param name="request">Request.</param>
        public object Get(DataPackagesSearchRequest request)
        {
            var context = TepWebContext.GetWebContext(PagePrivileges.EverybodyView);
            IOpenSearchResultCollection result = null;

            try {
                context.Open();
                context.LogInfo(this, string.Format("/data/package/search GET"));

                EntityList <Terradue.Tep.DataPackage> datapackages = new EntityList <DataPackage>(context);
                if (!string.IsNullOrEmpty(request.Key))
                {
                    UserTep user = UserTep.FromApiKey(context, request.Key);
                    datapackages.UserId = user.Id;
                    context.AccessLevel = EntityAccessLevel.Privilege;
                }
                datapackages.SetFilter("Kind", RemoteResourceSet.KINDRESOURCESETNORMAL.ToString());

                // Load the complete request
                HttpRequest      httpRequest = HttpContext.Current.Request;
                OpenSearchEngine ose         = MasterCatalogue.OpenSearchEngine;

                // the opensearch cache system uses the query parameters
                // we add to the parameters the filters added to the load in order to avoir wrong cache
                // we use 't2-' in order to not interfer with possibly used query parameters
                var qs = new NameValueCollection(Request.QueryString);
                foreach (var filter in datapackages.FilterValues)
                {
                    qs.Add("t2-" + filter.Key.FieldName, filter.Value.ToString());
                }

                if (qs["visibility"] != null && qs["visibility"] != "all")
                {
                    datapackages.AccessLevel = EntityAccessLevel.Privilege;
                }

                if (context.UserLevel == UserLevel.Administrator && (qs["visibility"] == null || qs["visibility"] != "owned"))
                {
                    datapackages.SetFilter("Identifier", "!_index_*,!_series_*,!_products_*");
                }

                Type type = OpenSearchFactory.ResolveTypeFromRequest(httpRequest.QueryString, httpRequest.Headers, ose);
                result = ose.Query(datapackages, qs, type);

                context.Close();
            } catch (Exception e) {
                context.LogError(this, e.Message, e);
                context.Close();
                throw e;
            }

            return(new HttpResult(result.SerializeToString(), result.ContentType));
        }
Example #22
0
        private IOpenSearchResultCollection GetActivityResultCollection(EntityList <Activity> activities)
        {
            // Load the complete request
            HttpRequest      httpRequest = HttpContext.Current.Request;
            OpenSearchEngine ose         = MasterCatalogue.OpenSearchEngine;

            Type responseType = OpenSearchFactory.ResolveTypeFromRequest(httpRequest.QueryString, httpRequest.Headers, ose);
            IOpenSearchResultCollection osr = ose.Query(activities, httpRequest.QueryString, responseType);

            OpenSearchFactory.ReplaceOpenSearchDescriptionLinks(activities, osr);

            return(osr);
        }
Example #23
0
        //---------------------------------------------------------------------------------------------------------------------

        /// <summary>
        /// Gets the web server open search description.
        /// </summary>
        /// <returns>The web server open search description.</returns>
        public OpenSearchDescription GetWebServerOpenSearchDescription()
        {
            OpenSearchDescription OSDD = new OpenSearchDescription();

            OSDD.ShortName        = "Terradue 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 packages of Tep 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 = new NameValueCollection();

            string[] queryString;

            urib       = new UriBuilder(context.BaseUrl);
            urib.Path += "/data/collection/search";
            query.Add(OpenSearchFactory.GetBaseOpenSearchParameter());

            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);
        }
Example #24
0
        public NameValueCollection GetOpenSearchParameters(string mimeType)
        {
            var nvc = OpenSearchFactory.GetBaseOpenSearchParameter();

            //add EntityCollections parameters
            nvc.Set("id", "{t2:uid?}");
            nvc.Set("sl", "{t2:sl?}");
            nvc.Set("disableCache", "{t2:cache?}");
            nvc.Set("domain", "{t2:domain?}");
            nvc.Set("author", "{t2:author?}");
            nvc.Set("visibility", "{t2:visibility?}");
            nvc.Add("correlatedTo", "{cor:with?}");
            return(nvc);
        }
        //---------------------------------------------------------------------------------------------------------------------

        public virtual IOpenSearchable[] GetOpenSearchableArray()
        {
            List <IOpenSearchable> osResources = new List <IOpenSearchable>(Resources.Count);

            var settings = new OpenSearchableFactorySettings(ose);

            settings.MergeFilters = Terradue.Metadata.EarthObservation.Helpers.GeoTimeOpenSearchHelper.MergeGeoTimeFilters;

            foreach (RemoteResource res in Resources)
            {
                var entity = OpenSearchFactory.FindOpenSearchable(settings, new Uri(res.Location));
                osResources.Add(entity);
            }

            return(osResources.ToArray());
        }
Example #26
0
        public object Put(WpsJobUpdateRequestTep request)
        {
            var context = TepWebContext.GetWebContext(PagePrivileges.UserView);

            context.Open();
            context.LogInfo(this, string.Format("/job/wps PUT Id='{0}'", request.Id));

            WpsJob job = WpsJob.FromIdentifier(context, request.Identifier);

            try{
                job.Name = request.Name;
                job.Store();
                context.LogDebug(this, string.Format("WpsJob '{0}' updated", job.Name));
            }catch (Exception e) {
                throw e;
            }

            EntityList <WpsJob> wpsjobs = new EntityList <WpsJob>(context);

            wpsjobs.ItemVisibility = EntityItemVisibility.OwnedOnly;
            wpsjobs.Load();

            OpenSearchEngine ose = MasterCatalogue.OpenSearchEngine;

            string format;

            if (Request.QueryString["format"] == null)
            {
                format = "atom";
            }
            else
            {
                format = Request.QueryString["format"];
            }

            NameValueCollection nvc = new NameValueCollection();

            nvc.Add("id", job.Identifier);

            Type responseType = OpenSearchFactory.ResolveTypeFromRequest(HttpContext.Current.Request.QueryString, HttpContext.Current.Request.Headers, ose);
            IOpenSearchResultCollection osr = ose.Query(wpsjobs, nvc, responseType);

            OpenSearchFactory.ReplaceOpenSearchDescriptionLinks(wpsjobs, osr);

            context.Close();
            return(new HttpResult(osr.SerializeToString(), osr.ContentType));
        }
        public new NameValueCollection GetOpenSearchParameters()
        {
            var parameters = OpenSearchFactory.GetBaseOpenSearchParameter();

            parameters.Add("id", "{geo:uid?}");
            parameters.Add("wpsUrl", "{t2:url?}");
            parameters.Add("pid", "{t2:id?}");
            parameters.Add("cat", "{dct:subject?}");
            parameters.Add("sandbox", "{t2:cloudsandbox?}");
            parameters.Add("cloud", "{t2:cloud?}");
            parameters.Add("hostname", "{t2:cloudhostname?}");
            parameters.Add("tag", "{t2:cloudtag?}");
            parameters.Add("available", "{t2:available?}");
            parameters.Add("cr", "{t2:wpsprovider?}");
            parameters.Add("version", "{t2:version?}");
            return(parameters);
        }
Example #28
0
        public object Get(WpsJobSearchRequestTep request)
        {
            var context = TepWebContext.GetWebContext(PagePrivileges.EverybodyView);

            context.Open();
            context.LogInfo(this, string.Format("/job/wps/search GET"));

            EntityList <WpsJob> wpsjobs = new EntityList <WpsJob>(context);

            wpsjobs.AddSort("Id", SortDirection.Descending);
            wpsjobs.IncludeOwnerFieldsInSearch = true;

            // Load the complete request
            HttpRequest httpRequest = HttpContext.Current.Request;
            var         qs          = new NameValueCollection(httpRequest.QueryString);

            OpenSearchEngine ose = MasterCatalogue.OpenSearchEngine;

            if (qs["visibility"] != null && qs["visibility"] != "all")
            {
                wpsjobs.AccessLevel = EntityAccessLevel.Privilege;
            }

            if (!string.IsNullOrEmpty(qs["key"]))
            {
                try{
                    UserTep user = UserTep.FromApiKey(context, qs["key"]);
                    wpsjobs.UserId      = user.Id;
                    context.AccessLevel = EntityAccessLevel.Privilege;
                }catch (Exception) {}
            }

            if (string.IsNullOrEmpty(qs["id"]) && string.IsNullOrEmpty(qs["uid"]) && string.IsNullOrEmpty(qs["archivestatus"]))
            {
                qs.Set("archivestatus", (int)WpsJobArchiveStatus.NOT_ARCHIVED + "");
            }

            Type responseType = OpenSearchFactory.ResolveTypeFromRequest(httpRequest.QueryString, httpRequest.Headers, ose);
            IOpenSearchResultCollection osr = ose.Query(wpsjobs, qs, responseType);

            OpenSearchFactory.ReplaceOpenSearchDescriptionLinks(wpsjobs, osr);
//            OpenSearchFactory.ReplaceSelfLinks(wpsjobs, httpRequest.QueryString, osr.Result, EntrySelfLinkTemplate);

            context.Close();
            return(new HttpResult(osr.SerializeToString(), osr.ContentType));
        }
Example #29
0
        private Dictionary <string, string> InitializeParametersKeywordsTable()
        {
            Dictionary <string, string> table = OpenSearchFactory.GetBaseOpenSearchParametersKeywordsTable();

            table["update"]     = "{http://purl.org/dc/terms/}modified";
            table["updated"]    = "{http://purl.org/dc/terms/}modified";
            table["modified"]   = "{http://purl.org/dc/terms/}modified";
            table["do"]         = "{http://www.terradue.com/opensearch}downloadOrigin";
            table["from"]       = "{http://a9.com/-/opensearch/extensions/eo/1.0/}accessedFrom";
            table["start"]      = "{http://a9.com/-/opensearch/extensions/time/1.0/}start";
            table["stop"]       = "{http://a9.com/-/opensearch/extensions/time/1.0/}end";
            table["end"]        = "{http://a9.com/-/opensearch/extensions/time/1.0/}end";
            table["trel"]       = "{http://a9.com/-/opensearch/extensions/time/1.0/}relation";
            table["box"]        = "{http://a9.com/-/opensearch/extensions/geo/1.0/}box";
            table["bbox"]       = "{http://a9.com/-/opensearch/extensions/geo/1.0/}box";
            table["geom"]       = "{http://a9.com/-/opensearch/extensions/geo/1.0/}geometry";
            table["geometry"]   = "{http://a9.com/-/opensearch/extensions/geo/1.0/}geometry";
            table["uid"]        = "{http://a9.com/-/opensearch/extensions/geo/1.0/}uid";
            table["id"]         = "{http://purl.org/dc/terms/}identifier";
            table["rel"]        = "{http://a9.com/-/opensearch/extensions/geo/1.0/}relation";
            table["cat"]        = "{http://purl.org/dc/terms/}subject";
            table["pt"]         = "{http://a9.com/-/opensearch/extensions/eo/1.0/}productType";
            table["pc"]         = "{http://a9.com/-/opensearch/extensions/eo/1.0/}processingCenter";
            table["pl"]         = "{http://a9.com/-/opensearch/extensions/eo/1.0/}processingLevel";
            table["psn"]        = "{http://a9.com/-/opensearch/extensions/eo/1.0/}platform";
            table["psi"]        = "{http://a9.com/-/opensearch/extensions/eo/1.0/}platformSerialIdentifier";
            table["polc"]       = "{http://a9.com/-/opensearch/extensions/eo/1.0/}polarizationChannels";
            table["isn"]        = "{http://a9.com/-/opensearch/extensions/eo/1.0/}instrument";
            table["sm"]         = "{http://a9.com/-/opensearch/extensions/eo/1.0/}sensorType";
            table["sensor"]     = "{http://a9.com/-/opensearch/extensions/eo/1.0/}sensorMode";
            table["st"]         = "{http://a9.com/-/opensearch/extensions/eo/1.0/}sensorType";
            table["od"]         = "{http://a9.com/-/opensearch/extensions/eo/1.0/}orbitDirection";
            table["ot"]         = "{http://a9.com/-/opensearch/extensions/eo/1.0/}orbitType";
            table["title"]      = "{http://a9.com/-/opensearch/extensions/eo/1.0/}title";
            table["track"]      = "{http://a9.com/-/opensearch/extensions/eo/1.0/}track";
            table["frame"]      = "{http://a9.com/-/opensearch/extensions/eo/1.0/}frame";
            table["swath"]      = "{http://a9.com/-/opensearch/extensions/eo/1.0/}swathIdentifier";
            table["stst"]       = "{http://a9.com/-/opensearch/extensions/eo/1.0/}statusSubType";
            table["timeliness"] = "{http://a9.com/-/opensearch/extensions/eo/1.0/}timeliness";
            table["cc"]         = "{http://a9.com/-/opensearch/extensions/eo/1.0/}cloudCover";
            table["lc"]         = "{http://www.terradue.com/opensearch}landCover";
            table["dcg"]        = "{http://www.terradue.com/opensearch}doubleCheckGeometry";
            return(table);
        }
Example #30
0
        /// <summary>
        /// Get the specified request.
        /// </summary>
        /// <param name="request">Request.</param>
        public object Get(GetOpensearchSearch request)
        {
            var context = TepWebContext.GetWebContext(PagePrivileges.EverybodyView);
            IOpenSearchResultCollection result = null;

            try{
                context.Open();
                context.LogInfo(this, string.Format("/data/collection/{{serieId}}/search GET serieId='{0}'", request.serieId));

                // Load the complete request
                HttpRequest httpRequest = HttpContext.Current.Request;

                if (request.serieId == null)
                {
                    throw new ArgumentNullException(Terradue.Tep.WebServer.CustomErrorMessages.WRONG_IDENTIFIER);
                }

                Terradue.Tep.Collection serie = Terradue.Tep.Collection.FromIdentifier(context, request.serieId);

                OpenSearchEngine ose = MasterCatalogue.OpenSearchEngine;
                ose.DefaultTimeOut = 60000;

                Type type = OpenSearchFactory.ResolveTypeFromRequest(httpRequest.QueryString, httpRequest.Headers, ose);

                result = ose.Query(serie, httpRequest.QueryString, type);

                var descriptionUrl = serie.GetDescriptionBaseUrl("application/opensearchdescription+xml");
                if (descriptionUrl != null)
                {
                    result.Links.Add(new SyndicationLink(new Uri(descriptionUrl.Template), descriptionUrl.Relation, "OpenSearch Description link", descriptionUrl.Type, 0));
                }

                MasterCatalogue.ReplaceSelfLinksFormat(result, Request.QueryString);

                context.Close();
            }catch (Exception e) {
                context.LogError(this, e.Message, e);
                context.Close();
                throw e;
            }

            return(new HttpResult(result.SerializeToString(), result.ContentType));
        }