From c6e3340be1964d64c2276adc24a6bc2cfad31df3 Mon Sep 17 00:00:00 2001 From: Shannon Date: Thu, 24 Apr 2014 11:58:18 +1000 Subject: [PATCH] Updates an error msg for media resource, performs a null check --- .../src/common/resources/mediatype.resource.js | 2 +- src/Umbraco.Web/Editors/ContentControllerBase.cs | 8 +++++--- src/Umbraco.Web/Editors/MediaController.cs | 2 ++ 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/Umbraco.Web.UI.Client/src/common/resources/mediatype.resource.js b/src/Umbraco.Web.UI.Client/src/common/resources/mediatype.resource.js index 0c2ffceafd..94699d4195 100644 --- a/src/Umbraco.Web.UI.Client/src/common/resources/mediatype.resource.js +++ b/src/Umbraco.Web.UI.Client/src/common/resources/mediatype.resource.js @@ -34,7 +34,7 @@ function mediaTypeResource($q, $http, umbRequestHelper) { "mediaTypeApiBaseUrl", "GetAllowedChildren", [{ contentId: mediaId }])), - 'Failed to retrieve data for media id ' + mediaId); + 'Failed to retrieve allowed types for media id ' + mediaId); } }; diff --git a/src/Umbraco.Web/Editors/ContentControllerBase.cs b/src/Umbraco.Web/Editors/ContentControllerBase.cs index 7e97940d08..12f829fe49 100644 --- a/src/Umbraco.Web/Editors/ContentControllerBase.cs +++ b/src/Umbraco.Web/Editors/ContentControllerBase.cs @@ -154,9 +154,11 @@ namespace Umbraco.Web.Editors /// protected TPersisted GetObjectFromRequest(Func getFromService) { - return Request.Properties.ContainsKey(typeof (TPersisted).ToString()) == false - ? getFromService() - : (TPersisted) Request.Properties[typeof (TPersisted).ToString()]; + //checks if the request contains the key and the item is not null, if that is the case, return it from the request, otherwise return + // it from the callback + return Request.Properties.ContainsKey(typeof(TPersisted).ToString()) && Request.Properties[typeof(TPersisted).ToString()] != null + ? (TPersisted) Request.Properties[typeof (TPersisted).ToString()] + : getFromService(); } /// diff --git a/src/Umbraco.Web/Editors/MediaController.cs b/src/Umbraco.Web/Editors/MediaController.cs index 978b1403be..3ea57a7967 100644 --- a/src/Umbraco.Web/Editors/MediaController.cs +++ b/src/Umbraco.Web/Editors/MediaController.cs @@ -96,6 +96,8 @@ namespace Umbraco.Web.Editors if (foundContent == null) { HandleContentNotFound(id); + //HandleContentNotFound will throw an exception + return null; } return Mapper.Map(foundContent); }