Example #1
0
        //TODO: modify here, and on mobile in order to have the same api as the other methods
        public IApplicationResponse Operation(String application, String operation, JObject json, ClientPlatform platform, string id = "")
        {
            MockingUtils.EvalMockingErrorModeActive(json, Request);
            var currentschemaKey = _nextSchemaRouter.GetSchemaKeyFromJson(application, json, true);
            var nextSchemaKey    = _nextSchemaRouter.GetSchemaKeyFromJson(application, json, false);

            currentschemaKey.Platform = platform;
            //            nextSchemaKey.Platform = platform;
            var mockMaximo = MockingUtils.IsMockingMaximoModeActive(json);

            return(DoExecute(application, json, id, operation, currentschemaKey, mockMaximo, nextSchemaKey, platform));
        }
Example #2
0
        private IApplicationResponse DoExecute(string application, JObject json, string id, string operation,
                                               ApplicationMetadataSchemaKey currentschemaKey, bool mockMaximo, ApplicationMetadataSchemaKey nextSchemaKey, ClientPlatform platform)
        {
            MockingUtils.EvalMockingErrorModeActive(json, Request);
            var user = SecurityFacade.CurrentUser();

            if (null == user)
            {
                throw new HttpResponseException(HttpStatusCode.Unauthorized);
            }

            if (Log.IsDebugEnabled)
            {
                Log.Debug(json.ToString(Newtonsoft.Json.Formatting.Indented, new StringEnumConverter()));
            }
            var applicationMetadata = MetadataProvider
                                      .Application(application)
                                      .ApplyPolicies(currentschemaKey, user, platform);

            ContextLookuper.SetInternalQueryExecution();

            var maximoResult = new MaximoResult(id, null);

            if (!mockMaximo)
            {
                maximoResult = DataSetProvider.LookupAsBaseDataSet(application)
                               .Execute(applicationMetadata, json, id, operation);
            }
            if (currentschemaKey.Platform == ClientPlatform.Mobile)
            {
                //mobile requests doesn´t have to handle success messages or redirections
                return(null);
            }
            if (nextSchemaKey == null)
            {
                //keep on same schema unless explicetely told otherwise
                nextSchemaKey = currentschemaKey;
            }

            if (nextSchemaKey != null)
            {
                var response = _nextSchemaRouter.RedirectToNextSchema(applicationMetadata, operation,
                                                                      maximoResult.Id, platform, currentschemaKey, nextSchemaKey, mockMaximo);
                response.SuccessMessage = _successMessageHandler.FillSucessMessage(applicationMetadata, maximoResult.Id, operation);
                return(response);
            }
            return(new BlankApplicationResponse()
            {
                SuccessMessage = _successMessageHandler.FillSucessMessage(applicationMetadata, maximoResult.Id, operation)
            });
        }
Example #3
0
        public ActionResult Input([NotNull] string application, string json, ClientPlatform platform, [NotNull] string currentSchemaKey, string nextSchemaKey)
        {
            var user = SecurityFacade.CurrentUser();

            Log.Info("receiving ie9 attachment request");

            var currentSchema       = _nextSchemaRouter.GetSchemaKeyFromString(application, currentSchemaKey, platform);
            var applicationMetadata = MetadataProvider
                                      .Application(application)
                                      .ApplyPolicies(currentSchema, user, ClientPlatform.Web);
            var queryStrings = HttpUtility.ParseQueryString(Request.UrlReferrer.Query);
            var popupmode    = queryStrings["popupmode"];
            var datamap      = JObject.Parse(json);
            var entityId     = datamap[applicationMetadata.Schema.IdFieldName].ToString();

            try {
                PopulateFilesInJson(datamap, String.IsNullOrWhiteSpace(entityId));
                PopulateInputsInJson(datamap);
                var mockMaximo = MockingUtils.IsMockingMaximoModeActive(datamap);

                IApplicationResponse response;
                if (String.IsNullOrWhiteSpace(entityId))
                {
                    Log.DebugFormat("redirecting to datacontroller post with datamap " + datamap);
                    response = _dataController.Post(application, datamap, platform, currentSchemaKey, nextSchemaKey, mockMaximo);
                }
                else
                {
                    Log.DebugFormat("redirecting to datacontroller put");
                    response = _dataController.Put(application, entityId, datamap, platform, currentSchemaKey,
                                                   nextSchemaKey, mockMaximo);
                }
                return(RedirectToAction("RedirectToAction", "Home", BuildParameter(entityId, application, platform, response, popupmode, applicationMetadata)));
            } catch (Exception e) {
                var rootException = ExceptionUtil.DigRootException(e);
                //TODO: handle error properly
                Log.Error(rootException, e);
                return(RedirectToAction("RedirectToAction", "Home", BuildErrorParameter(entityId, application, platform, popupmode, applicationMetadata, e)));
            }
        }