Compare commits

..

281 Commits

Author SHA1 Message Date
Sebastiaan Janssen e553f2c671 Correct little mistake in nuspec file 2013-06-28 14:21:25 +02:00
Morten Christensen 42c6533e16 Correcting merge issues 2013-06-28 13:33:41 +02:00
Morten Christensen b0f4cb7d02 Merge branch '6.0.7' into 6.1.2 2013-06-28 13:30:04 +02:00
Morten Christensen f809dec874 Updating repository factory to inject unique name setting into ContentRepository 2013-06-28 13:28:03 +02:00
Morten Christensen 2477500045 Fixes #U4-2414 and removes internal usage of action handlers Yay! 2013-06-28 13:27:23 +02:00
Morten Christensen d89539a437 Merge branch '6.1.2' of https://github.com/umbraco/Umbraco-CMS into 6.1.2 2013-06-27 15:36:46 +02:00
Morten Christensen 4368f15097 Updating nuspec files which is a bit different for 6.1.x then 6.0.x 2013-06-27 15:36:25 +02:00
Morten Christensen b90150279b Merge branch '6.0.7' into 6.1.2
Conflicts:
	build/Build.proj
	build/NuSpecs/UmbracoCms.Core.nuspec
	src/Umbraco.Tests/Services/ContentTypeServiceTests.cs
2013-06-27 15:27:31 +02:00
Morten Christensen ca1b05e30d Correcting unit test after update to ContentType ctor 2013-06-27 15:23:15 +02:00
Morten Christensen 5c09ba9a2d Updating nuspec files and build 2013-06-27 15:15:27 +02:00
Sebastiaan Janssen cfa3e3aff1 Bump version number 2013-06-27 15:09:44 +02:00
Morten Christensen 59ff4a0484 It hurts having to do this, but Sebastiaan says I have to. So re-wiring the BulkPublishController to use the legacy Document class so legacy events are also fired. 2013-06-27 12:30:16 +02:00
Morten Christensen b1db99f639 Fixing issue in previous fix for #U4-2182 2013-06-27 10:57:49 +02:00
Morten Christensen ccbb838cef Fixing another part of #U4-2186 2013-06-27 10:56:45 +02:00
Sebastiaan Janssen 0d5ec8bfd5 Merge branch '6.0.7' into 6.1.2 2013-06-26 20:57:32 +02:00
Sebastiaan Janssen 5f67e85471 Merge branch '6.0.7' of github.com:umbraco/Umbraco-CMS into 6.0.7 2013-06-26 20:55:11 +02:00
Sebastiaan Janssen d9228c368f Fixes U4-2404 Photo gallery broken on Azure - Since the template saving routine is doing ToSafeAlias, we should also do it when setting the default template 2013-06-26 20:54:36 +02:00
Morten Christensen 8226505e5b Merge branch '6.0.7' into 6.1.2 2013-06-26 15:55:49 +02:00
Morten Christensen 41b8de09b7 Fixes U4-2234 including test case from issue 2013-06-26 15:49:00 +02:00
Morten Christensen bbf06cd13d Fixes U4-2234 2013-06-26 14:31:36 +02:00
Morten Christensen 639cb17741 Fixes U4-2182 and U4-2167 2013-06-26 14:31:10 +02:00
Morten Christensen 4643d34546 Moving generation of xml from ContentExtensions to the PackagingService 2013-06-26 13:30:54 +02:00
Sebastiaan Janssen 50035eae49 Merge pull request #33 from bokmadsen/6.0.7
Bugfix for previous pullrequest "Duplicate e-mail addresses: U4-315, U4-...
2013-06-26 02:43:34 -07:00
Bo Kingo Damgaard 2d857a8635 Bugfix for previous pullrequest "Duplicate e-mail addresses: U4-315, U4-2147, U4-304"
There was a bug in the previous pullrequest that didn't allow a member
to saved if the email wasn't changed. Furthermore duplicate emails are
now prevented if requireUniqueEmail was false, but is switched to true
(when saving a member)
2013-06-26 10:47:27 +02:00
Morten Christensen e4387b8dae Adding some internal bits in the ServiceContextManager and PackagingService 2013-06-25 13:43:57 +02:00
Morten Christensen 188aca499a Merge branch '6.0.7' into 6.1.2 2013-06-25 11:54:24 +02:00
Morten Christensen 3040d362ef Fixes #U4-2361 2013-06-25 11:48:37 +02:00
Shannon a57aa07721 Updated default controller resolver to use new IRenderMvcController interface, fixed some merge issues. 2013-06-25 09:55:45 +10:00
Shannon f2b8e3407b Merge remote-tracking branch 'origin/6.0.7' into 6.1.2
Conflicts:
	src/Umbraco.Web/Mvc/RenderControllerFactory.cs
	src/Umbraco.Web/Mvc/RenderMvcController.cs
	src/Umbraco.Web/Mvc/RenderRouteHandler.cs
	src/Umbraco.Web/Umbraco.Web.csproj
2013-06-25 09:41:27 +10:00
Shannon 1ec7cd3b89 Implements: #U4-2342 - IRenderMvcController 2013-06-25 09:33:48 +10:00
Sebastiaan Janssen bd77463fa4 Merge branch '6.0.7' into 6.1.2
Conflicts:
	build/NuSpecs/UmbracoCms.Core.nuspec
	src/Umbraco.Core/Models/ContentTypeBase.cs
	src/Umbraco.Core/Models/IContentTypeBase.cs
	src/Umbraco.Core/Models/PropertyGroupCollection.cs
2013-06-24 12:06:58 +02:00
Sebastiaan Janssen 368954226a Update to not require specific version of MVC4, just 4.0.20710.0 and higher 2013-06-24 12:05:22 +02:00
Sebastiaan Janssen 496d51c2a0 Merge pull request #25 from kipusoep/Duplicate-words-domainHelp
Duplicate words removed
2013-06-24 01:30:04 -07:00
Stefan Kip b01b4f7aa7 Forgot to update XML comments
Signed-off-by: Sebastiaan Janssen <sebastiaan@umbraco.com>
2013-06-24 10:29:03 +02:00
Stefan Kip 49a699c858 Added RemovePropertyGroup method
Signed-off-by: Sebastiaan Janssen <sebastiaan@umbraco.com>
2013-06-24 10:28:42 +02:00
Morten Christensen f68571ef7c Merge pull request #24 from kipusoep/U4-2421-RemovePropertyGroup
U4-2421 Added RemovePropertyGroup method
2013-06-24 01:18:21 -07:00
Stefan Kip 6cc1735363 Duplicate words removed 2013-06-23 21:49:43 +02:00
Stefan Kip d553dfd4b0 Forgot to update XML comments 2013-06-23 20:24:22 +02:00
Stefan Kip f3e737720b Added RemovePropertyGroup method 2013-06-23 16:38:11 +02:00
Stefan Kip 22cf59345c Removed space before UmbracoModule
Removed space before UmbracoModule
Conflicts:
	src/Umbraco.Web.UI/web.Template.config
2013-06-23 16:02:02 +02:00
Michiel van Oosterhout 16a46a4ea4 Changed default user email address to use the example domain, instead of domain.com 2013-06-23 16:01:04 +02:00
Sebastiaan Janssen 09d9728fb8 Merge branch '6.0.7' into 6.1.2
Conflicts:
	src/Umbraco.Web.UI/Umbraco.Web.UI.csproj
