cancel
Showing results for 
Search instead for 
Did you mean: 

Metadata Manipulation Via Web Scripts

whitewizard
Champ in-the-making
Champ in-the-making
Hi,

I am working on producing a Java based GUI to Alfresco using web scripts to provide access to the repository. I am struggling to find any documentation or examples of the creation/manipulation of metadata using the Javascript API. If someone could point me in the right direction, it would be greatly appreciated.

Thanks
9 REPLIES 9

mikeh
Star Contributor
Star Contributor

whitewizard
Champ in-the-making
Champ in-the-making
Thank you very much. I have no idea how I missed that page…

whitewizard
Champ in-the-making
Champ in-the-making
Thank you, I now have a complete grasp on how to retrieve and update metadata. I was wondering if there was a way to list all the content models, and the properties they have, via the Javacript API. I can't seem to find anything along those lines.

schambon
Champ in-the-making
Champ in-the-making
What you want is the DictionaryService from the java API.

As far as I'm aware the dictionary service is not exposed to JavaScript. Just extend the JS runtime with the Dictionary Service and run from there. Just read this: http://wiki.alfresco.com/wiki/3.0_JavaScript_API#Native_Java_API_Access and linked pages and follow the procedure.

whitewizard
Champ in-the-making
Champ in-the-making
Thank you very much for your help.

I have written a Java class that I believe will expose the DictionaryService object to the Javascript API, but I am unsure as to where I need to put it in the directory structure, and how to tell alfresco to use it. I know that I need to use something along the lines of:
<bean id="JavascriptCompatibleDictionaryService" parent="baseJavaScriptExtension" class="ext.packagename.JavaCompatibleDictionaryService">
    <property name="extensionName">
        <value>dictionaryservice</value>
    </property>
</bean>

But again, I am unsure where to put this. Any pointers would be greatly appreciated, and I'm terribly sorry if I am missing the obvious.

schambon
Champ in-the-making
Champ in-the-making
Hi,

You need to put this XML excerpt in a *-context.xml file in (typically) tomcat/shared/classes/alfresco/extension

For instance you'd have : dictionary-service-extension-context.xml in there that would contain:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING/DTD BEAN//EN"
   "http://www.springframework.org/dtd/spring-beans.dtd">
<beans>
  <bean id="JavascriptCompatibleDictionaryService" parent="baseJavaScriptExtension" class="ext.packagename.JavaCompatibleDictionaryService">
    <property name="extensionName">
        <value>dictionaryservice</value>
    </property>
  </bean>
</beans>

Now you should be able to access the dictionary service's API through the JavaScript object "dictionaryservice".

whitewizard
Champ in-the-making
Champ in-the-making
Thank you very much. Alfresco is now looking for my class, but it is unable to find it. I've tried placing it in a .jar inside the /tomcat/shared/classes/alfresco/extensions and /tomcat/lib directories, but neither have worked. Any advice? Sorry to keep asking these questions >_<

schambon
Champ in-the-making
Champ in-the-making
Hi,

Drop your jar in this directory: tomcat/webapps/alfresco/WEB-INF/lib

(you could try in tomcat/shared/lib but you'd have to check the Tomcat configuration in catalina.properties; and it may not work due to class loading issues.)

Sylvain.

whitewizard
Champ in-the-making
Champ in-the-making
You, my good sir, are stunning. Thanks for all your help.