Presentation is loading. Please wait.

Presentation is loading. Please wait.

IMPORTING & EXPORTING DATA

Similar presentations


Presentation on theme: "IMPORTING & EXPORTING DATA"— Presentation transcript:

1 IMPORTING & EXPORTING DATA
Paul Taylor, Solutions Architect October 29, 2014

2 IMPORTING & EXPORTING DATA
- AGENDA Importing & Exporting Data Resources CMS Publishing Architecture Your Feedback Importing Data Exporting Data

3 CMS Publishing Architecture

4 CMS PUBLISHING ARCHITECTURE
IMPORTING / EXPORTING DATA CMS PUBLISHING ARCHITECTURE Any Platform Any Device You will see a number of diagrams this week detailing the CrownPeak CMS architecture. Detail architecture diagram. Any Integration Anywhere…

5 CMS PUBLISHING ARCHITECTURE
IMPORTING / EXPORTING DATA CMS PUBLISHING ARCHITECTURE End User System Content Delivery Content Management Core Content Management Delivery Template-Managed I/O Input Processing Output Generation Policies and Standards Dynamic Services Repository (content, security, workflow) Targeting and Personalization Search Management

6 CMS PUBLISHING ARCHITECTURE
IMPORTING / EXPORTING DATA CMS PUBLISHING ARCHITECTURE Core Content Management Template-Managed I/O Policies and Standards Input Processing Repository (content, security, workflow) Content Delivery Content Management Output Generation Delivery CrownPeak-Hosted Platform Customer-Hosted Platform Third-Party Service

7 CMS PUBLISHING ARCHITECTURE
IMPORTING / EXPORTING DATA CMS PUBLISHING ARCHITECTURE Core Content Management Template-Managed I/O Policies and Standards Input Processing Repository (content, security, workflow) Content Delivery Content Management Output Generation Delivery Java EE (JSP) .Net (ASP) PHP XML CSV JSON

8 Importing Data

9 IMPORTING / EXPORTING DATA
IMPORTING DATA CrownPeak currently supports 3 methods of importing data into the CMS from external sources SMTP FTP Custom Template (HTTP, REST etc.) Import WS API (Coming Soon!)

10 IMPORTING DATA SMTP In cases where not practical to create an Asset individually and where data can be obtained in a structured XML or CSV format Preferred for small jobs – only a few updates per hour Configuration mapping defined within CMS interface Import token sent in subject line Data sent in the body of an , or as an attachment smtp_import.aspx Defines how imported data is mapped to CMS Asset

11 SMTP – Example - Configuration
IMPORTING DATA SMTP – Example - Configuration Available via the Classic UI System > Configure > Import > SMTP Multiple SMTP Import Profiles

12 SMTP – Example - Template
IMPORTING DATA SMTP – Example - Template Within specified Model asset: smtp_import.aspx

13 IMPORTING DATA FTP In cases where not practical to create an Asset individually and where data can be obtained in a structured XML or CSV format Preferred for large jobs – e.g. bulk content imports Configuration mapping defined within CMS interface Requires your own FTP server to ‘host’ the data to be imported FTP server is automatically polled – schedule configurable Import token included within filename ftp_import.aspx Defines how imported data is mapped to CMS Asset

14 FTP – Example - Configuration
IMPORTING DATA FTP – Example - Configuration Available via the Classic UI System > Configure > Import > FTP Multiple FTP Import Profiles

15 FTP – Example - Template
IMPORTING DATA FTP – Example - Template Within specified Model asset: ftp_import.aspx

16 IMPORTING DATA CUSTOM TEMPLATE In cases where import via ‘pull’ is required upon a regular schedule Custom Developer Template created Makes HttpWebRequest (Util class) call to external service access.com/select/?q=custom_ss_type:Location&rows= &fl=* Reads HttpWebResponse (Util class) Processes data into CMS Can be run one-time (View Output – be careful!), initiated in Workflow, or run on schedule ‘Be careful’ on initiating via ‘View Output’, as preview will also trigger the import – have necessary checking in your code.

