cancel
Showing results for 
Search instead for 
Did you mean: 

documentLibrary not visible after creating site in Share

horia
Champ in-the-making
Champ in-the-making
Hi,

I have a problem identifying the root folder <strong>documentLibrary</strong> after creating a new site.
I'm using a POST command to create a new site (to service/modules/create-site) and everything looks fine, the site is there. However, listing the folders show that there is no defaultLibrary. I need its ID in order to create new folders on the site visible on the web pages of Alfresco share.

My impression is that the documentLibraryis only created when you access the site on the web. Any ideas?


Thanks

EDIT: the correct name is documentLibrary
4 REPLIES 4

rjohnson
Star Contributor
Star Contributor
I suspect you mean documentLibrary.

If you POST to the create-site script then that should generate you a site based on the template you request becase all that the Share "Create Site" dashlet does is that POST.

How are you calling the POST and what is the response from the script?

horia
Champ in-the-making
Champ in-the-making
Hi Bob,

The name is documentLibrary, you're right.
I'm posting an HttpEntity formed out of a list of properties (username, password). There is no template in there.
Is there any way to pass a template accepted by share?

Thanks

santoshbaradwaj
Champ in-the-making
Champ in-the-making
Yes Mr.Horia,
After creating site the appropriate preset will added to it.
through share UI when you trying to access the document Library .the service will create the documentLibrary node under site node.

rjohnson
Star Contributor
Star Contributor
I wrote my own version of My Sites which included the ability to create a site. There was a fair bit of code in that dashlet, but below is the code that actually creates the site. All it does is call the same webscript that the regular Share dashlet calls when you do a create site. Provided you pass all the proper data it should generate you a fully functional site. The site creation start when the user has filled in a form and clicks "Create" at which point the function onDBAR is executed…. You can track it from there its dead easy. Visiblility is PUBLIC, Title is whatever you want, shortName must be all lower case and have no spaces or special characters, description is just text and sitePreset must be the name of a preset that exists in presets.xml. The name is the id.


     /**
      * Set busy and create base site
      */
      onDBAR: function FGCreateSiteMgr_onDBAR(p_form, obj) {
         this.submittedForm = p_form;
         this._setBusy(this.msg("fg-create-site-mgr.create.creating"));      
         // Call the site create
         var jsonSite = {
               visibility: this.siteVisibility,
               title: p_form.dataObj[this.siteTitle],
               shortName: p_form.dataObj[this.siteTitle],
               description: p_form.dataObj[this.siteDescription],
               sitePreset: this.sitePreset
         }
         var actionURL = YAHOO.lang.substitute("/share/service/modules/create-site");
         Alfresco.util.Ajax.request(
                {
                    url: actionURL,
                     method: Alfresco.util.Ajax.POST,
                     dataObj: jsonSite,
                     requestContentType: Alfresco.util.Ajax.JSON,
                     responseContentType: Alfresco.util.Ajax.JSON,
                    successCallback:
                    {
                       fn: this._siteCreated,
                        scope: this
                    },
                    failureCallback:
                    {
                        fn: this._createSiteFailed,
                        scope: this
                    },
                    scope: this,
                    noReloadOnAuthFailure: true
                 });
         // This kills the AJAX processing of the form and allows me
         // to do my own submit control.
         return false;
      },
      _siteCreated: function FGCreateSiteMgr__siteCreated()
      {
         this._releaseBusy();
        Alfresco.util.PopupManager.displayMessage(
         {
            text: this.msg("fg-create-site-mgr.create.complete"),
             spanClass: "wait",
             displayTime: 0
         });
       var responseJSON = eval('(' + response.serverResponse.responseText + ')');       
         if (responseJSON) {
            // Now, where do we go "none" means go to the site dashboard
           var navigateTo = "";
          if(responseJSON.navigateTo == "none") {
               navigateTo = "/share/page/site/" + responseJSON.shortName + "/dashboard";
          } else {
                navigateTo = "/share/page/site/" + responseJSON.shortName + "/create-content?destination=" + responseJSON.nodeRef + "&itemId=" + responseJSON.navigateTo + "&mimeType=text/plain";
          }
            window.location.href = navigateTo;            
         }
      },
     
      _createSiteFailed: function FGCreateSiteMgr__createSiteFailed(response)
      {
           this._releaseBusy();
         var errorMsg = this.msg("fg-create-site-mgr.create.failed");
         if((response.serverResponse.status != 200) && (response.serverResponse.status != 500)) {
               errorMsg = errorMsg + ": " + response.serverResponse.status + " " + response.serverResponse.statusText;           
         }
        if (response.json.message) {
           var ourMsg = this.msg(response.json.message);
           errorMsg = errorMsg + ": " + ourMsg;
        }
         Alfresco.util.PopupManager.displayPrompt(
         {
            title: this.msg("message.failure"),
            text: errorMsg
         });
      },

      /**
       * Tell the world we are doing something
       */
      _setBusy: function FGCreateSiteMgr__setBusy(busyMessage)
      {
         if (this.busy)
         {
            return false;
         }
         this.busy = true;
         this.widgets.busyMessage = Alfresco.util.PopupManager.displayMessage(
         {
            text: busyMessage,
            spanClass: "wait",
            displayTime: 0
         });
         return true;
      },

      /**
       * Removes the busy message and marks the component as non-busy
       *
       * @method _releaseBusy
       */
      _releaseBusy: function FGCreateSiteMgr__releaseBusy()
      {
         if (this.busy)
         {
            this.widgets.busyMessage.destroy();
            this.busy = false;
            return true;
         }
         else
         {
            return false;
         }
      }