Monday, July 6, 2015

O365 - PointPublishing - Create a channel / pointpublishing site using javascript

In this post, we will see some of the technical details of the Office Video channels / PointPublishing site and creating a new Video channel / PointPublishing site using Javascript in the Office 365 Video portal.

When we create a channel within the Video portal,

  • Creates a new site collection using the POINTPUBLISHINGTOPIC#0 template.
  • Each channel / site collection is created as
    • http://<tenant>/portals/<channel>
  • Each channel contains the following list
    • http://<tenant>/portals/<channel>/_layouts/15/mcontent.aspx

  • All the videos uploaded are stored as the "Cloud Video" content type and the copy of the video is uploaded into the Azure media.

  • The channel settings are stored within the "Channel Settings" list.

  • Sample JSON data:
{  "Version": "1.0",  "PostType": 2,
"Title": "Office 365",
"SubTitle": "subtitle",
"ThumbnailSource": "?\u0026Height=144\u0026Group=PointPublishing",
"Author": "anonymous author",
"ControlData": {
"cid1435091429301378053": {
"Version": "1.0",
"IsInternalControl": true,
"ControlName": "ArticleHeaderControl",
"ControlType": 11,
"DataContext": {
"ImageControlSize": 12,
"ImageSourceType": 3,
"ImageSource": "",
"CaptionText": "",
"Title": "Office 365",
"Subtitle": "subtitle",
"Author": "Balamurugan Kailasam",
"PublishDate": "Tue Jun 23 2015 14:54:33 GMT+0100 (BST)",
"__type": "ImageHeaderControlDataContext"
},
"__type": "ControlData"
},
"cid143509142933596014": {
"Version": "1.0",
"IsInternalControl": true,
"ControlName": "RichTextControl",
"ControlType": 0,
"DataContext": {
"Subtype": 1,
"Value": "My first article",
"NoDefaultValue": false,
"__type": "TextControlDataContext"
},
"__type": "ControlData"
},
"cid1435091467898430486": {
"Version": "1.0",
"IsInternalControl": true,
"ControlName": "RichTextControl",
"ControlType": 0,
"DataContext": {
"Subtype": 1,
"Value": "Office 365 content\u003cbr\u003e",
"NoDefaultValue": false,
"__type": "TextControlDataContext"
},
"__type": "ControlData"
},
"cid1435092311439433690": {
"Version": "1.0",
"IsInternalControl": true,
"ControlName": "RichTextControl",
"ControlType": 0,
"DataContext": {
"Subtype": 1,
"Value": "",
"NoDefaultValue": false,
"__type": "TextControlDataContext"
},
"__type": "ControlData"
},
"cid1435091487994979407": {
"Version": "1.0",
"IsInternalControl": true,
"ControlName": "RichTextControl",
"ControlType": 0,
"DataContext": {
"Subtype": 1,
"Value": "",
"NoDefaultValue": false,
"__type": "TextControlDataContext"
},
"__type": "ControlData"
},
"cid1435091469088714729": {
"Version": "1.0",
"IsInternalControl": true,
"ControlName": "RichTextControl",
"ControlType": 0,
"DataContext": {
"Subtype": 1,
"Value": "",
"NoDefaultValue": false,
"__type": "TextControlDataContext"
},
"__type": "ControlData"
},
"cid143509146986680419": {
"Version": "1.0",
"IsInternalControl": true,
"ControlName": "RichTextControl",
"ControlType": 0,
"DataContext": {
"Subtype": 1,
"Value": "",
"NoDefaultValue": false,
"__type": "TextControlDataContext"
},
"__type": "ControlData"
},
"cid1435091464093905470": {
"Version": "1.0",
"IsInternalControl": true,
"ControlName": "RichTextControl",
"ControlType": 0,
"DataContext": {
"Subtype": 1,
"Value": "",
"NoDefaultValue": false,
"__type": "TextControlDataContext"
},
"__type": "ControlData"
},
"cid1435091429338210015": {
"Version": "1.0",
"IsInternalControl": true,
"ControlName": "DocumentHookControl",
"ControlType": 8,
"DataContext": {
"OfficeDocumentDataContext": {
"DocId": "100794310",
"ImpressionId": "",
"Title": "Document",
"FullDocumentUrl": "http://ift.tt/1TgpCn2",
"Summary": "Last Modified On Mon Nov 23 2009",
"DocLibTitle": "Balamurugan Kailasam",
"DocPath": "http://ift.tt/1KKOIY7",
"FileType": 2,
"DocumentPreviewHeight": 225,
"DocumentPreviewWidth": 300,
"DocumentPreviewImageUrl": "/_layouts/15/getpreview.ashx?guidFile={CECC796B-AD72-44A4-87D9-8D65640E6D07}\u0026guidSite={4fe63a08-5634-4d63-8006-d83e89c3fa9c}\u0026guidWeb=ccdfc405-ba62-437a-97d1-a081b0b2a140\u0026docid=100794310\u0026metadatatoken=\u0026ClientType=DelveWeb",
"Author": null,
"ModifiedTime": "\/Date(1435093231837)\/",
"__type": "DocumentCardDataContext"
},
"Annotation": "",
"ResponsiveModeEnabled": false,
"__type": "DocumentHookDataContext"
},
"__type": "ControlData"
}
},
"ControlMap": {
"Rows": [
{
"Columns": [
{
"ControlId": "cid1435091429301378053",
"HasChildren": false
}
]
},
{
"Columns": [
{
"HasChildren": false,
"ControlId": "cid143509142933596014"
}
]
},
{
"Columns": [
{
"HasChildren": false,
"ControlId": "cid1435091467898430486"
}
]
},
{
"Columns": [
{
"HasChildren": false,
"ControlId": "cid1435092311439433690"
}
]
},
{
"Columns": [
{
"HasChildren": false,
"ControlId": "cid1435091487994979407"
}
]
},
{
"Columns": [
{
"HasChildren": false,
"ControlId": "cid1435091469088714729"
}
]
},
{
"Columns": [
{
"HasChildren": false,
"ControlId": "cid143509146986680419"
}
]
},
{
"Columns": [
{
"HasChildren": false,
"ControlId": "cid1435091464093905470"
}
]
},
{
"Columns": [
{
"HasChildren": false,
"ControlId": "cid1435091429338210015"
}
]
}
],
"GridSize": 12,
"__type": "ControlMap"
},
"__type": "PersistedPostModel"
}

