dfc.tracing.enabled = false
dfc.tracing.recordParameters = on
dfc.tracing.recordReturnValue = on
dfc.tracing.stackDepth = 100
dfc.tracing.combineDMCL = on
dfc.tracing.dir = /tmp/dfclogs
Any further ideas how to trace the DQL? Then just post a comment to this article!
Wednesday, July 25, 2012
How to enable DQL tracing
I am currently analyzing some Documentum performance issues. To be able to reconstruct the problem maybe more easier or to check the database indexes it is useful to identify the problematic DQL queries. DQL is Documentum's Query Language. In fact a DQL statement is translated into an SQL one. The Documentum Administrator can return you the SQL for every running DQL. So what you need to get the DQL is to add the following lines to your dfc.properties file on side of your Content Server installation (E.G. ./product/6.5/shared/config/dfc.properties):
Wednesday, June 20, 2012
A simple pinboard dashlet
0.) Preamble
This example shows how you could develop simple Alfresco Dashlets. So here some requirements:
- A dashlet is required to see and post short messages
- Everybody should be able to post messages to the specific site where the dashlet is available.
1.) Define the Content Model
At first we need to define the content model for our pinboard entry type. The content model looks as the following:
<?xml version="1.0" encoding="UTF-8"?>
<!-- Model definition -->
<model name="ecg:pinboardmodel" xmlns="http://www.alfresco.org/model/dictionary/1.0">
<!-- Optional meta-data about the model -->
<description> The pinboard model </description>
<author> David Maier </author>
<version> 1.0 </version>
<!-- Imports are required to reference definitions in other models -->
<imports>
<import uri="http://www.alfresco.org/model/dictionary/1.0" prefix="d" />
<import uri="http://www.alfresco.org/model/content/1.0" prefix="cm" />
</imports>
<!-- The name space of our model -->
<namespaces>
<namespace uri="http://www.ecmgeek.de/model/content/1.0" prefix="ecg" />
</namespaces>
<!-- Content types -->
<types>
<!-- Default types -->
<type name="ecg:document">
<title>Document</title>
<parent>cm:content</parent>
</type>
<type name="ecg:folder">
<title>Folder</title>
<parent>cm:folder</parent>
</type>
<!-- Specific types -->
<type name="ecg:pinboardentry">
<title>PinboardEntry</title>
<parent>ecg:document</parent>
<properties>
<property name="ecg:subject">
<type>d:text</type>
</property>
<property name="ecg:description">
<type>d:text</type>
</property>
</properties>
</type>
</types>
</model>
You can see that we just extended the default types by deriving the type 'ecg:pinboardentry'.
I deployed the model by just adding it to the Data Dictionary.
2.) Prepare the site
The next step is to prepare the site which you would like to use. This I just created a subfolder 'pinBoard' inside the site's folder.
3.) Create Data Web Scripts
Two Web Scripts are required. One to add a pinboard entry to a specific site and another one to get all pinboard entries from a specific site.
3.1.) Add entry Web Script
Here the descriptor:
pinboardadd.get.desc.xml
<?xml version="1.0" encoding="UTF-8"?>
<webscript>
<shortname>Add Pinboard entry</shortname>
<description>To add a pinboard entry</description>
<url>/alfintra/pinboard/add?name={nameArgument}&desc={descArgument}&site={siteArgument}</url>
<format default="xml">extension</format>
<authentication>user</authentication>
<transaction>required</transaction>
</webscript>
And the Java Script controller:
pinboardadd.get.js/**
* Arguments
*/
//The target site name
var siteName = args["site"];
//The name of the future entry
var entryName = args["name"];
//The description of the future entry
var entryDesc = args["desc"];
/**
* Argument validation
*/
var siteFolder = companyhome.childByNamePath("Sites/" + siteName + "/pinBoard" );
if (siteFolder == undefined )
{
status.code = 404;
logger.log(status.code);
status.message = "The site's pinBoard folder was not found. Did you prepare your site in order to use the pinboard?";
logger.log(status.message);
status.redirect = true;
}
else
{
addPinboardEntry(siteFolder, entryName, entryDesc);
}
/**
* Script logic
*/
function addPinboardEntry(siteFolder, entryName, entryDesc)
{
logger.log("Entering addPinboardEntry");
logger.log("Setting properties");
var props = new Array();
props["ecg:subject"] = entryName;
props["ecg:description"]= entryDesc;
logger.log("Creating node");
siteFolder.createNode(entryName,"ecg:pinboardentry", props);
logger.log("Setting model");
model.created = "true";
logger.log("Leaving addPinboardEntry");
}
Finally the presentation template. This template shows nothing. It just redirects to the page from which the html page was called.
pinboardadd.get.html.ftl
<script type="text/javascript">
var ref = document.referrer;
location.replace(ref);
</script>
3.2.) Get entries Web Script
Here the descriptor:
pinboardlist.get.desc.xml
<?xml version="1.0" encoding="UTF-8"?>
<webscript>
<shortname>List pinboard entries</shortname>
<description>To list the pinboard entries of a site</description>
<url>/alfintra/pinboard/list?site={siteArgument}</url>
<format default="xml">extension</format>
<authentication>user</authentication>
<transaction>required</transaction>
</webscript>
The Java Script controller:
pinboardlist.get.js
/**
* Arguments
*/
//The target site name
var siteName = args["site"];
/**
* Argument validation
*/
var siteFolder = companyhome.childByNamePath("Sites/" + siteName + "/pinBoard" );
if (siteFolder == undefined )
{
status.code = 404;
logger.log(status.code);
status.message = "The site's pinBoard folder was not found.";
logger.log(status.message);
status.redirect = true;
}
else
{
listPinboardEntries(siteFolder);
}
function listPinboardEntries(siteFolder)
{
logger.log("Entering listPinboardEntries");
logger.log("Getting all childs");
model.entries = siteFolder.children;
logger.log("Leaving listPinboardEntries");
}
The JSON output:
pinboardlist.get.json.ftl
<#escape x as jsonUtils.encodeJSONString(x)>
{
"pinboard":
{
"entries":
[
<#list entries as node>
<#if node.properties["ecg:subject"]?exists>
<#if node.properties["ecg:description"]?exists>
{"name":"${node.properties['ecg:subject']}", "desc":"${node.properties['ecg:description']}", "site":"${args.site}"}
<#if node_has_next>,</#if>
</#if>
</#if>
</#list>
]
}
}
</#escape>
4.) Create the Dashlet
The idea is now that that the controller of the Web Script accesses the data which is provided by the data web script. The controller passes the data to the model and the presentation template renders it inside a dashlet. The content is presented within the dashlet's body container.
To create a new entry the URL of the 'Add Entry' Web Script is called as a form action. Here we do not use AJAX, instead a simple HTML form is used to call the entry creating Web Script. After this Web Script is called, it just redirects back to the previous page. By using additional Java Script inside the presentation template, it should be also possible to perform such an action without the need to redirect to the previous called page by refreshing this one. However, the dashlet shows how the interaction with the Data Web Scripts can basically work. The form is presented within the dashlet' toolbar container.
So what we need at first is a Dashlet Descriptor:
.../site-webscripts/de/ecmgeek/components/dashlets/pinboardlist.get.desc.xml
<webscript>
<shortname>List pinboard entries</shortname>
<description>To list pinboard entries</description>
<family>site-dashlet</family>
<url>/components/dashlets/pinboardlist</url>
</webscript>
We also need a controller which gets the data from our Data Web Script and passes it to the model:
.../site-webscripts/de/ecmgeek/components/dashlets/pinboardlist.get.js
var siteName = page.url.templateArgs.site;
var data = remote.call("/alfintra/pinboard/list.json?site=" + siteName);
var results = eval('(' + data + ')');
model.entries = results.pinboard.entries;
Finally we need to create the dashlet's UI. You could basically add any HTML which you want to the dashlet's html template. But to integrate better with Alfresco, you should at least define the following containers:
- dashlet
- toolbar
- body
If you want that your dashlet is resizable you should also instantiate an Alfresco Dashlet Resizer by using the following line inside a JavaScript block:
new Alfresco.widget.DashletResizer("${args.htmlid}", "${instance.object.id}");)
Interesting to know is that Alfresco Share comes with a Proxy servlet which allows you to access the Data Web Scripts of the Alfresco Repository. This proxy can be also used to avoid problems with the same origin policy if using client side Java Script to access the Data Web Script.
Our dashlet code looks now as the following:
.../site-webscripts/de/ecmgeek/components/dashlets/pinboardlist.get.html.ftl
<script type="text/javascript">//<![CDATA[//Make the dashlet resizeablenew Alfresco.widget.DashletResizer("${args.htmlid}", "${instance.object.id}");//]]></script><div class="dashlet"><div class="title">${msg("title")}</div><div class="toolbar"><form name="postToPinboardForm" method="get" action="/share/proxy/alfresco/alfintra/pinboard/add.html"><table><tr><td> ${msg("subject")} </td><td> ${msg("desc")} </td><td> </td></tr><tr><td> <input type="text" name="name"> </td><td> <input type="text" name="desc"> </td><td> <input type="hidden" name="site" value="${page.url.templateArgs.site}"></td><td> <input type="submit" value="Post"> </td></tr></table></form></div><div class="body scrollableList" id="${args.htmlid}-body"><table><#list entries as e><tr> <td> <b> ${e.name} </b> </td> </tr><tr> <td> ${e.desc} </td> </tr><tr> <td> </td> </tr></#list></table></div></div>
The template reads some properties from the following properties file (or message bundle):
.../site-webscripts/de/ecmgeek/components/dashlets/pinboardlist.get.properties
title=Pinboard
subject=Subjectdesc=Description
Even if this is not the most complicated dashlet, I hope that it may help you to get started with dashlet development. Finally the dashlet looks this way:
Tuesday, June 12, 2012
Theme it
Today I had to investigate how to add a custom theme to my Alfresco 4.x installation. Some parts were a bit tricky, but the most of it was quite simple. Here some useful steps:
- Navigate to $WEBAPPS/share/WEB-INF/classes/alfresco/site-data/themes . BTW: $WEBAPPS is the deployment folder of your servlet container.
- Copy the file yellowTheme.xml to myTheme.xml
- Edit the file myTheme.xml by setting the title and the id. The id has to be 'theme.myTheme'
- Navigate to $WEBAPPS/themes!
- Make a copy of the complete folder 'yellowTheme' by naming it to 'myTheme'.
- Naviagate to $WEBAPPS/themes/myTheme/images!
- Open all the images by using E.G. the G(nu) I(mage) M(anipulation) P(rogram) . The Command is 'gimp'. Then colorize the images to fit your required base color. I just colorized every image which had a yellow color before. The main loge image is named 'app_logo.png' and can be replaced by your prefered one.
- Navigate back to $WEBAPPS/themes/myTheme!
- Edit the file presentation.css by setting the required colors. Again, I just copied the color codes to GIMP by only replacing the yellow color tones with my prefered ones.
- Now the tricky part. There are some css dependencies those need to be changed inside this file. So just replace every occurrence of 'yellowTheme' with 'myTheme' inside this file.
- Naviagete to $WEBAPPS/themes/myTheme/yui/assets
- Inside the file 'skin.css', also replace every occurrence of 'yellowTheme' with 'myTheme'.
- Restart Alfresco
- Open Alfresco Share, create a new site and choose the entry 'myTheme' as the site theme.
- Perform some CSS changes by being able to test your changes immediately by refreshing the just created site.
- Open the Administration Console and set the theme 'myTheme' as the gloabl one.
Friday, April 27, 2012
Alfresco cloud service
Alfresco started a cloud service. More detailed it is is an instance of Alfresco Share which is avaiable in the WWW. The smallest offering is for FREE and it allows you to use Share functions like:
I just created an instance for magicable.de and created two user accounts. However both have to log-in to be able to see the content. So this service is not suitable for sharing your content accross the web. It's more for companies or cloesed communities those need to access and collaborate on their documents inside the web. So there seems to be no guest access to your Share instance in the cloud.
Unfortunately the free instance does not allow to access it via an API. So you can't use it as content repo in the web. As far as I understand this functionality will be available later for the paid version of it.
However, if you want to store some documents online (including meta data - this is something which can't drop box do for you), then Alfresco in the Cloud may be an alternative for you.
- The document library
- The dashboard
- Collaborate on documents
- Manage site members
I just created an instance for magicable.de and created two user accounts. However both have to log-in to be able to see the content. So this service is not suitable for sharing your content accross the web. It's more for companies or cloesed communities those need to access and collaborate on their documents inside the web. So there seems to be no guest access to your Share instance in the cloud.
Unfortunately the free instance does not allow to access it via an API. So you can't use it as content repo in the web. As far as I understand this functionality will be available later for the paid version of it.
However, if you want to store some documents online (including meta data - this is something which can't drop box do for you), then Alfresco in the Cloud may be an alternative for you.
Are we brain-washed?
In fact I am coming from the database world. This means I worked as an Engineer for the vendor of an relational database and also did Consulting for a No-SQL company. In both cases I had contact with ECM and related systems. So as I worked for Ingres I did Partner Certification work for systems like Alfresco and Liferay. In the past the system borders of an ECM system were very clear to me. So everything beyond the storage of just Meta Data was out of the scope of the Database System itself. I became a 'border liner' during my time as a Senior Consultant for a Graph Database System. The vertices could store not just meta data but also provide you a Content Stream. The system aimed to support unstructured data very well (as mentioned it supported Content streams and also something that was named Undefined Attribute). There were even Document Management use cases those were covered by this system. However ... . During my work with ECM, I realized that ECM companies understand themself more and more as Data Management companies. (Another point seems to be that today everything has to be Social or in the Cloud.) We tend to see everything as document. By definition a document is a set of properties thoses are used to store the meta data and the content itself. This raises questions like:
But what's if the answer is 'No'. In my opinion we should then not use an ECM/DM system to store such data, even if we want to do it because it seems to be close because there is already one available. Just use a Database System (NoSQL or Relational, whatever the use cases are requiring) to store the data regarding the required data model. Be not brain-wahsed! Do not belive that ECM solves all your Data Management problems and the answers to the above questions will be often (but not every time):
- Is a document without content really a document?
- Is really everything which has meta data and content a document?
- Is there a real paper document involved in a given use case?
- Are there some real workflows with real persons those are handling real documents?
- What should the person know about the document?
But what's if the answer is 'No'. In my opinion we should then not use an ECM/DM system to store such data, even if we want to do it because it seems to be close because there is already one available. Just use a Database System (NoSQL or Relational, whatever the use cases are requiring) to store the data regarding the required data model. Be not brain-wahsed! Do not belive that ECM solves all your Data Management problems and the answers to the above questions will be often (but not every time):
- A document without content should be an object in a datbase (row, vertex, ...).
- Not everything which has meta data and content is really a document!
Monday, April 16, 2012
Alfresco Web Scripts
A few days ago I talked about 'Server side Java Script'. This post describes a technique which is named 'Web Script' and explains for which purpose it could be useful. With Web Scripts Alfresco allows to easily deploy content oriented RESTFul Web Services to the Repository. The logic behind these services is then often realized by using Java Script.
A Web Script contains 4 pieces:
Let's begin by investigating the Desctiptor file in detail. Such an descriptor contains:
What we need next is to investigate the Java Script file. There are specifc naming conventions. So a Java Script which is accessible via HTTP GET should have an Descriptor and a Java Script file which is named as the following:
The Java Script file can contain basic Java Script (or even Java because it is interpreted by a Java based engine) and calls of the Alfresco Java Script API. Let me give you a short overview about this API. It is even useful if you want to implement Actions or Workflows for the Alfresco System. You can think about this Java Script API like a built in language to access Content. If you know Procedural Languages for Database Systems, then you know what I mean. Indeed, the possibilities those are provided by this API are quite beyond the ones of for instance PL/SQL. So even if you are not a Java Script guy, it should be possible to use the API. There are multiple versios of the API available. This article focuses on the 3.4 one.
A script can import another one:
The API provides some root objects. Those objects are available out of the box.
The Script Node API has the following important methods:
The properties attribute is an associative array. You can access it by using 'node.properties.propx' or 'node.properties["propx"]'.
Beyond the Script Node API there is also the "Modify and Creating" API. Here some important methods:
The content of the node was accessed by using the content attribute. This one provides the following API:
The search API allows you to search for specific documents. The following methods are part of the search API:
The people API allows to handle users those are stored inside Alfresco. Here the methods of it:
A special root object for Web Scripts is the one which is named 'model'. It allows you to set the result of the execution of you web script. Here an example:
Basically a freemarker template can be anything which is textual. So you can write it as html, as text as xml. The idea behind it is to use some static text with some dynamic text from the model. There is a whole language about this freemarker stuff. We just look on the most important parts:
The data model is a Tree and can be set. Every value which you access via a place holder is stored inside the data model. Everything which is not a leaf inside the data model's tree is named 'Hash'. The variables inside the tree those are storing single values (the leafs of the tree) are named 'Scalars'. You can navigate through the model's tree by using indexes. For instance 'animals[0].name'. Scalars are typed: String, Number, Date/Time, Boolean .
Sequences are lists of strings:
There are several directives. The 'if' directive looks as the following:
The list directive is used to itterate over elements of the data model.
The include directive can be used to insert content from another file to the template:
Let's now investigate how multiple languages are supported. The default message bundle is a properties-file with the following name:
A Web Script contains 4 pieces:
- A descriptor file
- A Java Script (or a Java Class)
- A freemarker template
- Language bundles
Let's begin by investigating the Desctiptor file in detail. Such an descriptor contains:
- The short name (shortname)
- The description (description)
- The url by including the parameters (url)
- The default format
- The authentication method
<webscript>
<shortname>Hello World</shortname>
<description>Greet a user</description>
<url>/helloworld?to={name?}</url>
<url>/hello/world?to={name?}</url>
<format default="html">extension</format>
<authentication>user</authentication>
</webscript>
Above you can see a Web Script which has the name 'Hello Word'. It 'Greets a user'. The URL is mapped to '/helloworld', whereby one Parameter 'to' is expected. The default response should be 'html' and a user authentication is required in order to execute the script. The value 'extension' means that the requested format is determined by the extension which is used as part of the URL. So for instance 'world.html' or 'world.txt'. As authentication the following values are possible: 'none', 'guest', 'user' or 'admin. Possible formats are: 'html', 'text', 'xml', 'atom', 'rss' or 'json'. There is an optional parameter which is named 'runas'. This parameter is used to execute the Web Script inside the context of another user's session. To be able to fully use this feature it is required that the Web Script is deployed in a static way. (We will talk about the deployment options later in this article.)What we need next is to investigate the Java Script file. There are specifc naming conventions. So a Java Script which is accessible via HTTP GET should have an Descriptor and a Java Script file which is named as the following:
- ${id}.${http method}.desc.xml
- ${id}.${http method}.js
The Java Script file can contain basic Java Script (or even Java because it is interpreted by a Java based engine) and calls of the Alfresco Java Script API. Let me give you a short overview about this API. It is even useful if you want to implement Actions or Workflows for the Alfresco System. You can think about this Java Script API like a built in language to access Content. If you know Procedural Languages for Database Systems, then you know what I mean. Indeed, the possibilities those are provided by this API are quite beyond the ones of for instance PL/SQL. So even if you are not a Java Script guy, it should be possible to use the API. There are multiple versios of the API available. This article focuses on the 3.4 one.
A script can import another one:
The example above shows a 'dynamic' import. Which means that the imported script is stored in Alfresco itself. It's also possible to just import from the classpath by using "classpath:${path to js}".
<import resource="/Company Home/Data Dictionary/Scripts/library.js">
The API provides some root objects. Those objects are available out of the box.
- companyhome: The company home root folder
- userhome: The current user's home folder
- person: The current user object
- search: The search API
- people: The people API
- actions: The action API
- logger: A logger
- session: Provides session specific information
- classification: The classification API
- utils: Some helpers
- groups: To access group authorities
- stites: The sites API
The Script Node API has the following important methods:
- properties
- children
- assocs
- aspects
- content
- id
- nodeRef
- name
- type
- parents
- childByNamePath
- getSite
The properties attribute is an associative array. You can access it by using 'node.properties.propx' or 'node.properties["propx"]'.
Beyond the Script Node API there is also the "Modify and Creating" API. Here some important methods:
- createFile
- createFolder
- createNode
- addNode (as child)
- removeNode (remove child assocs)
- createAssociation
- move
- copy
- addAspect
- checkout
- checkin
- cancelCheckout
- isVersioned
- versionHistory
- getVersion
- createdDate
- creator
- label
- type
- descrption
- nodeRef
- node
The content of the node was accessed by using the content attribute. This one provides the following API:
- mimetype
- encoding
- size
- url
- downloadURL
The search API allows you to search for specific documents. The following methods are part of the search API:
- luceneSearch
- xpathSearch
- savedSearch
- findNode (by given node reference)
- query (by using an object which consists a search method and the search query)
var query = {query: "SELECT e.* FROM ecg:mytype AS e WHERE e.ecg:myprop=" + myvar, language: "cmis-alfresco"};
The people API allows to handle users those are stored inside Alfresco. Here the methods of it:
- createPerson
- deletePerson
- getGroup
- createGroup
- parentGroup
- getMembers
- isAdmin
- changePassword
- setPassword
var myaction = create("myaction");The classification API provides the following methods:
myaction.parameters.myparam = 'myvalue';
myaction.execute;
- getAllCategoryNodes
- getAllClassificationAspects
- createRootCategory
- isCategory
- categoryMembers
- subCategories
- createSubCategory
- removeCategory
A special root object for Web Scripts is the one which is named 'model'. It allows you to set the result of the execution of you web script. Here an example:
var username = person.properties.userName;The model object is used to transfer data from the controlling Web Script to the Freemarker template. So let's take a closer look on Freemarker templates!
model.username = username;
Basically a freemarker template can be anything which is textual. So you can write it as html, as text as xml. The idea behind it is to use some static text with some dynamic text from the model. There is a whole language about this freemarker stuff. We just look on the most important parts:
- Place holders
- Data model
- Variables and Types
- Sequences
- Directives
- Comments
- Built-ins
The data model is a Tree and can be set. Every value which you access via a place holder is stored inside the data model. Everything which is not a leaf inside the data model's tree is named 'Hash'. The variables inside the tree those are storing single values (the leafs of the tree) are named 'Scalars'. You can navigate through the model's tree by using indexes. For instance 'animals[0].name'. Scalars are typed: String, Number, Date/Time, Boolean .
Sequences are lists of strings:
["myval1", ... , "myvaln"]
There are several directives. The 'if' directive looks as the following:
<#if myvar = "mystringval"> My text <#else> My other text </#if>Possible operators are: <, >, !=, = .
The list directive is used to itterate over elements of the data model.
<# list myhashvar as myvar> ${myvar.myscalarvar} </#list>
<# list myseq as myvar> ${myvar} </#list>
The include directive can be used to insert content from another file to the template:
<#include "/myfile.html">It is possible to create user defined directives the following way:
<@mydirective myparam1=myval1, ... myparamn=myvaln>
<#-- Some commands --#>
</@mydirective>Comments are used the following way:
<#-- My comment --#>The following built in functions are available:
- myvar!"My optional value": Uses the optional value if myvar is not set
- myvar??: Returns true if myvar is set
- myvar?upper_case: Returns the variable value in upper case letters
- myvar?cap_first: Converts the first letter to upper case
- myvar?trim
- myvar?size
- myvar?int: The integer part of a number (E.G. 5 in case of 5.432)
- myvar?string_short: Date to String conversion
- myvar?foo:string : Boolean to Strng conversion
Let's now investigate how multiple languages are supported. The default message bundle is a properties-file with the following name:
- ${id}.${http method}.properties
- ${id}.${method}_${locale}.properties
${msg("myprop")}So the final question of this article is: How can I deploy and use such a Web Script. There are multiple ways to deploy a web script:
- Dynamic deployment: To the Content Repository itself. Which mean you need to import it to 'Data Dictionary/Web Scripts' or 'Data Dictionary/Web Script Extensions' (The second folder should be used to override scripts from the first folder for testing purposes.)
- Static deployment by copying the folder which contains the Web Script files to ${CATALINA_HOME}/webapps/alfresco/WEB-INF/classes/alfresco/templates/webscripts. This can be simplified by bundling the Web Script into an Alfresco Module Package.
- Extension deployment by copying the folder which contains the Web Script files to ${CATALINA_HOME}/shared/classes/alfresco/extension/templates/webscripts
- Navigate to 'http://${myhost}:8080/alfresco/service/index'
- Click on the 'Refresh Web Scripts' button
Sunday, March 11, 2012
Server side JavaScript
I really do not like the idea to use server side Java Script. In fact I
am really hating Java Script even on the client side. I everytime worked
arround even the client side one by using the GWT framework. (GWT
allows you to write Java code which will become translated to
JavaScript. So my question was "Why the hell should anybody like to have
server side Java Script?". There two different answers from two
different perspectives:
- As a Developer for Alfresco, you just need (not really you can also use the more complicated Java API) to know that it is existent, because they invented something which is called WebScript.
- Because it is interpreted code, it is really more flexible. So you can just change it on runtime. A JavaScript engine then is used to just execute your code. Such an engine is E.G. Rhino
WebScripts
A WebScript is just a JavaScript file which can be accessed as a RESTFul service. It sets some output model which is then used together with a Freemarker template to generate the response. So it is following a Model View Controller concept. The WebScript takes the role of the controller. It has access to a model. A freemarker template is used for the View. (This could be HTML or just JSON or plain TXT) A WebScript has access to Alfresco-s JavaScript API. (http://wiki.alfresco.com/wiki/3.4_JavaScript_API). So it can access content by providing some output (E.G. the content properties as XML). The advantage is that you can just deploy content oriented RESTFul Web Services without the need to restart your Servlet-Container or Application server. Alfresco is using it quite often, even for their Share-Dahslets. Meanwhile it also became added to the Spring Web-Framework (http://www.springsource.org/extensions/se-surf)
Rhino
Rhino is a JavaScript engine which is implemented in Java. You can just use it to extend your own Java application to support JavaScript. Further information are available here: http://www.mozilla.org/rhino/
What's your opinion about server side JavaScript? Just give me some comments!
Subscribe to:
Posts (Atom)
