1 Reply Latest reply on Oct 4, 2016 6:06 AM by adave004

    Problem when I'm creating multiple spaces from Jive

    dpuscau

      Hi all,

       

      My task is to create with node.js multiple space and subspaces in Jive, taking data from database.

       

      In a already created space, I have to create from code 5 subspaces and in them another 472 subspaces.

       

      When I'm creating one space (node code below):

      function createSpace(radford, displayName, parentUrl, callback)

      {

          var deferred = q.defer();

       

          formatSubject(radford['job_profile_title'], radford['department']).then(function(subject) {

              var data = {

                      parent      : parentUrl,

                      type        : 'space',

                      name        : radford['job_profile_title'],

                      displayName : displayName

                  };

       

       

              var post_data    = JSON.stringify(data);

              var post_options = {

                      host:    config.basicUrl,

                      port:    443,

                      path:    placeUrl,

                      method:  'POST',

                      headers: {

                          'Authorization': basicAuth,

                          'Content-Type':  'application/json'

                      }

              };

       

       

              var post_req = https.request(post_options, function(res) {

                  res.setEncoding('utf8');

                  var str = '';

                  res.on('data', function (chunk) {

                      str += chunk;

                  });

                  res.on('end', function () {

                      var input1 = '<HTML><HEAD>';

                      var input2 = '<!DOCTYPE';

                      if(str.substring(0, input1.length) === input1 || str.substring(0, input2.length) === input2) {

                          console.log('System Error');

                          var parse_str = { erorr: { status: 404, message: 'System Error'}};

                          deferred.resolve(parse_str); 

                      } else {

                          try {

                              var parse_str = JSON.parse(str);

                              deferred.resolve(parse_str);

                          } catch(err) {

                              console.log('Error createSpace:');

                              console.log(err);

                              deferred.reject(err);  

                          }

                      }

                  });

              });

       

              post_req.on('error',function(err){

                  console.log('Error');

                  console.log(err);

                  deferred.reject(err);

              });

       

              var rsp = post_req.write(post_data);

              post_req.end();

       

          }, function (error) {

              console.error('Handle error: ' + error);

              deferred.reject(new Error(error));

              throw error;

          });

          deferred.promise.nodeify(callback);

          return deferred.promise;

      }

      I'm getting this response from it:

       

       

      {

        "id" : "11553",

        "resources" : {

          "entitlements" : {

            "allowed" : [ "GET" ],

            "ref" : "https://mdsol-sandbox.jiveon.com/api/core/v3/places/50081/entitlements"

          },

          "followingIn" : {

            "allowed" : [ "POST", "GET" ],

            "ref" : "https://mdsol-sandbox.jiveon.com/api/core/v3/places/50081/followingIn"

          },

          "activity" : {

            "allowed" : [ "GET" ],

            "ref" : "https://mdsol-sandbox.jiveon.com/api/core/v3/places/50081/activities"

          },

          "avatar" : {

            "allowed" : [ "POST", "DELETE", "GET" ],

            "ref" : "https://mdsol-sandbox.jiveon.com/api/core/v3/places/50081/avatar"

          },

          "blog" : {

            "allowed" : [ "DELETE", "PUT", "GET" ],

            "ref" : "https://mdsol-sandbox.jiveon.com/api/core/v3/places/50082"

          },

          "statics" : {

            "allowed" : [ "POST", "GET" ],

            "ref" : "https://mdsol-sandbox.jiveon.com/api/core/v3/places/50081/statics"

          },

          "places" : {

            "allowed" : [ "GET" ],

            "ref" : "https://mdsol-sandbox.jiveon.com/api/core/v3/places/50081/places"

          },

          "followers" : {

            "allowed" : [ "GET" ],

            "ref" : "https://mdsol-sandbox.jiveon.com/api/core/v3/places/50081/followers"

          },

          "pages" : {

            "allowed" : [ "POST", "GET" ],

            "ref" : "https://mdsol-sandbox.jiveon.com/api/core/v3/places/50081/pages"

          },

          "contents" : {

            "allowed" : [ "POST", "GET" ],

            "ref" : "https://mdsol-sandbox.jiveon.com/api/core/v3/places/50081/contents"

          },

          "appliedEntitlements" : {

            "allowed" : [ "GET" ],

            "ref" : "https://mdsol-sandbox.jiveon.com/api/core/v3/places/49998/appliedEntitlements"

          },

          "self" : {

            "allowed" : [ "DELETE", "PUT", "GET" ],

            "ref" : "https://mdsol-sandbox.jiveon.com/api/core/v3/places/50081"

          },

          "html" : {

            "allowed" : [ "GET" ],

            "ref" : "https://mdsol-sandbox.jiveon.com/community/radford2/us11"

          },

          "featuredContent" : {

            "allowed" : [ "GET" ],

            "ref" : "https://mdsol-sandbox.jiveon.com/api/core/v3/places/50081/contents/featured"

          },

          "categories" : {

            "allowed" : [ "POST", "GET" ],

            "ref" : "https://mdsol-sandbox.jiveon.com/api/core/v3/places/50081/categories"

          },

          "extprops" : {

            "allowed" : [ "POST", "DELETE", "GET" ],

            "ref" : "https://mdsol-sandbox.jiveon.com/api/core/v3/places/50081/extprops"

          },

          "announcements" : {

            "allowed" : [ "POST", "GET" ],

            "ref" : "https://mdsol-sandbox.jiveon.com/api/core/v3/places/50081/announcements"

          }

        },

        "followerCount" : 1,

        "followed" : true,

        "published" : "2015-10-30T15:05:50.125+0000",

        "tags" : [ ],

        "updated" : "2015-10-30T15:05:50.125+0000",

        "iconCss" : "jive-icon-space",

        "placeID" : "50081",

        "contentTypes" : [ "blog", "2901s", "documents", "files", "discussions", "polls", "projects", "extStreamActivities", "events", "ideas", "videos" ],

        "description" : " ",

        "displayName" : "us11",

        "name" : "US11",

        "parent" : "https://mdsol-sandbox.jiveon.com/api/core/v3/places/49998",

        "status" : "Active",

        "viewCount" : 1,

        "visibleToExternalContributors" : false,

        "placeTopics" : [ ],

        "childCount" : 0,

        "locale" : "en",

        "inheritsAppliedEntitlements" : true,

        "type" : "space",

        "typeCode" : 14

      }

      Meaning the space is created. But actually Jive didn't finish creating that space. Sometimes, from the next space created I get this message:

       

      { status: 503,

        message: 'A place creation or deletion request is currently in progress. Please wait for this to finish before creating or deleting a place.' }

       

      I added a sleep function to wait before the next createSpace() function is created:

      sleep.sleep(10);

      But I still receive that error sometimes.

       

      How do I know when is the right time to create the next space? Is JIVE API has a check function? Is it any limit in creating subspaces via the JIVE REST API?

      I broken one the JIVE instance when I ran my script (The data structure defining the parent/child relationship between spaces is in an inconsistent state )

       

      Regards,

      Diana

        • Re: Problem when I'm creating multiple spaces from Jive
          adave004

          Hi Diana Puscau,

           

          I've come across your query above and can confirm that we've had the same problem with our instance. In fact, we have a space structure much like yours as described above (with over 400 spaces living in one mother space).

           

          We have seen inconsistent behaviour in the creation and deletion of sub-spaces recently, which indicate that on creation of a space, application of permissions and other back end processing etc have shown up as delayed on the Audit Logs, causing even more odd behaviour.

           

          I see you've posted a private case regarding inconsistency of space states above. I'd be very keen to hear if you have any tips or lessons learnt regarding this inconsitency.

           

          I'd be happy to continue the discussion via private messaging to learn more.

           

          Thanks,

           

          Regards,

           

          Avnee