예제 #1
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));
        }
예제 #2
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));
        }
예제 #3
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));
        }
예제 #4
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));
        }
예제 #5
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));
        }
예제 #6
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));
        }
예제 #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));
        }
예제 #8
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));
        }
예제 #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));
        }
예제 #10
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));
        }
예제 #11
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));
        }
예제 #12
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));
        }
예제 #13
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));
        }
예제 #14
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));
        }
예제 #15
0
        /// <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));
        }
예제 #16
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));
        }