250 likes | 408 Views
Mike Reynolds Product Technical Lead MedTouch. Oh CRUD -- Enhance the Sitecore Item Web API to Fit Your Needs.
E N D
Mike Reynolds Product Technical Lead MedTouch Oh CRUD -- Enhance the Sitecore Item Web API to Fit Your Needs Sharing Inspiring Connecting
Sitecore Item Web API- Create, Read, Update and Delete (CRUD) - Defined by HTTP request methods- Create => POST - Read => GET - Update => PUT- Delete => DELETE (really? :P) Sharing Inspiring Connecting
Sitecore Item Web API- Touch multiple items in “scope” - Parent => p - Self => s - Children => c - can request all three -- sweet!- Uses JSON in responses by default- Customizable through pipelines Sharing Inspiring Connecting
<itemWebApiRequest>- Main pipeline to handle requests -- I knew that! ;)- Determines if user has permission to make request- Gets items- Ascertains scope- Executes action- Serializes and returns response (JSON by default) Sharing Inspiring Connecting
<itemWebApiRequest>- ResolveAction processor - Executes action - Creates media library items - Cannot set media library item fields Sharing Inspiring Connecting
<itemWebApiRequest>- But I want to set media library item fields! - Create a custom ResolveAction processor Sharing Inspiring Connecting
<itemWebApiRequest> Let’s see one Sharing Inspiring Connecting
<itemWebApiRequest>- But I don't want to use JSON! - Then change the Serializer already! Sharing Inspiring Connecting
<itemWebApiRequest> Let’s see such a thing Sharing Inspiring Connecting
<preprocessRequest>- Has one lonely processor :(- Does some URL rewriting magic- Creates the default Serializer instance Sharing Inspiring Connecting
<preprocessRequest> Sharing Inspiring Connecting
<preprocessRequest>- Didn’t we already talk about the Serializer? - an alternative way to change it - custom PreprocessRequestProcessor Sharing Inspiring Connecting
<preprocessRequest> Let’s see an example Sharing Inspiring Connecting
<itemWebApiGetProperties>- Consists of one processor- Provides information about an item - e.g. ID, Language, Template, Hair Color, Blood Type, etc. Sharing Inspiring Connecting
<itemWebApiGetProperties> Sharing Inspiring Connecting
<itemWebApiGetProperties>- But I want to know more about an item! :D - Add a custom GetPropertiesProcessor! Sharing Inspiring Connecting
<itemWebApiGetProperties> Let’s see an example Sharing Inspiring Connecting
<itemWebApiDelete>- Composed of one processor- Ignores RecycleBinActive setting in Web.config - Permanently deletes all items in scope! O_O Sharing Inspiring Connecting
<itemWebApiDelete>- How can we recycle items instead? - Recycle items using a DeleteProcessor Sharing Inspiring Connecting
<itemWebApiDelete>Show me the code! Sharing Inspiring Connecting
What About Publishing?- Does not exist “out of the box” - Fill the gap using a custom pipeline - custom <itemWebApiPatch> pipeline - Publish => PATCH - Let’s see it! Sharing Inspiring Connecting
Go Check It Out!Download it (SDN): http://bit.ly/19E9AzADeveloper's Guide: http://bit.ly/GQIaugSitecoreJunkie.com: http://bit.ly/19DoIY0Kern's Console Application: http://bit.ly/16UqOZx Sharing Inspiring Connecting
Get In Touch!Email: mreynolds@medtouch.comTwitter: @mike_i_reynoldsBlog: http://sitecorejunkie.com Sharing Inspiring Connecting
Questions? Sharing Inspiring Connecting
Thank You!Fin Sharing Inspiring Connecting