Hi Jivers,

In jive 5 and jive 6, we had a custom java plugin called Moved Content which enabled us to move contents from one group / space to other in bulk.

As Jive 7 arrived, we decided to create add-on for the same feature to get rid of plugins and get advantage of the easy development and deployment that jive-sdk has.

We have this working on our production site.

 

The Add-on

This add-on is totally based on jive's javascript apis.

I have some other apps which use combination of javascript apis on website and REST api through a connected node service.

Thats how I have modified Ryan Rutan's admin essentials to control google group memberships and stream associations from jive.

I will share that soon..

 

How the app looks


Displaying the content in current place as per selected filter options and picker for target place at the top.

First is the blog posts view.

Internally in jive, blog posts are not linked directly to a group but to a place type called blog, which is then linked to the parent group.

So keeping two separate views to avoid complexity


Screen Shot 2015-01-09 at 1.47.31 PM.png


Showing all other supported content types on other pane


Screen Shot 2015-01-09 at 1.47.43 PM.png


Showing the progress post processing



Screen Shot 2015-01-09 at 2.37.38 PM.png


 

Our dev Krunal Patel helped me design the UI.

 

Some Code

The code I have shared here is the simplest possible javascript code coz my intention is to help anyone with basic JS knowledge to understand and use this app and jive-sdk.

Trust me, with basic knowledge of javascript and jquery and jive's apis, you can create wonders.

You can use some promises and other jquery utils  to beautify the code below.

 

First the user is provided with place pickers to select source and target places.

 

var displaySourcePlacePicker = function(){
    osapi.jive.corev3.places.requestPicker({
        success : function(data) {
            $("#toGroup").val(data.name);
            $("#toGroup").attr("data-groupid", data.placeID);
        }
    });
}




Then user can select content types as shown in screenshot.

 

On either selection of source group or content types, I refresh the content by making a new api call to jive with content types.

I push every selected content type in array contentTypes to be sent to jive api.

And I send the groupID, contenttypes array and current index to the method below.


var displayContentInGroup = function (groupId, contentTypes, index){
    osapi.jive.corev3.contents.get({
        "place":opensocial.getEnvironment()['jiveUrl']+"/api/core/v3/places/"+groupId,
        "type":contentTypes.join(","),
        "startIndex":index.toString(),
        "count":itemsPerPage.toString()
    }).execute(function(data){
        $("#content-body").html("");
        var contentList = [];
        if(data.list.length != 0){
            contentList.push(createHtml(data, $("#selectAll:checked").val()));
            if (data.links && data.links.next)
                setupNextPaginationButton(index+itemsPerPage);
            if (data.links && data.links.previous)
                setupPrevPaginationButton(index-itemsPerPage);
        } else {
            contentList.push("<tr> \n<td colspan=4> <h3>No content to display</h3> </td> \n</tr>");
        }
        $("#content-body").append(contentList.join(""));
    });
};





After the user selects the contents and clicks Move Content button, I call this function.

 

var moveContent = function(targetGroupId){
    var contentIds = getIdsForSelectedContent();

        for (var i in contentIds){
            content_url = opensocial.getEnvironment()['jiveUrl']+"/api/core/v3/contents/"+contentIds[i]
            osapi.jive.corev3.contents.get({"uri":content_url}).execute(function(data){
                data.parent = opensocial.getEnvironment()['jiveUrl']+"/api/core/v3/places/"+$("#toGroup").attr("data-groupid");
                data.update().execute(function (data) {
                    if(i == (contentIds.length-1)){
                        displaySuccessMessage("Successfully Moved the content");
                        refreshContentList();
                    }
                });
            })
        }
};





The above api calls changes the parent place without changing the date of the content.

And no notification is shown in activity stream for this action, so its a silent move.

 

Please find the initial version of my move content app here --> Move-content-app by shahpawan

 

Special thanks to shilpa kondawar to help me with this and all the other jive add-ons we developed for Thoughtworks

 

Enjoy node.js and jive_sdk.

Node.js has awesome possibilities, and hence now Jive has awesome possibilities.

 

Note : For people on jive cloud version 8c4+, you can just download the extension.zip attached with this blog and upload it to jive instance.

No need to download the source code, no node server required to build it locally.