cancel
Showing results for 
Search instead for 
Did you mean: 

Automatic site creation : surf-config not generated

tonyrivet
Champ in-the-making
Champ in-the-making
Hi everyone,

I would like to create a workflow task which could automatically create a Share site on transition.

I have created a Java JBPM action (extending JBPMSpringActionHandler), executed in my workflow task transition.
As the site pages creation must be done on the Share side, this action simply makes a remote call to the create site Share module:

   
RemoteClient remote = new RemoteClient(); 
   remote.setEndpoint("http");
   remote.setRequestMethod(HttpMethod.POST);
   remote.setRequestContentType("application/json");
   remote.setTicket(ticket);
                  
   Map<String, String> properties = new HashMap<String, String>();
   properties.put("shortName", siteShortName);
   properties.put("sitePreset", sitePreset);
   properties.put("title", siteTitle);
   properties.put("description", siteDesc);
   properties.put("visibility", "PUBLIC");
   properties.put("ticket", ticket);

   JSONObject json = new JSONObject(properties);
                  
   Response response = remote.call("http://localhost:8080/share/service/modules/create-site", json.toString());

I have also extended the create-site module to forward the session ticket to the site creation request:

   if(clientJSON.ticket)
   {
      repoResponse = scriptRemoteConnector.post("/api/sites?alf_ticket="+clientJSON.ticket, clientRequest, "application/json");
   }
   else
   {
      repoResponse = scriptRemoteConnector.post("/api/sites", clientRequest, "application/json");
   }

The action is executed well and the site seems to be correctly created : it appears in the sites list and I can access to the site pages.
However, the created "st:site" node does not contain the surf configuration ("surf-config" node) useful to access the site pages, which must be generated when calling the
"sitedata.newPreset()" method in the module…
And indeed, after restarting the server, the site is not accessible anymore…

It's quite weird because I think I am doing exaclty the same way as a manual site creation (i.e. calling the create-site Share module), and the manual site creation is working perfectly.

So I would like to know if someone has a clue on why the "surf-config" node isn't generated ?
All information about automatic site creation is welcomed !

Thank you in advance.
10 REPLIES 10

joraff
Champ in-the-making
Champ in-the-making
FYI, ever since the CSRF filter was included you must modify that filter if you're going to be POSTing from a different server.

What I did was copy the CSRFPolicy config section from share-security-config.xml to share-custom-config.xml

Update the config string to read
<config evaluator="string-compare" condition="CSRFPolicy" replace="true">


Then add a rule in the filter section (in the first position) like this:


<rule>
  <request>
    <method>POST</method>
    <path>/service/modules/create-site</path>
  </request>
  <action name="assertReferer">
    <param name="always">false</param>
  </action>
  <action name="assertOrigin">
    <param name="always">false</param>
  </action>
</rule>


This disabled the referer and origin url checks for create-site. Might not be the best way to go - open to other suggestions - but it now works for me again.

More info here: http://blogs.alfresco.com/wp/ewinlof/2013/03/11/introducing-the-new-csrf-filter-in-alfresco-share/