Beispiel #1
0
        public object Get(GetStorageRepoRequestTep request)
        {
            var    context = string.IsNullOrEmpty(request.apikey) ? TepWebContext.GetWebContext(PagePrivileges.UserView) : TepWebContext.GetWebContext(PagePrivileges.EverybodyView);
            string result  = null;

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

                var apikey  = request.apikey ?? UserTep.FromId(context, context.UserId).GetSessionApiKey();
                var factory = new StoreFactory(context, apikey);

                RepositoryInfoList repos = factory.GetRepositoriesToDeploy();
                var children             = new List <FileInfoChildren>();
                if (repos != null && repos.RepoTypesList != null)
                {
                    foreach (var repo in repos.RepoTypesList)
                    {
                        var child = new FileInfoChildren {
                            Uri    = "/" + repo.RepoKey,
                            Folder = true
                        };
                        children.Add(child);
                    }
                }
                FolderInfo info = new FolderInfo {
                    Uri      = System.Web.HttpContext.Current.Request.Url.AbsoluteUri,
                    Repo     = "",
                    Path     = "/",
                    Children = children.ToArray()
                };
                result = factory.Serializer.Serialize(info);

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

            return(new HttpResult(result, Request.ContentType));
        }
Beispiel #2
0
        private void CheckRepoRestriction(string repoKey)
        {
            RepositoryInfoList repos = GetRepositoriesToDeploy();
            bool canAccessRepo       = false;

            if (repos != null && repos.RepoTypesList != null)
            {
                foreach (var repo in repos.RepoTypesList)
                {
                    if (repoKey == repo.RepoKey)
                    {
                        canAccessRepo = true;
                    }
                }
            }
            if (!canAccessRepo)
            {
                throw new Exception("The requested path is not valid");
            }
        }