cannot create object by normal user

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-24-2013 12:14 AM
I am using Alfresco 4.2.c and opencmis 0.8.0. When I connect Alfresco by Admin user, then he can create object. But if logging in as a user who is not in administration group and the home space has been set as /Company Home, then "cmispermissiondeniedexception:forbidden" exception occurs while creating folder/document under Company Home. When I login as the same user from Alfresco console, this user can actually create objects under Company Home.
Code is :
Map<String, String> parameter = new HashMap<String, String>();
parameter.put(SessionParameter.USER, userName);
parameter.put(SessionParameter.PASSWORD, password);
parameter.put(SessionParameter.AUTH_HTTP_BASIC, "true");
parameter.put(SessionParameter.ATOMPUB_URL, "http://localhost:8080/alfresco/cmisatom");
parameter.put(SessionParameter.BINDING_TYPE, BindingType.ATOMPUB.value());
parameter.put(SessionParameter.OBJECT_FACTORY_CLASS, "org.alfresco.cmis.client.impl.AlfrescoObjectFactoryImpl");
// create session with the first (and only) repository
SessionFactory factory = SessionFactoryImpl.newInstance();
Session session = factory.getRepositories(parameter).get(0).createSession();
Map<String, String> newFolderProps = new HashMap<String, String>();
newFolderProps.put(PropertyIds.OBJECT_TYPE_ID, "cmis:folder");
newFolderProps.put(PropertyIds.NAME, "folderName");
Folder createdFolder = session.getRootFolder().createFolder(newFolderProps); //exception here
Code is :
Map<String, String> parameter = new HashMap<String, String>();
parameter.put(SessionParameter.USER, userName);
parameter.put(SessionParameter.PASSWORD, password);
parameter.put(SessionParameter.AUTH_HTTP_BASIC, "true");
parameter.put(SessionParameter.ATOMPUB_URL, "http://localhost:8080/alfresco/cmisatom");
parameter.put(SessionParameter.BINDING_TYPE, BindingType.ATOMPUB.value());
parameter.put(SessionParameter.OBJECT_FACTORY_CLASS, "org.alfresco.cmis.client.impl.AlfrescoObjectFactoryImpl");
// create session with the first (and only) repository
SessionFactory factory = SessionFactoryImpl.newInstance();
Session session = factory.getRepositories(parameter).get(0).createSession();
Map<String, String> newFolderProps = new HashMap<String, String>();
newFolderProps.put(PropertyIds.OBJECT_TYPE_ID, "cmis:folder");
newFolderProps.put(PropertyIds.NAME, "folderName");
Folder createdFolder = session.getRootFolder().createFolder(newFolderProps); //exception here
Labels:
- Labels:
-
Archive
7 REPLIES 7
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-24-2013 05:02 AM
Hello Nick,
By default the user home is set under /Company Home/User Homes/<UserName> where in the default permissions are set as ROLE_OWNER (allowed) and <user> (allowed) which is not the case under /Company Home.
By default the user home is set under /Company Home/User Homes/<UserName> where in the default permissions are set as ROLE_OWNER (allowed) and <user> (allowed) which is not the case under /Company Home.

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-24-2013 07:47 PM
Hi Sujay,
Thanks for the reply.
Actually when I create a user, I already set his home space as /Company Home/ instead of /Company Home/User Homes/
So when I log in as this user from Alfresco console, he can actually create any objects under /Company Home/, the problem happens when I try to do the same by java code as shown in first post.
Thanks for the reply.
Actually when I create a user, I already set his home space as /Company Home/ instead of /Company Home/User Homes/
So when I log in as this user from Alfresco console, he can actually create any objects under /Company Home/, the problem happens when I try to do the same by java code as shown in first post.
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-25-2013 02:24 AM
Hi Nick,
This code worked for me -
The only difference between yours and mine is the use of statement -
I was getting an error using it so ignored it.
Did you try to connect to your repository using the CMIS Workbench ?
When I connect using the same user i see the Allowable Actions for root folder [Company Home] as below -
This code worked for me -
public static void main(String[] args) { SessionFactory factory = SessionFactoryImpl.newInstance(); Map<String,String> parameters = new HashMap<String, String>(); parameters.put(SessionParameter.ATOMPUB_URL, "http://localhost:8080/alfresco/cmisatom"); parameters.put(SessionParameter.BINDING_TYPE, BindingType.ATOMPUB.value()); parameters.put(SessionParameter.AUTH_HTTP_BASIC, "true"); parameters.put(SessionParameter.USER, "testuser2"); parameters.put(SessionParameter.PASSWORD, "test123"); parameters.put(SessionParameter.REPOSITORY_ID, "8d6fe36d-a3e0-40f4-aece-4639647c9bc8"); Session session = factory.createSession(parameters); System.out.println(">>> " + session.getRootFolder().getName()); Map<String,String> folderProps = new HashMap<String, String>(); folderProps.put(PropertyIds.OBJECT_TYPE_ID, "cmis:folder"); folderProps.put(PropertyIds.NAME,"TestUser1234"); session.getRootFolder().createFolder(folderProps); }
The only difference between yours and mine is the use of statement -
parameters.put(SessionParameter.OBJECT_FACTORY_CLASS, "org.alfresco.cmis.client.impl.AlfrescoObjectFactoryImpl");
I was getting an error using it so ignored it.
Did you try to connect to your repository using the CMIS Workbench ?
When I connect using the same user i see the Allowable Actions for root folder [Company Home] as below -
- CAN_UPDATE_PROPERTIES
- CAN_GET_FOLDER_TREE
- CAN_GET_PROPERTIES
- CAN_GET_OBJECT_RELATIONSHIPS
- CAN_GET_DESCENDANTS
- CAN_GET_APPLIED_POLICIES
- CAN_GET_CHILDREN
- CAN_CREATE_DOCUMENT
- CAN_CREATE_FOLDER
- CAN_CREATE_RELATIONSHIP
- CAN_GET_ACL
- CAN_APPLY_ACL

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-25-2013 09:15 PM
Yes I did check the allowable ations before creating the folder. CAN_CREATE_FOLDER permission is there, but it still gives me error when creating.
While logging as Administrator works.
While logging as Administrator works.

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-26-2013 01:57 AM
I even removed
parameters.put(SessionParameter.OBJECT_FACTORY_CLASS, "org.alfresco.cmis.client.impl.AlfrescoObjectFactoryImpl");
But still no luck.
I need it in real scenario as I need some Alfresco defined Aspects.
parameters.put(SessionParameter.OBJECT_FACTORY_CLASS, "org.alfresco.cmis.client.impl.AlfrescoObjectFactoryImpl");
But still no luck.
I need it in real scenario as I need some Alfresco defined Aspects.
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-26-2013 04:12 AM
What release are you using? I used Release 0.8.0.

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-26-2013 06:32 PM
I used 0.8.0 as well. I even tried 0.9.0-beta1, but no luck.
It is very weird, as the parent folder has already have CREATE_FOLDER ability, the still failing.
And why it is working when logging in as Administrator?
It is very weird, as the parent folder has already have CREATE_FOLDER ability, the still failing.
And why it is working when logging in as Administrator?
