cancel
Showing results for 
Search instead for 
Did you mean: 

Adding Custom metadata dynamically through Java Found API

pramodkhare
Champ in-the-making
Champ in-the-making
I am new to Alfresco development. So please need help with this.

Hi currently I am developing web-UI in ExtJS for Alfresco 4.0 using Java Foundation API. Our total application is really big and we want to build a Document Mgmt Module, so we are using Alfresco at backend as doc-repository.

Basically, I am creating a new ExtJS UI which will internally connect with Alfresco Java Foundation API services. (i.e. ExtJS UI –> Struts Controller Action classes – > Some Custom/helper Classes—>Alfresco Java Services), we will be using Alfresco in embedded deployment mode.

I have a doubt - I want to add as many custom-metadata fields to a documents as user wants, I don't want to change Content Model.

From what I know is, we can achieve above feature by dynamically adding Aspects to document, and these aspects will have properties.

But my question is how to create these aspects dynamically, through java Foundation API.
As I am not using Alfresco-Explorer or Share as my UI, I am just using Core repository.

I know there are few approaches for Alfresco Explorer like adding new content model xml in alfresco/extension folder, or adding new aspect xml to this folder and restarting server. But I don't have that here.

I want to create a new aspect dynamically through Java Foundation API, and without server restart.

Any input is appreciated. If my approach is wrong then please suggest what should be the correct one.
If this query is already been raised by someone pls let me know that post's url.
ANY ANY HELP IS REALLY APPRECIATED.

Thanks
3 REPLIES 3

jpotts
World-Class Innovator
World-Class Innovator
You will still have to create the XML, but you can do that with code. Instead of putting the content model on the file system, which would require a restart, put it in the data dictionary. See http://wiki.alfresco.com/wiki/Dynamic_Models#Dynamic_models.

Jeff

pramodkhare
Champ in-the-making
Champ in-the-making
Really Thanks Jeff.

I need to ask few more things, -

1) Basically I want to add custom-metadata i.e. Properties to a document (properties which are not specified in my content model), apart from new Aspect/Content Model Creation, is there any other way of doing this?? i.e. Adding custom properties to a content (maybe through Java Foundation API beans).

2) I am currently developing a new UI in ExtJS for Alfresco, so I am thinking to use alfresco in embedded deployment mode, i.e. I will connect my controller classes to Alfresco Java Core Foundation API, is this a correct approach? Why because not only my whole application is built in Java, but I want to reduce Alfresco footprints, and avoid unnecessary code also. As you have a lot lot more understanding about Alfresco's structure, I am asking your advice on this.

3) Can you suggest me some books/articles/websites or anythings which will give me more understanding about Java Foundation Services (i.e. Spring beans implementation) for doing my development.

4) I have checked out Alfresco SVN repository completely, but I am confused which projects should I use for my Embedded Alfresco deployment/development. Please suggest regarding the same, where can I find related information.

jpotts
World-Class Innovator
World-Class Innovator
1) Basically I want to add custom-metadata i.e. Properties to a document (properties which are not specified in my content model), apart from new Aspect/Content Model Creation, is there any other way of doing this?? i.e. Adding custom properties to a content (maybe through Java Foundation API beans).
You can set properties via the Java Foundation API if those properties are already defined in your content model. An exception to that is something called a "transient property", but those aren't documented very well and I don't know much about them. You'll have to hunt around to determine whether or not they will work for your particular use case.
2) I am currently developing a new UI in ExtJS for Alfresco, so I am thinking to use alfresco in embedded deployment mode, i.e. I will connect my controller classes to Alfresco Java Core Foundation API, is this a correct approach? Why because not only my whole application is built in Java, but I want to reduce Alfresco footprints, and avoid unnecessary code also. As you have a lot lot more understanding about Alfresco's structure, I am asking your advice on this.
I am a fan of de-coupling the repository from the front-end. Especially if you ever need to scale your solution. You want the flexibility to scale those tiers separately. I wouldn't embed the repository in your application unless you have a very good reason to do so.
3) Can you suggest me some books/articles/websites or anythings which will give me more understanding about Java Foundation Services (i.e. Spring beans implementation) for doing my development.
You'll know what meets your needs better than I will. The best I can do is point you to to the JavaDoc, the wiki, the official docs, and the Alfresco Developer Guide (2008, Packt). Beyond that you'll have to search.
4) I have checked out Alfresco SVN repository completely, but I am confused which projects should I use for my Embedded Alfresco deployment/development. Please suggest regarding the same, where can I find related information.
Look at the First Foundation Client example in the Alfresco SDK Eclipse project.

Good luck!

Jeff