Example #1
0
        public ActionResult <HttpResponseMessage> SaveServiceFile(string org, string app, FileEditorMode fileEditorMode, string fileName, bool stageFile)
        {
            if (!ApplicationHelper.IsValidFilename(fileName))
            {
                return(BadRequest());
            }

            string content = string.Empty;

            try
            {
                using (var reader = new StreamReader(Request.Body))
                {
                    content = reader.ReadToEnd();
                }

                switch (fileEditorMode)
                {
                case FileEditorMode.Implementation:
                    _repository.SaveAppLogicFile(org, app, fileName, content);
                    break;

                case FileEditorMode.Dynamics:
                    _repository.SaveRuleHandler(org, app, content);
                    break;

                case FileEditorMode.Calculation:
                    _repository.SaveAppLogicFile(org, app, "Calculation/" + fileName, content);
                    break;

                case FileEditorMode.Validation:
                    _repository.SaveAppLogicFile(org, app, "Validation/" + fileName, content);
                    break;

                case FileEditorMode.All:
                    _repository.SaveConfiguration(org, app, fileName, content);
                    break;

                case FileEditorMode.Root:
                    _repository.SaveFile(org, app, fileName, content);
                    break;

                default:
                    // Return 501 Not Implemented
                    return(new HttpResponseMessage(HttpStatusCode.NotImplemented));
                }

                if (stageFile)
                {
                    _sourceControl.StageChange(org, app, fileName);
                }

                return(new HttpResponseMessage(HttpStatusCode.OK));
            }
            catch (Exception)
            {
                return(new HttpResponseMessage(HttpStatusCode.InternalServerError));
            }
        }
Example #2
0
 /// <inheritdoc/>
 public void StageChange(string org, string repository, string fileName)
 {
     try
     {
         _decoratedService.StageChange(org, repository, fileName);
     }
     catch (Exception ex)
     {
         LogError(ex, "StageChange", org, repository);
         throw;
     }
 }
Example #3
0
        public ActionResult StageChange(string org, string repository, string fileName)
        {
            try
            {
                if (string.IsNullOrEmpty(org) || string.IsNullOrEmpty(repository) || string.IsNullOrEmpty(fileName))
                {
                    return(ValidationProblem("One or all of the input parameters are null"));
                }

                _sourceControl.StageChange(org, repository, fileName);
                return(Ok());
            }
            catch (Exception)
            {
                return(StatusCode(StatusCodes.Status500InternalServerError));
            }
        }
Example #4
0
        public ActionResult <HttpResponseMessage> StageChange(string owner, string repository, string fileName)
        {
            try
            {
                if (string.IsNullOrEmpty(owner) || string.IsNullOrEmpty(repository) || string.IsNullOrEmpty(fileName))
                {
                    HttpResponseMessage badRequest = new HttpResponseMessage(HttpStatusCode.BadRequest);
                    badRequest.ReasonPhrase = "One or all of the input parameters are null";
                    return(badRequest);
                }

                _sourceControl.StageChange(owner, repository, fileName);
                return(new HttpResponseMessage(HttpStatusCode.OK));
            }
            catch (Exception ex)
            {
                return(new HttpResponseMessage(HttpStatusCode.InternalServerError));
            }
        }
Example #5
0
        public ActionResult <HttpResponseMessage> SaveServiceFile(string org, string service, FileEditorMode fileEditorMode, string fileName, bool stageFile)
        {
            string content = string.Empty;

            try
            {
                using (var reader = new StreamReader(Request.Body))
                {
                    content = reader.ReadToEnd();
                }

                switch (fileEditorMode)
                {
                case FileEditorMode.Implementation:
                    if (fileName == "RuleHandler.js")
                    {
                        _repository.SaveResourceFile(org, service, fileName, content);
                    }
                    else
                    {
                        _repository.SaveImplementationFile(org, service, fileName, content);
                    }

                    break;

                case FileEditorMode.Dynamics:
                    _repository.SaveResourceFile(org, service, "Dynamics/" + fileName, content);
                    break;

                case FileEditorMode.Calculation:
                    _repository.SaveImplementationFile(org, service, "Calculation/" + fileName, content);
                    break;

                case FileEditorMode.Validation:
                    _repository.SaveImplementationFile(org, service, "Validation/" + fileName, content);
                    break;

                case FileEditorMode.All:
                    _repository.SaveConfiguration(org, service, fileName, content);
                    break;

                case FileEditorMode.Root:
                    _repository.SaveFile(org, service, fileName, content);
                    break;

                default:
                    // Return 501 Not Implemented
                    return(new HttpResponseMessage(HttpStatusCode.NotImplemented));
                }

                if (stageFile)
                {
                    _sourceControl.StageChange(org, service, fileName);
                }

                return(new HttpResponseMessage(HttpStatusCode.OK));
            }
            catch (Exception ex)
            {
                return(new HttpResponseMessage(HttpStatusCode.InternalServerError));
            }
        }