17 IMPORTING DATA CUSTOM TEMPLATE - DEMO Deploy a Custom Developer Template in order to import data from an external XML-based web service Define Asset Template Import data into new Asset Folder, based upon Template Demo Steps: - Create project folder, with ‘locations’ folder within; - Create output.aspx in template ‘HTTP_Import_Locations_From_SearchG2_Sample’, following content: Page Language="C#" Inherits="CrownPeak.Internal.Debug.OutputInit" %> Import Namespace="CrownPeak.CMSAPI" %> Import Namespace="CrownPeak.CMSAPI.Services" %> Import Namespace="CrownPeak.CMSAPI.CustomLibrary" %> <!--DO NOT MODIFY CODE ABOVE THIS LINE--> <% context.DisablePreviewCache = true; const string importEndPoint = " var assetSaveFolder = Asset.Load("/Samples/Data Import & Export Samples/Locations/"); var assetSaveModel = Asset.Load("/System/Models/Samples/SearchG2 Spatial Search/Location/Location"); var getHttpParams = new GetHttpParams {TimeOut = 300}; var getHttpResponse = Util.GetHttp(importEndPoint, getHttpParams); if (getHttpResponse.StatusCode >= 200 && getHttpResponse.StatusCode < 300) { var result = Util.LoadXml(getHttpResponse.ResponseText, "result").First(); foreach (var doc in result.XmlNodes) var docNodes = doc.XmlNodes; var assetData = new Dictionary<string, string>(); var assetName = docNodes.First(node => node.Attributes["name"] == "custom_s_name").Value; assetData.Add("name", assetName); assetData.Add("address", (docNodes.FirstOrDefault(node => node.Attributes["name"] == "custom_s_address") != null) ? docNodes.FirstOrDefault(node => node.Attributes["name"] == "custom_s_address").Value : String.Empty); assetData.Add("latitude", (docNodes.FirstOrDefault(node => node.Attributes["name"] == "custom_p_location") != null) ? docNodes.FirstOrDefault(node => node.Attributes["name"] == "custom_p_location").Value.Split(',')[0] : String.Empty); assetData.Add("longitude", (docNodes.FirstOrDefault(node => node.Attributes["name"] == "custom_p_location") != null) ? docNodes.FirstOrDefault(node => node.Attributes["name"] == "custom_p_location").Value.Split(',')[1] : String.Empty); assetData.Add("telephone", (docNodes.FirstOrDefault(node => node.Attributes["name"] == "custom_ss_tel_number") != null) ? docNodes.FirstOrDefault(node => node.Attributes["name"] == "custom_ss_tel_number").Value : String.Empty); assetData.Add("fax", (docNodes.FirstOrDefault(node => node.Attributes["name"] == "custom_ss_fax_number") != null) ? docNodes.FirstOrDefault(node => node.Attributes["name"] == "custom_ss_fax_number").Value : String.Empty); assetData.Add(" ", (docNodes.FirstOrDefault(node => node.Attributes["name"] == "custom_ss_ _address") != null) ? docNodes.FirstOrDefault(node => node.Attributes["name"] == "custom_ss_ _address").Value : String.Empty); var newAsset = Asset.CreateNewAsset(assetName, assetSaveFolder, assetSaveModel, assetData); Out.WriteLine("New asset created ({0}) with ID ({1}).", newAsset.Label, newAsset.Id); } %> - Run preview to import content. Next Steps: - Add logging; - Add check asset logic for update.

18 Exporting Data

19 IMPORTING / EXPORTING DATA
Lots of ways to export data from the CMS All require Developer Template to translate Asset content Uses Asset.Load() to pull in content from CMS Assets Uses Template Files to render content into required format Will require publication of content to the Delivery Server(s) ‘Be careful’ on initiating via ‘View Output’, as preview will also trigger the import – have necessary checking in your code.

