Hi, My problem occured during the creation of a site using java webscript . I can create a site with this code.
protected Map<String, Object> executeImpl(WebScriptRequest req, Status status, Cache cache) { String siteID = "site_test"; SiteInfo siteinfo = null; try { siteinfo = createSite(siteID); System.out.println(siteinfo); } catch (SiteServiceException e2 ) { //e2.printStackTrace(); System.out.println("SITE: " + siteID + " already exists!"); } Map<String, Object> model = new HashMap<String, Object>(); model.put("result", "true"); //System.out.println("end"); return model; }
After the execution of the webscript, using above code, site is created but only in repo.
Problem is that when I sign in into alfresco share this error occures in command line:
and this appers in share:
and the site I created in repo did not show up in share.
I am using Alfresco 6.2. Can somebody help me fix this error and create a functional site in share as well as in repo ?
Do I need to add some code to different files?
Or is there any other way to create a site in java that will appear in alfresco share?
The error is expected as site also expect surf objects based on the site preset you are using. These are also called site data.
Creating site via java backed webscript would create the site node but would setup site data for the site you just created.
Take a look at this thread and see if it helps:
Thanks @abhinavmishra14 for your answer. I read more about it and I decided to have repo webscript.
In link you sent me I found what to do in case I chose surf webscript, but It is not clear to me what to do when I want to use repo webscript. Can you help me?
Thanks.
You would have to write logic to import the surf-config from within your java backed webscript. SiteService allows to create site but it doesn't setup surf-config which is required for every site.
Check the surf config used for default site preset here: https://github.com/Alfresco/alfresco-repository/tree/master/src/main/resources/alfresco/bootstrap/si...
Make sure you have appropriate surf-config setup for your site presets. Check the link given above. If you use the above given surf-config as is, it will setup surf config for default site preset always. so make sure you make changes accordingly and bootstrap the surf-config.
Check this class and bean definition which is used to import surf-config for default site.
If you are using default site preset (i.e. 'site-dashboard') provided by alfresco, you can use this OOTB rest api which creates the site and setup surf-config by default. If you are using default site preset, then writing a custom webscript for creating site is not required.
https://docs.alfresco.com/6.1/concepts/dev-api-by-language-alf-rest-manage-sites-create.html
Example:
POST: http://localhost:8080/alfresco/api/-default-/public/alfresco/versions/1/sites?alf_ticket=TICKET_4ad80403182aac65b38d69efa88998814c6d80be
Payload:
{ "id": "test-site", "title": "Test site", "description": "Test site desc", "visibility": "PUBLIC" }
Ask for and offer help to other Alfresco Content Services Users and members of the Alfresco team.
Related links:
By using this site, you are agreeing to allow us to collect and use cookies as outlined in Alfresco’s Cookie Statement and Terms of Use (and you have a legitimate interest in Alfresco and our products, authorizing us to contact you in such methods). If you are not ok with these terms, please do not use this website.