Exemple #1
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));
        }
        /// <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));
        }
Exemple #3
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));
        }
Exemple #4
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));
        }
Exemple #5
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));
        }
Exemple #6
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));
        }
Exemple #7
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));
        }
        /// <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));
        }
Exemple #9
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));
        }
        /// <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));
        }
Exemple #11
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);
        }
Exemple #12
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));
        }
Exemple #13
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));
        }
        /// <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));
        }
Exemple #15
0
        public object Get(ProxyGetUrlRequestTep request)
        {
            var uri  = new UriBuilder(request.url);
            var host = uri.Host;

            if (!((host.EndsWith("terradue.int") || host.EndsWith("terradue.com")) || !host.Equals(HttpContext.Current.Request.Url.Host)))
            {
                throw new Exception("Non Terradue urls are not accepted");
            }

            var        context = TepWebContext.GetWebContext(PagePrivileges.EverybodyView);
            HttpResult result  = null;

            context.Open();
            context.LogInfo(this, string.Format("/proxy GET url='{0}'", request.url));

            OpenSearchEngine ose = MasterCatalogue.OpenSearchEngine;
            var settings         = MasterCatalogue.OpenSearchFactorySettings;

            if (uri.Path.EndsWith("/description") || uri.Path.EndsWith("/OSDD"))
            {
                GenericOpenSearchable urlToShare = new GenericOpenSearchable(new OpenSearchUrl(request.url), settings);
                Terradue.OpenSearch.Schema.OpenSearchDescription osd = urlToShare.GetOpenSearchDescription();
                result = new HttpResult(osd, "application/opensearchdescription+xml");
            }
            else
            {
                var e = OpenSearchFactory.FindOpenSearchable(settings, new Uri(request.url), "application/atom+xml");
                if (e.DefaultMimeType != "application/atom+xml" && !e.DefaultMimeType.Contains("xml"))
                {
                    throw new InvalidOperationException("No Url in the OpenSearch Description Document that query fully qualified model");
                }

                Type type = OpenSearchFactory.ResolveTypeFromRequest(HttpContext.Current.Request.QueryString, HttpContext.Current.Request.Headers, ose);
                var  res  = ose.Query(e, new NameValueCollection(), type);

                result = new HttpResult(res.SerializeToString(), res.ContentType);
            }

            context.Close();
            return(result);
        }
Exemple #16
0
        public object Get(TransactionsSearchRequestTep request)
        {
            var context = TepWebContext.GetWebContext(PagePrivileges.UserView);
            IOpenSearchResultCollection result;

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

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

                EntityList <Transaction> transactions = new EntityList <Transaction>(context);
                if (context.AccessLevel != EntityAccessLevel.Administrator || httpRequest.QueryString["author"] == null)
                {
                    //Only admin can see others transactions
                    transactions.SetFilter("OwnerId", context.UserId + "");
                }
                else
                {
                    var user = UserTep.FromIdentifier(context, httpRequest.QueryString["author"]);
                    transactions.SetFilter("OwnerId", user.Id + "");
                }
                transactions.AddSort("LogTime", SortDirection.Descending);

                var ose = MasterCatalogue.OpenSearchEngine;

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

                OpenSearchFactory.ReplaceOpenSearchDescriptionLinks(transactions, result);

                context.Close();
            } catch (Exception e) {
                context.LogError(this, e.Message, e);
                context.Close();
                throw e;
            }
            return(new HttpResult(result.SerializeToString(), result.ContentType));
        }
        public static IOpenSearchResultCollection QueryResult(IOpenSearchableElasticType type, NameValueCollection parameters, Type resultType = null)
        {
            OpenSearchEngine ose = type.GetOpenSearchEngine(parameters);

            if (resultType == null)
            {
                resultType = OpenSearchFactory.ResolveTypeFromRequest(HttpContext.Current.Request, ose);
            }

            if (resultType == typeof(ParametersResult))
            {
                return(type.DescribeParameters());
            }

            var result = ose.Query(type, parameters, resultType);

            OpenSearchFactory.ReplaceSelfLinks(type, parameters, result, type.EntrySelfLinkTemplate, result.ContentType);
            OpenSearchFactory.ReplaceOpenSearchDescriptionLinks(type, result);

            result.Title = new TextSyndicationContent(string.Format("Result for OpenSearch query over type {0} in index {1}", type.Type.Name, type.Index.Name));

            return(result);
        }