20 EXPORTING DATA EXPORTING DATA - DEMO Deploy a new Custom Developer Template in order to export data from a folder of assets into a JSON file Define Asset Template Export data Demo Steps: - Create output.aspx in template ‘HTTP_Export_Locations_to _JSON’, following content: Page Language="C#" Inherits="CrownPeak.Internal.Debug.OutputInit" %> Import Namespace="CrownPeak.CMSAPI" %> Import Namespace="CrownPeak.CMSAPI.Services" %> Import Namespace="CrownPeak.CMSAPI.CustomLibrary" %> <!--DO NOT MODIFY CODE ABOVE THIS LINE--> <% context.DisablePreviewCache = true; const int modelId = 15830; var parameters = new FilterParams { FilterStatus = Util.MakeList(asset.WorkflowStatus.ToString()) }; var locations = asset.Parent.GetFilterList(parameters); var jsonOutput = new StringBuilder(); foreach (var location in locations.Where(location => location.CreatedFromModelId == modelId)) { jsonOutput.Append( String.Format("{{\n\t\"name\": {0},\n\t\"address\": {1},\n\t\"telephone\": {2},\n\t\"fax\": {3},\n\t\" \": {4},\n\t\"position\": {{\n\t\t\"latitude\": {5},\n\t\t\"longitude\": {6},\n\t\t\"zoom\": {7}\n\t}}\n}}", TidyForJson(location["name"], true), TidyForJson(location["address"], true), TidyForJson(location["telephone"], true), TidyForJson(location["fax"], true), TidyForJson(location[" "], true), TidyForJson(location["latitude"]), TidyForJson(location["longitude"]), TidyForJson(location["zoom"]) ) ); } Out.Write("{\"locations\":" + "[" + jsonOutput + "]" + "}"); %> <script runat="server" data-cpcode="true"> private static string TidyForJson(string source, bool addQuotes = false) var dest = source; if (string.IsNullOrEmpty(dest)) dest = string.Empty; dest = dest.Replace("\"", """); dest = dest.Replace("\r\n", "\n"); dest = new System.Text.RegularExpressions.Regex("\n+").Replace(dest, "\\n"); if (string.IsNullOrWhiteSpace(source) && !addQuotes) return "\"\""; return string.Format("{1}{0}{1}", dest, (addQuotes ? "\"" : "")); </script> - Create Index file in root of Locations, with Basic Workflow –> View Output to see JSON. Next Steps: - Add logging

21 Resources

22 IMPORTING / EXPORTING DATA
RESOURCES Playbooks – Available on CrownPeak Connect Best Practice Articles tices Discussion

23 Before we go… Your Feedback

24 We are here to hear your ideas and requests.
PARTNER SUMMIT - FEEDBACK We want your feedback! We are here to hear your ideas and requests. You have our ear - here at the conference, through support, through Connect. We want to open a dialogue that starts here and continues well beyond So please share your feedback cos we are always looking for ways to improve our product. Product improvements come from 3 channels- Product Management Innovations from Customer Success team- And of course Feedback and contributions from Developers like you Through conversation at the conference or by posting on Connect Product Management Customer Success Community Feedback Developers

25 Twitter Forums on Connect - FEEDBACK Template development
PARTNER SUMMIT - FEEDBACK Twitter @CrownPeak #CrownPeakPartners For ongoing discussions with the CrownPeak community on Template development User & Developer Experience Solutions and Extensions Product features & roadmap Hosting & Publishing Integrations Forums on Connect Twitter hashtag and QR Code <a href=" class="twitter-hashtag-button" data-related="CrownPeakHelp,CrownPeak">Tweet #CrownPeakPartners</a> <script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0],p=/^ 'script', 'twitter-wjs');</script> <img src=" d=https%3A%2F%2Ftwitter.com%2Fintent%2Ftweet%3Fbutton_hashtag%3DCrownPeakPartners" alt="QRCode"/> Forums QR code <img src=" alt="QRCode"/>

26     Access to Customer Success and Product Teams - FEEDBACK
PARTNER SUMMIT - FEEDBACK Access to Customer Success and Product Teams You have access the Product and Customer Success teams to give direct feedback on features and best practices Meet the team during the presentations and Q&A sessions Make suggestions – we are capturing it. Team members are armed with Post-its! Ask questions – We want to start a conversation that last well beyond the summit Any Questions? MEET THE TEAM MAKE SUGGESTIONS ASK QUESTIONS Partners and Developers

27 Partners and Developers
PARTNER SUMMIT - FEEDBACK FEEDBACK? Partners and Developers

28 CrownPeak + Web Experience Management
CrownPeak + Web Experience Management


Download ppt "IMPORTING & EXPORTING DATA"

Similar presentations


Ads by Google