Create a channel / PointPublishing site collection:

So to create a channel, we have to create a site collection using the POINTPUBLISHINGTOPIC#0 template and the status of the site can be checked using the GetSiteStatus rest api available within the publishingsitemanager. The below script creates the channel with the specified name.

function createChannel(channelName){    
var executor = new SP.RequestExecutor("https://<tenant>/portals/hub"); executor.executeAsync( {
url: "https://<tenant>/portals/hub/_api/publishingsitemanager/create",
method: "POST",
headers: { "content-type": "application/json;odata=verbose","Accept": "application/json; odata=nometadata" },
body:JSON.stringify({ 'siteInfo' : {'__metadata':{ 'type':'SP.Publishing.PublishSiteInformation' }, 'Title':channelName, 'SiteType':'4'}}),
success: function(data){
},
error: function(data, errorCode, errorMessage){
}
});
}
// Expected namespace after loaded
var namespace = "SP.RequestExecutor";
// SOD Key of target js file
var key = "sp.requestexecutor.js";
// Load straight away, or in queue
var bSync = false;
SP.SOD.executeFunc(key, namespace, function () {
createChannel(Channel O365);
}, bSync);
  • Request: The above script sends the below request to create the pointpublishing site / channel.
siteInfo: {  __metadata: {    type: "SP.Publishing.PublishSiteInformation"
},
Title: "O365 Channel",
SiteType: "4"
}SiteType: "4"Title: "O365 Channel"__metadata: {
type: "SP.Publishing.PublishSiteInformation"
}type: "SP.Publishing.PublishSiteInformation"
  • Response: Returns the SiteStatus information.
{  "FriendlyUrl": "http://ift.tt/1TgpCDk",  "SiteId": "00000000-0000-0000-0000-000000000000",
"SiteUrl": "http://ift.tt/1KKOIYb",
"Status": 3
}
  • ScreenShot: 

Get the PointPublishing site status:

Sometimes the site collection creation takes time and the status of the site can be checked using the "_api/publishingsitemanager/GetSiteStatus" rest api.

  • Request:
    • Rest end point: portals/hub/_api/publishingsitemanager/GetSiteStatus?siteInfo=%7B%27Title%27:%27O365%20Channel%27,%20%27SiteType%27:%274%27,%20%27SiteUrl%27:%27%27%7D
    • GET
    • Pass the Site Title or the Url in the query as mentioned below:
      • siteInfo: {'Title':'O365 Channel', 'SiteType':'4', 'SiteUrl':''}
  • Response: Returns the SiteId, FriendlyUrl and the Status.
<?xml version="1.0" encoding="UTF-8"?><entry xmlns="http://ift.tt/r5ut6F" xmlns:d="http://ift.tt/1cVQIMf" xmlns:georss="http://ift.tt/N7lROd" xmlns:gml="http://ift.tt/WaETtx" xmlns:m="http://ift.tt/1dtZymv" xml:base="http://ift.tt/1TgpCDv">   <id>https://<tenant>http://.sharepoint.com/portals/hub/_api/publishingsitemanager/GetSiteStatus</id>
<category term="SP.Publishing.PointPublishingSiteStatus" scheme="http://ift.tt/1aFoa69" />
<link rel="edit" href="publishingsitemanager/GetSiteStatus" />
<title />
<updated>2015-07-04T10:23:42Z</updated>
<author>
<name />
</author>
<content type="application/xml">
<m:properties>
<d:FriendlyUrl>https://<tenant>http://.sharepoint.com/portals/hub/O365-Channel</d:FriendlyUrl>
<d:SiteId m:type="Edm.Guid">ff48f982-88dc-4746-b6d5-d32f703e3d7a</d:SiteId>
<d:SiteUrl>http://ift.tt/1TgpCDx</d:SiteUrl>
<d:Status m:type="Edm.Int32">2</d:Status>
</m:properties>
</content>
</entry>

Looking forward about this NextGen Portals within the Office 365 and more details about the NextGen portal can be found on Chris O'Brien - Info and some thoughts on Office 365 “NextGen” portals – Microsites, Boards and the Knowledge Management portal .


by Balamurugan Kailasam via Everyone's Blog Posts - SharePoint Community

No comments:

Post a Comment