Search code examples
javaalfrescocmisopencmisapache-chemistry

Create Site in Alfresco using the Apache Chemistry


Greetings to the community! I am using alfresco Community Edition 6.0.0 with the Apache Chemistry API. I have successfully managed so far to create/fetch content from the alfresco repository through it (Folder and Document files).

Now what I would like to do is use the Apache Chemistry API to create an alfresco site (like I would do using the alfresco/api/-default-/public/alfresco/versions/1/sites POST method in the Alfresco REST API).

Is that feasible?? What I have done following the way I already created folders in the repository is:

Folder folder = retrieveSitesFolder(); // this returns the folder object using the node id of the "Sites" node
Map<String, Object> props = new HashMap<String, Object>();
props.put(PropertyIds.OBJECT_TYPE_ID, "F:st:site"); //this is recognized fine
props.put("st:siteVisibility", "PUBLIC");
props.put("st:sitePreset", "something");
props.put("cmis:name", "something"); 
Folder subFolder = folder.createFolder(props);

I am following the site model from here concerning the properties I add https://svn.alfresco.com/repos/alfresco-open-mirror/alfresco/COMMUNITYTAGS/V4.2a/root/projects/repository/config/alfresco/model/siteModel.xml

Unfortunately, when I run this piece of code I get the following error:

Exception in thread "main" org.apache.chemistry.opencmis.commons.exceptions.CmisRuntimeException: 10290059 Site something does not exist.

which seems to me very strange as what I expect my code to do is create that site not search for it in anyway.

What makes this more strange is when I created a site with name "something" via the REST API and re-run the code, the code run successfully, but I did not get any extra site in the alfresco/api/-default-/public/alfresco/versions/1/sites endpoint of the REST API.

Could anyone shed some light on this please? Any help would be greatly appreciated!


Solution

  • As Gagravarr says the API hasn't supported creating functional sites until, as Billerby pointed out, the REST API made some improvements.

    Apache Chemistry has no idea what a site is, but, as you've discovered, an st:site is just a child type of cm:folder.

    Despite that this is most likely not going to work via CMIS, I wanted to point out that you are using "something" for site preset. That is not going to work unless you've defined a new site preset called "something".

    By default, there is a single out-of-the-box site preset called "site-dashboard" which is the ID for the "Collaboration Site" preset.

    You might change your st:sitePreset to "site-dashboard" and see if you get any further.