cancel
Showing results for 
Search instead for 
Did you mean: 

Adding info to documents

fabernate
Champ in-the-making
Champ in-the-making
Hello

I have red many articles about how add informations to documents:
sombody tells to add an xml file into the directory tomcat\webapps\share\WEB-INF\classes\alfresco\web-extension\share-config-custom.xml
so that I can create aspect, but it doesn't work.

somebody tells to use AlfrescoDocument extension lib.

For example I want to add the information RESULT to a resumè document in JAVA without open it. i.e. RESULT = 'PASSED'

how can I do that.

more, what's the CATEGORY tab in the alfresco site ? can I manage it from JAVA ?

THANKS

Fabio
5 REPLIES 5

jpotts
World-Class Innovator
World-Class Innovator
If you are trying to set a piece of metadata you must first decide which property you are going to set. Out-of-the-box, Alfresco provides a standard content model that has properties you can set. For example, you might want to set RESULT = 'passed' as part of the title or part of the description.

Most commonly your code will run remote from the Alfresco server. You've said Java is a requirement so you will want to use OpenCMIS (ships with Alfresco 4 or download from Apache Chemistry) to connect to Alfresco to make your update. Examples showing how to update both properties and content from Java using OpenCMIS live here.

Be aware that many properties you will want to set are defined in "aspects" rather than "types". CMIS 1.0 lacks support for aspects, so in addition to OpenCMIS you'll want the OpenCMIS Extension for Alfresco. This also ships with Alfresco 4 or you can find it on Google Code.

If you want to set a property that isn't defined in the out-of-the-box content model, you can extend the out-of-the-box content model to add your own custom types and aspects. Then you can set them as discussed above. When you do extend the content model, if you want to be able to set those properties through the Alfresco user interface, you must configure the user interface, which is why you've come across share-config-custom.xml–that's purely for configuring the Share user interface.

A good resource for learning how to extend the content model, configure the user interface, and create, update, delete, and query for objects via the CMIS API is this tutorial. It includes source code you can use on your project.

Finally, you mentioned category. Categories are part of a controlled vocabulary classification that can be added to a document to help organize your content regardless of how they are stored in the folder structure. Categories can be manipulated via both Java and JavaScript. Categories can not be managed, set, or read via CMIS. If you need to manipulate categories remotely, you'll have to write a web script and then invoke that from your application.

I hope this sheds some light on what you are trying to do and gets you pointed in the right direction.

Jeff

fabernate
Champ in-the-making
Champ in-the-making
Dear Jeff

so I am going to re-study how add custom property via xml file.
But I need to know something else about:

1) If I use the config.xml way, do I need to use AlfrescoDocument.class or I can go on just with OpenCMis !?

2) then how can files keep the information ? if I download the file and/or re-upload/update to Alfresco or to another alfresco which
doesn't have the config file and then re-moved to the original place, will the information be available anyway ?

3) if the config xml was made by just these tags (and the required tags as config etc etc), would it be right ?

<aspects>
        <aspect name="zz:attributes">
            <title>More Attributes</title>
            <properties>
                <property name="zz:docType">
                    <type>dSmiley Frustratedtring</type>
                </property>
                <property name="zz:refId">
                    <type>dSmiley Frustratedtring</type>
                </property>
            </properties>
        </aspect>

jpotts
World-Class Innovator
World-Class Innovator
1) If I use the config.xml way, do I need to use AlfrescoDocument.class or I can go on just with OpenCMis !?
I'm confused about what you are asking here.
2) then how can files keep the information ? if I download the file and/or re-upload/update to Alfresco or to another alfresco which
doesn't have the config file and then re-moved to the original place, will the information be available anyway ?
In Alfresco, an object contains both the metadata and the content stream. Under-the-covers, the metadata lives in the relational database and the file lives on the file system, but as a developer you don't see that distinction–you just see an object. If you upload a new version of the content stream it does not change the metadata that is stored on the object. If you move the object to another folder it does not change the metadata that is stored on the object either. The only way you'd lose the metadata is if you deleted the object and then created a new one.
3) if the config xml was made by just these tags (and the required tags as config etc etc), would it be right ?
The XML you have in your post looks like a correct XML snippet from a larger Alfresco content model file, except that instead of dSmiley Frustratedtring you should use d:text. If you need to see the full content model file, refer to the source code that accompanies the tutorial referenced earlier in the thread.

Jeff

fabernate
Champ in-the-making
Champ in-the-making
Hi Jeff,
I am a little bit confused, please have patient.

1) I think that AlfrescoDocument class manage their extensions and their attributes, but I need the mine so I keep on using only the OpenCMIS
library instead of use ALfrescoExtension lib as well.

2) I imaged this answer.

3) I just need to add those attributes, nothing else….. at most I may need to VIEW if possible those value on line with AlfrescoExplorer.
shall I add something else for this ??? this part of Alfresco is more hard to work, please have patient.

Thanks Jeff, very kind!!!

Regards
Fabio

jpotts
World-Class Innovator
World-Class Innovator
AlfrescoDocument is what you use when you are using the Alfresco OpenCMIS Extensions JAR. It is required when you are working with aspect-defined properties.

If you extend Alfresco's content model and you use nothing but types, then there is no need to use the Alfresco object factory class that is part of the OpenCMIS Extensions. When everything is in a type, you can work with it using straight CMIS.

Jeff