2013-06-23 15:16:44 +02:00
Sebastiaan Janssen c0df3e0202 Match IIS Express port number to Umbraco version so it's easier to use a few copies of the repo locally
(you don't have to re-map your port to the correct folder)
2013-06-23 15:13:27 +02:00
Sebastiaan Janssen d09e283900 Merge branch '6.0.7' into 6.1.2
Conflicts:
	.hgtags
2013-06-23 15:00:14 +02:00
Sebastiaan Janssen 507c6c23b9 If you never had VS2010 installed, the build now works, checking if the Publishing Tasks dll exists now 2013-06-23 14:57:53 +02:00
Sebastiaan Janssen 3daf936623 Remove hgignore files 2013-06-23 14:52:45 +02:00
Sebastiaan Janssen e93c910347 Fix more unit tests 2013-06-22 17:32:22 +02:00
Sebastiaan Janssen 7139e30296 Don't delete the config file directory, it can't sometimes
For now, don't delete umbracoSettings.config either, it makes a lot of tests fail
2013-06-22 15:53:10 +02:00
Sebastiaan Janssen df1940a01c Fix unit test by ensuring config file is copied if it doesn't exist 2013-06-22 15:07:40 +02:00
Sebastiaan Janssen aafb5a0285 Merge branch '6.0.7' into 6.1.2
Conflicts:
	src/Umbraco.Tests/PublishedCache/PublishedContentCacheTests.cs
2013-06-22 14:22:43 +02:00
Sebastiaan Janssen 033f981718 Fix unit test 2013-06-22 14:19:22 +02:00
Sebastiaan Janssen 5bd55bdd09 Merge branch '6.0.7' into 6.1.2 2013-06-21 17:33:42 +02:00
Sebastiaan Janssen 76358e3e13 U4-2374 Mono port to do: dealing with empty string 2013-06-21 17:29:55 +02:00
Sebastiaan Janssen 35c0eb3b0c U4-2377 Mono port to do: Universal currency character does not work as split character unless given in unicode. 2013-06-21 17:22:13 +02:00
Sebastiaan Janssen 7fad8ca98b U4-2378 Mono port to do: TypeFinder needs exclusions for Monodevelop Nunit 2013-06-21 17:15:42 +02:00
Sebastiaan Janssen a2da27121e U4-2335 [Regression] YSOD when editing stylesheet property on 6.0.6 2013-06-21 17:00:40 +02:00
Sebastiaan Janssen 23ec07276a U4-2369 Wrong path for Umbraco/Config/Lang/xx.xml for publish notification mail 2013-06-21 16:56:59 +02:00
Sebastiaan Janssen 96cec0b407 U4-2410 EditRelationType.aspx missing virtual path - 6.0.6 2013-06-21 16:30:44 +02:00
Sebastiaan Janssen 47b94e68e3 Merge branch '6.0.7' of github.com:umbraco/Umbraco-CMS into 6.0.7 2013-06-21 15:26:10 +02:00
Sebastiaan Janssen 0f4b1752e0 U4-2416 Missing colon in file ListChildPagesOrderedByProperty causes Web site not to run 2013-06-21 15:25:46 +02:00
Shannon eac66f5696 Merge branch '6.0.7' into 6.1.2 2013-06-21 13:00:56 +10:00
Shannon b2c604f7b3 updated ignore 2013-06-21 11:26:23 +10:00
Shannon 3f626b444f re-enables CDF logger 2013-06-21 10:55:38 +10:00
Shannon c5b8931aa6 Merge branch '6.0.7' into 6.1.2
Conflicts:
	src/Umbraco.Web.UI/config/ClientDependency.config
2013-06-21 10:50:35 +10:00
Shannon 818d22ba61 updates CDF config examples (#U4-2331) 2013-06-21 10:49:27 +10:00
Shannon f9902964b0 Merge branch '6.0.7' into 6.1.2
Conflicts:
	src/Umbraco.Web.UI/config/Dashboard.config
	src/Umbraco.Web.UI/config/ExamineIndex.config
2013-06-21 09:20:53 +10:00
Shannon 27fdb1ebab removed custom dashboard, re-put back in the external index (must have got removed by accident) 2013-06-21 09:19:50 +10:00
Shannon 1368ba8dc9 Fixes unit tests 2013-06-21 08:47:01 +10:00
Shannon 3618722574 Fixed some merging issues. 2013-06-20 15:57:23 +10:00
Shannon 24a76f53b4 Merge branch '6.0.7' into 6.1.2
Conflicts:
	src/Umbraco.Core/Umbraco.Core.csproj
	src/Umbraco.Core/Xml/XmlNodeExtensions.cs
	src/Umbraco.Web.UI/config/ClientDependency.config
	src/Umbraco.Web.UI/config/Dashboard.config
	src/Umbraco.Web/DefaultPublishedContentStore.cs
	src/Umbraco.Web/umbraco.presentation/umbraco/dialogs/moveOrCopy.aspx.cs
	src/umbraco.businesslogic/BasePages/BasePage.cs
2013-06-20 15:49:55 +10:00
Shannon 86ce48ddc8 Fixes: #U4-2312 - Moving content with the new API (and in the old api when calling library.UpdateDocumentCache(p.Id)) The document is actually moved properly in the content XML structure without republishing it and then rebuilding the entire XML structure, it just does it inline. Have also updated MoveAndCopy.aspx dialog to use the new API which now saves on about 20+ queries that were not needed. Also updated the MoveAndCopy dialog to have the correct code behind structure. 2013-06-20 15:34:57 +10:00
Shannon cb592d687c Merge branch '6.0.7' into 6.1.2 2013-06-20 11:26:01 +10:00
Shannon 2161ec98b0 Fixes: #U4-2324 - Umbraco.Field will now work with custom routed pages. 2013-06-20 11:25:33 +10:00
Shannon 5a6ee168c3 Merge branch '6.0.7' into 6.1.2 2013-06-20 10:08:50 +10:00
Shannon 52292cab60 Fixes: #U4-2403 2013-06-20 10:08:02 +10:00
Stephan 2933c879e1 U4-2327 - fix PublishedContentRequest redirect vs. permanent 2013-06-19 20:30:43 +02:00
Sebastiaan Janssen c8a19dff44 Merge branch '6.0.7' into 6.1.2
Conflicts:
	src/Umbraco.Web/Media/ImageUrl.cs
	src/Umbraco.Web/Media/ImageUrlProviders/ImageUrlProvider.cs
	src/Umbraco.Web/umbraco.presentation/umbraco/uQuery/MediaExtensions.cs
2013-06-19 18:26:45 +02:00
WadeKallhoff a6768263d3 image thumb extension fix 2013-06-19 18:11:28 +02:00
kensykora e66306978a macro rendering fix 2013-06-19 17:59:30 +02:00
Phil Dye 7f22809ebf U4-1478 Create button still visible when not active 2013-06-19 17:55:00 +02:00
Edwin de Koning 302ebde422 Translating the word "or" 2013-06-19 16:28:58 +02:00
Murray@tbpc10.terabyte.co.nz cf5624f377 #U4-2326 Added Try Catch for PlatformNotSupportedException
Signed-off-by: Sebastiaan Janssen <sebastiaan@umbraco.com>
2013-06-19 16:24:09 +02:00
Morten Bock f386c9d024 U4-1226 Umbraco:image control 2013-06-19 16:18:15 +02:00
Edwin de Koning 530fcf0ea3 Fixes U4-2261 2013-06-19 16:04:56 +02:00
Sebastiaan Janssen 26e4091f28 Due to previous fix we don't need to sort individually any more
(see changeset 32f86f750e)
2013-06-19 16:01:50 +02:00
Dennis Ravn Pedersen 32f86f750e Query would reverse logic sorting of children. Would make move operations ignore sorting.
Signed-off-by: Sebastiaan Janssen <sebastiaan@umbraco.com>
2013-06-19 15:36:08 +02:00
Sebastiaan Janssen ebad631140 Merge branch '6.0.7' into 6.1.2 2013-06-19 15:16:32 +02:00
Sebastiaan Janssen b8304c03ee Merge branch '6.0.7' of https://github.com/bokmadsen/Umbraco-CMS into bokmadsen-6.0.7 2013-06-19 14:50:41 +02:00
Sebastiaan Janssen 556c2d625f Merge branch '6.0.7' into 6.1.2
Conflicts:
	src/umbraco.cms/businesslogic/member/Member.cs
2013-06-19 14:42:14 +02:00
Sebastiaan Janssen aaa4469def Merge branch '6.0.7' of github.com:umbraco/Umbraco-CMS into 6.0.7 2013-06-19 14:36:17 +02:00
Sebastiaan Janssen baa0069262 Merge branch 'master' into 6.0.7
Conflicts:
	README.md
2013-06-19 14:22:57 +02:00
Sebastiaan Janssen 9ac4c7aef5 Merge branch 'master' of https://github.com/umbraco/Umbraco-CMS 2013-06-19 14:14:51 +02:00
Sebastiaan Janssen cb2a35594f Merge branch '6.0.6'
Conflicts:
	src/Umbraco.Core/TypeFinder.cs
2013-06-19 14:13:09 +02:00
Sebastiaan Janssen dd501d0198 Merge pull request #16 from darrenferguson/master
Remove obsoletion of Member methods
2013-06-19 05:07:35 -07:00
Sebastiaan Janssen b724d8fb32 Merge pull request #15 from pynej/master
Fix for U4-2384. Author not changed to current user when a node is copied.
2013-06-19 05:06:23 -07:00
Darren Ferguson 7c6aee17e9 Remove obsolete messages from member class
I've removed the obsolete methods from the member class because many of
the suggested alternatives don't work. and some require a lot of
configuration to get working.

Also, the member methods return Members - so they are not obsolete if
you want a reference to a member, you can choose to use System
membership if you want, but for custom properties and groups you need to
fallback to the Umbraco API, so these shouldn't be obsolete! :)
2013-06-19 13:02:58 +01:00
Jeremy Pyne 5e2c3a0a8b Fixed a type on content copy. 2013-06-18 10:38:08 -04:00
Jeremy Pyne f5121bd183 Fix for U4-2384. Author not changed to current user when a node is copied. 2013-06-18 09:35:33 -04:00
Bo Kingo Damgaard 51b5334126 Duplicate e-mail addresses: U4-315, U4-2147, U4-304
- Allows for duplicate e-mail addresses in member section by opt-in
(requiresUniqueEmail="false" in
web.config/membership/providers/"UmbracoMembershipProvider").
- Fixes issues with backoffice not checking for duplicate emails when
changing member after creation.
- Lower cases email addresses upon creating member and when searching to
prevent duplicates.
- Added Member.GetMembersByEmail to get alle members with specific email
2013-06-18 14:23:05 +02:00
Shannon 273c1956ab Fixes: #U4-2343 for api controllers, already fixed for surface controllers 2013-06-18 15:46:36 +10:00
Shannon f7c474ac2c fixed merge issue and ensures UseNamespaceFallback are set for plugin controllers. 2013-06-18 15:24:44 +10:00
Shannon 4143dbd02d Fixed some merge issues 2013-06-18 15:20:18 +10:00
Shannon 768eb3d1ed Merge branch '6.0.7' into 6.1.2
Conflicts:
	src/Umbraco.Web/Mvc/AreaRegistrationExtensions.cs
	src/Umbraco.Web/Mvc/PluginControllerArea.cs
	src/Umbraco.Web/Umbraco.Web.csproj
	src/Umbraco.Web/WebBootManager.cs
2013-06-18 15:13:43 +10:00
Shannon 120bdca9eb removed constraint names on SurfaceControllers, they don't need to be suffixed with SurfaceController, only Controller. 2013-06-18 15:05:13 +10:00
Shannon a5041aa34e Backported changes to use a real Area to do Umbraco area routes and updates our extension methods with the UseNamespaceFallback data token to only check in one namespace. 2013-06-18 14:59:00 +10:00
Shandem 59811c2841 Merge pull request #11 from florisrobbemont/6.1.2
Fix U4-2286 - IFilteredControllerFactory classes are not resolved by Umb...
2013-06-17 21:27:19 -07:00
Shannon 38eee6135e Merge branch '6.0.7' into 6.1.2 2013-06-18 14:21:11 +10:00
Shannon d3780848dc updated ignore file with correct case sensitivity 2013-06-18 14:20:50 +10:00
Shannon 5719820fad Merge branch '6.0.7' into 6.1.2
Conflicts:
	.gitignore
	src/Umbraco.Web/umbraco.presentation/umbraco/Trees/loadPackages.cs
2013-06-18 14:18:17 +10:00
Shannon 9d15228c68 manually applies patch for drag/drop fix in media for vdir 2013-06-17 03:06:24 +02:00
Shannon c9c3623457 updated ignore
Signed-off-by: Shannon <sdeminick@gmail.com>
2013-06-17 02:59:00 +02:00
Floris Robbemont aecc3d28bf Fix U4-2286 - IFilteredControllerFactory classes are not resolved by Umbraco
Simple fix, just made the FilteredCOntrollerFactoriesResolver public. This way developers can add their own on application start
2013-06-15 22:46:01 +02:00
Sebastiaan Janssen b51022575f Merge pull request #8 from mattbrailsford/6.1.2
Updated RenderMvcController to have the view engines test for file existance
2013-06-13 03:42:34 -07:00
Sebastiaan Janssen 6600e9c899 Merge pull request #6 from dpen2000/UserPermisionsFixIn6.1.2
Fix U4-2320 - Error on saving User Permissions (for 6.1.2 release)
2013-06-13 03:18:37 -07:00
Sebastiaan Janssen 68aa2abbc0 Merge pull request #7 from pynej/6.1.2
Fixed Ctl+S on stylesheets editor.
2013-06-13 03:11:57 -07:00
Sebastiaan Janssen e0a483ca48 Merge pull request #5 from tcmorris/patch-1
Update README.md
2013-06-13 02:05:43 -07:00
mattbrailsford 9b78cb3f7c Updated RenderMvcController to have the view engines test for file existance, rather than assuming views will always be razor. This allows alternative MVC view engines to be used. 2013-06-13 09:26:45 +01:00
Jeremy Pyne c6c90fde44 Fixed Ctl+S on stylesheets editor. 2013-06-12 23:41:49 -03:00
david.pendray 773500332b Fix U4-2320 - Error on saving User Permissions
Nodes can be null but NodeIds property always returns a collection and this will return Ids from Nodes if _nodeIds are null and Nodes is not.
2013-06-13 02:50:25 +01:00
Thomas Morris 95eb00a81c Update README.md
Updating link and formatting
2013-06-12 18:24:54 +02:00
Sebastiaan Janssen 3921b0974e Merge pull request #3 from Jayshoe/patch-1
Sitemap provider be gone! Issue #U4-1950
2013-06-12 07:19:56 -07:00
Jayshoe 2cd07c841f Sitemap provider be gone! Issue #U4-1950 2013-06-12 16:19:14 +02:00
Sebastiaan Janssen 8f80f0e95c Merge pull request #2 from Jeavon/patch-1
Update README.md
2013-06-12 06:38:32 -07:00
Jeavon 73ac2c0309 Update README.md
Readme.md corrections and updates
2013-06-12 15:34:26 +02:00
Sebastiaan Janssen a5ddb6c818 Merge pull request #1 from dpen2000/patch-1
Update README.md
2013-06-12 06:10:28 -07:00
dpen2000 458e61e049 Update README.md
Fix link to Umbraco releases page
2013-06-12 14:45:41 +02:00
Sebastiaan Janssen 0815842640 Update README.md 2013-06-12 11:10:18 +03:00
Sebastiaan Janssen 53b31a5c1b Update README.md 2013-06-12 10:04:31 +02:00
Sebastiaan Janssen 292dd9115b Update README.md 2013-06-11 00:57:36 +02:00
Sebastiaan Janssen c6d0a9be00 Update README.md 2013-06-11 00:57:34 +02:00
Sebastiaan Janssen 14c3acc4b7 Create README.md 2013-06-11 00:57:31 +02:00
Sebastiaan Janssen a4098b5d25 Update README.md 2013-06-11 00:57:03 +02:00
Sebastiaan Janssen acdcca0b91 Add missing files 2013-06-11 00:48:29 +02:00
Sebastiaan Janssen 33ff82e766 Add missing files 2013-06-11 00:47:44 +02:00
Sebastiaan Janssen 5fd90e1c13 Update README.md 2013-06-10 19:17:37 +03:00
Sebastiaan Janssen a6eaec9ecb Update README.md 2013-06-10 19:09:03 +03:00
Sebastiaan Janssen f5553bcc06 Create README.md 2013-06-10 18:05:07 +02:00
leekelleher e0c68a8e1c Resolves #U4-184 Upgrade package when installing a newer version.
Multiple package versions can be installed, only the latest version is listed under "Installed Packages".
When the installed package is viewed, a list of previously installed versions (of that package) are listed.
2013-06-10 13:55:58 -01:00
Morten Christensen bc1b2dc5f4 Fixes #U4-2333 2013-06-07 05:19:45 -02:00
Morten Christensen 0bb643672f Adding some minor changes/adjustments to the TypeFinder to make a bit more flexible for external usage. 2013-06-07 05:19:25 -02:00
Shannon Deminick 813d60521c Merge with 6.0.7 2013-06-03 16:27:20 -10:00
Shannon Deminick 5212d17f49 Fixes: #U4-2313 - manually adding a reserved route value in BeginUmbracoForm 2013-06-03 14:56:15 -10:00
Shannon Deminick 932115585e Fixes: #U4-2315 - CDF grouping issue, updated to new version 2013-06-03 13:35:41 -10:00
Sebastiaan Janssen 948ffe4796 Merge with 6.0.7 2013-06-03 15:11:44 -02:00
Sebastiaan Janssen 6b1dd07310 Fixes U4-2254 [Object object] error when selecting media link for content. 2013-06-03 15:11:23 -02:00
Sebastiaan Janssen dc2554c6d0 Fixes U4-2254 [Object object] error when selecting media link for content. 2013-06-03 15:08:56 -02:00
Sebastiaan Janssen 5c6514929e Opening branch 6.1.2 2013-06-03 06:16:19 -02:00
Sebastiaan Janssen 9739b3e2ef Closing branch 6.1.1 2013-06-03 06:15:57 -02:00
Sebastiaan Janssen 0b1f72f139 Added tag release-6.1.1 for changeset 7271ae03cb53 2013-06-03 06:15:31 -02:00
Morten Christensen 2a2e867784 Fxies U4-2257 2013-06-02 11:30:27 -02:00
Sebastiaan Janssen 79e0242468 Show containers in folderbrowser again 2013-06-02 05:03:51 -02:00
Morten Christensen 242443d861 Fixes the EntityRepository for Content and Media, so trees load correctly.
Fixes U4-2306
Fixes loading of MNTP.
FolderBrowser is now able to show multiple images on a single media item.
FolderBrowser only shows images and not containers.
2013-06-01 20:40:51 -02:00
Sebastiaan Janssen 7c066b9ded Merge with 6.0.7 2013-05-31 14:01:21 -02:00
Sebastiaan Janssen 159d605434 U4-2262 Release 6.1.0 Build 2 (Beta) has Razor Errors on scripting files 2013-05-31 13:59:35 -02:00
Sebastiaan Janssen 1971006a48 Merge with 6.0.7 2013-05-31 12:16:09 -02:00
Sebastiaan Janssen 5c0c33a46b Fixes U4-2304 Typo bug in umbraco.cms.businesslogic.packager 2013-05-31 12:14:03 -02:00
Sebastiaan Janssen 9bd255d9a5 Include ExamineManagementIco.png in project so it's included in the build 2013-05-31 11:35:21 -02:00
Sebastiaan Janssen cc7f41d9ee U4-2295 Templates tree doesn't refresh and Master template stays at "None" 2013-05-31 09:15:10 -02:00
Sebastiaan Janssen b4b0a37c2c Fixes U4-2302 Breaking change in 6.1? Macro parameter "contentPicker" no longer
passes an id, but a node
2013-05-31 09:13:25 -02:00
Sebastiaan Janssen 8c841f97cc Merge with 6.0.7 2013-05-31 05:57:18 -02:00
Sebastiaan Janssen a1ee352514 Additional fix for U4-335 Image cropper out of memory 2013-05-31 05:46:10 -02:00
Morten Christensen c25b06b15f Fixes #U4-2296 2013-05-30 14:28:34 -02:00
Sebastiaan Janssen 78bfb6a8cc Fix missing Examine dashboard 2013-05-30 10:26:54 -02:00
Sebastiaan Janssen d8a8bf5f74 Bump version number 2013-05-30 10:26:40 -02:00
Sebastiaan Janssen b70c98ea74 Merge with 6.0.7 2013-05-30 10:25:20 -02:00
Sebastiaan Janssen a8ad8c2a43 Bump version number 2013-05-30 10:23:35 -02:00
Sebastiaan Janssen 96f8cd3d60 Opening branch 6.1.1 2013-05-30 10:21:34 -02:00
Sebastiaan Janssen 91436ad247 Closing branch 6.1.0 2013-05-30 10:20:59 -02:00
Sebastiaan Janssen 678f911ff1 Added tag release-6.1.0 for changeset 8309c3bd6db5 2013-05-30 10:20:36 -02:00
Sebastiaan Janssen afbe3ca3b9 Creating branch 6.0.7 2013-05-30 09:57:33 -02:00
Sebastiaan Janssen 32d6f2e50c Closing branch 6.0.6 2013-05-30 09:57:03 -02:00
Sebastiaan Janssen 9909f5b6be Added tag release-6.0.6 for changeset 953c466faf8f 2013-05-30 09:56:32 -02:00
Sebastiaan Janssen ddbe15de08 Config file formatting, remove logger from CD for now as it was throwing errors 2013-05-30 08:47:17 -02:00
Sebastiaan Janssen 5c5d63ce9a web.Template.config formatting 2013-05-30 06:26:55 -02:00
Morten Christensen d3916a1d85 Sorting - now it works 2013-05-29 13:37:41 -02:00
Morten Christensen db7cb2dcb4 Merge with 6.0.6 2013-05-29 13:18:40 -02:00
Morten Christensen 6281268954 Updating sort method in Content- and MediaService 2013-05-29 13:18:03 -02:00
Sebastiaan Janssen cd606a7e9e Merge 2013-05-29 05:41:50 -02:00
Sebastiaan Janssen ae9d77a765 Bump version number 2013-05-29 05:40:55 -02:00
Morten Christensen f6e44b4e7c Merge with 6.0.6 2013-05-29 05:38:35 -02:00
Morten Christensen 8e1c45e981 Updating Sort methods to skip items that hasn't been sorted 2013-05-29 05:37:55 -02:00
Sebastiaan Janssen 955282f260 Merge with 6.0.6 2013-05-29 03:49:44 -02:00
Sebastiaan Janssen 4a7ee52d63 Merge with 4.11.9 2013-05-29 03:47:26 -02:00
Sebastiaan Janssen b4d88b0361 U4-2279 TryGetRouteDefinitionFromAncestorViewContexts has infinite loop when
currentContext doesnt contain umbraco-route-def
2013-05-29 03:44:01 -02:00
Sebastiaan Janssen b41cf37dd5 U4-2290 Notifications do not handle fields that have null values. 2013-05-29 03:42:20 -02:00
Shannon Deminick e6fcdc8dc6 Fixes: #U4-2279 2013-05-28 14:16:39 -10:00
Shannon Deminick 547a137b9a Merge 2013-05-28 13:49:17 -10:00
Shannon Deminick 5041e6fcc4 Updated to latest CDF version that has a few bug fixes and added a CDF logger. 2013-05-28 13:24:48 -10:00
Sebastiaan Janssen db0d139a39 Merge with 6.0.6 2013-05-28 15:48:51 -02:00
Sebastiaan Janssen fc32100142 Merge with 4.11.9 2013-05-28 15:45:59 -02:00
Sebastiaan Janssen 7ecbc3b391 Fixes U4-2248 Spelling error in back office 2013-05-28 15:44:59 -02:00
Sebastiaan Janssen c3c44df52e Merge with 4.11.9 2013-05-28 15:43:40 -02:00
Sebastiaan Janssen 13a86624ff Fixes U4-2248 Spelling error in back office 2013-05-28 15:39:12 -02:00
Sebastiaan Janssen 2f61bc27c8 Bump version number 2013-05-28 15:15:32 -02:00
Sebastiaan Janssen f484dbf0fc Fix merge issue 2013-05-28 12:37:29 -02:00
Sebastiaan Janssen 6d0ededd9f Merge with 6.0.6 2013-05-28 12:21:31 -02:00
Sebastiaan Janssen e7d157a209 Merge with 4.11.9 2013-05-28 12:18:49 -02:00
Sebastiaan Janssen d3ed90c23e Some fixes & refactor 2013-05-28 12:10:29 -02:00
Shannon Deminick f6155d8e49 Fixes: #U4-2243 - reverts code to use the legacy API to create a template until the new template service is updated to work as it did. 2013-05-27 17:13:12 -10:00
Sebastiaan Janssen c1cd609325 Merge with 6.0.6 2013-05-27 10:23:03 -02:00
Sebastiaan Janssen b916360771 Merge with 4.11.9 2013-05-27 10:22:20 -02:00
Sebastiaan Janssen db4b93dbc3 Update test because of new added restextension (EmbedMediaService) 2013-05-27 10:21:14 -02:00
Sebastiaan Janssen fa8934f89a Merge with 6.0.6 2013-05-27 10:09:00 -02:00
Sebastiaan Janssen c6940096d3 Merge 2013-05-27 10:08:36 -02:00
Sebastiaan Janssen 40868ac361 Merge 2013-05-27 10:02:01 -02:00
Sebastiaan Janssen f399a9f52b Merge with 4.11.9 2013-05-27 10:00:28 -02:00
Sebastiaan Janssen 562851b93e Possible fix for U4-2251 TreeDataService throws JSON JavaScriptSerializer. The
length of the string exceeds the value set on the maxJsonLength property
2013-05-27 09:59:02 -02:00
Morten Christensen 634e4a6949 Merge with 6.0.6 2013-05-27 08:47:14 -02:00
Morten Christensen e61b567ee1 Fixes #U4-2270 and #U4-2269 2013-05-27 08:45:07 -02:00
Sebastiaan Janssen 7ccae64dd1 Fix merge issue 2013-05-27 08:19:20 -02:00
Sebastiaan Janssen aef44065c5 Merge with 6.0.6 2013-05-27 08:17:49 -02:00
Sebastiaan Janssen 4ce22b836e Merge with 4.11.9 2013-05-27 08:16:18 -02:00
Sebastiaan Janssen 2b8544b4c7 Merge 2013-05-27 07:40:59 -02:00
Sebastiaan Janssen 6afa6a277f Fixes U4-2263 unable to create or save stylesheet content 2013-05-27 07:40:29 -02:00
Sebastiaan Janssen f5bf05a6f5 Move embed media service from webservices dll into it's own /base class 2013-05-27 07:19:42 -02:00
Morten Christensen 469db82f1d Internal creation of backoffice users and unit test to verify 2013-05-27 06:50:14 -02:00
Sebastiaan Janssen e50569597b Minor update to legacy ajax calls 2013-05-27 06:10:04 -02:00
Sebastiaan Janssen 071f3dcc01 Fix javascript error with the speechbubble 2013-05-27 06:05:13 -02:00
Morten Christensen e0bc99af9c Merge 2013-05-24 08:14:07 -02:00
Morten Christensen 232581664b Moving internal membership provider classes.
Adding missing alias to AllowedContentTypes on ContentType.
Adding Package export test.
2013-05-24 08:13:24 -02:00
Shannon Deminick b15e147d6b Removed internal classes relating to property editors that are not used and were initially ported from v5 but we'll be
creating new/different ones for v7.
2013-05-23 21:32:26 -10:00
Morten Christensen c7a4c782e3 Internal work around the creation of users through the new api. 2013-05-23 13:25:14 -02:00
Morten Christensen 780908e24f Fixing merge issues and updating nodeSorter to use EntityService and new Sort method for improved performance.
Fixes #U4-1750
2013-05-23 11:34:06 -02:00
Morten Christensen 3ac7e237c4 Merge with 6.0.6 2013-05-23 10:38:09 -02:00
Morten Christensen 6943a454f3 Implementing Sort-method for the Content/MediaService 2013-05-23 10:29:44 -02:00
Morten Christensen e870db3c29 Fixing MacroTests that had a dependency on the Profiler, which wasn't setup in the fixture. 2013-05-22 11:24:46 -02:00
Morten Christensen 41b17160f7 Excluding a few new classes, which won't make it into 6.1.0. 2013-05-22 11:08:27 -02:00
Morten Christensen b19621c07b Improving tree performance for Content and Media trees using the new EntityService and the thin IUmbracoEntity object.
Updating a few internal overloads as well as adding new ones to ensure backwards compatibility for events used by the tree.
Fixing issue with the Published/Unpublished/Saved/Pending Changes states shown in the content tree.
2013-05-22 11:06:21 -02:00
Morten Christensen 0ff979e814 Adding missing method for retreiving parent or child relations.
Implements #U4-2237
2013-05-22 07:53:16 -02:00
Morten Christensen f26e39f5ce Adding a new extensibility in relation to #U4-2244 which allows consumers of the CoreBootManager to explicitly set the path to the root of an umbraco site/solution.
A bit of cleanup in the IOHelper class.
2013-05-22 07:48:42 -02:00
Morten Christensen 9a6030a3eb Fixes #U4-2244 2013-05-22 07:12:58 -02:00
Morten Christensen 84ef216d57 Merge 2013-05-17 05:51:49 -02:00
Morten Christensen ecfe51134d Updating the internal standalone context, and adding one that is limited to the core assembly to limit dependencies. 2013-05-17 05:51:22 -02:00
Shannon Deminick c8414116ad Merge with 6.0.6 2013-05-14 14:21:15 -10:00
Shannon Deminick 532f407260 Merge with 4.11.9 2013-05-14 14:20:52 -10:00
Shannon Deminick 834d04f8ed Fixes: #U4-1469, #U4-1156 2013-05-14 14:18:41 -10:00
Shannon Deminick 2aa902beaf Fixed up unit test 2013-05-14 13:50:16 -10:00
Shannon Deminick 2f16e6662d updates disposable timer to ensure it also outputs to HttpTrace if there is one. 2013-05-14 13:39:55 -10:00
Shannon Deminick 0c4897d7c1 Changed the trace logger for PublishedContentRequestEngine to be correct. 2013-05-13 22:32:02 -10:00
Shannon Deminick 43dc14fa93 Changed over all direct calls to the profiler to use DisposableTimer.DebugDuration 2013-05-13 22:17:55 -10:00
Shannon Deminick e209aa3c2a Streamlined the profiling in the macro class. 2013-05-13 22:13:52 -10:00
Shannon Deminick 5890fe1849 Upgraded DisposableTimer to wrap the profiler... now we should really just use DisposableTimer for all profiling. 2013-05-13 21:11:03 -10:00
Shannon Deminick b6f52bf782 Changed the profiler over to use resolvers again. We no longer will call MiniProfiler directly.
Added an HtmlHelper extension which is used to render the profiler html output.
Added an HtmlHelper property to the new base page too.
2013-05-13 20:10:28 -10:00
Shannon Deminick 922ebe5411 Started implementing static cache provider for the application cache... centralizing static cache. 2013-05-13 19:31:27 -10:00
dmilic f36ab37f6a Fix for the U4-2229 issue - broken PublishWithSubs method 2013-05-13 15:49:59 -12:00
Sebastiaan Janssen aeff33d0a6 Bump version number 2013-05-28 15:17:55 -02:00
Sebastiaan Janssen 645637d550 Merge with 6.0.6 2013-05-13 13:48:34 -02:00
Sebastiaan Janssen 5cfe9e57ce Merge with 4.11.9 2013-05-13 13:47:01 -02:00
Sebastiaan Janssen 4863e657df Fixes U4-2226 Javascript error "tinyMCE is undefined" in IE - THANKS Adriano Buscema! 2013-05-13 13:42:57 -02:00
Shannon Deminick 2486e75210 Merge with 6.0.6 2013-05-12 23:57:09 -10:00
Shannon Deminick c0e1be4df9 Merge 2013-05-12 23:56:47 -10:00
Sebastiaan Janssen a93e562f14 Fixes U4-2209 6.0.5 - Bug - Empty recycle bin DELETES all content 2013-05-13 07:48:35 -02:00
Shannon Deminick 2201c644f7 Merge with 6.0.6 2013-05-12 21:49:38 -10:00
Shannon Deminick 822cac5d87 Adds test for #U4-2207 which will now pass but it will still fail on the website because of the case
sensitive checking for the default proeprty editor lookup. Need feedback from sebastian before continuing
2013-05-12 21:44:02 -10:00
Shannon Deminick d58487fafc Merge 2013-05-12 21:13:50 -10:00
Shannon Deminick ea9653fa83 patches fix for #U4-2214 2013-05-12 21:12:55 -10:00
Shannon Deminick b38397868e Fixes: #U4-2214 - encrypted cookie value issue when it is invalid 2013-05-12 21:07:16 -10:00
Shannon Deminick 7d1a18638b missing proj checking 2013-05-12 21:06:53 -10:00
Shannon Deminick 748e88c3e8 added web.config files to the root of xslt folders which will disable the ability for people
to publicly download other's xslt files .
2013-05-12 19:29:05 -10:00
Shannon Deminick cb8d080f1d Removes the abstraction on the profiler, no need for a resolver, it will work in unit tests and we can override the provider if needed.
Added better support for MVC profiling by using the built in ProfilingViewEngine and ProfilingActionFilter.
2013-05-12 19:05:49 -10:00
Shannon Deminick 3fd3bf0fda updated extensino method to prefix the type name better. 2013-05-12 18:17:53 -10:00
Shannon Deminick 09a6cdc8b6 Removed all MiniProfile calls that were trying to be simple trace messages (not actually profiling). This doesn't actually
work since MiniProfiler was not meant for that and won't actually output them unless you add Thread.Sleep statements into the using
clauses simply to slow down the application, not ideal. Updated the WebProfiler to log a statement when in medium trust.
2013-05-12 18:06:26 -10:00
Shannon Deminick b2fe35695f Fixes MiniProfile implementation for macros. 2013-05-12 17:38:54 -10:00
Shannon Deminick 67b57dea50 Changes profiler over to use a resolver and uses an interface for it. Changes core over to use a
LogProfiler and the web project to use a web profiler (MiniProfiler). Fixes medium trust implementation,
adds performance check for binding to begin request, changes Web profiler over to be decoupled from the
umbraco application objects (binds to events by itself)
2013-05-12 15:25:46 -10:00
Sebastiaan Janssen 3d6172738f Added tag release-6.1.0-beta2 for changeset 7670bb47a671 2013-05-10 11:00:57 -02:00
Morten Christensen d94772892d Merge 2013-05-08 06:28:13 -02:00
Morten Christensen 50c12a5c35 Merge 2013-05-07 12:35:28 -02:00
Morten Christensen b42fb1c5c1 WIP Related to PackagingService 2013-05-07 12:35:13 -02:00
Shannon Deminick af51465a6a Merge 2013-04-29 19:57:44 -10:00
Sebastiaan Janssen c2057656bc Merge with 6.0.4 2013-04-25 11:23:31 -02:00
Sebastiaan Janssen 09a4e33f3f Closing again.. 2013-04-25 11:20:21 -02:00
Thomas Skyldahl Sørensen c12f9d0272 Optimization for issue: U4-1187
Url: http://issues.umbraco.org/issue/U4-1187

Added assembly filtering, to stop scanning of third party assemblies
that doesn't reference the types we are looking for.
this limits the amount of possible missing references we encounter
when checking against the types
2013-04-17 14:03:54 -02:00
Sebastiaan Janssen d2d1843e03 Fix default branch 2013-04-08 07:03:57 -02:00
Sebastiaan Janssen a89a122b09 Merge with 6.0.3 2013-03-27 11:56:44 -01:00
Shannon Deminick e5e22f75fc Merge 2013-03-11 18:47:36 +06:00
Sebastiaan Janssen cab21e9d48 Merge with 6.0.1 2013-03-01 06:51:38 -01:00
Sebastiaan Janssen 2e7c26fcc0 Closing branch 6.0.1 2013-03-01 06:49:59 -01:00
Sebastiaan Janssen 0f6c41679c Added tag Release-6.0.1 for changeset 92410e141d9c 2013-03-01 06:49:45 -01:00
Sebastiaan Janssen 777d397ae7 Merge with 6.0.0 2013-01-31 14:07:05 -01:00
Adam Nelson 41258104f6 U4-497 - Razor errors should be completely silent when UmbracoDebug=false.
Modified implementation to have a single global setting in UmbracoSettings.config
which can now be overridden when the umbraco.macro.Error event is handled on a
per-macro basis if desired.
2013-01-16 00:45:18 -11:00
Adam Nelson 08a8e6b816 U4-497 : Razor errors should be completely silent when UmbracoDebug=false.
Optionally requires macroErrors.config to define macro error behaviour.
See http://issues.umbraco.org/issue/U4-497.
2013-01-14 00:48:54 -11:00
254 changed files with 6269 additions and 2889 deletions
+81
View File
@@ -0,0 +1,81 @@
*.obj
*.pdb
*.user
*.aps
*.pch
*.vspscc
[Bb]in
[Db]ebug*/
obj/
[Rr]elease*/
_ReSharper*/
_NCrunch_*/
*.ncrunchsolution
*.ncrunchsolution.user
*.ncrunchproject
*.crunchsolution.cache
[Tt]est[Rr]esult*
[Bb]uild[Ll]og.*
*.[Pp]ublish.xml
*.suo
[sS]ource
[sS]andbox
umbraco.config
*.vs10x
App_Data/TEMP/*
[Uu]mbraco/[Pp]resentation/[Uu]mbraco/[Pp]lugins/*
[Uu]mbraco/[Pp]resentation/[Uu]ser[Cc]ontrols/*
[Uu]mbraco/[Pp]resentation/[Ss]cripts/*
[Uu]mbraco/[Pp]resentation/[Ff]onts/*
[Uu]mbraco/[Pp]resentation/[Cc]ss/*
src/Umbraco.Web.UI/[Cc]ss/*
src/Umbraco.Web.UI/App_Code/*
src/Umbraco.Web.UI/App_Data/*
src/Umbraco.Tests/App_Data/*
src/Umbraco.Web.UI/[Mm]edia/*
src/Umbraco.Web.UI/[Mm]aster[Pp]ages/*
src/Umbraco.Web.UI/[Mm]acro[Ss]cripts/*
src/Umbraco.Web.UI/[Xx]slt/*
src/Umbraco.Web.UI/[Ii]mages/*
src/Umbraco.Web.UI/[Ss]cripts/*
src/Umbraco.Web.UI/Web.*.config.transformed
umbraco/presentation/umbraco/plugins/uComponents/uComponentsInstaller.ascx
umbraco/presentation/packages/uComponents/MultiNodePicker/CustomTreeService.asmx
_BuildOutput/*
build/UmbracoCms.AllBinaries*zip
build/UmbracoCms.WebPI*zip
build/UmbracoCms*zip
build/*.nupkg
src/Umbraco.Tests/config/applications.config
src/Umbraco.Tests/config/trees.config
src/Umbraco.Web.UI/web.config
*.orig
src/Umbraco.Tests/config/404handlers.config
src/Umbraco.Web.UI/[Vv]iews/*.cshtml
src/Umbraco.Web.UI/[Vv]iews/*.vbhtml
src/Umbraco.Tests/[Cc]onfig/umbracoSettings.config
src/Umbraco.Web.UI/[Vv]iews/*
src/packages/
src/packages/repositories.config
src/Umbraco.Web.UI/[Ww]eb.config
*.transformed
webpihash.txt
node_modules
src/Umbraco.Web.UI/[Uu]mbraco/[Ll]ib/*
src/Umbraco.Web.UI/[Uu]mbraco/[Jj]s/umbraco.*
src/Umbraco.Web.UI/[Uu]mbraco/[Jj]s/routes.js
src/Umbraco.Web.UI/[Uu]mbraco/[Jj]s/main.js
src/Umbraco.Web.UI/[Uu]mbraco/[Jj]s/app.js
src/Umbraco.Web.UI/[Uu]mbraco/[Vv]iews/**/*.js
src/Umbraco.Web.UI/[Uu]mbraco/[Vv]iews/**/*.css
src/Umbraco.Web.UI/[Uu]mbraco/[Vv]iews/**/*.html
src/Umbraco.Web.UI/[Uu]mbraco/[Aa]ssets/*
src/Umbraco.Web.UI.Client/[Bb]uild/*
src/Umbraco.Web.UI.Client/[Bb]uild/[Bb]elle/
src/Umbraco.Web.UI/[Uu]ser[Cc]ontrols/
build/_BuildOutput/
tools/NDepend/
-70
View File
@@ -1,70 +0,0 @@
syntax: regexp
^src/packages/(?!repositories.config$)
web.Template.[a-zA-Z0-9]*.Debug.config
syntax: glob
*.obj
*.pdb
*.user
*.aps
*.pch
*.vspscc
[Bb]in
[Db]ebug*/
obj/
[Rr]elease*/
_ReSharper*/
_NCrunch_*/
*.ncrunchsolution
*.ncrunchsolution.user
*.ncrunchproject
*.crunchsolution.cache
[Tt]est[Rr]esult*
[Bb]uild[Ll]og.*
*.[Pp]ublish.xml
*.suo
[sS]ource
[sS]andbox
umbraco.config
*.vs10x
App_Data\TEMP\*
umbraco\presentation\umbraco\plugins\*
umbraco\presentation\usercontrols\*
umbraco\presentation\scripts\*
umbraco\presentation\fonts\*
umbraco\presentation\css\*
src\Umbraco.Web.UI\[Cc]ss\*
src\Umbraco.Web.UI\App_Code\*
src\Umbraco.Web.UI\App_Data\*
src\Umbraco.Tests\App_Data\*
src\Umbraco.Web.UI\[Mm]edia\*
src\Umbraco.Web.UI\[Mm]aster[Pp]ages\*
src\Umbraco.Web.UI\[Mm]acro[Ss]cripts\*
src\Umbraco.Web.UI\[Xx]slt\*
src\Umbraco.Web.UI\[Ii]mages\*
src\Umbraco.Web.UI\[Ss]cripts\*
src\Umbraco.Web.UI\Web.*.config.transformed
umbraco\presentation\umbraco\plugins\uComponents\uComponentsInstaller.ascx
umbraco\presentation\packages\uComponents\MultiNodePicker\CustomTreeService.asmx
_BuildOutput/*
*.ncrunchsolution
build/UmbracoCms.AllBinaries*zip
build/UmbracoCms.WebPI*zip
build/UmbracoCms*zip
build/*.nupkg
src/Umbraco.Tests/config/applications.config
src/Umbraco.Tests/config/trees.config
src/Umbraco.Web.UI/web.config
*.orig
src/Umbraco.Tests/config/404handlers.config
src/Umbraco.Web.UI/Views/*.cshtml
src/Umbraco.Web.UI/Views/*.vbhtml
src/Umbraco.Tests/config/umbracoSettings.config
src/Umbraco.Web.UI/App_Plugins/*
src/Umbraco.Web.UI/Views/*
src/packages/
src\Umbraco.Web.UI\[W]eb.config
*.transformed
-34
View File
@@ -1,34 +0,0 @@
d0aba247db91d1b70c39c6397b965ca370a67497 Sprint-Juno-A
0b8f67be2ca8faf008151d87f232c698de69e735 Release-4.5.0
5960c073250926d202861a09472f5f334da6e283 Sprint-Juno-B
f15d4ff81a8368e9d42788f7e0ae726f7a70a3b1 Release-4.0.3
283065df4d3c27245267709dd2644a479c4f62a5 Release-4.0.4.2
ffc34b23e1a03785e4098afa4290d8c03cf10115 Release-4.5.2
d03fcffb8834a9583a56813bb44b6abbd9f042cc Release-4.6.0
1809f7b2593270c192cd47bdcfdb392100686f79 4.7.2
488779dec0ceb1d2874bcef906241b919325c904 4.8.0-beta
096f20bb0575d6199f20fcb3147b63554e765a74 Release-4.8.0
8f8a203857886b373148af29edd57460a42940be Release-4.8.1
de73e687ddf6086ed52b6554676c1632865d07f2 Release-4.9.0
8d7d8609e2e4b971da99cd97f72132ce85ce3333 Release-4.9.1
f6da531fbb4c251ff61d314e2a7effb13c71e74a Release-4.10.0
20e4dff821d8ac2527a5353618fa1a23ea1d8b34 Release-4.11.0
7f827760cb49d749616859f528d19dde64807947 Release-4.11.1
7f827760cb49d749616859f528d19dde64807947 Release-4.11.1
6eb5f2fb5a88aa29ea544499df9160a1b31b5638 Release-4.11.1
73711b806a4044dbf0d7d7c095ddfdda23b09932 4.11.2
73711b806a4044dbf0d7d7c095ddfdda23b09932 4.11.2
0000000000000000000000000000000000000000 4.11.2
73711b806a4044dbf0d7d7c095ddfdda23b09932 Release-4.11.2
77db220b89e166b3c0736ed321ecfd6416cddbcd Release-4.11.2.1
54cde33b809dcb3a1f7e7ae0d5375f6dd0d89c8d Release-4.11.2.2
ff3bb24ea0c915878396a6ae27f1ff164e8ac150 Release-6.0.0-beta
56015ac26f5ab60e3c61b1d09075297b660afa07 Release-6.0.0-RC
1719fbd857f28b376639ac2aa0abada0ef2e7560 Release-6.0.0
e02f5aebb87e3f07d27376647756caa9762931d8 Release-4.11.4
14338b0ab1738fbd8987677ecdb9a73d79fc229d release-4.11.6
ce47176bc6b9298741783e20f1fe2672c811f744 release-4.11.7
b247b35d821144849f551e02da8ba719f91d5fb0 Release-6.0.2
aed55cba29009ad3db48880a7cfb66407ce9805f release-6.0.3
87cf618a39e38ec58df916d10e6a924de62ae37d release-6.1.0-beta
0dee9964687ea51ea797984cf7cce3655d6a6558 release-6.0.4
+33
View File
@@ -0,0 +1,33 @@
Umbraco CMS
===========
## Watch a five minute introduction video ##
[![ScreenShot](http://umbraco.com/images/whatisumbraco.png)](http://umbraco.org/help-and-support/video-tutorials/getting-started/what-is-umbraco)
## Umbraco - the simple, flexible and friendly ASP.NET CMS ##
**More than 177,000 sites trust Umbraco**
For the first time on the Microsoft platform a free user and developer friendly CMS that makes it quick and easy to create websites - or a breeze to build complex web applications. Umbraco has award-winning integration capabilities and supports your ASP.NET User and Custom Controls out of the box. It's a developers dream and your users will love it too.
Used by more than 177,000 active websites including [http://daviscup.com](http://daviscup.com), [http://heinz.com](http://heinz.com), [http://peugeot.com](http://peugeot.com), [http://www.hersheys.com/](http://www.hersheys.com/) and **The Official ASP.NET and IIS.NET website from Microsoft** ([http://asp.net](http://asp.net) / [http://iis.net](http://iis.net)) you can be sure that the technology is proven, stable and scales.
To view more examples please visit [http://umbraco.com/why-umbraco/#caseStudies](http://umbraco.com/why-umbraco/#caseStudies)
## Downloading ##
The downloadable Umbraco releases live at [http://our.umbraco.org/contribute/releases](http://our.umbraco.org/contribute/releases).
## Forums ##
We have a forum running on [http://our.umbraco.org](http://our.umbraco.org). The discussions group on [Google Groups](https://groups.google.com/forum/#!forum/umbraco-dev) is for discussions on developing the core, and not on Umbraco-implementations or extensions in general. For those topics, please use [http://our.umbraco.org](http://our.umbraco.org).
## Contribute to Umbraco ##
If you want to contribute back to Umbraco you should check out our [guide to contributing](http://our.umbraco.org/contribute).
## Found a bug? ##
Another way you can contribute to Umbraco is by providing issue reports, for information on how to submit an issue report refer to our [online guide for reporting issues](http://our.umbraco.org/contribute/report-an-issue-or-request-a-feature).
To view existing issues please visit [http://issues.umbraco.org](http://issues.umbraco.org)
+4 -2
View File
@@ -1,10 +1,12 @@
@ECHO OFF
SET release=6.1.0
SET comment=beta-2
SET release=6.1.2
SET comment=
SET version=%release%
IF [%comment%] EQU [] (SET version=%release%) ELSE (SET version=%release%-%comment%)
ReplaceIISExpressPortNumber.exe ..\src\Umbraco.Web.UI\Umbraco.Web.UI.csproj %release%
%windir%\Microsoft.NET\Framework\v4.0.30319\msbuild.exe "Build.proj" /p:BUILD_RELEASE=%release% /p:BUILD_COMMENT=%comment%
echo This file is only here so that the containing folder will be included in the NuGet package, it is safe to delete. > .\_BuildOutput\WebApp\App_Code\dummy.txt
+20 -1
View File
@@ -82,6 +82,7 @@
<SolutionBinFolder>$(BuildFolder)bin\</SolutionBinFolder>
<WebAppFolder>$(BuildFolder)WebApp\</WebAppFolder>
<WebPiFolder>$(BuildFolder)WebPi\</WebPiFolder>
<ConfigsFolder>$(BuildFolder)Configs\</ConfigsFolder>
<SolutionBinFolderRelativeToProjects>$(BuildFolderRelativeToProjects)bin\</SolutionBinFolderRelativeToProjects>
<SolutionBinFolderAbsolutePath>$(BuildFolderAbsolutePath)bin\</SolutionBinFolderAbsolutePath>
<WebAppFolderRelativeToProjects>$(BuildFolderRelativeToProjects)WebApp\</WebAppFolderRelativeToProjects>
@@ -197,7 +198,7 @@
</Target>
<!-- Copy the transformed web.config file to the root -->
<Target Name="CopyTransformedWebConfig" DependsOnTargets="CopyXmlDocumentation">
<Target Name="CopyTransformedWebConfig" DependsOnTargets="CopyTransformedConfig">
<ItemGroup>
<WebConfigFile Include="..\src\Umbraco.Web.UI\web.$(BuildConfiguration).Config.transformed" />
</ItemGroup>
@@ -206,6 +207,24 @@
DestinationFiles="$(WebAppFolder)Web.config"
OverwriteReadOnlyFiles="true"
SkipUnchangedFiles="false" />
</Target>
<!-- Copy the config files and rename them to *.config.transform -->
<Target Name="CopyTransformedConfig" DependsOnTargets="CopyXmlDocumentation">
<ItemGroup>
<ConfigFiles Include="$(WebAppFolder)config\*.config" />
<WebConfigTransformFile Include="$(WebAppFolder)Web.config" />
</ItemGroup>
<Copy SourceFiles="@(ConfigFiles)"
DestinationFiles="@(ConfigFiles->'$(ConfigsFolder)\%(RecursiveDir)%(Filename)%(Extension)')"
OverwriteReadOnlyFiles="true"
SkipUnchangedFiles="false" />
<Copy SourceFiles="@(WebConfigTransformFile)"
DestinationFiles="$(ConfigsFolder)Web.config.transform"
OverwriteReadOnlyFiles="true"
SkipUnchangedFiles="false" />
</Target>
<!-- Copy the xml documentation to the bin folder -->
+7 -8
View File
@@ -2,7 +2,7 @@
<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
<metadata>
<id>UmbracoCms.Core</id>
<version>6.0.0-alpha</version>
<version>6.1.2</version>
<title>Umbraco Cms Core Binaries</title>
<authors>Morten Christensen</authors>
<owners>Umbraco HQ</owners>
@@ -15,10 +15,14 @@
<language>en-US</language>
<tags>umbraco</tags>
<dependencies>
<dependency id="Microsoft.AspNet.Mvc" version="[4.0.20710.0]" />
<dependency id="Microsoft.AspNet.WebApi" version="4.0.20710.0" />
<dependency id="Microsoft.AspNet.Mvc" version="4.0" />
<dependency id="Microsoft.AspNet.WebApi" version="4.0" />
<dependency id="Microsoft.AspNet.Mvc.FixedDisplayModes" version="1.0.0" />
<dependency id="MiniProfiler" version="2.1.0" />
<dependency id="HtmlAgilityPack" version="1.4.5" />
<dependency id="Lucene.Net" version="[2.9.4.1]" />
<dependency id="SharpZipLib" version="0.86.0" />
<dependency id="MySql.Data" version="[6.6,6.7)" />
</dependencies>
</metadata>
<files>
@@ -32,16 +36,11 @@
<file src="..\_BuildOutput\WebApp\bin\controls.xml" target="lib\controls.xml" />
<file src="..\_BuildOutput\WebApp\bin\CookComputing.XmlRpcV2.dll" target="lib\CookComputing.XmlRpcV2.dll" />
<file src="..\_BuildOutput\WebApp\bin\Examine.dll" target="lib\Examine.dll" />
<file src="..\_BuildOutput\WebApp\bin\HtmlAgilityPack.dll" target="lib\HtmlAgilityPack.dll" />
<file src="..\_BuildOutput\WebApp\bin\ICSharpCode.SharpZipLib.dll" target="lib\ICSharpCode.SharpZipLib.dll" />
<file src="..\_BuildOutput\WebApp\bin\interfaces.dll" target="lib\interfaces.dll" />
<file src="..\_BuildOutput\WebApp\bin\interfaces.xml" target="lib\interfaces.xml" />
<file src="..\_BuildOutput\WebApp\bin\log4net.dll" target="lib\log4net.dll" />
<file src="..\_BuildOutput\WebApp\bin\Lucene.Net.dll" target="lib\Lucene.Net.dll" />
<file src="..\_BuildOutput\WebApp\bin\Lucene.Net.xml" target="lib\Lucene.Net.xml" />
<file src="..\_BuildOutput\WebApp\bin\Microsoft.ApplicationBlocks.Data.dll" target="lib\Microsoft.ApplicationBlocks.Data.dll" />
<file src="..\_BuildOutput\WebApp\bin\Microsoft.Web.Helpers.dll" target="lib\Microsoft.Web.Helpers.dll" />
<file src="..\_BuildOutput\WebApp\bin\MySql.Data.dll" target="lib\MySql.Data.dll" />
<file src="..\_BuildOutput\WebApp\bin\Our.Umbraco.uGoLive.47x.dll" target="lib\Our.Umbraco.uGoLive.47x.dll" />
<file src="..\_BuildOutput\WebApp\bin\Our.Umbraco.uGoLive.Checks.dll" target="lib\Our.Umbraco.uGoLive.Checks.dll" />
<file src="..\_BuildOutput\WebApp\bin\Our.Umbraco.uGoLive.dll" target="lib\Our.Umbraco.uGoLive.dll" />
+4 -4
View File
@@ -2,7 +2,7 @@
<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
<metadata>
<id>UmbracoCms</id>
<version>6.0.0-alpha</version>
<version>6.1.2</version>
<title>Umbraco Cms</title>
<authors>Morten Christensen</authors>
<owners>Umbraco HQ</owners>
@@ -21,14 +21,14 @@
<files>
<file src="..\_BuildOutput\WebApp\bin\amd64\**" target="Content\bin\amd64" />
<file src="..\_BuildOutput\WebApp\bin\x86\**" target="Content\bin\x86" />
<file src="..\_BuildOutput\WebApp\config\*.config" target="Content\config" />
<file src="..\_BuildOutput\Configs\**" target="Content\config" exclude="..\_BuildOutput\Configs\Web.config.transform" />
<file src="..\_BuildOutput\WebApp\css\**" target="Content\css" />
<file src="..\_BuildOutput\WebApp\macroScripts\**" target="Content\macroScripts" />
<file src="..\_BuildOutput\WebApp\masterpages\**" target="Content\masterpages" />
<file src="..\_BuildOutput\WebApp\media\**" target="Content\media" />
<file src="..\_BuildOutput\WebApp\scripts\**" target="Content\scripts" />
<file src="..\_BuildOutput\WebApp\usercontrols\**" target="Content\usercontrols" />
<file src="..\_BuildOutput\WebApp\Views\**" target="Content\Views" />
<file src="..\_BuildOutput\WebApp\Views\**" target="Content\Views" exclude="..\_BuildOutput\WebApp\Views\Web.config" />
<file src="..\_BuildOutput\WebApp\xslt\**" target="Content\xslt" />
<file src="..\_BuildOutput\WebApp\default.aspx" target="Content\default.aspx" />
<file src="..\_BuildOutput\WebApp\Web.config" target="Content\Web.config" />
@@ -36,7 +36,7 @@
<file src="..\_BuildOutput\WebApp\App_Code\**" target="UmbracoFiles\App_Code" />
<file src="..\_BuildOutput\WebApp\App_Data\**" target="UmbracoFiles\App_Data" />
<file src="..\_BuildOutput\WebApp\App_Plugins\**" target="UmbracoFiles\App_Plugins" />
<file src="..\_BuildOutput\WebApp\config\**" target="UmbracoFiles\config" />
<file src="..\_BuildOutput\WebApp\config\splashes\**" target="UmbracoFiles\config\splashes" />
<file src="..\_BuildOutput\WebApp\install\**" target="UmbracoFiles\install" />
<file src="..\_BuildOutput\WebApp\umbraco\**" target="UmbracoFiles\umbraco" />
<file src="..\_BuildOutput\WebApp\umbraco_client\**" target="UmbracoFiles\umbraco_client" />
+8 -5
View File
@@ -1,15 +1,18 @@
A note about running Umbraco from Visual Studio.
When upgrading your website using nuget a backup of config files and web.config will be created and the files will
be overwritten with those from the current release. This means that you'll have to merge the files if you made any
changes to the previous config files.
When upgrading your website using nuget a backup of config files and web.config will be created. Only the web.config will
be overwritten by default to ensure that it has the necessary settings from the current release. This means that you'll
have to merge the files if you made any changes to the previous config files.
The config files found in the config folder will usually not be changed for patch releases, so they can usually be skipped,
but the web.config will have to have its previous "umbracoConfigurationStatus"-appsetting and "umbracoDbDSN" connection string
copied over (as a minimum).
It's not possible to create a deploy package from Visual Studio, which contains everything out of the box. This is
due to a number of files and folders that are not added to the Visual Studio project. These folders include:
install, umbraco and umbraco_client.
A custom deploy script will be added in a later release.
Please read the release notes on Codeplex:
http://umbraco.codeplex.com/releases
Please read the release notes on our.umbraco.org:
http://our.umbraco.org/contribute/releases
- Umbraco
Binary file not shown.
Binary file not shown.
+6 -5
View File
@@ -17,7 +17,8 @@
</PropertyGroup>
<ItemGroup Condition=" '$(PackageSources)' == '' ">
<!-- Package sources used to restore packages. By default will used the registered sources under %APPDATA%\NuGet\NuGet.Config -->
<!-- Package sources used to restore packages. By default, registered sources under %APPDATA%\NuGet\NuGet.Config will be used -->
<!-- The official NuGet package source (https://nuget.org/api/v2/) will be excluded if package sources are specified and it does not appear in the list -->
<!--
<PackageSource Include="https://nuget.org/api/v2/" />
<PackageSource Include="https://my-nuget-source/nuget/" />
@@ -54,10 +55,10 @@
<BuildCommand>$(NuGetCommand) pack "$(ProjectPath)" -p Configuration=$(Configuration) -o "$(PackageOutputDir)" -symbols</BuildCommand>
<!-- We need to ensure packages are restored prior to assembly resolve -->
<ResolveReferencesDependsOn Condition="$(RestorePackages) == 'true'">
<BuildDependsOn Condition="$(RestorePackages) == 'true'">
RestorePackages;
$(ResolveReferencesDependsOn);
</ResolveReferencesDependsOn>
$(BuildDependsOn);
</BuildDependsOn>
<!-- Make the build depend on restore packages -->
<BuildDependsOn Condition="$(BuildPackage) == 'true'">
@@ -75,7 +76,7 @@
This effectively acts as a lock that makes sure that the download operation will only happen once and all
parallel builds will have to wait for it to complete.
-->
<MsBuild Targets="_DownloadNuGet" Projects="$(MSBuildThisFileFullPath)" Properties="Configuration=NOT_IMPORTANT" />
<MsBuild Targets="_DownloadNuGet" Projects="$(MSBuildThisFileFullPath)" Properties="Configuration=NOT_IMPORTANT;DownloadNuGetExe=$(DownloadNuGetExe)" />
</Target>
<Target Name="_DownloadNuGet">
+2 -12
View File
@@ -1,12 +1,10 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.Web.Caching;
namespace Umbraco.Core.Cache
{
/// <summary>
/// An abstract class for implementing a cache helper
/// An abstract class for implementing a basic cache provider
/// </summary>
/// <remarks>
/// THIS MUST REMAIN INTERNAL UNTIL WE STREAMLINE HOW ALL CACHE IS HANDLED, WE NEED TO SUPPORT HTTP RUNTIME CACHE, IN MEMORY CACHE, ETC...
@@ -22,13 +20,5 @@ namespace Umbraco.Core.Cache
public abstract IEnumerable<T> GetCacheItemsByKeySearch<T>(string keyStartsWith);
public abstract T GetCacheItem<T>(string cacheKey);
public abstract T GetCacheItem<T>(string cacheKey, Func<T> getCacheItem);
public abstract T GetCacheItem<T>(string cacheKey, TimeSpan? timeout, Func<T> getCacheItem);
public abstract T GetCacheItem<T>(string cacheKey, CacheItemRemovedCallback refreshAction, TimeSpan? timeout, Func<T> getCacheItem);
public abstract T GetCacheItem<T>(string cacheKey, CacheItemPriority priority, CacheItemRemovedCallback refreshAction, TimeSpan? timeout, Func<T> getCacheItem);
public abstract T GetCacheItem<T>(string cacheKey, CacheItemPriority priority, CacheItemRemovedCallback refreshAction, CacheDependency cacheDependency, TimeSpan? timeout, Func<T> getCacheItem);
public abstract void InsertCacheItem<T>(string cacheKey, CacheItemPriority priority, Func<T> getCacheItem);
public abstract void InsertCacheItem<T>(string cacheKey, CacheItemPriority priority, TimeSpan? timeout, Func<T> getCacheItem);
public abstract void InsertCacheItem<T>(string cacheKey, CacheItemPriority priority, CacheDependency cacheDependency, TimeSpan? timeout, Func<T> getCacheItem);
public abstract void InsertCacheItem<T>(string cacheKey, CacheItemPriority priority, CacheItemRemovedCallback refreshAction, CacheDependency cacheDependency, TimeSpan? timeout, Func<T> getCacheItem);
}
}
}
@@ -11,7 +11,7 @@ namespace Umbraco.Core.Cache
/// <summary>
/// A CacheProvider that wraps the logic of the HttpRuntime.Cache
/// </summary>
internal class HttpRuntimeCacheProvider : CacheProviderBase
internal class HttpRuntimeCacheProvider : RuntimeCacheProviderBase
{
private readonly System.Web.Caching.Cache _cache;
private static readonly object Locker = new object();
+1 -1
View File
@@ -5,7 +5,7 @@ using System.Web.Caching;
namespace Umbraco.Core.Cache
{
internal class NullCacheProvider : CacheProviderBase
internal class NullCacheProvider : RuntimeCacheProviderBase
{
public override void ClearAllCache()
{
@@ -0,0 +1,24 @@
using System;
using System.Text;
using System.Web.Caching;
namespace Umbraco.Core.Cache
{
/// <summary>
/// An abstract class for implementing a runtime cache provider
/// </summary>
/// <remarks>
/// THIS MUST REMAIN INTERNAL UNTIL WE STREAMLINE HOW ALL CACHE IS HANDLED, WE NEED TO SUPPORT HTTP RUNTIME CACHE, IN MEMORY CACHE, ETC...
/// </remarks>
internal abstract class RuntimeCacheProviderBase : CacheProviderBase
{
public abstract T GetCacheItem<T>(string cacheKey, TimeSpan? timeout, Func<T> getCacheItem);
public abstract T GetCacheItem<T>(string cacheKey, CacheItemRemovedCallback refreshAction, TimeSpan? timeout, Func<T> getCacheItem);
public abstract T GetCacheItem<T>(string cacheKey, CacheItemPriority priority, CacheItemRemovedCallback refreshAction, TimeSpan? timeout, Func<T> getCacheItem);
public abstract T GetCacheItem<T>(string cacheKey, CacheItemPriority priority, CacheItemRemovedCallback refreshAction, CacheDependency cacheDependency, TimeSpan? timeout, Func<T> getCacheItem);
public abstract void InsertCacheItem<T>(string cacheKey, CacheItemPriority priority, Func<T> getCacheItem);
public abstract void InsertCacheItem<T>(string cacheKey, CacheItemPriority priority, TimeSpan? timeout, Func<T> getCacheItem);
public abstract void InsertCacheItem<T>(string cacheKey, CacheItemPriority priority, CacheDependency cacheDependency, TimeSpan? timeout, Func<T> getCacheItem);
public abstract void InsertCacheItem<T>(string cacheKey, CacheItemPriority priority, CacheItemRemovedCallback refreshAction, CacheDependency cacheDependency, TimeSpan? timeout, Func<T> getCacheItem);
}
}
@@ -0,0 +1,102 @@
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
using System.Web.Caching;
namespace Umbraco.Core.Cache
{
/// <summary>
/// A cache provider that statically caches everything in an in memory dictionary
/// </summary>
internal class StaticCacheProvider : CacheProviderBase
{
private readonly ConcurrentDictionary<string, object> _staticCache = new ConcurrentDictionary<string, object>();
public override void ClearAllCache()
{
_staticCache.Clear();
}
public override void ClearCacheItem(string key)
{
object val;
_staticCache.TryRemove(key, out val);
}
public override void ClearCacheObjectTypes(string typeName)
{
foreach (var key in _staticCache.Keys)
{
if (_staticCache[key] != null
&& _staticCache[key].GetType().ToString().InvariantEquals(typeName))
{
object val;
_staticCache.TryRemove(key, out val);
}
}
}
public override void ClearCacheObjectTypes<T>()
{
foreach (var key in _staticCache.Keys)
{
if (_staticCache[key] != null
&& _staticCache[key].GetType() == typeof(T))
{
object val;
_staticCache.TryRemove(key, out val);
}
}
}
public override void ClearCacheByKeySearch(string keyStartsWith)
{
foreach (var key in _staticCache.Keys)
{
if (key.InvariantStartsWith(keyStartsWith))
{
ClearCacheItem(key);
}
}
}
public override void ClearCacheByKeyExpression(string regexString)
{
foreach (var key in _staticCache.Keys)
{
if (Regex.IsMatch(key, regexString))
{
ClearCacheItem(key);
}
}
}
public override IEnumerable<T> GetCacheItemsByKeySearch<T>(string keyStartsWith)
{
return (from KeyValuePair<string, object> c in _staticCache
where c.Key.InvariantStartsWith(keyStartsWith)
select c.Value.TryConvertTo<T>()
into attempt
where attempt.Success
select attempt.Result).ToList();
}
public override T GetCacheItem<T>(string cacheKey)
{
var result = _staticCache[cacheKey];
if (result == null)
{
return default(T);
}
return result.TryConvertTo<T>().Result;
}
public override T GetCacheItem<T>(string cacheKey, Func<T> getCacheItem)
{
return (T)_staticCache.GetOrAdd(cacheKey, getCacheItem);
}
}
}
+240 -76
View File
@@ -15,14 +15,13 @@ namespace Umbraco.Core
/// <summary>
/// Class that is exposed by the ApplicationContext for application wide caching purposes
/// </summary>
/// <remarks>
/// This class may be opened publicly at some point but needs a review of what is absoletely necessary.
/// </remarks>
public class CacheHelper //: CacheProviderBase
public class CacheHelper
{
private readonly bool _enableCache;
private readonly HttpRuntimeCacheProvider _httpCache;
private readonly NullCacheProvider _nullCache = new NullCacheProvider();
private readonly CacheProviderBase _staticCache;
private readonly CacheProviderBase _nullStaticCache = new NullCacheProvider();
private readonly RuntimeCacheProviderBase _httpCache;
private readonly RuntimeCacheProviderBase _nullHttpCache = new NullCacheProvider();
public CacheHelper(System.Web.Caching.Cache cache)
: this(cache, true)
@@ -30,21 +29,185 @@ namespace Umbraco.Core
}
internal CacheHelper(System.Web.Caching.Cache cache, bool enableCache)
{
_httpCache = new HttpRuntimeCacheProvider(cache);
_enableCache = enableCache;
: this(new HttpRuntimeCacheProvider(cache), enableCache)
{
}
internal CacheHelper(RuntimeCacheProviderBase httpCacheProvider, bool enableCache)
: this(httpCacheProvider, new StaticCacheProvider(), enableCache)
{
}
internal CacheHelper(RuntimeCacheProviderBase httpCacheProvider, CacheProviderBase staticCacheProvider, bool enableCache)
{
_httpCache = httpCacheProvider;
_staticCache = staticCacheProvider;
_enableCache = enableCache;
}
#region Static cache
/// <summary>
/// Clears the item in umbraco's static cache
/// </summary>
internal void ClearAllStaticCache()
{
if (!_enableCache)
{
_nullStaticCache.ClearAllCache();
}
else
{
_staticCache.ClearAllCache();
}
}
/// <summary>
/// Clears the item in umbraco's static cache with the given key
/// </summary>
/// <param name="key">Key</param>
internal void ClearStaticCacheItem(string key)
{
if (!_enableCache)
{
_nullStaticCache.ClearCacheItem(key);
}
else
{
_staticCache.ClearCacheItem(key);
}
}
/// <summary>
/// Clears all objects in the static cache with the System.Type name as the
/// input parameter. (using [object].GetType())
/// </summary>
/// <param name="typeName">The name of the System.Type which should be cleared from cache ex "System.Xml.XmlDocument"</param>
internal void ClearStaticCacheObjectTypes(string typeName)
{
if (!_enableCache)
{
_nullStaticCache.ClearCacheObjectTypes(typeName);
}
else
{
_staticCache.ClearCacheObjectTypes(typeName);
}
}
/// <summary>
/// Clears all objects in the static cache with the System.Type specified
/// </summary>
internal void ClearStaticCacheObjectTypes<T>()
{
if (!_enableCache)
{
_nullStaticCache.ClearCacheObjectTypes<T>();
}
else
{
_staticCache.ClearCacheObjectTypes<T>();
}
}
/// <summary>
/// Clears all static cache items that starts with the key passed.
/// </summary>
/// <param name="keyStartsWith">The start of the key</param>
internal void ClearStaticCacheByKeySearch(string keyStartsWith)
{
if (!_enableCache)
{
_nullStaticCache.ClearCacheByKeySearch(keyStartsWith);
}
else
{
_staticCache.ClearCacheByKeySearch(keyStartsWith);
}
}
/// <summary>
/// Clears all cache items that have a key that matches the regular expression
/// </summary>
/// <param name="regexString"></param>
internal void ClearStaticCacheByKeyExpression(string regexString)
{
if (!_enableCache)
{
_nullStaticCache.ClearCacheByKeyExpression(regexString);
}
else
{
_staticCache.ClearCacheByKeyExpression(regexString);
}
}
internal IEnumerable<T> GetStaticCacheItemsByKeySearch<T>(string keyStartsWith)
{
if (!_enableCache)
{
return _nullStaticCache.GetCacheItemsByKeySearch<T>(keyStartsWith);
}
else
{
return _staticCache.GetCacheItemsByKeySearch<T>(keyStartsWith);
}
}
/// <summary>
/// Returns a static cache item by key, does not update the cache if it isn't there.
/// </summary>
/// <typeparam name="TT"></typeparam>
/// <param name="cacheKey"></param>
/// <returns></returns>
internal TT GetStaticCacheItem<TT>(string cacheKey)
{
if (!_enableCache)
{
return _nullStaticCache.GetCacheItem<TT>(cacheKey);
}
else
{
return _staticCache.GetCacheItem<TT>(cacheKey);
}
}
/// <summary>
/// Gets (and adds if necessary) an item from the static cache with all of the default parameters
/// </summary>
/// <typeparam name="TT"></typeparam>
/// <param name="cacheKey"></param>
/// <param name="getCacheItem"></param>
/// <returns></returns>
internal TT GetStaticCacheItem<TT>(string cacheKey, Func<TT> getCacheItem)
{
if (!_enableCache)
{
return _nullStaticCache.GetCacheItem<TT>(cacheKey, getCacheItem);
}
else
{
return _staticCache.GetCacheItem<TT>(cacheKey, getCacheItem);
}
}
#endregion
#region Runtime/Http Cache
/// <summary>
/// Clears the item in umbraco's runtime cache
/// </summary>
public void ClearAllCache()
{
if (!_enableCache)
{
_nullCache.ClearAllCache();
}
else
{
_httpCache.ClearAllCache();
}
{
if (!_enableCache)
{
_nullHttpCache.ClearAllCache();
}
else
{
_httpCache.ClearAllCache();
}
}
/// <summary>
@@ -55,7 +218,7 @@ namespace Umbraco.Core
{
if (!_enableCache)
{
_nullCache.ClearCacheItem(key);
_nullHttpCache.ClearCacheItem(key);
}
else
{
@@ -73,7 +236,7 @@ namespace Umbraco.Core
{
if (!_enableCache)
{
_nullCache.ClearCacheObjectTypes(typeName);
_nullHttpCache.ClearCacheObjectTypes(typeName);
}
else
{
@@ -84,55 +247,55 @@ namespace Umbraco.Core
/// <summary>
/// Clears all objects in the System.Web.Cache with the System.Type specified
/// </summary>
public void ClearCacheObjectTypes<T>()
{
public void ClearCacheObjectTypes<T>()
{
if (!_enableCache)
{
_nullCache.ClearCacheObjectTypes<T>();
_nullHttpCache.ClearCacheObjectTypes<T>();
}
else
{
_httpCache.ClearCacheObjectTypes<T>();
}
}
}
/// <summary>
/// <summary>
/// Clears all cache items that starts with the key passed.
/// </summary>
/// <param name="keyStartsWith">The start of the key</param>
public void ClearCacheByKeySearch(string keyStartsWith)
{
{
if (!_enableCache)
{
_nullCache.ClearCacheByKeySearch(keyStartsWith);
_nullHttpCache.ClearCacheByKeySearch(keyStartsWith);
}
else
{
_httpCache.ClearCacheByKeySearch(keyStartsWith);
}
}
}
/// <summary>
/// Clears all cache items that have a key that matches the regular expression
/// </summary>
/// <param name="regexString"></param>
public void ClearCacheByKeyExpression(string regexString)
{
public void ClearCacheByKeyExpression(string regexString)
{
if (!_enableCache)
{
_nullCache.ClearCacheByKeyExpression(regexString);
_nullHttpCache.ClearCacheByKeyExpression(regexString);
}
else
{
_httpCache.ClearCacheByKeyExpression(regexString);
}
}
}
public IEnumerable<T> GetCacheItemsByKeySearch<T>(string keyStartsWith)
{
if (!_enableCache)
{
return _nullCache.GetCacheItemsByKeySearch<T>(keyStartsWith);
return _nullHttpCache.GetCacheItemsByKeySearch<T>(keyStartsWith);
}
else
{
@@ -140,7 +303,7 @@ namespace Umbraco.Core
}
}
/// <summary>
/// <summary>
/// Returns a cache item by key, does not update the cache if it isn't there.
/// </summary>
/// <typeparam name="TT"></typeparam>
@@ -150,7 +313,7 @@ namespace Umbraco.Core
{
if (!_enableCache)
{
return _nullCache.GetCacheItem<TT>(cacheKey);
return _nullHttpCache.GetCacheItem<TT>(cacheKey);
}
else
{
@@ -169,7 +332,7 @@ namespace Umbraco.Core
{
if (!_enableCache)
{
return _nullCache.GetCacheItem<TT>(cacheKey, getCacheItem);
return _nullHttpCache.GetCacheItem<TT>(cacheKey, getCacheItem);
}
else
{
@@ -190,7 +353,7 @@ namespace Umbraco.Core
{
if (!_enableCache)
{
return _nullCache.GetCacheItem<TT>(cacheKey, timeout, getCacheItem);
return _nullHttpCache.GetCacheItem<TT>(cacheKey, timeout, getCacheItem);
}
else
{
@@ -213,7 +376,7 @@ namespace Umbraco.Core
{
if (!_enableCache)
{
return _nullCache.GetCacheItem<TT>(cacheKey, refreshAction, timeout, getCacheItem);
return _nullHttpCache.GetCacheItem<TT>(cacheKey, refreshAction, timeout, getCacheItem);
}
else
{
@@ -237,7 +400,7 @@ namespace Umbraco.Core
{
if (!_enableCache)
{
return _nullCache.GetCacheItem<TT>(cacheKey, priority, refreshAction, timeout, getCacheItem);
return _nullHttpCache.GetCacheItem<TT>(cacheKey, priority, refreshAction, timeout, getCacheItem);
}
else
{
@@ -257,15 +420,15 @@ namespace Umbraco.Core
/// <param name="getCacheItem"></param>
/// <returns></returns>
public TT GetCacheItem<TT>(string cacheKey,
CacheItemPriority priority,
CacheItemRemovedCallback refreshAction,
CacheDependency cacheDependency,
TimeSpan timeout,
Func<TT> getCacheItem)
CacheItemPriority priority,
CacheItemRemovedCallback refreshAction,
CacheDependency cacheDependency,
TimeSpan timeout,
Func<TT> getCacheItem)
{
if (!_enableCache)
{
return _nullCache.GetCacheItem<TT>(cacheKey, priority, refreshAction, cacheDependency, timeout, getCacheItem);
return _nullHttpCache.GetCacheItem<TT>(cacheKey, priority, refreshAction, cacheDependency, timeout, getCacheItem);
}
else
{
@@ -289,7 +452,7 @@ namespace Umbraco.Core
{
if (!_enableCache)
{
return _nullCache.GetCacheItem<TT>(cacheKey, priority, null, cacheDependency, null, getCacheItem);
return _nullHttpCache.GetCacheItem<TT>(cacheKey, priority, null, cacheDependency, null, getCacheItem);
}
else
{
@@ -310,14 +473,14 @@ namespace Umbraco.Core
{
if (!_enableCache)
{
_nullCache.InsertCacheItem<T>(cacheKey, priority, getCacheItem);
_nullHttpCache.InsertCacheItem<T>(cacheKey, priority, getCacheItem);
}
else
{
_httpCache.InsertCacheItem<T>(cacheKey, priority, getCacheItem);
}
}
/// <summary>
/// Inserts an item into the cache, if it already exists in the cache it will be replaced
/// </summary>
@@ -333,7 +496,7 @@ namespace Umbraco.Core
{
if (!_enableCache)
{
_nullCache.InsertCacheItem<T>(cacheKey, priority, timeout, getCacheItem);
_nullHttpCache.InsertCacheItem<T>(cacheKey, priority, timeout, getCacheItem);
}
else
{
@@ -341,30 +504,30 @@ namespace Umbraco.Core
}
}
/// <summary>
/// Inserts an item into the cache, if it already exists in the cache it will be replaced
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="cacheKey"></param>
/// <param name="priority"></param>
/// <param name="cacheDependency"></param>
/// <param name="timeout">This will set an absolute expiration from now until the timeout</param>
/// <param name="getCacheItem"></param>
public void InsertCacheItem<T>(string cacheKey,
CacheItemPriority priority,
CacheDependency cacheDependency,
TimeSpan timeout,
Func<T> getCacheItem)
{
/// <summary>
/// Inserts an item into the cache, if it already exists in the cache it will be replaced
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="cacheKey"></param>
/// <param name="priority"></param>
/// <param name="cacheDependency"></param>
/// <param name="timeout">This will set an absolute expiration from now until the timeout</param>
/// <param name="getCacheItem"></param>
public void InsertCacheItem<T>(string cacheKey,
CacheItemPriority priority,
CacheDependency cacheDependency,
TimeSpan timeout,
Func<T> getCacheItem)
{
if (!_enableCache)
{
_nullCache.InsertCacheItem<T>(cacheKey, priority, cacheDependency, timeout, getCacheItem);
_nullHttpCache.InsertCacheItem<T>(cacheKey, priority, cacheDependency, timeout, getCacheItem);
}
else
{
_httpCache.InsertCacheItem<T>(cacheKey, priority, cacheDependency, timeout, getCacheItem);
}
}
}
/// <summary>
/// Inserts an item into the cache, if it already exists in the cache it will be replaced
@@ -376,22 +539,23 @@ namespace Umbraco.Core
/// <param name="cacheDependency"></param>
/// <param name="timeout">This will set an absolute expiration from now until the timeout</param>
/// <param name="getCacheItem"></param>
public void InsertCacheItem<T>(string cacheKey,
CacheItemPriority priority,
CacheItemRemovedCallback refreshAction,
CacheDependency cacheDependency,
TimeSpan? timeout,
Func<T> getCacheItem)
{
public void InsertCacheItem<T>(string cacheKey,
CacheItemPriority priority,
CacheItemRemovedCallback refreshAction,
CacheDependency cacheDependency,
TimeSpan? timeout,
Func<T> getCacheItem)
{
if (!_enableCache)
{
_nullCache.InsertCacheItem<T>(cacheKey, priority, refreshAction, cacheDependency, timeout, getCacheItem);
_nullHttpCache.InsertCacheItem<T>(cacheKey, priority, refreshAction, cacheDependency, timeout, getCacheItem);
}
else
{
_httpCache.InsertCacheItem<T>(cacheKey, priority, refreshAction, cacheDependency, timeout, getCacheItem);
}
}
}
#endregion
}
@@ -5,7 +5,7 @@ namespace Umbraco.Core.Configuration
{
public class UmbracoVersion
{
private static readonly Version Version = new Version("6.1.0");
private static readonly Version Version = new Version("6.1.2");
/// <summary>
/// Gets the current version of Umbraco.
@@ -23,7 +23,7 @@ namespace Umbraco.Core.Configuration
/// Gets the version comment (like beta or RC).
/// </summary>
/// <value>The version comment.</value>
public static string CurrentComment { get { return "beta-2"; } }
public static string CurrentComment { get { return ""; } }
// Get the version of the umbraco.dll by looking at a class in that dll
// Had to do it like this due to medium trust issues, see: http://haacked.com/archive/2010/11/04/assembly-location-and-medium-trust.aspx
+31 -3
View File
@@ -10,6 +10,7 @@ using Umbraco.Core.Persistence.Migrations.Upgrades.TargetVersionSix;
using Umbraco.Core.Persistence.Migrations.Upgrades.TargetVersionSixZeroOne;
using Umbraco.Core.Persistence.SqlSyntax;
using Umbraco.Core.Persistence.UnitOfWork;
using Umbraco.Core.Profiling;
using Umbraco.Core.PropertyEditors;
using Umbraco.Core.Publishing;
using Umbraco.Core.Macros;
@@ -52,8 +53,9 @@ namespace Umbraco.Core
if (_isInitialized)
throw new InvalidOperationException("The boot manager has already been initialized");
LogHelper.Info<CoreBootManager>("Umbraco application starting");
_timer = DisposableTimer.Start(x => LogHelper.Info<CoreBootManager>("Umbraco application startup complete" + " (took " + x + "ms)"));
InitializeProfilerResolver();
_timer = DisposableTimer.DebugDuration<CoreBootManager>("Umbraco application starting", "Umbraco application startup complete");
//create database and service contexts for the app context
var dbFactory = new DefaultDatabaseFactory(GlobalSettings.UmbracoConnectionName);
@@ -93,6 +95,20 @@ namespace Umbraco.Core
ApplicationContext = ApplicationContext.Current = new ApplicationContext(dbContext, serviceContext);
}
/// <summary>
/// Special method to initialize the ProfilerResolver
/// </summary>
protected virtual void InitializeProfilerResolver()
{
//By default we'll initialize the Log profiler (in the web project, we'll override with the web profiler)
ProfilerResolver.Current = new ProfilerResolver(new LogProfiler())
{
//This is another special resolver that needs to be resolvable before resolution is frozen
//since it is used for profiling the application startup
CanResolveBeforeFrozen = true
};
}
/// <summary>
/// Special method to initialize the ApplicationEventsResolver and any modifications required for it such
/// as adding custom types to the resolver.
@@ -113,6 +129,17 @@ namespace Umbraco.Core
ApplicationEventsResolver.Current.AddType<PublishedContentHelper>();
}
/// <summary>
/// Special method to extend the use of Umbraco by enabling the consumer to overwrite
/// the absolute path to the root of an Umbraco site/solution, which is used for stuff
/// like Umbraco.Core.IO.IOHelper.MapPath etc.
/// </summary>
/// <param name="rootPath">Absolute</param>
protected virtual void InitializeApplicationRootPath(string rootPath)
{
Umbraco.Core.IO.IOHelper.SetRootDirectory(rootPath);
}
/// <summary>
/// Fires after initialization and calls the callback to allow for customizations to occur &
/// Ensure that the OnApplicationStarting methods of the IApplicationEvents are called
@@ -185,7 +212,8 @@ namespace Umbraco.Core
/// Create the resolvers
/// </summary>
protected virtual void InitializeResolvers()
{
{
//by default we'll use the standard configuration based sync
ServerRegistrarResolver.Current = new ServerRegistrarResolver(
new ConfigServerRegistrar());
+52 -1
View File
@@ -1,5 +1,6 @@
using System;
using System.Collections;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Linq;
@@ -10,10 +11,60 @@ using System.Web;
namespace Umbraco.Core
{
///<summary>
/// Extension methods for dictionary
/// Extension methods for dictionary & concurrentdictionary
///</summary>
internal static class DictionaryExtensions
{
/// <summary>
/// Updates an item with the specified key with the specified value
/// </summary>
/// <typeparam name="TKey"></typeparam>
/// <typeparam name="TValue"></typeparam>
/// <param name="dict"></param>
/// <param name="key"></param>
/// <param name="updateFactory"></param>
/// <returns></returns>
/// <remarks>
/// Taken from: http://stackoverflow.com/questions/12240219/is-there-a-way-to-use-concurrentdictionary-tryupdate-with-a-lambda-expression
///
/// If there is an item in the dictionary with the key, it will keep trying to update it until it can
/// </remarks>
public static bool TryUpdate<TKey, TValue>(this ConcurrentDictionary<TKey, TValue> dict, TKey key, Func<TValue, TValue> updateFactory)
{
TValue curValue;
while (dict.TryGetValue(key, out curValue))
{
if (dict.TryUpdate(key, updateFactory(curValue), curValue))
return true;
//if we're looping either the key was removed by another thread, or another thread
//changed the value, so we start again.
}
return false;
}
/// <summary>
/// Updates an item with the specified key with the specified value
/// </summary>
/// <typeparam name="TKey"></typeparam>
/// <typeparam name="TValue"></typeparam>
/// <param name="dict"></param>
/// <param name="key"></param>
/// <param name="updateFactory"></param>
/// <returns></returns>
/// <remarks>
/// Taken from: http://stackoverflow.com/questions/12240219/is-there-a-way-to-use-concurrentdictionary-tryupdate-with-a-lambda-expression
///
/// WARNING: If the value changes after we've retreived it, then the item will not be updated
/// </remarks>
public static bool TryUpdateOptimisitic<TKey, TValue>(this ConcurrentDictionary<TKey, TValue> dict, TKey key, Func<TValue, TValue> updateFactory)
{
TValue curValue;
if (!dict.TryGetValue(key, out curValue))
return false;
dict.TryUpdate(key, updateFactory(curValue), curValue);
return true;//note we return true whether we succeed or not, see explanation below.
}
/// <summary>
/// Converts a dictionary to another type by only using direct casting
/// </summary>
+158 -83
View File
@@ -1,6 +1,8 @@
using System;
using System.Diagnostics;
using System.Web;
using Umbraco.Core.Logging;
using Umbraco.Core.Profiling;
namespace Umbraco.Core
{
@@ -9,11 +11,17 @@ namespace Umbraco.Core
/// </summary>
/// <example>
/// <code>
///
/// using (DisposableTimer.TraceDuration{MyType}("starting", "finished"))
/// {
/// Thread.Sleep(567);
/// }
///
/// Console.WriteLine("Testing Stopwatchdisposable, should be 567:");
// using (var timer = new DisposableTimer(result => Console.WriteLine("Took {0}ms", result)))
// {
// Thread.Sleep(567);
// }
/// using (var timer = new DisposableTimer(result => Console.WriteLine("Took {0}ms", result)))
/// {
/// Thread.Sleep(567);
/// }
/// </code>
/// </example>
public class DisposableTimer : DisposableObject
@@ -24,7 +32,7 @@ namespace Umbraco.Core
protected DisposableTimer(Action<long> callback)
{
_callback = callback;
}
}
public Stopwatch Stopwatch
{
@@ -36,96 +44,149 @@ namespace Umbraco.Core
/// </summary>
/// <param name="callback">The callback.</param>
/// <returns></returns>
[Obsolete("Use either TraceDuration or DebugDuration instead of using Start")]
public static DisposableTimer Start(Action<long> callback)
{
return new DisposableTimer(callback);
}
public static DisposableTimer TraceDuration<T>(Func<string> startMessage, Func<string> completeMessage)
{
return TraceDuration(typeof(T), startMessage, completeMessage);
}
#region TraceDuration
public static DisposableTimer TraceDuration<T>(Func<string> startMessage, Func<string> completeMessage)
{
return TraceDuration(typeof(T), startMessage, completeMessage);
}
public static DisposableTimer TraceDuration(Type loggerType, Func<string> startMessage, Func<string> completeMessage)
{
LogHelper.Debug(loggerType, startMessage);
return new DisposableTimer(x => LogHelper.Info(loggerType, () => completeMessage() + " (took " + x + "ms)"));
}
public static DisposableTimer TraceDuration(Type loggerType, Func<string> startMessage, Func<string> completeMessage)
{
var startMsg = startMessage();
LogHelper.Info(loggerType, startMsg);
if (HttpContext.Current != null)
HttpContext.Current.Trace.Write("Start: " + startMsg);
var profiler = ActivateProfiler(loggerType, startMsg);
return new DisposableTimer(x =>
{
profiler.DisposeIfDisposable();
LogHelper.Info(loggerType, () => completeMessage() + " (took " + x + "ms)");
if (HttpContext.Current != null)
HttpContext.Current.Trace.Write("End: " + startMsg);
});
}
/// <summary>
/// Adds a start and end log entry as Info and tracks how long it takes until disposed.
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="startMessage"></param>
/// <param name="completeMessage"></param>
/// <returns></returns>
public static DisposableTimer TraceDuration<T>(string startMessage, string completeMessage)
{
return TraceDuration(typeof(T), startMessage, completeMessage);
}
/// <summary>
/// Adds a start and end log entry as Info and tracks how long it takes until disposed.
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="startMessage"></param>
/// <param name="completeMessage"></param>
/// <returns></returns>
public static DisposableTimer TraceDuration<T>(string startMessage, string completeMessage)
{
return TraceDuration(typeof(T), startMessage, completeMessage);
}
/// <summary>
/// Adds a start and end log entry as Info and tracks how long it takes until disposed.
/// </summary>
/// <param name="loggerType"></param>
/// <param name="startMessage"></param>
/// <param name="completeMessage"></param>
/// <returns></returns>
public static DisposableTimer TraceDuration(Type loggerType, string startMessage, string completeMessage)
{
LogHelper.Info(loggerType, () => startMessage);
return new DisposableTimer(x => LogHelper.Info(loggerType, () => completeMessage + " (took " + x + "ms)"));
}
public static DisposableTimer TraceDuration<T>(string startMessage)
{
return TraceDuration(typeof(T), startMessage, "Complete");
}
/// <summary>
/// Adds a start and end log entry as Debug and tracks how long it takes until disposed.
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="startMessage"></param>
/// <param name="completeMessage"></param>
/// <returns></returns>
public static DisposableTimer DebugDuration<T>(string startMessage, string completeMessage)
{
return DebugDuration(typeof(T), startMessage, completeMessage);
}
/// <summary>
/// Adds a start and end log entry as Info and tracks how long it takes until disposed.
/// </summary>
/// <param name="loggerType"></param>
/// <param name="startMessage"></param>
/// <param name="completeMessage"></param>
/// <returns></returns>
public static DisposableTimer TraceDuration(Type loggerType, string startMessage, string completeMessage)
{
LogHelper.Info(loggerType, startMessage);
if (HttpContext.Current != null)
HttpContext.Current.Trace.Write("Start: " + startMessage);
var profiler = ActivateProfiler(loggerType, startMessage);
return new DisposableTimer(x =>
{
profiler.DisposeIfDisposable();
LogHelper.Info(loggerType, () => completeMessage + " (took " + x + "ms)");
if (HttpContext.Current != null)
HttpContext.Current.Trace.Write("End: " + startMessage);
});
}
#endregion
/// <summary>
/// Adds a start and end log entry as Debug and tracks how long it takes until disposed.
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="startMessage"></param>
/// <param name="completeMessage"></param>
/// <returns></returns>
public static DisposableTimer DebugDuration<T>(Func<string> startMessage, Func<string> completeMessage)
{
return DebugDuration(typeof(T), startMessage, completeMessage);
}
#region DebugDuration
/// <summary>
/// Adds a start and end log entry as Debug and tracks how long it takes until disposed.
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="startMessage"></param>
/// <param name="completeMessage"></param>
/// <returns></returns>
public static DisposableTimer DebugDuration<T>(string startMessage, string completeMessage)
{
return DebugDuration(typeof(T), startMessage, completeMessage);
}
/// <summary>
/// Adds a start and end log entry as Debug and tracks how long it takes until disposed.
/// </summary>
/// <param name="loggerType"></param>
/// <param name="startMessage"></param>
/// <param name="completeMessage"></param>
/// <returns></returns>
public static DisposableTimer DebugDuration(Type loggerType, string startMessage, string completeMessage)
{
LogHelper.Debug(loggerType, () => startMessage);
return new DisposableTimer(x => LogHelper.Debug(loggerType, () => completeMessage + " (took " + x + "ms)"));
}
public static DisposableTimer DebugDuration<T>(string startMessage)
{
return DebugDuration(typeof(T), startMessage, "Complete");
}
/// <summary>
/// Adds a start and end log entry as Debug and tracks how long it takes until disposed.
/// </summary>
/// <param name="loggerType"></param>
/// <param name="startMessage"></param>
/// <param name="completeMessage"></param>
/// <returns></returns>
public static DisposableTimer DebugDuration(Type loggerType, Func<string> startMessage, Func<string> completeMessage)
{
LogHelper.Debug(loggerType, startMessage);
return new DisposableTimer(x => LogHelper.Debug(loggerType, () => completeMessage() + " (took " + x + "ms)"));
}
/// <summary>
/// Adds a start and end log entry as Debug and tracks how long it takes until disposed.
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="startMessage"></param>
/// <param name="completeMessage"></param>
/// <returns></returns>
public static DisposableTimer DebugDuration<T>(Func<string> startMessage, Func<string> completeMessage)
{
return DebugDuration(typeof(T), startMessage, completeMessage);
}
/// <summary>
/// Adds a start and end log entry as Debug and tracks how long it takes until disposed.
/// </summary>
/// <param name="loggerType"></param>
/// <param name="startMessage"></param>
/// <param name="completeMessage"></param>
/// <returns></returns>
public static DisposableTimer DebugDuration(Type loggerType, string startMessage, string completeMessage)
{
LogHelper.Debug(loggerType, startMessage);
if (HttpContext.Current != null)
HttpContext.Current.Trace.Write("Start: " + startMessage);
var profiler = ActivateProfiler(loggerType, startMessage);
return new DisposableTimer(x =>
{
profiler.DisposeIfDisposable();
LogHelper.Debug(loggerType, () => completeMessage + " (took " + x + "ms)");
if (HttpContext.Current != null)
HttpContext.Current.Trace.Write("End: " + startMessage);
});
}
/// <summary>
/// Adds a start and end log entry as Debug and tracks how long it takes until disposed.
/// </summary>
/// <param name="loggerType"></param>
/// <param name="startMessage"></param>
/// <param name="completeMessage"></param>
/// <returns></returns>
public static DisposableTimer DebugDuration(Type loggerType, Func<string> startMessage, Func<string> completeMessage)
{
var msg = startMessage();
LogHelper.Debug(loggerType, msg);
if (HttpContext.Current != null)
HttpContext.Current.Trace.Write("Start: " + startMessage);
var profiler = ActivateProfiler(loggerType, msg);
return new DisposableTimer(x =>
{
profiler.DisposeIfDisposable();
LogHelper.Debug(loggerType, () => completeMessage() + " (took " + x + "ms)");
if (HttpContext.Current != null)
HttpContext.Current.Trace.Write("End: " + startMessage);
});
}
#endregion
/// <summary>
/// Handles the disposal of resources. Derived from abstract class <see cref="DisposableObject"/> which handles common required locking logic.
@@ -134,5 +195,19 @@ namespace Umbraco.Core
{
_callback.Invoke(Stopwatch.ElapsedMilliseconds);
}
private static IDisposable ActivateProfiler(Type loggerType, string profileName)
{
try
{
return ProfilerResolver.Current.Profiler.Step(loggerType, profileName);
}
catch (InvalidOperationException)
{
//swallow this exception, it will occur if the ProfilerResolver is not initialized... generally only in
// unit tests.
}
return null;
}
}
}
@@ -5,12 +5,11 @@ using System.Text;
using Umbraco.Core.CodeAnnotations;
namespace Umbraco.Core.IO
{
[UmbracoExperimentalFeature("http://issues.umbraco.org/issue/U4-1156", "Will be declared public after 4.10")]
{
[AttributeUsage(AttributeTargets.Class, AllowMultiple = false, Inherited = false)]
internal class FileSystemProviderAttribute : Attribute
public class FileSystemProviderAttribute : Attribute
{
public string Alias { get; set; }
public string Alias { get; private set; }
public FileSystemProviderAttribute(string alias)
{
@@ -6,8 +6,7 @@ using Umbraco.Core.CodeAnnotations;
namespace Umbraco.Core.IO
{
[UmbracoExperimentalFeature("http://issues.umbraco.org/issue/U4-1156", "Will be declared public after 4.10")]
internal class FileSystemProvider
internal class FileSystemProviderConstants
{
public const string Media = "media";
}
@@ -9,9 +9,8 @@ using Umbraco.Core.CodeAnnotations;
using Umbraco.Core.Configuration;
namespace Umbraco.Core.IO
{
[UmbracoExperimentalFeature("http://issues.umbraco.org/issue/U4-1156", "Will be declared public after 4.10")]
internal class FileSystemProviderManager
{
public class FileSystemProviderManager
{
private readonly FileSystemProvidersSection _config;
@@ -28,7 +27,7 @@ namespace Umbraco.Core.IO
#region Constructors
public FileSystemProviderManager()
internal FileSystemProviderManager()
{
_config = (FileSystemProvidersSection)ConfigurationManager.GetSection("FileSystemProviders");
}
@@ -48,7 +47,15 @@ namespace Umbraco.Core.IO
private readonly ConcurrentDictionary<string, ProviderConstructionInfo> _providerLookup = new ConcurrentDictionary<string, ProviderConstructionInfo>();
private readonly ConcurrentDictionary<Type, string> _wrappedProviderLookup = new ConcurrentDictionary<Type, string>();
public IFileSystem GetFileSystemProvider(string alias)
/// <summary>
/// Returns the underlying (non-typed) file system provider for the alias specified
/// </summary>
/// <param name="alias"></param>
/// <returns></returns>
/// <remarks>
/// It is recommended to use the typed GetFileSystemProvider method instead to get a strongly typed provider instance.
/// </remarks>
public IFileSystem GetUnderlyingFileSystemProvider(string alias)
{
//either get the constructor info from cache or create it and add to cache
var ctorInfo = _providerLookup.GetOrAdd(alias, s =>
@@ -88,6 +95,11 @@ namespace Umbraco.Core.IO
return fs;
}
/// <summary>
/// Returns the strongly typed file system provider
/// </summary>
/// <typeparam name="TProviderTypeFilter"></typeparam>
/// <returns></returns>
public TProviderTypeFilter GetFileSystemProvider<TProviderTypeFilter>()
where TProviderTypeFilter : FileSystemWrapper
{
@@ -111,7 +123,7 @@ namespace Umbraco.Core.IO
return attr.Alias;
});
var innerFs = GetFileSystemProvider(alias);
var innerFs = GetUnderlyingFileSystemProvider(alias);
var outputFs = Activator.CreateInstance(typeof (TProviderTypeFilter), innerFs);
return (TProviderTypeFilter)outputFs;
}
+57 -27
View File
@@ -1,14 +1,11 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Globalization;
using System.Reflection;
using System.Text;
using System.IO;
using System.Configuration;
using System.Web;
using System.Text.RegularExpressions;
using System.Xml;
using Umbraco.Core.Configuration;
using Umbraco.Core.Logging;
@@ -37,7 +34,7 @@ namespace Umbraco.Core.IO
if (virtualPath.StartsWith("~"))
retval = virtualPath.Replace("~", SystemDirectories.Root);
if (virtualPath.StartsWith("/") && !virtualPath.StartsWith(SystemDirectories.Root))
if (virtualPath.StartsWith("/") && virtualPath.StartsWith(SystemDirectories.Root) == false)
retval = SystemDirectories.Root + "/" + virtualPath.TrimStart('/');
return retval;
@@ -68,11 +65,7 @@ namespace Umbraco.Core.IO
if (tag.Groups[1].Success)
url = tag.Groups[1].Value;
// The richtext editor inserts a slash in front of the url. That's why we need this little fix
// if (url.StartsWith("/"))
// text = text.Replace(url, ResolveUrl(url.Substring(1)));
// else
if (!String.IsNullOrEmpty(url))
if (string.IsNullOrEmpty(url) == false)
{
string resolvedUrl = (url.Substring(0, 1) == "/") ? ResolveUrl(url.Substring(1)) : ResolveUrl(url);
text = text.Replace(url, resolvedUrl);
@@ -97,19 +90,15 @@ namespace Umbraco.Core.IO
if (useHttpContext && HttpContext.Current != null)
{
//string retval;
if (!string.IsNullOrEmpty(path) && (path.StartsWith("~") || path.StartsWith(SystemDirectories.Root)))
if (string.IsNullOrEmpty(path) == false && (path.StartsWith("~") || path.StartsWith(SystemDirectories.Root)))
return System.Web.Hosting.HostingEnvironment.MapPath(path);
else
return System.Web.Hosting.HostingEnvironment.MapPath("~/" + path.TrimStart('/'));
}
//var root = (!string.IsNullOrEmpty(System.Web.Hosting.HostingEnvironment.ApplicationPhysicalPath))
// ? System.Web.Hosting.HostingEnvironment.ApplicationPhysicalPath.TrimEnd(IOHelper.DirSepChar)
// : getRootDirectorySafe();
var root = GetRootDirectorySafe();
var newPath = path.TrimStart('~', '/').Replace('/', IOHelper.DirSepChar);
var retval = root + IOHelper.DirSepChar.ToString() + newPath;
var retval = root + IOHelper.DirSepChar.ToString(CultureInfo.InvariantCulture) + newPath;
return retval;
}
@@ -144,9 +133,9 @@ namespace Umbraco.Core.IO
/// <returns>A value indicating whether the filepath is valid.</returns>
internal static bool VerifyEditPath(string filePath, string validDir)
{
if (!filePath.StartsWith(MapPath(SystemDirectories.Root)))
if (filePath.StartsWith(MapPath(SystemDirectories.Root)) == false)
filePath = MapPath(filePath);
if (!validDir.StartsWith(MapPath(SystemDirectories.Root)))
if (validDir.StartsWith(MapPath(SystemDirectories.Root)) == false)
validDir = MapPath(validDir);
return filePath.StartsWith(validDir);
@@ -161,7 +150,7 @@ namespace Umbraco.Core.IO
/// <exception cref="FileSecurityException">The filepath is invalid.</exception>
internal static bool ValidateEditPath(string filePath, string validDir)
{
if (!VerifyEditPath(filePath, validDir))
if (VerifyEditPath(filePath, validDir) == false)
throw new FileSecurityException(String.Format("The filepath '{0}' is not within an allowed directory for this type of files", filePath.Replace(MapPath(SystemDirectories.Root), "")));
return true;
}
@@ -177,9 +166,9 @@ namespace Umbraco.Core.IO
foreach (var dir in validDirs)
{
var validDir = dir;
if (!filePath.StartsWith(MapPath(SystemDirectories.Root)))
if (filePath.StartsWith(MapPath(SystemDirectories.Root)) == false)
filePath = MapPath(filePath);
if (!validDir.StartsWith(MapPath(SystemDirectories.Root)))
if (validDir.StartsWith(MapPath(SystemDirectories.Root)) == false)
validDir = MapPath(validDir);
if (filePath.StartsWith(validDir))
@@ -198,7 +187,7 @@ namespace Umbraco.Core.IO
/// <exception cref="FileSecurityException">The filepath is invalid.</exception>
internal static bool ValidateEditPath(string filePath, IEnumerable<string> validDirs)
{
if (!VerifyEditPath(filePath, validDirs))
if (VerifyEditPath(filePath, validDirs) == false)
throw new FileSecurityException(String.Format("The filepath '{0}' is not within an allowed directory for this type of files", filePath.Replace(MapPath(SystemDirectories.Root), "")));
return true;
}
@@ -211,7 +200,7 @@ namespace Umbraco.Core.IO
/// <returns>A value indicating whether the filepath is valid.</returns>
internal static bool VerifyFileExtension(string filePath, List<string> validFileExtensions)
{
if (!filePath.StartsWith(MapPath(SystemDirectories.Root)))
if (filePath.StartsWith(MapPath(SystemDirectories.Root)) == false)
filePath = MapPath(filePath);
var f = new FileInfo(filePath);
@@ -227,7 +216,7 @@ namespace Umbraco.Core.IO
/// <exception cref="FileSecurityException">The filepath is invalid.</exception>
internal static bool ValidateFileExtension(string filePath, List<string> validFileExtensions)
{
if (!VerifyFileExtension(filePath, validFileExtensions))
if (VerifyFileExtension(filePath, validFileExtensions) == false)
throw new FileSecurityException(String.Format("The extension for the current file '{0}' is not of an allowed type for this editor. This is typically controlled from either the installed MacroEngines or based on configuration in /config/umbracoSettings.config", filePath.Replace(MapPath(SystemDirectories.Root), "")));
return true;
}
@@ -241,7 +230,7 @@ namespace Umbraco.Core.IO
/// <returns></returns>
internal static string GetRootDirectorySafe()
{
if (!String.IsNullOrEmpty(_rootDir))
if (string.IsNullOrEmpty(_rootDir) == false)
{
return _rootDir;
}
@@ -250,12 +239,53 @@ namespace Umbraco.Core.IO
var uri = new Uri(codeBase);
var path = uri.LocalPath;
var baseDirectory = Path.GetDirectoryName(path);
_rootDir = baseDirectory.Substring(0, baseDirectory.LastIndexOf("bin") - 1);
if (string.IsNullOrEmpty(baseDirectory))
throw new Exception("No root directory could be resolved. Please ensure that your Umbraco solution is correctly configured.");
_rootDir = baseDirectory.Contains("bin")
? baseDirectory.Substring(0, baseDirectory.LastIndexOf("bin", StringComparison.OrdinalIgnoreCase) - 1)
: baseDirectory;
return _rootDir;
}
internal static string GetRootDirectoryBinFolder()
{
string binFolder = string.Empty;
if (string.IsNullOrEmpty(_rootDir))
{
binFolder = Assembly.GetExecutingAssembly().GetAssemblyFile().Directory.FullName;
return binFolder;
}
binFolder = Path.Combine(GetRootDirectorySafe(), "bin");
#if DEBUG
var debugFolder = Path.Combine(binFolder, "debug");
if (Directory.Exists(debugFolder))
return debugFolder;
#endif
var releaseFolder = Path.Combine(binFolder, "release");
if (Directory.Exists(releaseFolder))
return releaseFolder;
if (Directory.Exists(binFolder))
return binFolder;
return _rootDir;
}
/// <summary>
/// Allows you to overwrite RootDirectory, which would otherwise be resolved
/// automatically upon application start.
/// </summary>
/// <remarks>The supplied path should be the absolute path to the root of the umbraco site.</remarks>
/// <param name="rootPath"></param>
internal static void SetRootDirectory(string rootPath)
{
_rootDir = rootPath;
}
/// <summary>
/// Check to see if filename passed has any special chars in it and strips them to create a safe filename. Used to overcome an issue when Umbraco is used in IE in an intranet environment.
/// </summary>
+48 -92
View File
@@ -16,6 +16,7 @@ using Umbraco.Core.Models.Membership;
using Umbraco.Core.Strings;
using Umbraco.Core.Persistence;
using Umbraco.Core.Persistence.UnitOfWork;
using Umbraco.Core.Services;
namespace Umbraco.Core.Models
{
@@ -105,6 +106,50 @@ namespace Umbraco.Core.Models
}
#endregion
/// <summary>
/// Checks if the IContentBase has children
/// </summary>
/// <param name="content"></param>
/// <param name="services"></param>
/// <returns></returns>
/// <remarks>
/// This is a bit of a hack because we need to type check!
/// </remarks>
internal static bool HasChildren(IContentBase content, ServiceContext services)
{
if (content is IContent)
{
return services.ContentService.HasChildren(content.Id);
}
if (content is IMedia)
{
return services.MediaService.HasChildren(content.Id);
}
return false;
}
/// <summary>
/// Returns the children for the content base item
/// </summary>
/// <param name="content"></param>
/// <param name="services"></param>
/// <returns></returns>
/// <remarks>
/// This is a bit of a hack because we need to type check!
/// </remarks>
internal static IEnumerable<IContentBase> Children(IContentBase content, ServiceContext services)
{
if (content is IContent)
{
return services.ContentService.GetChildren(content.Id);
}
if (content is IMedia)
{
return services.MediaService.GetChildren(content.Id);
}
return null;
}
/// <summary>
/// Set property values by alias with an annonymous object
/// </summary>
@@ -467,38 +512,7 @@ namespace Umbraco.Core.Models
/// <returns>Xml representation of the passed in <see cref="IContent"/></returns>
internal static XElement ToDeepXml(this IContent content)
{
var xml = content.ToXml();
var descendants = content.Descendants().ToArray();
var currentChildren = descendants.Where(x => x.ParentId == content.Id);
AddChildXml(descendants, currentChildren, xml);
return xml;
}
/// <summary>
/// Used by ToDeepXml to recursively add children
/// </summary>
/// <param name="originalDescendants"></param>
/// <param name="currentChildren"></param>
/// <param name="currentXml"></param>
private static void AddChildXml(
IContent[] originalDescendants,
IEnumerable<IContent> currentChildren,
XElement currentXml)
{
foreach (var child in currentChildren)
{
//add the child's xml
var childXml = child.ToXml();
currentXml.Add(childXml);
//copy local (out of closure)
var c = child;
//get this item's children
var children = originalDescendants.Where(x => x.ParentId == c.Id);
//recurse and add it's children to the child xml element
AddChildXml(originalDescendants, children, childXml);
}
return ApplicationContext.Current.Services.PackagingService.Export(content, true);
}
/// <summary>
@@ -508,21 +522,7 @@ namespace Umbraco.Core.Models
/// <returns>Xml representation of the passed in <see cref="IContent"/></returns>
public static XElement ToXml(this IContent content)
{
//nodeName should match Casing.SafeAliasWithForcingCheck(content.ContentType.Alias);
var nodeName = UmbracoSettings.UseLegacyXmlSchema ? "node" : content.ContentType.Alias.ToSafeAliasWithForcingCheck();
var x = content.ToXml(nodeName);
x.Add(new XAttribute("nodeType", content.ContentType.Id));
x.Add(new XAttribute("creatorName", content.GetCreatorProfile().Name));
x.Add(new XAttribute("writerName", content.GetWriterProfile().Name));
x.Add(new XAttribute("writerID", content.WriterId));
x.Add(new XAttribute("template", content.Template == null ? "0" : content.Template.Id.ToString()));
if (UmbracoSettings.UseLegacyXmlSchema)
{
x.Add(new XAttribute("nodeTypeAlias", content.ContentType.Alias));
}
return x;
return ApplicationContext.Current.Services.PackagingService.Export(content);
}
/// <summary>
@@ -532,53 +532,9 @@ namespace Umbraco.Core.Models
/// <returns>Xml representation of the passed in <see cref="IContent"/></returns>
public static XElement ToXml(this IMedia media)
{
//nodeName should match Casing.SafeAliasWithForcingCheck(content.ContentType.Alias);
var nodeName = UmbracoSettings.UseLegacyXmlSchema ? "node" : media.ContentType.Alias.ToSafeAliasWithForcingCheck();
var x = media.ToXml(nodeName);
x.Add(new XAttribute("nodeType", media.ContentType.Id));
x.Add(new XAttribute("writerName", media.GetCreatorProfile().Name));
x.Add(new XAttribute("writerID", media.CreatorId));
x.Add(new XAttribute("version", media.Version));
x.Add(new XAttribute("template", 0));
if (UmbracoSettings.UseLegacyXmlSchema)
{
x.Add(new XAttribute("nodeTypeAlias", media.ContentType.Alias));
}
return x;
return ApplicationContext.Current.Services.PackagingService.Export(media);
}
/// <summary>
/// Creates the xml representation for the <see cref="IContentBase"/> object
/// </summary>
/// <param name="contentBase"><see cref="IContent"/> to generate xml for</param>
/// <param name="nodeName"></param>
/// <returns>Xml representation of the passed in <see cref="IContent"/></returns>
private static XElement ToXml(this IContentBase contentBase, string nodeName)
{
// note: that one will take care of umbracoUrlName
var url = contentBase.GetUrlSegment();
var xml = new XElement(nodeName,
new XAttribute("id", contentBase.Id),
new XAttribute("parentID", contentBase.Level > 1 ? contentBase.ParentId : -1),
new XAttribute("level", contentBase.Level),
new XAttribute("creatorID", contentBase.CreatorId),
new XAttribute("sortOrder", contentBase.SortOrder),
new XAttribute("createDate", contentBase.CreateDate.ToString("s")),
new XAttribute("updateDate", contentBase.UpdateDate.ToString("s")),
new XAttribute("nodeName", contentBase.Name),
new XAttribute("urlName", url),
new XAttribute("path", contentBase.Path),
new XAttribute("isDoc", ""));
foreach (var property in contentBase.Properties.Where(p => p != null))
xml.Add(property.ToXml());
return xml;
}
/// <summary>
/// Creates the xml representation for the <see cref="IContent"/> object
/// </summary>
@@ -477,6 +477,15 @@ namespace Umbraco.Core.Models
}
}
/// <summary>
/// Removes a PropertyGroup from the current ContentType
/// </summary>
/// <param name="propertyGroupName">Name of the <see cref="PropertyGroup"/> to remove</param>
public void RemovePropertyGroup(string propertyGroupName)
{
PropertyGroups.RemoveItem(propertyGroupName);
}
/// <summary>
/// Sets the ParentId from the lazy integer id
/// </summary>
@@ -75,7 +75,7 @@ namespace Umbraco.Core.Models
if (contentType.ContentTypeComposition.Any(x => x.CompositionAliases().Any(ContentTypeCompositionExists)))
return false;
if (!ContentTypeCompositionExists(contentType.Alias))
if (ContentTypeCompositionExists(contentType.Alias) == false)
{
_contentTypeComposition.Add(contentType);
OnPropertyChanged(ContentTypeCompositionSelector);
@@ -64,6 +64,12 @@ namespace Umbraco.Core.Models
/// <param name="propertyTypeAlias">Alias of the <see cref="PropertyType"/> to remove</param>
void RemovePropertyType(string propertyTypeAlias);
/// <summary>
/// Removes a PropertyGroup from the current ContentType
/// </summary>
/// <param name="propertyGroupName">Name of the <see cref="PropertyGroup"/> to remove</param>
void RemovePropertyGroup(string propertyGroupName);
/// <summary>
/// Sets the ParentId from the lazy integer id
/// </summary>
@@ -1,6 +1,5 @@
using System;
using Umbraco.Core.Models.EntityBase;
using Umbraco.Core.Persistence.Mappers;
namespace Umbraco.Core.Models
{
@@ -0,0 +1,51 @@
using System;
using System.Web.Security;
namespace Umbraco.Core.Models.Membership
{
internal class UmbracoMembershipUser<T> : MembershipUser where T : IMembershipUser
{
private T _user;
#region Constructors
/// <summary>
/// Initializes a new instance of the <see cref="UmbracoMembershipUser{T}"/> class.
/// </summary>
public UmbracoMembershipUser(T user)
{
_user = user;
}
/// <summary>
/// Initializes a new instance of the <see cref="UmbracoMembershipUser{T}"/> class.
/// </summary>
/// <param name="providerName">Name of the provider.</param>
/// <param name="name">The name.</param>
/// <param name="providerUserKey">The provider user key.</param>
/// <param name="email">The email.</param>
/// <param name="passwordQuestion">The password question.</param>
/// <param name="comment">The comment.</param>
/// <param name="isApproved">if set to <c>true</c> [is approved].</param>
/// <param name="isLockedOut">if set to <c>true</c> [is locked out].</param>
/// <param name="creationDate">The creation date.</param>
/// <param name="lastLoginDate">The last login date.</param>
/// <param name="lastActivityDate">The last activity date.</param>
/// <param name="lastPasswordChangedDate">The last password changed date.</param>
/// <param name="lastLockoutDate">The last lockout date.</param>
/// <param name="fullName">The full name.</param>
/// <param name="language">The language.</param>
/// <param name="userType">Type of the user.</param>
/// <param name="user"></param>
public UmbracoMembershipUser(string providerName, string name, object providerUserKey, string email,
string passwordQuestion, string comment, bool isApproved, bool isLockedOut,
DateTime creationDate, DateTime lastLoginDate, DateTime lastActivityDate, DateTime lastPasswordChangedDate,
DateTime lastLockoutDate, string fullName, string language, IUserType userType, T user)
: base( providerName, name, providerUserKey, email, passwordQuestion, comment, isApproved, isLockedOut,
creationDate, lastLoginDate, lastActivityDate, lastPasswordChangedDate, lastLockoutDate)
{
_user = user;
}
#endregion
}
}
@@ -97,6 +97,14 @@ namespace Umbraco.Core.Models
return this.Any(x => x.Name == groupName);
}
public void RemoveItem(string propertyGroupName)
{
var key = IndexOfKey(propertyGroupName);
//Only removes an item if the key was found
if (key != -1)
RemoveItem(key);
}
public int IndexOfKey(string key)
{
for (var i = 0; i < this.Count; i++)
@@ -20,5 +20,8 @@ namespace Umbraco.Core.Models.Rdbms
[Column("SortOrder")]
[Constraint(Name = "df_cmsContentTypeAllowedContentType_sortOrder", Default = "0")]
public int SortOrder { get; set; }
[ResultColumn]
public ContentTypeDto ContentTypeDto { get; set; }
}
}
+10 -16
View File
@@ -1,4 +1,5 @@
using System;
using System.Collections.Generic;
using System.Reflection;
using Umbraco.Core.Models.EntityBase;
@@ -21,7 +22,6 @@ namespace Umbraco.Core.Models
private bool _isDraft;
private bool _hasPendingChanges;
private string _contentTypeAlias;
private string _umbracoFile;
private Guid _nodeObjectTypeId;
private static readonly PropertyInfo CreatorIdSelector = ExpressionHelper.GetPropertyInfo<UmbracoEntity, int>(x => x.CreatorId);
@@ -38,7 +38,6 @@ namespace Umbraco.Core.Models
private static readonly PropertyInfo ContentTypeAliasSelector = ExpressionHelper.GetPropertyInfo<UmbracoEntity, string>(x => x.ContentTypeAlias);
private static readonly PropertyInfo ContentTypeIconSelector = ExpressionHelper.GetPropertyInfo<UmbracoEntity, string>(x => x.ContentTypeIcon);
private static readonly PropertyInfo ContentTypeThumbnailSelector = ExpressionHelper.GetPropertyInfo<UmbracoEntity, string>(x => x.ContentTypeThumbnail);
private static readonly PropertyInfo UmbracoFileSelector = ExpressionHelper.GetPropertyInfo<UmbracoEntity, string>(x => x.UmbracoFile);
private static readonly PropertyInfo NodeObjectTypeIdSelector = ExpressionHelper.GetPropertyInfo<UmbracoEntity, Guid>(x => x.NodeObjectTypeId);
private string _contentTypeIcon;
private string _contentTypeThumbnail;
@@ -171,7 +170,7 @@ namespace Umbraco.Core.Models
public bool IsDraft
{
get { return _isPublished; }
get { return _isDraft; }
set
{
SetPropertyValueAndDetectChanges(o =>
@@ -234,19 +233,6 @@ namespace Umbraco.Core.Models
}
}
public string UmbracoFile
{
get { return _umbracoFile; }
set
{
SetPropertyValueAndDetectChanges(o =>
{
_umbracoFile = value;
return _umbracoFile;
}, _umbracoFile, UmbracoFileSelector);
}
}
public Guid NodeObjectTypeId
{
get { return _nodeObjectTypeId; }
@@ -259,5 +245,13 @@ namespace Umbraco.Core.Models
}, _nodeObjectTypeId, NodeObjectTypeIdSelector);
}
}
public IList<UmbracoProperty> UmbracoProperties { get; set; }
internal class UmbracoProperty
{
public Guid DataTypeControlId { get; set; }
public string Value { get; set; }
}
}
}
@@ -170,7 +170,7 @@ namespace Umbraco.Core.ObjectResolution
get
{
// ensure we can
if (!CanResolveBeforeFrozen)
if (CanResolveBeforeFrozen == false)
Resolution.EnsureIsFrozen();
// note: we apply .ToArray() to the output of CreateInstance() because that is an IEnumerable that
@@ -13,7 +13,7 @@ namespace Umbraco.Core.ObjectResolution
//add itself to the internal collection
ResolverCollection.Add(this, resetAction);
}
}
/// <summary>
@@ -69,6 +69,12 @@ namespace Umbraco.Core.ObjectResolution
#endregion
/// <summary>
/// Gets or sets a value indicating whether the resolver can resolve objects before resolution is frozen.
/// </summary>
/// <remarks>This is false by default and is used for some special internal resolvers.</remarks>
internal bool CanResolveBeforeFrozen { get; set; }
/// <summary>
/// Gets a value indicating whether the resolved object instance can be null.
/// </summary>
@@ -96,7 +102,10 @@ namespace Umbraco.Core.ObjectResolution
{
get
{
Resolution.EnsureIsFrozen();
// ensure we can
if (CanResolveBeforeFrozen == false)
Resolution.EnsureIsFrozen();
using (new ReadLock(_lock))
{
if (!_canBeNull && _value == null)
@@ -0,0 +1,45 @@
using System;
using NuGet;
using Umbraco.Core.Configuration;
namespace Umbraco.Core.Packaging
{
internal class DefaultPackageContext : IPackageContext
{
public DefaultPackageContext(Func<string, string> mapPath)
{}
private readonly string _localPackageRepoFolderPath;
private readonly string _pluginInstallFolderPath;
private readonly Lazy<IPackageManager> _localPackageManager;
private readonly Lazy<IPackageRepository> _localPackageRepository;
private readonly Lazy<IPackageManager> _publicPackageManager;
private readonly Lazy<IPackageManager> _privatePackageManager;
private readonly Lazy<IPackageRepository> _publicPackageRepository;
private readonly Lazy<IPackageRepository> _sprivatePackageRepository;
/// <summary>
/// Gets the local path resolver.
/// </summary>
public IPackagePathResolver LocalPathResolver
{
get { return ((PackageManager)LocalPackageManager).PathResolver; }
}
/// <summary>
/// Gets the local package manager.
/// </summary>
public IPackageManager LocalPackageManager
{
get { return _localPackageManager.Value; }
}
/// <summary>
/// Gets the public package manager.
/// </summary>
public IPackageManager PublicPackageManager
{
get { return _publicPackageManager.Value; }
}
}
}
@@ -0,0 +1,11 @@
using NuGet;
namespace Umbraco.Core.Packaging
{
internal interface IPackageContext
{
IPackageManager LocalPackageManager { get; }
IPackageManager PublicPackageManager { get; }
IPackagePathResolver LocalPathResolver { get; }
}
}
@@ -67,17 +67,18 @@ namespace Umbraco.Core.Persistence.Factories
if (property.HasIdentity)
dto.Id = property.Id;
if (property.DataTypeDatabaseType == DataTypeDatabaseType.Integer && property.Value != null && string.IsNullOrWhiteSpace(property.Value.ToString()) == false)
if (property.DataTypeDatabaseType == DataTypeDatabaseType.Integer)
{
if (property.Value is bool)
if (property.Value is bool || property.PropertyType.DataTypeId == new Guid("38b352c1-e9f8-4fd8-9324-9a2eab06d97a"))
{
int val = Convert.ToInt32(property.Value);
dto.Integer = val;
dto.Integer = property.Value != null && string.IsNullOrEmpty(property.Value.ToString())
? 0
: Convert.ToInt32(property.Value);
}
else
{
int val;
if (int.TryParse(property.Value.ToString(), out val))
if ((property.Value != null && string.IsNullOrWhiteSpace(property.Value.ToString()) == false) && int.TryParse(property.Value.ToString(), out val))
{
dto.Integer = val;
}
@@ -1,4 +1,5 @@
using System;
using System.Collections.Generic;
using System.Globalization;
using Umbraco.Core.Models;
using Umbraco.Core.Persistence.Repositories;
@@ -25,15 +26,25 @@ namespace Umbraco.Core.Persistence.Factories
ContentTypeAlias = dto.Alias ?? string.Empty,
ContentTypeIcon = dto.Icon ?? string.Empty,
ContentTypeThumbnail = dto.Thumbnail ?? string.Empty,
UmbracoFile = dto.UmbracoFile ?? string.Empty
UmbracoProperties = new List<UmbracoEntity.UmbracoProperty>()
};
entity.IsPublished = dto.PublishedVersion != default(Guid) ||
(dto.NewestVersion != default(Guid) && dto.PublishedVersion == dto.NewestVersion);
entity.IsDraft = dto.NewestVersion != default(Guid) &&
(dto.PublishedVersion == default(Guid) || dto.PublishedVersion != dto.NewestVersion);
entity.HasPendingChanges = dto.PublishedVersion != default(Guid) && dto.NewestVersion != default(Guid) &&
dto.PublishedVersion != dto.NewestVersion;
entity.IsPublished = dto.PublishedVersion != default(Guid) || (dto.NewestVersion != default(Guid) && dto.PublishedVersion == dto.NewestVersion);
entity.IsDraft = dto.NewestVersion != default(Guid) && (dto.PublishedVersion == default(Guid) || dto.PublishedVersion != dto.NewestVersion);
entity.HasPendingChanges = (dto.PublishedVersion != default(Guid) && dto.NewestVersion != default(Guid)) && dto.PublishedVersion != dto.NewestVersion;
if (dto.UmbracoPropertyDtos != null)
{
foreach (var propertyDto in dto.UmbracoPropertyDtos)
{
entity.UmbracoProperties.Add(new UmbracoEntity.UmbracoProperty
{
DataTypeControlId =
propertyDto.DataTypeControlId,
Value = propertyDto.UmbracoFile
});
}
}
return entity;
}
@@ -455,9 +455,12 @@ namespace Umbraco.Core.Persistence.Querying
if (fieldType == typeof(decimal))
return ((decimal)value).ToString(CultureInfo.InvariantCulture);
if(fieldType == typeof(DateTime))
if (fieldType == typeof(DateTime))
return "'" + EscapeParam(((DateTime)value).ToString(CultureInfo.InvariantCulture)) + "'";
if (fieldType == typeof(bool))
return ((bool)value) ? Convert.ToString(1, CultureInfo.InvariantCulture) : Convert.ToString(0, CultureInfo.InvariantCulture);
return ShouldQuoteValue(fieldType)
? "'" + EscapeParam(value) + "'"
: value.ToString();
@@ -27,6 +27,8 @@ namespace Umbraco.Core.Persistence.Repositories
{
_contentTypeRepository = contentTypeRepository;
_templateRepository = templateRepository;
EnsureUniqueNaming = true;
}
public ContentRepository(IDatabaseUnitOfWork work, IRepositoryCacheProvider cache, IContentTypeRepository contentTypeRepository, ITemplateRepository templateRepository)
@@ -34,8 +36,12 @@ namespace Umbraco.Core.Persistence.Repositories
{
_contentTypeRepository = contentTypeRepository;
_templateRepository = templateRepository;
EnsureUniqueNaming = true;
}
public bool EnsureUniqueNaming { get; set; }
#region Overrides of RepositoryBase<IContent>
protected override IContent PerformGet(int id)
@@ -180,6 +186,9 @@ namespace Umbraco.Core.Persistence.Repositories
{
((Content)entity).AddingEntity();
//Ensure unique name on the same level
entity.Name = EnsureUniqueNodeName(entity.ParentId, entity.Name);
var factory = new ContentFactory(NodeObjectTypeId, entity.Id);
var dto = factory.BuildDto(entity);
@@ -260,6 +269,9 @@ namespace Umbraco.Core.Persistence.Repositories
entity.UpdateDate = DateTime.Now;
}
//Ensure unique name on the same level
entity.Name = EnsureUniqueNodeName(entity.ParentId, entity.Name, entity.Id);
//Look up parent to get and set the correct Path and update SortOrder if ParentId has changed
if (((ICanBeDirty)entity).IsPropertyDirty("ParentId"))
{
@@ -489,5 +501,77 @@ namespace Umbraco.Core.Persistence.Repositories
return new PropertyCollection(properties);
}
private string EnsureUniqueNodeName(int parentId, string nodeName, int id = 0)
{
if (EnsureUniqueNaming == false)
return nodeName;
var sql = new Sql();
sql.Select("*")
.From<NodeDto>()
.Where<NodeDto>(x => x.ParentId == parentId && x.Text.StartsWith(nodeName));
int uniqueNumber = 1;
var currentName = nodeName;
var dtos = Database.Fetch<NodeDto>(sql);
if (dtos.Any())
{
var results = dtos.OrderBy(x => x.Text, new SimilarNodeNameComparer());
foreach (var dto in results)
{
if(id != 0 && id == dto.NodeId) continue;
if (dto.Text.ToLowerInvariant().Equals(currentName.ToLowerInvariant()))
{
currentName = nodeName + string.Format(" ({0})", uniqueNumber);
uniqueNumber++;
}
}
}
return currentName;
}
/// <summary>
/// Comparer that takes into account the duplicate index of a node name
/// This is needed as a normal alphabetic sort would go Page (1), Page (10), Page (2) etc.
/// </summary>
private class SimilarNodeNameComparer : IComparer<string>
{
public int Compare(string x, string y)
{
if (x.LastIndexOf(')') == x.Length - 1 && y.LastIndexOf(')') == y.Length - 1)
{
if (x.ToLower().Substring(0, x.LastIndexOf('(')) == y.ToLower().Substring(0, y.LastIndexOf('(')))
{
int xDuplicateIndex = ExtractDuplicateIndex(x);
int yDuplicateIndex = ExtractDuplicateIndex(y);
if (xDuplicateIndex != 0 && yDuplicateIndex != 0)
{
return xDuplicateIndex.CompareTo(yDuplicateIndex);
}
}
}
return String.Compare(x.ToLower(), y.ToLower(), StringComparison.Ordinal);
}
private int ExtractDuplicateIndex(string text)
{
int index = 0;
if (text.LastIndexOf('(') != -1 && text.LastIndexOf('(') < text.Length - 2)
{
int startPos = text.LastIndexOf('(') + 1;
int length = text.Length - 1 - startPos;
int.TryParse(text.Substring(startPos, length), out index);
}
return index;
}
}
}
}
@@ -203,7 +203,7 @@ namespace Umbraco.Core.Persistence.Repositories
.Where<NodeDto>(x => x.NodeObjectType == new Guid(Constants.ObjectTypes.Document))
.Where<ContentDto>(x => x.ContentTypeId == entity.Id);
var contentDtos = Database.Fetch<DocumentDto, ContentVersionDto, ContentDto, NodeDto>(sql);
var contentDtos = Database.Fetch<ContentDto, NodeDto>(sql);
//Loop through all tracked keys, which corresponds to the ContentTypes that has been removed from the composition
foreach (var key in compositionBase.RemovedContentTypeKeyTracker)
{
@@ -320,10 +320,12 @@ namespace Umbraco.Core.Persistence.Repositories
var sql = new Sql();
sql.Select("*")
.From<ContentTypeAllowedContentTypeDto>()
.LeftJoin<ContentTypeDto>()
.On<ContentTypeAllowedContentTypeDto, ContentTypeDto>(left => left.AllowedId, right => right.NodeId)
.Where<ContentTypeAllowedContentTypeDto>(x => x.Id == id);
var allowedContentTypeDtos = Database.Fetch<ContentTypeAllowedContentTypeDto>(sql);
return allowedContentTypeDtos.Select(x => new ContentTypeSort { Id = new Lazy<int>(() => x.AllowedId), SortOrder = x.SortOrder }).ToList();
var allowedContentTypeDtos = Database.Fetch<ContentTypeAllowedContentTypeDto, ContentTypeDto>(sql);
return allowedContentTypeDtos.Select(x => new ContentTypeSort { Id = new Lazy<int>(() => x.AllowedId), Alias = x.ContentTypeDto.Alias, SortOrder = x.SortOrder }).ToList();
}
protected PropertyGroupCollection GetPropertyGroupCollection(int id, DateTime createDate, DateTime updateDate)
@@ -45,7 +45,7 @@ namespace Umbraco.Core.Persistence.Repositories
public virtual IUmbracoEntity Get(int id)
{
var sql = GetBaseWhere(GetBase, false, id);
var sql = GetBaseWhere(GetBase, false, false, id);
var nodeDto = _work.Database.FirstOrDefault<UmbracoEntityDto>(sql);
if (nodeDto == null)
return null;
@@ -58,8 +58,9 @@ namespace Umbraco.Core.Persistence.Repositories
public virtual IUmbracoEntity Get(int id, Guid objectTypeId)
{
bool isContentOrMedia = objectTypeId == new Guid(Constants.ObjectTypes.Document) || objectTypeId == new Guid(Constants.ObjectTypes.Media);
var sql = GetBaseWhere(GetBase, isContentOrMedia, objectTypeId, id).Append(GetGroupBy(isContentOrMedia));
bool isContent = objectTypeId == new Guid(Constants.ObjectTypes.Document);
bool isMedia = objectTypeId == new Guid(Constants.ObjectTypes.Media);
var sql = GetBaseWhere(GetBase, isContent, isMedia, objectTypeId, id).Append(GetGroupBy(isContent, isMedia));
var nodeDto = _work.Database.FirstOrDefault<UmbracoEntityDto>(sql);
if (nodeDto == null)
return null;
@@ -81,10 +82,13 @@ namespace Umbraco.Core.Persistence.Repositories
}
else
{
bool isContentOrMedia = objectTypeId == new Guid(Constants.ObjectTypes.Document) || objectTypeId == new Guid(Constants.ObjectTypes.Media);
var sql = GetBaseWhere(GetBase, isContentOrMedia, objectTypeId).Append(GetGroupBy(isContentOrMedia));
var dtos = _work.Database.Fetch<UmbracoEntityDto>(sql);
bool isContent = objectTypeId == new Guid(Constants.ObjectTypes.Document);
bool isMedia = objectTypeId == new Guid(Constants.ObjectTypes.Media);
var sql = GetBaseWhere(GetBase, isContent, isMedia, objectTypeId).Append(GetGroupBy(isContent, isMedia));
var dtos = isMedia
? _work.Database.Fetch<UmbracoEntityDto, UmbracoPropertyDto, UmbracoEntityDto>(
new UmbracoEntityRelator().Map, sql)
: _work.Database.Fetch<UmbracoEntityDto>(sql);
var factory = new UmbracoEntityFactory();
foreach (var dto in dtos)
@@ -97,9 +101,9 @@ namespace Umbraco.Core.Persistence.Repositories
public virtual IEnumerable<IUmbracoEntity> GetByQuery(IQuery<IUmbracoEntity> query)
{
var sqlClause = GetBase(false);
var sqlClause = GetBase(false, false);
var translator = new SqlTranslator<IUmbracoEntity>(sqlClause, query);
var sql = translator.Translate().Append(GetGroupBy(false));
var sql = translator.Translate().Append(GetGroupBy(false, false));
var dtos = _work.Database.Fetch<UmbracoEntityDto>(sql);
@@ -111,12 +115,16 @@ namespace Umbraco.Core.Persistence.Repositories
public virtual IEnumerable<IUmbracoEntity> GetByQuery(IQuery<IUmbracoEntity> query, Guid objectTypeId)
{
bool isContentOrMedia = objectTypeId == new Guid(Constants.ObjectTypes.Document) || objectTypeId == new Guid(Constants.ObjectTypes.Media);
var sqlClause = GetBaseWhere(GetBase, isContentOrMedia, objectTypeId);
bool isContent = objectTypeId == new Guid(Constants.ObjectTypes.Document);
bool isMedia = objectTypeId == new Guid(Constants.ObjectTypes.Media);
var sqlClause = GetBaseWhere(GetBase, isContent, isMedia, objectTypeId);
var translator = new SqlTranslator<IUmbracoEntity>(sqlClause, query);
var sql = translator.Translate().Append(GetGroupBy(isContentOrMedia));
var sql = translator.Translate().Append(GetGroupBy(isContent, isMedia));
var dtos = _work.Database.Fetch<UmbracoEntityDto>(sql);
var dtos = isMedia
? _work.Database.Fetch<UmbracoEntityDto, UmbracoPropertyDto, UmbracoEntityDto>(
new UmbracoEntityRelator().Map, sql)
: _work.Database.Fetch<UmbracoEntityDto>(sql);
var factory = new UmbracoEntityFactory();
var list = dtos.Select(factory.BuildEntity).Cast<IUmbracoEntity>().ToList();
@@ -128,7 +136,7 @@ namespace Umbraco.Core.Persistence.Repositories
#region Sql Statements
protected virtual Sql GetBase(bool isContentOrMedia)
protected virtual Sql GetBase(bool isContent, bool isMedia)
{
var columns = new List<object>
{
@@ -146,14 +154,19 @@ namespace Umbraco.Core.Persistence.Repositories
"COUNT(parent.parentID) as children"
};
if (isContentOrMedia)
if (isContent || isMedia)
{
columns.Add("published.versionId as publishedVerison");
columns.Add("latest.versionId as newestVersion");
columns.Add("contenttype.alias");
columns.Add("contenttype.icon");
columns.Add("contenttype.thumbnail");
}
if (isMedia)
{
columns.Add("property.dataNvarchar as umbracoFile");
columns.Add("property.controlId");
}
var sql = new Sql()
@@ -162,7 +175,7 @@ namespace Umbraco.Core.Persistence.Repositories
.LeftJoin("umbracoNode parent").On("parent.parentID = umbracoNode.id");
if (isContentOrMedia)
if (isContent || isMedia)
{
sql.InnerJoin("cmsContent content").On("content.nodeId = umbracoNode.id")
.LeftJoin("cmsContentType contenttype").On("contenttype.nodeId = content.contentType")
@@ -171,40 +184,51 @@ namespace Umbraco.Core.Persistence.Repositories
.On("umbracoNode.id = published.nodeId")
.LeftJoin(
"(SELECT nodeId, versionId FROM cmsDocument WHERE newest = 1 GROUP BY nodeId, versionId) as latest")
.On("umbracoNode.id = latest.nodeId")
.LeftJoin(
"(SELECT contentNodeId, dataNvarchar FROM cmsPropertyData INNER JOIN cmsPropertyType ON cmsPropertyType.id = cmsPropertyData.propertytypeid"+
" INNER JOIN cmsDataType ON cmsPropertyType.dataTypeId = cmsDataType.nodeId WHERE cmsDataType.controlId = '"+ Constants.PropertyEditors.UploadField +"') as property")
.On("umbracoNode.id = latest.nodeId");
}
/*if (isContent)
{
sql.LeftJoin(
"(SELECT contentNodeId, versionId, dataNvarchar, controlId FROM cmsPropertyData INNER JOIN cmsPropertyType ON cmsPropertyType.id = cmsPropertyData.propertytypeid" +
" INNER JOIN cmsDataType ON cmsPropertyType.dataTypeId = cmsDataType.nodeId) as property")
.On("umbracoNode.id = property.contentNodeId AND latest.versionId = property.versionId");
}*/
if (isMedia)
{
sql.LeftJoin(
"(SELECT contentNodeId, versionId, dataNvarchar, controlId FROM cmsPropertyData INNER JOIN cmsPropertyType ON cmsPropertyType.id = cmsPropertyData.propertytypeid" +
" INNER JOIN cmsDataType ON cmsPropertyType.dataTypeId = cmsDataType.nodeId) as property")
.On("umbracoNode.id = property.contentNodeId");
}
return sql;
}
protected virtual Sql GetBaseWhere(Func<bool, Sql> baseQuery, bool isContentOrMedia, Guid id)
protected virtual Sql GetBaseWhere(Func<bool, bool, Sql> baseQuery, bool isContent, bool isMedia, Guid id)
{
var sql = baseQuery(isContentOrMedia)
var sql = baseQuery(isContent, isMedia)
.Where("umbracoNode.nodeObjectType = @NodeObjectType", new { NodeObjectType = id });
return sql;
}
protected virtual Sql GetBaseWhere(Func<bool, Sql> baseQuery, bool isContentOrMedia, int id)
protected virtual Sql GetBaseWhere(Func<bool, bool, Sql> baseQuery, bool isContent, bool isMedia, int id)
{
var sql = baseQuery(isContentOrMedia)
var sql = baseQuery(isContent, isMedia)
.Where("umbracoNode.id = @Id", new { Id = id })
.Append(GetGroupBy(isContentOrMedia));
.Append(GetGroupBy(isContent, isMedia));
return sql;
}
protected virtual Sql GetBaseWhere(Func<bool, Sql> baseQuery, bool isContentOrMedia, Guid objectId, int id)
protected virtual Sql GetBaseWhere(Func<bool, bool, Sql> baseQuery, bool isContent, bool isMedia, Guid objectId, int id)
{
var sql = baseQuery(isContentOrMedia)
var sql = baseQuery(isContent, isMedia)
.Where("umbracoNode.id = @Id AND umbracoNode.nodeObjectType = @NodeObjectType",
new {Id = id, NodeObjectType = objectId});
return sql;
}
protected virtual Sql GetGroupBy(bool isContentOrMedia)
protected virtual Sql GetGroupBy(bool isContent, bool isMedia)
{
var columns = new List<object>
{
@@ -221,14 +245,19 @@ namespace Umbraco.Core.Persistence.Repositories
"umbracoNode.createDate"
};
if (isContentOrMedia)
if (isContent || isMedia)
{
columns.Add("published.versionId");
columns.Add("latest.versionId");
columns.Add("contenttype.alias");
columns.Add("contenttype.icon");
columns.Add("contenttype.thumbnail");
}
if (isMedia)
{
columns.Add("property.dataNvarchar");
columns.Add("property.controlId");
}
var sql = new Sql()
@@ -262,7 +291,7 @@ namespace Umbraco.Core.Persistence.Repositories
[Column("publishedVerison")]
public Guid PublishedVersion { get; set; }
[Column("newestVerison")]
[Column("newestVersion")]
public Guid NewestVersion { get; set; }
[Column("alias")]
@@ -274,9 +303,57 @@ namespace Umbraco.Core.Persistence.Repositories
[Column("thumbnail")]
public string Thumbnail { get; set; }
[ResultColumn]
public List<UmbracoPropertyDto> UmbracoPropertyDtos { get; set; }
}
[ExplicitColumns]
internal class UmbracoPropertyDto
{
[Column("controlId")]
public Guid DataTypeControlId { get; set; }
[Column("umbracoFile")]
public string UmbracoFile { get; set; }
}
internal class UmbracoEntityRelator
{
internal UmbracoEntityDto Current;
internal UmbracoEntityDto Map(UmbracoEntityDto a, UmbracoPropertyDto p)
{
// Terminating call. Since we can return null from this function
// we need to be ready for PetaPoco to callback later with null
// parameters
if (a == null)
return Current;
// Is this the same UmbracoEntityDto as the current one we're processing
if (Current != null && Current.UniqueId == a.UniqueId)
{
// Yes, just add this UmbracoPropertyDto to the current UmbracoEntityDto's collection
Current.UmbracoPropertyDtos.Add(p);
// Return null to indicate we're not done with this UmbracoEntityDto yet
return null;
}
// This is a different UmbracoEntityDto to the current one, or this is the
// first time through and we don't have a Tab yet
// Save the current UmbracoEntityDto
var prev = Current;
// Setup the new current UmbracoEntityDto
Current = a;
Current.UmbracoPropertyDtos = new List<UmbracoPropertyDto>();
Current.UmbracoPropertyDtos.Add(p);
// Return the now populated previous UmbracoEntityDto (or null if first time through)
return prev;
}
}
#endregion
}
}
@@ -43,7 +43,7 @@ namespace Umbraco.Core.Persistence
uow,
RuntimeCacheProvider.Current,
CreateContentTypeRepository(uow),
CreateTemplateRepository(uow));
CreateTemplateRepository(uow)) { EnsureUniqueNaming = Umbraco.Core.Configuration.UmbracoSettings.EnsureUniqueNaming };
}
public virtual IContentTypeRepository CreateContentTypeRepository(IDatabaseUnitOfWork uow)
+43
View File
@@ -0,0 +1,43 @@
using System;
namespace Umbraco.Core.Profiling
{
/// <summary>
/// Defines an object for use in the application to profile operations
/// </summary>
internal interface IProfiler
{
/// <summary>
/// Render the UI to display the profiler
/// </summary>
/// <returns></returns>
/// <remarks>
/// Generally used for HTML displays
/// </remarks>
string Render();
/// <summary>
/// Profile an operation
/// </summary>
/// <param name="name"></param>
/// <returns></returns>
/// <remarks>
/// Use the 'using(' syntax
/// </remarks>
IDisposable Step(string name);
/// <summary>
/// Start the profiler
/// </summary>
void Start();
/// <summary>
/// Start the profiler
/// </summary>
/// <remarks>
/// set discardResults to false when you want to abandon all profiling, this is useful for
/// when someone is not authenticated or you want to clear the results based on some other mechanism.
/// </remarks>
void Stop(bool discardResults = false);
}
}
+35
View File
@@ -0,0 +1,35 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Umbraco.Core.Logging;
namespace Umbraco.Core.Profiling
{
/// <summary>
/// A profiler that outputs its results to the LogHelper
/// </summary>
internal class LogProfiler : IProfiler
{
public string Render()
{
return string.Empty;
}
public IDisposable Step(string name)
{
LogHelper.Debug(typeof(LogProfiler), "Starting - " + name);
return DisposableTimer.Start(l => LogHelper.Info(typeof(LogProfiler), () => name + " (took " + l + "ms)"));
}
public void Start()
{
//the log will alwasy be started
}
public void Stop(bool discardResults = false)
{
//we don't need to do anything here
}
}
}
-52
View File
@@ -1,52 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using StackExchange.Profiling;
namespace Umbraco.Core.Profiling
{
public class Profiler
{
private static Profiler _instance;
private Profiler()
{
}
public string Render()
{
return MiniProfiler.RenderIncludes().ToString();
}
public IDisposable Step(string name)
{
return MiniProfiler.Current.Step(name);
}
public void Start()
{
MiniProfiler.Start();
}
public void Stop()
{
MiniProfiler.Stop();
}
public static Profiler Instance
{
get
{
if (_instance == null)
{
_instance = new Profiler();
}
return _instance;
}
}
}
}
@@ -0,0 +1,35 @@
using System;
namespace Umbraco.Core.Profiling
{
internal static class ProfilerExtensions
{
/// <summary>
/// Writes out a step prefixed with the type
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="profiler"></param>
/// <param name="name"></param>
/// <returns></returns>
internal static IDisposable Step<T>(this IProfiler profiler, string name)
{
if (profiler == null) throw new ArgumentNullException("profiler");
return profiler.Step(typeof (T), name);
}
/// <summary>
/// Writes out a step prefixed with the type
/// </summary>
/// <param name="profiler"></param>
/// <param name="objectType"></param>
/// <param name="name"></param>
/// <returns></returns>
internal static IDisposable Step(this IProfiler profiler, Type objectType, string name)
{
if (profiler == null) throw new ArgumentNullException("profiler");
if (objectType == null) throw new ArgumentNullException("objectType");
if (name == null) throw new ArgumentNullException("name");
return profiler.Step(string.Format("[{0}] {1}", objectType.Name, name));
}
}
}
@@ -0,0 +1,39 @@
using Umbraco.Core.ObjectResolution;
namespace Umbraco.Core.Profiling
{
/// <summary>
/// A resolver exposing the current profiler
/// </summary>
internal class ProfilerResolver : SingleObjectResolverBase<ProfilerResolver, IProfiler>
{
/// <summary>
/// Constructor
/// </summary>
/// <param name="profiler"></param>
public ProfilerResolver(IProfiler profiler)
: base(profiler)
{
}
/// <summary>
/// Method allowing to change the profiler during startup
/// </summary>
/// <param name="profiler"></param>
internal void SetProfiler(IProfiler profiler)
{
Value = profiler;
}
/// <summary>
/// Gets the current profiler
/// </summary>
public IProfiler Profiler
{
get { return Value; }
}
}
}
+161
View File
@@ -0,0 +1,161 @@
using System;
using System.Web;
using StackExchange.Profiling;
using Umbraco.Core.Configuration;
using Umbraco.Core.Logging;
namespace Umbraco.Core.Profiling
{
/// <summary>
/// A profiler used for web based activity based on the MiniProfiler framework
/// </summary>
internal class WebProfiler : IProfiler
{
/// <summary>
/// Constructor
/// </summary>
/// <remarks>
/// Binds to application events to enable the MiniProfiler
/// </remarks>
internal WebProfiler()
{
UmbracoApplicationBase.ApplicationInit += UmbracoApplicationApplicationInit;
}
/// <summary>
/// Handle the Init event o fthe UmbracoApplication which allows us to subscribe to the HttpApplication events
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
void UmbracoApplicationApplicationInit(object sender, EventArgs e)
{
var app = sender as HttpApplication;
if (app == null) return;
if (SystemUtilities.GetCurrentTrustLevel() < AspNetHostingPermissionLevel.High)
{
//If we don't have a high enough trust level we cannot bind to the events
LogHelper.Info<WebProfiler>("Cannot start the WebProfiler since the application is running in Medium trust");
}
else
{
app.BeginRequest += UmbracoApplicationBeginRequest;
app.EndRequest += UmbracoApplicationEndRequest;
}
}
/// <summary>
/// Handle the begin request event
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
void UmbracoApplicationEndRequest(object sender, EventArgs e)
{
if (GlobalSettings.DebugMode == false) return;
var request = TryGetRequest(sender);
if (request.Success == false) return;
if (request.Result.Url.IsClientSideRequest()) return;
if (string.IsNullOrEmpty(request.Result["umbDebug"]) == false)
{
//stop the profiler
Stop();
}
}
/// <summary>
/// Handle the end request event
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
void UmbracoApplicationBeginRequest(object sender, EventArgs e)
{
if (GlobalSettings.DebugMode == false) return;
var request = TryGetRequest(sender);
if (request.Success == false) return;
if (request.Result.Url.IsClientSideRequest()) return;
if (string.IsNullOrEmpty(request.Result["umbDebug"]) == false)
{
//start the profiler
Start();
}
}
/// <summary>
/// Render the UI to display the profiler
/// </summary>
/// <returns></returns>
/// <remarks>
/// Generally used for HTML displays
/// </remarks>
public string Render()
{
return MiniProfiler.RenderIncludes().ToString();
}
/// <summary>
/// Profile a step
/// </summary>
/// <param name="name"></param>
/// <returns></returns>
/// <remarks>
/// Use the 'using(' syntax
/// </remarks>
public IDisposable Step(string name)
{
if (GlobalSettings.DebugMode == false) return null;
return MiniProfiler.Current.Step(name);
}
/// <summary>
/// Start the profiler
/// </summary>
public void Start()
{
if (GlobalSettings.DebugMode == false) return;
//will not run in medium trust
if (SystemUtilities.GetCurrentTrustLevel() < AspNetHostingPermissionLevel.High) return;
MiniProfiler.Start();
}
/// <summary>
/// Start the profiler
/// </summary>
/// <remarks>
/// set discardResults to false when you want to abandon all profiling, this is useful for
/// when someone is not authenticated or you want to clear the results based on some other mechanism.
/// </remarks>
public void Stop(bool discardResults = false)
{
if (GlobalSettings.DebugMode == false) return;
//will not run in medium trust
if (SystemUtilities.GetCurrentTrustLevel() < AspNetHostingPermissionLevel.High) return;
MiniProfiler.Stop(discardResults);
}
/// <summary>
/// Gets the request object from the app instance if it is available
/// </summary>
/// <param name="sender">The application object</param>
/// <returns></returns>
private Attempt<HttpRequestBase> TryGetRequest(object sender)
{
var app = sender as HttpApplication;
if (app == null) return Attempt<HttpRequestBase>.False;
try
{
var req = app.Request;
return new Attempt<HttpRequestBase>(true, new HttpRequestWrapper(req));
}
catch (HttpException ex)
{
return new Attempt<HttpRequestBase>(ex);
}
}
}
}
+2 -1
View File
@@ -42,4 +42,5 @@ using System.Security.Permissions;
[assembly: InternalsVisibleTo("Umbraco.Courier.Persistence")]
[assembly: InternalsVisibleTo("Concorde.Sync")]
[assembly: InternalsVisibleTo("Umbraco.Belle")]
[assembly: InternalsVisibleTo("Umbraco.Belle")]
[assembly: InternalsVisibleTo("Umbraco.VisualStudio")]
@@ -1,48 +0,0 @@
using System;
namespace Umbraco.Core.PropertyEditors.Attributes
{
/// <summary>
/// Defines a PropertyEditor
/// </summary>
[AttributeUsage(AttributeTargets.Class, AllowMultiple = false)]
internal sealed class PropertyEditorAttribute : Attribute
{
public PropertyEditorAttribute(string id, string alias, string name)
{
Mandate.ParameterNotNullOrEmpty(id, "id");
Mandate.ParameterNotNullOrEmpty(alias, "alias");
Mandate.ParameterNotNullOrEmpty(name, "name");
Id = Guid.Parse(id);
Alias = alias;
Name = name;
IsContentPropertyEditor = true;
}
public Guid Id { get; private set; }
/// <summary>
/// Gets or sets the name.
/// </summary>
/// <value>The name.</value>
public string Name { get; set; }
/// <summary>
/// Gets or sets the alias.
/// </summary>
/// <value>The alias.</value>
public string Alias { get; set; }
/// <summary>
/// Flag determining if this property editor is used to edit content
/// </summary>
public bool IsContentPropertyEditor { get; set; }
/// <summary>
/// Flag determining if this property editor is used to edit parameters
/// </summary>
public bool IsParameterEditor { get; set; }
}
}
@@ -1,22 +0,0 @@
using System;
namespace Umbraco.Core.PropertyEditors.Attributes
{
/// <summary>
/// Attribute determining whether or not to hide/show the label of a property
/// </summary>
/// <remarks>
/// This directly affects the meta data property: HideSurroundingHtml
/// </remarks>
[AttributeUsage(AttributeTargets.Property | AttributeTargets.Field, AllowMultiple = false, Inherited = false)]
internal class ShowLabelAttribute : Attribute
{
public ShowLabelAttribute(bool show)
{
ShowLabel = show;
}
public bool ShowLabel { get; private set; }
}
}
@@ -1,13 +0,0 @@
namespace Umbraco.Core.PropertyEditors
{
/// <summary>
/// A class representing a blank, null or empty pre-value editor.
/// </summary>
/// <remarks>
/// This class can be used for Property Editors who do not define a Pre value editor
/// </remarks>
internal class BlankPreValueModel : PreValueModel
{
}
}
@@ -1,147 +0,0 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Web.Mvc;
namespace Umbraco.Core.PropertyEditors
{
internal abstract class EditorModel<TValueModel> where TValueModel : IValueModel, new()
{
protected EditorModel()
{
// Set the UI Elements collection to an empty list
//UIElements = new List<UIElement>();
}
[ReadOnly(true)]
public virtual bool ShowUmbracoLabel
{
get { return true; }
}
/// <summary>
/// Gets a list of UI Elements for the property editor.
/// </summary>
//[ScaffoldColumn(false)]
//public virtual IList<UIElement> UIElements { get; protected internal set; }
private ModelMetadata _modelMetadata;
/// <summary>
/// Returns the meta data for the current editor model
/// </summary>
protected internal ModelMetadata MetaData
{
get
{
return _modelMetadata ?? (_modelMetadata = ModelMetadataProviders.Current.GetMetadataForType(() => this, GetType()));
}
}
/// <summary>
/// Returns the serialized value for the PropertyEditor
/// </summary>
/// <returns></returns>
public virtual IDictionary<string, object> GetSerializedValue()
{
var editableProps = MetaData.Properties.Where(x => x.ShowForEdit && !x.IsReadOnly);
var d = new Dictionary<string, object>();
foreach (var p in editableProps)
{
//by default, we will not support complex modelled properties, developers will need to override
//the GetSerializedValue method if they need support for this.
if (p.IsComplexType)
{
//TODO: We should magically support this
throw new NotSupportedException("The default serialization implementation of EditorModel does not support properties that are complex models");
}
d.Add(p.PropertyName, p.Model);
}
return d;
}
public virtual void SetModelValues(IDictionary<string, object> serializedVal)
{
if (serializedVal == null || serializedVal.Count == 0)
{
return;
}
var modelProperties = GetType().GetProperties();
var editableProps = MetaData.Properties.Where(x => x.ShowForEdit && !x.IsReadOnly);
foreach (var i in serializedVal)
{
if (i.Value == null)
continue;
//get the property with the name
var prop = editableProps.Where(x => x.PropertyName == i.Key).SingleOrDefault();
if (prop != null)
{
//set the property value
var toConverter = TypeDescriptor.GetConverter(prop.ModelType);
if (toConverter != null)
{
//get the model property for this property meta data to set its value
var propInfo = modelProperties.Where(x => x.Name == prop.PropertyName).Single();
object convertedVal;
//if value is already of the same type, just use the current value, otherwise try and convert it
if (i.Value.GetType() == propInfo.PropertyType)
{
convertedVal = i.Value;
}
else
{
try
{
convertedVal = toConverter.ConvertFrom(i.Value);
}
catch (NotSupportedException)
{
//this occurs when the converter doesn't know how, so we can try the opposite way as a last ditch effort
var fromConverter = TypeDescriptor.GetConverter(i.Value.GetType());
if (fromConverter == null)
{
throw;
}
convertedVal = fromConverter.ConvertTo(i.Value, prop.ModelType);
}
}
propInfo.SetValue(this, convertedVal, null);
}
}
}
}
public virtual TValueModel GetValueModel()
{
var editableProps = MetaData.Properties.Where(x => x.ShowForEdit && !x.IsReadOnly);
var d = new TValueModel();
foreach (var p in editableProps)
{
//by default, we will not support complex modelled properties, developers will need to override
//the GetSerializedValue method if they need support for this.
//TODO Test if this exception is still valid
if (p.IsComplexType)
{
throw new NotSupportedException("The default serialization implementation of EditorModel does not support properties that are complex models");
}
var property = d.GetType().GetProperty(p.PropertyName);
if(property != null)
{
property.SetValue(d, p.Model, null);
}
}
return d;
}
}
}
@@ -1,27 +0,0 @@
namespace Umbraco.Core.PropertyEditors
{
/// <summary>
/// An abstract class representing the model to render a Property Editor's content editor with PreValues
/// </summary>
/// <typeparam name="TPreValueModel">The type of the PreValue model.</typeparam>
/// <typeparam name="TValueModel"> </typeparam>
internal abstract class EditorModel<TValueModel, TPreValueModel> : EditorModel<TValueModel>
where TValueModel : IValueModel, new()
where TPreValueModel : PreValueModel
{
/// <summary>
/// Constructor
/// </summary>
/// <param name="preValues">The pre value options used to construct the editor</param>
protected EditorModel(TPreValueModel preValues)
{
PreValueModel = preValues;
}
/// <summary>
/// The pre value options used to configure the editor
/// </summary>
/// <value>The pre value model.</value>
public TPreValueModel PreValueModel { get; protected internal set; }
}
}
@@ -1,7 +0,0 @@
namespace Umbraco.Core.PropertyEditors
{
internal interface IValueModel
{
}
}
@@ -1,21 +0,0 @@
using System;
namespace Umbraco.Core.PropertyEditors
{
/// <summary>
/// A class representing a single value of a Pre-Value editor to be saved
/// </summary>
internal class PreValueDefinition
{
public PreValueDefinition(string propertyName, Type modeType, object modelValue)
{
ModelType = modeType;
PropertyName = propertyName;
ModelValue = modelValue;
}
public Type ModelType { get; private set; }
public string PropertyName { get; private set; }
public object ModelValue { get; private set; }
}
}
@@ -1,31 +0,0 @@
using System;
using System.Collections.Generic;
namespace Umbraco.Core.PropertyEditors
{
/// <summary>
/// Abstract class representing a Property Editor's model to render it's Pre value editor
/// </summary>
internal abstract class PreValueModel
{
protected virtual IEnumerable<PreValueDefinition> GetValueDefinitions()
{
throw new NotImplementedException();
}
public virtual string GetSerializedValue()
{
throw new NotImplementedException();
}
protected virtual void SetModelPropertyValue(PreValueDefinition def, Action<object> setProperty)
{
throw new NotImplementedException();
}
public virtual void SetModelValues(string serializedVal)
{
throw new NotImplementedException();
}
}
}
@@ -1,37 +0,0 @@
using System;
using System.Linq;
using Umbraco.Core.PropertyEditors.Attributes;
namespace Umbraco.Core.PropertyEditors
{
internal abstract class PropertyEditor
{
/// <summary>
/// Constructor for a PropertyEditor
/// </summary>
protected PropertyEditor()
{
//Locate the metadata attribute
var docTypeAttributes = GetType()
.GetCustomAttributes(typeof(PropertyEditorAttribute), true)
.OfType<PropertyEditorAttribute>();
if (!docTypeAttributes.Any())
throw new InvalidOperationException(
string.Format("The PropertyEditor of type {0} is missing the {1} attribute", GetType().FullName,
typeof(PropertyEditorAttribute).FullName));
//assign the properties of this object to those of the metadata attribute
var attr = docTypeAttributes.First();
Id = attr.Id;
Name = attr.Name;
Alias = attr.Alias;
}
public virtual Guid Id { get; protected set; }
public virtual string Name { get; protected set; }
public virtual string Alias { get; protected set; }
}
}
@@ -1,49 +0,0 @@
namespace Umbraco.Core.PropertyEditors
{
/// <summary>
/// Abstract class that all Property editors should inherit from
/// </summary>
/// <typeparam name="TEditorModel"></typeparam>
/// <typeparam name="TPreValueModel"></typeparam>
/// <typeparam name="TValueModel"> </typeparam>
internal abstract class PropertyEditor<TValueModel, TEditorModel, TPreValueModel> : PropertyEditor
where TValueModel : IValueModel, new()
where TEditorModel : EditorModel<TValueModel>
where TPreValueModel : PreValueModel
{
/// <summary>
/// Returns the editor model to be used for the property editor
/// </summary>
/// <returns></returns>
public abstract TEditorModel CreateEditorModel(TPreValueModel preValues);
/// <summary>
/// Returns the editor model to be used for the prevalue editor
/// </summary>
/// <returns></returns>
public abstract TPreValueModel CreatePreValueEditorModel();
}
/// <summary>
/// Abstract class that Property editors should inherit from that don't require a pre-value editor
/// </summary>
/// <typeparam name="TEditorModel"></typeparam>
/// <typeparam name="TValueModel"> </typeparam>
internal abstract class PropertyEditor<TValueModel, TEditorModel> : PropertyEditor<TValueModel, TEditorModel, BlankPreValueModel>
where TValueModel : IValueModel, new()
where TEditorModel : EditorModel<TValueModel>
{
public override BlankPreValueModel CreatePreValueEditorModel()
{
return new BlankPreValueModel();
}
public sealed override TEditorModel CreateEditorModel(BlankPreValueModel preValues)
{
return CreateEditorModel();
}
public abstract TEditorModel CreateEditorModel();
}
}
+257 -76
View File
@@ -60,8 +60,13 @@ namespace Umbraco.Core.Services
/// <summary>
/// Creates an <see cref="IContent"/> object using the alias of the <see cref="IContentType"/>
/// that this Content is based on.
/// that this Content should based on.
/// </summary>
/// <remarks>
/// Note that using this method will simply return a new IContent without any identity
/// as it has not yet been persisted. It is intended as a shortcut to creating new content objects
/// that does not invoke a save operation against the database.
/// </remarks>
/// <param name="name">Name of the Content object</param>
/// <param name="parentId">Id of Parent for the new Content</param>
/// <param name="contentTypeAlias">Alias of the <see cref="IContentType"/></param>
@@ -70,7 +75,7 @@ namespace Umbraco.Core.Services
public IContent CreateContent(string name, int parentId, string contentTypeAlias, int userId = 0)
{
var contentType = FindContentTypeByAlias(contentTypeAlias);
var content = new Content(name, parentId, contentType); ;
var content = new Content(name, parentId, contentType);
if (Creating.IsRaisedEventCancelled(new NewEventArgs<IContent>(content, contentTypeAlias, parentId), this))
{
@@ -90,8 +95,13 @@ namespace Umbraco.Core.Services
/// <summary>
/// Creates an <see cref="IContent"/> object using the alias of the <see cref="IContentType"/>
/// that this Content is based on.
/// that this Content should based on.
/// </summary>
/// <remarks>
/// Note that using this method will simply return a new IContent without any identity
/// as it has not yet been persisted. It is intended as a shortcut to creating new content objects
/// that does not invoke a save operation against the database.
/// </remarks>
/// <param name="name">Name of the Content object</param>
/// <param name="parent">Parent <see cref="IContent"/> object for the new Content</param>
/// <param name="contentTypeAlias">Alias of the <see cref="IContentType"/></param>
@@ -118,6 +128,86 @@ namespace Umbraco.Core.Services
return content;
}
/// <summary>
/// Creates and saves an <see cref="IContent"/> object using the alias of the <see cref="IContentType"/>
/// that this Content should based on.
/// </summary>
/// <remarks>
/// This method returns an <see cref="IContent"/> object that has been persisted to the database
/// and therefor has an identity.
/// </remarks>
/// <param name="name">Name of the Content object</param>
/// <param name="parentId">Id of Parent for the new Content</param>
/// <param name="contentTypeAlias">Alias of the <see cref="IContentType"/></param>
/// <param name="userId">Optional id of the user creating the content</param>
/// <returns><see cref="IContent"/></returns>
public IContent CreateContentWithIdentity(string name, int parentId, string contentTypeAlias, int userId = 0)
{
var contentType = FindContentTypeByAlias(contentTypeAlias);
var content = new Content(name, parentId, contentType);
if (Creating.IsRaisedEventCancelled(new NewEventArgs<IContent>(content, contentTypeAlias, parentId), this))
{
content.WasCancelled = true;
return content;
}
var uow = _uowProvider.GetUnitOfWork();
using (var repository = _repositoryFactory.CreateContentRepository(uow))
{
content.CreatorId = userId;
content.WriterId = userId;
repository.AddOrUpdate(content);
uow.Commit();
}
Created.RaiseEvent(new NewEventArgs<IContent>(content, false, contentTypeAlias, parentId), this);
Audit.Add(AuditTypes.New, "", content.CreatorId, content.Id);
return content;
}
/// <summary>
/// Creates and saves an <see cref="IContent"/> object using the alias of the <see cref="IContentType"/>
/// that this Content should based on.
/// </summary>
/// <remarks>
/// This method returns an <see cref="IContent"/> object that has been persisted to the database
/// and therefor has an identity.
/// </remarks>
/// <param name="name">Name of the Content object</param>
/// <param name="parent">Parent <see cref="IContent"/> object for the new Content</param>
/// <param name="contentTypeAlias">Alias of the <see cref="IContentType"/></param>
/// <param name="userId">Optional id of the user creating the content</param>
/// <returns><see cref="IContent"/></returns>
public IContent CreateContentWithIdentity(string name, IContent parent, string contentTypeAlias, int userId = 0)
{
var contentType = FindContentTypeByAlias(contentTypeAlias);
var content = new Content(name, parent, contentType);
if (Creating.IsRaisedEventCancelled(new NewEventArgs<IContent>(content, contentTypeAlias, parent), this))
{
content.WasCancelled = true;
return content;
}
var uow = _uowProvider.GetUnitOfWork();
using (var repository = _repositoryFactory.CreateContentRepository(uow))
{
content.CreatorId = userId;
content.WriterId = userId;
repository.AddOrUpdate(content);
uow.Commit();
}
Created.RaiseEvent(new NewEventArgs<IContent>(content, false, contentTypeAlias, parent), this);
Audit.Add(AuditTypes.New, "", content.CreatorId, content.Id);
return content;
}
/// <summary>
/// Gets an <see cref="IContent"/> object by Id
/// </summary>
@@ -243,7 +333,7 @@ namespace Umbraco.Core.Services
using (var repository = _repositoryFactory.CreateContentRepository(_uowProvider.GetUnitOfWork()))
{
var query = Query<IContent>.Builder.Where(x => x.ParentId == id);
var contents = repository.GetByQuery(query);
var contents = repository.GetByQuery(query).OrderBy(x => x.SortOrder);
return contents;
}
@@ -946,7 +1036,10 @@ namespace Umbraco.Core.Services
var uow = _uowProvider.GetUnitOfWork();
using (var repository = _repositoryFactory.CreateContentRepository(uow))
{
content.WriterId = userId;
// Update the create author and last edit author
copy.CreatorId = userId;
copy.WriterId = userId;
repository.AddOrUpdate(copy);
uow.Commit();
@@ -1021,7 +1114,7 @@ namespace Umbraco.Core.Services
}
//Look for children and copy those as well
var children = GetChildren(content.Id).OrderBy(x => x.SortOrder);
var children = GetChildren(content.Id);
foreach (var child in children)
{
Copy(child, copy.Id, relateToOriginal, userId);
@@ -1082,6 +1175,7 @@ namespace Umbraco.Core.Services
{
content.WriterId = userId;
content.CreatorId = userId;
content.ChangePublishedState(PublishedState.Unpublished);
repository.AddOrUpdate(content);
uow.Commit();
@@ -1094,6 +1188,92 @@ namespace Umbraco.Core.Services
return content;
}
/// <summary>
/// Sorts a collection of <see cref="IContent"/> objects by updating the SortOrder according
/// to the ordering of items in the passed in <see cref="IEnumerable{T}"/>.
/// </summary>
/// <remarks>
/// Using this method will ensure that the Published-state is maintained upon sorting
/// so the cache is updated accordingly - as needed.
/// </remarks>
/// <param name="items"></param>
/// <param name="userId"></param>
/// <param name="raiseEvents"></param>
/// <returns>True if sorting succeeded, otherwise False</returns>
public bool Sort(IEnumerable<IContent> items, int userId = 0, bool raiseEvents = true)
{
if (raiseEvents)
{
if (Saving.IsRaisedEventCancelled(new SaveEventArgs<IContent>(items), this))
return false;
}
var shouldBePublished = new List<IContent>();
var shouldBeSaved = new List<IContent>();
using (new WriteLock(Locker))
{
var uow = _uowProvider.GetUnitOfWork();
using (var repository = _repositoryFactory.CreateContentRepository(uow))
{
int i = 0;
foreach (var content in items)
{
//If the current sort order equals that of the content
//we don't need to update it, so just increment the sort order
//and continue.
if (content.SortOrder == i)
{
i++;
continue;
}
content.SortOrder = i;
content.WriterId = userId;
i++;
if (content.Published)
{
var published = _publishingStrategy.Publish(content, userId);
shouldBePublished.Add(content);
}
else
shouldBeSaved.Add(content);
repository.AddOrUpdate(content);
}
uow.Commit();
foreach (var content in shouldBeSaved)
{
//Create and Save PreviewXml DTO
var xml = content.ToXml();
CreateAndSavePreviewXml(xml, content.Id, content.Version, uow.Database);
}
foreach (var content in shouldBePublished)
{
//Create and Save PreviewXml DTO
var xml = content.ToXml();
CreateAndSavePreviewXml(xml, content.Id, content.Version, uow.Database);
//Create and Save ContentXml DTO
CreateAndSaveContentXml(xml, content.Id, uow.Database);
}
}
}
if (raiseEvents)
Saved.RaiseEvent(new SaveEventArgs<IContent>(items, false), this);
if(shouldBePublished.Any())
_publishingStrategy.PublishingFinalized(shouldBePublished, false);
Audit.Add(AuditTypes.Sort, "Sorting content performed by user", userId, 0);
return true;
}
#region Internal Methods
/// <summary>
@@ -1275,11 +1455,10 @@ namespace Umbraco.Core.Services
var uow = _uowProvider.GetUnitOfWork();
using (var repository = _repositoryFactory.CreateContentRepository(uow))
{
//Only loop through content that was successfully published, was not already published and where the Published property has been updated
//NOTE The Publish with subpages-dialog was used more as a republish-type-thing, so we'll have to include PublishStatusType.SuccessAlreadyPublished
//in the updated-list, so the Published event is triggered with the expected set of pages and the xml is updated.
foreach (var item in publishedOutcome.Where(
x => x.Success
&& x.Result.StatusType != PublishStatusType.SuccessAlreadyPublished
&& ((ICanBeDirty)x.Result.ContentItem).IsPropertyDirty("Published")))
x => x.Success || x.Result.StatusType == PublishStatusType.SuccessAlreadyPublished))
{
item.Result.ContentItem.WriterId = userId;
repository.AddOrUpdate(item.Result.ContentItem);
@@ -1369,24 +1548,9 @@ namespace Umbraco.Core.Services
var publishStatus = new PublishStatus(content, PublishStatusType.Success); //initially set to success
//Check if parent is published (although not if its a root node) - if parent isn't published this Content cannot be published
if (content.ParentId != -1 && content.ParentId != -20 && IsPublishable(content) == false)
{
LogHelper.Info<ContentService>(
string.Format(
"Content '{0}' with Id '{1}' could not be published because its parent is not published.",
content.Name, content.Id));
publishStatus.StatusType = PublishStatusType.FailedPathNotPublished;
}
publishStatus.StatusType = CheckAndLogIsPublishable(content);
//Content contains invalid property values and can therefore not be published - fire event?
if (content.IsValid() == false)
{
LogHelper.Info<ContentService>(
string.Format(
"Content '{0}' with Id '{1}' could not be published because of invalid properties.",
content.Name, content.Id));
publishStatus.StatusType = PublishStatusType.FailedContentInvalid;
}
publishStatus.StatusType = CheckAndLogIsValid(content);
//if we're still successful, then publish using the strategy
if (publishStatus.StatusType == PublishStatusType.Success)
@@ -1413,37 +1577,12 @@ namespace Umbraco.Core.Services
var xml = content.ToXml();
//Preview Xml
var previewPoco = new PreviewXmlDto
{
NodeId = content.Id,
Timestamp = DateTime.Now,
VersionId = content.Version,
Xml = xml.ToString(SaveOptions.None)
};
var previewExists =
uow.Database.ExecuteScalar<int>("SELECT COUNT(nodeId) FROM cmsPreviewXml WHERE nodeId = @Id AND versionId = @Version",
new { Id = content.Id, Version = content.Version }) != 0;
int previewResult = previewExists
? uow.Database.Update<PreviewXmlDto>(
"SET xml = @Xml, timestamp = @Timestamp WHERE nodeId = @Id AND versionId = @Version",
new
{
Xml = previewPoco.Xml,
Timestamp = previewPoco.Timestamp,
Id = previewPoco.NodeId,
Version = previewPoco.VersionId
})
: Convert.ToInt32(uow.Database.Insert(previewPoco));
CreateAndSavePreviewXml(xml, content.Id, content.Version, uow.Database);
if (published)
{
//Content Xml
var contentPoco = new ContentXmlDto { NodeId = content.Id, Xml = xml.ToString(SaveOptions.None) };
var contentExists = uow.Database.ExecuteScalar<int>("SELECT COUNT(nodeId) FROM cmsContentXml WHERE nodeId = @Id", new { Id = content.Id }) != 0;
int contentResult = contentExists
? uow.Database.Update(contentPoco)
: Convert.ToInt32(uow.Database.Insert(contentPoco));
CreateAndSaveContentXml(xml, content.Id, uow.Database);
}
}
@@ -1501,27 +1640,7 @@ namespace Umbraco.Core.Services
//Preview Xml
var xml = content.ToXml();
var previewPoco = new PreviewXmlDto
{
NodeId = content.Id,
Timestamp = DateTime.Now,
VersionId = content.Version,
Xml = xml.ToString(SaveOptions.None)
};
var previewExists =
uow.Database.ExecuteScalar<int>("SELECT COUNT(nodeId) FROM cmsPreviewXml WHERE nodeId = @Id AND versionId = @Version",
new { Id = content.Id, Version = content.Version }) != 0;
int previewResult = previewExists
? uow.Database.Update<PreviewXmlDto>(
"SET xml = @Xml, timestamp = @Timestamp WHERE nodeId = @Id AND versionId = @Version",
new
{
Xml = previewPoco.Xml,
Timestamp = previewPoco.Timestamp,
Id = previewPoco.NodeId,
Version = previewPoco.VersionId
})
: Convert.ToInt32(uow.Database.Insert(previewPoco));
CreateAndSavePreviewXml(xml, content.Id, content.Version, uow.Database);
}
if (raiseEvents)
@@ -1565,6 +1684,68 @@ namespace Umbraco.Core.Services
return true;
}
private PublishStatusType CheckAndLogIsPublishable(IContent content)
{
//Check if parent is published (although not if its a root node) - if parent isn't published this Content cannot be published
if (content.ParentId != -1 && content.ParentId != -20 && IsPublishable(content) == false)
{
LogHelper.Info<ContentService>(
string.Format(
"Content '{0}' with Id '{1}' could not be published because its parent is not published.",
content.Name, content.Id));
return PublishStatusType.FailedPathNotPublished;
}
return PublishStatusType.Success;
}
private PublishStatusType CheckAndLogIsValid(IContent content)
{
//Content contains invalid property values and can therefore not be published - fire event?
if (content.IsValid() == false)
{
LogHelper.Info<ContentService>(
string.Format(
"Content '{0}' with Id '{1}' could not be published because of invalid properties.",
content.Name, content.Id));
return PublishStatusType.FailedContentInvalid;
}
return PublishStatusType.Success;
}
private void CreateAndSavePreviewXml(XElement xml, int id, Guid version, UmbracoDatabase db)
{
var previewPoco = new PreviewXmlDto
{
NodeId = id,
Timestamp = DateTime.Now,
VersionId = version,
Xml = xml.ToString(SaveOptions.None)
};
var previewExists =
db.ExecuteScalar<int>("SELECT COUNT(nodeId) FROM cmsPreviewXml WHERE nodeId = @Id AND versionId = @Version",
new { Id = id, Version = version }) != 0;
int previewResult = previewExists
? db.Update<PreviewXmlDto>(
"SET xml = @Xml, timestamp = @Timestamp WHERE nodeId = @Id AND versionId = @Version",
new
{
Xml = previewPoco.Xml,
Timestamp = previewPoco.Timestamp,
Id = previewPoco.NodeId,
Version = previewPoco.VersionId
})
: Convert.ToInt32(db.Insert(previewPoco));
}
private void CreateAndSaveContentXml(XElement xml, int id, UmbracoDatabase db)
{
var contentPoco = new ContentXmlDto { NodeId = id, Xml = xml.ToString(SaveOptions.None) };
var contentExists = db.ExecuteScalar<int>("SELECT COUNT(nodeId) FROM cmsContentXml WHERE nodeId = @Id", new { Id = id }) != 0;
int contentResult = contentExists ? db.Update(contentPoco) : Convert.ToInt32(db.Insert(contentPoco));
}
private IContentType FindContentTypeByAlias(string contentTypeAlias)
{
using (var repository = _repositoryFactory.CreateContentTypeRepository(_uowProvider.GetUnitOfWork()))
@@ -1572,7 +1753,7 @@ namespace Umbraco.Core.Services
var query = Query<IContentType>.Builder.Where(x => x.Alias == contentTypeAlias);
var types = repository.GetByQuery(query);
if (!types.Any())
if (types.Any() == false)
throw new Exception(
string.Format("No ContentType matching the passed in Alias: '{0}' was found",
contentTypeAlias));
+19 -1
View File
@@ -101,7 +101,7 @@ namespace Umbraco.Core.Services
}
/// <summary>
/// Gets all values for an <see cref="IDataTypeDefinition"/>
/// Gets all prevalues for an <see cref="IDataTypeDefinition"/>
/// </summary>
/// <param name="id">Id of the <see cref="IDataTypeDefinition"/> to retrieve prevalues from</param>
/// <returns>An enumerable list of string values</returns>
@@ -115,6 +115,24 @@ namespace Umbraco.Core.Services
}
}
/// <summary>
/// Gets all prevalues for an <see cref="IDataTypeDefinition"/>
/// </summary>
/// <remarks>
/// This method should be kept internal until a proper PreValue object model is introduced.
/// </remarks>
/// <param name="id">Id of the <see cref="IDataTypeDefinition"/> to retrieve prevalues from</param>
/// <returns>An enumerable list of Tuples containing Id, Alias, SortOrder, Value</returns>
internal IEnumerable<Tuple<int, string, int, string>> GetDetailedPreValuesByDataTypeId(int id)
{
using (var uow = _uowProvider.GetUnitOfWork())
{
var dtos = uow.Database.Fetch<DataTypePreValueDto>("WHERE datatypeNodeId = @Id", new { Id = id });
var list = dtos.Select(x => new Tuple<int, string, int, string>(x.Id, x.Alias, x.SortOrder, x.Value)).ToList();
return list;
}
}
/// <summary>
/// Gets a specific PreValue by its Id
/// </summary>
+52 -3
View File
@@ -1,6 +1,5 @@
using System;
using System.Collections.Generic;
using System.Xml.Linq;
using Umbraco.Core.Models;
namespace Umbraco.Core.Services
@@ -12,8 +11,13 @@ namespace Umbraco.Core.Services
{
/// <summary>
/// Creates an <see cref="IContent"/> object using the alias of the <see cref="IContentType"/>
/// that this Content is based on.
/// that this Content should based on.
/// </summary>
/// <remarks>
/// Note that using this method will simply return a new IContent without any identity
/// as it has not yet been persisted. It is intended as a shortcut to creating new content objects
/// that does not invoke a save operation against the database.
/// </remarks>
/// <param name="name">Name of the Content object</param>
/// <param name="parentId">Id of Parent for the new Content</param>
/// <param name="contentTypeAlias">Alias of the <see cref="IContentType"/></param>
@@ -23,8 +27,13 @@ namespace Umbraco.Core.Services
/// <summary>
/// Creates an <see cref="IContent"/> object using the alias of the <see cref="IContentType"/>
/// that this Content is based on.
/// that this Content should based on.
/// </summary>
/// <remarks>
/// Note that using this method will simply return a new IContent without any identity
/// as it has not yet been persisted. It is intended as a shortcut to creating new content objects
/// that does not invoke a save operation against the database.
/// </remarks>
/// <param name="name">Name of the Content object</param>
/// <param name="parent">Parent <see cref="IContent"/> object for the new Content</param>
/// <param name="contentTypeAlias">Alias of the <see cref="IContentType"/></param>
@@ -302,6 +311,18 @@ namespace Umbraco.Core.Services
/// <param name="content"><see cref="IContent"/> to retrieve ancestors for</param>
/// <returns>An Enumerable list of <see cref="IContent"/> objects</returns>
IEnumerable<IContent> GetAncestors(IContent content);
/// Sorts a collection of <see cref="IContent"/> objects by updating the SortOrder according
/// to the ordering of items in the passed in <see cref="IEnumerable{T}"/>.
/// </summary>
/// <remarks>
/// Using this method will ensure that the Published-state is maintained upon sorting
/// so the cache is updated accordingly - as needed.
/// </remarks>
/// <param name="items"></param>
/// <param name="userId"></param>
/// <param name="raiseEvents"></param>
/// <returns>True if sorting succeeded, otherwise False</returns>
bool Sort(IEnumerable<IContent> items, int userId = 0, bool raiseEvents = true);
/// <summary>
/// Gets the parent of the current content as an <see cref="IContent"/> item.
@@ -316,5 +337,33 @@ namespace Umbraco.Core.Services
/// <param name="content"><see cref="IContent"/> to retrieve the parent from</param>
/// <returns>Parent <see cref="IContent"/> object</returns>
IContent GetParent(IContent content);
/// Creates and saves an <see cref="IContent"/> object using the alias of the <see cref="IContentType"/>
/// that this Content should based on.
/// </summary>
/// <remarks>
/// This method returns an <see cref="IContent"/> object that has been persisted to the database
/// and therefor has an identity.
/// </remarks>
/// <param name="name">Name of the Content object</param>
/// <param name="parent">Parent <see cref="IContent"/> object for the new Content</param>
/// <param name="contentTypeAlias">Alias of the <see cref="IContentType"/></param>
/// <param name="userId">Optional id of the user creating the content</param>
/// <returns><see cref="IContent"/></returns>
IContent CreateContentWithIdentity(string name, IContent parent, string contentTypeAlias, int userId = 0);
/// <summary>
/// Creates and saves an <see cref="IContent"/> object using the alias of the <see cref="IContentType"/>
/// that this Content should based on.
/// </summary>
/// <remarks>
/// This method returns an <see cref="IContent"/> object that has been persisted to the database
/// and therefor has an identity.
/// </remarks>
/// <param name="name">Name of the Content object</param>
/// <param name="parentId">Id of Parent for the new Content</param>
/// <param name="contentTypeAlias">Alias of the <see cref="IContentType"/></param>
/// <param name="userId">Optional id of the user creating the content</param>
/// <returns><see cref="IContent"/></returns>
IContent CreateContentWithIdentity(string name, int parentId, string contentTypeAlias, int userId = 0);
}
}
+53 -3
View File
@@ -11,8 +11,13 @@ namespace Umbraco.Core.Services
{
/// <summary>
/// Creates an <see cref="IMedia"/> object using the alias of the <see cref="IMediaType"/>
/// that this Media is based on.
/// that this Media should based on.
/// </summary>
/// <remarks>
/// Note that using this method will simply return a new IMedia without any identity
/// as it has not yet been persisted. It is intended as a shortcut to creating new media objects
/// that does not invoke a save operation against the database.
/// </remarks>
/// <param name="name">Name of the Media object</param>
/// <param name="parentId">Id of Parent for the new Media item</param>
/// <param name="mediaTypeAlias">Alias of the <see cref="IMediaType"/></param>
@@ -22,8 +27,13 @@ namespace Umbraco.Core.Services
/// <summary>
/// Creates an <see cref="IMedia"/> object using the alias of the <see cref="IMediaType"/>
/// that this Media is based on.
/// that this Media should based on.
/// </summary>
/// <remarks>
/// Note that using this method will simply return a new IMedia without any identity
/// as it has not yet been persisted. It is intended as a shortcut to creating new media objects
/// that does not invoke a save operation against the database.
/// </remarks>
/// <param name="name">Name of the Media object</param>
/// <param name="parent">Parent <see cref="IMedia"/> for the new Media item</param>
/// <param name="mediaTypeAlias">Alias of the <see cref="IMediaType"/></param>
@@ -184,7 +194,7 @@ namespace Umbraco.Core.Services
/// <param name="mediaPath">Path of the media item to retreive (for example: /media/1024/koala_403x328.jpg)</param>
/// <returns><see cref="IMedia"/></returns>
IMedia GetMediaByPath(string mediaPath);
/// <summary>
/// Gets a collection of <see cref="IMedia"/> objects, which are ancestors of the current media.
/// </summary>
@@ -219,5 +229,45 @@ namespace Umbraco.Core.Services
/// <param name="media"><see cref="IMedia"/> to retrieve the parent from</param>
/// <returns>Parent <see cref="IMedia"/> object</returns>
IMedia GetParent(IMedia media);
/// <summary>
/// Sorts a collection of <see cref="IMedia"/> objects by updating the SortOrder according
/// to the ordering of items in the passed in <see cref="IEnumerable{T}"/>.
/// </summary>
/// <param name="items"></param>
/// <param name="userId"></param>
/// <param name="raiseEvents"></param>
/// <returns>True if sorting succeeded, otherwise False</returns>
bool Sort(IEnumerable<IMedia> items, int userId = 0, bool raiseEvents = true);
/// <summary>
/// Creates an <see cref="IMedia"/> object using the alias of the <see cref="IMediaType"/>
/// that this Media should based on.
/// </summary>
/// <remarks>
/// This method returns an <see cref="IMedia"/> object that has been persisted to the database
/// and therefor has an identity.
/// </remarks>
/// <param name="name">Name of the Media object</param>
/// <param name="parent">Parent <see cref="IMedia"/> for the new Media item</param>
/// <param name="mediaTypeAlias">Alias of the <see cref="IMediaType"/></param>
/// <param name="userId">Optional id of the user creating the media item</param>
/// <returns><see cref="IMedia"/></returns>
IMedia CreateMediaWithIdentity(string name, IMedia parent, string mediaTypeAlias, int userId = 0);
/// <summary>
/// Creates an <see cref="IMedia"/> object using the alias of the <see cref="IMediaType"/>
/// that this Media should based on.
/// </summary>
/// <remarks>
/// This method returns an <see cref="IMedia"/> object that has been persisted to the database
/// and therefor has an identity.
/// </remarks>
/// <param name="name">Name of the Media object</param>
/// <param name="parentId">Id of Parent for the new Media item</param>
/// <param name="mediaTypeAlias">Alias of the <see cref="IMediaType"/></param>
/// <param name="userId">Optional id of the user creating the media item</param>
/// <returns><see cref="IMedia"/></returns>
IMedia CreateMediaWithIdentity(string name, int parentId, string mediaTypeAlias, int userId = 0);
}
}
@@ -0,0 +1,19 @@
namespace Umbraco.Core.Services
{
/// <summary>
/// Defines the MemberService, which is an easy access to operations involving (umbraco) members.
/// </summary>
internal interface IMemberService : IMembershipMemberService
{
}
/// <summary>
/// Defines part of the MemberService, which is specific to methods used by the membership provider.
/// </summary>
/// <remarks>
/// Idea is to have this is an isolated interface so that it can be easily 'replaced' in the membership provider impl.
/// </remarks>
internal interface IMembershipMemberService : IService
{}
}
+27 -18
View File
@@ -4,31 +4,40 @@ using Umbraco.Core.Models.Membership;
namespace Umbraco.Core.Services
{
/// <summary>
/// Defines the UserService, which is an easy access to operations involving <see cref="IProfile"/> and eventually Users and Members.
/// Defines the UserService, which is an easy access to operations involving <see cref="IProfile"/> and eventually Users.
/// </summary>
internal interface IUserService : IService
internal interface IUserService : IMembershipUserService
{
/// <summary>
/// Gets an <see cref="IProfile"/> for the current BackOffice User
/// </summary>
/// <param name="httpContext">HttpContext to fetch the user through</param>
/// <returns><see cref="IProfile"/> containing the Name and Id of the logged in BackOffice User</returns>
IProfile GetCurrentBackOfficeUser(HttpContextBase httpContext);
/// <summary>
/// Gets an <see cref="IProfile"/> for the current BackOffice User.
/// </summary>
/// <remarks>
/// Requests the current HttpContext, so this method will only work in a web context.
/// </remarks>
/// <returns><see cref="IProfile"/> containing the Name and Id of the logged in BackOffice User</returns>
IProfile GetCurrentBackOfficeUser();
/// <summary>
/// Gets an IProfile by User Id.
/// </summary>
/// <param name="id">Id of the User to retrieve</param>
/// <returns><see cref="IProfile"/></returns>
IProfile GetProfileById(int id);
/// <summary>
/// Gets an IUserType by its Alias
/// </summary>
/// <param name="alias">Alias of the UserType to retrieve</param>
/// <returns><see cref="IUserType"/></returns>
IUserType GetUserTypeByAlias(string alias);
/// <summary>
/// Gets an IUserType by its Name
/// </summary>
/// <param name="name">Name of the UserType to retrieve</param>
/// <returns><see cref="IUserType"/></returns>
IUserType GetUserTypeByName(string name);
}
/// <summary>
/// Defines part of the UserService, which is specific to methods used by the membership provider.
/// </summary>
/// <remarks>
/// Idea is to have this is an isolated interface so that it can be easily 'replaced' in the membership provider impl.
/// </remarks>
internal interface IMembershipUserService : IService
{
IMembershipUser CreateUser(string name, string login, string password, IUserType userType, string email = "");
}
}
+204 -50
View File
@@ -38,8 +38,13 @@ namespace Umbraco.Core.Services
/// <summary>
/// Creates an <see cref="IMedia"/> object using the alias of the <see cref="IMediaType"/>
/// that this Media is based on.
/// that this Media should based on.
/// </summary>
/// <remarks>
/// Note that using this method will simply return a new IMedia without any identity
/// as it has not yet been persisted. It is intended as a shortcut to creating new media objects
/// that does not invoke a save operation against the database.
/// </remarks>
/// <param name="name">Name of the Media object</param>
/// <param name="parentId">Id of Parent for the new Media item</param>
/// <param name="mediaTypeAlias">Alias of the <see cref="IMediaType"/></param>
@@ -47,25 +52,7 @@ namespace Umbraco.Core.Services
/// <returns><see cref="IMedia"/></returns>
public IMedia CreateMedia(string name, int parentId, string mediaTypeAlias, int userId = 0)
{
IMediaType mediaType;
var uow = _uowProvider.GetUnitOfWork();
using (var repository = _repositoryFactory.CreateMediaTypeRepository(uow))
{
var query = Query<IMediaType>.Builder.Where(x => x.Alias == mediaTypeAlias);
var mediaTypes = repository.GetByQuery(query);
if (!mediaTypes.Any())
throw new Exception(string.Format("No MediaType matching the passed in Alias: '{0}' was found",
mediaTypeAlias));
mediaType = mediaTypes.First();
if (mediaType == null)
throw new Exception(string.Format("MediaType matching the passed in Alias: '{0}' was null",
mediaTypeAlias));
}
var mediaType = FindMediaTypeByAlias(mediaTypeAlias);
var media = new Models.Media(name, parentId, mediaType);
if (Creating.IsRaisedEventCancelled(new NewEventArgs<IMedia>(media, mediaTypeAlias, parentId), this))
@@ -85,8 +72,13 @@ namespace Umbraco.Core.Services
/// <summary>
/// Creates an <see cref="IMedia"/> object using the alias of the <see cref="IMediaType"/>
/// that this Media is based on.
/// that this Media should based on.
/// </summary>
/// <remarks>
/// Note that using this method will simply return a new IMedia without any identity
/// as it has not yet been persisted. It is intended as a shortcut to creating new media objects
/// that does not invoke a save operation against the database.
/// </remarks>
/// <param name="name">Name of the Media object</param>
/// <param name="parent">Parent <see cref="IMedia"/> for the new Media item</param>
/// <param name="mediaTypeAlias">Alias of the <see cref="IMediaType"/></param>
@@ -94,25 +86,7 @@ namespace Umbraco.Core.Services
/// <returns><see cref="IMedia"/></returns>
public IMedia CreateMedia(string name, IMedia parent, string mediaTypeAlias, int userId = 0)
{
IMediaType mediaType;
var uow = _uowProvider.GetUnitOfWork();
using (var repository = _repositoryFactory.CreateMediaTypeRepository(uow))
{
var query = Query<IMediaType>.Builder.Where(x => x.Alias == mediaTypeAlias);
var mediaTypes = repository.GetByQuery(query);
if (!mediaTypes.Any())
throw new Exception(string.Format("No MediaType matching the passed in Alias: '{0}' was found",
mediaTypeAlias));
mediaType = mediaTypes.First();
if (mediaType == null)
throw new Exception(string.Format("MediaType matching the passed in Alias: '{0}' was null",
mediaTypeAlias));
}
var mediaType = FindMediaTypeByAlias(mediaTypeAlias);
var media = new Models.Media(name, parent, mediaType);
if (Creating.IsRaisedEventCancelled(new NewEventArgs<IMedia>(media, mediaTypeAlias, parent), this))
{
@@ -129,6 +103,94 @@ namespace Umbraco.Core.Services
return media;
}
/// <summary>
/// Creates an <see cref="IMedia"/> object using the alias of the <see cref="IMediaType"/>
/// that this Media should based on.
/// </summary>
/// <remarks>
/// This method returns an <see cref="IMedia"/> object that has been persisted to the database
/// and therefor has an identity.
/// </remarks>
/// <param name="name">Name of the Media object</param>
/// <param name="parentId">Id of Parent for the new Media item</param>
/// <param name="mediaTypeAlias">Alias of the <see cref="IMediaType"/></param>
/// <param name="userId">Optional id of the user creating the media item</param>
/// <returns><see cref="IMedia"/></returns>
public IMedia CreateMediaWithIdentity(string name, int parentId, string mediaTypeAlias, int userId = 0)
{
var mediaType = FindMediaTypeByAlias(mediaTypeAlias);
var media = new Models.Media(name, parentId, mediaType);
if (Creating.IsRaisedEventCancelled(new NewEventArgs<IMedia>(media, mediaTypeAlias, parentId), this))
{
media.WasCancelled = true;
return media;
}
using (new WriteLock(Locker))
{
var uow = _uowProvider.GetUnitOfWork();
using (var repository = _repositoryFactory.CreateMediaRepository(uow))
{
media.CreatorId = userId;
repository.AddOrUpdate(media);
uow.Commit();
var xml = media.ToXml();
CreateAndSaveMediaXml(xml, media.Id, uow.Database);
}
}
Created.RaiseEvent(new NewEventArgs<IMedia>(media, false, mediaTypeAlias, parentId), this);
Audit.Add(AuditTypes.New, "", media.CreatorId, media.Id);
return media;
}
/// <summary>
/// Creates an <see cref="IMedia"/> object using the alias of the <see cref="IMediaType"/>
/// that this Media should based on.
/// </summary>
/// <remarks>
/// This method returns an <see cref="IMedia"/> object that has been persisted to the database
/// and therefor has an identity.
/// </remarks>
/// <param name="name">Name of the Media object</param>
/// <param name="parent">Parent <see cref="IMedia"/> for the new Media item</param>
/// <param name="mediaTypeAlias">Alias of the <see cref="IMediaType"/></param>
/// <param name="userId">Optional id of the user creating the media item</param>
/// <returns><see cref="IMedia"/></returns>
public IMedia CreateMediaWithIdentity(string name, IMedia parent, string mediaTypeAlias, int userId = 0)
{
var mediaType = FindMediaTypeByAlias(mediaTypeAlias);
var media = new Models.Media(name, parent, mediaType);
if (Creating.IsRaisedEventCancelled(new NewEventArgs<IMedia>(media, mediaTypeAlias, parent), this))
{
media.WasCancelled = true;
return media;
}
using (new WriteLock(Locker))
{
var uow = _uowProvider.GetUnitOfWork();
using (var repository = _repositoryFactory.CreateMediaRepository(uow))
{
media.CreatorId = userId;
repository.AddOrUpdate(media);
uow.Commit();
var xml = media.ToXml();
CreateAndSaveMediaXml(xml, media.Id, uow.Database);
}
}
Created.RaiseEvent(new NewEventArgs<IMedia>(media, false, mediaTypeAlias, parent), this);
Audit.Add(AuditTypes.New, "", media.CreatorId, media.Id);
return media;
}
/// <summary>
/// Gets an <see cref="IMedia"/> object by Id
/// </summary>
@@ -651,18 +713,14 @@ namespace Umbraco.Core.Services
uow.Commit();
var xml = media.ToXml();
var poco = new ContentXmlDto {NodeId = media.Id, Xml = xml.ToString(SaveOptions.None)};
var exists = uow.Database.FirstOrDefault<ContentXmlDto>("WHERE nodeId = @Id", new {Id = media.Id}) != null;
int result = exists
? uow.Database.Update(poco)
: Convert.ToInt32(uow.Database.Insert(poco));
CreateAndSaveMediaXml(xml, media.Id, uow.Database);
}
if (raiseEvents)
Saved.RaiseEvent(new SaveEventArgs<IMedia>(media, false), this);
Audit.Add(AuditTypes.Save, "Save Media performed by user", media.CreatorId, media.Id);
}
if (raiseEvents)
Saved.RaiseEvent(new SaveEventArgs<IMedia>(media, false), this);
Audit.Add(AuditTypes.Save, "Save Media performed by user", userId, media.Id);
}
/// <summary>
@@ -679,6 +737,7 @@ namespace Umbraco.Core.Services
return;
}
var mediaXml = new Dictionary<int, Lazy<XElement>>();
var uow = _uowProvider.GetUnitOfWork();
using (var repository = _repositoryFactory.CreateMediaRepository(uow))
{
@@ -690,6 +749,11 @@ namespace Umbraco.Core.Services
//commit the whole lot in one go
uow.Commit();
foreach (var media in medias)
{
CreateAndSaveMediaXml(media.ToXml(), media.Id, uow.Database);
}
}
if(raiseEvents)
@@ -698,6 +762,67 @@ namespace Umbraco.Core.Services
Audit.Add(AuditTypes.Save, "Save Media items performed by user", userId, -1);
}
/// <summary>
/// Sorts a collection of <see cref="IMedia"/> objects by updating the SortOrder according
/// to the ordering of items in the passed in <see cref="IEnumerable{T}"/>.
/// </summary>
/// <param name="items"></param>
/// <param name="userId"></param>
/// <param name="raiseEvents"></param>
/// <returns>True if sorting succeeded, otherwise False</returns>
public bool Sort(IEnumerable<IMedia> items, int userId = 0, bool raiseEvents = true)
{
if (raiseEvents)
{
if (Saving.IsRaisedEventCancelled(new SaveEventArgs<IMedia>(items), this))
return false;
}
var shouldBeCached = new List<IMedia>();
using (new WriteLock(Locker))
{
var uow = _uowProvider.GetUnitOfWork();
using (var repository = _repositoryFactory.CreateMediaRepository(uow))
{
int i = 0;
foreach (var media in items)
{
//If the current sort order equals that of the media
//we don't need to update it, so just increment the sort order
//and continue.
if (media.SortOrder == i)
{
i++;
continue;
}
media.SortOrder = i;
i++;
repository.AddOrUpdate(media);
shouldBeCached.Add(media);
}
uow.Commit();
foreach (var content in shouldBeCached)
{
//Create and Save ContentXml DTO
var xml = content.ToXml();
CreateAndSaveMediaXml(xml, content.Id, uow.Database);
}
}
}
if (raiseEvents)
Saved.RaiseEvent(new SaveEventArgs<IMedia>(items, false), this);
Audit.Add(AuditTypes.Sort, "Sorting Media performed by user", userId, 0);
return true;
}
/// <summary>
/// Rebuilds all xml content in the cmsContentXml table for all media
/// </summary>
@@ -790,6 +915,35 @@ namespace Umbraco.Core.Services
return list;
}
private void CreateAndSaveMediaXml(XElement xml, int id, UmbracoDatabase db)
{
var poco = new ContentXmlDto { NodeId = id, Xml = xml.ToString(SaveOptions.None) };
var exists = db.FirstOrDefault<ContentXmlDto>("WHERE nodeId = @Id", new { Id = id }) != null;
int result = exists ? db.Update(poco) : Convert.ToInt32(db.Insert(poco));
}
private IMediaType FindMediaTypeByAlias(string mediaTypeAlias)
{
var uow = _uowProvider.GetUnitOfWork();
using (var repository = _repositoryFactory.CreateMediaTypeRepository(uow))
{
var query = Query<IMediaType>.Builder.Where(x => x.Alias == mediaTypeAlias);
var mediaTypes = repository.GetByQuery(query);
if (mediaTypes.Any() == false)
throw new Exception(string.Format("No MediaType matching the passed in Alias: '{0}' was found",
mediaTypeAlias));
var mediaType = mediaTypes.First();
if (mediaType == null)
throw new Exception(string.Format("MediaType matching the passed in Alias: '{0}' was null",
mediaTypeAlias));
return mediaType;
}
}
#region Event Handlers
/// <summary>
@@ -0,0 +1,30 @@
using Umbraco.Core.Persistence;
using Umbraco.Core.Persistence.UnitOfWork;
namespace Umbraco.Core.Services
{
/// <summary>
/// Represents the MemberService.
/// </summary>
internal class MemberService : IMemberService
{
private readonly RepositoryFactory _repositoryFactory;
private readonly IDatabaseUnitOfWorkProvider _uowProvider;
public MemberService(RepositoryFactory repositoryFactory)
: this(new PetaPocoUnitOfWorkProvider(), repositoryFactory)
{
}
public MemberService(IDatabaseUnitOfWorkProvider provider)
: this(provider, new RepositoryFactory())
{
}
public MemberService(IDatabaseUnitOfWorkProvider provider, RepositoryFactory repositoryFactory)
{
_repositoryFactory = repositoryFactory;
_uowProvider = provider;
}
}
}
+336 -7
View File
@@ -1,15 +1,18 @@
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text.RegularExpressions;
using System.Threading;
using System.Xml.Linq;
using Umbraco.Core.Configuration;
using Umbraco.Core.IO;
using Umbraco.Core.Logging;
using Umbraco.Core.Models;
using Umbraco.Core.Persistence;
using Umbraco.Core.Persistence.Querying;
using Umbraco.Core.Persistence.UnitOfWork;
using Umbraco.Core.Strings;
namespace Umbraco.Core.Services
{
@@ -45,8 +48,131 @@ namespace Umbraco.Core.Services
_importedContentTypes = new Dictionary<string, IContentType>();
}
#region Generic export methods
internal void ExportToFile(string absoluteFilePath, string nodeType, int id)
{
XElement xml = null;
if (nodeType.Equals("content", StringComparison.InvariantCultureIgnoreCase))
{
var content = _contentService.GetById(id);
xml = Export(content);
}
if (nodeType.Equals("media", StringComparison.InvariantCultureIgnoreCase))
{
var media = _mediaService.GetById(id);
xml = Export(media);
}
if (nodeType.Equals("contenttype", StringComparison.InvariantCultureIgnoreCase))
{
var contentType = _contentTypeService.GetContentType(id);
xml = Export(contentType);
}
if (nodeType.Equals("mediatype", StringComparison.InvariantCultureIgnoreCase))
{
var mediaType = _contentTypeService.GetMediaType(id);
xml = Export(mediaType);
}
if (nodeType.Equals("datatype", StringComparison.InvariantCultureIgnoreCase))
{
var dataType = _dataTypeService.GetDataTypeDefinitionById(id);
xml = Export(dataType);
}
if(xml != null)
xml.Save(absoluteFilePath);
}
#endregion
#region Content
/// <summary>
/// Exports an <see cref="IContent"/> item to xml as an <see cref="XElement"/>
/// </summary>
/// <param name="content">Content to export</param>
/// <param name="deep">Optional parameter indicating whether to include descendents</param>
/// <returns><see cref="XElement"/> containing the xml representation of the Content object</returns>
internal XElement Export(IContent content, bool deep = false)
{
//nodeName should match Casing.SafeAliasWithForcingCheck(content.ContentType.Alias);
var nodeName = UmbracoSettings.UseLegacyXmlSchema ? "node" : content.ContentType.Alias.ToSafeAliasWithForcingCheck();
var xml = Export(content, nodeName);
xml.Add(new XAttribute("nodeType", content.ContentType.Id));
xml.Add(new XAttribute("creatorName", content.GetCreatorProfile().Name));
xml.Add(new XAttribute("writerName", content.GetWriterProfile().Name));
xml.Add(new XAttribute("writerID", content.WriterId));
xml.Add(new XAttribute("template", content.Template == null ? "0" : content.Template.Id.ToString(CultureInfo.InvariantCulture)));
xml.Add(new XAttribute("nodeTypeAlias", content.ContentType.Alias));
if (deep)
{
var descendants = content.Descendants().ToArray();
var currentChildren = descendants.Where(x => x.ParentId == content.Id);
AddChildXml(descendants, currentChildren, xml);
}
return xml;
}
/// <summary>
/// Part of the export of IContent and IMedia which is shared
/// </summary>
/// <param name="contentBase">Base Content or Media to export</param>
/// <param name="nodeName">Name of the node</param>
/// <returns><see cref="XElement"/></returns>
private XElement Export(IContentBase contentBase, string nodeName)
{
//NOTE: that one will take care of umbracoUrlName
var url = contentBase.GetUrlSegment();
var xml = new XElement(nodeName,
new XAttribute("id", contentBase.Id),
new XAttribute("parentID", contentBase.Level > 1 ? contentBase.ParentId : -1),
new XAttribute("level", contentBase.Level),
new XAttribute("creatorID", contentBase.CreatorId),
new XAttribute("sortOrder", contentBase.SortOrder),
new XAttribute("createDate", contentBase.CreateDate.ToString("s")),
new XAttribute("updateDate", contentBase.UpdateDate.ToString("s")),
new XAttribute("nodeName", contentBase.Name),
new XAttribute("urlName", url),
new XAttribute("path", contentBase.Path),
new XAttribute("isDoc", ""));
foreach (var property in contentBase.Properties.Where(p => p != null))
xml.Add(property.ToXml());
return xml;
}
/// <summary>
/// Used by Content Export to recursively add children
/// </summary>
/// <param name="originalDescendants"></param>
/// <param name="currentChildren"></param>
/// <param name="currentXml"></param>
private void AddChildXml(IContent[] originalDescendants, IEnumerable<IContent> currentChildren, XElement currentXml)
{
foreach (var child in currentChildren)
{
//add the child's xml
var childXml = Export(child);
currentXml.Add(childXml);
//copy local (out of closure)
var c = child;
//get this item's children
var children = originalDescendants.Where(x => x.ParentId == c.Id);
//recurse and add it's children to the child xml element
AddChildXml(originalDescendants, children, childXml);
}
}
/// <summary>
/// Imports and saves package xml as <see cref="IContent"/>
/// </summary>
@@ -183,15 +309,80 @@ namespace Umbraco.Core.Services
return content;
}
internal XElement Export(IContent content, bool deep = false)
{
throw new NotImplementedException();
}
#endregion
#region ContentTypes
/// <summary>
/// Exports an <see cref="IContentType"/> to xml as an <see cref="XElement"/>
/// </summary>
/// <param name="contentType">ContentType to export</param>
/// <returns><see cref="XElement"/> containing the xml representation of the ContentType item.</returns>
public XElement Export(IContentType contentType)
{
var info = new XElement("Info",
new XElement("Name", contentType.Name),
new XElement("Alias", contentType.Alias),
new XElement("Icon", contentType.Icon),
new XElement("Thumbnail", contentType.Thumbnail),
new XElement("Description", contentType.Description),
new XElement("AllowAtRoot", contentType.AllowedAsRoot.ToString()));
var masterContentType = contentType.CompositionAliases().FirstOrDefault();
if(masterContentType != null)
info.Add(new XElement("Master", masterContentType));
var allowedTemplates = new XElement("AllowedTemplates");
foreach (var template in contentType.AllowedTemplates)
{
allowedTemplates.Add(new XElement("Template", template.Alias));
}
info.Add(allowedTemplates);
if(contentType.DefaultTemplate != null && contentType.DefaultTemplate.Id != 0)
info.Add(new XElement("DefaultTemplate", contentType.DefaultTemplate.Alias));
else
info.Add(new XElement("DefaultTemplate", ""));
var structure = new XElement("Structure");
foreach (var allowedType in contentType.AllowedContentTypes)
{
structure.Add(new XElement("DocumentType", allowedType.Alias));
}
var genericProperties = new XElement("GenericProperties");
foreach (var propertyType in contentType.PropertyTypes)
{
var definition = _dataTypeService.GetDataTypeDefinitionById(propertyType.DataTypeDefinitionId);
var propertyGroup = contentType.PropertyGroups.FirstOrDefault(x => x.Id == propertyType.PropertyGroupId.Value);
var genericProperty = new XElement("GenericProperty",
new XElement("Name", propertyType.Name),
new XElement("Alias", propertyType.Alias),
new XElement("Type", propertyType.DataTypeId.ToString()),
new XElement("Definition", definition.Key),
new XElement("Tab", propertyGroup == null ? "" : propertyGroup.Name),
new XElement("Mandatory", propertyType.Mandatory.ToString()),
new XElement("Validation", propertyType.ValidationRegExp),
new XElement("Description", new XCData(propertyType.Description)));
genericProperties.Add(genericProperty);
}
var tabs = new XElement("Tabs");
foreach (var propertyGroup in contentType.PropertyGroups)
{
var tab = new XElement("Tab",
new XElement("Id", propertyGroup.Id.ToString(CultureInfo.InvariantCulture)),
new XElement("Caption", propertyGroup.Name));
tabs.Add(tab);
}
var xml = new XElement("DocumentType",
info,
structure,
genericProperties,
tabs);
return xml;
}
/// <summary>
/// Imports and saves package xml as <see cref="IContentType"/>
/// </summary>
@@ -321,9 +512,10 @@ namespace Umbraco.Core.Services
foreach (var templateElement in allowedTemplatesElement.Elements("Template"))
{
var alias = templateElement.Value;
var template = _fileService.GetTemplate(alias);
var template = _fileService.GetTemplate(alias.ToSafeAlias());
if (template != null)
{
if(allowedTemplates.Any(x => x.Id == template.Id)) continue;
allowedTemplates.Add(template);
}
else
@@ -340,7 +532,7 @@ namespace Umbraco.Core.Services
if (string.IsNullOrEmpty(defaultTemplateElement.Value) == false)
{
var defaultTemplate = _fileService.GetTemplate(defaultTemplateElement.Value);
var defaultTemplate = _fileService.GetTemplate(defaultTemplateElement.Value.ToSafeAlias());
if (defaultTemplate != null)
{
contentType.SetDefaultTemplate(defaultTemplate);
@@ -482,6 +674,30 @@ namespace Umbraco.Core.Services
#region DataTypes
internal XElement Export(IDataTypeDefinition dataTypeDefinition)
{
var prevalues = new XElement("PreValues");
var prevalueList = ((DataTypeService)_dataTypeService).GetDetailedPreValuesByDataTypeId(dataTypeDefinition.Id);
foreach (var tuple in prevalueList)
{
var prevalue = new XElement("PreValue");
prevalue.Add(new XAttribute("Id", tuple.Item1));
prevalue.Add(new XAttribute("Value", tuple.Item4));
prevalue.Add(new XAttribute("Alias", tuple.Item2));
prevalue.Add(new XAttribute("SortOrder", tuple.Item3));
prevalues.Add(prevalue);
}
var xml = new XElement("DataType", prevalues);
xml.Add(new XAttribute("Name", dataTypeDefinition.Name));
xml.Add(new XAttribute("Id", dataTypeDefinition.Id));
xml.Add(new XAttribute("Definition", dataTypeDefinition.Key));
xml.Add(new XAttribute("DatabaseType", dataTypeDefinition.DatabaseType.ToString()));
return xml;
}
/// <summary>
/// Imports and saves package xml as <see cref="IDataTypeDefinition"/>
/// </summary>
@@ -549,6 +765,7 @@ namespace Umbraco.Core.Services
_dataTypeService.SavePreValues(dataTypeDefinition.Id, values);
}
}
#endregion
#region Dictionary Items
@@ -564,9 +781,121 @@ namespace Umbraco.Core.Services
#endregion
#region Media
/// <summary>
/// Exports an <see cref="IMedia"/> item to xml as an <see cref="XElement"/>
/// </summary>
/// <param name="media">Media to export</param>
/// <param name="deep">Optional parameter indicating whether to include descendents</param>
/// <returns><see cref="XElement"/> containing the xml representation of the Media object</returns>
internal XElement Export(IMedia media, bool deep = false)
{
//nodeName should match Casing.SafeAliasWithForcingCheck(content.ContentType.Alias);
var nodeName = UmbracoSettings.UseLegacyXmlSchema ? "node" : media.ContentType.Alias.ToSafeAliasWithForcingCheck();
var xml = Export(media, nodeName);
xml.Add(new XAttribute("nodeType", media.ContentType.Id));
xml.Add(new XAttribute("writerName", media.GetCreatorProfile().Name));
xml.Add(new XAttribute("writerID", media.CreatorId));
xml.Add(new XAttribute("version", media.Version));
xml.Add(new XAttribute("template", 0));
xml.Add(new XAttribute("nodeTypeAlias", media.ContentType.Alias));
if (deep)
{
var descendants = media.Descendants().ToArray();
var currentChildren = descendants.Where(x => x.ParentId == media.Id);
AddChildXml(descendants, currentChildren, xml);
}
return xml;
}
/// <summary>
/// Used by Media Export to recursively add children
/// </summary>
/// <param name="originalDescendants"></param>
/// <param name="currentChildren"></param>
/// <param name="currentXml"></param>
private void AddChildXml(IMedia[] originalDescendants, IEnumerable<IMedia> currentChildren, XElement currentXml)
{
foreach (var child in currentChildren)
{
//add the child's xml
var childXml = Export(child);
currentXml.Add(childXml);
//copy local (out of closure)
var c = child;
//get this item's children
var children = originalDescendants.Where(x => x.ParentId == c.Id);
//recurse and add it's children to the child xml element
AddChildXml(originalDescendants, children, childXml);
}
}
#endregion
#region MediaTypes
/// <summary>
/// Exports an <see cref="IMediaType"/> to xml as an <see cref="XElement"/>
/// </summary>
/// <param name="mediaType">MediaType to export</param>
/// <returns><see cref="XElement"/> containing the xml representation of the MediaType item.</returns>
internal XElement Export(IMediaType mediaType)
{
var info = new XElement("Info",
new XElement("Name", mediaType.Name),
new XElement("Alias", mediaType.Alias),
new XElement("Icon", mediaType.Icon),
new XElement("Thumbnail", mediaType.Thumbnail),
new XElement("Description", mediaType.Description),
new XElement("AllowAtRoot", mediaType.AllowedAsRoot.ToString()));
var masterContentType = mediaType.CompositionAliases().FirstOrDefault();
if (masterContentType != null)
info.Add(new XElement("Master", masterContentType));
var structure = new XElement("Structure");
foreach (var allowedType in mediaType.AllowedContentTypes)
{
structure.Add(new XElement("MediaType", allowedType.Alias));
}
var genericProperties = new XElement("GenericProperties");
foreach (var propertyType in mediaType.PropertyTypes)
{
var definition = _dataTypeService.GetDataTypeDefinitionById(propertyType.DataTypeDefinitionId);
var propertyGroup = mediaType.PropertyGroups.FirstOrDefault(x => x.Id == propertyType.PropertyGroupId.Value);
var genericProperty = new XElement("GenericProperty",
new XElement("Name", propertyType.Name),
new XElement("Alias", propertyType.Alias),
new XElement("Type", propertyType.DataTypeId.ToString()),
new XElement("Definition", definition.Key),
new XElement("Tab", propertyGroup == null ? "" : propertyGroup.Name),
new XElement("Mandatory", propertyType.Mandatory.ToString()),
new XElement("Validation", propertyType.ValidationRegExp),
new XElement("Description", new XCData(propertyType.Description)));
genericProperties.Add(genericProperty);
}
var tabs = new XElement("Tabs");
foreach (var propertyGroup in mediaType.PropertyGroups)
{
var tab = new XElement("Tab",
new XElement("Id", propertyGroup.Id.ToString(CultureInfo.InvariantCulture)),
new XElement("Caption", propertyGroup.Name));
tabs.Add(tab);
}
var xml = new XElement("MediaType",
info,
structure,
genericProperties,
tabs);
return xml;
}
#endregion
#region Package Manifest
@@ -140,6 +140,21 @@ namespace Umbraco.Core.Services
return repository.GetByQuery(query);
}
}
/// <summary>
/// Gets a list of <see cref="Relation"/> objects by their child or parent Id.
/// Using this method will get you all relations regards of it being a child or parent relation.
/// </summary>
/// <param name="id">Id of the child or parent to retrieve relations for</param>
/// <returns>An enumerable list of <see cref="Relation"/> objects</returns>
public IEnumerable<Relation> GetByParentOrChildId(int id)
{
using (var repository = _repositoryFactory.CreateRelationRepository(_uowProvider.GetUnitOfWork()))
{
var query = new Query<Relation>().Where(x => x.ChildId == id || x.ParentId == id);
return repository.GetByQuery(query);
}
}
/// <summary>
/// Gets a list of <see cref="Relation"/> objects by the Name of the <see cref="RelationType"/>
+13 -1
View File
@@ -14,6 +14,7 @@ namespace Umbraco.Core.Services
{
private Lazy<ContentService> _contentService;
private Lazy<UserService> _userService;
private Lazy<MemberService> _memberService;
private Lazy<MediaService> _mediaService;
private Lazy<ContentTypeService> _contentTypeService;
private Lazy<DataTypeService> _dataTypeService;
@@ -56,6 +57,9 @@ namespace Umbraco.Core.Services
if (_userService == null)
_userService = new Lazy<UserService>(() => new UserService(provider, repositoryFactory.Value));
if (_memberService == null)
_memberService = new Lazy<MemberService>(() => new MemberService(provider, repositoryFactory.Value));
if (_contentService == null)
_contentService = new Lazy<ContentService>(() => new ContentService(provider, repositoryFactory.Value, publishingStrategy));
@@ -165,11 +169,19 @@ namespace Umbraco.Core.Services
}
/// <summary>
/// Gets the <see cref="IMacroService"/>
/// Gets the <see cref="UserService"/>
/// </summary>
internal IUserService UserService
{
get { return _userService.Value; }
}
/// <summary>
/// Gets the <see cref="MemberService"/>
/// </summary>
internal IMemberService MemberService
{
get { return _memberService.Value; }
}
}
}
+75 -65
View File
@@ -1,13 +1,16 @@
using System;
using System.Web;
using System.Globalization;
using System.Linq;
using Umbraco.Core.Models.Membership;
using Umbraco.Core.Models.Rdbms;
using Umbraco.Core.Persistence;
using Umbraco.Core.Persistence.Querying;
using Umbraco.Core.Persistence.UnitOfWork;
namespace Umbraco.Core.Services
{
/// <summary>
/// Represents the UserService, which is an easy access to operations involving <see cref="IProfile"/> and eventually Users and Members.
/// Represents the UserService, which is an easy access to operations involving <see cref="IProfile"/>, <see cref="IMembershipUser"/> and eventually Backoffice Users.
/// </summary>
internal class UserService : IUserService
{
@@ -28,69 +31,6 @@ namespace Umbraco.Core.Services
#region Implementation of IUserService
/// <summary>
/// Gets an <see cref="IProfile"/> for the current BackOffice User.
/// </summary>
/// <param name="httpContext">HttpContext to fetch the user through</param>
/// <returns><see cref="IProfile"/> containing the Name and Id of the logged in BackOffice User</returns>
public IProfile GetCurrentBackOfficeUser(HttpContextBase httpContext)
{
Mandate.That(httpContext != null,
() =>
new ArgumentException(
"The HttpContext which is used to retrieve information about the currently logged in backoffice user was null and can therefor not be used",
"HttpContextBase"));
if (httpContext == null) return null;
var cookie = httpContext.Request.Cookies["UMB_UCONTEXT"];
Mandate.That(cookie != null, () => new ArgumentException("The Cookie containing the UserContext Guid Id was null", "Cookie"));
if (cookie == null) return null;
string contextId = cookie.Value;
string cacheKey = string.Concat("UmbracoUserContext", contextId);
int userId = 0;
if(HttpRuntime.Cache[cacheKey] == null)
{
using (var uow = _uowProvider.GetUnitOfWork())
{
userId =
uow.Database.ExecuteScalar<int>(
"select userID from umbracoUserLogins where contextID = @ContextId",
new { ContextId = new Guid(contextId) });
HttpRuntime.Cache.Insert(cacheKey, userId,
null,
System.Web.Caching.Cache.NoAbsoluteExpiration,
new TimeSpan(0, (int)(Umbraco.Core.Configuration.GlobalSettings.TimeOutInMinutes / 10), 0));
}
}
else
{
userId = (int) HttpRuntime.Cache[cacheKey];
}
var profile = GetProfileById(userId);
return profile;
}
/// <summary>
/// Gets an <see cref="IProfile"/> for the current BackOffice User.
/// </summary>
/// <remarks>
/// Requests the current HttpContext, so this method will only work in a web context.
/// </remarks>
/// <returns><see cref="IProfile"/> containing the Name and Id of the logged in BackOffice User</returns>
public IProfile GetCurrentBackOfficeUser()
{
var context = HttpContext.Current;
Mandate.That<Exception>(context != null);
var wrapper = new HttpContextWrapper(context);
return GetCurrentBackOfficeUser(wrapper);
}
/// <summary>
/// Gets an IProfile by User Id.
/// </summary>
@@ -104,6 +44,76 @@ namespace Umbraco.Core.Services
}
}
/// <summary>
/// Gets an IUserType by its Alias
/// </summary>
/// <param name="alias">Alias of the UserType to retrieve</param>
/// <returns><see cref="IUserType"/></returns>
public IUserType GetUserTypeByAlias(string alias)
{
using (var repository = _repositoryFactory.CreateUserTypeRepository(_uowProvider.GetUnitOfWork()))
{
var query = Query<IUserType>.Builder.Where(x => x.Alias == alias);
var contents = repository.GetByQuery(query);
return contents.SingleOrDefault();
}
}
/// <summary>
/// Gets an IUserType by its Name
/// </summary>
/// <param name="name">Name of the UserType to retrieve</param>
/// <returns><see cref="IUserType"/></returns>
public IUserType GetUserTypeByName(string name)
{
using (var repository = _repositoryFactory.CreateUserTypeRepository(_uowProvider.GetUnitOfWork()))
{
var query = Query<IUserType>.Builder.Where(x => x.Name == name);
var contents = repository.GetByQuery(query);
return contents.SingleOrDefault();
}
}
/// <summary>
/// Creates a new user for logging into the umbraco backoffice
/// </summary>
/// <param name="name"></param>
/// <param name="login"></param>
/// <param name="password"></param>
/// <param name="userType"></param>
/// <param name="email"></param>
/// <returns></returns>
public IMembershipUser CreateUser(string name, string login, string password, IUserType userType, string email = "")
{
var uow = _uowProvider.GetUnitOfWork();
using (var repository = _repositoryFactory.CreateUserRepository(uow))
{
var loginExists = uow.Database.ExecuteScalar<int>("SELECT COUNT(id) FROM umbracoUser WHERE userLogin = @Login", new { Login = login }) != 0;
if (loginExists)
throw new ArgumentException("Login already exists");
var user = new User(userType)
{
DefaultToLiveEditing = false,
Email = email,
Language = Umbraco.Core.Configuration.GlobalSettings.DefaultUILanguage,
Name = name,
Password = password,
Permissions = userType.Permissions,
Username = login,
StartContentId = -1,
StartMediaId = -1,
NoConsole = false,
IsApproved = true
};
repository.AddOrUpdate(user);
uow.Commit();
return user;
}
}
#endregion
}
}
@@ -0,0 +1,70 @@
using System;
using System.Diagnostics;
using Umbraco.Core.Persistence;
using Umbraco.Core.Persistence.Mappers;
using Umbraco.Core.Persistence.UnitOfWork;
using Umbraco.Core.Publishing;
using Umbraco.Core.Services;
namespace Umbraco.Core.Standalone
{
internal class ServiceContextManager : IDisposable
{
private readonly string _connectionString;
private readonly string _providerName;
private ServiceContext _serviceContext;
private readonly StandaloneCoreApplication _application;
public ServiceContextManager(string connectionString, string providerName, string baseDirectory)
{
_connectionString = connectionString;
_providerName = providerName;
Trace.WriteLine("ServiceContextManager-Current AppDomain: " + AppDomain.CurrentDomain.FriendlyName);
Trace.WriteLine("ServiceContextManager-Current AppDomain: " + AppDomain.CurrentDomain.BaseDirectory);
//var webAssembly = AppDomain.CurrentDomain.GetAssemblies().FirstOrDefault(x => x.FullName.StartsWith("umbraco"));
//if (webAssembly != null && examineEventHandlerToRemove == null)
//{
// var examineEventType = webAssembly.GetType("Umbraco.Web.Search.ExamineEvents");
// examineEventHandlerToRemove = examineEventType;
//}
_application = StandaloneCoreApplication.GetApplication(baseDirectory);
var examineEventHandlerToRemove = Type.GetType("Umbraco.Web.Search.ExamineEvents, umbraco");
if (examineEventHandlerToRemove != null)
_application.WithoutApplicationEventHandler(examineEventHandlerToRemove);
_application.Start();
}
public ServiceContext Services
{
get
{
if (_serviceContext == null)
{
var dbFactory = new DefaultDatabaseFactory(_connectionString, _providerName);
var dbContext = new DatabaseContext(dbFactory);
Database.Mapper = new PetaPocoMapper();
_serviceContext = new ServiceContext(
new PetaPocoUnitOfWorkProvider(dbFactory),
new FileUnitOfWorkProvider(),
new PublishingStrategy());
//initialize the DatabaseContext
dbContext.Initialize(_providerName);
}
return _serviceContext;
}
}
public void Dispose()
{
((IDisposable)ApplicationContext.Current).Dispose();
_application.Dispose();
}
}
}
@@ -0,0 +1,122 @@
using System;
using System.Collections.Generic;
namespace Umbraco.Core.Standalone
{
internal class StandaloneCoreApplication : UmbracoApplicationBase
{
/// <summary>
/// Initializes a new instance of the <see cref="StandaloneCoreApplication"/> class.
/// </summary>
protected StandaloneCoreApplication(string baseDirectory)
{
_baseDirectory = baseDirectory;
}
/// <summary>
/// Provides the application boot manager.
/// </summary>
/// <returns>An application boot manager.</returns>
protected override IBootManager GetBootManager()
{
return new StandaloneCoreBootManager(this, _handlersToAdd, _handlersToRemove, _baseDirectory);
}
#region Application
private readonly string _baseDirectory;
private static StandaloneCoreApplication _application;
private static bool _started;
private static readonly object AppLock = new object();
/// <summary>
/// Gets the instance of the standalone Umbraco application.
/// </summary>
public static StandaloneCoreApplication GetApplication(string baseDirectory)
{
lock (AppLock)
{
return _application ?? (_application = new StandaloneCoreApplication(baseDirectory));
}
}
/// <summary>
/// Starts the application.
/// </summary>
public void Start()
{
lock (AppLock)
{
if (_started)
throw new InvalidOperationException("Application has already started.");
Application_Start(this, EventArgs.Empty);
_started = true;
}
}
#endregion
#region IApplicationEventHandler management
private readonly List<Type> _handlersToAdd = new List<Type>();
private readonly List<Type> _handlersToRemove = new List<Type>();
/// <summary>
/// Associates an <see cref="IApplicationEventHandler"/> type with the application.
/// </summary>
/// <typeparam name="T">The type to associate.</typeparam>
/// <returns>The application.</returns>
/// <remarks>Types implementing <see cref="IApplicationEventHandler"/> from within
/// an executable are not automatically discovered by Umbraco and have to be
/// explicitely associated with the application using this method.</remarks>
public StandaloneCoreApplication WithApplicationEventHandler<T>()
where T : IApplicationEventHandler
{
_handlersToAdd.Add(typeof(T));
return this;
}
/// <summary>
/// Dissociates an <see cref="IApplicationEventHandler"/> type from the application.
/// </summary>
/// <typeparam name="T">The type to dissociate.</typeparam>
/// <returns>The application.</returns>
public StandaloneCoreApplication WithoutApplicationEventHandler<T>()
where T : IApplicationEventHandler
{
_handlersToRemove.Add(typeof(T));
return this;
}
/// <summary>
/// Associates an <see cref="IApplicationEventHandler"/> type with the application.
/// </summary>
/// <param name="type">The type to associate.</param>
/// <returns>The application.</returns>
/// <remarks>Types implementing <see cref="IApplicationEventHandler"/> from within
/// an executable are not automatically discovered by Umbraco and have to be
/// explicitely associated with the application using this method.</remarks>
public StandaloneCoreApplication WithApplicationEventHandler(Type type)
{
if (type.Implements<IApplicationEventHandler>() == false)
throw new ArgumentException("Type does not implement IApplicationEventHandler.", "type");
_handlersToAdd.Add(type);
return this;
}
/// <summary>
/// Dissociates an <see cref="IApplicationEventHandler"/> type from the application.
/// </summary>
/// <param name="type">The type to dissociate.</param>
/// <returns>The application.</returns>
public StandaloneCoreApplication WithoutApplicationEventHandler(Type type)
{
if (type.Implements<IApplicationEventHandler>() == false)
throw new ArgumentException("Type does not implement IApplicationEventHandler.", "type");
_handlersToRemove.Add(type);
return this;
}
#endregion
}
}
@@ -0,0 +1,59 @@
using System;
using System.Collections.Generic;
using Umbraco.Core.ObjectResolution;
using Umbraco.Core.Persistence.Mappers;
using umbraco.interfaces;
namespace Umbraco.Core.Standalone
{
internal class StandaloneCoreBootManager : CoreBootManager
{
private readonly IEnumerable<Type> _handlersToAdd;
private readonly IEnumerable<Type> _handlersToRemove;
private readonly string _baseDirectory;
public StandaloneCoreBootManager(UmbracoApplicationBase umbracoApplication, IEnumerable<Type> handlersToAdd, IEnumerable<Type> handlersToRemove, string baseDirectory)
: base(umbracoApplication)
{
_handlersToAdd = handlersToAdd;
_handlersToRemove = handlersToRemove;
_baseDirectory = baseDirectory;
base.InitializeApplicationRootPath(_baseDirectory);
// this is only here to ensure references to the assemblies needed for
// the DataTypesResolver otherwise they won't be loaded into the AppDomain.
var interfacesAssemblyName = typeof(IDataType).Assembly.FullName;
}
protected override void InitializeApplicationEventsResolver()
{
base.InitializeApplicationEventsResolver();
foreach (var type in _handlersToAdd)
ApplicationEventsResolver.Current.AddType(type);
foreach (var type in _handlersToRemove)
ApplicationEventsResolver.Current.RemoveType(type);
}
protected override void InitializeResolvers()
{
base.InitializeResolvers();
//Mappers are not resolved, which could be because of a known TypeMapper issue
/*MappingResolver.Reset();
MappingResolver.Current = new MappingResolver(
() =>
new List<Type>
{
typeof (ContentMapper),
typeof (ContentTypeMapper),
typeof (MediaMapper),
typeof (MediaTypeMapper),
typeof (DataTypeDefinitionMapper),
typeof (UmbracoEntityMapper)
});*/
}
}
}
+29
View File
@@ -1035,5 +1035,34 @@ namespace Umbraco.Core
{
return ShortStringHelper.CleanStringForSafeFileName(text, culture);
}
/// <summary>
/// An extension method that returns a new string in which all occurrences of a
/// specified string in the current instance are replaced with another specified string.
/// StringComparison specifies the type of search to use for the specified string.
/// </summary>
/// <param name="source">Current instance of the string</param>
/// <param name="oldString">Specified string to replace</param>
/// <param name="newString">Specified string to inject</param>
/// <param name="stringComparison">String Comparison object to specify search type</param>
/// <returns>Updated string</returns>
public static string Replace(this string source, string oldString, string newString, StringComparison stringComparison)
{
var index = source.IndexOf(oldString, stringComparison);
// Determine if we found a match
var matchFound = index >= 0;
if (matchFound)
{
// Remove the old text
source = source.Remove(index, oldString.Length);
// Add the replacemenet text
source = source.Insert(index, newString);
}
return source;
}
}
}
+5 -3
View File
@@ -73,8 +73,10 @@ namespace Umbraco.Core
{
//NOTE: we cannot use AppDomain.CurrentDomain.GetAssemblies() because this only returns assemblies that have
// already been loaded in to the app domain, instead we will look directly into the bin folder and load each one.
var binFolder = Assembly.GetExecutingAssembly().GetAssemblyFile().Directory;
var binAssemblyFiles = Directory.GetFiles(binFolder.FullName, "*.dll", SearchOption.TopDirectoryOnly).ToList();
var binFolder = IOHelper.GetRootDirectoryBinFolder();
var binAssemblyFiles = Directory.GetFiles(binFolder, "*.dll", SearchOption.TopDirectoryOnly).ToList();
//var binFolder = Assembly.GetExecutingAssembly().GetAssemblyFile().Directory;
//var binAssemblyFiles = Directory.GetFiles(binFolder.FullName, "*.dll", SearchOption.TopDirectoryOnly).ToList();
assemblies = new List<Assembly>();
foreach (var a in binAssemblyFiles)
{
@@ -540,7 +542,7 @@ namespace Umbraco.Core
foreach (var typeToSearch in subTypesToSearch)
{
//recursively find the types inheriting from this sub type in the other non-scanned assemblies.
var foundTypes = GetClasses(typeToSearch, otherAssemblies, onlyConcreteClasses);
var foundTypes = GetClasses(typeToSearch, otherAssemblies, onlyConcreteClasses, additionalFilter);
foundAssignableTypes.AddRange(foundTypes);
}
+20 -14
View File
@@ -64,6 +64,7 @@
<Reference Include="System.Runtime.Serialization" />
<Reference Include="System.Transactions" />
<Reference Include="System.Web" />
<Reference Include="System.Web.ApplicationServices" />
<Reference Include="System.Web.Extensions" />
<Reference Include="System.Web.Helpers, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<Private>True</Private>
@@ -112,13 +113,15 @@
<Compile Include="Auditing\IAuditWriteProvider.cs" />
<Compile Include="CacheHelper.cs" />
<Compile Include="Cache\CacheKeys.cs" />
<Compile Include="Cache\CacheProviderBase.cs" />
<Compile Include="Cache\CacheRefresherBase.cs" />
<Compile Include="Cache\CacheRefresherEventArgs.cs" />
<Compile Include="Cache\CacheProviderBase.cs" />
<Compile Include="Cache\RuntimeCacheProviderBase.cs" />
<Compile Include="Cache\HttpRuntimeCacheProvider.cs" />
<Compile Include="Cache\IJsonCacheRefresher.cs" />
<Compile Include="Cache\JsonCacheRefresherBase.cs" />
<Compile Include="Cache\NullCacheProvider.cs" />
<Compile Include="Cache\StaticCacheProvider.cs" />
<Compile Include="Cache\TypedCacheRefresherBase.cs" />
<Compile Include="CodeAnnotations\FriendlyNameAttribute.cs" />
<Compile Include="CodeAnnotations\UmbracoObjectTypeAttribute.cs" />
@@ -193,6 +196,7 @@
<Compile Include="Models\IDictionaryTranslation.cs" />
<Compile Include="Models\IFile.cs" />
<Compile Include="Models\ILanguage.cs" />
<Compile Include="Models\Membership\UmbracoMembershipUser.cs" />
<Compile Include="Models\ServerRegistration.cs" />
<Compile Include="Models\ITemplate.cs" />
<Compile Include="Models\Language.cs" />
@@ -521,17 +525,11 @@
<Compile Include="Persistence\UnitOfWork\IUnitOfWorkRepository.cs" />
<Compile Include="Persistence\UnitOfWork\PetaPocoUnitOfWork.cs" />
<Compile Include="Persistence\UnitOfWork\PetaPocoUnitOfWorkProvider.cs" />
<Compile Include="Profiling\Profiler.cs" />
<Compile Include="PropertyEditors\Attributes\PropertyEditorAttribute.cs" />
<Compile Include="PropertyEditors\Attributes\ShowLabelAttribute.cs" />
<Compile Include="PropertyEditors\BlankPreValueModel.cs" />
<Compile Include="PropertyEditors\EditorModel.cs" />
<Compile Include="PropertyEditors\EditorModel`T.cs" />
<Compile Include="PropertyEditors\IValueModel.cs" />
<Compile Include="PropertyEditors\PreValueDefinition.cs" />
<Compile Include="PropertyEditors\PreValueModel.cs" />
<Compile Include="PropertyEditors\PropertyEditor.cs" />
<Compile Include="PropertyEditors\PropertyEditor`T.cs" />
<Compile Include="Profiling\IProfiler.cs" />
<Compile Include="Profiling\LogProfiler.cs" />
<Compile Include="Profiling\ProfilerExtensions.cs" />
<Compile Include="Profiling\ProfilerResolver.cs" />
<Compile Include="Profiling\WebProfiler.cs" />
<Compile Include="PublishedContentExtensions.cs" />
<Compile Include="Dictionary\ICultureDictionary.cs" />
<Compile Include="Dynamics\ClassFactory.cs" />
@@ -681,15 +679,20 @@
<Compile Include="Services\IFileService.cs" />
<Compile Include="Services\ILocalizationService.cs" />
<Compile Include="Services\IMediaService.cs" />
<Compile Include="Services\IMemberService.cs" />
<Compile Include="Services\IService.cs" />
<Compile Include="Services\IUserService.cs" />
<Compile Include="Services\LocalizationService.cs" />
<Compile Include="Services\MediaService.cs" />
<Compile Include="Services\MemberService.cs" />
<Compile Include="Services\RelationService.cs" />
<Compile Include="Services\ServerRegistrationService.cs" />
<Compile Include="Services\PackagingService.cs" />
<Compile Include="Services\ServiceContext.cs" />
<Compile Include="Services\UserService.cs" />
<Compile Include="Standalone\ServiceContextManager.cs" />
<Compile Include="Standalone\StandaloneCoreApplication.cs" />
<Compile Include="Standalone\StandaloneCoreBootManager.cs" />
<Compile Include="Strings\ContentBaseExtensions.cs" />
<Compile Include="TopologicalSorter.cs" />
<Compile Include="Strings\DefaultUrlSegmentProvider.cs" />
@@ -748,7 +751,7 @@
<Compile Include="IfExtensions.cs" />
<Compile Include="PluginManager.cs" />
<Compile Include="IO\FileSecurityException.cs" />
<Compile Include="IO\FileSystemProvider.cs" />
<Compile Include="IO\FileSystemProviderConstants.cs" />
<Compile Include="IO\FileSystemProviderManager.cs" />
<Compile Include="IO\IFileSystem.cs" />
<Compile Include="IO\IOHelper.cs" />
@@ -769,7 +772,6 @@
<Compile Include="Xml\DynamicContext.cs" />
<Compile Include="Xml\XmlNamespaces.cs" />
<Compile Include="Xml\XmlNodeListFactory.cs" />
<Compile Include="Xml\XmlNodeExtensions.cs" />
<Compile Include="Xml\XPathNavigatorExtensions.cs" />
<Compile Include="Xml\XPathVariable.cs" />
</ItemGroup>
@@ -785,6 +787,10 @@
<ItemGroup>
<Content Include="Strings\Notes.txt" />
</ItemGroup>
<ItemGroup>
<Folder Include="Packaging\" />
<Folder Include="PropertyEditors\Attributes\" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Import Project="$(SolutionDir)\.nuget\nuget.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
+22 -18
View File
@@ -1,7 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web;
using System.Web.Hosting;
using System.Web.Mvc;
@@ -25,6 +22,11 @@ namespace Umbraco.Core
public static event EventHandler ApplicationStarting;
public static event EventHandler ApplicationStarted;
/// <summary>
/// Called when the HttpApplication.Init() is fired, allows developers to subscribe to the HttpApplication events
/// </summary>
public static event EventHandler ApplicationInit;
/// <summary>
/// Boots up the Umbraco application
/// </summary>
@@ -50,22 +52,13 @@ namespace Umbraco.Core
StartApplication(sender, e);
}
protected void Application_BeginRequest()
/// <summary>
/// Override init and raise the event
/// </summary>
public override void Init()
{
if (GlobalSettings.DebugMode)
{
if (!String.IsNullOrEmpty(Request["umbDebug"]))
Umbraco.Core.Profiling.Profiler.Instance.Start();
}
}
protected void Application_EndRequest()
{
if (GlobalSettings.DebugMode)
{
if (!String.IsNullOrEmpty(Request["umbDebug"]))
Umbraco.Core.Profiling.Profiler.Instance.Stop();
}
base.Init();
OnApplicationInit(this, new EventArgs());
}
/// <summary>
@@ -90,6 +83,17 @@ namespace Umbraco.Core
ApplicationStarted(sender, e);
}
/// <summary>
/// Called to raise the ApplicationInit event
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void OnApplicationInit(object sender, EventArgs e)
{
if (ApplicationInit != null)
ApplicationInit(sender, e);
}
/// <summary>
/// A method that can be overridden to invoke code when the application has an error.
/// </summary>
+15
View File
@@ -1,4 +1,6 @@
using System;
using System.IO;
using System.Linq;
using System.Text;
namespace Umbraco.Core
@@ -8,6 +10,19 @@ namespace Umbraco.Core
/// </summary>
public static class UriExtensions
{
/// <summary>
/// This is a performance tweak to check if this is a .css, .js or .ico, .jpg, .jpeg, .png, .gif file request since
/// .Net will pass these requests through to the module when in integrated mode.
/// We want to ignore all of these requests immediately.
/// </summary>
/// <param name="url"></param>
/// <returns></returns>
internal static bool IsClientSideRequest(this Uri url)
{
var toIgnore = new[] { ".js", ".css", ".ico", ".png", ".jpg", ".jpeg", ".gif" };
return toIgnore.Any(x => Path.GetExtension(url.LocalPath).InvariantEquals(x));
}
/// <summary>
/// Rewrites the path of uri.
/// </summary>
-169
View File
@@ -1,169 +0,0 @@
using System.Collections.Generic;
using System.Linq;
using System.Xml;
using System.Xml.XPath;
// source: mvpxml.codeplex.com
namespace Umbraco.Core.Xml
{
/// <summary>
/// Provides extensions to XmlNode.
/// </summary>
internal static class XmlNodeExtensions
{
/// <summary>
/// Selects a list of XmlNode matching an XPath expression.
/// </summary>
/// <param name="source">A source XmlNode.</param>
/// <param name="expression">An XPath expression.</param>
/// <param name="variables">A set of XPathVariables.</param>
/// <returns>The list of XmlNode matching the XPath expression.</returns>
/// <remarks>
/// <para>If <param name="variables" /> is <c>null</c>, or is empty, or contains only one single
/// value which itself is <c>null</c>, then variables are ignored.</para>
/// <para>The XPath expression should reference variables as <c>$var</c>.</para>
/// </remarks>
public static XmlNodeList SelectNodes(this XmlNode source, string expression, IEnumerable<XPathVariable> variables)
{
var av = variables == null ? null : variables.ToArray();
return SelectNodes(source, expression, av);
}
/// <summary>
/// Selects a list of XmlNode matching an XPath expression.
/// </summary>
/// <param name="source">A source XmlNode.</param>
/// <param name="expression">An XPath expression.</param>
/// <param name="variables">A set of XPathVariables.</param>
/// <returns>The list of XmlNode matching the XPath expression.</returns>
/// <remarks>
/// <para>If <param name="variables" /> is <c>null</c>, or is empty, or contains only one single
/// value which itself is <c>null</c>, then variables are ignored.</para>
/// <para>The XPath expression should reference variables as <c>$var</c>.</para>
/// </remarks>
public static XmlNodeList SelectNodes(this XmlNode source, XPathExpression expression, IEnumerable<XPathVariable> variables)
{
var av = variables == null ? null : variables.ToArray();
return SelectNodes(source, expression, av);
}
/// <summary>
/// Selects a list of XmlNode matching an XPath expression.
/// </summary>
/// <param name="source">A source XmlNode.</param>
/// <param name="expression">An XPath expression.</param>
/// <param name="variables">A set of XPathVariables.</param>
/// <returns>The list of XmlNode matching the XPath expression.</returns>
/// <remarks>
/// <para>If <param name="variables" /> is <c>null</c>, or is empty, or contains only one single
/// value which itself is <c>null</c>, then variables are ignored.</para>
/// <para>The XPath expression should reference variables as <c>$var</c>.</para>
/// </remarks>
public static XmlNodeList SelectNodes(this XmlNode source, string expression, params XPathVariable[] variables)
{
if (variables == null || variables.Length == 0 || variables[0] == null)
return source.SelectNodes(expression);
var iterator = source.CreateNavigator().Select(expression, variables);
return XmlNodeListFactory.CreateNodeList(iterator);
}
/// <summary>
/// Selects a list of XmlNode matching an XPath expression.
/// </summary>
/// <param name="source">A source XmlNode.</param>
/// <param name="expression">An XPath expression.</param>
/// <param name="variables">A set of XPathVariables.</param>
/// <returns>The list of XmlNode matching the XPath expression.</returns>
/// <remarks>
/// <para>If <param name="variables" /> is <c>null</c>, or is empty, or contains only one single
/// value which itself is <c>null</c>, then variables are ignored.</para>
/// <para>The XPath expression should reference variables as <c>$var</c>.</para>
/// </remarks>
public static XmlNodeList SelectNodes(this XmlNode source, XPathExpression expression, params XPathVariable[] variables)
{
if (variables == null || variables.Length == 0 || variables[0] == null)
return source.SelectNodes(expression);
var iterator = source.CreateNavigator().Select(expression, variables);
return XmlNodeListFactory.CreateNodeList(iterator);
}
/// <summary>
/// Selects the first XmlNode that matches an XPath expression.
/// </summary>
/// <param name="source">A source XmlNode.</param>
/// <param name="expression">An XPath expression.</param>
/// <param name="variables">A set of XPathVariables.</param>
/// <returns>The first XmlNode that matches the XPath expression.</returns>
/// <remarks>
/// <para>If <param name="variables" /> is <c>null</c>, or is empty, or contains only one single
/// value which itself is <c>null</c>, then variables are ignored.</para>
/// <para>The XPath expression should reference variables as <c>$var</c>.</para>
/// </remarks>
public static XmlNode SelectSingleNode(this XmlNode source, string expression, IEnumerable<XPathVariable> variables)
{
var av = variables == null ? null : variables.ToArray();
return SelectSingleNode(source, expression, av);
}
/// <summary>
/// Selects the first XmlNode that matches an XPath expression.
/// </summary>
/// <param name="source">A source XmlNode.</param>
/// <param name="expression">An XPath expression.</param>
/// <param name="variables">A set of XPathVariables.</param>
/// <returns>The first XmlNode that matches the XPath expression.</returns>
/// <remarks>
/// <para>If <param name="variables" /> is <c>null</c>, or is empty, or contains only one single
/// value which itself is <c>null</c>, then variables are ignored.</para>
/// <para>The XPath expression should reference variables as <c>$var</c>.</para>
/// </remarks>
public static XmlNode SelectSingleNode(this XmlNode source, XPathExpression expression, IEnumerable<XPathVariable> variables)
{
var av = variables == null ? null : variables.ToArray();
return SelectSingleNode(source, expression, av);
}
/// <summary>
/// Selects the first XmlNode that matches an XPath expression.
/// </summary>
/// <param name="source">A source XmlNode.</param>
/// <param name="expression">An XPath expression.</param>
/// <param name="variables">A set of XPathVariables.</param>
/// <returns>The first XmlNode that matches the XPath expression.</returns>
/// <remarks>
/// <para>If <param name="variables" /> is <c>null</c>, or is empty, or contains only one single
/// value which itself is <c>null</c>, then variables are ignored.</para>
/// <para>The XPath expression should reference variables as <c>$var</c>.</para>
/// </remarks>
public static XmlNode SelectSingleNode(this XmlNode source, string expression, params XPathVariable[] variables)
{
if (variables == null || variables.Length == 0 || variables[0] == null)
return source.SelectSingleNode(expression);
return SelectNodes(source, expression, variables).Cast<XmlNode>().FirstOrDefault();
}
/// <summary>
/// Selects the first XmlNode that matches an XPath expression.
/// </summary>
/// <param name="source">A source XmlNode.</param>
/// <param name="expression">An XPath expression.</param>
/// <param name="variables">A set of XPathVariables.</param>
/// <returns>The first XmlNode that matches the XPath expression.</returns>
/// <remarks>
/// <para>If <param name="variables" /> is <c>null</c>, or is empty, or contains only one single
/// value which itself is <c>null</c>, then variables are ignored.</para>
/// <para>The XPath expression should reference variables as <c>$var</c>.</para>
/// </remarks>
public static XmlNode SelectSingleNode(this XmlNode source, XPathExpression expression, params XPathVariable[] variables)
{
if (variables == null || variables.Length == 0 || variables[0] == null)
return source.SelectSingleNode(expression);
return SelectNodes(source, expression, variables).Cast<XmlNode>().FirstOrDefault();
}
}
}
+158
View File
@@ -1,6 +1,10 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Xml;
using System.Xml.Linq;
using System.Xml.XPath;
using Umbraco.Core.Xml;
namespace Umbraco.Core
{
@@ -9,6 +13,160 @@ namespace Umbraco.Core
/// </summary>
internal static class XmlExtensions
{
/// <summary>
/// Selects a list of XmlNode matching an XPath expression.
/// </summary>
/// <param name="source">A source XmlNode.</param>
/// <param name="expression">An XPath expression.</param>
/// <param name="variables">A set of XPathVariables.</param>
/// <returns>The list of XmlNode matching the XPath expression.</returns>
/// <remarks>
/// <para>If <param name="variables" /> is <c>null</c>, or is empty, or contains only one single
/// value which itself is <c>null</c>, then variables are ignored.</para>
/// <para>The XPath expression should reference variables as <c>$var</c>.</para>
/// </remarks>
public static XmlNodeList SelectNodes(this XmlNode source, string expression, IEnumerable<XPathVariable> variables)
{
var av = variables == null ? null : variables.ToArray();
return SelectNodes(source, expression, av);
}
/// <summary>
/// Selects a list of XmlNode matching an XPath expression.
/// </summary>
/// <param name="source">A source XmlNode.</param>
/// <param name="expression">An XPath expression.</param>
/// <param name="variables">A set of XPathVariables.</param>
/// <returns>The list of XmlNode matching the XPath expression.</returns>
/// <remarks>
/// <para>If <param name="variables" /> is <c>null</c>, or is empty, or contains only one single
/// value which itself is <c>null</c>, then variables are ignored.</para>
/// <para>The XPath expression should reference variables as <c>$var</c>.</para>
/// </remarks>
public static XmlNodeList SelectNodes(this XmlNode source, XPathExpression expression, IEnumerable<XPathVariable> variables)
{
var av = variables == null ? null : variables.ToArray();
return SelectNodes(source, expression, av);
}
/// <summary>
/// Selects a list of XmlNode matching an XPath expression.
/// </summary>
/// <param name="source">A source XmlNode.</param>
/// <param name="expression">An XPath expression.</param>
/// <param name="variables">A set of XPathVariables.</param>
/// <returns>The list of XmlNode matching the XPath expression.</returns>
/// <remarks>
/// <para>If <param name="variables" /> is <c>null</c>, or is empty, or contains only one single
/// value which itself is <c>null</c>, then variables are ignored.</para>
/// <para>The XPath expression should reference variables as <c>$var</c>.</para>
/// </remarks>
public static XmlNodeList SelectNodes(this XmlNode source, string expression, params XPathVariable[] variables)
{
if (variables == null || variables.Length == 0 || variables[0] == null)
return source.SelectNodes(expression);
var iterator = source.CreateNavigator().Select(expression, variables);
return XmlNodeListFactory.CreateNodeList(iterator);
}
/// <summary>
/// Selects a list of XmlNode matching an XPath expression.
/// </summary>
/// <param name="source">A source XmlNode.</param>
/// <param name="expression">An XPath expression.</param>
/// <param name="variables">A set of XPathVariables.</param>
/// <returns>The list of XmlNode matching the XPath expression.</returns>
/// <remarks>
/// <para>If <param name="variables" /> is <c>null</c>, or is empty, or contains only one single
/// value which itself is <c>null</c>, then variables are ignored.</para>
/// <para>The XPath expression should reference variables as <c>$var</c>.</para>
/// </remarks>
public static XmlNodeList SelectNodes(this XmlNode source, XPathExpression expression, params XPathVariable[] variables)
{
if (variables == null || variables.Length == 0 || variables[0] == null)
return source.SelectNodes(expression);
var iterator = source.CreateNavigator().Select(expression, variables);
return XmlNodeListFactory.CreateNodeList(iterator);
}
/// <summary>
/// Selects the first XmlNode that matches an XPath expression.
/// </summary>
/// <param name="source">A source XmlNode.</param>
/// <param name="expression">An XPath expression.</param>
/// <param name="variables">A set of XPathVariables.</param>
/// <returns>The first XmlNode that matches the XPath expression.</returns>
/// <remarks>
/// <para>If <param name="variables" /> is <c>null</c>, or is empty, or contains only one single
/// value which itself is <c>null</c>, then variables are ignored.</para>
/// <para>The XPath expression should reference variables as <c>$var</c>.</para>
/// </remarks>
public static XmlNode SelectSingleNode(this XmlNode source, string expression, IEnumerable<XPathVariable> variables)
{
var av = variables == null ? null : variables.ToArray();
return SelectSingleNode(source, expression, av);
}
/// <summary>
/// Selects the first XmlNode that matches an XPath expression.
/// </summary>
/// <param name="source">A source XmlNode.</param>
/// <param name="expression">An XPath expression.</param>
/// <param name="variables">A set of XPathVariables.</param>
/// <returns>The first XmlNode that matches the XPath expression.</returns>
/// <remarks>
/// <para>If <param name="variables" /> is <c>null</c>, or is empty, or contains only one single
/// value which itself is <c>null</c>, then variables are ignored.</para>
/// <para>The XPath expression should reference variables as <c>$var</c>.</para>
/// </remarks>
public static XmlNode SelectSingleNode(this XmlNode source, XPathExpression expression, IEnumerable<XPathVariable> variables)
{
var av = variables == null ? null : variables.ToArray();
return SelectSingleNode(source, expression, av);
}
/// <summary>
/// Selects the first XmlNode that matches an XPath expression.
/// </summary>
/// <param name="source">A source XmlNode.</param>
/// <param name="expression">An XPath expression.</param>
/// <param name="variables">A set of XPathVariables.</param>
/// <returns>The first XmlNode that matches the XPath expression.</returns>
/// <remarks>
/// <para>If <param name="variables" /> is <c>null</c>, or is empty, or contains only one single
/// value which itself is <c>null</c>, then variables are ignored.</para>
/// <para>The XPath expression should reference variables as <c>$var</c>.</para>
/// </remarks>
public static XmlNode SelectSingleNode(this XmlNode source, string expression, params XPathVariable[] variables)
{
if (variables == null || variables.Length == 0 || variables[0] == null)
return source.SelectSingleNode(expression);
return SelectNodes(source, expression, variables).Cast<XmlNode>().FirstOrDefault();
}
/// <summary>
/// Selects the first XmlNode that matches an XPath expression.
/// </summary>
/// <param name="source">A source XmlNode.</param>
/// <param name="expression">An XPath expression.</param>
/// <param name="variables">A set of XPathVariables.</param>
/// <returns>The first XmlNode that matches the XPath expression.</returns>
/// <remarks>
/// <para>If <param name="variables" /> is <c>null</c>, or is empty, or contains only one single
/// value which itself is <c>null</c>, then variables are ignored.</para>
/// <para>The XPath expression should reference variables as <c>$var</c>.</para>
/// </remarks>
public static XmlNode SelectSingleNode(this XmlNode source, XPathExpression expression, params XPathVariable[] variables)
{
if (variables == null || variables.Length == 0 || variables[0] == null)
return source.SelectSingleNode(expression);
return SelectNodes(source, expression, variables).Cast<XmlNode>().FirstOrDefault();
}
/// <summary>
/// Converts from an XDocument to an XmlDocument
/// </summary>
@@ -7,29 +7,38 @@ using NUnit.Framework;
using Umbraco.Core;
using Umbraco.Core.ObjectResolution;
using Umbraco.Core.Persistence.SqlSyntax;
using Umbraco.Tests.TestHelpers;
using umbraco.interfaces;
namespace Umbraco.Tests.BootManagers
{
[TestFixture]
public class CoreBootManagerTests
public class CoreBootManagerTests : BaseUmbracoApplicationTest
{
private TestApp _testApp;
[SetUp]
public void Setup()
public override void Initialize()
{
base.Initialize();
_testApp = new TestApp();
}
[TearDown]
public void TearDown()
public override void TearDown()
{
base.TearDown();
_testApp = null;
ApplicationEventsResolver.Reset();
SqlSyntaxProvidersResolver.Reset();
//ApplicationEventsResolver.Reset();
//SqlSyntaxProvidersResolver.Reset();
}
protected override void FreezeResolution()
{
//don't freeze resolution, we'll do that in the boot manager
}
/// <summary>
@@ -1,4 +1,5 @@
using System.Linq;
using System.IO;
using System.Linq;
using System.Text.RegularExpressions;
using NUnit.Framework;
using Umbraco.Core.Models;
@@ -57,11 +58,35 @@ namespace Umbraco.Tests.CodeFirst
#region Test setup
public override void Initialize()
{
var currDir = new DirectoryInfo(TestHelper.CurrentAssemblyDirectory);
var configPath = Path.Combine(currDir.Parent.Parent.FullName, "config");
if (Directory.Exists(configPath) == false)
Directory.CreateDirectory(configPath);
var umbracoSettingsFile = Path.Combine(currDir.Parent.Parent.FullName, "config", "umbracoSettings.config");
if (System.IO.File.Exists(umbracoSettingsFile) == false)
System.IO.File.Copy(
currDir.Parent.Parent.Parent.GetDirectories("Umbraco.Web.UI")
.First()
.GetDirectories("config").First()
.GetFiles("umbracoSettings.Release.config").First().FullName,
Path.Combine(currDir.Parent.Parent.FullName, "config", "umbracoSettings.config"),
true);
Core.Configuration.UmbracoSettings.SettingsFilePath = Core.IO.IOHelper.MapPath(Core.IO.SystemDirectories.Config + Path.DirectorySeparatorChar, false);
base.Initialize();
}
public override void TearDown()
{
var currDir = new DirectoryInfo(TestHelper.CurrentAssemblyDirectory);
var umbracoSettingsFile = Path.Combine(currDir.Parent.Parent.FullName, "config", "umbracoSettings.config");
if (System.IO.File.Exists(umbracoSettingsFile))
System.IO.File.Delete(umbracoSettingsFile);
base.TearDown();
}
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using NUnit.Framework;
@@ -17,8 +18,32 @@ namespace Umbraco.Tests.CoreStrings
public void Setup()
{
_helper = new LegacyShortStringHelper();
var currDir = new DirectoryInfo(TestHelpers.TestHelper.CurrentAssemblyDirectory);
Directory.CreateDirectory(Path.Combine(currDir.Parent.Parent.FullName, "config"));
File.Copy(
currDir.Parent.Parent.Parent.GetDirectories("Umbraco.Web.UI")
.First()
.GetDirectories("config").First()
.GetFiles("umbracoSettings.Release.config").First().FullName,
Path.Combine(currDir.Parent.Parent.FullName, "config", "umbracoSettings.config"),
true);
Core.Configuration.UmbracoSettings.SettingsFilePath = Core.IO.IOHelper.MapPath(Core.IO.SystemDirectories.Config + Path.DirectorySeparatorChar, false);
}
[TearDown]
public void TearDown()
{
//TODO: Deleting the umbracoSettings.config file makes a lot of tests fail
//var currDir = new DirectoryInfo(TestHelpers.TestHelper.CurrentAssemblyDirectory);
//var umbracoSettingsFile = Path.Combine(currDir.Parent.Parent.FullName, "config", "umbracoSettings.config");
//if (File.Exists(umbracoSettingsFile))
// File.Delete(umbracoSettingsFile);
}
#region Cases
[TestCase("foo", "foo")]
[TestCase(" foo ", "Foo")]
@@ -14,7 +14,7 @@ namespace Umbraco.Tests.IO
[Test]
public void Can_Get_Base_File_System()
{
var fs = FileSystemProviderManager.Current.GetFileSystemProvider(FileSystemProvider.Media);
var fs = FileSystemProviderManager.Current.GetUnderlyingFileSystemProvider(FileSystemProviderConstants.Media);
Assert.NotNull(fs);
}
+22 -7
View File
@@ -27,19 +27,34 @@ namespace Umbraco.Tests
UmbracoContext.Current = routingContext.UmbracoContext;
var currDir = new DirectoryInfo(TestHelper.CurrentAssemblyDirectory);
File.Copy(
currDir.Parent.Parent.Parent.GetDirectories("Umbraco.Web.UI")
.First()
.GetDirectories("config").First()
.GetFiles("umbracoSettings.Release.config").First().FullName,
Path.Combine(currDir.Parent.Parent.FullName, "config", "umbracoSettings.config"),
true);
var configPath = Path.Combine(currDir.Parent.Parent.FullName, "config");
if (Directory.Exists(configPath) == false)
Directory.CreateDirectory(configPath);
var umbracoSettingsFile = Path.Combine(currDir.Parent.Parent.FullName, "config", "umbracoSettings.config");
if (File.Exists(umbracoSettingsFile) == false)
File.Copy(
currDir.Parent.Parent.Parent.GetDirectories("Umbraco.Web.UI")
.First()
.GetDirectories("config").First()
.GetFiles("umbracoSettings.Release.config").First().FullName,
Path.Combine(currDir.Parent.Parent.FullName, "config", "umbracoSettings.config"),
true);
Core.Configuration.UmbracoSettings.SettingsFilePath = Core.IO.IOHelper.MapPath(Core.IO.SystemDirectories.Config + Path.DirectorySeparatorChar, false);
}
public override void TearDown()
{
//TODO: Deleting the umbracoSettings.config file makes a lot of tests fail
//var currDir = new DirectoryInfo(TestHelper.CurrentAssemblyDirectory);
//var umbracoSettingsFile = Path.Combine(currDir.Parent.Parent.FullName, "config", "umbracoSettings.config");
//if (File.Exists(umbracoSettingsFile))
// File.Delete(umbracoSettingsFile);
base.TearDown();
UmbracoContext.Current = null;
}
+7 -3
View File
@@ -1,11 +1,9 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Web.Caching;
using NUnit.Framework;
using Umbraco.Core;
using Umbraco.Core.Profiling;
using umbraco;
using umbraco.cms.businesslogic.macro;
@@ -20,11 +18,17 @@ namespace Umbraco.Tests.Macros
{
//we DO want cache enabled for these tests
ApplicationContext.Current = new ApplicationContext(true);
ProfilerResolver.Current = new ProfilerResolver(new LogProfiler())
{
CanResolveBeforeFrozen = true
};
}
[TearDown]
public void TearDown()
{
ProfilerResolver.Current.DisposeIfDisposable();
ProfilerResolver.Reset();
ApplicationContext.Current.ApplicationCache.ClearAllCache();
ApplicationContext.Current.DisposeIfDisposable();
ApplicationContext.Current = null;
@@ -2,13 +2,10 @@
using System.Xml.Linq;
using NUnit.Framework;
using Umbraco.Core;
using Umbraco.Core.ObjectResolution;
using Umbraco.Core.Models;
using Umbraco.Core.Strings;
using Umbraco.Tests.TestHelpers;
using Umbraco.Tests.TestHelpers.Entities;
using umbraco.editorControls.tinyMCE3;
using umbraco.interfaces;
namespace Umbraco.Tests.Models
{
+1 -1
View File
@@ -330,7 +330,7 @@ namespace Umbraco.Tests
public void Resolves_RestExtensions()
{
var types = PluginManager.Current.ResolveRestExtensions();
Assert.AreEqual(2, types.Count());
Assert.AreEqual(3, types.Count());
}
[Test]
@@ -4,6 +4,7 @@ using System.Xml;
using NUnit.Framework;
using Umbraco.Core;
using Umbraco.Core.Configuration;
using Umbraco.Tests.PublishedContent;
using Umbraco.Tests.TestHelpers;
using Umbraco.Web;
using Umbraco.Web.PublishedCache;
@@ -77,6 +78,7 @@ namespace Umbraco.Tests.PublishedCache
//ensure the StateHelper is using our custom context
StateHelper.HttpContext = _httpContextFactory.HttpContext;
UmbracoSettings.UseLegacyXmlSchema = false;
var cache = new PublishedContentCache
{
GetXmlDelegate = (context, preview) =>
@@ -30,13 +30,20 @@ namespace Umbraco.Tests.PublishedContent
base.Initialize();
//copy the umbraco settings file over
var currDir = new DirectoryInfo(TestHelper.CurrentAssemblyDirectory);
File.Copy(
currDir.Parent.Parent.Parent.GetDirectories("Umbraco.Web.UI")
.First()
.GetDirectories("config").First()
.GetFiles("umbracoSettings.Release.config").First().FullName,
Path.Combine(currDir.Parent.Parent.FullName, "config", "umbracoSettings.config"),
true);
var configPath = Path.Combine(currDir.Parent.Parent.FullName, "config");
if (Directory.Exists(configPath) == false)
Directory.CreateDirectory(configPath);
var umbracoSettingsFile = Path.Combine(currDir.Parent.Parent.FullName, "config", "umbracoSettings.config");
if (File.Exists(umbracoSettingsFile) == false)
File.Copy(
currDir.Parent.Parent.Parent.GetDirectories("Umbraco.Web.UI")
.First()
.GetDirectories("config").First()
.GetFiles("umbracoSettings.Release.config").First().FullName,
Path.Combine(currDir.Parent.Parent.FullName, "config", "umbracoSettings.config"),
true);
UmbracoSettings.SettingsFilePath = IOHelper.MapPath(SystemDirectories.Config + Path.DirectorySeparatorChar, false);
@@ -76,6 +83,14 @@ namespace Umbraco.Tests.PublishedContent
public override void TearDown()
{
//TODO: Deleting the umbracoSettings.config file makes a lot of tests fail
//var currDir = new DirectoryInfo(TestHelper.CurrentAssemblyDirectory);
//var umbracoSettingsFile = Path.Combine(currDir.Parent.Parent.FullName, "config", "umbracoSettings.config");
//if (File.Exists(umbracoSettingsFile))
// File.Delete(umbracoSettingsFile);
base.TearDown();
}
@@ -1,3 +1,4 @@
using System.IO;
using System.Linq;
using NUnit.Framework;
using Umbraco.Core;
@@ -6,6 +7,7 @@ using Umbraco.Web;
using Umbraco.Web.Models;
using Umbraco.Web.PublishedCache;
using Umbraco.Web.PublishedCache.XmlPublishedCache;
using File = Umbraco.Core.Models.File;
namespace Umbraco.Tests.PublishedContent
{
@@ -13,9 +15,26 @@ namespace Umbraco.Tests.PublishedContent
public class DynamicPublishedContentTests : DynamicDocumentTestsBase<DynamicPublishedContent, DynamicPublishedContentList>
{
public override void Initialize()
{
base.Initialize();
{
var currDir = new DirectoryInfo(TestHelpers.TestHelper.CurrentAssemblyDirectory);
var configPath = Path.Combine(currDir.Parent.Parent.FullName, "config");
if (Directory.Exists(configPath) == false)
Directory.CreateDirectory(configPath);
var umbracoSettingsFile = Path.Combine(currDir.Parent.Parent.FullName, "config", "umbracoSettings.config");
if (System.IO.File.Exists(umbracoSettingsFile) == false)
System.IO.File.Copy(
currDir.Parent.Parent.Parent.GetDirectories("Umbraco.Web.UI")
.First()
.GetDirectories("config").First()
.GetFiles("umbracoSettings.Release.config").First().FullName,
Path.Combine(currDir.Parent.Parent.FullName, "config", "umbracoSettings.config"),
true);
Core.Configuration.UmbracoSettings.SettingsFilePath = Core.IO.IOHelper.MapPath(Core.IO.SystemDirectories.Config + Path.DirectorySeparatorChar, false);
base.Initialize();
}
public override void TearDown()
@@ -24,7 +24,7 @@ namespace Umbraco.Tests.PublishedContent
//need to specify a custom callback for unit tests
PublishedContentHelper.GetDataTypeCallback = (docTypeAlias, propertyAlias) =>
{
if (propertyAlias == "content")
if (propertyAlias.InvariantEquals("content"))
{
//return the rte type id
return Guid.Parse(Constants.PropertyEditors.TinyMCEv3);
@@ -240,6 +240,10 @@ namespace Umbraco.Tests.PublishedContent
var propVal2 = doc.GetPropertyValue<IHtmlString>("content");
Assert.IsTrue(TypeHelper.IsTypeAssignableFrom<IHtmlString>(propVal2.GetType()));
Assert.AreEqual("<div>This is some content</div>", propVal2.ToString());
var propVal3 = doc.GetPropertyValue("Content");
Assert.IsTrue(TypeHelper.IsTypeAssignableFrom<IHtmlString>(propVal3.GetType()));
Assert.AreEqual("<div>This is some content</div>", propVal3.ToString());
}
[Test]
@@ -18,17 +18,36 @@ namespace Umbraco.Tests.Routing
base.Initialize();
var currDir = new DirectoryInfo(TestHelper.CurrentAssemblyDirectory);
File.Copy(
currDir.Parent.Parent.Parent.GetDirectories("Umbraco.Web.UI")
.First()
.GetDirectories("config").First()
.GetFiles("umbracoSettings.Release.config").First().FullName,
Path.Combine(currDir.Parent.Parent.FullName, "config", "umbracoSettings.config"),
true);
var configPath = Path.Combine(currDir.Parent.Parent.FullName, "config");
if (Directory.Exists(configPath) == false)
Directory.CreateDirectory(configPath);
var umbracoSettingsFile = Path.Combine(currDir.Parent.Parent.FullName, "config", "umbracoSettings.config");
if (File.Exists(umbracoSettingsFile) == false)
File.Copy(
currDir.Parent.Parent.Parent.GetDirectories("Umbraco.Web.UI")
.First()
.GetDirectories("config").First()
.GetFiles("umbracoSettings.Release.config").First().FullName,
Path.Combine(currDir.Parent.Parent.FullName, "config", "umbracoSettings.config"),
true);
SettingsForTests.SettingsFilePath = Core.IO.IOHelper.MapPath(Core.IO.SystemDirectories.Config + Path.DirectorySeparatorChar, false);
}
public void TearDown()
{
//TODO: Deleting the umbracoSettings.config file makes a lot of tests fail
//var currDir = new DirectoryInfo(TestHelper.CurrentAssemblyDirectory);
//var umbracoSettingsFile = Path.Combine(currDir.Parent.Parent.FullName, "config", "umbracoSettings.config");
//if (File.Exists(umbracoSettingsFile))
// File.Delete(umbracoSettingsFile);
}
protected override void FreezeResolution()
{
SiteDomainHelperResolver.Current = new SiteDomainHelperResolver(new SiteDomainHelper());

Some files were not shown because too many files have changed in this diff Show More