Exemple #18
0
        public object Get(ActivityByCommunitySearchRequestTep request)
        {
            var context = TepWebContext.GetWebContext(PagePrivileges.UserView);

            context.AccessLevel = EntityAccessLevel.Administrator;
            context.Open();
            context.LogInfo(this, string.Format("/community/{{community}}/activity/search GET - community='{0}'", request.Domain));

            ThematicCommunity domain = ThematicCommunity.FromIdentifier(context, request.Domain);

            //We only want some Privileges
            var privlist = new List <int> ();

            var privs = Privilege.Get(EntityType.GetEntityType(typeof(WpsJob)));

            foreach (var priv in privs)
            {
                privlist.Add(priv.Id);
            }

            privs = Privilege.Get(EntityType.GetEntityType(typeof(DataPackage)));
            foreach (var priv in privs)
            {
                privlist.Add(priv.Id);
            }

            privs = Privilege.Get(EntityType.GetEntityType(typeof(Series)));
            foreach (var priv in privs)
            {
                privlist.Add(priv.Id);
            }

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

            activities.AddSort("CreationTime", SortDirection.Descending);
            activities.SetFilter("PrivilegeId", string.Join(",", privlist));
            activities.SetFilter("DomainId", domain.Id.ToString());
            activities.Identifier = "activity";
            activities.Load();

            // 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 activities.FilterValues)
            {
                qs.Set("t2-" + filter.Key.FieldName, filter.Value.ToString());
            }

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

            OpenSearchFactory.ReplaceOpenSearchDescriptionLinks(activities, osr);

            context.Close();
            return(new HttpResult(osr.SerializeToString(), osr.ContentType));
        }
        /// <summary>
        /// Get the specified request.
        /// </summary>
        /// <param name="request">Request.</param>
        /// /apps/{identifier}/search GET
        public object Get(ThematicAppSearchRequestTep request)
        {
            IfyWebContext context = TepWebContext.GetWebContext(PagePrivileges.EverybodyView);

            context.Open();
            context.LogInfo(this, string.Format("/apps/search GET -- cache = {0}", request.cache));

            IOpenSearchResultCollection result;
            OpenSearchEngine            ose = MasterCatalogue.OpenSearchEngine;
            HttpRequest httpRequest         = HttpContext.Current.Request;
            Type        responseType        = OpenSearchFactory.ResolveTypeFromRequest(httpRequest.QueryString, httpRequest.Headers, ose);

            //first we get the communities the user can see
            var communities = new EntityList <ThematicCommunity>(context);

            if (context.UserId == 0)
            {
                communities.SetFilter("Kind", (int)DomainKind.Public + "");
            }
            else
            {
                communities.SetFilter("Kind", (int)DomainKind.Public + "," + (int)DomainKind.Hidden + "," + (int)DomainKind.Private);
                communities.AddSort("Kind", SortDirection.Ascending);
            }
            communities.Load();

            if (request.cache)
            {
                List <int> ids = new List <int>();
                foreach (var c in communities)
                {
                    if (c.IsUserJoined(context.UserId))
                    {
                        ids.Add(c.Id);
                    }
                }

                EntityList <ThematicApplicationCached> appsCached = new EntityList <ThematicApplicationCached>(context);
                var filterValues = new List <object>();
                filterValues.Add(string.Join(",", ids));
                filterValues.Add(SpecialSearchValue.Null);
                appsCached.SetFilter("DomainId", filterValues.ToArray());
                appsCached.SetGroupFilter("UId");
                appsCached.AddSort("LastUpdate", SortDirection.Descending);

                result = ose.Query(appsCached, httpRequest.QueryString, responseType);
                OpenSearchFactory.ReplaceOpenSearchDescriptionLinks(appsCached, result);
            }
            else
            {
                List <Terradue.OpenSearch.IOpenSearchable> osentities = new List <Terradue.OpenSearch.IOpenSearchable>();

                var settings     = MasterCatalogue.OpenSearchFactorySettings;
                var specsettings = (OpenSearchableFactorySettings)settings.Clone();
                if (context.UserId != 0)
                {
                    var user     = UserTep.FromId(context, context.UserId);
                    var apikey   = user.GetSessionApiKey();
                    var t2userid = user.TerradueCloudUsername;
                    if (!string.IsNullOrEmpty(apikey))
                    {
                        specsettings.Credentials = new System.Net.NetworkCredential(t2userid, apikey);
                    }
                }

                //get apps link from the communities the user can see
                foreach (var community in communities.Items)
                {
                    if (community.IsUserJoined(context.UserId))
                    {
                        var app = community.GetThematicApplication();
                        if (app != null)
                        {
                            app.LoadItems();
                            foreach (var item in app.Items)
                            {
                                if (!string.IsNullOrEmpty(item.Location))
                                {
                                    try {
                                        var ios = OpenSearchFactory.FindOpenSearchable(specsettings, new OpenSearchUrl(item.Location));
                                        osentities.Add(ios);
                                        context.LogDebug(this, string.Format("Apps search -- Add '{0}'", item.Location));
                                    } catch (Exception e) {
                                        context.LogError(this, e.Message, e);
                                    }
                                }
                            }
                        }
                    }
                }

                //get thematic apps without any domain
                var apps = new EntityList <ThematicApplication>(context);
                apps.SetFilter("DomainId", SpecialSearchValue.Null);
                apps.SetFilter("Kind", ThematicApplication.KINDRESOURCESETAPPS + "");
                apps.Load();
                foreach (var app in apps)
                {
                    app.LoadItems();
                    foreach (var item in app.Items)
                    {
                        if (!string.IsNullOrEmpty(item.Location))
                        {
                            try {
                                var ios = OpenSearchFactory.FindOpenSearchable(specsettings, new OpenSearchUrl(item.Location));
                                osentities.Add(ios);
                                context.LogDebug(this, string.Format("Apps search -- Add '{0}'", item.Location));
                            } catch (Exception e) {
                                context.LogError(this, e.Message, e);
                            }
                        }
                    }
                }

                MultiGenericOpenSearchable multiOSE = new MultiGenericOpenSearchable(osentities, specsettings);
                result = ose.Query(multiOSE, httpRequest.QueryString, responseType);
            }

            var sresult = result.SerializeToString();

            //replace usernames in apps
            try {
                var user = UserTep.FromId(context, context.UserId);
                sresult = sresult.Replace("${USERNAME}", user.Username);
                sresult = sresult.Replace("${T2USERNAME}", user.TerradueCloudUsername);
                sresult = sresult.Replace("${T2APIKEY}", user.GetSessionApiKey());
            } catch (Exception e) {
                context.LogError(this, e.Message, e);
            }

            if (!string.IsNullOrEmpty(httpRequest.QueryString["uid"]))
            {
                try{
                    var user = UserTep.FromId(context, context.UserId);
                    EventUserLoggerTep eventLogger = new EventUserLoggerTep(context);
                    eventLogger.GetLogEvent(user, "portal_user_access_workspace", "User workspace access").ContinueWith <Event>(
                        usrevent => {
                        if (usrevent != null)
                        {
                            var callId = httpRequest.QueryString["uid"];
                            usrevent.Result.Item.Properties.Add("app_id", callId);
                            EventFactory.Log(context, usrevent.Result);
                        }
                        return(usrevent.Result);
                    }
                        );
                }catch (Exception) {}
            }

            context.Close();
            return(new HttpResult(sresult, result.ContentType));
        }
        public object Get(ThematicAppCurrentUserSearchRequestTep request)
        {
            IfyWebContext context = TepWebContext.GetWebContext(PagePrivileges.EverybodyView);

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

            IOpenSearchResultCollection result;
            OpenSearchEngine            ose = MasterCatalogue.OpenSearchEngine;
            var  httpRequest  = HttpContext.Current.Request;
            Type responseType = OpenSearchFactory.ResolveTypeFromRequest(httpRequest.QueryString, httpRequest.Headers, ose);
            List <Terradue.OpenSearch.IOpenSearchable> osentities = new List <Terradue.OpenSearch.IOpenSearchable>();
            var settings = MasterCatalogue.OpenSearchFactorySettings;
            OpenSearchableFactorySettings specsettings = (OpenSearchableFactorySettings)settings.Clone();

            UserTep user = null;

            if (context.UserId != 0)
            {
                user = UserTep.FromId(context, context.UserId);
                if (request.cache)
                {
                    var domain = user.GetPrivateDomain();
                    EntityList <ThematicApplicationCached> appsCached = new EntityList <ThematicApplicationCached>(context);
                    appsCached.SetFilter("DomainId", domain.Id);
                    appsCached.AddSort("LastUpdate", SortDirection.Descending);

                    result = ose.Query(appsCached, Request.QueryString, responseType);
                    OpenSearchFactory.ReplaceOpenSearchDescriptionLinks(appsCached, result);
                }
                else
                {
                    //get user private thematic app
                    var apikey   = user.GetSessionApiKey();
                    var t2userid = user.TerradueCloudUsername;
                    if (!string.IsNullOrEmpty(apikey))
                    {
                        specsettings.Credentials = new System.Net.NetworkCredential(t2userid, apikey);
                    }
                    var app = user.GetPrivateThematicApp();
                    if (app != null)
                    {
                        foreach (var item in app.Items)
                        {
                            if (!string.IsNullOrEmpty(item.Location))
                            {
                                try {
                                    var sgOs = OpenSearchFactory.FindOpenSearchable(specsettings, new OpenSearchUrl(item.Location));
                                    osentities.Add(sgOs);
                                    context.LogDebug(this, string.Format("Apps search -- Add '{0}'", item.Location));
                                } catch (Exception e) {
                                    context.LogError(this, e.Message, e);
                                }
                            }
                        }
                    }
                    MultiGenericOpenSearchable multiOSE = new MultiGenericOpenSearchable(osentities, specsettings);
                    result = ose.Query(multiOSE, Request.QueryString, responseType);
                }
            }
            else
            {
                result = ose.Query(new MultiGenericOpenSearchable(osentities, specsettings), Request.QueryString, responseType);
            }

            string sresult = result.SerializeToString();

            //replace usernames in apps
            if (user != null)
            {
                try {
                    sresult = sresult.Replace("${USERNAME}", user.Username);
                    sresult = sresult.Replace("${T2USERNAME}", user.TerradueCloudUsername);
                    sresult = sresult.Replace("${T2APIKEY}", user.GetSessionApiKey());
                } catch (Exception e) {
                    context.LogError(this, e.Message, e);
                }
            }

            context.Close();

            return(new HttpResult(sresult, result.ContentType));
        }
        public object Get(ThematicAppByCommunitySearchRequestTep request)
        {
            IfyWebContext context = TepWebContext.GetWebContext(PagePrivileges.EverybodyView);

            context.Open();
            context.LogInfo(this, string.Format("/community/{{domain}}/apps/search GET domain='{0}'", request.Domain));

            var domain = ThematicCommunity.FromIdentifier(context, request.Domain);
            IOpenSearchResultCollection result;
            OpenSearchEngine            ose = MasterCatalogue.OpenSearchEngine;
            HttpRequest httpRequest         = HttpContext.Current.Request;
            Type        responseType        = OpenSearchFactory.ResolveTypeFromRequest(httpRequest.QueryString, httpRequest.Headers, ose);

            if (request.cache)
            {
                bool isjoined = domain.IsUserJoined(context.UserId);

                EntityList <ThematicApplicationCached> appsCached = new EntityList <ThematicApplicationCached>(context);
                if (isjoined)
                {
                    appsCached.SetFilter("DomainId", domain.Id.ToString());
                }
                else
                {
                    appsCached.SetFilter("DomainId", "-1");//if user is not joined we dont want him to see results
                }
                appsCached.AddSort("LastUpdate", SortDirection.Descending);
                result = ose.Query(appsCached, httpRequest.QueryString, responseType);
                OpenSearchFactory.ReplaceOpenSearchDescriptionLinks(appsCached, result);
            }
            else
            {
                if (MasterCatalogue.SearchCache != null)
                {
                    MasterCatalogue.SearchCache.ClearCache(".*", DateTime.Now);
                }

                var apps = new EntityList <DataPackage>(context);
                apps.SetFilter("Kind", ThematicApplication.KINDRESOURCESETAPPS.ToString());
                apps.SetFilter("DomainId", domain.Id.ToString());
                apps.Load();

                // 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 apps.FilterValues)
                {
                    qs.Add("t2-" + filter.Key.FieldName, filter.Value.ToString());
                }

                apps.OpenSearchEngine = ose;

                List <Terradue.OpenSearch.IOpenSearchable> osentities = new List <Terradue.OpenSearch.IOpenSearchable>();
                foreach (var app in apps.Items)
                {
                    app.OpenSearchEngine = ose;
                    osentities.AddRange(app.GetOpenSearchableArray());
                }

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

            var sresult = result.SerializeToString();

            //replace usernames in apps
            try {
                var user = UserTep.FromId(context, context.UserId);
                sresult = sresult.Replace("${USERNAME}", user.Username);
                sresult = sresult.Replace("${T2USERNAME}", user.TerradueCloudUsername);
                sresult = sresult.Replace("${T2APIKEY}", user.GetSessionApiKey());
            } catch (Exception e) {
                context.LogError(this, e.Message, e);
            }

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

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

                Terradue.Tep.DataPackage datapackage;

                try{
                    datapackage = DataPackage.FromIdentifier(context, request.DataPackageId);
                }catch (Exception) {
                    if (request.Key != null) //or if public
                    {
                        context.AccessLevel = EntityAccessLevel.Administrator;
                        datapackage         = DataPackage.FromIdentifier(context, request.DataPackageId);
                        if (request.Key != null && !request.Key.Equals(datapackage.AccessKey))
                        {
                            throw new UnauthorizedAccessException(CustomErrorMessages.WRONG_ACCESSKEY);
                        }
                    }
                    else
                    {
                        datapackage = DataPackage.FromIdentifier(context, request.DataPackageId);
                    }
                }

                if (Request.QueryString != null && Request.QueryString["cache"] == "false")
                {
                    datapackage.SetOpenSearchEngine(MasterCatalogue.GetNewOpenSearchEngine());
                }
                else if (Request.QueryString != null && Request.QueryString["clearcache"] == "true")
                {
                    datapackage.SetOpenSearchEngine(MasterCatalogue.ClearOpenSearchEngine());
                }
                else
                {
                    datapackage.SetOpenSearchEngine(MasterCatalogue.OpenSearchEngine);
                }

                OpenSearchEngine ose = MasterCatalogue.OpenSearchEngine;

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

                result = ose.Query(datapackage, Request.QueryString, responseType);

                var openSearchDescription = datapackage.GetLocalOpenSearchDescription();
                var uri_s = datapackage.GetSearchBaseUrl();
                OpenSearchDescriptionUrl openSearchUrlByRel = OpenSearchFactory.GetOpenSearchUrlByRel(openSearchDescription, "self");
                Uri uri_d;
                if (openSearchUrlByRel != null)
                {
                    uri_d = new Uri(openSearchUrlByRel.Template);
                }
                else
                {
                    uri_d = openSearchDescription.Originator;
                }
                if (uri_d != null)
                {
                    result.Links.Add(new SyndicationLink(uri_d, "search", "OpenSearch Description link", "application/opensearchdescription+xml", 0));
                }
                if (uri_s != null)
                {
                    result.Links.Add(new SyndicationLink(uri_s, "self", "OpenSearch Search link", "application/atom+xml", 0));
                }

                MasterCatalogue.ReplaceSelfLinksFormat(result, Request.QueryString);

                ActivityTep activity = new ActivityTep(context, datapackage, EntityOperationType.Search);
                activity.SetParam("items", result.TotalResults + "");
                activity.Store();

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

            return(new HttpResult(result.SerializeToString(), result.ContentType));
        }
Exemple #23
0
        public object Get(WpsJobProductSearchRequestTep request)
        {
            var        context = TepWebContext.GetWebContext(PagePrivileges.EverybodyView);
            HttpResult result  = null;

            try {
                context.Open();
                context.LogInfo(this, string.Format("/job/wps/{0}/products/search GET", request.JobId));

                WpsJob wpsjob = null;

                try {
                    wpsjob = WpsJob.FromIdentifier(context, request.JobId);
                } catch (Exception e) {
                    if (request.Key != null)                     //or if public
                    {
                        context.AccessLevel = EntityAccessLevel.Administrator;
                        wpsjob = WpsJob.FromIdentifier(context, request.JobId);
                        if (request.Key != null && !request.Key.Equals(wpsjob.AccessKey))
                        {
                            throw new UnauthorizedAccessException(CustomErrorMessages.WRONG_ACCESSKEY);
                        }
                    }
                    else
                    {
                        throw e;
                    }
                }

                OpenSearchEngine ose         = MasterCatalogue.OpenSearchEngine;
                HttpRequest      httpRequest = HttpContext.Current.Request;
                Type             type        = OpenSearchFactory.ResolveTypeFromRequest(httpRequest.QueryString, httpRequest.Headers, ose);
                var nvc = httpRequest.QueryString;

                if (CatalogueFactory.IsCatalogUrl(new Uri(wpsjob.StatusLocation)))
                {
                    var settings = MasterCatalogue.OpenSearchFactorySettings;
                    OpenSearchableFactorySettings specsettings = (OpenSearchableFactorySettings)settings.Clone();

                    //get credentials from current user
                    if (context.UserId != 0)
                    {
                        var user     = UserTep.FromId(context, context.UserId);
                        var apikey   = user.GetSessionApiKey();
                        var t2userid = user.TerradueCloudUsername;
                        if (!string.IsNullOrEmpty(apikey))
                        {
                            specsettings.Credentials = new System.Net.NetworkCredential(t2userid, apikey);
                        }
                    }
                    GenericOpenSearchable urlToShare = new GenericOpenSearchable(new OpenSearchUrl(wpsjob.StatusLocation), specsettings);
                    var res = ose.Query(urlToShare, nvc, type);
                    result = new HttpResult(res.SerializeToString(), res.ContentType);
                }
                else
                {
                    WpsJobProductOpenSearchable wpsjobProductOs = new WpsJobProductOpenSearchable(wpsjob, context);

                    //var nvc = wpsjobUrl.GetParameters ();
                    var res = ose.Query(wpsjobProductOs, nvc, type);
                    OpenSearchFactory.ReplaceSelfLinks(wpsjobProductOs, httpRequest.QueryString, res, EntrySelfLinkTemplate);
                    OpenSearchFactory.ReplaceOpenSearchDescriptionLinks(wpsjobProductOs, res);
                    result = new HttpResult(res.SerializeToString(), res.ContentType);
                }

                context.Close();
            } catch (Exception e) {
                context.LogError(this, e.Message, e);
                context.Close();
                throw e;
            }
            return(result);
        }
Exemple #24
0
        public object Get(ProxyWpsJobSearchRequestTep request)
        {
            var context = TepWebContext.GetWebContext(PagePrivileges.EverybodyView);

            context.Open();
            context.LogInfo(this, string.Format("/proxy/wps/{{jobid}}/search GET jobid='{0}'", request.jobid));

            WpsJob wpsjob = WpsJob.FromIdentifier(context, request.jobid);

            if (string.IsNullOrEmpty(wpsjob.StatusLocation))
            {
                throw new Exception("Invalid Status Location");
            }

            context.LogDebug(this, string.Format("Wps Proxy search for wpsjob {0}", wpsjob.Identifier));

            HttpWebRequest executeHttpRequest;

            if (wpsjob.Provider != null)
            {
                executeHttpRequest = wpsjob.Provider.CreateWebRequest(wpsjob.StatusLocation);
            }
            else
            {
                NetworkCredential credentials = null;
                var uri = new UriBuilder(wpsjob.StatusLocation);
                if (!string.IsNullOrEmpty(uri.UserName) && !string.IsNullOrEmpty(uri.Password))
                {
                    credentials = new NetworkCredential(uri.UserName, uri.Password);
                }
                executeHttpRequest = WpsProvider.CreateWebRequest(wpsjob.StatusLocation, credentials, context.Username);
            }

            if (wpsjob.StatusLocation.Contains("gpod.eo.esa.int"))
            {
                executeHttpRequest.Headers.Add("X-UserID", context.GetConfigValue("GpodWpsUser"));
            }
            OpenGis.Wps.ExecuteResponse execResponse = null;
            try {
                context.LogDebug(this, string.Format("Wps proxy - exec response requested - {0}", executeHttpRequest.Address.AbsoluteUri));
                using (var response = executeHttpRequest.GetResponse())
                    using (var stream = response.GetResponseStream())
                        execResponse = (OpenGis.Wps.ExecuteResponse) new System.Xml.Serialization.XmlSerializer(typeof(OpenGis.Wps.ExecuteResponse)).Deserialize(stream);
                context.LogDebug(this, string.Format("Wps proxy - exec response OK"));
            } catch (Exception e) {
                context.LogError(this, e.Message, e);
            }
            if (execResponse == null)
            {
                throw new Exception("Unable to get execute response from proxied job");
            }

            execResponse.statusLocation = context.BaseUrl + "/wps/RetrieveResultServlet?id=" + wpsjob.Identifier;
            context.LogDebug(this, string.Format("Proxy WPS - uri: " + execResponse.statusLocation));

            AtomFeed feed = new AtomFeed();

            if (execResponse.ProcessOutputs != null)
            {
                foreach (OutputDataType output in execResponse.ProcessOutputs)
                {
                    if (output.Identifier != null && output.Identifier.Value != null && output.Identifier.Value.Equals("result_metadata"))
                    {
                        context.LogDebug(this, string.Format("Wps proxy - metadata"));
                        if (output.Item is OutputReferenceType)
                        {
                            var            reference = output.Item as OutputReferenceType;
                            HttpWebRequest atomRequest;
                            if (wpsjob.Provider != null)
                            {
                                atomRequest = wpsjob.Provider.CreateWebRequest(reference.href);
                            }
                            else
                            {
                                NetworkCredential credentials = null;
                                var uri = new UriBuilder(reference.href);
                                if (!string.IsNullOrEmpty(uri.UserName) && !string.IsNullOrEmpty(uri.Password))
                                {
                                    credentials = new NetworkCredential(uri.UserName, uri.Password);
                                }
                                atomRequest = WpsProvider.CreateWebRequest(reference.href, credentials, context.Username);
                            }
                            feed = CreateFeedForMetadata(atomRequest);
                        }
                        else if (output.Item is DataType)
                        {
                            var            item      = ((DataType)(output.Item)).Item as ComplexDataType;
                            var            reference = item.Reference as OutputReferenceType;
                            HttpWebRequest atomRequest;
                            if (wpsjob.Provider != null)
                            {
                                atomRequest = wpsjob.Provider.CreateWebRequest(reference.href);
                            }
                            else
                            {
                                NetworkCredential credentials = null;
                                var uri = new UriBuilder(reference.href);
                                if (!string.IsNullOrEmpty(uri.UserName) && !string.IsNullOrEmpty(uri.Password))
                                {
                                    credentials = new NetworkCredential(uri.UserName, uri.Password);
                                }
                                atomRequest = WpsProvider.CreateWebRequest(reference.href, credentials, context.Username);
                            }
                            feed = CreateFeedForMetadata(atomRequest);
                        }
                    }
                    else
                    {
                        if (output.Item is DataType && ((DataType)(output.Item)).Item != null)
                        {
                            var item = ((DataType)(output.Item)).Item as ComplexDataType;
                            if (item.Any != null && item.Any [0].LocalName != null)
                            {
                                if (item.Any [0].LocalName.Equals("RDF"))
                                {
                                    context.LogDebug(this, string.Format("Wps proxy - RDF"));
                                    feed = CreateFeedForRDF(item.Any [0], request.jobid, context.BaseUrl);
                                }
                                else if (item.Any [0].LocalName.Equals("metalink"))
                                {
                                    context.LogDebug(this, string.Format("Wps proxy - metalink"));
                                    feed = CreateFeedForMetalink(item.Any [0], request.jobid, context.BaseUrl, context);
                                }
                            }
                        }
                    }
                }
            }

            /* Proxy id + add self */
            foreach (var item in feed.Items)
            {
                var self   = context.BaseUrl + "/proxy/wps/" + wpsjob.Identifier + "/search?uid=" + HttpUtility.UrlEncode(item.Id);
                var search = context.BaseUrl + "/proxy/wps/" + wpsjob.Identifier + "/description";
                item.Id = self;
                item.Links.Add(Terradue.ServiceModel.Syndication.SyndicationLink.CreateSelfLink(new Uri(self), "application/atom+xml"));
                item.Links.Add(new Terradue.ServiceModel.Syndication.SyndicationLink(new Uri(search), "search", "OpenSearch Description link", "application/opensearchdescription+xml", 0));
            }

            feed.Id = wpsjob.StatusLocation;

            var  ose          = MasterCatalogue.OpenSearchEngine;
            Type responseType = OpenSearchFactory.ResolveTypeFromRequest(HttpContext.Current.Request.QueryString, HttpContext.Current.Request.Headers, ose);
            var  ext          = ose.GetFirstExtensionByTypeAbility(responseType);

            var osfeed = new AtomFeedOpenSearchable(feed);
            IOpenSearchResultCollection osr = ose.Query(osfeed, HttpContext.Current.Request.QueryString, responseType);

            var osrDesc = new Uri(context.BaseUrl + "/proxy/wps/" + wpsjob.Identifier + "/description");

            osr.Links.Add(new Terradue.ServiceModel.Syndication.SyndicationLink(osrDesc, "search", "OpenSearch Description link", "application/opensearchdescription+xml", 0));

            context.Close();
            return(new HttpResult(osr.SerializeToString(), osr.ContentType));
        }