Access/modify workspace documents by programming

cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
soeursourire
Member II

Access/modify workspace documents by programming

Hello!

Please could you help me?
Imagine that during the process of creating a new user I am stocking an XML file with all his data in the node person and the XML file is stored in Alfresco admin workspace. If I decide to get the xml from NewUserWizard and I modify it during the process of user creation by programmation, how can I be sure that its version will increase, how can I get the xml from my class (ContentStore?), is there a simple path to use for this xml as I guess this xml is stored in MySQL ?

Thanks in advance for your help
7 Replies
davidc
Active Member II

Re: Access/modify workspace documents by programming

Sorry, I don't understand your question.

To store content (such as XML), you can use the ContentService api to read and write.  If you want it versioned, add the VersionableAspect to the content node that represents the xml file.  If you want the xml content node to be associated with the person, you can add it as a child of the person, or associate it with the person (via the NodeService).  I believe there's already a child configuration folder under each person, so you could place the xml content node in there.

Like all content managed in Alfresco, it's stored in the file system - only content meta-data is stored in the database.

That might help.
soeursourire
Member II

Re: Access/modify workspace documents by programming

Thanks a lot for your help.
I have also a problem of permission in my system: I would like to allow a person to change the XML stored in the system via a jsp page but without letting this person looking at the XML. I explain:

Imagine that I am creating a workspace called "Hobbies" in admin space and in this workspace I store an XML file containing all possible hobbies.
-Then I create a procedure via a jsp page that allows admin to choose which hobbies are available and to add new hobbies and thus the hobbies will be stored in this XML
-but then I would like to allow a person of the Alfresco system to use this procedure to be the manager of hobbies for the system but I do not want that this manager access to the XML directly (can only access the jsp page). Is it possible? Can the user change the XML via jsp page athough he does not have access to the workspace?

Thanks again.
andy
Active Member

Re: Access/modify workspace documents by programming

Hi

If you create a service that encapsulates these actions you can protect it however you like with permisssions. The XML file could have admin only access via the node service. However, via your service you can,  if you choose, wire in sevices that allow you to take direct action on the XML. For example, an addHobby() API method using the unprotected node and content services.

Regards

Andy
soeursourire
Member II

Re: Access/modify workspace documents by programming

Sorry but I keep reading and reading your answer and do not really understand what you mean by "if you choose, wire in sevices that allow you to take direct action on the XML. For example, an addHobby() API method using the unprotected node and content services. " The node should be unprotected? How?

Do you think that, while the user choose the jsp page to choose hobbies, I could copy (doing a checkin of) the XML from the admin workspace into the user workspace and access to the XML without admin rights?

Thanks for your help.
andy
Active Member

Re: Access/modify workspace documents by programming

Hi

Apologies

I meant the unprotected "nodeService" as opposed to protected "NodeService". Similarly there are two beans "contentService" and "ContentService" the first does not check permissions, the second does. If you use the unprotected beans in your service implementation they will not check any permissions. The permission checking should be done around the API for your protected "HobbbyService" which itself would probably use a "hobbyService" bean.

I recommend you write a service. You could get the unprotected beans from the spring context.

Hope this clarifies things.

Regards

Andy
soeursourire
Member II

Re: Access/modify workspace documents by programming

Ah oki that explains why we have sometime nodeService with N or n:-)
Thanks! I think that will help me a lot!
soeursourire
Member II

Re: Access/modify workspace documents by programming

I was changing the browse.jsp and I realized that this code is really necessary to access to the current node :

<a:breadcrumb value="#{NavigationBean.location}" styleClass="headbarLink" />

Why does this code affect the call of methods such as startWizard of NewUserWizard? I do not understand..

Thanks